Skip to content

Commit de5a5d5

Browse files
committed
Change bond_tensor return order
1 parent bbc3bc4 commit de5a5d5

5 files changed

Lines changed: 24 additions & 24 deletions

File tree

src/algorithms/time_evolution/ntupdate3site.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ function _bond_truncate(
5454
A, B = state2[row, col], state2[row, cp1]
5555

5656
# create bond environment
57-
X, a = bond_tensor_first(A; trunc = trunctol(; rtol = 1.0e-12))
58-
Y, b = bond_tensor_last(B; trunc = trunctol(; rtol = 1.0e-12))
57+
a, X = bond_tensor_first(A; trunc = trunctol(; rtol = 1.0e-12))
58+
b, Y = bond_tensor_last(B; trunc = trunctol(; rtol = 1.0e-12))
5959
benv = bondenv_ntu(row, col, X, Y, state2, alg.bondenv_alg)
6060
@debug "cond(benv) before gauge fix: $(LinearAlgebra.cond(benv))"
6161
if alg.fixgauge
@@ -76,8 +76,8 @@ function _bond_truncate(
7676
end
7777

7878
a, s, b, info = bond_truncate(a, b, benv, alg.opt_alg)
79-
A = undo_bond_tensor_first(X, a)
80-
B = undo_bond_tensor_last(Y, b)
79+
A = undo_bond_tensor_first(a, X)
80+
B = undo_bond_tensor_last(b, Y)
8181
normalize!(A, Inf)
8282
normalize!(B, Inf)
8383
normalize!(s, Inf)

src/algorithms/time_evolution/simpleupdate.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,12 @@ function _su_iter!(
113113
ϵ, s = 0.0, nothing
114114
gate_axs = alg.purified ? (1:1) : (1:2)
115115
for gate_ax in gate_axs
116-
X, a = bond_tensor_first(A; gate_ax, positive = true)
117-
Y, b = bond_tensor_last(B; gate_ax, positive = true)
116+
a, X = bond_tensor_first(A; gate_ax, positive = true)
117+
b, Y = bond_tensor_last(B; gate_ax, positive = true)
118118
a, s, b, ϵ′ = _apply_gate(a, b, gate, trunc)
119119
ϵ = max(ϵ, ϵ′)
120-
A = undo_bond_tensor_first(X, a; gate_ax)
121-
B = undo_bond_tensor_last(Y, b; gate_ax)
120+
A = undo_bond_tensor_first(a, X; gate_ax)
121+
B = undo_bond_tensor_last(b, Y; gate_ax)
122122
end
123123
# rotate back
124124
A = _bond_rotation(A, bond[1], rev; inv = true)

src/algorithms/truncation/bond_tensor.jl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@ For PEPOTensor,
1414
```
1515
gate_ax = 1 gate_ax = 2
1616
17-
1 2 2 2
18-
↘ | | ↘
17+
1 2 2 2
18+
↘ | | ↘
1919
5 - X ← 3 1 ← a - 3 5 - X ← 3 1 ← a - 3
20-
| ↘ | ↘
21-
4 2 4 1
20+
| ↘ | ↘
21+
4 2 4 1
2222
```
2323
"""
2424
function bond_tensor_first(A::PEPSTensor; gate_ax::Integer = 1, kwargs...)
2525
@assert gate_ax == 1
2626
X, a = left_orth!(permute(A, ((2, 4, 5), (1, 3)); copy = true); kwargs...)
2727
X = permute(X, (1, 4, 2, 3))
2828
a = permute(a, ((1, 2), (3,)))
29-
return X, a
29+
return a, X
3030
end
3131
function bond_tensor_first(A::PEPOTensor; gate_ax::Integer = 1, kwargs...)
3232
@assert 1 <= gate_ax <= 2
@@ -37,17 +37,17 @@ function bond_tensor_first(A::PEPOTensor; gate_ax::Integer = 1, kwargs...)
3737
end
3838
X = permute(X, (1, 2, 5, 3, 4))
3939
a = permute(a, ((1, 2), (3,)))
40-
return X, a
40+
return a, X
4141
end
4242

4343
"""
4444
Undo the decomposition in `bond_tensor_first`.
4545
"""
46-
function undo_bond_tensor_first(X::PEPSOrth, a::MPSTensor; gate_ax::Integer = 1)
46+
function undo_bond_tensor_first(a::MPSTensor, X::PEPSOrth; gate_ax::Integer = 1)
4747
@assert gate_ax == 1
4848
return @tensor A[-1; -2 -3 -4 -5] := X[-2 1 -4 -5] * a[1 -1 -3]
4949
end
50-
function undo_bond_tensor_first(X::PEPOOrth, a::MPSTensor; gate_ax::Integer = 1)
50+
function undo_bond_tensor_first(a::MPSTensor, X::PEPOOrth; gate_ax::Integer = 1)
5151
@assert 1 <= gate_ax <= 2
5252
if gate_ax == 1
5353
return @tensor A[-1 -2; -3 -4 -5 -6] := X[-2 -3 1 -5 -6] * a[1 -1 -4]
@@ -84,7 +84,7 @@ function bond_tensor_last(A::PEPSTensor; gate_ax::Integer = 1, kwargs...)
8484
Y, b = left_orth!(permute(A, ((2, 3, 4), (1, 5)); copy = true); kwargs...)
8585
Y = permute(Y, (1, 2, 3, 4))
8686
b = permute(b, ((3, 2), (1,)))
87-
return Y, b
87+
return b, Y
8888
end
8989
function bond_tensor_last(A::PEPOTensor; gate_ax::Integer = 1, kwargs...)
9090
@assert 1 <= gate_ax <= 2
@@ -95,17 +95,17 @@ function bond_tensor_last(A::PEPOTensor; gate_ax::Integer = 1, kwargs...)
9595
end
9696
Y = permute(Y, (1, 2, 3, 4, 5))
9797
b = permute(b, ((3, 2), (1,)))
98-
return Y, b
98+
return b, Y
9999
end
100100

101101
"""
102102
Undo the decomposition in `bond_tensor_last`.
103103
"""
104-
function undo_bond_tensor_last(Y::PEPSOrth, b::MPSTensor; gate_ax::Integer = 1)
104+
function undo_bond_tensor_last(b::MPSTensor, Y::PEPSOrth; gate_ax::Integer = 1)
105105
@assert gate_ax == 1
106106
return @tensor A[-1; -2 -3 -4 -5] := b[-5 -1 1] * Y[-2 -3 -4 1]
107107
end
108-
function undo_bond_tensor_last(Y::PEPOOrth, b::MPSTensor; gate_ax::Integer = 1)
108+
function undo_bond_tensor_last(b::MPSTensor, Y::PEPOOrth; gate_ax::Integer = 1)
109109
@assert 1 <= gate_ax <= 2
110110
if gate_ax == 1
111111
return @tensor A[-1 -2; -3 -4 -5 -6] := b[-6 -1 1] * Y[-2 -3 -4 -5 1]

test/bondenv/benv_ctm.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ function test_benv_ctm(state::Union{InfinitePEPS, InfinitePEPO})
4242
for row in 1:Nr, col in 1:Nc
4343
cp1 = PEPSKit._next(col, Nc)
4444
A, B = state.A[row, col], state.A[row, cp1]
45-
X, a = PEPSKit.bond_tensor_first(A)
46-
Y, b = PEPSKit.bond_tensor_last(B)
45+
a, X = PEPSKit.bond_tensor_first(A)
46+
b, Y = PEPSKit.bond_tensor_last(B)
4747
benv = PEPSKit.bondenv_ctm(row, col, X, Y, env)
4848
Z = PEPSKit.positive_approx(benv)
4949
# verify that gauge fixing can greatly reduce

test/bondenv/benv_ntu.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ function test_ntu_env(
1515
for row in 1:Nr, col in 1:Nc
1616
cp1 = PEPSKit._next(col, Nc)
1717
A, B = state.A[row, col], state.A[row, cp1]
18-
X, a = PEPSKit.bond_tensor_first(A)
19-
Y, b = PEPSKit.bond_tensor_last(B)
18+
a, X = PEPSKit.bond_tensor_first(A)
19+
b, Y = PEPSKit.bond_tensor_last(B)
2020
@tensor ab[DX DY; da db] := a[DX da D] * b[D db DY]
2121
benv = PEPSKit.bondenv_ntu(row, col, X, Y, state, env_alg)
2222
# this is a result of `bond_tensor_...`

0 commit comments

Comments
 (0)