I am trying to achieve the ITensor equivalent of the following
@tensor R2[a,b,i,j] := I_vvoo[a,b,i,j] + I_vvoo[b,a,j,i]
in the above snippet, I am using TensorOperations.jl and all the entities are Array{Float64,4}
. I am trying to achieve the same when I_vvoo
is an ITensor
with indices a_1,a_2,i_1,i_2
. I came across the permute
function which I though was what I needed and wrote
R = I_vvoo + permute(I_vvoo,a_2,a_1,i_2,i_1)
However, these two yeild different results (the later former being what the result should be). A minimal example of the above is the follows
I_vvoo = rand(Float64,2,2,4,4)
begin
a_1 = Index(2,"a_1")
a_2 = Index(2,"a_2")
i_1 = Index(4,"i_1")
i_2 = Index(4,"i_2")
end
iI_vvoo = ITensor(I_vvoo,a_1,a_2,i_1,i_2)
iR = iI_vvoo + permute(iI_vvoo,a_2,a_1,i_2,i_1)
@tensor R[a,b,i,j] := I_vvoo[a,b,i,j] + I_vvoo[b,a,j,i]
Array(iR,a_1,a_2,i_1,i_2) - R
If everything went as expected, the last expression should have resulted in a zero tensor. But it does not.