SparseArrays.jl
SparseArrays.jl copied to clipboard
SparseMatrixCSC type conversion (sometimes) drops structural nonzeros
Update: another surprising consequence of https://github.com/JuliaSparse/SparseArrays.jl/issues/190 that led to hours of debugging...
SparseMatrixCSC Float64.(A) drops structural nonzeros, but float(A) doesn't:
julia> A = SparseArrays.sparse([1 2 0; 0 0 3; 0 4 0])
julia> A[1, 1] = 0
julia> A
3×3 SparseArrays.SparseMatrixCSC{Int64, Int64} with 4 stored entries:
0 2 ⋅
⋅ ⋅ 3
⋅ 4 ⋅
julia> Float64.(A) # drops structural nonzeros !!
3×3 SparseArrays.SparseMatrixCSC{Float64, Int64} with 3 stored entries:
⋅ 2.0 ⋅
⋅ ⋅ 3.0
⋅ 4.0 ⋅
julia> float(A) # OK ?!
3×3 SparseArrays.SparseMatrixCSC{Float64, Int64} with 4 stored entries:
0.0 2.0 ⋅
⋅ ⋅ 3.0
⋅ 4.0 ⋅