Skip to content

Commit abe14a4

Browse files
committed
defined set_sector_label
1 parent 0589a4e commit abe14a4

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

NDTensors/src/lib/SymmetrySectors/src/sector_definitions/u1.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ struct U1{T} <: AbstractSector
1111
end
1212

1313
SymmetryStyle(::Type{<:U1}) = AbelianStyle()
14-
15-
GradedAxes.dual(u::U1) = U1(-u.n)
16-
1714
sector_label(u::U1) = u.n
1815

16+
set_sector_label(s::U1, sector_label) = typeof(s)(sector_label)
17+
GradedAxes.dual(s::U1) = set_sector_label(s, -sector_label(s))
18+
1919
trivial(::Type{U1}) = trivial(U1{Int})
2020
trivial(::Type{U1{T}}) where {T} = U1(zero(T))
2121

NDTensors/src/lib/SymmetrySectors/src/sector_definitions/zn.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@ using ...GradedAxes: GradedAxes
66

77
struct Z{N} <: AbstractSector
88
m::Int
9-
Z{N}(m) where {N} = new{N}(m % N)
9+
Z{N}(m) where {N} = new{N}(mod(m, N))
1010
end
1111

12-
SymmetryStyle(::Type{<:Z}) = AbelianStyle()
12+
modulus(::Type{Z{N}}) where {N} = N
13+
modulus(c::Z) = modulus(typeof(c))
1314

15+
SymmetryStyle(::Type{<:Z}) = AbelianStyle()
1416
sector_label(c::Z) = c.m
15-
modulus(::Type{Z{N}}) where {N} = N
1617

17-
modulus(c::Z) = modulus(typeof(c))
18+
set_sector_label(s::Z, sector_label) = typeof(s)(sector_label)
19+
GradedAxes.dual(s::Z) = set_sector_label(s, -sector_label(s))
1820

1921
trivial(sector_type::Type{<:Z}) = sector_type(0)
2022

2123
function abelian_label_fusion_rule(sector_type::Type{<:Z}, n1, n2)
22-
return sector_type((n1 + n2) % modulus(sector_type))
24+
return sector_type(n1 + n2)
2325
end
24-
25-
GradedAxes.dual(c::Z) = typeof(c)(mod(-sector_label(c), modulus(c)))

NDTensors/src/lib/SymmetrySectors/test/test_simple_sectors.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ using Test: @inferred, @test, @testset, @test_throws
7070
@test dual(Z{2}(1)) == Z{2}(1)
7171
@test isless(Z{2}(0), Z{2}(1))
7272
@test !isless(Z{2}(1), Z{2}(0))
73+
@test Z{2}(0) == z0
74+
@test Z{2}(-3) == z1
7375

7476
@test Z{2}(0) == TrivialSector()
7577
@test TrivialSector() < Z{2}(1)

0 commit comments

Comments
 (0)