Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

define nsymbol #4

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/abstractsector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
using BlockArrays: blocklengths
using LabelledNumbers: LabelledInteger, label, label_type, labelled, unlabel, unlabel_type
using GradedUnitRanges:
GradedUnitRanges, blocklabels, fuse_blocklengths, gradedrange, tensor_product
GradedUnitRanges,
blocklabels,
fuse_blocklengths,
fusion_product,
gradedrange,
tensor_product

abstract type AbstractSector end

Expand Down Expand Up @@ -47,6 +52,13 @@
quantum_dimension(::AbelianStyle, g::AbstractUnitRange) = length(g)
quantum_dimension(::NotAbelianStyle, g::AbstractUnitRange) = sum(block_dimensions(g))

function nsymbol(s1::AbstractSector, s2::AbstractSector, s3::AbstractSector)
full_space = fusion_product(s1, s2)
i = findfirst(==(s3), blocklabels(full_space))
isnothing(i) && return labelled(0, s3)
return blocklengths(full_space)[i]

Check warning on line 59 in src/abstractsector.jl

View check run for this annotation

Codecov / codecov/patch

src/abstractsector.jl#L55-L59

Added lines #L55 - L59 were not covered by tests
end

# =============================== Fusion rule interface ==================================
⊗(c1::AbstractSector, c2::AbstractSector) = fusion_rule(c1, c2)

Expand Down
12 changes: 12 additions & 0 deletions test/test_fusion_rules.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using GradedUnitRanges:
dual, fusion_product, space_isequal, gradedrange, flip, tensor_product
using LabelledNumbers: label
using SymmetrySectors:
⊗,
Fib,
Expand All @@ -11,6 +12,7 @@ using SymmetrySectors:
U1,
Z,
block_dimensions,
nsymbol,
quantum_dimension,
trivial
using Test: @inferred, @test, @testset, @test_throws
Expand All @@ -29,6 +31,8 @@ using Test: @inferred, @test, @testset, @test_throws
@test (@inferred q ⊗ q) == q
@test (@inferred q ⊗ z0) == z0
@test (@inferred z1 ⊗ q) == z1
@test nsymbol(q, q, q) == 1
@test label(nsymbol(q, q, q)) == q

# using GradedUnitRanges interface
@test space_isequal(fusion_product(z0, z0), gradedrange([z0 => 1]))
Expand All @@ -49,6 +53,11 @@ using Test: @inferred, @test, @testset, @test_throws
@test q1 ⊗ q2 == U1(3)
@test q2 ⊗ q1 == U1(3)
@test (@inferred q1 ⊗ q2) == q3 # no better way, see Julia PR 23426

@test nsymbol(q1, q2, q3) == 1
@test label(nsymbol(q1, q2, q3)) == q3
@test nsymbol(q1, q1, q3) == 0
@test label(nsymbol(q1, q1, q3)) == q3
end

@testset "O2 fusion rules" begin
Expand Down Expand Up @@ -263,6 +272,9 @@ end
@test space_isequal(
fusion_product(dual(g5), dual(g6)), gradedrange([s1 => 2, f3 => 1, c3 => 1, ad8 => 1])
)

@test nsymbol(ad8, ad8, ad8) == 2
@test label(nsymbol(ad8, ad8, ad8)) == ad8
end

@testset "Mixed GradedUnitRange - Sector fusion rules" begin
Expand Down
Loading