I was reading the docs on in place operations and have a few questions.
Firstly, suppose I have two tensors one rank 4 and the other a square rank 2. If we contact these, the resulting tensor has the same shape as the origional rank 4 but with a differing index. Can someone explain the reason behind this error? How would I go about doing a in place contraction like this, if it is possible.
julia> A
ITensor ord=4 (dim=100|id=563) (dim=100|id=563)' (dim=100|id=563)'' (dim=100|id=563)'''
NDTensors.Dense{Float64, Vector{Float64}}
julia> B
ITensor ord=2 (dim=100|id=563)''' (dim=100|id=563)'4
NDTensors.Dense{Float64, Vector{Float64}}
julia> C = A * B
ITensor ord=4 (dim=100|id=563) (dim=100|id=563)' (dim=100|id=563)'' (dim=100|id=563)'4
NDTensors.Dense{Float64, Vector{Float64}}
julia> C += A * B
ITensor ord=4 (dim=100|id=563) (dim=100|id=563)' (dim=100|id=563)'' (dim=100|id=563)'4
NDTensors.Dense{Float64, Vector{Float64}}
julia> C .+= A .* B
ERROR: You are trying to add an ITensor with indices:
((dim=100|id=563), (dim=100|id=563)', (dim=100|id=563)'', (dim=100|id=563)''')
into an ITensor with indices:
((dim=100|id=563), (dim=100|id=563)', (dim=100|id=563)'', (dim=100|id=563)'4)
but the indices are not permutations of each other.
Stacktrace:
[1] error(s::String)
@ Base .\error.jl:35
[2] _map!!(f::Function, R::NDTensors.DenseTensor{Float64, 4, NTuple{4, Index{Int64}}, NDTensors.Dense{Float64, Vector{Float64}}}, T1::NDTensors.DenseTensor{Float64, 4, NTuple{4, Index{Int64}}, NDTensors.Dense{Float64, Vector{Float64}}}, T2::NDTensors.DenseTensor{Float64, 4, NTuple{4, Index{Int64}}, NDTensors.Dense{Float64, Vector{Float64}}})
@ ITensors C:\Users\Oliver\.julia\packages\ITensors\HjjU3\src\itensor.jl:1900
[3] map!(f::Function, R::ITensor, T1::ITensor, T2::ITensor)
@ ITensors C:\Users\Oliver\.julia\packages\ITensors\HjjU3\src\itensor.jl:1926
[4] copyto!
@ C:\Users\Oliver\.julia\packages\ITensors\HjjU3\src\broadcast.jl:487 [inlined]
[5] materialize!
@ .\broadcast.jl:871 [inlined]
[6] materialize!(dest::ITensor, bc::Base.Broadcast.Broadcasted{ITensors.ITensorStyle, Nothing, typeof(+), Tuple{ITensor, Base.Broadcast.Broadcasted{ITensors.ITensorStyle, Nothing, typeof(*), Tuple{ITensor, ITensor}}}})
@ Base.Broadcast .\broadcast.jl:868
[7] top-level scope
@ REPL[31]:1
I’m using ITensors@0.3.34 in Julia@1.8.5