Skip to content

Commit 4176bcb

Browse files
committed
Fix normalization for Gamma tensors
1 parent e2a257f commit 4176bcb

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

src/MPS.jl

+20-7
Original file line numberDiff line numberDiff line change
@@ -729,15 +729,28 @@ end
729729

730730
# this method just normalizes the Λ tensors
731731
function LinearAlgebra.normalize!(::Canonical, ψ::AbstractMPO; bond=nothing)
732-
if isnothing(bond)
733-
for i in 1:(nlanes(ψ) - 1)
734-
Λ = tensors(ψ; bond=(Lane(i), Lane(i + 1)))
735-
normalize!(Λ)
736-
end
737-
else
738-
Λ = tensors(ψ; bond)
732+
if !isnothing(bond)
733+
# Λ = tensors(ψ; bond)
734+
# normalize!(Λ)
735+
error("Forced normalization of just one bond is not implemented yet")
736+
end
737+
738+
# normalize the Λ tensors
739+
for i in 1:(nlanes(ψ) - 1)
740+
Λ = tensors(ψ; bond=(Lane(i), Lane(i + 1)))
739741
normalize!(Λ)
740742
end
741743

744+
# normalize the Γ tensors
745+
for i in 2:(nlanes(ψ) - 1)
746+
Γ = tensors(ψ; at=Lane(i))
747+
Λᵢ₋₁ = tensors(ψ; bond=(Lane(i - 1), Lane(i)))
748+
Λᵢ₊₁ = tensors(ψ; bond=(Lane(i), Lane(i + 1)))
749+
750+
# NOTE manual binary contraction due to bugs in `contract(args...)`
751+
Z = norm(contract(contract(Γ, Λᵢ₋₁; dims=Symbol[]), Λᵢ₊₁; dims=Symbol[]))
752+
Γ ./= Z
753+
end
754+
742755
return ψ
743756
end

0 commit comments

Comments
 (0)