Skip to content

Commit

Permalink
Allow coeffs not defining zero
Browse files Browse the repository at this point in the history
  • Loading branch information
blegat committed Jun 13, 2024
1 parent 7550169 commit 859feb6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/sparse_coeffs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ function Base.getindex(sc::SparseCoefficients{K}, key::K) where {K}
k = searchsortedfirst(sc.basis_elements, key; lt = comparable(K))
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
Expand Down

0 comments on commit 859feb6

Please sign in to comment.