koblas

DenseMatrix

@Serializable
@SerialName(value = "DenseMatrix")
class DenseMatrix : MatrixView(source)

Dense column-major matrix backed by a single contiguous DoubleArray of length rows * cols. Element (i, j) lives at data[i + j * rows], so each column is a contiguous run of rows doubles.

Column-major is the layout LAPACK and Fortran define, so a host library reads this backing directly: no row-major wrappers, no transposition into a temporary, and lda is simply rows. It also matches what the algorithms want. A triangular solve, an eta update and a Householder reflector are all column operations, and SparseMatrix is already CSC, so the dense and sparse sides of the library now agree on which axis is contiguous.

Flat layout buys three properties: one heap allocation rather than cols separate column arrays; cache-friendly sweeps across column boundaries; the SIMD primitives in the internal Primitives.kt can stream long runs without re-fetching column references on each iteration.

Serializes as its shape plus the flat backing — {"rows":2,"cols":2,"data":[…]} — which is both the compact form and the extensible one. It used to encode as a nested Array<DoubleArray> of rows, chosen for readability; that cost a bracket pair per row and, more importantly, could not carry a polymorphic type discriminator, so a DenseMatrix could not decode through MatrixView while a SparseMatrix could. A named-field object fixes both and leaves room to add fields later without breaking readers.

Unlike the read-only MatrixView contract, the concrete matrix exposes its flat data backing and elementwise set so in-place algorithms (factorizations, updates) can work without reallocating.

Constructors

DenseMatrix

constructor(rows: Int, cols: Int = rows)(source)

Types

Link copied to clipboard
object Companion

Factory entrypoints for DenseMatrix.

Properties

cols

open override val cols: Int(source)

data

rows

open override val rows: Int(source)

Functions

equals

open operator override fun equals(other: Any?): Boolean(source)

get

open operator override fun get(i: Int, j: Int): Double(source)

Read entry at row i, column j.

hashCode

open override fun hashCode(): Int(source)

set

operator fun set(i: Int, j: Int, v: Double)(source)

Set entry (i, j).

toArray

open override fun toArray(): Array<DoubleArray>(source)

Materialise into a fresh Array<DoubleArray> of rows. Always allocates; the result is independent of any internal storage.

toString

open override fun toString(): String(source)
Link copied to clipboard
fun MatrixLike.cholesky(policy: CholeskyPolicy = CholeskyPolicy.Strict): DenseMatrix

Lower-triangular Cholesky decomposition A = L * LT, returned as a fresh matrix, from the installed backend; see Lapack.cholesky.

Link copied to clipboard

LU-factorize this square matrix with the active backend (koblas).

Link copied to clipboard

Matrix-matrix product this · other with the active backend.

Link copied to clipboard

Fresh transposed matrix Aᵀ. Always materializes; for products against a transposed operand, prefer the transpose flags on LinearAlgebra.gemv / LinearAlgebra.gemm, which read the original storage without copying.