Skip to content

Commit dd699cb

Browse files
committed
define nsymbol
1 parent 8767c22 commit dd699cb

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

src/abstractsector.jl

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@
44
using BlockArrays: blocklengths
55
using LabelledNumbers: LabelledInteger, label, label_type, labelled, unlabel, unlabel_type
66
using GradedUnitRanges:
7-
GradedUnitRanges, blocklabels, fuse_blocklengths, gradedrange, tensor_product
7+
GradedUnitRanges,
8+
blocklabels,
9+
fuse_blocklengths,
10+
fusion_product,
11+
gradedrange,
12+
tensor_product
813

914
abstract type AbstractSector end
1015

@@ -47,6 +52,13 @@ quantum_dimension(::AbelianStyle, ::AbstractSector) = 1
4752
quantum_dimension(::AbelianStyle, g::AbstractUnitRange) = length(g)
4853
quantum_dimension(::NotAbelianStyle, g::AbstractUnitRange) = sum(block_dimensions(g))
4954

55+
function nsymbol(s1::AbstractSector, s2::AbstractSector, s3::AbstractSector)
56+
full_space = fusion_product(s1, s2)
57+
i = findfirst(==(s3), blocklabels(full_space))
58+
isnothing(i) && return labelled(0, s3)
59+
return blocklengths(full_space)[i]
60+
end
61+
5062
# =============================== Fusion rule interface ==================================
5163
(c1::AbstractSector, c2::AbstractSector) = fusion_rule(c1, c2)
5264

test/test_fusion_rules.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using GradedUnitRanges:
22
dual, fusion_product, space_isequal, gradedrange, flip, tensor_product
3+
using LabelledNumbers: label
34
using SymmetrySectors:
45
,
56
Fib,
@@ -11,6 +12,7 @@ using SymmetrySectors:
1112
U1,
1213
Z,
1314
block_dimensions,
15+
nsymbol,
1416
quantum_dimension,
1517
trivial
1618
using Test: @inferred, @test, @testset, @test_throws
@@ -29,6 +31,8 @@ using Test: @inferred, @test, @testset, @test_throws
2931
@test (@inferred q q) == q
3032
@test (@inferred q z0) == z0
3133
@test (@inferred z1 q) == z1
34+
@test nsymbol(q, q, q) == 1
35+
@test label(nsymbol(q, q, q)) == q
3236

3337
# using GradedUnitRanges interface
3438
@test space_isequal(fusion_product(z0, z0), gradedrange([z0 => 1]))
@@ -49,6 +53,11 @@ using Test: @inferred, @test, @testset, @test_throws
4953
@test q1 q2 == U1(3)
5054
@test q2 q1 == U1(3)
5155
@test (@inferred q1 q2) == q3 # no better way, see Julia PR 23426
56+
57+
@test nsymbol(q1, q2, q3) == 1
58+
@test label(nsymbol(q1, q2, q3)) == q3
59+
@test nsymbol(q1, q1, q3) == 0
60+
@test label(nsymbol(q1, q1, q3)) == q3
5261
end
5362

5463
@testset "O2 fusion rules" begin
@@ -263,6 +272,9 @@ end
263272
@test space_isequal(
264273
fusion_product(dual(g5), dual(g6)), gradedrange([s1 => 2, f3 => 1, c3 => 1, ad8 => 1])
265274
)
275+
276+
@test nsymbol(ad8, ad8, ad8) == 2
277+
@test label(nsymbol(ad8, ad8, ad8)) == ad8
266278
end
267279

268280
@testset "Mixed GradedUnitRange - Sector fusion rules" begin

0 commit comments

Comments
 (0)