Skip to content

Commit b5b32c8

Browse files
committed
Add left_canonicalize!
1 parent 4046fad commit b5b32c8

File tree

1 file changed

+41
-5
lines changed

1 file changed

+41
-5
lines changed

src/operators/ortho.jl

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
function TensorKit.leftorth!(W::JordanMPOTensor; alg = QRpos())
1+
function TensorKit.leftorth(W::JordanMPOTensor; alg = QRpos())
22
# orthogonalize second column against first
33
WI = removeunit(W[1, 1, 1, 1], 1)
44
@tensor t[l; r] := conj(WI[p; p' l]) * W.C[p; p' r]
55
I = sectortype(W)
66
S = spacetype(W)
77

8-
@tensor t[l; r] := conj(removeunit(W[1, 1, 1, 1], 1)[p; p' l]) * W.C[p; p' r]
9-
@tensor C′[p; p' r] := W.C[p; p' r] - WI[p; p' l] * t[l; r]
8+
@plansor t[l; r] := conj(removeunit(W[1, 1, 1, 1], 1)[p; p' l]) * W.C[p; p' r]
9+
# @plansor C′[p; p' r] := W.C[p; p' r] - WI[p; p' l] * t[l; r]
10+
@plansor C′[p; p' r] := -WI[p; p' l] * t[l; r]
11+
add!(C′, W.C)
1012

1113
# QR of second column
12-
CA = cat(insertleftunit(C′, 1), W.A; dims = 1)
13-
Q, r = leftorth(CA, ((3, 1, 2), (4,)); alg)
14+
CA = transpose(cat(insertleftunit(C′, 1), W.A; dims = 1), ((3, 1, 2), (4,)))
15+
Q, r = leftorth!(CA; alg)
1416
Q′ = transpose(Q, ((2, 3), (1, 4)))
1517
V = codomain(W) physicalspace(W) BlockTensorKit.oplus(oneunit(S), right_virtualspace(Q′), oneunit(S))
1618
Q1 = SparseBlockTensorMap(Q′[2:end, 1, 1, 1])
@@ -27,3 +29,37 @@ function TensorKit.leftorth!(W::JordanMPOTensor; alg = QRpos())
2729

2830
return W′, R
2931
end
32+
33+
function left_canonicalize!(H::MPOHamilonian, i::Int; alg = QRPos())
34+
@assert i != 1 "TBA"
35+
36+
W = H[i]
37+
38+
# orthogonalize second column against first
39+
WI = removeunit(W[1, 1, 1, 1], 1)
40+
@tensor t[l; r] := conj(WI[p; p' l]) * W.C[p; p' r]
41+
# @plansor C′[p; p' r] := W.C[p; p' r] - WI[p; p' l] * t[l; r]
42+
@plansor C′[p; p' r] := -WI[p; p' l] * t[l; r]
43+
add!(C′, W.C)
44+
45+
# QR of second column
46+
CA = transpose(cat(insertleftunit(C′, 1), W.A; dims = 1), ((3, 1, 2), (4,)))
47+
Q, R = leftorth!(CA; alg)
48+
Q′ = transpose(Q, ((2, 3), (1, 4)))
49+
Q1 = SparseBlockTensorMap(Q′[2:end, 1, 1, 1])
50+
Q2 = removeunit(SparseBlockTensorMap(Q′[1:1, 1, 1, 1]), 1)
51+
V = BlockTensorKit.oplus(oneunit(spacetype(W)), right_virtualspace(Q′), oneunit(spacetype(W)))
52+
H[i] = JordanMPOTensor(codomain(W) physicalspace(W) V, Q1, W.B, Q2, W.D)
53+
54+
# absorb into next site
55+
W′ = H[i + 1]
56+
@plansor A′[l p; p' r] := R[l; r'] * W′.A[r' p; p' r]
57+
@plansor B′[l p; p'] := R[l; r] * W′.B[r p; p']
58+
@plansor C′[l p; p' r] := t[l; r'] * W′.A[r' p; p' r]
59+
C′ = add!(removeunit(C, 1), W′.C)
60+
@plansor D′[l p; p'] := t[l; r] * W′.B[r p; p']
61+
D′ = add!(removeunit(D, 1), W′.D)
62+
63+
H[i + 1] = JordanMPOTensor(V physicalspace(W′) domain(W′), A′, B′, C′, D′)
64+
return H
65+
end

0 commit comments

Comments
 (0)