koblas

VectorStorage

@Serializable
sealed interface VectorStorage : Vector(source)

The vector storages koblas itself defines, DenseVector and SparseVector.

Inheritors

Properties

Link copied to clipboard
abstract val size: Int

Number of entries, counting the unstored zeros of a sparse vector.

Functions

Link copied to clipboard

Sum of absolute values (BLAS dasum). Sparse vectors sum over stored entries only.

Link copied to clipboard

Sum of the entries with Neumaier's compensation, holding to within one rounding of the exact sum whatever the length or the ordering.

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

aT * b. Sparse operands walk their stored entries only.

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

Visit each stored entry as (index, value), in ascending index order for any storage. A SparseVector may present numerical zeros as stored, and any other Vector has every index visited.

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

The entry at index (i). Throws IndexOutOfBoundsException outside 0 until size, whatever the storage.

Link copied to clipboard

Zero-based logical index of the first maximum absolute value (BLAS idamax), or -1 when empty. Dense vectors use DenseVectorKernels.iamax; sparse vectors visit only their stored entries. NaNs are ignored by the strict comparison; a later finite or infinite magnitude can therefore win after a leading NaN. All-zero and all-NaN nonempty inputs return 0, as do sparse inputs whose maximum is an implicit zero. Strided views report their logical index rather than a backing-array offset.

Link copied to clipboard

Euclidean norm (BLAS dnrm2). Rescales when the sum of squares would overflow or underflow, so any finite input gives the correct norm.

Link copied to clipboard

Plain sum of the entries. Distinct from asum, which sums their absolute values.

Link copied to clipboard
abstract fun toDoubleArray(): DoubleArray

Materialise into a fresh dense DoubleArray, independent of the internal storage.