diff --git a/src/coefficients.jl b/src/coefficients.jl index 9330350..a2b0d6c 100644 --- a/src/coefficients.jl +++ b/src/coefficients.jl @@ -33,6 +33,7 @@ key_type(b) = keytype(b) # back to `keytype{::Type{<:AbstractArray})` which returns `Int`. key_type(::Type{SparseArrays.SparseVector{V,K}}) where {V,K} = K key_type(v::SparseArrays.SparseVector) = key_type(typeof(v)) +key_type(::Tuple) = Int Base.iszero(ac::AbstractCoefficients) = isempty(keys(ac)) @@ -260,5 +261,3 @@ function MA.operate_to!( end return res end - - diff --git a/src/types.jl b/src/types.jl index e3bd5bf..7ec2dce 100644 --- a/src/types.jl +++ b/src/types.jl @@ -51,9 +51,12 @@ function MA.promote_operation(::typeof(basis), ::Type{<:AlgebraElement{A}}) wher end basis(a::AlgebraElement) = basis(parent(a)) +value_type(coeffs) = valtype(coeffs) +value_type(::NTuple{N,T}) where {N,T} = T + function AlgebraElement(coeffs, A::AbstractStarAlgebra) _sanity_checks(coeffs, A) - return AlgebraElement{typeof(A),valtype(coeffs),typeof(coeffs)}(coeffs, A) + return AlgebraElement{typeof(A),value_type(coeffs),typeof(coeffs)}(coeffs, A) end function AlgebraElement(