diff --git a/src/linalg/linalg.jl b/src/linalg/linalg.jl index aedc2bb..0abd9a3 100644 --- a/src/linalg/linalg.jl +++ b/src/linalg/linalg.jl @@ -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: diff --git a/src/vectorspaces/sumspace.jl b/src/vectorspaces/sumspace.jl index b4d97a4..8415b62 100644 --- a/src/vectorspaces/sumspace.jl +++ b/src/vectorspaces/sumspace.jl @@ -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) diff --git a/test/vectorspaces/sumspace.jl b/test/vectorspaces/sumspace.jl index e4faa52..1c877ba 100644 --- a/test/vectorspaces/sumspace.jl +++ b/test/vectorspaces/sumspace.jl @@ -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))) @@ -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))