Is there some simple way to check if there's a stored value at a specific index of a sparse array? I'm imagining some function like
julia> A = sprand(3, 3, 0.5)
3×3 SparseMatrixCSC{Float64, Int64} with 5 stored entries:
0.593332 ⋅ ⋅
⋅ 0.349431 ⋅
0.860202 0.653576 0.819548
julia> isstored(A, 1, 1)
true
julia> isstored(A, 1, 2)
false
oh, turns out there is in fact a function for this in Base that's just not exported with the name I made up:
julia> Base.isstored(A, 1, 1)
true
julia> Base.isstored(A, 1, 2)
false
Guess I should have checked that :sweat_smile:
Mason Protter has marked this topic as resolved.
opened a PR to make it public
: https://github.com/JuliaLang/julia/pull/56421
It's a bit mysterious. The function isstored
is defined and implemented for AbstractArray
in abstractarray.jl . But it's not exported and it's not referred to anywhere in Base
. It is tested in Base
. And the SparseArrays
methods extend it. It kind of looks like its current state is not intentional.
It's for special matrix types with sparity like SparseMatrix
, BandedMatrix
, UpperTriangular
, etc.
(none of which are defined in Base so it's just a default implementation there in Base
)
Last updated: Dec 28 2024 at 04:38 UTC