koblas

MatrixView

@Serializable
sealed interface MatrixView : MatrixLike(source)

The matrix storages koblas itself defines: DenseMatrix and SparseMatrix, and nothing else ever.

Sealed for one reason — serialization. A snapshot has to decode back into the concrete storage it was written from, and a closed set is what lets kotlinx.serialization do that without a consumer registering anything. It is also why both storages live in this package: a sealed subtype must be declared alongside its root.

Take MatrixLike instead unless you genuinely need the closed set. This exists so serialization and exhaustive dispatch work, not to restrict what callers can pass.

get is O(1) on the dense storage and a search within a column on the sparse one, so an algorithm that sweeps every entry through get is the wrong shape for a sparse operand — walk the stored entries instead.

Inheritors

Properties

Link copied to clipboard
abstract val cols: Int

Number of columns.

Link copied to clipboard
abstract val rows: Int

Number of rows.

Functions

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
abstract operator fun get(i: Int, j: Int): Double

Read entry at row i, column j.

Link copied to clipboard
abstract fun toArray(): Array<DoubleArray>

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