koblas

DenseVector

@Serializable
@SerialName(value = "DenseVector")
class DenseVector : VectorView(source)

Dense double-precision vector backed by a flat DoubleArray. The default carrier when the caller already has a dense array or expects most entries to be populated.

Construction goes through the Companion factories: DenseVector.of (copy a DoubleArray) or DenseVector.zero (allocate a zero vector of given size). Unlike the read-only VectorView contract, the concrete vector exposes its data backing and elementwise set for in-place updates.

Constructors

DenseVector

constructor(size: Int)(source)

Types

Link copied to clipboard
object Companion

Factory entrypoints for DenseVector.

Properties

data

size

open override val size: Int(source)

Number of entries (including stored zeros for sparse).

Functions

equals

open operator override fun equals(other: Any?): Boolean(source)

get

open operator override fun get(i: Int): Double(source)

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.

hashCode

open override fun hashCode(): Int(source)

set

operator fun set(i: Int, v: Double)(source)

Set entry i.

toDoubleArray

open override fun toDoubleArray(): DoubleArray(source)

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.

toString

open override fun toString(): String(source)
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.