koblas

VectorView

@Serializable
sealed interface VectorView : VectorLike(source)

The vector storages koblas itself defines: DenseVector and SparseVector, and nothing else ever.

Sealed for serialization, exactly as MatrixView is — a snapshot decodes back into the storage it was written from without a consumer registering anything. Take VectorLike instead unless you need the closed set.

The split between the two storages is a backing-storage choice, not a semantic one: dense pays per coordinate, sparse pays per nonzero. Most code iterates via forEachStored to walk only the populated entries, so sparse callers feed sparse vectors without the cost of dense materialisation and dense callers walk every index the same way.

Inheritors

Properties

Link copied to clipboard
abstract val size: Int

Number of entries (including stored zeros for sparse).

Functions

Link copied to clipboard
infix fun VectorLike.dot(other: VectorLike): Double

aT * b. Dense×dense routes through the active com.eignex.koblas.dense.VectorKernels; a mixed pair walks the sparse side and gathers from the dense one; anything else is read entry by entry.

Link copied to clipboard
inline fun VectorLike.forEachStored(block: (i: Int, v: Double) -> Unit)

Visit each stored entry of this as (index, value), in ascending index order for any storage. For DenseVector that's every index in 0 until size; for SparseVector that's the entries present in the parallel index/value arrays (which may include numerical zeros); for any other VectorLike it is every index, read through VectorLike.get.

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

Read entry at i. O(1) for DenseVector, O(log nnz) for SparseVector, which binary-searches its ascending indices. Use the 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.