Skip to content

Commit 9818146

Browse files
committed
Fixes for GradedArrays.jl v0.5
1 parent 42977e4 commit 9818146

File tree

10 files changed

+105
-103
lines changed

10 files changed

+105
-103
lines changed

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "FusionTensors"
22
uuid = "e16ca583-1f51-4df0-8e12-57d32947d33e"
33
authors = ["ITensor developers <[email protected]> and contributors"]
4-
version = "0.5.14"
4+
version = "0.5.15"
55

66
[deps]
77
Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"
@@ -22,7 +22,7 @@ WignerSymbols = "9f57e263-0b3d-5e2e-b1be-24f2bb48858b"
2222
Accessors = "0.1.42"
2323
BlockArrays = "1.7"
2424
BlockSparseArrays = "0.10"
25-
GradedArrays = "0.4, 0.5"
25+
GradedArrays = "0.5"
2626
HalfIntegers = "1.6"
2727
LRUCache = "1.6"
2828
LinearAlgebra = "1.10"

src/fusion_trees/clebsch_gordan_tensors.jl

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ using WignerSymbols: clebschgordan
77

88
using GradedArrays:
99
AbelianStyle,
10-
AbstractSector,
1110
NotAbelianStyle,
1211
O2,
13-
SU,
12+
SU2,
13+
SectorRange,
1414
SymmetryStyle,
1515
dual,
1616
istrivial,
@@ -22,15 +22,15 @@ using GradedArrays:
2222
using TensorAlgebra: contract
2323
using TensorProducts:
2424

25-
function symbol_1j(s::AbstractSector)
25+
function symbol_1j(s::SectorRange)
2626
cgt = clebsch_gordan_tensor(s, dual(s), trivial(s), 1)
2727
return sqrt(quantum_dimension(s)) * cgt[:, :, 1]
2828
end
2929

3030
function clebsch_gordan_tensor(
31-
s1::AbstractSector,
32-
s2::AbstractSector,
33-
s3::AbstractSector,
31+
s1::SectorRange,
32+
s2::SectorRange,
33+
s3::SectorRange,
3434
arrow1::Bool,
3535
arrow2::Bool,
3636
inner_mult_index::Int,
@@ -104,11 +104,11 @@ function clebsch_gordan_tensor(s1::O2, s2::O2, s3::O2)
104104
return cgt
105105
end
106106

107-
function clebsch_gordan_tensor(::NotAbelianStyle, s1::SU{2}, s2::SU{2}, s3::SU{2}, ::Int)
107+
function clebsch_gordan_tensor(::NotAbelianStyle, s1::SU2, s2::SU2, s3::SU2, ::Int)
108108
return clebsch_gordan_tensor(s1, s2, s3) # no outer multiplicity
109109
end
110110

111-
function clebsch_gordan_tensor(s1::SU{2}, s2::SU{2}, s3::SU{2})
111+
function clebsch_gordan_tensor(s1::SU2, s2::SU2, s3::SU2)
112112
d1 = quantum_dimension(s1)
113113
d2 = quantum_dimension(s2)
114114
d3 = quantum_dimension(s3)
@@ -125,13 +125,14 @@ function clebsch_gordan_tensor(s1::SU{2}, s2::SU{2}, s3::SU{2})
125125
return cgtensor
126126
end
127127

128-
function clebsch_gordan_tensor(
129-
::NotAbelianStyle, s1::SU{3}, s2::SU{3}, s3::SU{3}, outer_mult_index::Int
130-
)
131-
d1 = quantum_dimension(s1)
132-
d2 = quantum_dimension(s2)
133-
d3 = quantum_dimension(s3)
134-
cgtensor = zeros(d1, d2, d3)
135-
# dummy
136-
return cgtensor
137-
end
128+
## TODO: Implement and move to `FusionTensorsSUNRepresentationsExt`.
129+
## function clebsch_gordan_tensor(
130+
## ::NotAbelianStyle, s1::SU{3}, s2::SU{3}, s3::SU{3}, outer_mult_index::Int
131+
## )
132+
## d1 = quantum_dimension(s1)
133+
## d2 = quantum_dimension(s2)
134+
## d3 = quantum_dimension(s3)
135+
## cgtensor = zeros(d1, d2, d3)
136+
## # dummy
137+
## return cgtensor
138+
## end

src/fusion_trees/fusiontree.jl

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,18 @@
55

66
using GradedArrays:
77
GradedArrays,
8-
×,
98
AbstractGradedUnitRange,
10-
AbstractSector,
11-
SectorProduct,
9+
SectorProductRange,
10+
SectorRange,
11+
×,
1212
arguments,
1313
flip,
1414
flip_dual,
1515
isdual,
1616
nsymbol,
1717
sector_multiplicities,
1818
sector_type,
19+
sectorproduct,
1920
sectors,
2021
to_gradedrange,
2122
trivial
@@ -125,7 +126,7 @@ function GradedArrays.:×(f1::SectorFusionTree, f2::SectorFusionTree)
125126
)
126127
end
127128

128-
function GradedArrays.arguments(f::SectorFusionTree{<:SectorProduct})
129+
function GradedArrays.arguments(f::SectorFusionTree{<:SectorProductRange})
129130
transposed_indices = outer_multiplicity_split.(
130131
Base.tail(leaves(f)),
131132
branch_sectors(f),
@@ -136,7 +137,7 @@ function GradedArrays.arguments(f::SectorFusionTree{<:SectorProduct})
136137
arguments_leaves = arguments.(leaves(f))
137138
arguments_branch_sectors = arguments.(branch_sectors(f))
138139
# TODO way to avoid explicit ntuple?
139-
# works fine for Tuple and NamedTuple SectorProduct
140+
# works fine for Tuple and NamedTuple SectorProductRange
140141
return ntuple(
141142
i -> SectorFusionTree(
142143
getindex.(arguments_leaves, i),
@@ -149,21 +150,21 @@ function GradedArrays.arguments(f::SectorFusionTree{<:SectorProduct})
149150
)
150151
end
151152

152-
function GradedArrays.arguments(f::SectorFusionTree{<:SectorProduct, 0})
153+
function GradedArrays.arguments(f::SectorFusionTree{<:SectorProductRange, 0})
153154
return map(arg -> SectorFusionTree((), (), arg, (), ()), arguments(root_sector(f)))
154155
end
155156

156-
function GradedArrays.arguments(f::SectorFusionTree{<:SectorProduct, 1})
157+
function GradedArrays.arguments(f::SectorFusionTree{<:SectorProductRange, 1})
157158
arguments_root = arguments(root_sector(f))
158159
arguments_leave = arguments(only(leaves(f)))
159-
# use map(keys) to stay agnostic with respect to SectorProduct implementation
160+
# use map(keys) to stay agnostic with respect to SectorProductRange implementation
160161
return map(keys(arguments_root)) do k
161162
return SectorFusionTree((arguments_leave[k],), arrows(f), arguments_root[k], (), ())
162163
end
163164
end
164165

165166
# TBD change type depending on AbelianStyle?
166-
fusiontree_eltype(::Type{<:AbstractSector}) = Float64
167+
fusiontree_eltype(::Type{<:SectorRange}) = Float64
167168

168169
# constructors
169170
function build_trees(legs::Vararg{AbstractGradedUnitRange})
@@ -175,7 +176,7 @@ function build_trees(legs::Vararg{AbstractGradedUnitRange})
175176
end
176177

177178
function build_trees(
178-
sectors_to_fuse::NTuple{N, <:AbstractSector}, arrows_to_fuse::NTuple{N, Bool}
179+
sectors_to_fuse::NTuple{N, <:SectorRange}, arrows_to_fuse::NTuple{N, Bool}
179180
) where {N}
180181
# construct all authorized trees with fixed outer sectors
181182
trees = [SectorFusionTree(first(sectors_to_fuse), first(arrows_to_fuse))]
@@ -186,18 +187,18 @@ end
186187
# ===================================== Internals ========================================
187188
#
188189

189-
# --------------- SectorProduct helper functions ---------------
190+
# --------------- SectorProductRange helper functions ---------------
190191
function outer_multiplicity_kron(
191192
sec1, sec2, fused, outer_multiplicity1, outer_multiplicity2
192193
)
193-
n = nsymbol(sec1, sec2, fused)
194+
n = Int(nsymbol(sec1, sec2, fused))
194195
linear_inds = LinearIndices((n, outer_multiplicity2))
195196
return linear_inds[outer_multiplicity1, outer_multiplicity2]
196197
end
197198

198199
function outer_multiplicity_split(
199200
sec1::S, sec2::S, fused::S, outer_mult_index::Integer
200-
) where {S <: SectorProduct}
201+
) where {S <: SectorProductRange}
201202
args1 = arguments(sec1)
202203
args2 = arguments(sec2)
203204
args12 = arguments(fused)
@@ -207,15 +208,15 @@ end
207208

208209
# --------------- Build trees ---------------
209210
# zero leg: need S to get sector type information
210-
function SectorFusionTree{S}() where {S <: AbstractSector}
211+
function SectorFusionTree{S}() where {S <: SectorRange}
211212
return SectorFusionTree((), (), trivial(S), (), ())
212213
end
213-
function SectorFusionTree{S}(::Tuple{}, ::Tuple{}) where {S <: AbstractSector}
214+
function SectorFusionTree{S}(::Tuple{}, ::Tuple{}) where {S <: SectorRange}
214215
return SectorFusionTree((), (), trivial(S), (), ())
215216
end
216217

217218
# one leg
218-
function SectorFusionTree(sect::AbstractSector, arrow::Bool)
219+
function SectorFusionTree(sect::SectorRange, arrow::Bool)
219220
return SectorFusionTree((sect,), (arrow,), sect, (), ())
220221
end
221222

@@ -227,7 +228,7 @@ end
227228

228229
function append_tree_leave(
229230
parent_tree::SectorFusionTree,
230-
branch_sector::AbstractSector,
231+
branch_sector::SectorRange,
231232
level_arrow::Bool,
232233
child_root_sector,
233234
outer_mult,
@@ -242,7 +243,7 @@ function append_tree_leave(
242243
end
243244

244245
function fuse_next_sector(
245-
parent_tree::SectorFusionTree, branch_sector::AbstractSector, level_arrow::Bool
246+
parent_tree::SectorFusionTree, branch_sector::SectorRange, level_arrow::Bool
246247
)
247248
new_space = to_gradedrange(root_sector(parent_tree) branch_sector)
248249
return mapreduce(
@@ -282,7 +283,7 @@ function to_array(f::SectorFusionTree)
282283
return grow_tensor_tree(tree_tensor, f)
283284
end
284285

285-
function to_array(f::SectorFusionTree{<:SectorProduct})
286+
function to_array(f::SectorFusionTree{<:SectorProductRange})
286287
args = convert.(Array, arguments(f))
287288
return reduce(_tensor_kron, args)
288289
end

src/fusiontensor/fusiontensor.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ using BlockSparseArrays:
66
AbstractBlockSparseMatrix, BlockSparseArray, eachblockstoredindex, to_block_indices
77
using GradedArrays:
88
AbstractGradedUnitRange,
9-
SectorProduct,
9+
SymmetryStyle,
1010
TrivialSector,
1111
dual,
1212
findfirstblock,
@@ -35,7 +35,7 @@ function flip_domain(nonflipped_col_axis, nonflipped_trees_to_ranges)
3535
return col_axis, domain_trees_to_ranges_mapping
3636
end
3737

38-
function fuse_axes(::Type{S}, ::Tuple{}) where {S <: AbstractSector}
38+
function fuse_axes(::Type{S}, ::Tuple{}) where {S <: SectorRange}
3939
fused_axis = trivial_axis(S)
4040
trees_to_ranges_mapping = Dict([SectorFusionTree{S}() => Block(1)[1:1]])
4141
return fused_axis, trees_to_ranges_mapping
@@ -253,7 +253,9 @@ function GradedArrays.sector_type(::Type{FT}) where {FT <: FusionTensor}
253253
return sector_type(type_parameters(FT, 3))
254254
end
255255

256-
SymmetryStyle(::Type{FT}) where {FT <: FusionTensor} = SymmetryStyle(sector_type(FT))
256+
function GradedArrays.SymmetryStyle(::Type{FT}) where {FT <: FusionTensor}
257+
return SymmetryStyle(sector_type(FT))
258+
end
257259

258260
# ============================== FusionTensor interface ==================================
259261

src/fusiontensor/fusiontensoraxes.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ using BlockArrays: BlockArrays
22
using GradedArrays:
33
GradedArrays,
44
AbstractGradedUnitRange,
5-
AbstractSector,
65
SymmetryStyle,
76
TrivialSector,
87
dual,

test/Project.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ FusionTensors = "e16ca583-1f51-4df0-8e12-57d32947d33e"
66
GradedArrays = "bc96ca6e-b7c8-4bb6-888e-c93f838762c2"
77
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
88
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
9+
SUNRepresentations = "1a50b95c-7aac-476d-a9ce-2bfc675fc617"
910
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
1011
Suppressor = "fd094767-a336-5f1f-9728-57cf17d0bbfb"
1112
TensorAlgebra = "68bd88dc-f39d-4e12-b2ca-f046b68fcc6a"
@@ -17,9 +18,10 @@ Aqua = "0.8.11"
1718
BlockArrays = "1.6"
1819
BlockSparseArrays = "0.10"
1920
FusionTensors = "0.5"
20-
GradedArrays = "0.4, 0.5"
21+
GradedArrays = "0.5"
2122
LinearAlgebra = "1.10.0"
2223
Random = "1.10"
24+
SUNRepresentations = "0.3.1"
2325
SafeTestsets = "0.1.0"
2426
Suppressor = "0.2.8"
2527
TensorAlgebra = "0.4"

test/test_array_cast.jl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ using Test: @test, @test_throws, @testset
44
using BlockArrays: Block, BlockedArray, blocksize
55

66
using FusionTensors: FusionTensor, data_matrix, to_fusiontensor
7-
using GradedArrays: O2, SectorProduct, SU2, TrivialSector, U1, dual, gradedrange
7+
using GradedArrays: O2, SU2, TrivialSector, U1, dual, gradedrange, sectorproduct
88
using TensorProducts: tensor_product
99

1010
include("setup.jl")
@@ -389,20 +389,21 @@ end
389389
tRVB[i, 1, 1, 1, i + 1] = 1.0
390390
end
391391

392-
gd = gradedrange([SectorProduct(s, U1(3)) => 1])
392+
gd = gradedrange([sectorproduct(s, U1(3)) => 1])
393393
codomain_legs = (dual(gd),)
394-
gD = gradedrange([SectorProduct(SU2(0), U1(1)) => 1, SectorProduct(s, U1(0)) => 1])
394+
gD = gradedrange([sectorproduct(SU2(0), U1(1)) => 1, sectorproduct(s, U1(0)) => 1])
395395
domain_legs = (gD, gD, gD, gD)
396396
ft = to_fusiontensor(tRVB, codomain_legs, domain_legs)
397397
@test isnothing(check_sanity(ft))
398398
@test Array(ft) tRVB
399399

400400
# same with NamedTuples
401-
gd_nt = gradedrange([SectorProduct(; S = s, N = U1(3)) => 1])
401+
gd_nt = gradedrange([sectorproduct((; S = s, N = U1(3))) => 1])
402402
codomain_legs_nt = (dual(gd_nt),)
403403
gD_nt = gradedrange(
404404
[
405-
SectorProduct(; S = SU2(0), N = U1(1)) => 1, SectorProduct(; S = s, N = U1(0)) => 1,
405+
sectorproduct((; S = SU2(0), N = U1(1))) => 1,
406+
sectorproduct((; S = s, N = U1(0))) => 1,
406407
]
407408
)
408409
domain_legs_nt = (gD_nt, gD_nt, gD_nt, gD_nt)

0 commit comments

Comments
 (0)