DynamicMatrix

open class DynamicMatrix(simple: SimpleMatrix)(source)

Represents a matrix of doubles with dynamic (runtime-checked) dimensions. Internally represented as a SimpleMatrix from EJML.

Inheritors

Constructors

Link copied to clipboard
constructor(simple: SimpleMatrix)
constructor(data: Array<DoubleArray>)

Constructor to create a DynamicMatrix from a 2D array.

constructor(data: Collection<Collection<Double>>)

Constructor to create a DynamicMatrix from a list of lists.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
@get:JvmName(name = "inverse")
val inverse: DynamicMatrix

The inverse of this matrix. The matrix must be square and invertible. If the matrix is not square, use pseudoInverse instead.

Link copied to clipboard
@get:JvmName(name = "norm")
val norm: Double

Returns the Frobenius norm of this matrix. The Frobenius norm is the square root of the sum of squares of all elements.

Link copied to clipboard

The number of columns in the matrix.

Link copied to clipboard

The number of rows in the matrix.

Link copied to clipboard
@get:JvmName(name = "pseudoInverse")
val pseudoInverse: DynamicMatrix

The pseudo-inverse of this matrix. The matrix must be square and invertible.

Link copied to clipboard
val size: Pair<Int, Int>

The size of the matrix.

Link copied to clipboard
@get:JvmName(name = "transpose")
val transpose: DynamicMatrix

The transpose of this matrix.

Functions

Link copied to clipboard

Returns the nth column of the matrix.

Link copied to clipboard
open fun copy(): DynamicMatrix

Returns a copy of this matrix.

Link copied to clipboard

Returns the diagonal elements of this matrix.

Link copied to clipboard
open operator fun div(scalar: Double): DynamicMatrix
open operator fun div(scalar: Number): DynamicMatrix

Divides this matrix by a scalar.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard

Computes the matrix exponential of this matrix, using the Padé approximant.

Link copied to clipboard
operator fun get(i: Int, j: Int): Double

Returns the element at the given indices.

Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard

Returns the LDLT decomposition of this matrix. Only works for symmetric matrices.

Link copied to clipboard

Returns the LLT (Cholesky) decomposition of this matrix. Only works for symmetric, positive-definite matrices. Provides in-place rank-1 update/downdate methods.

Link copied to clipboard

Returns the LU decomposition of this matrix.

Link copied to clipboard
operator fun minus(other: DynamicMatrix): DynamicMatrix

Subtracts another matrix from this matrix. The matrices must have the same dimensions.

Link copied to clipboard
operator fun plus(other: DynamicMatrix): DynamicMatrix

Adds another matrix to this matrix. The matrices must have the same dimensions.

Link copied to clipboard

Returns the QR decomposition of this matrix.

Link copied to clipboard

Returns the nth row of the matrix.

Link copied to clipboard
operator fun set(i: Int, j: Int, value: Double)

Sets the element at the given indices to the given value.

Link copied to clipboard
fun slice(startRow: Int, endRow: Int, startCol: Int, endCol: Int): DynamicMatrix

Returns a submatrix of this matrix.

Link copied to clipboard
Link copied to clipboard
operator fun times(other: DynamicMatrix): DynamicMatrix

Multiplies this matrix by another matrix. The number of columns in this matrix must match the number of rows in the other matrix.

open operator fun times(scalar: Double): DynamicMatrix
open operator fun times(scalar: Number): DynamicMatrix

Multiplies this matrix by a scalar.

Link copied to clipboard
fun <R : Nat, C : Nat> toSizedMatrix(rows: R, cols: C): Matrix<R, C>

Returns a Matrix with the same dimensions as this matrix. The dimensions are checked at runtime.

Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
open operator fun unaryMinus(): DynamicMatrix

Returns the matrix with all elements negated. This is equivalent to multiplying the matrix by -1.