koblas

Companion

Factory entrypoints for SparseVector.

Functions

of

fun of(size: Int, indices: IntArray, values: DoubleArray): SparseVector(source)

Build a sparse vector, sorting by index and summing duplicates. Copies its inputs, so the caller can reuse the arrays.

The forgiving counterpart to the constructor, which requires the ordering it relies on. Entries may arrive in any order; a repeated index contributes the sum of its values, which is what a scatter of accumulated contributions means.