|
1 | 1 | """ |
2 | | -$(SIGNATURES) |
| 2 | +Given the first tensor `A` in the cluster acted on by a gate, |
| 3 | +obtain reduced tensor on its next bond. |
3 | 4 |
|
4 | | -Use QR decomposition on two tensors `A`, `B` connected by a bond to get the reduced tensors. |
5 | | -When `A`, `B` are PEPSTensors, |
| 5 | +For PEPSTensor, |
6 | 6 | ``` |
7 | | - 2 1 1 |
8 | | - | | | |
9 | | - 5 -A/B- 3 ====> 4 - X ← 2 1 ← a - 3 1 - b → 3 4 → Y - 2 |
10 | | - | ↘ | ↘ ↘ | |
11 | | - 4 1 3 2 2 3 |
| 7 | + 1 |
| 8 | + | |
| 9 | + 4 - X ← 2 1 ← a - 3 |
| 10 | + | ↘ |
| 11 | + 3 2 |
12 | 12 | ``` |
13 | | -When `A`, `B` are PEPOTensors, |
14 | | -- If `gate_ax = 1` |
| 13 | +For PEPOTensor, |
15 | 14 | ``` |
16 | | - 2 3 1 2 1 2 |
17 | | - ↘ | ↘ | ↘ | |
18 | | - 6 -A/B- 4 ====> 5 - X ← 3 1 ← a - 3 1 - b → 3 5 → Y - 3 |
19 | | - | ↘ | ↘ ↘ | |
20 | | - 5 1 4 2 2 4 |
21 | | -``` |
22 | | -- If `gate_ax = 2` |
23 | | -``` |
24 | | - 2 3 2 2 2 2 |
25 | | - ↘ | | ↘ ↘ | |
26 | | - 6 -A/B- 4 ====> 5 - X ← 3 1 ← a - 3 1 - b → 3 5 → Y - 3 |
27 | | - | ↘ | ↘ | ↘ |
28 | | - 5 1 4 1 4 1 |
| 15 | + gate_ax = 1 gate_ax = 2 |
| 16 | +
|
| 17 | + 1 2 2 2 |
| 18 | + ↘ | | ↘ |
| 19 | + 5 - X ← 3 1 ← a - 3 5 - X ← 3 1 ← a - 3 |
| 20 | + | ↘ | ↘ |
| 21 | + 4 2 4 1 |
29 | 22 | ``` |
30 | 23 | """ |
31 | | -function _qr_bond(A::PT, B::PT; gate_ax::Int = 1, kwargs...) where {PT <: Union{PEPSTensor, PEPOTensor}} |
32 | | - @assert 1 <= gate_ax <= numout(A) |
33 | | - permA, permB, permX, permY = if A isa PEPSTensor |
34 | | - ((2, 4, 5), (1, 3)), ((2, 3, 4), (1, 5)), (1, 4, 2, 3), Tuple(1:4) |
| 24 | +function bond_tensor_first(A::PEPSTensor; gate_ax::Integer = 1, kwargs...) |
| 25 | + @assert gate_ax == 1 |
| 26 | + X, a = left_orth!(permute(A, ((2, 4, 5), (1, 3)); copy = true); kwargs...) |
| 27 | + X = permute(X, (1, 4, 2, 3)) |
| 28 | + a = permute(a, ((1, 2), (3,))) |
| 29 | + return X, a |
| 30 | +end |
| 31 | +function bond_tensor_first(A::PEPOTensor; gate_ax::Integer = 1, kwargs...) |
| 32 | + @assert 1 <= gate_ax <= 2 |
| 33 | + X, a = if gate_ax == 1 |
| 34 | + left_orth!(permute(A, ((2, 3, 5, 6), (1, 4)); copy = true); kwargs...) |
35 | 35 | else |
36 | | - if gate_ax == 1 |
37 | | - ((2, 3, 5, 6), (1, 4)), ((2, 3, 4, 5), (1, 6)), (1, 2, 5, 3, 4), Tuple(1:5) |
38 | | - else |
39 | | - ((1, 3, 5, 6), (2, 4)), ((1, 3, 4, 5), (2, 6)), (1, 2, 5, 3, 4), Tuple(1:5) |
40 | | - end |
| 36 | + left_orth!(permute(A, ((1, 3, 5, 6), (2, 4)); copy = true); kwargs...) |
41 | 37 | end |
42 | | - X, a = left_orth!(permute(A, permA; copy = true); kwargs...) |
43 | | - Y, b = left_orth!(permute(B, permB; copy = true); kwargs...) |
44 | | - X, Y = permute(X, permX), permute(Y, permY) |
45 | | - b = permute(b, ((3, 2), (1,))) |
46 | | - return X, a, b, Y |
| 38 | + X = permute(X, (1, 2, 5, 3, 4)) |
| 39 | + a = permute(a, ((1, 2), (3,))) |
| 40 | + return X, a |
47 | 41 | end |
48 | 42 |
|
49 | 43 | """ |
50 | | -$(SIGNATURES) |
| 44 | +Undo the decomposition in `bond_tensor_first`. |
| 45 | +""" |
| 46 | +function undo_bond_tensor_first(X::PEPSOrth, a::MPSTensor; gate_ax::Integer = 1) |
| 47 | + @assert gate_ax == 1 |
| 48 | + return @tensor A[-1; -2 -3 -4 -5] := X[-2 1 -4 -5] * a[1 -1 -3] |
| 49 | +end |
| 50 | +function undo_bond_tensor_first(X::PEPOOrth, a::MPSTensor; gate_ax::Integer = 1) |
| 51 | + @assert 1 <= gate_ax <= 2 |
| 52 | + if gate_ax == 1 |
| 53 | + return @tensor A[-1 -2; -3 -4 -5 -6] := X[-2 -3 1 -5 -6] * a[1 -1 -4] |
| 54 | + else |
| 55 | + return @tensor A[-1 -2; -3 -4 -5 -6] := X[-1 -3 1 -5 -6] * a[1 -2 -4] |
| 56 | + end |
| 57 | +end |
51 | 58 |
|
52 | | -Reconstruct the tensors connected by a bond from their `_qr_bond` results. |
53 | | -For PEPSTensors, |
| 59 | +""" |
| 60 | +Given the last tensor `A` in the cluster acted on by a gate, |
| 61 | +obtain reduced tensor on its previous bond. |
| 62 | +
|
| 63 | +For PEPSTensor, |
54 | 64 | ``` |
55 | | - -2 -2 |
56 | | - | | |
57 | | - -5- X - 1 - a - -3 -5 - b - 1 - Y - -3 |
58 | | - | ↘ ↘ | |
59 | | - -4 -1 -1 -4 |
| 65 | + 1 |
| 66 | + | |
| 67 | + 1 - b → 3 4 → Y - 2 |
| 68 | + ↘ | |
| 69 | + 2 3 |
60 | 70 | ``` |
61 | | -For PEPOTensors |
| 71 | +For PEPOTensor, |
62 | 72 | ``` |
63 | | - -2 -3 -2 -3 |
64 | | - ↘ | ↘ | |
65 | | - -6- X - 1 - a - -4 -6 - b - 1 - Y - -4 |
66 | | - | ↘ ↘ | |
67 | | - -5 -1 -1 -5 |
| 73 | + gate_ax = 1 gate_ax = 2 |
68 | 74 |
|
69 | | - -3 -2 -2 -3 |
70 | | - | ↘ ↘ | |
71 | | - -6- X - 1 - a - -4 -6 - b - 1 - Y - -4 |
72 | | - | ↘ | ↘ |
73 | | - -5 -1 -5 -1 |
| 75 | + 1 2 2 2 |
| 76 | + ↘ | ↘ | |
| 77 | + 1 - b → 3 5 → Y - 3 1 - b → 3 5 → Y - 3 |
| 78 | + ↘ | | ↘ |
| 79 | + 2 4 4 1 |
74 | 80 | ``` |
75 | 81 | """ |
76 | | -function _qr_bond_undo(X::PEPSOrth, a::AbstractTensorMap, b::AbstractTensorMap, Y::PEPSOrth) |
77 | | - @tensor A[-1; -2 -3 -4 -5] := X[-2 1 -4 -5] * a[1 -1 -3] |
78 | | - @tensor B[-1; -2 -3 -4 -5] := b[-5 -1 1] * Y[-2 -3 -4 1] |
79 | | - return A, B |
| 82 | +function bond_tensor_last(A::PEPSTensor; gate_ax::Integer = 1, kwargs...) |
| 83 | + @assert gate_ax == 1 |
| 84 | + Y, b = left_orth!(permute(A, ((2, 3, 4), (1, 5)); copy = true); kwargs...) |
| 85 | + Y = permute(Y, (1, 2, 3, 4)) |
| 86 | + b = permute(b, ((3, 2), (1,))) |
| 87 | + return Y, b |
| 88 | +end |
| 89 | +function bond_tensor_last(A::PEPOTensor; gate_ax::Integer = 1, kwargs...) |
| 90 | + @assert 1 <= gate_ax <= 2 |
| 91 | + Y, b = if gate_ax == 1 |
| 92 | + left_orth!(permute(A, ((2, 3, 4, 5), (1, 6)); copy = true); kwargs...) |
| 93 | + else |
| 94 | + left_orth!(permute(A, ((1, 3, 4, 5), (2, 6)); copy = true); kwargs...) |
| 95 | + end |
| 96 | + Y = permute(Y, (1, 2, 3, 4, 5)) |
| 97 | + b = permute(b, ((3, 2), (1,))) |
| 98 | + return Y, b |
| 99 | +end |
| 100 | + |
| 101 | +""" |
| 102 | +Undo the decomposition in `bond_tensor_last`. |
| 103 | +""" |
| 104 | +function undo_bond_tensor_last(Y::PEPSOrth, b::MPSTensor) |
| 105 | + return @tensor A[-1; -2 -3 -4 -5] := b[-5 -1 1] * Y[-2 -3 -4 1] |
80 | 106 | end |
81 | | -function _qr_bond_undo(X::PEPOOrth, a::AbstractTensorMap, b::AbstractTensorMap, Y::PEPOOrth) |
82 | | - if !isdual(space(a, 2)) |
83 | | - @tensor A[-1 -2; -3 -4 -5 -6] := X[-2 -3 1 -5 -6] * a[1 -1 -4] |
84 | | - @tensor B[-1 -2; -3 -4 -5 -6] := b[-6 -1 1] * Y[-2 -3 -4 -5 1] |
| 107 | +function undo_bond_tensor_last(Y::PEPOOrth, b::MPSTensor; gate_ax::Integer = 1) |
| 108 | + @assert 1 <= gate_ax <= 2 |
| 109 | + if gate_ax == 1 |
| 110 | + return @tensor A[-1 -2; -3 -4 -5 -6] := b[-6 -1 1] * Y[-2 -3 -4 -5 1] |
85 | 111 | else |
86 | | - @tensor A[-1 -2; -3 -4 -5 -6] := X[-1 -3 1 -5 -6] * a[1 -2 -4] |
87 | | - @tensor B[-1 -2; -3 -4 -5 -6] := b[-6 -2 1] * Y[-1 -3 -4 -5 1] |
| 112 | + return @tensor A[-1 -2; -3 -4 -5 -6] := b[-6 -2 1] * Y[-1 -3 -4 -5 1] |
88 | 113 | end |
89 | | - return A, B |
90 | 114 | end |
0 commit comments