@@ -3,7 +3,8 @@ struct BimoduleSector{Name} <: Sector
33 j:: Int
44 label:: Int
55 function BimoduleSector {:A4} (i:: Int , j:: Int , label:: Int )
6- i <= 12 && j <= 12 || throw (DomainError (" object outside the matrix A4" ))
6+ i <= size (BimoduleSector{:A4 }) && j <= size (BimoduleSector{:A4 }) ||
7+ throw (DomainError (" object outside the matrix A4" ))
78 return label <= _numlabels (BimoduleSector{:A4 }, i, j) ? new {:A4} (i, j, label) :
89 throw (DomainError (" label outside category A4($i , $j )" ))
910 end
@@ -21,12 +22,15 @@ function Base.convert(::Type{BimoduleSector{Name}}, d::NTuple{3,Int}) where {Nam
2122 return BimoduleSector {Name} (d... )
2223end
2324
25+ Base. size (:: Type{A4Object} ) = 7
26+
2427Base. IteratorSize (:: Type{<:SectorValues{<:BimoduleSector}} ) = Base. SizeUnknown ()
2528
2629# TODO : generalize?
2730function Base. iterate (iter:: SectorValues{A4Object} , (I, label)= (1 , 1 ))
28- I > 12 * 12 && return nothing
29- i, j = CartesianIndices ((12 , 12 ))[I]. I
31+ s = size (A4Object)
32+ I > s * s && return nothing
33+ i, j = CartesianIndices ((s, s))[I]. I
3034 maxlabel = _numlabels (A4Object, i, j)
3135 return if label > maxlabel
3236 iterate (iter, (I + 1 , 1 ))
@@ -36,7 +40,8 @@ function Base.iterate(iter::SectorValues{A4Object}, (I, label)=(1, 1))
3640end
3741
3842function Base. length (:: SectorValues{A4Object} )
39- return sum (_numlabels (A4Object, i, j) for i in 1 : 12 , j in 1 : 12 )
43+ s = size (A4Object)
44+ return sum (_numlabels (A4Object, i, j) for i in 1 : s, j in 1 : s)
4045end
4146
4247TensorKitSectors. FusionStyle (:: Type{A4Object} ) = GenericFusion ()
6065const artifact_path = joinpath (artifact " fusiondata" , " MultiTensorKit.jl-data-v0.1.3" )
6166
6267function extract_Nsymbol (:: Type{A4Object} )
63- filename = joinpath (artifact_path, " A4" , " Nsymbol.json" )
64- isfile (filename) || throw (LoadError (filename, 0 , " Nsymbol file not found for $Name " ))
65- json_string = read (filename, String)
66- Narray = copy (JSON3. read (json_string))
67- return map (reshape (Narray, 12 , 12 , 12 )) do x
68- y = Dict {NTuple{3,Int},Int} ()
69- for (k, v) in x
70- a, b, c = parse .(Int, split (string (k)[2 : (end - 1 )], " , " ))
71- y[(a, b, c)] = v
72- end
73- return y
68+ filename = joinpath (artifact_path, " A4" , " Nsymbol.txt" )
69+ isfile (filename) || throw (LoadError (filename, 0 , " Nsymbol file not found for A4" ))
70+ Narray = readdlm (filename) # matrix with 7 columns
71+
72+ data_dict = Dict {NTuple{3,Int},Dict{NTuple{3,Int},Int}} ()
73+ for row in eachrow (Narray)
74+ i, j, k, a, b, c, N = Int .(@view (row[1 : size (A4Object)]))
75+ colordict = get! (data_dict, (i, j, k), Dict {NTuple{3,Int},Int} ())
76+ push! (colordict, (a, b, c) => N)
7477 end
78+
79+ return data_dict
7580end
7681
77- const Ncache = IdDict{Type{<: BimoduleSector },Array{Dict{NTuple{3 ,Int},Int},3 }}()
82+ const Ncache = IdDict{Type{<: BimoduleSector },
83+ Dict{NTuple{3 ,Int},Dict{NTuple{3 ,Int},Int}}}()
7884
7985function _get_Ncache (:: Type{T} ) where {T<: BimoduleSector }
8086 global Ncache
102108
103109function extract_dual (:: Type{A4Object} )
104110 N = _get_Ncache (A4Object)
105- ncats = size (N, 1 )
111+ ncats = size (A4Object )
106112 Is = zeros (Int, ncats)
107113
108114 map (1 : ncats) do i
@@ -175,24 +181,22 @@ end
175181
176182function extract_Fsymbol (:: Type{A4Object} )
177183 result = Dict {NTuple{4,Int},Dict{NTuple{6,Int},Array{ComplexF64,4}}} ()
178- for i in 1 : 12
179- filename = joinpath (artifact_path, " A4" , " Fsymbol_$i .txt" )
180- @assert isfile (filename) " cannot find $filename "
181- Farray_part = readdlm (filename)
182- for ((i, j, k, l), colordict) in convert_Fs (Farray_part)
183- result[(i, j, k, l)] = Dict {NTuple{6,Int},Array{ComplexF64,4}} ()
184- for ((a, b, c, d, e, f), Fvals) in colordict
185- a_ob, b_ob, c_ob, d_ob, e_ob, f_ob = A4Object .(((i, j, a), (j, k, b),
186- (k, l, c), (i, l, d),
187- (i, k, e), (j, l, f)))
188- result[(i, j, k, l)][(a, b, c, d, e, f)] = zeros (ComplexF64,
189- Nsymbol (a_ob, b_ob, e_ob),
190- Nsymbol (e_ob, c_ob, d_ob),
191- Nsymbol (b_ob, c_ob, f_ob),
192- Nsymbol (a_ob, f_ob, d_ob))
193- for (I, v) in Fvals
194- result[(i, j, k, l)][(a, b, c, d, e, f)][I] = v
195- end
184+ filename = joinpath (artifact_path, " A4" , " Fsymbol.txt" )
185+ @assert isfile (filename) " cannot find $filename "
186+ Farray = readdlm (filename)
187+ for ((i, j, k, l), colordict) in convert_Fs (Farray)
188+ result[(i, j, k, l)] = Dict {NTuple{6,Int},Array{ComplexF64,4}} ()
189+ for ((a, b, c, d, e, f), Fvals) in colordict
190+ a_ob, b_ob, c_ob, d_ob, e_ob, f_ob = A4Object .(((i, j, a), (j, k, b),
191+ (k, l, c), (i, l, d),
192+ (i, k, e), (j, l, f)))
193+ result[(i, j, k, l)][(a, b, c, d, e, f)] = zeros (ComplexF64,
194+ Nsymbol (a_ob, b_ob, e_ob),
195+ Nsymbol (e_ob, c_ob, d_ob),
196+ Nsymbol (b_ob, c_ob, f_ob),
197+ Nsymbol (a_ob, f_ob, d_ob))
198+ for (I, v) in Fvals
199+ result[(i, j, k, l)][(a, b, c, d, e, f)][I] = v
196200 end
197201 end
198202 end
@@ -254,7 +258,8 @@ function TensorKit.blocksectors(W::TensorMapSpace{S,N₁,N₂}) where
254258 dom = domain (W)
255259 if N₁ == 0 && N₂ == 0 # 0x0-dimensional TensorMap is just a scalar, return all units
256260 # this is a problem in full contractions where the coloring outside is 𝒞
257- return NTuple {12,A4Object} (one (A4Object (i, i, 1 )) for i in 1 : 12 ) # have to return all units b/c no info on W in this case
261+ return NTuple {size(A4Object),A4Object} (one (A4Object (i, i, 1 ))
262+ for i in 1 : size (A4Object)) # have to return all units b/c no info on W in this case
258263 elseif N₁ == 0
259264 @assert N₂ != 0 " one of Type A4Object doesn't exist"
260265 return filter! (isone, collect (blocksectors (dom)))
0 commit comments