Skip to content
This repository has been archived by the owner on Jul 7, 2024. It is now read-only.

Commit

Permalink
Refactor canonize_site!
Browse files Browse the repository at this point in the history
  • Loading branch information
mofeing committed Feb 22, 2024
1 parent 754ca92 commit 9a20417
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/Ansatz/Chain.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 9a20417

Please sign in to comment.