-
Notifications
You must be signed in to change notification settings - Fork 56
Closed
Description
Hi thanks for your guys' good package.
I am writing a code, whose tensors are morphisms in VecG, the category of G-graded vector spaces. It is not a braided category so there is only the fusion structure.
The following is the code to define the VecD8 category structure following your documentation.
using TensorKit
struct D8 <: Sector
s::Int
r::Int
end
Base.one(::Type{D8}) = D8(0,0)
Base.conj(g::D8) = D8(mod(-g.s,2), mod((-1)^(g.s + 1) * g.r,4))
dim(g::D8) = 1
Base.isreal(::Type{D8}) = true
TensorKit.FusionStyle(::Type{D8}) = UniqueFusion()
TensorKit.Nsymbol(a::D8, b::D8, c::D8) = (mod(a.s + b.s, 2), mod((-1)^b.s * a.r + b.r, 4)) == (c.s, c.r) ? 1 : 0
⊗(a::D8, b::D8) = D8(mod(a.s + b.s, 2), mod((-1)^b.s * a.r + b.r, 4))
Base.isless(a::D8, b::D8) = a.s < b.s || (a.s == b.s && a.r < b.r)
function Base.iterate(::TensorKit.SectorValues{D8},s=0,r=0)
if s==0 && r < 4
return (D8(s,r), (s, r+1))
elseif s==0 && r==4
return (D8(0,4), (1,0))
elseif s==1 && r < 4
return (D8(s,r), (s, r+1))
else
return nothing
end
end
TensorKit.Fsymbol(a::D8, b::D8, c::D8, d::D8, e::D8, f::D8) = 1
Base.length(::TensorKit.SectorValues{D8}) = 8
Base.getindex(::TensorKit.SectorValues{D8}, i::Int) = D8((i-1)÷4, (i-1)%4)
TensorKit.findindex(::TensorKit.SectorValues{D8}, c::D8) = c.r + 4 * c.s + 1
V1 = Vect[D8](D8(0,0) => 1, D8(1,2) => 2)
V2 = Vect[D8](D8(0,0) => 1, D8(1,2) => 2)
V3 = Vect[D8](D8(0,0) => 1, D8(1,2) => 2)
V4 = Vect[D8](D8(0,0) => 1, D8(1,2) => 2)
function ⊗(V1::GradedSpace{D8, NTuple{8, Int64}}, V2::GradedSpace{D8, NTuple{8, Int64}})
G = TensorKit.SectorValues{D8}()
multiplicity = zeros(Int, 8)
for i in 1:8, j in 1:8
delta = V1.dims[i] * V2.dims[j]
g = G[i] ⊗ G[j]
multiplicity[TensorKit.findindex(G, g)] += delta
end
return GradedSpace{D8, NTuple{8, Int64}}(Tuple(multiplicity), false)
end
@show D8(1,2) ⊗ D8(0,0)
@show V1 ⊗ V4
rand(V1 ⊗ V4 ← V2 ⊗ V3)
It reports error:
ERROR: ArgumentError: Union{} does not have elements
Stacktrace:
[1] eltype(::Type{Union{}})
@ Base ./abstractarray.jl:240
[2] sectorscalartype(::Type{D8})
@ TensorKitSectors ~/.julia/packages/TensorKitSectors/cqTdc/src/sectors.jl:112
[3] TensorMap{Float64, GradedSpace{…}, 1, 1, Vector{…}}(data::Vector{Float64}, space::TensorMapSpace{GradedSpace{…}, 1, 1})
@ TensorKit ~/.julia/packages/TensorKit/esxcj/src/tensors/tensor.jl:34
[4] TensorMap{Float64, GradedSpace{…}, 1, 1, Vector{…}}(::UndefInitializer, space::TensorMapSpace{GradedSpace{…}, 1, 1})
@ TensorKit ~/.julia/packages/TensorKit/esxcj/src/tensors/tensor.jl:24
[5] (TensorMap{…} where {…})(::UndefInitializer, V::TensorMapSpace{…})
@ TensorKit ~/.julia/packages/TensorKit/esxcj/src/tensors/tensor.jl:90
[6] rand(rng::Random.TaskLocalRNG, ::Type{Float64}, V::TensorMapSpace{GradedSpace{D8, NTuple{8, Int64}}, 1, 1})
@ TensorKit ~/.julia/packages/TensorKit/esxcj/src/tensors/tensor.jl:259
[7] rand(::Type{Float64}, V::TensorMapSpace{GradedSpace{D8, NTuple{8, Int64}}, 1, 1})
@ TensorKit ~/.julia/packages/TensorKit/esxcj/src/tensors/tensor.jl:252
[8] rand(V::TensorMapSpace{GradedSpace{D8, NTuple{8, Int64}}, 1, 1})
@ TensorKit ~/.julia/packages/TensorKit/esxcj/src/tensors/tensor.jl:245
I am wondering whether it can be supported with only a small modification? I am also writing a code, but I am only trying to tackle VecG case.
Metadata
Metadata
Assignees
Labels
No labels