66
77const A4Object = BimoduleSector{:A4 }
88
9+ # Utility implementations
10+ # -----------------------
11+ function Base. isless (a:: I , b:: I ) where {I<: BimoduleSector }
12+ return isless ((a. i, a. j, a. label), (b. i, b. j, b. label))
13+ end
14+ Base. hash (a:: BimoduleSector , h:: UInt ) = hash (a. i, hash (a. j, hash (a. label, h)))
15+ Base. convert (:: Type{BimoduleSector{Name}} , d:: NTuple{3,Int} ) = BimoduleSector {Name} (d... )
16+
17+ Base. IteratorSize (:: Type{SectorValues{<:BimoduleSector}} ) = Base. SizeUnknown ()
18+
19+ # TODO : generalize?
20+ # TODO : numlabels?
21+ function Base. iterate (iter:: SectorValues{A4Object} , (I, label)= (1 , 1 ))
22+ I > 12 * 12 && return nothing
23+ i, j = CartesianIndices ((12 , 12 ))[I]. I
24+ maxlabel = numlabels (A4Object, i, j)
25+ return if label > maxlabel
26+ iterate (iter, (I + 1 , 1 ))
27+ else
28+ A4Object (i, j, label), (I, label + 1 )
29+ end
30+ end
31+
32+ TensorKitSectors. FusionStyle (:: Type{A4Object} ) = GenericFusion ()
33+ TensorKitSectors. BraidingStyle (:: Type{A4Object} ) = NoBraiding ()
34+
35+ function TensorKitSectors.:⊗ (a:: A4Object , b:: A4Object )
36+ @assert a. j == b. i
37+ return Iterators. filter (c -> NSymbol (a, b, c) > 0 ,
38+ map (label -> A4Object (a. i, b. j, label),
39+ numlabels (A4Object, a. i, b. j)))
40+ end
41+
42+ # TODO : can I assume A4Irrep(i, i, 1) is identity?
43+ function Base. conj (a:: A4Object )
44+ i, j = a. i, a. j
45+ label = findfirst (x -> Nsymbol (a, A4Irrep (j, i, x), A4Irrep (i, i, 1 )) == 1 ,
46+ 1 : numlabels (A4Object, j, i))
47+ return A4Object (j, i, label)
48+ end
49+
950# Data from files
1051# ---------------
1152const artifact_path = joinpath (artifact " fusiondata" , " MultiTensorKit.jl-data-v0.1.0" )
@@ -24,14 +65,13 @@ function extract_Nsymbol(::Type{A4Object})
2465 end
2566end
2667
27- let Ncache = extract_Nsymbol (A4Object)
28- function TensorKitSectors. Nsymbol (a:: I , b:: I , c:: I ) where {I<: A4Object }
29- # TODO : should this error or return 0?
30- (a. j == b. i && a. i == c. i && b. j == c. j) ||
31- throw (ArgumentError (" invalid fusion channel" ))
32- i, j, k = a. i, a. j, b. j
33- return get (Ncache[i, j, k], (a. label, b. label, c. label), 0 )
34- end
68+ const A4_Ncache = extract_Nsymbol (A4Object)
69+ function TensorKitSectors. Nsymbol (a:: I , b:: I , c:: I ) where {I<: A4Object }
70+ # TODO : should this error or return 0?
71+ (a. j == b. i && a. i == c. i && b. j == c. j) ||
72+ throw (ArgumentError (" invalid fusion channel" ))
73+ i, j, k = a. i, a. j, b. j
74+ return get (A4_Ncache[i, j, k], (a. label, b. label, c. label), 0 )
3575end
3676
3777function extract_Fsymbol (:: Type{A4Object} )
@@ -50,20 +90,19 @@ function extract_Fsymbol(::Type{A4Object})
5090 end
5191end
5292
53- let Fcache = extract_Fsymbol (A4Object)
54- function TensorKitSectors. Fsymbol (a:: I , b:: I , c:: I , d:: I , e:: I ,
55- f:: I ) where {I<: A4Object }
56- # TODO : should this error or return 0?
57- (a. j == b. i && b. j == c. i && a. i == d. i && c. j == d. j &&
58- a. i == e. i && b. j == e. j && f. i == a. j && f. j == c. j) ||
59- throw (ArgumentError (" invalid fusion channel" ))
93+ const A4_Fcache = extract_Fsymbol (A4Object)
94+ function TensorKitSectors. Fsymbol (a:: I , b:: I , c:: I , d:: I , e:: I ,
95+ f:: I ) where {I<: A4Object }
96+ # TODO : should this error or return 0?
97+ (a. j == b. i && b. j == c. i && a. i == d. i && c. j == d. j &&
98+ a. i == e. i && b. j == e. j && f. i == a. j && f. j == c. j) ||
99+ throw (ArgumentError (" invalid fusion channel" ))
60100
61- i, j, k, l = a. i, a. j, b. j, c. j
62- return get (Fcache[i, j, k, l],
63- (a. label, b. label, c. label, d. label, e. label, f. label)) do
64- return zeros (sectorscalartype (A4Object),
65- (Nsymbol (a, b, e), Nsymbol (e, c, d), Nsymbol (b, c, f),
66- Nsymbol (a, f, d)))
67- end
101+ i, j, k, l = a. i, a. j, b. j, c. j
102+ return get (A4_Fcache[i, j, k, l],
103+ (a. label, b. label, c. label, d. label, e. label, f. label)) do
104+ return zeros (sectorscalartype (A4Object),
105+ (Nsymbol (a, b, e), Nsymbol (e, c, d), Nsymbol (b, c, f),
106+ Nsymbol (a, f, d)))
68107 end
69108end
0 commit comments