Matrix<T> class abstract base

A simple Dart implementation of a matrix whose size is m x n. Thanks to its generic nature, you can decide to work with int, double, Complex or any other kind of numerical type. This library implements:

By default, the cells of a matrix are initialized with zeroes. You can access elements of the matrix either by calling itemAt or by using the call method (which makes the object 'callable').

Implementers

Constructors

Matrix({required int rows, required int columns, required T defaultValue, required T identityOneValue, bool identity = false})
Creates a new N x M matrix where rows is N and columns is M. The matrix is filled with zeroes.
Matrix.diagonal({required int rows, required int columns, required T defaultValue, required T diagonalValue})
Creates a new N x M matrix where rows is N and columns is M. The matrix is filled with diagonalValue in the main diagonal and zeroes otherwise.
Matrix.fromData({required int rows, required int columns, required List<List<T>> data})
Creates a new N x M matrix where rows is N and columns is M. The matrix is filled with values from data.
Matrix.fromFlattenedData({required int rows, required int columns, required List<T> data})
Creates a new N x M matrix where rows is N and columns is M. The matrix is filled with values from data.

Properties

columnCount int
The number of columns of the matrix.
final
flattenData List<T>
An unmodifiable, flattened representation of the matrix data.
no setter
hashCode int
The hash code for this object.
no setteroverride
isSquareMatrix bool
Determines whether the matrix is square nor not.
no setter
rowCount int
The number of rows of the matrix.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

call(int row, int col) → T
Use this method to retrieve the element at a given position in the matrix. For example:
characteristicPolynomial() Algebraic
The characteristic polynomial can only be computed if the matrix is square, meaning that it must have the same number of columns and rows.
choleskyDecomposition() List<Matrix<T>>
Uses the the Cholesky decomposition algorithm to factor the matrix into the product of a lower triangular matrix and its conjugate transpose. In particular, this method returns the L and LT matrices of the
cofactorMatrix() Matrix<T>
The matrix formed by all of the cofactors of a square matrix is called the "cofactor matrix" (also called "the matrix of cofactors").
determinant() → T
The determinant can only be computed if the matrix is square, meaning that it must have the same number of columns and rows.
eigenDecomposition() List<Matrix<T>>
Computes the V, D and V' matrices of the eigendecomposition algorithm. In particular, this method returns the following matrices:
eigenvalues() List<Complex>
Returns the eigenvalues associated to this matrix.
inverse() Matrix<T>
Returns the inverse of this matrix.
isDiagonal() bool
A diagonal matrix is a matrix in which the entries outside the main diagonal are all zero.
isIdentity() bool
The identity matrix is a square matrix with ones on the main diagonal and zeros elsewhere. It is denoted by In, or simply by I.
isSymmetric() bool
A symmetric matrix is a square matrix that is equal to its transpose. Because equal matrices have equal dimensions, only square matrices can be symmetric.
itemAt(int row, int col) → T
Use this method to retrieve the element at a given position in the matrix. For example:
luDecomposition() List<Matrix<T>>
Factors the matrix as the product of a lower triangular matrix L and an upper triangular matrix U. The matrix must be square.
minor(int row, int col) Matrix<T>
A minor of a matrix A is the determinant of some smaller square matrix, cut down from A by removing one or more of its rows and columns.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
qrDecomposition() List<Matrix<T>>
Computes the Q and R matrices of the QR decomposition algorithm. In particular, this method returns the Q and R matrices of the
rank() int
The rank of a matrix A is the dimension of the vector space generated by its columns. This corresponds to the maximal number of linearly independent columns of A.
singleValueDecomposition() List<Matrix<T>>
Computes the E, U and V matrices of the SVD (Single Value Decomposition) algorithm. In particular, this method returns the following matrices:
toList() List<T>
Returns a modifiable "flattened" view of the matrix as a List<T> object.
toListOfList() List<List<T>>
Returns a modifiable view of the matrix as a List<List<T>> object.
toString() String
A string representation of this object.
override
trace() → T
The trace of a square matrix A, denoted tr(A), is defined to be the sum of elements on the main diagonal (from the upper left to the lower right).
transpose() Matrix<T>
Returns the transpose of this matrix.
transposedValue(int row, int col) → T
Returns the value at (row, col) position as if this matrix were transposed. For example, let's say we have this matrix object:

Operators

operator *(Matrix<T> other) Matrix<T>
Returns the product of two matrices.
operator +(Matrix<T> other) Matrix<T>
Returns the sum of two matrices.
operator -(Matrix<T> other) Matrix<T>
Returns the difference of two matrices.
operator /(Matrix<T> other) Matrix<T>
Returns the division of two matrices.
operator ==(Object other) bool
The equality operator.
override