koblas

MatrixLike

interface MatrixLike(source)

Read-only matrix contract: shape, entry access, materialisation. Anything that only reads a matrix should take this.

Open, deliberately, and that is the difference from MatrixView. koblas cannot know every shape a caller already has — a row-major buffer from another library, a banded or blocked structure, a lazily generated kernel matrix — and requiring a copy into DenseMatrix to use any of koblas's routines was a tax on exactly the callers with the most data. Implement this and the read-only routines accept it.

The cost of an adapter is that koblas can only reach it through get. Its own storages are recognised by type and swept along their contiguous axis; a foreign implementation takes the generic path, which visits rows × cols entries through a virtual call. That is the right trade for correctness-with-any-input, and the reason to hand koblas a DenseMatrix when the data is dense and hot.

See also

the closed, serializable subset.

Inheritors

Properties

cols

abstract val cols: Int(source)

Number of columns.

rows

abstract val rows: Int(source)

Number of rows.

Functions

get

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

Read entry at row i, column j.

toArray

abstract fun toArray(): Array<DoubleArray>(source)

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

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.