Skip to content

Commit bb6eee3

Browse files
committed
adapt TensorKit.scalar
1 parent 5bd5c12 commit bb6eee3

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/bimodulesector.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,3 +373,14 @@ function TensorKit.insertleftunit(P::ProductSpace{V,N}, ::Val{i}; # want no defa
373373
end
374374
return ProductSpace(TupleTools.insertafter(P.spaces, i - 1, (u,)))
375375
end
376+
377+
function TensorKit.scalar(t::AbstractTensorMap{T,S,0,0}) where {T,
378+
S<:GradedSpace{<:BimoduleSector}}
379+
inds = findall(!iszero last, blocks(t))
380+
isempty(inds) && return zero(scalartype(t))
381+
@assert length(inds) == 1
382+
383+
c = blocksectors(t)[only(inds)]
384+
return only(block(t, c))
385+
end
386+

0 commit comments

Comments
 (0)