koblas

sparse

Sparse linear algebra over the CSC com.eignex.koblas.SparseMatrix, behind three swappable seams that mirror the dense ones.

  • SparseVectorKernels — the sparse level-1 tier: a sparse vector against a dense one (usdot, usaxpy in Sparse BLAS terms) or against another sparse one, plus scatter and the reductions. Unlike the dense VectorKernels there is no length threshold, because the fallback here is an object rather than a compiled-in primitive and there is no compile-time kernel to protect.

  • SparseBlas — the sparse matrix routines. gemv in both directions, walking columns, which is what CSC stores. Deliberately thin: a sparse gemm fills in and is a different algorithm with a different result type, so it lands here when something needs it.

  • SparseLapack — the factorizations. SparseLapack.factor returns SparseFactorization, never null: a singular matrix yields a factorization reporting singular, matching the dense contract.

  • SparseLinearAlgebra pairs the two matrix seams. All three are offered through registerSparseBlas / com.eignex.koblas.registerBackend and forced with com.eignex.koblas.installBackends, resolving as com.eignex.koblas.koblas and its sparseVectorKernels.

  • Implementation: SparseLu, a Markowitz threshold-pivoting P·B·Q = L·U that keeps the factors sparse instead of filling toward O(m²).

SparseFactorization is an interface rather than a class, which is the one place this deviates from the dense shape. LAPACK's packed formats are a standard, so a dense com.eignex.koblas.dense.LuDecomposition travels between backends; no sparse solver describes its factors — UMFPACK hands back a void *, KLU and CHOLMOD their own structs — so a seam demanding a concrete type could never admit one.

The containers themselves live in the parent package, alongside the dense ones, because the sealed view roots require their subtypes in one package.

Types

Link copied to clipboard

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

Link copied to clipboard

What SparseLapack.factor returns when no numerically acceptable pivot remains.

Link copied to clipboard
interface SparseBlas : Backend

The sparse matrix routines, the seam a host sparse BLAS plugs into.

Link copied to clipboard

A factored sparse matrix you can solve against, whoever produced it.

Link copied to clipboard
interface SparseLapack : Backend

The sparse factorizations, the seam a host sparse solver plugs into.

Link copied to clipboard

Both sparse matrix seams at once, the counterpart of com.eignex.koblas.dense.LinearAlgebra.

Link copied to clipboard

Sparse LU factorization P·B·Q = L·U of an m × m matrix, with Markowitz threshold pivoting: at each step the pivot (near-)minimises fill (the Markowitz count (rowNnz−1)·(colNnz−1) over the active submatrix, searched over a bounded set of lowest-count candidate columns à la Suhl & Suhl) among entries that are numerically acceptable (|a| ≥ τ·max|column|), so the factors stay sparse instead of filling toward O(m²). Both a row permutation P and a column permutation Q are produced; only the nonzeros of L/U are stored, so memory is O(nnz).

Link copied to clipboard

The sparse level-1 kernels: a sparse vector against a dense one, or against another sparse one.

Properties

Link copied to clipboard
const val NO_DROP: Double = 0.0

The default SparseLapack.factor drop tolerance: keep every entry the elimination produces.

Functions

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

this · x, or thisᵀ · x when transpose, with the active backend (koblas).

Link copied to clipboard
fun SparseMatrix.lu(equilibrate: Boolean = false, dropTolerance: Double = NO_DROP): SparseFactorization

Factorize this sparse matrix with the active backend (koblas) — the sparse counterpart of DenseMatrix.lu(), carrying the same name for the same operation on the other storage.

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

Solve op(T) · x = b in place against this matrix's lower or upper triangle, with the active backend (koblas) — the sparse counterpart of the dense trsv free function. See SparseBlas.trsv.