About the movesite
function, the source code is:
"""
movesite(::Union{MPS, MPO}, n1n2::Pair{Int, Int})
Create a new MPS/MPO where the site at `n1` is moved to `n2`,
for a pair `n1n2 = n1 => n2`.
This is done with a series a pairwise swaps, and can introduce
a lot of entanglement into your state, so use with caution.
"""
function movesite(
ψ::AbstractMPS, n1n2::Pair{Int,Int}; orthocenter::Integer=last(n1n2), kwargs...
)
n1, n2 = n1n2
n1 == n2 && return copy(ψ)
ψ = orthogonalize(ψ, n2)
r = n1:(n2 - 1)
ortho = "left"
if n1 > n2
r = reverse(n2:(n1 - 1))
ortho = "right"
end
for n in r
ψ = swapbondsites(ψ, n; ortho=ortho, kwargs...)
end
ψ = orthogonalize(ψ, orthocenter)
return ψ
end
In this code, I can’t understand why we initially need to move the orthocenter to n2
rather than n1
. In my opinion, when we need the site at n1
to be moved to n2
, we first should move the orthocenter to n1
, and then move the orthocenter to the right (when n1 < n2
, and vice versa.) step-by-step by using swapbondsites
function.