Skip to content

Commit 64c6ac4

Browse files
committed
pass basic tests
1 parent bc22b8d commit 64c6ac4

File tree

8 files changed

+34
-29
lines changed

8 files changed

+34
-29
lines changed

Project.toml

Lines changed: 7 additions & 7 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.2.0"
4+
version = "0.2.1"
55

66
[deps]
77
Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"
@@ -12,26 +12,26 @@ HalfIntegers = "f0d1745a-41c9-11e9-1dd9-e5d34d218721"
1212
LRUCache = "8ac3fa9e-de4c-5943-b1dc-09c6b5f20637"
1313
LabelledNumbers = "f856a3a6-4152-4ec4-b2a7-02c1a55d7993"
1414
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
15-
SparseArraysBase = "0d5efcca-f356-4864-8770-e1ed8d78f208"
1615
Strided = "5e0ebb24-38b0-5f93-81fe-25c709ecae67"
1716
SymmetrySectors = "f8a8ad64-adbc-4fce-92f7-ffe2bb36a86e"
1817
TensorAlgebra = "68bd88dc-f39d-4e12-b2ca-f046b68fcc6a"
18+
TensorProducts = "decf83d6-1968-43f4-96dc-fdb3fe15fc6d"
1919
TypeParameterAccessors = "7e5a90cf-f82e-492e-a09b-e3e26432c138"
2020
WignerSymbols = "9f57e263-0b3d-5e2e-b1be-24f2bb48858b"
2121

2222
[compat]
2323
Accessors = "0.1.39"
2424
BlockArrays = "1.2.0"
25-
BlockSparseArrays = "0.2.9"
26-
GradedUnitRanges = "0.1.1"
25+
BlockSparseArrays = "0.3.9"
26+
GradedUnitRanges = "0.2.2"
2727
HalfIntegers = "1.6.0"
2828
LRUCache = "1.6.1"
2929
LabelledNumbers = "0.1.0"
3030
LinearAlgebra = "1.10.0"
31-
SparseArraysBase = "0.2.0"
3231
Strided = "2.2.0"
33-
SymmetrySectors = "0.1.1"
34-
TensorAlgebra = "0.1.5"
32+
SymmetrySectors = "0.1.7"
33+
TensorAlgebra = "0.2.4"
34+
TensorProducts = "0.1.3"
3535
TypeParameterAccessors = "0.2.0"
3636
WignerSymbols = "2.0.0"
3737
julia = "1.10"

src/fusion_trees/clebsch_gordan_tensors.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
using HalfIntegers: half
66
using WignerSymbols: clebschgordan
77

8-
using GradedUnitRanges: dual, fusion_product
8+
using GradedUnitRanges: dual
99
using SymmetrySectors:
10-
,
1110
AbelianStyle,
1211
AbstractSector,
1312
NotAbelianStyle,
@@ -20,6 +19,7 @@ using SymmetrySectors:
2019
trivial,
2120
zero_odd
2221
using TensorAlgebra: contract
22+
using TensorProducts:
2323

2424
function symbol_1j(s::AbstractSector)
2525
cgt = clebsch_gordan_tensor(s, dual(s), trivial(s), 1)
@@ -66,7 +66,7 @@ function clebsch_gordan_tensor(s1::O2, s2::O2, s3::O2)
6666
d2 = quantum_dimension(s2)
6767
d3 = quantum_dimension(s3)
6868
cgt = zeros((d1, d2, d3))
69-
s3 blocklabels(fusion_product(s1, s2)) && return cgt
69+
s3 blocklabels(s1 s2) && return cgt
7070

7171
# adapted from TensorKit
7272
l1 = sector_label(s1)

src/fusion_trees/fusiontree.jl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
# TBD
44
# compatibility with TensorKit conventions?
55

6-
using GradedUnitRanges:
7-
AbstractGradedUnitRange, GradedUnitRanges, flip, fusion_product, isdual, sector_type
8-
using SymmetrySectors: ×, AbstractSector, SectorProduct, SymmetrySectors, arguments, trivial
6+
using GradedUnitRanges: AbstractGradedUnitRange, GradedUnitRanges, flip, isdual, sector_type
7+
using SymmetrySectors:
8+
×, AbstractSector, SectorProduct, SymmetrySectors, arguments, trivial, to_gradedrange
99
using TensorAlgebra: flatten_tuples
10+
using TensorProducts: , tensor_product
1011

1112
#
1213
# A fusion tree fuses N sectors sec1, secN onto one sector fused_sec. A given set of
@@ -186,7 +187,7 @@ end
186187

187188
# TODO move to GradedUnitRanges
188189
function nsymbol(s1::AbstractSector, s2::AbstractSector, s3::AbstractSector)
189-
full_space = fusion_product(s1, s2)
190+
full_space = tensor_product(s1, s2)
190191
x = findfirst(==(s3), blocklabels(full_space))
191192
isnothing(x) && return 0 # OR labelled(0, s3)?
192193
return Int(blocklengths(full_space)[x])
@@ -241,7 +242,7 @@ end
241242
function fuse_next_sector(
242243
parent_tree::SectorFusionTree, branch_sector::AbstractSector, level_arrow::Bool
243244
)
244-
new_space = fusion_product(root_sector(parent_tree), branch_sector)
245+
new_space = to_gradedrange(root_sector(parent_tree) branch_sector)
245246
return mapreduce(vcat, zip(blocklabels(new_space), blocklengths(new_space))) do (la, n)
246247
return [
247248
append_tree_leave(parent_tree, branch_sector, level_arrow, la, outer_mult) for

src/fusiontensor/fusiontensor.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ using GradedUnitRanges:
1717
space_isequal
1818
using SymmetrySectors: SectorProduct, TrivialSector
1919
using TensorAlgebra: BlockedTuple, tuplemortar
20+
using TensorProducts: tensor_product
2021

2122
struct FusionTensor{T,N,Axes,Mat,Mapping} <: AbstractArray{T,N}
2223
data_matrix::Mat
@@ -108,13 +109,13 @@ function promote_sectors(
108109
# fuse with trivial to insert all missing arguments inside each GradedAxis
109110
# avoid depending on SymmetrySectors internals
110111
s0 = trivial(T)
111-
return map_blocklabels.(s -> only(blocklabels(fusion_product(s0, s))), legs)
112+
return map_blocklabels.(s -> only(blocklabels(tensor_product(s0, s))), legs)
112113
end
113114

114115
function promote_sector_type(legs)
115116
# fuse trivial sectors to produce unified type
116117
# avoid depending on SymmetrySectors internals
117-
return sector_type(fusion_product(trivial.(legs)...))
118+
return sector_type(tensor_product(trivial.(legs)...))
118119
end
119120

120121
# initialize with already computed data_matrix
@@ -229,7 +230,7 @@ function initialize_data_matrix(
229230
)
230231
# non-abelian fusion trees have float eltype: need compatible type
231232
promoted = promote_type(elt, fusiontree_eltype(sector_type(mat_row_axis)))
232-
mat = BlockSparseArray{promoted}(mat_row_axis, mat_col_axis)
233+
mat = BlockSparseArray{promoted}(undef, mat_row_axis, mat_col_axis)
233234
initialize_allowed_sectors!(mat)
234235
return mat
235236
end

test/Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
99
Suppressor = "fd094767-a336-5f1f-9728-57cf17d0bbfb"
1010
SymmetrySectors = "f8a8ad64-adbc-4fce-92f7-ffe2bb36a86e"
1111
TensorAlgebra = "68bd88dc-f39d-4e12-b2ca-f046b68fcc6a"
12+
TensorProducts = "decf83d6-1968-43f4-96dc-fdb3fe15fc6d"
1213
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
1314

1415
[compat]

test/basics/test_array_cast.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ using Test: @test, @test_throws, @testset
55
using BlockArrays: Block, BlockedArray, blocksize
66

77
using FusionTensors: FusionTensor, data_matrix, to_fusiontensor
8-
using GradedUnitRanges: dual, fusion_product, gradedrange
8+
using GradedUnitRanges: dual, gradedrange
99
using SymmetrySectors: O2, SectorProduct, SU2, TrivialSector, U1
10+
using TensorProducts: tensor_product
1011

1112
include("setup.jl")
1213

@@ -365,7 +366,7 @@ end
365366
end
366367

367368
@testset "large identity" begin
368-
g = reduce(fusion_product, (SU2(1 / 2), SU2(1 / 2), SU2(1 / 2)))
369+
g = reduce(tensor_product, (SU2(1 / 2), SU2(1 / 2), SU2(1 / 2)))
369370
N = 3
370371
codomain_legs = ntuple(_ -> g, N)
371372
domain_legs = dual.(codomain_legs)

test/basics/test_basics.jl

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ using FusionTensors:
1414
matrix_size,
1515
ndims_domain,
1616
ndims_codomain
17-
using GradedUnitRanges:
18-
blockmergesort, dual, flip, fusion_product, gradedrange, sector_type, space_isequal
17+
using GradedUnitRanges: blockmergesort, dual, flip, gradedrange, sector_type, space_isequal
1918
using SymmetrySectors: U1, SU2, SectorProduct, TrivialSector, Z
2019
using TensorAlgebra: tuplemortar
20+
using TensorProducts: tensor_product
2121

2222
include("setup.jl")
2323

@@ -27,10 +27,11 @@ include("setup.jl")
2727

2828
# check dual convention when initializing data_matrix
2929
ft0 = FusionTensor(Float64, (g1,), (g2,))
30+
@test ft0 isa FusionTensor
3031
@test space_isequal(matrix_row_axis(ft0), g1)
3132
@test space_isequal(matrix_column_axis(ft0), g2)
3233

33-
m = BlockSparseArray{Float64}(g1, g2)
34+
m = BlockSparseArray{Float64}(undef, g1, g2)
3435
ft1 = FusionTensor(m, (g1,), (g2,))
3536

3637
# getters
@@ -104,9 +105,9 @@ end
104105
g2 = gradedrange([U1(0) => 2, U1(1) => 2, U1(3) => 1])
105106
g3 = dual(gradedrange([U1(-1) => 1, U1(0) => 2, U1(1) => 1]))
106107
g4 = dual(gradedrange([U1(-1) => 1, U1(0) => 1, U1(1) => 1]))
107-
gr = fusion_product(g1, g2)
108-
gc = dual(fusion_product(dual(g3), dual(g4)))
109-
m2 = BlockSparseArray{Float64}(gr, gc)
108+
gr = tensor_product(g1, g2)
109+
gc = dual(tensor_product(dual(g3), dual(g4)))
110+
m2 = BlockSparseArray{Float64}(undef, gr, gc)
110111
ft = FusionTensor(m2, (g1, g2), (g3, g4))
111112

112113
@test data_matrix(ft) == m2
@@ -249,7 +250,7 @@ end
249250
@test_throws DimensionMismatch ft7 * ft3
250251
end
251252

252-
@testset "mising SectorProduct" begin
253+
@testset "missing SectorProduct" begin
253254
g1 = gradedrange([SectorProduct(U1(1)) => 1])
254255
g2 = gradedrange([SectorProduct(U1(1), SU2(1//2)) => 1])
255256
g3 = gradedrange([SectorProduct(U1(1), SU2(1//2), Z{2}(1)) => 1])
@@ -267,7 +268,7 @@ end
267268
gA = gradedrange([SectorProduct(; A=U1(1)) => 1])
268269
gB = gradedrange([SectorProduct(; B=SU2(1//2)) => 1])
269270
gC = gradedrange([SectorProduct(; C=Z{2}(0)) => 1])
270-
gABC = fusion_product(fusion_product(gA, gB), gC)
271+
gABC = tensor_product(gA, gB, gC)
271272
S = sector_type(gABC)
272273

273274
ft = FusionTensor(Float64, (gA, gB), (dual(gA), dual(gB), gC))

test/basics/test_fusion_trees.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ using FusionTensors:
1313
leaves,
1414
outer_multiplicity_indices,
1515
root_sector
16-
using GradedUnitRanges: blocklabels, fusion_product, sector_type
16+
using GradedUnitRanges: blocklabels, sector_type
1717
using SymmetrySectors: ×, SectorProduct, SU, SU2, TrivialSector, arguments
1818

1919
@testset "Trivial fusion trees" begin

0 commit comments

Comments
 (0)