RealMatrix class base

A simple Dart implementation of an m x n matrix whose data type is double.

final matrix = RealMatrix(
  rowCount: 3,
  columnCount: 4,
);

By default, the cells of a matrix are initialized with zeroes. You can access elements of the matrix very conveniently with the following syntax:

final matrix = RealMatrix(
  rowCount: 6,
  columnCount: 6,
);

final value = matrix(2, 3);
final value = matrix.itemAt(2, 3);

Both versions return the same value but the first one is less verbose and preferred. In the example, value holds the value of the element at position (1, 3) in the matrix.

Inheritance

Constructors

RealMatrix({required int rows, required int columns, bool identity = false})
Creates a new N x M matrix where rows is N and columns is M. The matrix is filled with zeroes.
RealMatrix.diagonal({required int rows, required int columns, required double 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.
RealMatrix.fromData({required int rows, required int columns, required List<List<double>> data})
Creates a new N x M matrix where rows is N and columns is M. The matrix is filled with values from data.
RealMatrix.fromFlattenedData({required int rows, required int columns, required List<double> 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.
finalinherited
flattenData List<double>
An unmodifiable, flattened representation of the matrix data.
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
isSquareMatrix bool
Determines whether the matrix is square nor not.
no setterinherited
rowCount int
The number of rows of the matrix.
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

call(int row, int col) double
Use this method to retrieve the element at a given position in the matrix. For example:
inherited
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.
override
choleskyDecomposition() List<RealMatrix>
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
override
cofactorMatrix() RealMatrix
The matrix formed by all of the cofactors of a square matrix is called the "cofactor matrix" (also called "the matrix of cofactors").
override
complexHypot(Complex x, Complex y) Complex
Computes sqrt(x^2 + y^2) without under/overflow.
inherited
determinant() double
The determinant can only be computed if the matrix is square, meaning that it must have the same number of columns and rows.
override
eigenDecomposition() List<RealMatrix>
Computes the V, D and V' matrices of the eigendecomposition algorithm. In particular, this method returns the following matrices:
override
eigenvalues() List<Complex>
Returns the eigenvalues associated to this matrix.
override
hypot(double x, double y) double
Computes sqrt(x^2 + y^2) without under/overflow.
inherited
inverse() RealMatrix
Returns the inverse of this matrix.
override
isDiagonal() bool
A diagonal matrix is a matrix in which the entries outside the main diagonal are all zero.
override
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.
override
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.
inherited
itemAt(int row, int col) double
Use this method to retrieve the element at a given position in the matrix. For example:
inherited
luDecomposition() List<RealMatrix>
Factors the matrix as the product of a lower triangular matrix L and an upper triangular matrix U. The matrix must be square.
override
minor(int row, int col) RealMatrix
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.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
qrDecomposition() List<RealMatrix>
Computes the Q and R matrices of the QR decomposition algorithm. In particular, this method returns the Q and R matrices of the
override
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.
override
singleValueDecomposition() List<RealMatrix>
Computes the E, U and V matrices of the SVD (Single Value Decomposition) algorithm. In particular, this method returns the following matrices:
override
toList() List<double>
Returns a modifiable "flattened" view of the matrix as a List<T> object.
inherited
toListOfList() List<List<double>>
Returns a modifiable view of the matrix as a List<List<T>> object.
inherited
toString() String
A string representation of this object.
inherited
trace() double
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).
override
transpose() RealMatrix
Returns the transpose of this matrix.
override
transposedValue(int row, int col) double
Returns the value at (row, col) position as if this matrix were transposed. For example, let's say we have this matrix object:
inherited

Operators

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