Package-level declarations

Types

Link copied to clipboard
@Serializable
class Matrix(val rows: Int, val cols: Int)

Represents a two-dimensional matrix with support for basic operations such as indexing, copying, and mathematical computations.

Link copied to clipboard
@Serializable
class SparseMatrix(val rows: Int, val cols: Int, val values: DoubleArray, val columnIndices: IntArray, val rowPointers: IntArray)

Represents a sparse matrix using the Compressed Sparse Row (CSR) format.

Functions

Link copied to clipboard
Link copied to clipboard

Performs the Cholesky decomposition on a given square, positive-definite matrix. The Cholesky decomposition expresses the matrix as L * L^T, where L is a lower triangular matrix.

Link copied to clipboard

Calculates the mean of each column in the matrix and returns the result as a new single-row matrix.

Link copied to clipboard

Calculates the Frobenius norm of the sparse matrix. The Frobenius norm is the square root of the sum of the squares of all the non-zero elements in the matrix.

Link copied to clipboard

Computes the inverse of a given symmetric, positive-definite matrix using the Cholesky decomposition.

Link copied to clipboard
operator fun Matrix.minus(other: Matrix): Matrix

operator fun Matrix.minus(other: SparseMatrix): Matrix

Extension function to subtract a SparseMatrix from a Matrix.

operator fun SparseMatrix.minus(other: Matrix): Matrix

Extension function to subtract a Matrix from a SparseMatrix.

Link copied to clipboard
operator fun Matrix.plus(other: SparseMatrix): Matrix

Extension function to add a Matrix to a SparseMatrix.

operator fun SparseMatrix.plus(other: Matrix): Matrix

Adds this sparse matrix to another matrix and returns the resulting matrix.

Link copied to clipboard

Performs QR decomposition on a sparse matrix.

Link copied to clipboard

Solves a linear system Ax = b using QR decomposition.

Link copied to clipboard
fun SparseMatrix(rows: Int, cols: Int, values: Map<Pair<Int, Int>, Double>): SparseMatrix

Constructs a SparseMatrix instance with the specified number of rows, columns, and non-zero values.

fun SparseMatrix(rows: Int, cols: Int, indices: List<Pair<Int, Int>>, values: List<Double>, presorted: Boolean = true): SparseMatrix

Constructs a sparse matrix in Compressed Sparse Row (CSR) format.

Link copied to clipboard
operator fun Double.times(matrix: SparseMatrix): SparseMatrix

Extension function to multiply a scalar by a SparseMatrix.

operator fun SparseMatrix.times(other: Matrix): Matrix

Multiplies this sparse matrix with another matrix and returns the resulting matrix.

Link copied to clipboard

Extension function to convert a dense Matrix to a SparseMatrix.