-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Closed
Labels
broadcastApplying a function over a collectionApplying a function over a collectionsparseSparse arraysSparse arrays
Description
I was surprised to notice that broadcast on a Diagonal matrix results in a sparse matrix, not a dense one:
julia> Diagonal(-1:0) .+ 1
2×2 SparseMatrixCSC{Int64,Int64} with 4 stored entries:
[1, 1] = 0
[2, 1] = 1
[1, 2] = 1
[2, 2] = 1In particular, the 0 in the above example is a "stored entry", so even in the case where there are many zeros in the result, it will still take more memory than a dense matrix.
Metadata
Metadata
Assignees
Labels
broadcastApplying a function over a collectionApplying a function over a collectionsparseSparse arraysSparse arrays