@@ -19,7 +19,7 @@ const FiniteMPO{O<:MPOTensor} = MPO{O,Vector{O}}
1919
2020function FiniteMPO (Os:: AbstractVector{O} ) where {O<: MPOTensor }
2121 for i in eachindex (Os)[1 : (end - 1 )]
22- dual ( right_virtualspace (Os[i]) ) == left_virtualspace (Os[i + 1 ]) ||
22+ right_virtualspace (Os[i]) == left_virtualspace (Os[i + 1 ]) ||
2323 throw (SpaceMismatch (" unmatching virtual spaces at site $i " ))
2424 end
2525 return FiniteMPO {O} (Os)
@@ -38,7 +38,7 @@ const InfiniteMPO{O<:MPOTensor} = MPO{O,PeriodicVector{O}}
3838
3939function InfiniteMPO (Os:: AbstractVector{O} ) where {O<: MPOTensor }
4040 for i in eachindex (Os)
41- dual ( right_virtualspace (Os[i]) ) == left_virtualspace (Os[mod1 (i + 1 , end )]) ||
41+ right_virtualspace (Os[i]) == left_virtualspace (Os[mod1 (i + 1 , end )]) ||
4242 throw (SpaceMismatch (" umatching virtual spaces at site $i " ))
4343 end
4444 return InfiniteMPO {O} (Os)
@@ -139,8 +139,8 @@ function Base.convert(::Type{TensorMap}, mpo::FiniteMPO)
139139 U_left = ones (scalartype (mpo), V_left)'
140140
141141 V_right = right_virtualspace (mpo, length (mpo))
142- @assert V_right == oneunit (V_right)'
143- U_right = ones (scalartype (mpo), V_right' )
142+ @assert V_right == oneunit (V_right)
143+ U_right = ones (scalartype (mpo), V_right)
144144
145145 tensors = vcat (U_left, parent (mpo), U_right)
146146 indices = [[i, - i, - (2 N - i + 1 ), i + 1 ] for i in 1 : length (mpo)]
@@ -166,10 +166,10 @@ function Base.:+(mpo1::FiniteMPO{TO}, mpo2::FiniteMPO{TO}) where {TO}
166166 A = storagetype (TO)
167167
168168 # left half
169- F₁ = isometry (A, (right_virtualspace (mpo1, 1 ) ⊕ right_virtualspace (mpo2, 1 ))' ,
170- right_virtualspace (mpo1, 1 )' )
169+ F₁ = isometry (A, (right_virtualspace (mpo1, 1 ) ⊕ right_virtualspace (mpo2, 1 )),
170+ right_virtualspace (mpo1, 1 ))
171171 F₂ = leftnull (F₁)
172- @assert _lastspace (F₂) == right_virtualspace (mpo2, 1 )
172+ @assert _lastspace (F₂) == right_virtualspace (mpo2, 1 )'
173173
174174 @plansor O[- 3 - 1 - 2 ; - 4 ] := mpo1[1 ][- 1 - 2 ; - 3 1 ] * conj (F₁[- 4 ; 1 ]) +
175175 mpo2[1 ][- 1 - 2 ; - 3 1 ] * conj (F₂[- 4 ; 1 ])
@@ -184,10 +184,10 @@ function Base.:+(mpo1::FiniteMPO{TO}, mpo2::FiniteMPO{TO}) where {TO}
184184 @plansor O₂[- 1 - 2 ; - 3 - 4 ] := R[- 1 ; 1 ] * F₂[1 ; 2 ] * mpo2[i][2 - 2 ; - 3 - 4 ]
185185
186186 # incorporate fusers from right side
187- F₁ = isometry (A, (right_virtualspace (mpo1, i) ⊕ right_virtualspace (mpo2, i))' ,
188- right_virtualspace (mpo1, i)' )
187+ F₁ = isometry (A, (right_virtualspace (mpo1, i) ⊕ right_virtualspace (mpo2, i)),
188+ right_virtualspace (mpo1, i))
189189 F₂ = leftnull (F₁)
190- @assert _lastspace (F₂) == right_virtualspace (mpo2, i)
190+ @assert _lastspace (F₂) == right_virtualspace (mpo2, i)'
191191 @plansor O[- 3 - 1 - 2 ; - 4 ] := O₁[- 1 - 2 ; - 3 1 ] * conj (F₁[- 4 ; 1 ]) +
192192 O₂[- 1 - 2 ; - 3 1 ] * conj (F₂[- 4 ; 1 ])
193193
@@ -248,8 +248,8 @@ function Base.:*(mpo1::FiniteMPO{TO}, mpo2::FiniteMPO{TO}) where {TO}
248248 S = spacetype (TO)
249249 if (left_virtualspace (mpo1, 1 ) != oneunit (S) ||
250250 left_virtualspace (mpo2, 1 ) != oneunit (S)) ||
251- (right_virtualspace (mpo1, N)' != oneunit (S) ||
252- right_virtualspace (mpo2, N)' != oneunit (S))
251+ (right_virtualspace (mpo1, N) != oneunit (S) ||
252+ right_virtualspace (mpo2, N) != oneunit (S))
253253 @warn " left/right virtual space is not trivial, fusion may not be unique"
254254 # this is a warning because technically any isomorphism that fuses the left/right
255255 # would work and for now I dont feel like figuring out if this is important
@@ -261,13 +261,8 @@ function Base.:*(mpo1::FiniteMPO{TO}, mpo2::FiniteMPO{TO}) where {TO}
261261 # note order of mpos: mpo1 * mpo2 * state -> mpo2 on top of mpo1
262262 local Fᵣ # trick to make Fᵣ defined in the loop
263263 for i in 1 : N
264- Fₗ = i != 1 ? Fᵣ :
265- isomorphism (A, fuse (left_virtualspace (mpo2, i), left_virtualspace (mpo1, i)),
266- left_virtualspace (mpo2, i) * left_virtualspace (mpo1, i))
267- Fᵣ = isomorphism (A,
268- fuse (right_virtualspace (mpo2, i)' , right_virtualspace (mpo1, i)' ),
269- right_virtualspace (mpo2, i)' * right_virtualspace (mpo1, i)' )
270-
264+ Fₗ = i != 1 ? Fᵣ : fuser (A, left_virtualspace (mpo2, i), left_virtualspace (mpo1, i))
265+ Fᵣ = fuser (A, right_virtualspace (mpo2, i), right_virtualspace (mpo1, i))
271266 @plansor O[i][- 1 - 2 ; - 3 - 4 ] := Fₗ[- 1 ; 1 4 ] * mpo2[i][1 2 ; - 3 3 ] *
272267 mpo1[i][4 - 2 ; 2 5 ] *
273268 conj (Fᵣ[- 4 ; 3 5 ])
@@ -284,11 +279,8 @@ function Base.:*(mpo::FiniteMPO, mps::FiniteMPS)
284279
285280 local Fᵣ # trick to make Fᵣ defined in the loop
286281 for i in 1 : length (mps)
287- Fₗ = i != 1 ? Fᵣ :
288- isomorphism (TT, fuse (left_virtualspace (A[i]), left_virtualspace (mpo, i)),
289- left_virtualspace (A[i]) * left_virtualspace (mpo, i))
290- Fᵣ = isomorphism (TT, fuse (right_virtualspace (A[i])' , right_virtualspace (mpo, i)' ),
291- right_virtualspace (A[i])' * right_virtualspace (mpo, i)' )
282+ Fₗ = i != 1 ? Fᵣ : fuser (TT, left_virtualspace (mps, i), left_virtualspace (mpo, i))
283+ Fᵣ = fuser (TT, right_virtualspace (mps, i), right_virtualspace (mpo, i))
292284 A[i] = _fuse_mpo_mps (mpo[i], A[i], Fₗ, Fᵣ)
293285 end
294286
@@ -298,12 +290,11 @@ function Base.:*(mpo::FiniteMPO, mps::FiniteMPS)
298290end
299291
300292function Base.:* (mpo:: InfiniteMPO , mps:: InfiniteMPS )
301- check_length (mpo, mps)
293+ L = check_length (mpo, mps)
302294 T = promote_type (scalartype (mpo), scalartype (mps))
303- fusers = PeriodicArray (map (mps. AL, mpo) do al, mp
304- return fuser (T, _firstspace (al), _firstspace (mp))
305- end )
306- As = map (1 : length (mps)) do i
295+ fusers = PeriodicArray (fuser .(T, left_virtualspace .(Ref (mps), 1 : L),
296+ left_virtualspace .(Ref (mpo), 1 : L)))
297+ As = map (1 : L) do i
307298 return _fuse_mpo_mps (mpo[i], mps. AL[i], fusers[i], fusers[i + 1 ])
308299 end
309300 return changebonds (InfiniteMPS (As), SvdCut (; trscheme= notrunc ()))
@@ -346,14 +337,14 @@ function TensorKit.dot(bra::FiniteMPS{T}, mpo::FiniteMPO, ket::FiniteMPS{T}) whe
346337 Nhalf = N ÷ 2
347338 # left half
348339 ρ_left = isomorphism (storagetype (T),
349- left_virtualspace (bra, 0 ) ⊗ left_virtualspace (mpo, 1 )' ,
350- left_virtualspace (ket, 0 ))
340+ left_virtualspace (bra, 1 ) ⊗ left_virtualspace (mpo, 1 )' ,
341+ left_virtualspace (ket, 1 ))
351342 T_left = TransferMatrix (ket. AL[1 : Nhalf], mpo[1 : Nhalf], bra. AL[1 : Nhalf])
352343 ρ_left = ρ_left * T_left
353344
354345 # right half
355346 ρ_right = isomorphism (storagetype (T),
356- right_virtualspace (ket, N) ⊗ right_virtualspace (mpo, N)' ,
347+ right_virtualspace (ket, N) ⊗ right_virtualspace (mpo, N),
357348 right_virtualspace (ket, length (ket)))
358349 T_right = TransferMatrix (ket. AR[(Nhalf + 1 ): end ], mpo[(Nhalf + 1 ): end ],
359350 bra. AR[(Nhalf + 1 ): end ])
0 commit comments