# How to define a TT-cross implementation using ITensors without usage of for loops

**URL:** https://discourse.julialang.org/t/how-to-define-a-tt-cross-implementation-using-itensors-without-usage-of-for-loops/105472
**Category:** Quantum
**Tags:** itensors, itensor
**Created:** [October 27, 2023, 8:58am UTC](https://discourse.julialang.org/t/how-to-define-a-tt-cross-implementation-using-itensors-without-usage-of-for-loops/105472 "2023-10-27T08:58:03Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![matinator](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/matinator/32/202765_2.png) [@matinator](https://discourse.julialang.org/u/matinator)
#### Post date: [October 27, 2023, 8:58am UTC](https://discourse.julialang.org/t/how-to-define-a-tt-cross-implementation-using-itensors-without-usage-of-for-loops/105472/1 "2023-10-27T08:58:03Z")

</div>

Hello everyone I was trying to define the following ket state from a paper which has the following equation:  
 ![immagine](https://global.discourse-cdn.com/julialang/original/3X/1/d/1d53552528fe9222333fd5fafd58cb15cbcea3c7.png)  
where \varphi is a complex valued function, the only way I was able to produce this is by the usage of the following code for a 3d case:

```julia
i = Index(N,"i")
j = Index(N,"j")
k = Index(N,"k")
p = ITensor(i,j,k)
for iv in eachindex(p)
    j = collect(Tuple(iv) .- N/2)
    p[iv] = phi(-eta .*j .- im *alpha)
end

```

Is it possible to avoid the for loop and use the formalism of the ITensor to provide a TT-train approximation of such quantity?  
For example if I use the [tntorch](https://tntorch.readthedocs.io/en/latest/api.html#module-cross) python library I can use a lambda function to define it:

```julia
tn.cross(function=lambda x: x**2, tensors=[t]) # Compute the element-wise square of `t` using 5 TT-ranks

```
