# Dense .+ sparse -\> sparse?

**URL:** <https://discourse.julialang.org/t/dense-sparse-sparse/20126>\
**Category:** Internals & Design\
**Created:** [January 26, 2019, 12:05pm UTC](https://discourse.julialang.org/t/dense-sparse-sparse/20126 "2019-01-26T12:05:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![abraunst](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abraunst/32/6880_2.png) [@abraunst](https://discourse.julialang.org/u/abraunst)\
**Post date:** [January 26, 2019, 12:05pm UTC](https://discourse.julialang.org/t/dense-sparse-sparse/20126/1 "2019-01-26T12:05:28Z")

</div>

I find this counterintuitive:

```julia
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?

---

<div class="post-metadata">

**Author:** ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Post date:** [January 26, 2019, 1:52pm UTC](https://discourse.julialang.org/t/dense-sparse-sparse/20126/2 "2019-01-26T13:52:32Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![abraunst](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abraunst/32/6880_2.png) [@abraunst](https://discourse.julialang.org/u/abraunst)\
**Post date:** [January 26, 2019, 2:13pm UTC](https://discourse.julialang.org/t/dense-sparse-sparse/20126/3 "2019-01-26T14:13:04Z")

</div>

Thanks, I’ll open an issue then. Done [here](https://github.com/JuliaLang/julia/issues/30848#issue-403445977).
