Skip to content

Commit ea5cc1c

Browse files
authored
excise RecursiveVec (#189)
1 parent a8d03c0 commit ea5cc1c

File tree

7 files changed

+26
-36
lines changed

7 files changed

+26
-36
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Accessors = "0.1"
2626
FLoops = "0.1, 0.2"
2727
FastClosures = "0.3"
2828
FoldsThreads = "0.1"
29-
KrylovKit = "=0.8.1"
29+
KrylovKit = "0.8.3"
3030
LinearAlgebra = "1.6"
3131
LoggingExtras = "1"
3232
OptimKit = "0.3.1"

src/algorithms/derivatives.jl

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,8 @@ function ∂AC(x::MPSTensor{S}, opp::Number, leftenv::MPSTensor{S},
104104
end
105105

106106
# mpo multiline
107-
function ∂AC(x::RecursiveVec, opp, leftenv, rightenv)
108-
return RecursiveVec(circshift(map(t -> ∂AC(t...), zip(x.vecs, opp, leftenv, rightenv)),
109-
1))
107+
function ∂AC(x::Vector, opp, leftenv, rightenv)
108+
return circshift(map(t -> ∂AC(t...), zip(x, opp, leftenv, rightenv)), 1)
110109
end
111110

112111
function ∂AC(x::MPSTensor, ::Nothing, leftenv, rightenv)
@@ -160,9 +159,8 @@ function ∂AC2(x::MPOTensor, ::Nothing, ::Nothing, leftenv, rightenv)
160159
@plansor y[-1 -2; -3 -4] := x[1 -2; 2 -4] * leftenv[-1; 1] * rightenv[2; -3]
161160
end
162161

163-
function ∂AC2(x::RecursiveVec, opp1, opp2, leftenv, rightenv)
164-
return RecursiveVec(circshift(map(t -> ∂AC2(t...),
165-
zip(x.vecs, opp1, opp2, leftenv, rightenv)), 1))
162+
function ∂AC2(x::Vector, opp1, opp2, leftenv, rightenv)
163+
return circshift(map(t -> ∂AC2(t...), zip(x, opp1, opp2, leftenv, rightenv)), 1)
166164
end
167165

168166
"""
@@ -192,8 +190,8 @@ function ∂C(x::MPSBondTensor, leftenv::MPSBondTensor, rightenv::MPSBondTensor)
192190
@plansor toret[-1; -2] := leftenv[-1; 1] * x[1; 2] * rightenv[2; -2]
193191
end
194192

195-
function ∂C(x::RecursiveVec, leftenv, rightenv)
196-
return RecursiveVec(circshift(map(t -> ∂C(t...), zip(x.vecs, leftenv, rightenv)), 1))
193+
function ∂C(x::Vector, leftenv, rightenv)
194+
return circshift(map(t -> ∂C(t...), zip(x, leftenv, rightenv)), 1)
197195
end
198196

199197
#downproject for approximate

src/algorithms/excitation/quasiparticleexcitation.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,15 +171,15 @@ function excitations(H::MPOMultiline, alg::QuasiparticleAnsatz, ϕ₀::Multiline
171171
lenvs, renvs; num=1, solver=Defaults.linearsolver)
172172
qp_envs(ϕ) = environments(ϕ, H, lenvs, renvs; solver)
173173
function H_eff(ϕ′)
174-
ϕ = Multiline(ϕ′.vecs)
175-
return RecursiveVec(effective_excitation_hamiltonian(H, ϕ, qp_envs(ϕ)).data.data)
174+
ϕ = Multiline(ϕ′)
175+
return effective_excitation_hamiltonian(H, ϕ, qp_envs(ϕ)).data.data
176176
end
177177

178-
Es, ϕs, convhist = eigsolve(H_eff, RecursiveVec(ϕ₀.data.data), num, :LM, alg.alg)
178+
Es, ϕs, convhist = eigsolve(H_eff, ϕ₀.data.data, num, :LM, alg.alg)
179179
convhist.converged < num &&
180180
@warn "excitation failed to converge: normres = $(convhist.normres)"
181181

182-
return Es, map(x -> Multiline(x.vecs), ϕs)
182+
return Es, map(Multiline, ϕs)
183183
end
184184

185185
function excitations(H::MPOMultiline, alg::QuasiparticleAnsatz, ϕ₀::Multiline{<:InfiniteQP},

src/algorithms/statmech/vomps.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,24 @@ function leading_boundary(ψ::MPSMultiline, O::MPOMultiline, alg::VOMPS,
3838
@sync for col in 1:size(ψ, 2)
3939
Threads.@spawn begin
4040
H_AC = ∂∂AC(col, ψ, O, envs)
41-
ac = RecursiveVec(ψ.AC[:, col])
41+
ac = ψ.AC[:, col]
4242
temp_ACs[:, col] .= H_AC(ac)
4343
end
4444

4545
Threads.@spawn begin
4646
H_C = ∂∂C(col, ψ, O, envs)
47-
c = RecursiveVec(ψ.CR[:, col])
47+
c = ψ.CR[:, col]
4848
temp_Cs[:, col] .= H_C(c)
4949
end
5050
end
5151
else
5252
for col in 1:size(ψ, 2)
5353
H_AC = ∂∂AC(col, ψ, O, envs)
54-
ac = RecursiveVec(ψ.AC[:, col])
54+
ac = ψ.AC[:, col]
5555
temp_ACs[:, col] .= H_AC(ac)
5656

5757
H_C = ∂∂C(col, ψ, O, envs)
58-
c = RecursiveVec(ψ.CR[:, col])
58+
c = ψ.CR[:, col]
5959
temp_Cs[:, col] .= H_C(c)
6060
end
6161
end

src/algorithms/statmech/vumps.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,29 +31,29 @@ function leading_boundary(ψ::MPSMultiline, H, alg::VUMPS, envs=environments(ψ,
3131
@sync for col in 1:size(ψ, 2)
3232
Threads.@spawn begin
3333
H_AC = ∂∂AC($col, $ψ, $H, $envs)
34-
ac = RecursiveVec($ψ.AC[:, col])
34+
ac = $ψ.AC[:, col]
3535
_, ac′ = fixedpoint(H_AC, ac, :LM, alg_eigsolve)
36-
$temp_ACs[:, col] = ac′.vecs[:]
36+
$temp_ACs[:, col] = ac′[:]
3737
end
3838

3939
Threads.@spawn begin
4040
H_C = ∂∂C($col, $ψ, $H, $envs)
41-
c = RecursiveVec($ψ.CR[:, col])
41+
c = $ψ.CR[:, col]
4242
_, c′ = fixedpoint(H_C, c, :LM, alg_eigsolve)
43-
$temp_Cs[:, col] = c′.vecs[:]
43+
$temp_Cs[:, col] = c′[:]
4444
end
4545
end
4646
else
4747
for col in 1:size(ψ, 2)
4848
H_AC = ∂∂AC(col, ψ, H, envs)
49-
ac = RecursiveVec(ψ.AC[:, col])
49+
ac = ψ.AC[:, col]
5050
_, ac′ = fixedpoint(H_AC, ac, :LM, alg_eigsolve)
51-
temp_ACs[:, col] = ac′.vecs[:]
51+
temp_ACs[:, col] = ac′[:]
5252

5353
H_C = ∂∂C(col, ψ, H, envs)
54-
c = RecursiveVec(ψ.CR[:, col])
54+
c = ψ.CR[:, col]
5555
_, c′ = fixedpoint(H_C, c, :LM, alg_eigsolve)
56-
temp_Cs[:, col] = c′.vecs[:]
56+
temp_Cs[:, col] = c′[:]
5757
end
5858
end
5959

src/algorithms/timestep/timeevmpo.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,9 @@ function make_time_mpo(H::MPOHamiltonian{S,T}, dt, alg::WII) where {S,T}
160160
domain(H[i][1, H.odim]))
161161
init = [init_1, zero(H[i][1, k]), zero(H[i][j, H.odim]), zero(H[i][j, k])]
162162

163-
(y, convhist) = exponentiate(1.0, RecursiveVec(init),
163+
(y, convhist) = exponentiate(1.0, init,
164164
Arnoldi(; tol=alg.tol, maxiter=alg.maxiter)) do x
165-
out = similar(x.vecs)
165+
out = similar(x)
166166

167167
@plansor out[1][-1 -2; -3 -4] := δ * x[1][-1 1; -3 -4] *
168168
H[i][1, H.odim][2 3; 1 4] * τ[-2 4; 2 3]
@@ -186,7 +186,7 @@ function make_time_mpo(H::MPOHamiltonian{S,T}, dt, alg::WII) where {S,T}
186186
@plansor out[4][-1 -2; -3 -4] += sqrt(δ) * x[3][-1 4; -3 3] *
187187
H[i][1, k][2 -2; 1 -4] * τ[3 4; 1 2]
188188

189-
return RecursiveVec(out)
189+
return out
190190
end
191191
convhist.converged == 0 &&
192192
@warn "exponentiate failed to converge: normres = $(convhist.normres)"

src/transfermatrix/transfer.jl

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,6 @@ function transfer_right(v::MPOTensor, O::MPOTensor, A::MPSTensor, Ab::MPSTensor)
125125
@plansor v[-1 -2; -3 -4] := A[-1 4; 5] * O[-2 2; 4 3] * conj(Ab[-4 2; 1]) * v[5 3; -3 1]
126126
end
127127

128-
# --- the following really needs a proper rewrite; probably without transducers
129-
function transfer_left(vec::RecursiveVec, opp, A, Ab)
130-
return RecursiveVec(transfer_left(vec.vecs, opp, A, Ab))
131-
end;
132-
function transfer_right(vec::RecursiveVec, opp, A, Ab)
133-
return RecursiveVec(transfer_right(vec.vecs, opp, A, Ab))
134-
end;
135-
136128
# usual sparsemposlice transfer
137129
function transfer_left(vec::AbstractVector{V}, ham::SparseMPOSlice, A::V,
138130
Ab::V) where {V<:MPSTensor}

0 commit comments

Comments
 (0)