@@ -75,24 +75,45 @@ function permutebetween(from, to)
75
75
end
76
76
77
77
"""
78
- sweep_contract!(TN::TensorNetwork , χ, τ;
78
+ sweep_contract(LTN::LabelledTensorNetwork , χ, τ;
79
79
fast=false, valid=false, planar=false, connected=false, report=false)
80
- sweep_contract!(LTN::LabelledTensorNetwork , χ, τ;
80
+ sweep_contract(TN::TensorNetwork , χ, τ;
81
81
fast=false, valid=false, planar=false, connected=false, report=false)
82
-
83
82
Returns the contraction of the `TensorNetwork TN`, or the `LabelledTensorNetwork LTN` using
84
83
the sweepline contraction algorithm of `arXiv:2101.04125`. The MPS is truncated down to a
85
84
bond dimension of `χ` whenever any bond dimension exceeds `τ`.
86
-
87
85
By default the network is checked for validity, planarised, and sweep-connected, where
88
86
necessary. The keyword flags `valid`, `planar`, and `connected` can be used to skip these,
89
87
or the flag `fast` can be used to skip them all. If these flags are enabled then contraction
90
88
may fail on poorly formed networks.
91
-
92
89
To avoid underflow/overflow issues the contraction value of the network is returned as a
93
90
tuple `(f::Float64, i::Int64)` where `1≦f<2` or `f` is `0`, representing a value of `f*2^i`.
94
91
The function `ldexp` can be used to convert this back to a Float64.
92
+ `sweep_contract` is non-mutating and acts upon a deep copy of the network, where possible
93
+ use the more efficient mutating version `sweep_contract!`.
94
+ """
95
+ sweep_contract (LTN:: LabelledTensorNetwork , χ:: Int , τ:: Int ;
96
+ fast= false , valid= false , planar= false , connected= false , report= false ) =
97
+ sweep_contract! (deepcopy (LTN), χ, τ;
98
+ fast= fast, planar= planar, connected= connected, report= report)
99
+
100
+ sweep_contract (TN:: TensorNetwork , χ:: Int , τ:: Int ;
101
+ fast= false , valid= false , planar= false , connected= false , report= false ) =
102
+ sweep_contract! (deepcopy (TN), χ, τ;
103
+ fast= fast, planar= planar, connected= connected, report= report)
104
+
95
105
"""
106
+ sweep_contract!(LTN::LabelledTensorNetwork, χ, τ;
107
+ fast=false, valid=false, planar=false, connected=false, report=false)
108
+ sweep_contract!(TN::TensorNetwork, χ, τ;
109
+ fast=false, valid=false, planar=false, connected=false, report=false)
110
+ The mutating form of `sweep_contract`.
111
+ """
112
+ sweep_contract! (LTN:: LabelledTensorNetwork , χ:: Int , τ:: Int ;
113
+ fast= false , valid= false , planar= false , connected= false , report= false ) =
114
+ sweep_contract! (delabel (LTN), χ, τ;
115
+ fast= fast, planar= planar, connected= connected, report= report)
116
+
96
117
function sweep_contract! (TN:: TensorNetwork , χ:: Int , τ:: Int ;
97
118
fast= false ,valid= false ,planar= false ,connected= false ,report= false ):: Tuple{Float64,Int}
98
119
if ! fast
@@ -198,27 +219,3 @@ function sweep_contract!(TN::TensorNetwork, χ::Int, τ::Int;
198
219
h = Int (floor (log2 (abs (res))));
199
220
return (res/ exp2 (h),resexp+ h);
200
221
end
201
-
202
- sweep_contract! (
203
- LTN:: LabelledTensorNetwork , χ:: Int , τ:: Int ;
204
- fast= false , valid= false , planar= false , connected= false , report= false
205
- ) = sweep_contract! (
206
- delabel (LTN), χ, τ;
207
- fast= fast, planar= planar, connected= connected, report= report
208
- )
209
-
210
- sweep_contract (
211
- TN:: TensorNetwork , χ:: Int , τ:: Int ;
212
- fast= false , valid= false , planar= false , connected= false , report= false
213
- ) = sweep_contract! (
214
- deepcopy (TN), χ, τ;
215
- fast= fast, planar= planar, connected= connected, report= report
216
- )
217
-
218
- sweep_contract (
219
- LTN:: LabelledTensorNetwork , χ:: Int , τ:: Int ;
220
- fast= false , valid= false , planar= false , connected= false , report= false
221
- ) = sweep_contract! (
222
- deepcopy (LTN), χ, τ;
223
- fast= fast, planar= planar, connected= connected, report= report
224
- )
0 commit comments