# `Latu.ML.SparseVector`
[🔗](https://github.com/zero-one-group/latu_ml/blob/v0.4.2/lib/latu/ml/sparse_vector.ex#L1)

A Spark sparse vector, kept sparse.

`Nx` has no sparse tensor, so densifying is the only way to make one — and a sparse vector
is usually sparse for a reason. This struct is what `Latu.ML.Linalg.from_udt/1` hands back
instead, and `to_dense/1` is the caller's decision, never Latu ML's.

`indices` are ascending and zero-based, and `values` runs parallel to them.

# `t`

```elixir
@type t() :: %Latu.ML.SparseVector{
  indices: [non_neg_integer()],
  size: non_neg_integer(),
  values: [float()]
}
```

# `to_dense`

```elixir
@spec to_dense(t()) :: Nx.Tensor.t()
```

Fill in the zeros: an `{size}` `f64` tensor.

    iex> vector = %Latu.ML.SparseVector{size: 4, indices: [1, 3], values: [2.0, 4.0]}
    iex> Nx.to_flat_list(Latu.ML.SparseVector.to_dense(vector))
    [0.0, 2.0, 0.0, 4.0]

---

*Consult [api-reference.md](api-reference.md) for complete listing*
