ITensors.jl
ITensors.jl copied to clipboard
Generalize `inner(::MPO, ::MPS, ::MPO, ::MPS)` for arbitrary tags
This currently fails:
using ITensors
s = siteinds("S=1/2", 3)
A = MPO(s, "Id")
A = noprime(replacetags(A, "Site" => "X"; plev = 1))
ψ = randomMPS(s)
inner(A, ψ, A, ψ)
with an error:
ERROR: MethodError: no method matching prime(::Nothing, ::Int64)
Closest candidates are:
prime(::Index, ::Int64) at /home/mfishman/.julia/dev/ITensors/src/index.jl:374
prime(::IndexVal, ::Integer) at /home/mfishman/.julia/dev/ITensors/src/index.jl:535
prime(::IndexSet, ::Integer, ::Any...; kwargs...) at /home/mfishman/.julia/dev/ITensors/src/indexset.jl:810
...
Stacktrace:
[1] dot(::MPO, ::MPS, ::MPO, ::MPS; make_inds_match::Bool) at /home/mfishman/.julia/dev/ITensors/src/mps/mpo.jl:233
[2] dot at /home/mfishman/.julia/dev/ITensors/src/mps/mpo.jl:217 [inlined]
[3] inner(::MPO, ::MPS, ::MPO, ::MPS) at /home/mfishman/.julia/dev/ITensors/src/mps/mpo.jl:247
[...]
since inner(::MPO, ::MPS, ::MPO, ::MPS)
currently assumes the MPO has pairs of primed and unprimed indices with "Site"
tags. This would be very useful to generalize (for example, when using an LPDO representing an MPDO in the form X*X†
).
The issue with relying on the "Site"
tags would be solved by replacing
https://github.com/ITensor/ITensors.jl/blob/a5733fc4433e1accbca1a5ac0593d73e424442df/src/mps/mpo.jl#L430
with
ABcommon = uniqueind(siteinds(A, j), IndexSet(Axcommon))
I believe, which should then work for arbitrary tags. Is this all you meant, or were you implying that the assumptions on the prime structure of the MPO
s should also be relaxed?
In principle it shouldn't depend on any tag or prime conventions, it should just require that for inner(A, x, B, y)
:
-
A
andx
share site indices. -
B
andy
share site indices. -
A * x
andB * y
share site indices.