Skip to content

Commit 4e94367

Browse files
committed
define fusiontree_eltype
1 parent 5f2452d commit 4e94367

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

src/fusion_trees/fusiontree.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,9 @@ function SymmetrySectors.arguments(f::SectorFusionTree{<:SectorProduct,1})
151151
end
152152
end
153153

154+
# TBD change type depending on AbelianStyle?
155+
fusiontree_eltype(::Type{<:AbstractSector}) = Float64
156+
154157
#
155158
# ===================================== Internals ========================================
156159
#

src/fusiontensor/base_interface.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ end
9292
Base.permutedims(ft::FusionTensor, args...) = fusiontensor_permutedims(ft, args...)
9393

9494
function Base.similar(ft::FusionTensor, ::Type{T}) where {T}
95-
# fusion trees have Float64 eltype: need compatible type
96-
@assert promote_type(T, Float64) === T
95+
# some fusion trees have Float64 eltype: need compatible type
96+
@assert promote_type(T, fusiontree_eltype(sector_type(ft))) === T
9797
mat = similar(data_matrix(ft), T)
9898
initialize_allowed_sectors!(mat)
9999
return FusionTensor(mat, codomain_axes(ft), domain_axes(ft), trees_block_mapping(ft))

src/fusiontensor/fusiontensor.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,10 @@ end
167167
function initialize_data_matrix(
168168
elt::Type{<:Number}, codomain_fused_axes::FusedAxes, domain_fused_axes::FusedAxes
169169
)
170-
# fusion trees have Float64 eltype: need compatible type
171-
promoted = promote_type(elt, Float64)
172170
mat_row_axis = fused_axis(codomain_fused_axes)
173171
mat_col_axis = dual(fused_axis(domain_fused_axes))
172+
# non-abelian fusion trees have float eltype: need compatible type
173+
promoted = promote_type(elt, fusiontree_eltype(sector_type(mat_row_axis)))
174174
mat = BlockSparseArray{promoted}(mat_row_axis, mat_col_axis)
175175
initialize_allowed_sectors!(mat)
176176
return mat

test/basics/test_fusion_trees.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ using FusionTensors:
99
arrows,
1010
branch_sectors,
1111
build_trees,
12+
fusiontree_eltype,
1213
leaves,
1314
outer_multiplicity_indices,
1415
root_sector
@@ -41,6 +42,8 @@ using SymmetrySectors: ×, SectorProduct, SU, SU2, TrivialSector, arguments
4142
@test branch_sectors(f) == (q,)
4243
@test outer_multiplicity_indices(f) == (1,)
4344
@test convert(Array, f) ones((1, 1, 1))
45+
46+
@test fusiontree_eltype(sector_type(f)) === eltype(convert(Array, f))
4447
end
4548

4649
@testset "SU(2) SectorFusionTree" begin
@@ -54,6 +57,7 @@ end
5457
@test outer_multiplicity_indices(f) == ()
5558
@test sector_type(f) == typeof(j2)
5659
@test convert(Array, f) I(2)
60+
@test fusiontree_eltype(sector_type(f)) === eltype(convert(Array, f))
5761

5862
f = only(build_trees((j2,), (true,)))
5963
@test arrows(f) == (true,)

0 commit comments

Comments
 (0)