koblas

F64ReferenceSparseLinearAlgebra

The portable sparse backend, available on every target. The sparse seams declare their routines and this implements them, so a binding that means to accelerate one cannot inherit the portable version by accident.

Properties

isPortable

open override val isPortable: Boolean(source)

Whether this is koblas's own implementation rather than a binding to a host library. The compiled-in SIMD kernels are portable however fast they are; only something calling out counts as accelerated.

name

open override val name: String(source)

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

Link copied to clipboard

Whether this backend can do work on this host. koblas's own implementations always can, so the default is true; a binding reports whether the library it calls resolved.

Link copied to clipboard
open val priority: Int

Relative preference among the backends offered for one half (F64Blas, F64Decompositions, F64Kernels or a sparse counterpart). registerBackend picks the highest; the portable reference is 0.

Link copied to clipboard

The sparse vector kernels used by operations around these matrix halves.

Link copied to clipboard

Whether factorBasis answers with a factorization that updates its factors in place. When false a replacement costs a factorization, so a caller pacing its own refactorizations has nothing left to pace.

Functions

asum

open override fun asum(x: F64SparseVector): Double(source)

Sum |x_i| over the stored entries.

axpy

open override fun axpy(y: DoubleArray, alpha: Double, x: F64SparseVector)(source)

y += alpha·x for a sparse x into a dense y (Sparse BLAS usaxpy), touching only x's stored positions.

dot

open override fun dot(x: F64SparseVector, y: DoubleArray): Double(source)

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


open override fun dot(x: F64SparseVector, y: F64SparseVector): Double(source)

xᵀ·y for two sparse vectors, merging their index lists in one pass. Relies on both operands being strictly ascending, which F64SparseVector validates.

factor

open override fun factor(a: F64SparseMatrix, equilibrate: Boolean = false, dropTolerance: Double = NO_DROP): F64SparseFactorization(source)

Factorize the square a into something solvable. A singular matrix comes back as a factorization reporting singular rather than as an exception, with a failedAt counting elimination steps rather than naming a column: the step that fails is the one with no acceptable pivot left, so there is no column of a to attribute it to.

Parameters

a

the square matrix to factorize.

equilibrate

scale rows by a power of two first; the solves undo it.

dropTolerance

discard produced entries this far below the largest magnitude, giving an incomplete factorization.

gemv

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

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

nrm2

open override fun nrm2(x: F64SparseVector): Double(source)

Euclidean norm over the stored entries, rescaled as the dense euclideanNorm is.

scatter

open override fun scatter(x: F64SparseVector, out: DoubleArray)(source)

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.

trsv

open override fun trsv(a: F64SparseMatrix, x: DoubleArray, lower: Boolean, transpose: Boolean = false, unitDiag: Boolean = false)(source)

Solve op(T) · x = b in place, op transposing when transpose. x holds the right-hand side on entry and the solution on return. Only the lower or upper triangle of a is read, and unitDiag takes the diagonal as 1 without reading it, as the dense com.eignex.koblas.dense.F64Blas.trsv does.

Unlike the dense half, which follows dtrsv in reporting nothing and answering a singular triangle with infinities, this reports it. There is no sparse BLAS routine whose silence it has to match, and the value is looked up to divide by it anyway, so a healthy solve pays nothing; only the failing column pays the extra scan that tells a stored zero from a missing entry.

Throws

if a diagonal entry is missing or zero and unitDiag is false, naming its position.

Link copied to clipboard

Factor a simplex basis for column replacements.

Link copied to clipboard
open fun refactor(previous: F64SparseFactorization, a: F64SparseMatrix, equilibrate: Boolean = false, dropTolerance: Double = NO_DROP): F64SparseFactorization

Factor a, reusing compatible state from previous when this backend can. The returned factorization supersedes previous, which must not be solved after this call. Backends that cannot reuse it answer as factor would.

Link copied to clipboard
open fun solve(f: F64SparseFactorization, b: DoubleArray, transpose: Boolean = false): DoubleArray

solveInto into a fresh vector.

Link copied to clipboard
open fun solveInto(f: F64SparseFactorization, b: DoubleArray, out: DoubleArray, transpose: Boolean = false, workspace: Workspace? = null): DoubleArray

Solve A·x = b from f into out, Aᵀ·x = b when transpose. The work belongs to the factorization; this is here so the seam reads the same from the sparse side as com.eignex.koblas .dense.F64Decompositions.solveInto does from the dense one.