Skip to content

Commit 9d1a99a

Browse files
committed
refactor operator orthogonalization to use new orths
1 parent 0fe74f9 commit 9d1a99a

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/algorithms/changebonds/svdcut.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,13 @@ function changebonds!(H::FiniteMPOHamiltonian, alg::SvdCut)
120120
end
121121

122122
# swipe right
123+
alg_trunc = MatrixAlgebraKit.TruncatedAlgorithm(alg.alg_svd, alg.trscheme)
123124
for i in 1:(length(H) - 1)
124-
H = left_canonicalize!(H, i; alg = alg.alg_svd, alg.trscheme)
125+
H = left_canonicalize!(H, i; alg = alg_trunc)
125126
end
126127
# swipe left -- TODO: do we really need this double sweep?
127128
for i in length(H):-1:2
128-
H = right_canonicalize!(H, i; alg = alg.alg_svd, alg.trscheme)
129+
H = right_canonicalize!(H, i; alg = alg_trunc)
129130
end
130131

131132
return H

src/operators/ortho.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
function left_canonicalize!(
22
H::FiniteMPOHamiltonian, i::Int;
3-
alg = Defaults.alg_qr(), trscheme::TruncationStrategy = notrunc()
3+
alg::MatrixAlgebraKit.AbstractAlgorithm = Defaults.alg_qr()
44
)
55
1 i < length(H) || throw(ArgumentError("Bounds error in canonicalize"))
66

@@ -19,7 +19,7 @@ function left_canonicalize!(
1919
# QR of second column
2020
if size(W, 1) == 1
2121
tmp = transpose(C′, ((2, 1), (3,)))
22-
Q, R = left_orth!(tmp; alg, trunc = trscheme)
22+
Q, R = left_orth!(tmp; alg)
2323

2424
if dim(R) == 0 # fully truncated
2525
V = oneunit(S) oneunit(S)
@@ -35,7 +35,7 @@ function left_canonicalize!(
3535
H[i] = JordanMPOTensor(codomain(W) physicalspace(W) V, Q1, W.B, Q2, W.D)
3636
else
3737
tmp = transpose(cat(insertleftunit(C′, 1), W.A; dims = 1), ((3, 1, 2), (4,)))
38-
Q, R = left_orth!(tmp; alg, trunc = trscheme)
38+
Q, R = left_orth!(tmp; alg)
3939

4040
if dim(R) == 0 # fully truncated
4141
V = oneunit(S) oneunit(S)
@@ -86,7 +86,7 @@ end
8686

8787
function right_canonicalize!(
8888
H::FiniteMPOHamiltonian, i::Int;
89-
alg = Defaults.alg_lq(), trscheme::TruncationStrategy = notrunc()
89+
alg::MatrixAlgebraKit.AbstractAlgorithm = Defaults.alg_lq()
9090
)
9191
1 < i length(H) || throw(ArgumentError("Bounds error in canonicalize"))
9292

@@ -105,7 +105,7 @@ function right_canonicalize!(
105105
# LQ of second row
106106
if size(W, 4) == 1
107107
tmp = transpose(B′, ((1,), (3, 2)))
108-
R, Q = right_orth!(tmp; alg, trunc = trscheme)
108+
R, Q = right_orth!(tmp; alg)
109109

110110
if dim(R) == 0
111111
V = oneunit(S) oneunit(S)
@@ -121,7 +121,7 @@ function right_canonicalize!(
121121
H[i] = JordanMPOTensor(V physicalspace(W) domain(W), Q1, Q2, W.C, W.D)
122122
else
123123
tmp = transpose(cat(insertleftunit(B′, 4), W.A; dims = 4), ((1,), (3, 4, 2)))
124-
R, Q = right_orth!(tmp; alg, trunc = trscheme)
124+
R, Q = right_orth!(tmp; alg)
125125
if dim(R) == 0
126126
V = oneunit(S) oneunit(S)
127127
Q1 = typeof(W.A)(undef, SumSpace{S}() physicalspace(W) physicalspace(W) SumSpace{S}())

0 commit comments

Comments
 (0)