Dense .+ sparse -> sparse?


#1

I find this counterintuitive:

julia> using SparseArrays

julia> A=rand(100,100);

julia> B=sprand(100,100,0.01);

julia> typeof(A + B)
Array{Float64,2}

julia> typeof(A .+ B)
SparseMatrixCSC{Float64,Int64}

I would have expected the result to be dense. What is the rationale?


#2

Seems like a bug to me. Anything that is guaranteed to generate a sparse matrix with all structural non-zeros is pointless and should just produce a dense matrix.


#3

Thanks, I’ll open an issue then. Done here.