diff --git a/src/TensorKitSectors.jl b/src/TensorKitSectors.jl index ebe0e8c..984fcbe 100644 --- a/src/TensorKitSectors.jl +++ b/src/TensorKitSectors.jl @@ -6,13 +6,12 @@ export Sector, Group, AbstractIrrep, AbstractGroupElement export Irrep, GroupElement export Nsymbol, Fsymbol, Rsymbol, Asymbol, Bsymbol -export sectorscalartype +export sectorscalartype, fusionscalartype, braidingscalartype, dimscalartype export dim, sqrtdim, invsqrtdim, frobenius_schur_indicator, frobenius_schur_phase, twist, fusiontensor, dual export otimes, deligneproduct, times -export FusionStyle, UniqueFusion, MultipleFusion, SimpleFusion, GenericFusion, - MultiplicityFreeFusion -export UnitStyle, SimpleUnit, GenericUnit +export FusionStyle, UniqueFusion, MultipleFusion, SimpleFusion, GenericFusion, MultiplicityFreeFusion export BraidingStyle, NoBraiding, HasBraiding, SymmetricBraiding, Bosonic, Fermionic, Anyonic +export UnitStyle, SimpleUnit, GenericUnit export SectorSet, SectorValues, findindex export unit, rightunit, leftunit, allunits, isunit @@ -50,7 +49,7 @@ end using Base: SizeUnknown, HasLength, IsInfinite using Base: HasEltype, EltypeUnknown using Base.Iterators: product, filter -using Base: tuple_type_head, tuple_type_tail +using Base: @assume_effects using LinearAlgebra: tr using TensorOperations diff --git a/src/anyons.jl b/src/anyons.jl index a6935f7..1fef682 100644 --- a/src/anyons.jl +++ b/src/anyons.jl @@ -28,6 +28,7 @@ dual(::PlanarTrivial) = PlanarTrivial() FusionStyle(::Type{PlanarTrivial}) = UniqueFusion() BraidingStyle(::Type{PlanarTrivial}) = NoBraiding() +fusionscalartype(::Type{PlanarTrivial}) = Int sectorscalartype(::Type{PlanarTrivial}) = Int Nsymbol(::Vararg{PlanarTrivial, 3}) = 1 @@ -82,7 +83,9 @@ const _goldenratio = Float64(MathConstants.golden) dim(a::FibonacciAnyon) = isunit(a) ? one(_goldenratio) : _goldenratio FusionStyle(::Type{FibonacciAnyon}) = SimpleFusion() +fusionscalartype(::Type{FibonacciAnyon}) = Float64 BraidingStyle(::Type{FibonacciAnyon}) = Anyonic() +braidingscalartype(::Type{FibonacciAnyon}) = ComplexF64 sectorscalartype(::Type{FibonacciAnyon}) = ComplexF64 const FibonacciAnyonProdIterator = SectorProductIterator{FibonacciAnyon} @@ -198,7 +201,9 @@ dual(s::IsingAnyon) = s dim(a::IsingAnyon) = a.s == :σ ? sqrt(2) : 1.0 FusionStyle(::Type{IsingAnyon}) = SimpleFusion() +fusionscalartype(::Type{IsingAnyon}) = Float64 BraidingStyle(::Type{IsingAnyon}) = Anyonic() +braidingscalartype(::Type{IsingAnyon}) = ComplexF64 sectorscalartype(::Type{IsingAnyon}) = ComplexF64 const IsingAnyonProdIterator = SectorProductIterator{IsingAnyon} diff --git a/src/fermions.jl b/src/fermions.jl index 9b783e1..3db0f5d 100644 --- a/src/fermions.jl +++ b/src/fermions.jl @@ -35,7 +35,9 @@ dual(f::FermionParity) = f dim(f::FermionParity) = 1 FusionStyle(::Type{FermionParity}) = UniqueFusion() +fusionscalartype(::Type{FermionParity}) = Int BraidingStyle(::Type{FermionParity}) = Fermionic() +braidingscalartype(::Type{FermionParity}) = Int sectorscalartype(::Type{FermionParity}) = Int ⊗(a::FermionParity, b::FermionParity) = (FermionParity(a.isodd ⊻ b.isodd),) diff --git a/src/groups.jl b/src/groups.jl index 899dfdf..d8482be 100644 --- a/src/groups.jl +++ b/src/groups.jl @@ -119,7 +119,7 @@ const times = × function ×( G1::Type{ProductGroup{T1}}, G2::Type{ProductGroup{T2}} ) where {T1 <: GroupTuple, T2 <: GroupTuple} - return tuple_type_head(T1) × (ProductGroup{tuple_type_tail(T1)} × G2) + return Base.tuple_type_head(T1) × (ProductGroup{Base.tuple_type_tail(T1)} × G2) end ×(G1::Type{ProductGroup{Tuple{}}}, G2::Type{<:Group}) = ProductGroup{Tuple{G2}} function ×(G1::Type{ProductGroup{T}}, G2::Type{<:Group}) where {T <: GroupTuple} diff --git a/src/irreps/a4irrep.jl b/src/irreps/a4irrep.jl index 60ffb1f..bf0a613 100644 --- a/src/irreps/a4irrep.jl +++ b/src/irreps/a4irrep.jl @@ -18,6 +18,8 @@ struct A4Irrep <: AbstractIrrep{A₄} end FusionStyle(::Type{A4Irrep}) = GenericFusion() +fusionscalartype(::Type{A4Irrep}) = Float64 +braidingscalartype(::Type{A4Irrep}) = Float64 sectorscalartype(::Type{A4Irrep}) = Float64 unit(::Type{A4Irrep}) = A4Irrep(0) @@ -80,7 +82,7 @@ end function Fsymbol(a::I, b::I, c::I, d::I, e::I, f::I) where {I <: A4Irrep} - T = sectorscalartype(I) + T = fusionscalartype(I) Nabe = Nsymbol(a, b, e) Necd = Nsymbol(e, c, d) Nbcf = Nsymbol(b, c, f) @@ -103,7 +105,7 @@ end # bosonic function Rsymbol(a::I, b::I, c::I) where {I <: A4Irrep} Nabc = Nsymbol(a, b, c) - R = zeros(sectorscalartype(I), Nabc, Nabc) + R = zeros(braidingscalartype(I), Nabc, Nabc) Nabc == 0 && return R if a == b == c == A4Irrep(3) R[1, 1] = -1 diff --git a/src/irreps/cu1irrep.jl b/src/irreps/cu1irrep.jl index ec16cf5..cc78563 100644 --- a/src/irreps/cu1irrep.jl +++ b/src/irreps/cu1irrep.jl @@ -107,6 +107,8 @@ end dim(c::CU1Irrep) = ifelse(c.j == zero(HalfInt), 1, 2) FusionStyle(::Type{CU1Irrep}) = SimpleFusion() +fusionscalartype(::Type{CU1Irrep}) = Float64 +braidingscalartype(::Type{CU1Irrep}) = Float64 sectorscalartype(::Type{CU1Irrep}) = Float64 Base.isreal(::Type{CU1Irrep}) = true @@ -121,15 +123,15 @@ function Nsymbol(a::CU1Irrep, b::CU1Irrep, c::CU1Irrep) end function Fsymbol( - a::CU1Irrep, b::CU1Irrep, c::CU1Irrep, d::CU1Irrep, e::CU1Irrep, - f::CU1Irrep + a::CU1Irrep, b::CU1Irrep, c::CU1Irrep, + d::CU1Irrep, e::CU1Irrep, f::CU1Irrep ) Nabe = convert(Int, Nsymbol(a, b, e)) Necd = convert(Int, Nsymbol(e, c, d)) Nbcf = convert(Int, Nsymbol(b, c, f)) Nafd = convert(Int, Nsymbol(a, f, d)) - T = sectorscalartype(CU1Irrep) + T = fusionscalartype(CU1Irrep) Nabe * Necd * Nbcf * Nafd == 0 && return zero(T) op = CU1Irrep(0, 0) @@ -211,12 +213,12 @@ function Fsymbol( end function Rsymbol(a::CU1Irrep, b::CU1Irrep, c::CU1Irrep) - R = convert(sectorscalartype(CU1Irrep), Nsymbol(a, b, c)) + R = convert(braidingscalartype(CU1Irrep), Nsymbol(a, b, c)) return c.s == 1 && a.j > 0 ? -R : R end function fusiontensor(a::CU1Irrep, b::CU1Irrep, c::CU1Irrep) - C = fill(0.0, dim(a), dim(b), dim(c), 1) + C = fill(zero(sectorscalartype(CU1Irrep)), dim(a), dim(b), dim(c), 1) !Nsymbol(a, b, c) && return C if c.j == 0 if a.j == b.j == 0 diff --git a/src/irreps/dnirrep.jl b/src/irreps/dnirrep.jl index b91cda5..44b176f 100644 --- a/src/irreps/dnirrep.jl +++ b/src/irreps/dnirrep.jl @@ -44,6 +44,8 @@ function Base.getproperty(a::DNIrrep{N}, sym::Symbol) where {N} end FusionStyle(::Type{DNIrrep{N}}) where {N} = N < 3 ? UniqueFusion() : SimpleFusion() +fusionscalartype(::Type{DNIrrep{N}}) where {N} = Float64 +braidingscalartype(::Type{DNIrrep{N}}) where {N} = Float64 sectorscalartype(::Type{DNIrrep{N}}) where {N} = Float64 unit(::Type{DNIrrep{N}}) where {N} = DNIrrep{N}(0, false) @@ -186,7 +188,7 @@ function Nsymbol(a::DNIrrep{N}, b::DNIrrep{N}, c::DNIrrep{N}) where {N} end function Fsymbol(a::I, b::I, c::I, d::I, e::I, f::I) where {N, I <: DNIrrep{N}} - T = sectorscalartype(I) + T = fusionscalartype(I) (Nsymbol(a, b, e) & Nsymbol(e, c, d) & Nsymbol(b, c, f) & Nsymbol(a, f, d)) || return zero(T) # tensoring with units gives 1 @@ -206,7 +208,7 @@ function Fsymbol(a::I, b::I, c::I, d::I, e::I, f::I) where {N, I <: DNIrrep{N}} end function Rsymbol(a::I, b::I, c::I) where {N, I <: DNIrrep{N}} - R = convert(sectorscalartype(I), Nsymbol(a, b, c)) + R = convert(braidingscalartype(I), Nsymbol(a, b, c)) return ifelse((c.j == 0) & c.isodd & !(a.j == b.j == 0) & !((2 * a.j) == (2 * b.j) == N), -R, R) end diff --git a/src/irreps/irreps.jl b/src/irreps/irreps.jl index ea1a35a..e78e8c3 100644 --- a/src/irreps/irreps.jl +++ b/src/irreps/irreps.jl @@ -47,20 +47,26 @@ function Base.show(io::IO, c::AbstractIrrep) end const AbelianIrrep{G} = AbstractIrrep{G} where {G <: AbelianGroup} + FusionStyle(::Type{<:AbelianIrrep}) = UniqueFusion() +fusionscalartype(::Type{<:AbelianIrrep}) = Int +braidingscalartype(::Type{<:AbelianIrrep}) = Int sectorscalartype(::Type{<:AbelianIrrep}) = Int +dimscalartype(::Type{<:AbelianIrrep}) = Int Nsymbol(a::I, b::I, c::I) where {I <: AbelianIrrep} = c == first(a ⊗ b) function Fsymbol(a::I, b::I, c::I, d::I, e::I, f::I) where {I <: AbelianIrrep} - return Int(Nsymbol(a, b, e) * Nsymbol(e, c, d) * Nsymbol(b, c, f) * Nsymbol(a, f, d)) + T = fusionscalartype(I) + return T(Nsymbol(a, b, e) * Nsymbol(e, c, d) * Nsymbol(b, c, f) * Nsymbol(a, f, d)) end -frobenius_schur_phase(a::AbelianIrrep) = 1 -Asymbol(a::I, b::I, c::I) where {I <: AbelianIrrep} = Int(Nsymbol(a, b, c)) -Bsymbol(a::I, b::I, c::I) where {I <: AbelianIrrep} = Int(Nsymbol(a, b, c)) -Rsymbol(a::I, b::I, c::I) where {I <: AbelianIrrep} = Int(Nsymbol(a, b, c)) +frobenius_schur_phase(a::AbelianIrrep) = one(fusionscalartype(typeof(a))) +Asymbol(a::I, b::I, c::I) where {I <: AbelianIrrep} = fusionscalartype(I)(Nsymbol(a, b, c)) +Bsymbol(a::I, b::I, c::I) where {I <: AbelianIrrep} = fusionscalartype(I)(Nsymbol(a, b, c)) +Rsymbol(a::I, b::I, c::I) where {I <: AbelianIrrep} = braidingscalartype(I)(Nsymbol(a, b, c)) function fusiontensor(a::I, b::I, c::I) where {I <: AbelianIrrep} - return fill(Int(Nsymbol(a, b, c)), (1, 1, 1, 1)) + T = sectorscalartype(I) + return fill(T(Nsymbol(a, b, c)), (1, 1, 1, 1)) end include("znirrep.jl") diff --git a/src/irreps/su2irrep.jl b/src/irreps/su2irrep.jl index d296854..66a3ad4 100644 --- a/src/irreps/su2irrep.jl +++ b/src/irreps/su2irrep.jl @@ -43,6 +43,8 @@ findindex(::SectorValues{SU2Irrep}, s::SU2Irrep) = twice(s.j) + 1 dim(s::SU2Irrep) = twice(s.j) + 1 FusionStyle(::Type{SU2Irrep}) = SimpleFusion() +fusionscalartype(::Type{SU2Irrep}) = Float64 +braidingscalartype(::Type{SU2Irrep}) = Float64 sectorscalartype(::Type{SU2Irrep}) = Float64 Nsymbol(sa::SU2Irrep, sb::SU2Irrep, sc::SU2Irrep) = WignerSymbols.δ(sa.j, sb.j, sc.j) @@ -56,26 +58,26 @@ function Fsymbol( else return sqrtdim(s5) * sqrtdim(s6) * WignerSymbols.racahW( - sectorscalartype(SU2Irrep), s1.j, s2.j, s4.j, s3.j, + fusionscalartype(SU2Irrep), s1.j, s2.j, s4.j, s3.j, s5.j, s6.j ) end end function Rsymbol(sa::SU2Irrep, sb::SU2Irrep, sc::SU2Irrep) - Nsymbol(sa, sb, sc) || return zero(sectorscalartype(SU2Irrep)) - return iseven(convert(Int, sa.j + sb.j - sc.j)) ? one(sectorscalartype(SU2Irrep)) : - -one(sectorscalartype(SU2Irrep)) + T = braidingscalartype(SU2Irrep) + Nsymbol(sa, sb, sc) || return zero(T) + return iseven(convert(Int, sa.j + sb.j - sc.j)) ? one(T) : -one(T) end function fusiontensor(a::SU2Irrep, b::SU2Irrep, c::SU2Irrep) - C = Array{Float64}(undef, dim(a), dim(b), dim(c), 1) + T = sectorscalartype(SU2Irrep) + C = Array{T}(undef, dim(a), dim(b), dim(c), 1) ja, jb, jc = a.j, b.j, c.j for kc in 1:dim(c), kb in 1:dim(b), ka in 1:dim(a) C[ka, kb, kc, 1] = WignerSymbols.clebschgordan( - ja, ja + 1 - ka, jb, jb + 1 - kb, jc, - jc + 1 - kc + T, ja, ja + 1 - ka, jb, jb + 1 - kb, jc, jc + 1 - kc ) end return C diff --git a/src/precompile.jl b/src/precompile.jl index 17b342a..98d744d 100644 --- a/src/precompile.jl +++ b/src/precompile.jl @@ -4,6 +4,13 @@ Precompile common methods for the given sector type. """ function precompile_sector(::Type{I}) where {I <: Sector} + precompile(FusionStyle, (I,)) + precompile(BraidingStyle, (I,)) + + precompile(sectorscalartype, (I,)) + precompile(fusionscalartype, (I,)) + precompile(braidingscalartype, (I,)) + precompile(Nsymbol, (I, I, I)) precompile(Fsymbol, (I, I, I, I, I, I)) precompile(Rsymbol, (I, I, I)) @@ -15,9 +22,6 @@ function precompile_sector(::Type{I}) where {I <: Sector} precompile(⊗, (I, I, I)) precompile(⊗, (I, I, I, I)) - precompile(FusionStyle, (I,)) - precompile(BraidingStyle, (I,)) - precompile(dim, (I,)) precompile(sqrtdim, (I,)) precompile(invsqrtdim, (I,)) diff --git a/src/product.jl b/src/product.jl index 55d5b19..c1eb799 100644 --- a/src/product.jl +++ b/src/product.jl @@ -22,7 +22,7 @@ Base.iterate(s::ProductSector, args...) = iterate(s.sectors, args...) Base.indexed_iterate(s::ProductSector, args...) = Base.indexed_iterate(s.sectors, args...) _sectors(::Type{Tuple{}}) = () -Base.@pure function _sectors(::Type{T}) where {T <: SectorTuple} +@assume_effects :foldable function _sectors(::Type{T}) where {T <: SectorTuple} return (Base.tuple_type_head(T), _sectors(Base.tuple_type_tail(T))...) end @@ -215,14 +215,23 @@ end function FusionStyle(::Type{<:ProductSector{T}}) where {T <: SectorTuple} return mapreduce(FusionStyle, &, _sectors(T)) end +@assume_effects :foldable function fusionscalartype(::Type{<:ProductSector{T}}) where {T <: SectorTuple} + return typeof(prod(zero ∘ fusionscalartype, _sectors(T))) +end function UnitStyle(::Type{<:ProductSector{T}}) where {T <: SectorTuple} return mapreduce(UnitStyle, &, _sectors(T)) end function BraidingStyle(::Type{<:ProductSector{T}}) where {T <: SectorTuple} return mapreduce(BraidingStyle, &, _sectors(T)) end -function sectorscalartype(::Type{<:ProductSector{T}}) where {T <: SectorTuple} - return mapreduce(sectorscalartype, promote_type, _sectors(T)) +@assume_effects :foldable function braidingscalartype(::Type{<:ProductSector{T}}) where {T <: SectorTuple} + return typeof(prod(zero ∘ braidingscalartype, _sectors(T))) +end +@assume_effects :foldable function sectorscalartype(::Type{<:ProductSector{T}}) where {T <: SectorTuple} + return typeof(prod(zero ∘ sectorscalartype, _sectors(T))) +end +@assume_effects :foldable function dimscalartype(::Type{<:ProductSector{T}}) where {T <: SectorTuple} + return typeof(prod(zero ∘ dimscalartype, _sectors(T))) end fermionparity(P::ProductSector) = mapreduce(fermionparity, xor, P.sectors) @@ -272,20 +281,10 @@ group representations, we have `Irrep[G₁] ⊠ Irrep[G₂] == Irrep[G₁ × G ⊠(I1::Type{Trivial}, I2::Type{<:Sector}) = I2 ⊠(I1::Type{<:ProductSector}, I2::Type{Trivial}) = I1 -@static if VERSION >= v"1.8" - Base.@assume_effects :foldable function ⊠( - I1::Type{<:ProductSector}, I2::Type{<:ProductSector} - ) - T1 = I1.parameters[1] - T2 = I2.parameters[1] - return ProductSector{Tuple{T1.parameters..., T2.parameters...}} - end -else - Base.@pure function ⊠(I1::Type{<:ProductSector}, I2::Type{<:ProductSector}) - T1 = I1.parameters[1] - T2 = I2.parameters[1] - return ProductSector{Tuple{T1.parameters..., T2.parameters...}} - end +@assume_effects :foldable function ⊠(I1::Type{<:ProductSector}, I2::Type{<:ProductSector}) + T1 = I1.parameters[1] + T2 = I2.parameters[1] + return ProductSector{Tuple{T1.parameters..., T2.parameters...}} end ⊠(I1::Type{<:ProductSector}, I2::Type{<:Sector}) = I1 ⊠ ProductSector{Tuple{I2}} @@ -366,9 +365,9 @@ function type_repr(::Type{ProductSector{T}}) where {T <: Tuple{Vararg{AbstractIr end function Base.getindex(::IrrepTable, ::Type{ProductGroup{Gs}}) where {Gs <: GroupTuple} - G1 = tuple_type_head(Gs) - Grem = tuple_type_tail(Gs) - return ProductSector{Tuple{Irrep[G1]}} ⊠ Irrep[ProductGroup{tuple_type_tail(Gs)}] + G1 = Base.tuple_type_head(Gs) + Grem = Base.tuple_type_tail(Gs) + return ProductSector{Tuple{Irrep[G1]}} ⊠ Irrep[ProductGroup{Grem}] end function Base.getindex(::IrrepTable, ::Type{ProductGroup{Tuple{G}}}) where {G <: Group} return ProductSector{Tuple{Irrep[G]}} diff --git a/src/sectors.jl b/src/sectors.jl index 8f19af1..8cb7347 100644 --- a/src/sectors.jl +++ b/src/sectors.jl @@ -162,25 +162,47 @@ Return the dual label of `a`, i.e. the unique label `ā = dual(a)` such that Base.conj(a::Sector) = dual(a) """ - sectorscalartype(I::Type{<:Sector}) -> Type + sectorscalartype(I::Type{<:Sector}) -> Type{<:Number} -Return the scalar type of the topological data ([`Fsymbol`](@ref) and [`Rsymbol`](@ref)) of the sector `I`. +Return the scalar type of the topological data of the sector `I`. +In particular, this is a combination of the scalar type of both the [`Fsymbol`](@ref) and [`Rsymbol`](@ref), +and determines the scalar type of the [`fusiontensor`](@ref) whenever it is defined. + +See also [`fusionscalartype`](@ref) and [`braidingscalartype`](@ref). """ -function sectorscalartype(::Type{I}) where {I <: Sector} - if BraidingStyle(I) === NoBraiding() - return _Fscalartype(I) +@assume_effects :foldable function sectorscalartype(::Type{I}) where {I <: Sector} + return if BraidingStyle(I) === NoBraiding() + fusionscalartype(I) else - return Base.promote_op(*, _Fscalartype(I), _Rscalartype(I)) + typeof(zero(fusionscalartype(I)) * zero(braidingscalartype(I))) end end -function _Fscalartype(::Type{I}) where {I <: Sector} - Ftype = Core.Compiler.return_type(Fsymbol, NTuple{6, I}) - return FusionStyle(I) === UniqueFusion() ? Ftype : eltype(Ftype) + +""" + fusionscalartype(I::Type{<:Sector}) -> Type{<:Number} + +Return the scalar type of the topological data associated to fusion of the sector `I`. +In particular, this is the scalar type of [`Fsymbol`](@ref). + +See also [`braidingscalartype`](@ref) and [`sectorscalartype`](@ref). +""" +@assume_effects :foldable function fusionscalartype(::Type{I}) where {I <: Sector} + u = first(allunits(I)) + return eltype(Fsymbol(u, u, u, u, u, u)) end -function _Rscalartype(::Type{I}) where {I <: Sector} + +""" + braidingscalartype(I::Type{<:Sector}) -> Type{<:Number} + +Return the scalar type of the topological data associated to braiding of the sector `I`. +In particular, this is the scalar type of [`Rsymbol`](@ref). + +See also [`fusionscalartype`](@ref) and [`sectorscalartype`](@ref). +""" +@assume_effects :foldable function braidingscalartype(::Type{I}) where {I <: Sector} BraidingStyle(I) === NoBraiding() && throw(ArgumentError("No braiding for sector $I")) - Rtype = Core.Compiler.return_type(Rsymbol, NTuple{3, I}) - return FusionStyle(I) === UniqueFusion() ? Rtype : eltype(Rtype) + u = first(allunits(I)) + return eltype(Rsymbol(u, u, u)) end """ @@ -400,6 +422,15 @@ end sqrtdim(a::Sector) = (FusionStyle(a) isa UniqueFusion) ? 1 : sqrt(dim(a)) invsqrtdim(a::Sector) = (FusionStyle(a) isa UniqueFusion) ? 1 : inv(sqrt(dim(a))) +""" + dimscalartype(::Type{<:Sector}) -> Type{<:Number} + +Return the scalar type of the quantum dimensions associated to sectors of type `I`. +In particular, this is the scalar type of [`dim`](@ref). +""" +@assume_effects :foldable dimscalartype(::Type{I}) where {I <: Sector} = + FusionStyle(I) isa UniqueFusion ? Int : typeof(dim(first(allunits(I)))) + """ frobenius_schur_phase(a::Sector) diff --git a/src/timereversed.jl b/src/timereversed.jl index 99423f1..75ac2b0 100644 --- a/src/timereversed.jl +++ b/src/timereversed.jl @@ -70,3 +70,8 @@ end function Base.isless(c1::TimeReversed{I}, c2::TimeReversed{I}) where {I <: Sector} return isless(c1.a, c2.a) end + +fusionscalartype(::Type{TimeReversed{I}}) where {I} = fusionscalartype(I) +braidingscalartype(::Type{TimeReversed{I}}) where {I} = braidingscalartype(I) +sectorscalartype(::Type{TimeReversed{I}}) where {I} = sectorscalartype(I) +dimscalartype(::Type{TimeReversed{I}}) where {I} = dimscalartype(I) diff --git a/src/trivial.jl b/src/trivial.jl index 121939b..84ba0db 100644 --- a/src/trivial.jl +++ b/src/trivial.jl @@ -23,7 +23,10 @@ findindex(::SectorValues{Trivial}, c::Trivial) = 1 unit(::Type{Trivial}) = Trivial() dual(::Trivial) = Trivial() Base.isless(::Trivial, ::Trivial) = false +fusionscalartype(::Type{Trivial}) = Int +braidingscalartype(::Type{Trivial}) = Int sectorscalartype(::Type{Trivial}) = Int +dimscalartype(::Type{Trivial}) = Int # fusion rules ⊗(::Trivial, ::Trivial) = (Trivial(),) diff --git a/test/sectors.jl b/test/sectors.jl index dcf7ef5..a1d7f4d 100644 --- a/test/sectors.jl +++ b/test/sectors.jl @@ -16,8 +16,10 @@ using LinearAlgebra @testinferred Asymbol(s...) B = @testinferred Bsymbol(s...) F = @testinferred Fsymbol(s..., s...) + @test eltype(F) === @testinferred fusionscalartype(I) if BraidingStyle(I) isa HasBraiding R = @testinferred Rsymbol(s...) + @test eltype(R) === @testinferred braidingscalartype(I) if FusionStyle(I) === SimpleFusion() @test typeof(R * F) <: @testinferred sectorscalartype(I) else