SparseArrays.jl icon indicating copy to clipboard operation
SparseArrays.jl copied to clipboard

Inconsistent addition between sparse and dense

Open matbesancon opened this issue 1 year ago • 1 comments

julia>  spzeros(2) + [1.4, 3]
2-element SparseVector{Float64, Int64} with 2 stored entries:
       ⋮
  [2]  =  3.0

julia>  spzeros(2,2) +
        [1.4 3
        0 2]
2×2 Matrix{Float64}:
 1.4  3.0
 0.0  2.0

The matrix behavior seems to be the most sensible, assuming that adding a dense and a sparse will yield something sparse seems very risky

matbesancon avatar Feb 21 '24 16:02 matbesancon

Agree. Having a dense result is the sensible- since one of the inputs was already dense.

ViralBShah avatar Feb 21 '24 16:02 ViralBShah