koblas

F64Context

class F64Context(val kernels: F64Kernels, val blas: F64Blas, val decompositions: F64Decompositions, val sparseKernels: F64SparseKernels, val sparseBlas: F64SparseBlas, val sparseLu: F64SparseLu) : F64LinearAlgebra, F64Blas, F64Decompositions, F64SparseLinearAlgebra, F64SparseBlas, F64SparseLu(source)

Every backend koblas will use for a piece of work, in one object you can hold. Immutable, and itself a F64LinearAlgebra and a F64SparseLinearAlgebra by delegation.

Constructors

F64Context

constructor(kernels: F64Kernels, blas: F64Blas, decompositions: F64Decompositions, sparseKernels: F64SparseKernels, sparseBlas: F64SparseBlas, sparseLu: F64SparseLu)(source)

Properties

blas

decompositions

isAvailable

open override val isAvailable: Boolean(source)

True when every half can run, which a context assembled from resolved backends always can.

isPortable

open override val isPortable: Boolean(source)

True when every half is koblas's own, so the context calls out to nothing.

kernels

open override val kernels: F64Kernels(source)

name

open override val name: String(source)

The distinct names of the backends that do the matrix work, joined, such as "openblas+reference". The vector-kernel halves are left out; koblasInfo prints both parts.

priority

open override val priority: Int(source)

The strongest half's priority, so a context is at least as preferred as the best thing in it.

sparseBlas

sparseKernels

sparseLu

Link copied to clipboard

The slots still running koblas's own portable implementation, in declaration order.

Link copied to clipboard
open override val supportsBasisUpdates: Boolean

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

toString

open override fun toString(): String(source)

with

fun with(kernels: F64Kernels = this.kernels, blas: F64Blas = this.blas, decompositions: F64Decompositions = this.decompositions, sparseKernels: F64SparseKernels = this.sparseKernels, sparseBlas: F64SparseBlas = this.sparseBlas, sparseLu: F64SparseLu = this.sparseLu): F64Context(source)

A copy with the named halves replaced and the rest kept. A replaced kernels reaches the inherited routines of halves that follow the installed context, which requires installBackends; a half built around kernels of its own always keeps them.

Link copied to clipboard
open override fun applyQ(qr: F64QrDecomposition, y: DoubleArray, transpose: Boolean = false): DoubleArray

Apply Q, or Qᵀ when transpose, from qr to a length-m y, into a fresh result (LAPACK dormqr restricted to a single column).

Link copied to clipboard
open override fun applyQInto(qr: F64QrDecomposition, y: DoubleArray, out: DoubleArray, transpose: Boolean = false): DoubleArray

Apply Q, or Qᵀ when transpose, from qr to y into out, which is returned. out may be y.

Link copied to clipboard

The backend installed in slot.

Link copied to clipboard
open override fun cholesky(a: F64DenseMatrix, policy: CholeskyPolicy = CholeskyPolicy.Strict): F64CholeskyDecomposition

Cholesky factorization A = L·Lᵀ of a symmetric positive-definite a (dpotrf with uplo = 'L'). Reads only the lower triangle of a, so an upper-only matrix factors to silent nonsense.

Link copied to clipboard

LU factorization with partial pivoting of a square a (LAPACK dgetrf). a is not modified.

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

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.

Link copied to clipboard

Factor a simplex basis for column replacements.

Link copied to clipboard

Refactorize a into out's existing buffers, returning out. out must have a's dimension and its previous contents are discarded.

Link copied to clipboard

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

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

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.

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

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

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

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: F64SparseMatrix, x: DoubleArray, transpose: Boolean = false): DoubleArray

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

open override fun gemv(alpha: Double, a: F64SparseMatrix, 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: F64DenseMatrix)

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

Link copied to clipboard
open override fun invert(chol: F64CholeskyDecomposition, workspace: Workspace? = null): F64DenseMatrix

Invert an SPD matrix from its Cholesky factorization, returning A⁻¹ given chol (LAPACK dpotri).

open override fun invert(lu: F64LuDecomposition, workspace: Workspace? = null): F64DenseMatrix

Invert a general matrix from its LU factorization, returning A⁻¹ given P·A = L·U (LAPACK dgetri). Prefer solve to apply A⁻¹, which costs less and is more accurate.

Link copied to clipboard

Whether slot is filled by something other than koblas's own portable implementation.

Link copied to clipboard
open override fun ldl(a: F64DenseMatrix, workspace: Workspace? = null): F64LdlDecomposition

Symmetric indefinite factorization A = L·D·Lᵀ with Bunch-Kaufman pivoting (LAPACK dsytrf, lower). Reads only the lower triangle of a, so an upper-only matrix factors to silent nonsense.

Link copied to clipboard
open override fun qr(a: F64DenseMatrix, workspace: Workspace? = null): F64QrDecomposition

QR factorization A = Q·R of an m×n a via Householder reflections (LAPACK dgeqrf). a is not modified, any shape is accepted, and rank deficiency is not detected.

Link copied to clipboard
open override fun qrPivoted(a: F64DenseMatrix, tolerance: Double = AUTOMATIC_RANK_TOLERANCE, workspace: Workspace? = null): F64PivotedQrDecomposition

QR with column pivoting, A·P = Q·R (LAPACK dgeqp3), reporting F64PivotedQrDecomposition.rank as the count of leading diagonal entries with |R_kk| > tolerance · |R₀₀|. tolerance is a fraction of |R₀₀|; AUTOMATIC_RANK_TOLERANCE derives one from the shape, max(m, n) · ε, and a negative value is rejected.

Link copied to clipboard
open override fun rcond(lu: F64LuDecomposition, anorm: Double, workspace: Workspace? = null): Double

Order-of-magnitude estimate of 1 / (anorm · est(‖A⁻¹‖₁)) (LAPACK dgecon), where anorm is the 1-norm of the unfactored matrix (see norm1). Returns 1.0 when n == 0 and 0.0 when singular.

Link copied to clipboard
open override 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

Throws unless every one of slots is filled by an accelerated backend.

Link copied to clipboard

Solve A · x = b for the Cholesky factorization chol (LAPACK dpotrs). b is not modified.

Solve A · X = B for all right-hand-side columns of b at once against a symmetric indefinite factorization (LAPACK dsytrs with nrhs).

open override fun solve(ldl: F64LdlDecomposition, b: DoubleArray): DoubleArray

Solve A · x = b for a symmetric indefinite factorization ldl (LAPACK dsytrs).

open override fun solve(lu: F64LuDecomposition, b: F64DenseMatrix, transpose: Boolean = false): F64DenseMatrix

Solve A · X = B, or Aᵀ · X = B when transpose, for all right-hand-side columns of b at once (LAPACK dgetrs with nrhs).

open override fun solve(lu: F64LuDecomposition, b: DoubleArray, transpose: Boolean = false): DoubleArray

Solve A · x = b, or Aᵀ · x = b when transpose, for the factorization lu (LAPACK dgetrs).

open override fun solve(qr: F64PivotedQrDecomposition, b: DoubleArray, workspace: Workspace? = null): DoubleArray

Least-squares solve from a pivoted factorization, with the column permutation undone. A rank-deficient factorization returns the basic solution, not the minimum-norm one: zero outside the pivoted rank.

open override fun solve(qr: F64QrDecomposition, b: DoubleArray, minimumNorm: Boolean = false, workspace: Workspace? = null): DoubleArray

Solve from a QR factorization. By default, finds the least-squares solution min ‖A·x − b‖₂ for a tall or square A; it requires full column rank and returns R⁻¹·(Qᵀb). With minimumNorm, finds the minimum-norm solution of a consistent wide system from qr(Aᵀ); it requires full row rank.

open override fun solve(f: F64SparseFactorization, b: DoubleArray, transpose: Boolean = false): DoubleArray

solveInto into a fresh vector.

Link copied to clipboard

Solve A · x = b into out, which is returned. out may be b.

open override fun solveInto(ldl: F64LdlDecomposition, b: F64DenseMatrix, out: F64DenseMatrix, workspace: Workspace? = null): F64DenseMatrix

Solve A · X = B into out, which is returned. out may be b.

open override fun solveInto(qr: F64PivotedQrDecomposition, b: DoubleArray, out: DoubleArray, workspace: Workspace? = null): DoubleArray

solve into out, which is returned.

open override fun solveInto(lu: F64LuDecomposition, b: F64DenseMatrix, out: F64DenseMatrix, transpose: Boolean = false, workspace: Workspace? = null): F64DenseMatrix

Solve A · X = B, or Aᵀ · X = B when transpose, into out, which is returned. out may be b, and a workspace lends the transposed direction's n·nrhs staging block.

open override fun solveInto(lu: F64LuDecomposition, b: DoubleArray, out: DoubleArray, transpose: Boolean = false, workspace: Workspace? = null): DoubleArray

Solve A · x = b, or Aᵀ · x = b when transpose, into out, which is returned. out may be b, and a workspace lends the transposed direction's staging buffer.

open override fun solveInto(qr: F64QrDecomposition, b: DoubleArray, out: DoubleArray, minimumNorm: Boolean = false, workspace: Workspace? = null): DoubleArray

solve into out, which is returned. Its length is n by default and m with minimumNorm. A workspace lends the intermediate for applying Q or Qᵀ.

open override 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.

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

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.

Link copied to clipboard
open override fun symv(alpha: Double, a: F64DenseMatrix, 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.

Link copied to clipboard
open override fun syr(alpha: Double, x: F64VectorLike, a: F64DenseMatrix, uplo: Uplo = Uplo.FULL)

A += alpha · x · xᵀ (BLAS dsyr), writing the triangles uplo selects. syrk is the rank-k form.

Link copied to clipboard
open override fun syr2(alpha: Double, x: F64VectorLike, y: F64VectorLike, a: F64DenseMatrix, uplo: Uplo = Uplo.FULL)

A += alpha · (x · yᵀ + y · xᵀ) (BLAS dsyr2), writing the triangles uplo selects.

Link copied to clipboard
open override fun syr2k(alpha: Double, a: F64DenseMatrix, b: F64DenseMatrix, transpose: Boolean, beta: Double, c: F64DenseMatrix, uplo: Uplo = Uplo.FULL, workspace: Workspace? = null)

C = alpha · (op(A) · op(B)ᵀ + op(B) · op(A)ᵀ) + beta · C (BLAS dsyr2k), where op transposes when transpose. Writes the triangles uplo selects.

Link copied to clipboard
open override fun syrk(alpha: Double, a: F64DenseMatrix, transpose: Boolean, beta: Double, c: F64DenseMatrix, uplo: Uplo = Uplo.FULL, workspace: Workspace? = null)

C = alpha · A·Aᵀ + beta · C, or alpha · Aᵀ·A + beta · C when transpose (BLAS dsyrk). Uplo.FULL writes both triangles, unlike standard dsyrk; beta == 0.0 overwrites without reading.

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

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

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

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

Link copied to clipboard
open override fun trsm(a: F64DenseMatrix, b: F64DenseMatrix, 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 dtrsm). Flags follow trsv; the right-hand sides are the columns of b from the left and its rows from the right.

Link copied to clipboard
open override fun trsv(a: F64DenseMatrix, 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: F64SparseMatrix, 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.F64Blas.trsv does.

Link copied to clipboard
open override fun trtri(a: F64DenseMatrix, lower: Boolean, unitDiag: Boolean = false): F64DenseMatrix

Invert a triangular matrix into a fresh result (LAPACK dtrtri), returning T⁻¹ for the lower or upper triangle of the square a, taking the diagonal as 1 when unitDiag.