Dense .+ sparse -> sparse?


I find this counterintuitive:

julia> using SparseArrays

julia> A=rand(100,100);

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

julia> typeof(A + B)

julia> typeof(A .+ B)

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


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.


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