Remove explicit null values ​​from sparse matrix in Julia

Is it possible to remove explicit null value from sparse matrix in Julia?

Namely, I want to convert a=sparse([1],[1],[0])

tob=spzeros(1,1)

+3


source to share


1 answer


Yes: see dropzeros

:

julia> a=sparse([1],[1],[0])
1Γ—1 SparseMatrixCSC{Int64,Int64} with 1 stored entry:
  [1, 1]  =  0

julia> dropzeros(a)
1Γ—1 SparseMatrixCSC{Int64,Int64} with 0 stored entries

      



Or you can do it in-place (change a

) with dropzeros!

.

+8


source







All Articles