Skip to content

Commit a2f1ec1

Browse files
committed
custom zero of GradedSpace and fuse
1 parent f6b6a59 commit a2f1ec1

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/bimodulesector.jl

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,11 +302,24 @@ function rounddim(c::I) where {I<:BimoduleSector}
302302
end
303303
end
304304

305-
function dim(V::GradedSpace{<:BimoduleSector})
305+
function TensorKit.dim(V::GradedSpace{<:BimoduleSector})
306306
T = Base.promote_op(*, Int, real(sectorscalartype(sectortype(V))))
307307
return reduce(+, dim(V, c) * rounddim(c) for c in sectors(V); init=zero(T))
308308
end
309309

310+
Base.zero(S::Type{<:GradedSpace{<:BimoduleSector}}) = S()
311+
312+
function TensorKit.fuse(V₁::GradedSpace{I}, V₂::GradedSpace{I}) where {I<:BimoduleSector}
313+
dims = SectorDict{I,Int}()
314+
for a in sectors(V₁), b in sectors(V₂)
315+
a.j == b.i || continue # skip if not compatible
316+
for c in a b
317+
dims[c] = get(dims, c, 0) + Nsymbol(a, b, c) * dim(V₁, a) * dim(V₂, b)
318+
end
319+
end
320+
return typeof(V₁)(dims)
321+
end
322+
310323
# limited oneunit
311324
function Base.oneunit(S::GradedSpace{<:BimoduleSector})
312325
allequal(a.i for a in sectors(S)) && allequal(a.j for a in sectors(S)) ||

0 commit comments

Comments
 (0)