@@ -19,7 +19,7 @@ const FiniteMPO{O<:MPOTensor} = MPO{O,Vector{O}}
19
19
20
20
function FiniteMPO (Os:: AbstractVector{O} ) where {O<: MPOTensor }
21
21
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 ]) ||
23
23
throw (SpaceMismatch (" unmatching virtual spaces at site $i " ))
24
24
end
25
25
return FiniteMPO {O} (Os)
@@ -38,7 +38,7 @@ const InfiniteMPO{O<:MPOTensor} = MPO{O,PeriodicVector{O}}
38
38
39
39
function InfiniteMPO (Os:: AbstractVector{O} ) where {O<: MPOTensor }
40
40
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 )]) ||
42
42
throw (SpaceMismatch (" umatching virtual spaces at site $i " ))
43
43
end
44
44
return InfiniteMPO {O} (Os)
@@ -139,8 +139,8 @@ function Base.convert(::Type{TensorMap}, mpo::FiniteMPO)
139
139
U_left = ones (scalartype (mpo), V_left)'
140
140
141
141
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)
144
144
145
145
tensors = vcat (U_left, parent (mpo), U_right)
146
146
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}
166
166
A = storagetype (TO)
167
167
168
168
# 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 ))
171
171
F₂ = leftnull (F₁)
172
- @assert _lastspace (F₂) == right_virtualspace (mpo2, 1 )
172
+ @assert _lastspace (F₂) == right_virtualspace (mpo2, 1 )'
173
173
174
174
@plansor O[- 3 - 1 - 2 ; - 4 ] := mpo1[1 ][- 1 - 2 ; - 3 1 ] * conj (F₁[- 4 ; 1 ]) +
175
175
mpo2[1 ][- 1 - 2 ; - 3 1 ] * conj (F₂[- 4 ; 1 ])
@@ -184,10 +184,10 @@ function Base.:+(mpo1::FiniteMPO{TO}, mpo2::FiniteMPO{TO}) where {TO}
184
184
@plansor O₂[- 1 - 2 ; - 3 - 4 ] := R[- 1 ; 1 ] * F₂[1 ; 2 ] * mpo2[i][2 - 2 ; - 3 - 4 ]
185
185
186
186
# 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))
189
189
F₂ = leftnull (F₁)
190
- @assert _lastspace (F₂) == right_virtualspace (mpo2, i)
190
+ @assert _lastspace (F₂) == right_virtualspace (mpo2, i)'
191
191
@plansor O[- 3 - 1 - 2 ; - 4 ] := O₁[- 1 - 2 ; - 3 1 ] * conj (F₁[- 4 ; 1 ]) +
192
192
O₂[- 1 - 2 ; - 3 1 ] * conj (F₂[- 4 ; 1 ])
193
193
@@ -248,8 +248,8 @@ function Base.:*(mpo1::FiniteMPO{TO}, mpo2::FiniteMPO{TO}) where {TO}
248
248
S = spacetype (TO)
249
249
if (left_virtualspace (mpo1, 1 ) != oneunit (S) ||
250
250
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))
253
253
@warn " left/right virtual space is not trivial, fusion may not be unique"
254
254
# this is a warning because technically any isomorphism that fuses the left/right
255
255
# 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}
261
261
# note order of mpos: mpo1 * mpo2 * state -> mpo2 on top of mpo1
262
262
local Fᵣ # trick to make Fᵣ defined in the loop
263
263
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))
271
266
@plansor O[i][- 1 - 2 ; - 3 - 4 ] := Fₗ[- 1 ; 1 4 ] * mpo2[i][1 2 ; - 3 3 ] *
272
267
mpo1[i][4 - 2 ; 2 5 ] *
273
268
conj (Fᵣ[- 4 ; 3 5 ])
@@ -284,11 +279,8 @@ function Base.:*(mpo::FiniteMPO, mps::FiniteMPS)
284
279
285
280
local Fᵣ # trick to make Fᵣ defined in the loop
286
281
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))
292
284
A[i] = _fuse_mpo_mps (mpo[i], A[i], Fₗ, Fᵣ)
293
285
end
294
286
@@ -298,12 +290,11 @@ function Base.:*(mpo::FiniteMPO, mps::FiniteMPS)
298
290
end
299
291
300
292
function Base.:* (mpo:: InfiniteMPO , mps:: InfiniteMPS )
301
- check_length (mpo, mps)
293
+ L = check_length (mpo, mps)
302
294
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
307
298
return _fuse_mpo_mps (mpo[i], mps. AL[i], fusers[i], fusers[i + 1 ])
308
299
end
309
300
return changebonds (InfiniteMPS (As), SvdCut (; trscheme= notrunc ()))
@@ -346,14 +337,14 @@ function TensorKit.dot(bra::FiniteMPS{T}, mpo::FiniteMPO, ket::FiniteMPS{T}) whe
346
337
Nhalf = N ÷ 2
347
338
# left half
348
339
ρ_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 ))
351
342
T_left = TransferMatrix (ket. AL[1 : Nhalf], mpo[1 : Nhalf], bra. AL[1 : Nhalf])
352
343
ρ_left = ρ_left * T_left
353
344
354
345
# right half
355
346
ρ_right = isomorphism (storagetype (T),
356
- right_virtualspace (ket, N) ⊗ right_virtualspace (mpo, N)' ,
347
+ right_virtualspace (ket, N) ⊗ right_virtualspace (mpo, N),
357
348
right_virtualspace (ket, length (ket)))
358
349
T_right = TransferMatrix (ket. AR[(Nhalf + 1 ): end ], mpo[(Nhalf + 1 ): end ],
359
350
bra. AR[(Nhalf + 1 ): end ])
0 commit comments