Skip to content

Commit b17abce

Browse files
authored
define nsymbol (#4)
1 parent c379b0c commit b17abce

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "SymmetrySectors"
22
uuid = "f8a8ad64-adbc-4fce-92f7-ffe2bb36a86e"
33
authors = ["ITensor developers <[email protected]> and contributors"]
4-
version = "0.1.8"
4+
version = "0.1.9"
55

66
[deps]
77
BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e"

src/abstractsector.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ to_gradedrange(c::AbstractSector) = to_gradedrange(labelled(1, c))
5252
to_gradedrange(l::LabelledInteger) = gradedrange([l])
5353
to_gradedrange(g::AbstractUnitRange) = g
5454

55+
function nsymbol(s1::AbstractSector, s2::AbstractSector, s3::AbstractSector)
56+
full_space = to_gradedrange(s1 s2)
57+
i = findfirst(==(s3), blocklabels(full_space))
58+
isnothing(i) && return 0
59+
return unlabel(blocklengths(full_space)[i])
60+
end
61+
5562
# =============================== Fusion rule interface ==================================
5663
function fusion_rule(c1::AbstractSector, c2::AbstractSector)
5764
return fusion_rule(combine_styles(SymmetryStyle(c1), SymmetryStyle(c2)), c1, c2)

test/test_fusion_rules.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ using SymmetrySectors:
99
U1,
1010
Z,
1111
block_dimensions,
12+
nsymbol,
1213
quantum_dimension,
1314
trivial
1415
using TensorProducts: , tensor_product
@@ -29,6 +30,7 @@ using TestExtras: @constinferred
2930
@test (@constinferred q q) == q
3031
@test (@constinferred q z0) == z0
3132
@test (@constinferred z1 q) == z1
33+
@test nsymbol(q, q, q) == 1
3234

3335
# test different input number
3436
@test tensor_product(z0) == z0
@@ -46,6 +48,8 @@ using TestExtras: @constinferred
4648
@test q1 q2 == U1(3)
4749
@test q2 q1 == U1(3)
4850
@test (@constinferred q1 q2) == q3
51+
@test nsymbol(q1, q2, q3) == 1
52+
@test nsymbol(q1, q1, q3) == 0
4953
end
5054

5155
@testset "O2 fusion rules" begin
@@ -262,6 +266,8 @@ end
262266
@test space_isequal(
263267
tensor_product(dual(g5), dual(g6)), gradedrange([s1 => 2, f3 => 1, c3 => 1, ad8 => 1])
264268
)
269+
270+
@test nsymbol(ad8, ad8, ad8) == 2
265271
end
266272

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

0 commit comments

Comments
 (0)