kumulant

VectorView

@Serializable
sealed interface VectorView(source)

Read-only N-vector with sealed dense / sparse backing. Callers see the same surface either way; query the size, read entries by index, materialise to a DoubleArray. The same VectorView is used everywhere a vector observation flows: as the input to com.eignex.kumulant.core.VectorStat.update and com.eignex.kumulant.core.RegressionStat.update, as the weights of every fitted com.eignex.kumulant.core.HasLinearModel result, as the argument to every predict(VectorView) method.

The split between DenseVector and SparseVector is purely a backing- storage choice: dense pays per coordinate, sparse pays per nonzero. Most library code iterates via the internal forEachStored extension to walk only the populated entries; sparse callers feed sparse vectors without the cost of dense materialisation, and dense callers walk every index the same way.

Dot products, axpy, factorisations, and mutation are internal to kumulant; VectorView is an observation snapshot, not a general linear-algebra type. For ad-hoc math reach for the DoubleArray materialisation via toDoubleArray.

Subtypes are sealed and @Serializable so snapshots round-trip through kotlinx.serialization with their concrete storage preserved.

Inheritors

Properties

Link copied to clipboard
abstract val size: Int

Number of entries (including stored zeros for sparse).

Functions

Link copied to clipboard
abstract operator fun get(i: Int): Double

Read entry at i. O(1) for DenseVector, O(nnz) linear scan for SparseVector. Use the internal forEachStored extension when you want to walk the populated entries without per-index lookup cost.

Link copied to clipboard
abstract fun toDoubleArray(): DoubleArray

Materialise into a fresh dense DoubleArray. Always allocates; the returned array is independent of any internal storage, so the caller is free to mutate it.

get

abstract operator fun get(i: Int): Double(source)

Read entry at i. O(1) for DenseVector, O(nnz) linear scan for SparseVector. Use the internal forEachStored extension when you want to walk the populated entries without per-index lookup cost.

size

abstract val size: Int(source)

Number of entries (including stored zeros for sparse).

toDoubleArray

Materialise into a fresh dense DoubleArray. Always allocates; the returned array is independent of any internal storage, so the caller is free to mutate it.