From 9a204178acaffc22fe17de50474debdfe59a4115 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20S=C3=A1nchez=20Ram=C3=ADrez?= Date: Thu, 22 Feb 2024 16:53:18 +0100 Subject: [PATCH] Refactor `canonize_site!` --- src/Ansatz/Chain.jl | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Ansatz/Chain.jl b/src/Ansatz/Chain.jl index 55e4d27..25b97e7 100644 --- a/src/Ansatz/Chain.jl +++ b/src/Ansatz/Chain.jl @@ -153,18 +153,18 @@ function canonize_site!(::Open, tn::Chain, site::Site; direction::Symbol, method right_inds = Symbol[] virtualind = if direction === :left - site == Site(nsites(tn)) && throw(ArgumentError("Cannot left-canonize right-most tensor")) - push!(right_inds, rightindex(tn, site)) + site == Site(1) && throw(ArgumentError("Cannot right-canonize left-most tensor")) + push!(left_inds, leftindex(tn, site)) - site == Site(1) || push!(left_inds, leftindex(tn, site)) - push!(left_inds, Quantum(tn)[site]) + site == Site(1) || push!(right_inds, rightindex(tn, site)) + push!(right_inds, Quantum(tn)[site]) - only(right_inds) + only(left_inds) elseif direction === :right - site == Site(1) && throw(ArgumentError("Cannot right-canonize left-most tensor")) - push!(right_inds, leftindex(tn, site)) + site == Site(nsites(tn)) && throw(ArgumentError("Cannot left-canonize right-most tensor")) + push!(right_inds, rightindex(tn, site)) - site == Site(nsites(tn)) || push!(left_inds, rightindex(tn, site)) + site == Site(nsites(tn)) || push!(left_inds, leftindex(tn, site)) push!(left_inds, Quantum(tn)[site]) only(right_inds)