Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/linalg/linalg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,14 @@ const _TM_CAN_MUL = Union{
TensorMap, AdjointTensorMap{<:Any, <:Any, <:Any, <:Any, <:TensorMap}, BraidingTensor,
}
function _mul!!(C::_TM_CAN_MUL, A::_TM_CAN_MUL, B::_TM_CAN_MUL, α::Number, β::Number)
return mul!(C, A, B, α, β)
return mul!(C, A, B, _blasscalar(α), _blasscalar(β))
end

# `LinearAlgebra` cannot handle `One`/`Zero`, which carry the same meaning as `true`/`false`
# TODO: remove once `VectorInterface` implements the full `Number` interface for these
_blasscalar(α::Number) = α
_blasscalar(::One) = true
_blasscalar(::Zero) = false
# TODO: optimize other implementations

# ensure that mixes with AbstractBlockTensorMap and AbstractTensorMap behave as expected:
Expand Down
5 changes: 3 additions & 2 deletions src/vectorspaces/sumspace.jl
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,10 @@ end
function TensorKit._sectors(S::SumSpace, ::Type{I}) where {I}
s = Set{I}()
for v in S.spaces
s = s ∪ sectors(v)
union!(s, sectors(v))
end
return values(s)
# sorted for a canonical order, consistent with `GradedSpace` and `blocksectors`
return sort!(collect(s))
end

TensorKit.dim(S::SumSpace, sector::Sector) = sum(v -> dim(v, sector), S.spaces; init = 0)
Expand Down
4 changes: 3 additions & 1 deletion test/vectorspaces/sumspace.jl
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ end

@test @constinferred(sectortype(V)) == sectortype(V1)
@test ((@constinferred sectors(V))...,) == (U1Irrep(0), U1Irrep(1))
@test issorted(sectors(V))
@test length(sectors(V)) == 2
@test @constinferred(hassector(V, U1Irrep(0)))
@test !@constinferred(hassector(V, U1Irrep(2)))
Expand Down Expand Up @@ -188,7 +189,8 @@ end
@test unitspace(V) == unitspace(V1)

@test @constinferred(sectortype(V)) == sectortype(V1)
@test ((@constinferred sectors(V))...,) == (C1, C0, D1, D0, M) # ordering matters
@test ((@constinferred sectors(V))...,) == (C0, C1, M, D0, D1) # sorted order
@test issorted(sectors(V))
@test length(sectors(V)) == 5
@test @constinferred(hassector(V, M))
@test !@constinferred(hassector(V, Mop))
Expand Down
Loading