Skip to content
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
1 change: 1 addition & 0 deletions src/TensorKitSectors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export D3Irrep, D4Irrep, DNIrrep, CU1Irrep
export A4Irrep
export SU2Irrep
export ZNElement, Z2Element, Z3Element, Z4Element
export ℤNElement, ℤ₂Element, ℤ₃Element, ℤ₄Element
export ProductSector, NamedSector, @NamedSector, TimeReversed
export FermionParity, FermionNumber, FermionSpin
export PlanarTrivial, FibonacciAnyon, IsingAnyon
Expand Down
6 changes: 6 additions & 0 deletions src/auxiliary.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,9 @@ function manhattan_to_multidimensional_index(index::Int, sz::Dims{N}) where {N}
index -= offset
return invertlocaloffset(d, index - 1, sz)
end

# pretty printing of ZNElement up to N = 4
function subscript(i::Integer)
return i < 0 ? error("$i is negative") :
string(Iterators.reverse('₀' + d for d in digits(i))...)
end
11 changes: 9 additions & 2 deletions src/groupelements.jl
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,20 @@ struct ZNElement{N, p} <: AbstractGroupElement{ℤ{N}}
end
ZNElement{N}(n::Integer) where {N} = ZNElement{N, 0}(n)
Base.getindex(::ElementTable, ::Type{ℤ{N}}, p::Int = 0) where {N} = ZNElement{N, mod(p, N)}
type_repr(::Type{ZNElement{N, p}}) where {N, p} = "GroupElement[ℤ{$N}, $p]"

Base.convert(T::Type{<:ZNElement}, n::Real) = T(n)
const Z2Element{p} = ZNElement{2, p}
const Z3Element{p} = ZNElement{3, p}
const Z4Element{p} = ZNElement{4, p}

const ℤNElement{N, p} = ZNElement{N, p}
const ℤ₂Element{p} = ℤNElement{2, p}
const ℤ₃Element{p} = ℤNElement{3, p}
const ℤ₄Element{p} = ℤNElement{4, p}

function type_repr(::Type{ZNElement{N, p}}) where {N, p}
return N < 5 ? "ℤ$(subscript(N))Element{$p}" : "ℤNElement{$N, $p}"
end

Base.one(::Type{Z}) where {Z <: ZNElement} = Z(0)
Base.inv(c::ZNElement) = typeof(c)(-c.n)
Base.:*(c1::ZNElement{N, p}, c2::ZNElement{N, p}) where {N, p} =
Expand Down
12 changes: 6 additions & 6 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ const sectorlist = (
NewSU2Irrep ⊠ SU2Irrep, FermionParity ⊠ SU2Irrep ⊠ NewSU2Irrep,
FibonacciAnyon ⊠ FibonacciAnyon ⊠ Z2Irrep,
A4Irrep ⊠ Z2Irrep, A4Irrep ⊠ SU2Irrep,
Z2Element{0}, Z2Element{1},
Z3Element{0}, Z3Element{1}, Z3Element{2},
Z4Element{0}, Z4Element{1}, Z4Element{2},
ZNElement{6, 0}, ZNElement{6, 1}, ZNElement{6, 3},
ℤ₂Element{0}, Z2Element{1},
Z3Element{0}, Z3Element{1}, ℤ₃Element{2},
Z4Element{0}, ℤ₄Element{1}, Z4Element{2},
ZNElement{6, 0}, ℤNElement{6, 1}, ZNElement{6, 3},
Z3Element{1} ⊠ SU2Irrep,
FibonacciAnyon ⊠ Z4Element{3},
IsingBimodule, IsingBimodule ⊠ IsingBimodule, IsingBimodule ⊠ Z2Irrep,
Expand All @@ -33,9 +33,9 @@ const sectorlist = (
TimeReversed{FibonacciAnyon}, TimeReversed{IsingAnyon},
TimeReversed{FermionParity},
TimeReversed{FermionParity ⊠ FermionParity},
TimeReversed{Z4Element{2}}, TimeReversed{ZNElement{6, 3}},
TimeReversed{ℤ₄Element{2}}, TimeReversed{ZNElement{6, 3}},
ZNElement{6, 1} ⊠ TimeReversed{FibonacciAnyon},
TimeReversed{ZNElement{6, 3} ⊠ FibonacciAnyon},
TimeReversed{ℤNElement{6, 3} ⊠ FibonacciAnyon},
TimeReversed{Z2Irrep ⊠ Z3Irrep ⊠ Z4Irrep},
TimeReversed{Z2Irrep} ⊠ TimeReversed{Z3Irrep} ⊠ TimeReversed{Z4Irrep},
TimeReversed{NewSU2Irrep ⊠ NewSU2Irrep},
Expand Down
Loading