koblas

ContiguousVector

@Serializable
@SerialName(value = "ContiguousVector")
class ContiguousVector : VectorStorage, DenseVector(source)

A dense vector that owns its whole buffer, so its entries are exactly values, in order and complete.

Properties

offset

open override val offset: Int(source)

First physical entry of this vector within values.

size

open override val size: Int(source)

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

stride

open override val stride: Int(source)

Physical distance between adjacent entries, which may be negative but is never zero.

values

open override val values: DoubleArray(source)

Functions

equals

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

get

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

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

hashCode

open override fun hashCode(): Int(source)

set

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

Writes (v) at index (i).

toDoubleArray

open override fun toDoubleArray(): DoubleArray(source)

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

toString

open override fun toString(): String(source)
Link copied to clipboard

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

Link copied to clipboard

A borrowed view over this whole vector, keeping whatever origin and spacing it already has.

Link copied to clipboard
fun DenseVector.axpy(alpha: Double, x: Vector)

y = y + alpha * x. A sparse x touches only the positions it stores. A dense x with an identical mapping is read directly; other dense overlaps, or sparse values sharing the destination buffer, are snapshotted before writing. Custom Vector implementations are also snapshotted, since their backing storage is opaque.

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

Zero-based logical index of the maximum absolute value (BLAS idamax), or -1 when empty. Dense vectors use DenseVectorKernels.iamax; sparse vectors visit only their stored entries. All-zero 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
@JvmName(name = "subtract")
operator fun DenseVector.minus(other: DenseVector): DenseVector

a - b, allocating. axpy with alpha = -1.0 accumulates into an existing operand.

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

Whether these vectors address at least one common buffer entry.

Link copied to clipboard
@JvmName(name = "add")
operator fun DenseVector.plus(other: DenseVector): DenseVector

a + b, allocating. axpy accumulates into an existing operand.

Link copied to clipboard

v = alpha * v.

Link copied to clipboard

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

Link copied to clipboard
@JvmName(name = "multiply")
operator fun DenseVector.times(alpha: Double): DenseVector

alpha * x, allocating. scale multiplies in place.

Link copied to clipboard
@JvmName(name = "negate")
operator fun DenseVector.unaryMinus(): DenseVector

-x, allocating.

Link copied to clipboard
fun DenseVector.view(offset: Int, size: Int, stride: Int = 1): StridedVector

A borrowed strided slice, addressed in this vector's logical indices rather than its buffer's positions.