-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathobjects.jl
More file actions
52 lines (44 loc) · 1.95 KB
/
objects.jl
File metadata and controls
52 lines (44 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
struct Object{F} <: Sector where {F <: FusionRing}
id::Int
function Object{F}(a::Int) where {F <: FusionRing}
0 < a <= rank(F) || throw(ArgumentError("Unknown $F Object $a."))
return new{F}(a)
end
end
function algebraic_structure(::Union{Type{Object{F}}, Object{F}}) where {F}
return F
end
Base.isless(a::Object{F}, b::Object{F}) where {F} = isless(a.id, b.id)
Base.hash(a::Object{F}, h::UInt) where {F} = hash(a.id, h)
Base.convert(::Type{F}, d::Integer) where {F <: Object} = F(d)
Base.IteratorSize(::Type{SectorValues{<:Object}}) = HasLength()
Base.length(::SectorValues{<:Object{F}}) where {F} = rank(F)
function Base.iterate(::SectorValues{<:Object{F}}, i = 1) where {F}
return i > rank(F) ? nothing : (Object{F}(i), i + 1)
end
function Base.getindex(S::SectorValues{<:Object{F}}, i::Int) where {F}
return 0 < i <= rank(F) ? Object{F}(i) : throw(BoundsError(S, i))
end
TensorKitSectors.findindex(::SectorValues{I}, c::I) where {I <: Object} = c.id
# some fallback styles - should probably be overwritten for specific categories
function TensorKitSectors.FusionStyle(::Type{<:Object{F}}) where {F}
return multiplicity(F) == 1 ? SimpleFusion() : GenericFusion()
end
TensorKitSectors.BraidingStyle(::Type{<:Object{<:BraidedCategory}}) = Anyonic()
TensorKitSectors.BraidingStyle(::Type{<:Object{<:FusionRing}}) = NoBraiding()
function TensorKitSectors.:⊗(a::I, b::I) where {I <: Object}
return Iterators.filter(c -> Nsymbol(a, b, c) > 0, values(I))
end
TensorKitSectors.unit(::Type{<:Object{F}}) where {F} = Object{F}(1)
function TensorKitSectors.dual(a::Object{F}) where {F}
if selfduality(F) == 0
return a
else
return Object{F}(
findfirst(x -> Nsymbol(a, x, unit(a)) == 1, collect(values(typeof(a))))
)
end
end
# must be integer for fusiontensor
TensorKitSectors.dim(a::Object{RepA4}) = a.id == 4 ? 3 : 1
TensorKitSectors.BraidingStyle(::Type{Object{RepA4}}) = TensorKitSectors.Bosonic()