koblas

StridedVectorView

class StridedVectorView @JvmOverloads constructor(val data: DoubleArray, val offset: Int, val size: Int, val stride: Int = 1) : Vector(source)

A mutable live view of size entries in data, starting at offset and separated by stride. Negative stride is supported when both ends remain in the buffer. The view never copies data, so mutations through the view or any other reference to the array are visible to each other.

Constructors

StridedVectorView

constructor(data: DoubleArray, offset: Int, size: Int, stride: Int = 1)(source)

Properties

data

offset

size

open override val size: Int(source)

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

stride

Functions

get

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

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

set

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

Writes value at logical 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

this = this + alpha * x over a borrowed strided destination. Sparse inputs touch only stored positions; overlapping built-in inputs are snapshotted before writing.

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

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

Whether these vectors address at least one common buffer entry.

Link copied to clipboard

this = alpha * this over a borrowed strided slice.

Link copied to clipboard

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