Skip to content

Commit

Permalink
Add reset_index kwarg
Browse files Browse the repository at this point in the history
  • Loading branch information
jofrevalles committed Nov 29, 2024
1 parent 07534eb commit 231bcc5
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/MPS.jl
Original file line number Diff line number Diff line change
Expand Up @@ -543,13 +543,23 @@ function mixed_canonize!(tn::AbstractMPO, orthog_center)
end

"""
evolve!(ψ::AbstractAnsatz, mpo::AbstractMPO; threshold=nothing, maxdim=nothing, normalize=true)
evolve!(ψ::AbstractAnsatz, mpo::AbstractMPO; threshold=nothing, maxdim=nothing, normalize=true, reset_index=true)
Evolve the [`AbstractAnsatz`](@ref) `ψ` with the [`AbstractMPO`](@ref) `mpo` along the output indices of `ψ`.
If `threshold` or `maxdim` are not `nothing`, the tensors are truncated after each sweep at the proper value.
If `threshold` or `maxdim` are not `nothing`, the tensors are truncated after each sweep at the proper value, and the
bond is normalized if `normalize=true`. If `reset_index=true`, the indices of the `ψ` are reset to the original ones.
"""
function evolve!::AbstractAnsatz, mpo::AbstractMPO; threshold=nothing, maxdim=nothing, normalize=true)
function evolve!::AbstractAnsatz, mpo::AbstractMPO; threshold=nothing, maxdim=nothing, normalize=true, reset_index=true)
original_sites = copy(Quantum(ψ).sites)
evolve!(form(ψ), ψ, mpo; threshold, maxdim, normalize)

if reset_index
resetindex!(Quantum(ψ); init=ninds(TensorNetwork(ψ))+1)

replacements = [(Quantum(ψ).sites[key] => original_sites[key]) for key in keys(original_sites)]
replace!(Quantum(ψ), replacements)
end

return ψ
end

Expand Down

0 comments on commit 231bcc5

Please sign in to comment.