Skip to content

Commit 2a853ff

Browse files
github-actions[bot]CompatHelper Juliamtfishmanlkdvos
authored
CompatHelper: bump compat for GradedArrays to 0.5, (keep existing compat) (#83)
Co-authored-by: CompatHelper Julia <[email protected]> Co-authored-by: Matt Fishman <[email protected]> Co-authored-by: mtfishman <[email protected]> Co-authored-by: Lukas Devos <[email protected]>
1 parent a241131 commit 2a853ff

File tree

10 files changed

+107
-174
lines changed

10 files changed

+107
-174
lines changed

Project.toml

Lines changed: 4 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.13"
4+
version = "0.5.14"
55

66
[deps]
77
Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"
@@ -14,6 +14,7 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1414
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
1515
Strided = "5e0ebb24-38b0-5f93-81fe-25c709ecae67"
1616
TensorAlgebra = "68bd88dc-f39d-4e12-b2ca-f046b68fcc6a"
17+
TensorKitSectors = "13a9c161-d5da-41f0-bcbd-e1a08ae0647f"
1718
TensorProducts = "decf83d6-1968-43f4-96dc-fdb3fe15fc6d"
1819
TypeParameterAccessors = "7e5a90cf-f82e-492e-a09b-e3e26432c138"
1920
WignerSymbols = "9f57e263-0b3d-5e2e-b1be-24f2bb48858b"
@@ -22,13 +23,14 @@ WignerSymbols = "9f57e263-0b3d-5e2e-b1be-24f2bb48858b"
2223
Accessors = "0.1.42"
2324
BlockArrays = "1.7"
2425
BlockSparseArrays = "0.10"
25-
GradedArrays = "0.4"
26+
GradedArrays = "0.5.2"
2627
HalfIntegers = "1.6"
2728
LRUCache = "1.6"
2829
LinearAlgebra = "1.10"
2930
Random = "1.10"
3031
Strided = "2.3"
3132
TensorAlgebra = "0.4"
33+
TensorKitSectors = "0.1, 0.2"
3234
TensorProducts = "0.1.7"
3335
TypeParameterAccessors = "0.4"
3436
WignerSymbols = "2.0.0"

src/fusion_trees/clebsch_gordan_tensors.jl

Lines changed: 20 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ using WignerSymbols: clebschgordan
77

88
using GradedArrays:
99
AbelianStyle,
10-
AbstractSector,
1110
NotAbelianStyle,
1211
O2,
13-
SU,
12+
SU2,
13+
SectorRange,
1414
SymmetryStyle,
15+
TrivialSector,
1516
dual,
1617
istrivial,
1718
quantum_dimension,
@@ -21,16 +22,17 @@ using GradedArrays:
2122
zero_odd
2223
using TensorAlgebra: contract
2324
using TensorProducts:
25+
import TensorKitSectors as TKS
2426

25-
function symbol_1j(s::AbstractSector)
27+
function symbol_1j(s::SectorRange)
2628
cgt = clebsch_gordan_tensor(s, dual(s), trivial(s), 1)
2729
return sqrt(quantum_dimension(s)) * cgt[:, :, 1]
2830
end
2931

3032
function clebsch_gordan_tensor(
31-
s1::AbstractSector,
32-
s2::AbstractSector,
33-
s3::AbstractSector,
33+
s1::SectorRange,
34+
s2::SectorRange,
35+
s3::SectorRange,
3436
arrow1::Bool,
3537
arrow2::Bool,
3638
inner_mult_index::Int,
@@ -47,91 +49,19 @@ function clebsch_gordan_tensor(
4749
return cgt
4850
end
4951

50-
function clebsch_gordan_tensor(s1::S, s2::S, s3::S, outer_mult_index::Int) where {S}
51-
return clebsch_gordan_tensor(SymmetryStyle(S), s1, s2, s3, outer_mult_index)
52-
end
53-
54-
function clebsch_gordan_tensor(
55-
::AbelianStyle, s1::S, s2::S, s3::S, outer_mult_index::Int
56-
) where {S}
57-
@assert outer_mult_index == 1
58-
return s1 s2 == s3 ? ones((1, 1, 1)) : zeros((1, 1, 1))
59-
end
60-
61-
function clebsch_gordan_tensor(::NotAbelianStyle, s1::O2, s2::O2, s3::O2, ::Int)
62-
return clebsch_gordan_tensor(s1, s2, s3) # no outer multiplicity
63-
end
64-
65-
function clebsch_gordan_tensor(s1::O2, s2::O2, s3::O2)
66-
d1 = quantum_dimension(s1)
67-
d2 = quantum_dimension(s2)
68-
d3 = quantum_dimension(s3)
69-
cgt = zeros((d1, d2, d3))
70-
s3 sectors(s1 s2) && return cgt
71-
72-
# adapted from TensorKit
73-
l1 = sector_label(s1)
74-
l2 = sector_label(s2)
75-
l3 = sector_label(s3)
76-
if l3 <= 0 # 0even or 0odd
77-
if l1 <= 0 && l2 <= 0
78-
cgt[1, 1, 1, 1] = 1.0
79-
else
80-
if istrivial(s3)
81-
cgt[1, 2, 1, 1] = 1.0 / sqrt(2)
82-
cgt[2, 1, 1, 1] = 1.0 / sqrt(2)
83-
else
84-
cgt[1, 2, 1, 1] = 1.0 / sqrt(2)
85-
cgt[2, 1, 1, 1] = -1.0 / sqrt(2)
86-
end
87-
end
88-
elseif l1 <= 0 # 0even or 0odd
89-
cgt[1, 1, 1, 1] = 1.0
90-
cgt[1, 2, 2, 1] = s1 == zero_odd(O2) ? -1.0 : 1.0
91-
elseif l2 == 0
92-
cgt[1, 1, 1, 1] = 1.0
93-
cgt[2, 1, 2, 1] = s2 == zero_odd(O2) ? -1.0 : 1.0
94-
elseif l3 == l1 + l2
95-
cgt[1, 1, 1, 1] = 1.0
96-
cgt[2, 2, 2, 1] = 1.0
97-
elseif l3 == l1 - l2
98-
cgt[1, 2, 1, 1] = 1.0
99-
cgt[2, 1, 2, 1] = 1.0
100-
elseif l3 == l2 - l1
101-
cgt[2, 1, 1, 1] = 1.0
102-
cgt[1, 2, 2, 1] = 1.0
52+
function clebsch_gordan_tensor(s1::S, s2::S, s3::S, outer_mult_index::Int = 1) where {S}
53+
CGC = TKS.fusiontensor(GradedArrays.label.((s1, s2, s3))...)
54+
outer_mult_index axes(CGC, 4) || throw(ArgumentError("invalid outer multiplicity index"))
55+
if TKS.FusionStyle(S) === TKS.GenericFusion()
56+
# TODO: do we want a view here?
57+
return CGC[:, :, :, outer_mult_index]
58+
else
59+
return dropdims(CGC; dims = 4)
10360
end
104-
return cgt
105-
end
106-
107-
function clebsch_gordan_tensor(::NotAbelianStyle, s1::SU{2}, s2::SU{2}, s3::SU{2}, ::Int)
108-
return clebsch_gordan_tensor(s1, s2, s3) # no outer multiplicity
109-
end
110-
111-
function clebsch_gordan_tensor(s1::SU{2}, s2::SU{2}, s3::SU{2})
112-
d1 = quantum_dimension(s1)
113-
d2 = quantum_dimension(s2)
114-
d3 = quantum_dimension(s3)
115-
j1 = half(d1 - 1)
116-
j2 = half(d2 - 1)
117-
j3 = half(d3 - 1)
118-
cgtensor = Array{Float64, 3}(undef, (d1, d2, d3))
119-
for (i, j, k) in Iterators.product(1:d1, 1:d2, 1:d3)
120-
m1 = j1 - i + 1
121-
m2 = j2 - j + 1
122-
m3 = j3 - k + 1
123-
cgtensor[i, j, k] = clebschgordan(j1, m1, j2, m2, j3, m3)
124-
end
125-
return cgtensor
12661
end
12762

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
63+
# TODO: remove once TensorKitSectors fixes this
64+
function clebsch_gordan_tensor(s1::TrivialSector, s2::TrivialSector, s3::TrivialSector, outer_mult_index::Int = 1)
65+
outer_mult_index == 1 || throw(ArgumentError("invalid outer multiplicity index"))
66+
return fill(1, (1, 1, 1))
13767
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"
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"

0 commit comments

Comments
 (0)