Matrix<T> class
abstract
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.
By default, the cells of a matrix are initialized with all zeroes. You can access elements of the matrix either by calling itemAt or by using the call method (which makes the instance '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 whererows
isN
andcolumns
isM
. The matrix is filled with zeroes. -
Matrix.fromData({required int rows, required int columns, required List<
List< data})T> > -
Creates a new
N x M
matrix whererows
isN
andcolumns
isM
. The matrix is filled with values fromdata
. -
Matrix.fromFlattenedData({required int rows, required int columns, required List<
T> data}) -
Creates a new
N x M
matrix whererows
isN
andcolumns
isM
. The matrix is filled with values fromdata
.
Properties
- columnCount → int
-
The number of columns of the matrix.
final
-
flattenData
↔ List<
T> -
A flattened representation of the data of the matrix
latefinal
- hashCode → int
-
The hash code for this object.
no setteroverride
- isSquareMatrix → bool
-
Determines whether the matrix is square
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:
-
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.
-
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.
-
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 matrixU
. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
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
, denotedtr(A)
, is defined to be the sum of elements on the main diagonal (from the upper left to the lower right). -
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 sum 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