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.
Summary
Functions
Fill in the zeros: an {size} f64 tensor.
Types
@type t() :: %Latu.ML.SparseVector{ indices: [non_neg_integer()], size: non_neg_integer(), values: [float()] }
Functions
@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]