Skip to content

Commit bbebdda

Browse files
borisdevoslkdvos
andauthored
[Breaking] UnitStyle, allunits and a bunch of renaming (#25)
* `MultiFusionStyle` and its properties with itself and `FusionStyle` * `allones` for `Type{Sector}` * changes to `IsingBimodule` * export them all * `allones` tests * fix `&` and make commutative for mixed case * `MultiFusionStyle` tests * format * update `MultiFusionStyle` to only reflect the semisimplicity of the unit * update for `IsingBimodule` * fix exports * fix tests * fix docstrings * add `MultiFusionStyle` for product sectors + test * remove interplay `MultiFusionStyle`-`FusionStyle` + related tests * fix domain error of one of IsingBimodule * introduce `allones` for all sectors * introduce generic `one` for type sector + remove for specific sectors * `allones` for productsector with tests * have multifusionstyle fully depend on `allones` * format * change `one` to `unit` and have `Base.one` fall back to `unit` + rename to `left/rightunit` and `allunits` * rename `MultiFusionStyle` to `UnitStyle` * replace `Base.conj` with `dual` and have `dual` fall back to `Base.conj` * replacing more `conj` with `dual` + docstring changes * minor docstring fix * more one to unit changes * fix `allunits` of product sector to be type stable and return set * `allunits` for `NewSU2Irrep` * add imports for `NewSU2Irrep` * `allunits` for `TimeReversed` * remove some specific `unit`s I missed * apply code suggestions * reverse roles of `unit` and `allunits` to make `unit` the entry point of a sector * more `mapreduce`s * another `mapreduce` + format * use `SectorSet` for time reversed `allunits` * remove `_isreal` code * derive `unit` from `one` for `GroupElement` * avoid string interpolations in error messages * reduce specification * make otimes output of time reversed a `SectorSet` * introduce `isunit` and change `isone` to `isunit` where relevant * bump version to 0.3.0 * one last `isunit` * change fib field name to `isunit` * `unit(::Type{<:AbstractGroupElement})` * noinline domainerror * also update precompile --------- Co-authored-by: Lukas Devos <ldevos98@gmail.com>
1 parent 4fc474c commit bbebdda

20 files changed

+180
-104
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "TensorKitSectors"
22
uuid = "13a9c161-d5da-41f0-bcbd-e1a08ae0647f"
33
authors = ["Lukas Devos", "Jutho Haegeman"]
4-
version = "0.2.1"
4+
version = "0.3.0"
55

66
[deps]
77
HalfIntegers = "f0d1745a-41c9-11e9-1dd9-e5d34d218721"

src/TensorKitSectors.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ export dim, sqrtdim, invsqrtdim, frobeniusschur, twist, fusiontensor, dual
1111
export otimes, deligneproduct, times
1212
export FusionStyle, UniqueFusion, MultipleFusion, SimpleFusion, GenericFusion,
1313
MultiplicityFreeFusion
14+
export UnitStyle, SimpleUnit, GenericUnit
1415
export BraidingStyle, NoBraiding, HasBraiding, SymmetricBraiding, Bosonic, Fermionic, Anyonic
1516
export SectorSet, SectorValues, findindex
16-
export rightone, leftone
17+
export unit, rightunit, leftunit, allunits, isunit
1718

1819
export triangle_equation, pentagon_equation, hexagon_equation
1920

src/anyons.jl

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ end
2121
findindex(::SectorValues{PlanarTrivial}, c::PlanarTrivial) = 1
2222
Base.isless(::PlanarTrivial, ::PlanarTrivial) = false
2323

24-
Base.one(::Type{PlanarTrivial}) = PlanarTrivial()
25-
Base.conj(::PlanarTrivial) = PlanarTrivial()
24+
unit(::Type{PlanarTrivial}) = PlanarTrivial()
25+
dual(::PlanarTrivial) = PlanarTrivial()
2626

2727
FusionStyle(::Type{PlanarTrivial}) = UniqueFusion()
2828
BraidingStyle(::Type{PlanarTrivial}) = NoBraiding()
@@ -43,11 +43,11 @@ corresponding to the trivial sector `FibonacciAnyon(:I)` and the non-trivial sec
4343
`FibonacciAnyon(:τ)` with fusion rules ``τ ⊗ τ = 1 ⊕ τ``.
4444
4545
## Fields
46-
- `isone::Bool`: indicates whether the sector corresponds the to trivial anyon `:I`
46+
- `isunit::Bool`: indicates whether the sector corresponds to the trivial anyon `:I`
4747
(`true`), or the non-trivial anyon `:τ` (`false`).
4848
"""
4949
struct FibonacciAnyon <: Sector
50-
isone::Bool
50+
isunit::Bool
5151
function FibonacciAnyon(s::Symbol)
5252
s in (:I, , :tau) || throw(ArgumentError("Unknown FibonacciAnyon $s."))
5353
return new(s === :I)
@@ -68,14 +68,14 @@ function Base.getindex(S::SectorValues{FibonacciAnyon}, i::Int)
6868
throw(BoundsError(S, i))
6969
end
7070
end
71-
findindex(::SectorValues{FibonacciAnyon}, s::FibonacciAnyon) = 2 - s.isone
71+
findindex(::SectorValues{FibonacciAnyon}, s::FibonacciAnyon) = 2 - s.isunit
7272

7373
Base.convert(::Type{FibonacciAnyon}, s::Symbol) = FibonacciAnyon(s)
74-
Base.one(::Type{FibonacciAnyon}) = FibonacciAnyon(:I)
75-
Base.conj(s::FibonacciAnyon) = s
74+
unit(::Type{FibonacciAnyon}) = FibonacciAnyon(:I)
75+
dual(s::FibonacciAnyon) = s
7676

7777
const _goldenratio = Float64(MathConstants.golden)
78-
dim(a::FibonacciAnyon) = isone(a) ? one(_goldenratio) : _goldenratio
78+
dim(a::FibonacciAnyon) = isunit(a) ? one(_goldenratio) : _goldenratio
7979

8080
FusionStyle(::Type{FibonacciAnyon}) = SimpleFusion()
8181
BraidingStyle(::Type{FibonacciAnyon}) = Anyonic()
@@ -89,7 +89,7 @@ struct FibonacciIterator
8989
end
9090
Base.IteratorSize(::Type{FibonacciIterator}) = Base.HasLength()
9191
Base.IteratorEltype(::Type{FibonacciIterator}) = Base.HasEltype()
92-
Base.length(iter::FibonacciIterator) = (isone(iter.a) || isone(iter.b)) ? 1 : 2
92+
Base.length(iter::FibonacciIterator) = (isunit(iter.a) || isunit(iter.b)) ? 1 : 2
9393
Base.eltype(::Type{FibonacciIterator}) = FibonacciAnyon
9494
function Base.iterate(iter::FibonacciIterator, state = 1)
9595
I = FibonacciAnyon(:I)
@@ -107,7 +107,7 @@ function Base.iterate(iter::FibonacciIterator, state = 1)
107107
end
108108

109109
function Nsymbol(a::FibonacciAnyon, b::FibonacciAnyon, c::FibonacciAnyon)
110-
return isone(a) + isone(b) + isone(c) != 2
110+
return isunit(a) + isunit(b) + isunit(c) != 2
111111
end # zero if one tau and two ones
112112

113113
function Fsymbol(
@@ -136,21 +136,21 @@ end
136136

137137
function Rsymbol(a::FibonacciAnyon, b::FibonacciAnyon, c::FibonacciAnyon)
138138
Nsymbol(a, b, c) || return 0 * cispi(0 / 1)
139-
if isone(a) || isone(b)
139+
if isunit(a) || isunit(b)
140140
return cispi(0 / 1)
141141
else
142-
return isone(c) ? cispi(4 / 5) : cispi(-3 / 5)
142+
return isunit(c) ? cispi(4 / 5) : cispi(-3 / 5)
143143
end
144144
end
145145

146146
function Base.show(io::IO, a::FibonacciAnyon)
147-
s = isone(a) ? ":I" : ""
147+
s = isunit(a) ? ":I" : ""
148148
return get(io, :typeinfo, nothing) === FibonacciAnyon ?
149149
print(io, s) : print(io, "FibonacciAnyon(", s, ")")
150150
end
151151

152-
Base.hash(a::FibonacciAnyon, h::UInt) = hash(a.isone, h)
153-
Base.isless(a::FibonacciAnyon, b::FibonacciAnyon) = isless(!a.isone, !b.isone)
152+
Base.hash(a::FibonacciAnyon, h::UInt) = hash(a.isunit, h)
153+
Base.isless(a::FibonacciAnyon, b::FibonacciAnyon) = isless(!a.isunit, !b.isunit)
154154

155155
# IsingAnyons
156156
"""
@@ -191,8 +191,8 @@ function findindex(::SectorValues{IsingAnyon}, a::IsingAnyon)
191191
end
192192

193193
Base.convert(::Type{IsingAnyon}, s::Symbol) = IsingAnyon(s)
194-
Base.one(::Type{IsingAnyon}) = IsingAnyon(:I)
195-
Base.conj(s::IsingAnyon) = s
194+
unit(::Type{IsingAnyon}) = IsingAnyon(:I)
195+
dual(s::IsingAnyon) = s
196196

197197
dim(a::IsingAnyon) = a.s == ? sqrt(2) : 1.0
198198

src/fermions.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ function Base.getindex(::SectorValues{FermionParity}, i::Int)
2828
end
2929
findindex(::SectorValues{FermionParity}, f::FermionParity) = f.isodd ? 2 : 1
3030

31-
Base.one(::Type{FermionParity}) = FermionParity(false)
32-
Base.conj(f::FermionParity) = f
31+
unit(::Type{FermionParity}) = FermionParity(false)
32+
dual(f::FermionParity) = f
3333
dim(f::FermionParity) = 1
3434

3535
FusionStyle(::Type{FermionParity}) = UniqueFusion()

src/groupelements.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ BraidingStyle(::Type{<:AbstractGroupElement}) = NoBraiding()
3434

3535
cocycle(a::I, b::I, c::I) where {I <: AbstractGroupElement} = 1
3636
(a::I, b::I) where {I <: AbstractGroupElement} = (a * b,)
37-
Base.one(a::AbstractGroupElement) = one(typeof(a))
38-
Base.conj(a::AbstractGroupElement) = inv(a)
37+
dual(a::AbstractGroupElement) = inv(a)
38+
unit(::Type{I}) where {I <: AbstractGroupElement} = one(I)
3939
Nsymbol(a::I, b::I, c::I) where {I <: AbstractGroupElement} = c == a * b
4040
function Fsymbol(a::I, b::I, c::I, d::I, e::I, f::I) where {I <: AbstractGroupElement}
4141
ω = cocycle(a, b, c)

src/irreps/cu1irrep.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ end
6666
Base.convert(::Type{CU1Irrep}, j::Real) = CU1Irrep(j)
6767
Base.convert(::Type{CU1Irrep}, js::Tuple{Real, Int}) = CU1Irrep(js...)
6868

69-
Base.one(::Type{CU1Irrep}) = CU1Irrep(zero(HalfInt), 0)
70-
Base.conj(c::CU1Irrep) = c
69+
unit(::Type{CU1Irrep}) = CU1Irrep(zero(HalfInt), 0)
70+
dual(c::CU1Irrep) = c
7171

7272
struct CU1ProdIterator
7373
a::CU1Irrep
@@ -82,7 +82,7 @@ function Base.iterate(p::CU1ProdIterator, s::Int = 1)
8282
elseif p.b.j == zero(HalfInt)
8383
return p.a, 4
8484
elseif p.a == p.b # != zero
85-
return one(CU1Irrep), 2
85+
return unit(CU1Irrep), 2
8686
else
8787
return CU1Irrep(abs(p.a.j - p.b.j)), 3
8888
end

src/irreps/dnirrep.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ FusionStyle(::Type{DNIrrep{N}}) where {N} = N < 3 ? UniqueFusion() : SimpleFusio
4747
sectorscalartype(::Type{DNIrrep{N}}) where {N} = Float64
4848
Base.isreal(::Type{DNIrrep{N}}) where {N} = true
4949

50-
Base.one(::Type{DNIrrep{N}}) where {N} = DNIrrep{N}(0, false)
51-
Base.conj(a::DNIrrep) = a
50+
unit(::Type{DNIrrep{N}}) where {N} = DNIrrep{N}(0, false)
51+
dual(a::DNIrrep) = a
5252

5353
Base.hash(a::DNIrrep, h::UInt) = hash(a.data, h)
5454
Base.convert(::Type{DNIrrep{N}}, (j, n)::Tuple{Integer, Bool}) where {N} = DNIrrep{N}(j, n)
@@ -195,7 +195,7 @@ function Fsymbol(a::I, b::I, c::I, d::I, e::I, f::I) where {N, I <: DNIrrep{N}}
195195
(Nsymbol(a, b, e) & Nsymbol(e, c, d) & Nsymbol(b, c, f) & Nsymbol(a, f, d)) || return zero(T)
196196

197197
# tensoring with units gives 1
198-
(isone(a) || isone(b) || isone(c)) && return one(T)
198+
(isunit(a) || isunit(b) || isunit(c)) && return one(T)
199199

200200
# fallback through fusiontensor
201201
A = fusiontensor(a, b, e)

src/irreps/su2irrep.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ Base.getindex(::IrrepTable, ::Type{SU₂}) = SU2Irrep
3030
Base.convert(::Type{SU2Irrep}, j::Real) = SU2Irrep(j)
3131

3232
const _su2one = SU2Irrep(zero(HalfInt))
33-
Base.one(::Type{SU2Irrep}) = _su2one
34-
Base.conj(s::SU2Irrep) = s
33+
unit(::Type{SU2Irrep}) = _su2one
34+
dual(s::SU2Irrep) = s
3535
(s1::SU2Irrep, s2::SU2Irrep) = SectorSet{SU2Irrep}(abs(s1.j - s2.j):(s1.j + s2.j))
3636

3737
Base.IteratorSize(::Type{SectorValues{SU2Irrep}}) = IsInfinite()

src/irreps/u1irrep.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ end
1919
Base.getindex(::IrrepTable, ::Type{U₁}) = U1Irrep
2020
Base.convert(::Type{U1Irrep}, c::Real) = U1Irrep(c)
2121

22-
Base.one(::Type{U1Irrep}) = U1Irrep(0)
23-
Base.conj(c::U1Irrep) = U1Irrep(-c.charge)
22+
unit(::Type{U1Irrep}) = U1Irrep(0)
23+
dual(c::U1Irrep) = U1Irrep(-c.charge)
2424
(c1::U1Irrep, c2::U1Irrep) = (U1Irrep(c1.charge + c2.charge),)
2525

2626
Base.IteratorSize(::Type{SectorValues{U1Irrep}}) = IsInfinite()

src/irreps/znirrep.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ const Z2Irrep = ZNIrrep{2}
2525
const Z3Irrep = ZNIrrep{3}
2626
const Z4Irrep = ZNIrrep{4}
2727

28-
Base.one(::Type{ZNIrrep{N}}) where {N} = ZNIrrep{N}(0)
29-
Base.conj(c::ZNIrrep{N}) where {N} = ZNIrrep{N}(-c.n)
28+
unit(::Type{ZNIrrep{N}}) where {N} = ZNIrrep{N}(0)
29+
dual(c::ZNIrrep{N}) where {N} = ZNIrrep{N}(-c.n)
3030
(c1::ZNIrrep{N}, c2::ZNIrrep{N}) where {N} = (ZNIrrep{N}(c1.n + c2.n),)
3131

3232
Base.IteratorSize(::Type{SectorValues{ZNIrrep{N}}}) where {N} = HasLength()

0 commit comments

Comments
 (0)