Matrix

@Serializable
class Matrix(val rows: Int, val cols: Int)(source)

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

Constructors

Link copied to clipboard
constructor(rows: Int, cols: Int)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val cols: Int

The number of columns in the matrix.

Link copied to clipboard
Link copied to clipboard
val rows: Int

The number of rows in the matrix.

Functions

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
fun copy(): Matrix
Link copied to clipboard
fun Matrix.dehankelVector2(closed: Boolean = false): List<Vector2>

Computes a list of 2D vectors from the given matrix by averaging values in paired rows. The matrix must have an even number of rows, positive dimensions, and follows a Hankel-like structure for computation.

Link copied to clipboard
operator fun get(row: Int, column: Int): Double
operator fun get(row: Int, columnRange: IntRange): Matrix
operator fun get(rowRange: IntRange, column: Int): Matrix
operator fun get(rowRange: IntRange, columnRange: IntRange): Matrix
Link copied to clipboard
fun isSymmetric(matrix: Matrix, tolerance: Double = 1.0E-10): Boolean

Checks if the given matrix is symmetric within a specified tolerance.

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.

Link copied to clipboard

Multiplies two matrices and returns the resulting matrix.

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

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

Extension function to add a Matrix to a SparseMatrix.

Link copied to clipboard
operator fun set(row: Int, column: Int, value: Double)

Set value

Link copied to clipboard
fun Matrix.svd(fullMatrix: Boolean = true): Triple<Matrix, Matrix, Matrix>

Computes the Singular Value Decomposition (SVD) of this matrix.

Link copied to clipboard
operator fun times(scale: Double): Matrix

operator fun times(other: Matrix): Matrix

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

Link copied to clipboard

Extension function to convert a dense Matrix to a SparseMatrix.

Link copied to clipboard

Returns a new matrix that is the transpose of this matrix.