This thread is old, but I was poking through some unread bits and found it.
Beyond that, it’s likely a better question for julia-users list (which I’m
including here).

Anyhow, the answer is that sparsevec converts a dense matrix into a sparse
matrix format where zero values are not explicitly stored. If the vector
(or matrix) really is dense, this does not save space.

julia> A = [23.1, 42.67, 8.246, 111.33]
4-element Array{Float64,1}:
  23.1
  42.67
   8.246
 111.33

julia> sparsevec(A)
Sparse vector of length 4 with 4 Float64 nonzero entries:
  [1]  =  23.1
  [2]  =  42.67
  [3]  =  8.246
  [4]  =  111.33


julia> B = [0,0,A...]
6-element Array{Float64,1}:
   0.0
   0.0
  23.1
  42.67
   8.246
 111.33

julia> sparsevec(B)
Sparse vector of length 6 with 4 Float64 nonzero entries:
  [3]  =  23.1
  [4]  =  42.67
  [5]  =  8.246
  [6]  =  111.33

Cameron


On Sat, Aug 20, 2016 at 7:15 AM, Parkway <dineshbvad...@hotmail.com> wrote:

> The doc for the function sparsevec(A) says:
> sparsevec(A)
> Convert a dense vector A into a sparse matrix of size m x 1. In julia,
> sparse vectors are really just sparse matrices with one column.
>
> What does this actually mean? For example, what does the dense vector A =
> [23.1, 42.67, 8.246, 111.33] get converted to?
>
>

Reply via email to