koblas

ReferenceSparseLinearAlgebra

The portable sparse backend: every routine in Kotlin, no host dependency, and the semantic reference a host backend is validated against.

Every operation is an interface default, so this object overrides nothing — the algorithms live on the seams where a backend can replace them one at a time.

Properties

name

open override val name: String(source)

A short backend identifier for diagnostics (e.g. "reference").

Link copied to clipboard
open val priority: Int

Relative preference among simultaneously available backends: automatic selection through registerBackend — JVM classpath discovery, native startup registration — picks the highest per half. The portable reference is 0; native-accelerated backends rank above it (koblas-openblas 100, koblas-cblas 90).

Functions

Link copied to clipboard
open fun asum(x: SparseVector): Double

Sum |x_i| over the stored entries.

Link copied to clipboard
open fun axpy(y: DoubleArray, alpha: Double, x: SparseVector)

y += alpha·x for a sparse x into a dense y (Sparse BLAS usaxpy); touches only x's positions, which is the reason to pass a sparse operand at all.

Link copied to clipboard

xᵀ·y for two sparse vectors, merging their index lists in one pass — O(nnz_x + nnz_y).

xᵀ·y for a sparse x against a dense y (Sparse BLAS usdot); walks only the stored entries.

Link copied to clipboard
open fun factor(a: SparseMatrix, equilibrate: Boolean = false, dropTolerance: Double = NO_DROP): SparseFactorization

Factorize the square a into something solvable, never null.

Link copied to clipboard
open fun gemv(a: SparseMatrix, x: DoubleArray, transpose: Boolean = false): DoubleArray

A · x, or Aᵀ · x when transpose, into a fresh result — the restricted gemv with alpha = 1, beta = 0.

open fun gemv(alpha: Double, a: SparseMatrix, x: DoubleArray, beta: Double, y: DoubleArray, transpose: Boolean = false)

In-place y = alpha · op(A) · x + beta · y, where op(A) is Aᵀ when transpose — the sparse dgemv. Per BLAS convention beta == 0.0 overwrites y without reading it, so it may arrive uninitialized, and alpha == 0.0 reduces to the beta scale.

Link copied to clipboard
open fun nrm2(x: SparseVector): Double

Euclidean norm over the stored entries.

Link copied to clipboard
open fun scatter(x: SparseVector, out: DoubleArray)

Write x's stored entries into out at their positions, leaving the rest of out alone (Sparse BLAS ussc). Zero-fill out first for a plain densification.

Link copied to clipboard
open fun trsv(a: SparseMatrix, x: DoubleArray, lower: Boolean, transpose: Boolean = false)

Solve op(T) · x = b in place, where T is the lower or upper triangle of the square a and op transposes when transpose — the sparse dtrsv. x holds the right-hand side on entry and the solution on return.