How do I check if a specific element in a sparse matrix is defined? (where the matrix possibly have 0-valued entries)

I have a sparse 2x2 matrix:

using SparseArrays
sm = SparseMatrixCSC(2, 2, [1, 3, 4], [1, 2, 1], [1.0, 0.0, 1.0])

that looks like:

 1.0  1.0
 0.0   ⋅ 

is there a way to check whenever element [2,2] is filled or not? Normally, I could do

sm[2,2] == 0.0

but that returns true both for [2,1] and [2,2].

julia> Base.isstored(sm,2,2)
false

julia> Base.isstored(sm,2,1)
true

maybe doing:

julia> import Base.isstored

julia> isstored(sm,2,2)
false

is nice if used a lot.

1 Like

Thanks!