koblas

KoblasEngine

An immutable dense and sparse BLAS engine.

The default koblas instance is selected once for the platform. Tests and benchmarks can construct an exact scalar, C, or SIMD composition from BuiltinEngines without changing process-global state. Each composition binds its dense vector, dense panel, packed tile, indexed sparse, and sparse panel kernels once.

Properties

name

Short read-only implementation description for logs and benchmark attribution.

nativeVariant

Ordinary C variant bound to native components; policy calls may retain in-runtime arithmetic.

packedKernels

Packed layout shape and tile arithmetic kernels.

packedPanels

Packed panel operations bound to this engine's exact packed kernels.

panelKernels

Dense matrix-panel arithmetic kernels.

sparseKernels

Sparse-vector kernels used by sparse convenience operations.

tuningDiagnostics

Malformed performance overrides retained as read-only diagnostic messages.

vectorKernels

Standalone contiguous dense-vector kernels.

Functions

explain

fun explain(operation: DenseOperation, length: Int): String(source)

Describes the selected implementation without performing arithmetic. length is the vector/panel length, product-tile depth, or standalone solve order. Semantic no-work exits still precede execution. Native IDs and layouts identify the selected component. Runtime descriptions identify scalar stages and potential data-dependent or stride fallbacks; inspecting length does not inspect operand values.

toString

open override fun toString(): String(source)
Link copied to clipboard
open override fun addScaled(alpha: Double, a: SparseMatrix, transposeA: Boolean, b: SparseMatrix): SparseMatrix

Fresh CSC alpha · op(A) + B. The structural union is retained, including explicit zeros, cancellations, and A-only positions when alpha is zero. Zero alpha does not read A's values; B values are copied. Output rows are strictly ascending and all arrays are independently owned.

Link copied to clipboard
open override fun gemm(a: DenseMatrix, b: DenseMatrix): DenseMatrix

gemm with alpha = 1, beta = 0, into a fresh matrix. A.cols must equal B.rows.

gemm over borrowed panels into a fresh owned matrix.

open override fun gemm(alpha: Double, a: StridedMatrixView, transposeA: Boolean, b: StridedMatrixView, transposeB: Boolean, beta: Double, c: StridedMatrixView)

gemm over borrowed column-major panels. c must not overlap either input; disjoint panels may share a backing buffer. Implementations must preserve each physical leading dimension without copying.

open override fun gemm(alpha: Double, a: DenseMatrix, transposeA: Boolean, b: DenseMatrix, transposeB: Boolean, beta: Double, c: DenseMatrix, workspace: Workspace? = null)

C = alpha · op(A) · op(B) + beta · C (BLAS dgemm), with shapes op(A): m×k, op(B): k×n, C: m×n. beta == 0.0 overwrites c without reading it. workspace reuses any needed transpose packing.

open override fun gemm(a: SparseMatrix, b: DenseMatrix): DenseMatrix

gemm with alpha = 1, beta = 0, into a fresh matrix. A.cols must equal B.rows.

open override fun gemm(a: SparseMatrix, b: SparseMatrix): SparseMatrix

C = A · B for two sparse operands, into a fresh matrix.

open override fun gemm(alpha: Double, a: SparseMatrix, transposeA: Boolean, b: SparseMatrix, transposeB: Boolean): SparseMatrix

Fresh CSC alpha · op(A) · op(B). Product support is discovered from stored positions, including explicit zeros, retained cancellations, and underflowed values; rows are sorted within every column and all result arrays are owned. When alpha == 0.0, the same structure is discovered without reading operand values and filled with alpha's signed zero.

open override fun gemm(alpha: Double, a: SparseMatrix, transposeA: Boolean, b: SparseMatrix, transposeB: Boolean, beta: Double, c: DenseMatrix, workspace: Workspace? = null)

Direct dense-destination C = alpha · op(A) · op(B) + beta · C for two sparse operands. No sparse intermediate is created and implicit sparse zeros are not evaluated. alpha == 0.0 reads neither sparse operand's values; beta == 0.0 does not read c. Sparse value buffers shared with c are staged using workspace.

open override fun gemm(alpha: Double, a: SparseMatrix, transposeA: Boolean, b: DenseMatrix, transposeB: Boolean, beta: Double, c: DenseMatrix, right: Boolean = false, workspace: Workspace? = null)

C = alpha · op(A) · op(B) + beta · C (Sparse BLAS usmm) for a sparse a against a dense b and c, or C = alpha · op(B) · op(A) + beta · C when right. beta == 0.0 overwrites c without reading it, as gemv does.

Link copied to clipboard
open override fun gemmt(alpha: Double, a: DenseMatrix, transposeA: Boolean, b: DenseMatrix, transposeB: Boolean, beta: Double, c: DenseMatrix, lower: Boolean = true, workspace: Workspace? = null)

C = alpha · op(A) · op(B) + beta · C in only the selected triangle (Netlib GEMMTR, commonly exposed as gemmt). op(A) is n×k, op(B) is k×n, and c is n×n. The opposite triangle is neither read nor written. alpha == 0.0 does not read either input and beta == 0.0 does not read selected destination entries. If c shares either input buffer, workspace supplies reusable staging.

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

gemv with alpha = 1, beta = 0, into a fresh result.

open override fun gemv(a: StridedMatrixView, x: StridedVectorView, transpose: Boolean = false): DoubleArray

gemv over borrowed storage into a fresh owned array.

open override fun gemv(alpha: Double, a: StridedMatrixView, x: StridedVectorView, beta: Double, y: StridedVectorView, transpose: Boolean = false)

gemv over borrowed strided storage. The destination must not overlap a or x; disjoint views may share one backing buffer. Implementations may pass offsets, strides, and leading dimensions directly to BLAS and must not materialize a contiguous copy. Like BLAS dgemv, a zero row or column count returns without reading or changing y.

open override fun gemv(alpha: Double, a: DenseMatrix, x: DoubleArray, beta: Double, y: DoubleArray, transpose: Boolean = false, workspace: Workspace? = null)

y = alpha · op(A) · x + beta · y (BLAS dgemv), with op(A) being Aᵀ when transpose. beta == 0.0 overwrites y without reading it.

open override fun gemv(a: SparseMatrix, x: DoubleArray, transpose: Boolean = false): DoubleArray

A · x, or Aᵀ · x when transpose, into a fresh result.

open override 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. Per BLAS convention beta == 0.0 overwrites y without reading it, so it may arrive uninitialized.

Link copied to clipboard
open override fun ger(alpha: Double, x: DoubleArray, y: DoubleArray, a: DenseMatrix)

A = A + alpha · x · yᵀ (BLAS dger), the dense form a backend can dispatch. The free ger accepts VectorStorage operands and takes a sparse fast path.

Link copied to clipboard

Copies a into an immutable snapshot for repeated products.

Link copied to clipboard
open override fun symm(alpha: Double, a: DenseMatrix, b: DenseMatrix, beta: Double, c: DenseMatrix, lower: Boolean = true, right: Boolean = false, workspace: Workspace? = null)

C = alpha · A · B + beta · C, or C = alpha · B · A + beta · C when right (BLAS dsymm). Only the lower triangle of a is read; beta == 0.0 overwrites c without reading it. workspace reuses the packed operand panels and edge tile.

open override fun symm(alpha: Double, a: SparseMatrix, b: DenseMatrix, beta: Double, c: DenseMatrix, lower: Boolean = true, right: Boolean = false, workspace: Workspace? = null)

C = alpha · A · B + beta · C, or C = alpha · B · A + beta · C when right, interpreting square sparse a as symmetric from exactly its selected lower or upper triangle. alpha == 0.0 reads neither input; beta == 0.0 does not read c. Shared input/destination buffers are staged, with workspace reused when supplied.

Link copied to clipboard
open override fun symv(alpha: Double, a: DenseMatrix, x: DoubleArray, beta: Double, y: DoubleArray, lower: Boolean = true)

y = alpha · A · x + beta · y for a symmetric a (BLAS dsymv). Only the lower triangle is read, diagonal included; beta == 0.0 overwrites y without reading it.

open override fun symv(alpha: Double, a: SparseMatrix, x: DoubleArray, beta: Double, y: DoubleArray, lower: Boolean = true)

y = alpha · A · x + beta · y for a square sparse a interpreted as symmetric. Exactly the selected lower or upper stored triangle is read; the other triangle and implicit zeros are ignored. A stored off-diagonal entry contributes to both mirrored positions. alpha == 0.0 reads neither a nor x, and beta == 0.0 overwrites y without reading it. Aliasing x with y, or a's values with y, is supported through internal staging.

Link copied to clipboard
open override fun syr(alpha: Double, x: Vector, a: DenseMatrix, lower: Boolean = true)

A += alpha · x · xᵀ (BLAS dsyr), writing only the lower or upper triangle.

Link copied to clipboard
open override fun syr2(alpha: Double, x: Vector, y: Vector, a: DenseMatrix, lower: Boolean = true)

A += alpha · (x · yᵀ + y · xᵀ) (BLAS dsyr2), writing only the lower or upper triangle.

Link copied to clipboard
open override fun syr2k(alpha: Double, a: DenseMatrix, b: DenseMatrix, transpose: Boolean, beta: Double, c: DenseMatrix, lower: Boolean = true, workspace: Workspace? = null)

C = alpha · (op(A) · op(B)ᵀ + op(B) · op(A)ᵀ) + beta · C (BLAS dsyr2k), where op transposes when transpose. Writes only the lower or upper triangle; beta == 0.0 overwrites it without reading.

Link copied to clipboard
open override fun syrk(alpha: Double, a: DenseMatrix, transpose: Boolean, beta: Double, c: DenseMatrix, lower: Boolean = true, workspace: Workspace? = null)

C = alpha · A·Aᵀ + beta · C, or alpha · Aᵀ·A + beta · C when transpose (BLAS dsyrk). Only the lower or upper triangle is written; beta == 0.0 overwrites it without reading.

open override fun syrk(a: SparseMatrix, transpose: Boolean = false, lower: Boolean = true): SparseMatrix

Fresh CSC selected triangle of op(A) · op(A)ᵀ. Stored-product support and cancellations are retained, rows are sorted, and result arrays are owned. The opposite triangle is absent rather than implicitly mirrored; consume the result with symv or symm when symmetric meaning is intended.

open override fun syrk(alpha: Double, a: SparseMatrix, transpose: Boolean, beta: Double, c: DenseMatrix, lower: Boolean = true, workspace: Workspace? = null)

Dense selected-triangle C = alpha · op(A) · op(A)ᵀ + beta · C. Only the selected lower or upper triangle of c is read or written, and products involving implicit sparse zeros are not evaluated.

Link copied to clipboard
open override fun transpose(a: DenseMatrix): DenseMatrix

Fresh transposed a. For a product prefer the transpose flags on gemv and gemm, which avoid a caller-visible intermediate; this is for a caller that means to hold the transpose.

open override fun transpose(a: SparseMatrix): SparseMatrix

Fresh transposed a, still CSC, which makes this the CSC-to-CSR conversion as well. Explicitly stored zeros survive, since the transpose is structural rather than arithmetic.

Link copied to clipboard
open override fun trmm(a: DenseMatrix, b: DenseMatrix, lower: Boolean, transpose: Boolean = false, unitDiag: Boolean = false, right: Boolean = false, alpha: Double = 1.0, workspace: Workspace? = null)

B = alpha · op(T) · B, or B = alpha · B · op(T) when right (BLAS dtrmm), the counterpart of trsm. workspace reuses portable staging.

open override fun trmm(a: SparseMatrix, b: DenseMatrix, lower: Boolean, transpose: Boolean = false, unitDiag: Boolean = false, right: Boolean = false, alpha: Double = 1.0)

B = alpha · op(T) · B in place, or B = alpha · B · op(T) when right (BLAS dtrmm). The triangle flags follow trmv. This is multiplication rather than a solve, so zero or missing diagonal entries participate normally and are never treated as singular. The destination may share a's value buffer.

Link copied to clipboard
open override fun trmv(a: DenseMatrix, x: DoubleArray, lower: Boolean, transpose: Boolean = false, unitDiag: Boolean = false)

x = op(T) · x in place (BLAS dtrmv), the product counterpart of trsv.

open override fun trmv(a: SparseMatrix, x: DoubleArray, lower: Boolean, transpose: Boolean = false, unitDiag: Boolean = false)

Multiply x = op(T) · x in place (BLAS dtrmv), where op transposes when transpose. Only the lower or upper triangle is read; unitDiag treats its diagonal as one without reading it.

Link copied to clipboard
open override fun trsm(a: DenseMatrix, b: DenseMatrix, lower: Boolean, transpose: Boolean = false, unitDiag: Boolean = false, right: Boolean = false, alpha: Double = 1.0, workspace: Workspace? = null)

B = alpha · op(T)⁻¹ · B in place, or B = alpha · B · op(T)⁻¹ when right (BLAS dtrsm). Flags follow trsv; the right-hand sides are the columns of b from the left and its rows from the right. workspace reuses portable staging.

open override fun trsm(a: SparseMatrix, b: DenseMatrix, lower: Boolean, transpose: Boolean = false, unitDiag: Boolean = false, right: Boolean = false, alpha: Double = 1.0, workspace: Workspace? = null)

B = alpha · op(T)⁻¹ · B in place, or B = alpha · B · op(T)⁻¹ when right (Sparse BLAS ussm). The triangle flags follow trsv; the right-hand sides are the columns of b from the left and its rows from the right. workspace reuses portable diagonal and RHS-panel staging. A missing diagonal entry behaves as zero, and singularity is not reported, as in dense dtrsm.

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

Solve op(T) · x = b in place (BLAS dtrsv) for the lower or upper triangle of the square a, op transposing when transpose and unitDiag taking the diagonal as 1. x carries b in and x out.

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

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.DenseBlas.trsv does.