FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
TensorKit.jl/src/TensorKit.jl at main · QuantumKitHub/TensorKit.jl · GitHub
QuantumKitHub
/
TensorKit.jl
Public
Notifications
You must be signed in to change notification settings
Fork
65
Star
416
Code
Issues
28
Pull requests
17
Discussions
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
TensorKit.jl
/
src
/
TensorKit.jl
Copy path
More file actions
More file actions
Latest commit
History
History
History
294 lines (241 loc) · 10.3 KB
Breadcrumbs
TensorKit.jl
/
src
/
TensorKit.jl
Copy path
File metadata and controls
294 lines (241 loc) · 10.3 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
#
TensorKit.jl
#
#
Main file for module TensorKit, a Julia package for working with
#
with tensors, tensor operations and tensor factorizations
module
TensorKit
#
Exports
#
---------
#
Reexport common sector types:
export
Sector, AbstractIrrep, Irrep, GroupElement
export
FusionStyle, UniqueFusion, MultipleFusion, MultiplicityFreeFusion, SimpleFusion, GenericFusion
export
UnitStyle, SimpleUnit, GenericUnit
export
BraidingStyle, SymmetricBraiding, Bosonic, Fermionic, Anyonic, NoBraiding, HasBraiding
export
Trivial, Z2Irrep, Z3Irrep, Z4Irrep, ZNIrrep, LargeZNIrrep
export
ZNElement, Z2Element, Z3Element, Z4Element, DNIrrep, A4Irrep, U1Irrep, SU2Irrep, CU1Irrep
export
ProductSector, NamedSector,
@NamedSector
, TimeReversed
export
FermionParity, FermionNumber, FermionSpin
export
FibonacciAnyon, IsingAnyon, IsingBimodule
#
Export common vector space, fusion tree and tensor types
export
VectorSpace, Field, ElementarySpace
#
abstract vector spaces
export
InnerProductStyle, NoInnerProduct, HasInnerProduct, EuclideanInnerProduct
export
ComplexSpace, CartesianSpace, GeneralSpace, GradedSpace
#
concrete spaces
export
ZNSpace, Z2Space, Z3Space, Z4Space, U1Space, CU1Space, SU2Space
export
Vect, Rep
#
space constructors
export
CompositeSpace, ProductSpace
#
composite spaces
export
FusionTree
export
IndexSpace, HomSpace, TensorSpace, TensorMapSpace
export
AbstractTensorMap, AbstractTensor, TensorMap, Tensor
#
tensors and tensor properties
export
DiagonalTensorMap, BraidingTensor
export
SpaceMismatch, SectorMismatch, IndexError
#
error types
#
Export general vector space methods
export
space, field, dual, dim, reduceddim, dims, fuse, flip, isdual
export
unitspace, zerospace, oplus, ominus
export
leftunitspace, rightunitspace, isunitspace
export
insertleftunit, insertrightunit, removeunit
#
partial order for vector spaces
export
infimum, supremum, isisomorphic, ismonomorphic, isepimorphic
#
Reexport methods for sectors and properties thereof
export
sectortype, sectors, hassector
export
unit, rightunit, leftunit, allunits, isunit, otimes, deligneproduct, timereversed
export
Nsymbol, Fsymbol, Rsymbol, Bsymbol, frobenius_schur_phase, frobenius_schur_indicator, twist, fusiontensor
export
sectorscalartype, fusionscalartype, braidingscalartype, dimscalartype
#
Export methods for fusion trees
export
fusiontrees, braid, permute, transpose
#
other fusion tree manipulations, should not be exported:
#
export insertat, split, merge, repartition, artin_braid,
#
bendleft, bendright, foldleft, foldright, cycleclockwise, cycleanticlockwise
#
some unicode
export
⊕
,
⊗
,
⊖
,
×
,
⊠
, ℂ, ℝ, ℤ,
←
,
→
,
≾
,
≿
,
≅
,
≺
,
≻
export
ℤ₂, ℤ₃, ℤ₄, D₃, D₄, A₄, U₁, SU, SU₂, CU₁
export
fℤ₂, fU₁, fSU₂
export
ℤ₂Space, ℤ₃Space, ℤ₄Space, U₁Space, CU₁Space, SU₂Space
#
Export tensor map methods
export
domain, codomain, numind, numout, numin, domainind, codomainind, allind
export
spacetype, storagetype, scalartype, tensormaptype
export
blocksectors, blockdim, block, blocks, subblocks, subblock
#
random methods for constructor
export
randisometry, randisometry!, rand, rand!, randn, randn!
#
special purpose constructors
export
zero, one, one!, id, id!, isomorphism, isomorphism!, unitary, unitary!, isometry,
isometry!
#
reexport most of VectorInterface and some more tensor algebra
export
zerovector, zerovector!, zerovector!!, scale, scale!, scale!!, add, add!, add!!
export
inner, dot, norm, normalize, normalize!, tr
#
factorizations
export
mul!, lmul!, rmul!, adjoint!, pinv, axpy!, axpby!
export
left_orth, right_orth, left_null, right_null,
left_orth!, right_orth!, left_null!, right_null!,
left_polar, left_polar!, right_polar, right_polar!,
qr_full, qr_compact, qr_null, lq_full, lq_compact, lq_null,
qr_full!, qr_compact!, qr_null!, lq_full!, lq_compact!, lq_null!,
svd_compact!, svd_full!, svd_trunc!, svd_compact, svd_full, svd_trunc, svd_vals, svd_vals!,
exp, exp!, exponential, exponential!,
eigh_full!, eigh_full, eigh_trunc!, eigh_trunc, eigh_vals!, eigh_vals,
eig_full!, eig_full, eig_trunc!, eig_trunc, eig_vals!, eig_vals,
eigen, eigen!,
ishermitian, project_hermitian, project_hermitian!,
isantihermitian, project_antihermitian, project_antihermitian!,
isisometric, isunitary, project_isometric, project_isometric!,
isposdef, isposdef!, sylvester, rank, cond
export
braid, braid!, permute, permute!, transpose, transpose!, twist, twist!, repartition, repartition!
export
catdomain, catcodomain, absorb, absorb!
#
tensor operations
export
@tensor
,
@tensoropt
,
@ncon
, ncon,
@planar
,
@plansor
export
scalar, add!, contract!
#
truncation schemes
export
notrunc, truncrank, trunctol, truncfilter, truncspace, truncerror
#
cache management
export
empty_globalcaches!
#
Imports
#
---------
using
TupleTools
using
Strided
using
VectorInterface
using
TensorOperations
:
TensorOperations,
@tensor
,
@tensoropt
,
@ncon
, ncon
using
TensorOperations
:
IndexTuple, Index2Tuple, linearize, AbstractBackend
const
TO
=
TensorOperations
using
MatrixAlgebraKit
using
Dictionaries
:
Dictionaries, Dictionary, Indices, gettoken, gettokenvalue
using
LRUCache
using
OhMyThreads
using
ScopedValues
using
TimerOutputs
:
TimerOutputs, TimerOutput,
@timeit_debug
using
TensorKitSectors
import
TensorKitSectors
:
dim, BraidingStyle, FusionStyle,
⊠
,
⊗
,
×
import
TensorKitSectors
:
dual, type_repr, fusiontensor
import
TensorKitSectors
:
twist
using
Base
:
@boundscheck
,
@propagate_inbounds
,
@constprop
,
OneTo, tail, front,
tuple_type_head, tuple_type_tail, tuple_type_cons,
SizeUnknown, HasLength, HasShape, IsInfinite, EltypeUnknown, HasEltype
using
Base
.
Iterators
:
product, filter
using
Printf
:
@sprintf
,
@printf
using
LinearAlgebra
:
LinearAlgebra, BlasFloat
using
LinearAlgebra
:
norm, dot, normalize, normalize!, tr,
axpy!, axpby!, lmul!, rmul!, mul!, ldiv!, rdiv!,
adjoint, adjoint!, transpose, transpose!,
lu, pinv, sylvester,
eigen, eigen!, svd, svd!,
isposdef, isposdef!, rank, cond,
Diagonal, Hermitian
import
Base
.
Meta
using
Random
:
Random, rand!, randn!
using
Adapt
:
Adapt
#
Auxiliary files
#
-----------------
include
(
"
auxiliary/timers.jl
"
)
include
(
"
auxiliary/auxiliary.jl
"
)
include
(
"
auxiliary/caches.jl
"
)
include
(
"
auxiliary/dicts.jl
"
)
include
(
"
auxiliary/iterators.jl
"
)
include
(
"
auxiliary/random.jl
"
)
#
--------------------------------------------------------------------
#
experiment with different dictionaries
const
SectorDict{K, V}
=
SortedVectorDict{K, V}
const
FusionTreeDict{K, V}
=
Dict{K, V}
#
--------------------------------------------------------------------
#
Exception types:
#
------------------
abstract type
TensorException
<:
Exception
end
#
Exception type for all errors related to sector mismatch
struct
SectorMismatch{S
<:
Union{Nothing, AbstractString}
}
<:
TensorException
message
::
S
end
SectorMismatch
()
=
SectorMismatch
{Nothing}
(
nothing
)
Base
.
showerror
(io
::
IO
,
::
SectorMismatch{Nothing}
)
=
print
(io,
"
SectorMismatch()
"
)
Base
.
showerror
(io
::
IO
, e
::
SectorMismatch
)
=
print
(io,
"
SectorMismatch(
\"
"
, e
.
message,
"
\"
)
"
)
#
Exception type for all errors related to vector space mismatch
struct
SpaceMismatch{S
<:
Union{Nothing, AbstractString}
}
<:
TensorException
message
::
S
end
SpaceMismatch
()
=
SpaceMismatch
{Nothing}
(
nothing
)
function
Base
.
showerror
(io
::
IO
, err
::
SpaceMismatch
)
print
(io,
"
SpaceMismatch:
"
)
isnothing
(err
.
message)
||
print
(io, err
.
message)
return
nothing
end
#
Exception type for all errors related to invalid tensor index specification.
struct
IndexError{S
<:
Union{Nothing, AbstractString}
}
<:
TensorException
message
::
S
end
IndexError
()
=
IndexError
{Nothing}
(
nothing
)
Base
.
showerror
(io
::
IO
,
::
IndexError{Nothing}
)
=
print
(io,
"
IndexError()
"
)
Base
.
showerror
(io
::
IO
, e
::
IndexError
)
=
print
(io,
"
IndexError(
"
, e
.
message,
"
)
"
)
#
Constructing and manipulating fusion trees and iterators thereof
#
------------------------------------------------------------------
include
(
"
fusiontrees/fusiontrees.jl
"
)
#
Definitions and methods for vector spaces
#
-------------------------------------------
include
(
"
spaces/vectorspaces.jl
"
)
#
ElementarySpace types
include
(
"
spaces/cartesianspace.jl
"
)
include
(
"
spaces/complexspace.jl
"
)
include
(
"
spaces/generalspace.jl
"
)
include
(
"
spaces/gradedspace.jl
"
)
include
(
"
spaces/planarspace.jl
"
)
#
CompositeSpace types
include
(
"
spaces/productspace.jl
"
)
include
(
"
spaces/deligne.jl
"
)
#
HomSpace
include
(
"
spaces/homspace.jl
"
)
#
Derived information
include
(
"
spaces/structure.jl
"
)
#
Multithreading settings
#
-------------------------
const
TRANSFORMER_THREADS
=
Ref
(
1
)
#
while timing, force serial execution: timer sections may only be entered from one task
get_num_transformer_threads
()
=
timers_enabled
()
?
1
:
TRANSFORMER_THREADS[]
function
set_num_transformer_threads
(n
::
Int
)
N
=
Base
.
Threads
.
nthreads
()
if
n
>
N
n
=
N
Strided
.
_set_num_threads_warn
(n)
end
return
TRANSFORMER_THREADS[]
=
n
end
const
TREEMANIPULATION_THREADS
=
Ref
(
1
)
get_num_manipulation_threads
()
=
timers_enabled
()
?
1
:
TREEMANIPULATION_THREADS[]
function
set_num_manipulation_threads
(n
::
Int
)
N
=
Base
.
Threads
.
nthreads
()
if
n
>
N
n
=
N
Strided
.
_set_num_threads_warn
(n)
end
return
TREEMANIPULATION_THREADS[]
=
n
end
#
Definitions and methods for tensors
#
-------------------------------------
#
general definitions
include
(
"
tensors/abstracttensor.jl
"
)
include
(
"
tensors/backends.jl
"
)
include
(
"
tensors/blockiterators.jl
"
)
include
(
"
tensors/sectorvector.jl
"
)
include
(
"
tensors/tensor.jl
"
)
include
(
"
tensors/adjoint.jl
"
)
include
(
"
tensors/linalg.jl
"
)
include
(
"
tensors/vectorinterface.jl
"
)
include
(
"
tensors/tensoroperations.jl
"
)
include
(
"
tensors/treetransformers.jl
"
)
include
(
"
tensors/indexmanipulations.jl
"
)
include
(
"
tensors/diagonal.jl
"
)
include
(
"
tensors/braidingtensor.jl
"
)
include
(
"
factorizations/factorizations.jl
"
)
using
.
Factorizations
#
# Planar macros and related functionality
#
#-----------------------------------------
@nospecialize
using
Base
.
Meta
:
isexpr
include
(
"
planar/analyzers.jl
"
)
include
(
"
planar/preprocessors.jl
"
)
include
(
"
planar/postprocessors.jl
"
)
include
(
"
planar/macros.jl
"
)
@specialize
include
(
"
planar/planaroperations.jl
"
)
#
include some AD specific things at the end
#
once all types have been declared
#
------------------------
include
(
"
auxiliary/ad.jl
"
)
include
(
"
pullbacks/tensoroperations.jl
"
)
include
(
"
pullbacks/indexmanipulations.jl
"
)
include
(
"
precompile/precompile.jl
"
)
end
Back
|
FazBrowse Home
|
New Git URL