diff --git a/src/sparse_coeffs.jl b/src/sparse_coeffs.jl index 1affb37..bdebbe9 100644 --- a/src/sparse_coeffs.jl +++ b/src/sparse_coeffs.jl @@ -14,10 +14,18 @@ function Base.copy(sc::SparseCoefficients) end function Base.getindex(sc::SparseCoefficients{K}, key::K) where {K} + @show sc.basis_elements + @show key k = searchsortedfirst(sc.basis_elements, key; lt = comparable(K)) + @show k + @show eachindex(sc.basis_elements) if k in eachindex(sc.basis_elements) v = sc.values[k] - return ifelse(sc.basis_elements[k] == key, v, zero(v)) + if sc.basis_elements[k] == key + return v + else + return zero(v) + end else return zero(valtype(sc)) end