Matrix class
The Matrix
class provides a structure for two-dimensional arrays of data,
along with various utility methods for manipulating these arrays.
The class extends IterableMixin
allowing iteration over the rows or columns of the matrix.
- Inheritance
-
- Object
- IterableMixin<
List> - Matrix
- Implementers
- Available extensions
Constructors
- Matrix.new([dynamic input])
-
Constructs a Matrix object from a
List<List<dynamic>>
or a String. If input is null or not provided, an empty Matrix is created. - Matrix.arrange(int end, {int start = 0, int step = 1, bool isColumn = false})
-
Alias for Matrix.range.
factory
-
Matrix.concatenate(List<
Matrix> matrices, {int axis = 0, bool resize = false}) -
Concatenates a list of matrices along the specified axis.
factory
- Matrix.eye(int size, {bool isDouble = false})
-
Creates a square identity Matrix of the specified size.
factory
- Matrix.fill(int rows, int cols, dynamic value)
-
Creates a Matrix of the specified dimensions with all elements set to the specified value.
factory
-
Matrix.fromBlocks(List<
List< blocks)Matrix> > -
Constructs a new
Matrix
from smaller square matrices (blocks).factory -
Matrix.fromColumns(List<
ColumnMatrix> columns, {bool resize = false}) -
Constructs a Matrix from a list of Column vectors.
factory
- Matrix.fromDiagonal(List diagonal)
-
Creates a square Matrix with the specified diagonal elements.
factory
- Matrix.fromFlattenedList(List source, int rows, int cols, {bool fillWithZeros = true})
-
Constructs a new Matrix from a flattened list.
factory
-
Matrix.fromList(List<
List> list) -
Creates a matrix from the given list of lists.
factory
-
Matrix.fromRows(List<
RowMatrix> rows, {bool resize = false}) -
Constructs a Matrix from a list of Row vectors.
factory
- Matrix.linspace(int start, int end, [int number = 50])
-
Creates a row Matrix with equally spaced values between the start and end values (inclusive).
factory
- Matrix.magic(int n)
-
Generates a magic square of the given size.
factory
- Matrix.ones(int rows, int cols, {bool isDouble = false})
-
Creates a Matrix of the specified dimensions with all elements set to 1.
factory
- Matrix.random(int rowCount, int columnCount, {double min = 0, double max = 1, bool isDouble = true, Random? random, int? seed})
-
Creates a matrix with random elements of type double or int.
factory
- Matrix.range(int end, {int start = 0, int step = 1, bool isColumn = false})
-
Creates a Matrix with values in the specified range, incremented or decremented by the specified step size.
factory
- Matrix.scalar(int size, dynamic value)
-
Method to create a scalar matrix.
Example:
factory
- Matrix.zeros(int rows, int cols, {bool isDouble = false})
-
Creates a Matrix of the specified dimensions with all elements set to 0.
factory
Properties
- columnCount → int
-
Returns the number of columns in the matrix.
no setter
-
columns
→ Iterable<
List> -
Getter to retrieve column-wise iteration over the matrix.
It returns an iterable of columns, where each column is a list of elements.
no setter
- decomposition → MatrixDecomposition
-
Getter to retrieve the MatrixDecomposition object associated with the matrix.
This object provides methods for various matrix decompositions, like LU, QR etc.
no setter
- elements → Iterable
-
Getter to retrieve an iterable over all elements in the matrix,
regardless of their row or column.
no setter
- first → List
-
The first element.
no setterinherited
- hashCode → int
-
The hash code for this object.
no setteroverride
- isEmpty → bool
-
Whether this collection has no elements.
no setterinherited
- isNotEmpty → bool
-
Whether this collection has at least one element.
no setterinherited
-
iterator
→ Iterator<
List> -
Overrides the iterator getter to provide a MatrixIterator.
This iterator iterates over the rows of the matrix.
no setteroverride
- last → List
-
The last element.
no setterinherited
- length → int
-
The number of elements in this Iterable.
no setterinherited
- linear → LinearSystemSolvers
-
Getter to retrieve the LinearSystemSolvers object associated with the matrix.
This object provides methods for solving linear systems of equations represented by the matrix.
no setter
- rowCount → int
-
Returns the number of rows in the matrix.
no setter
-
rows
→ Iterable<
List> -
Getter to retrieve row-wise iteration over the matrix.
It returns an iterable of rows, where each row is a list of elements.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
shape
→ List<
int> -
Returns the dimensions of the matrix as a
List<int>
in the formatrowCount, columnCount
.no setter - single → List
-
Checks that this iterable has only one element, and returns that element.
no setterinherited
Methods
-
abs(
) → Matrix -
Available on Matrix, provided by the MatrixOperationExtension extension
Calculates the element-wise absolute value of the matrix. -
acos(
) → Matrix -
Available on Matrix, provided by the MatrixFunctions extension
Element-wise arccosine -
acosh(
) → Matrix -
Available on Matrix, provided by the MatrixFunctions extension
Element-wise acosh -
addRow(
int sourceIndex, int targetIndex, dynamic scaleFactor) → void -
Available on Matrix, provided by the MatrixOperationExtension extension
Adds a multiple of one row to another row. -
addVector(
Vector vector) → Matrix -
Available on Matrix, provided by the MatrixVectorOperations extension
Add a matrix and a vector -
adjoint(
) → Matrix -
Available on Matrix, provided by the MatrixOperationExtension extension
Computes the adjoint (also known as adjugate or adjunct) of a square matrix. The adjoint is obtained by transposing the cofactor matrix. -
any(
bool test(List element)) → bool -
Checks whether any element of this iterable satisfies
test
.inherited -
appendColumns(
dynamic newColumns) → Matrix -
Available on Matrix, provided by the MatrixManipulationExtension extension
Appends new columns to the matrix with the values provided innewColumns
. -
appendRows(
dynamic newRows) → Matrix -
Available on Matrix, provided by the MatrixManipulationExtension extension
Appends new rows to the matrix with the values provided innewRows
. -
apply(
dynamic func(dynamic)) → Matrix -
Available on Matrix, provided by the MatrixManipulationExtension extension
Applies the given functionfunc
to each element in the matrix and returns a new matrix with the results. -
applyToRows(
List func(List)) → Matrix -
Available on Matrix, provided by the MatrixManipulationExtension extension
Applies the given functionfunc
to each row in the matrix and returns a new matrix with the results. -
asin(
) → Matrix -
Available on Matrix, provided by the MatrixFunctions extension
Element-wise arcsine -
asinh(
) → Matrix -
Available on Matrix, provided by the MatrixFunctions extension
Element-wise asinh -
atan(
) → Matrix -
Available on Matrix, provided by the MatrixFunctions extension
Element-wise arctangent -
atan2(
Matrix other) → Matrix -
Available on Matrix, provided by the MatrixFunctions extension
Element-wise atan2 -
atanh(
) → Matrix -
Available on Matrix, provided by the MatrixFunctions extension
Element-wise atanh -
augment(
dynamic augmentee) → Matrix -
Available on Matrix, provided by the MatrixManipulationExtension extension
Augments the matrix with the given column vector or matrix. This method is an alias ofappendColumns
. -
bidiagonalize(
) → Bidiagonalization -
Available on Matrix, provided by the MatrixOperationExtension extension
Computes the bidiagonalization of the matrix using Householder reflections. -
broadcast(
Matrix b) → List< Matrix> -
Available on Matrix, provided by the MatrixManipulationExtension extension
Broadcasts the current matrix with matrixb
. -
cast<
R> () → Iterable< R> -
A view of this iterable as an iterable of
R
instances.inherited -
cofactors(
) → Matrix -
Available on Matrix, provided by the MatrixOperationExtension extension
Computes the matrix of cofactors for a square matrix. Each element in the cofactor matrix is the determinant of the subMatrix formed by removing the corresponding row and column from the original matrix, multiplied by the alternating sign pattern. -
column(
int index) → ColumnMatrix - Returns the column at the specified index as a Column object.
-
columnMaxs(
) → List< double> -
Available on Matrix, provided by the MatrixStatsExtension extension
Calculates the maximum value for each column in the matrix. -
columnMeans(
) → List< double> -
Available on Matrix, provided by the MatrixStatsExtension extension
Calculates the mean value for each column in the matrix. -
columnMins(
) → List< double> -
Available on Matrix, provided by the MatrixStatsExtension extension
Calculates the minimum value for each column in the matrix. -
columnSpace(
) → Matrix -
Available on Matrix, provided by the MatrixOperationExtension extension
Returns the column space of the matrix. -
columnStdDevs(
) → List -
Available on Matrix, provided by the MatrixStatsExtension extension
Calculates the standard deviation for each column in the matrix. -
concatenate(
List< Matrix> matrices, {int axis = 0, bool resize = false}) → Matrix -
Available on Matrix, provided by the MatrixManipulationExtension extension
Concatenates the given list of matrices with the current matrix along the specified axis. -
conditionNumber(
) → dynamic -
Available on Matrix, provided by the MatrixOperationExtension extension
Calculates the condition number of the matrix using the Frobenius norm. -
conjugate(
) → Matrix -
Available on Matrix, provided by the MatrixOperationExtension extension
Computes the matrix of cofactors for a square matrix. Each element in the cofactor matrix is the determinant of the subMatrix formed by removing the corresponding row and column from the original matrix, multiplied by the alternating sign pattern. -
conjugateTranspose(
) → Matrix -
Available on Matrix, provided by the MatrixOperationExtension extension
Returns the conjugate transpose (also known as the Hermitian transpose) of the matrix. The conjugate transpose is obtained by first computing the conjugate of the matrix and then transposing it. -
contains(
Object? element) → bool -
Whether the collection contains an element equal to
element
.inherited -
containsIn(
List< Matrix> matrices) → bool -
Available on Matrix, provided by the MatrixOperationExtension extension
Checks if the current matrix is contained in or is a subMatrix of any matrix inmatrices
. -
copy(
) → Matrix -
Available on Matrix, provided by the MatrixManipulationExtension extension
Returns a copy of the matrix. -
copyFrom(
Matrix other, {bool resize = false, bool retainSize = false}) → void -
Available on Matrix, provided by the MatrixManipulationExtension extension
Copies the elements from another matrix into this matrix. -
cos(
) → Matrix -
Available on Matrix, provided by the MatrixFunctions extension
Element-wise cosine -
cosh(
) → Matrix -
Available on Matrix, provided by the MatrixFunctions extension
Element-wise cosh -
covarianceMatrix(
) → Matrix -
Available on Matrix, provided by the MatrixStatsExtension extension
Returns the covariance matrix of the input matrix. -
cumsum(
{bool continuous = false, int? axis}) → dynamic -
Available on Matrix, provided by the MatrixOperationExtension extension
Performs cumulative sum operations similar to numpy's cumsum but with more flexibility. -
determinant(
{DeterminantMethod method = DeterminantMethod.LU}) → dynamic -
Available on Matrix, provided by the MatrixOperationExtension extension
Computes the determinant of the matrix. -
diagonal(
{int k = 0, dynamic reverse = false}) → List - Extracts the diagonal elements from the matrix based on the given offset.
-
distance(
Matrix other, {DistanceType distance = DistanceType.frobenius}) → dynamic -
Available on Matrix, provided by the MatrixOperationExtension extension
Computes the distance between this matrix and another provided matrix based on the specified distance type. -
dot(
Matrix other) → Matrix -
Available on Matrix, provided by the MatrixOperationExtension extension
Calculates the dot product of two matrices. -
eigen(
{int maxIterations = 1000, num tolerance = 1e-10}) → Eigen -
Available on Matrix, provided by the MatrixOperationExtension extension
-
eigen1(
{int maxIterations = 1000, num tolerance = 1e-10}) → Eigen -
Available on Matrix, provided by the MatrixOperationExtension extension
Computes the eigenvalues and eigenvectors of the matrix using the QR algorithm. -
eigenvalues(
{int maxIterations = 1000, num tolerance = 1e-10}) → List -
Available on Matrix, provided by the MatrixOperationExtension extension
Computes the eigenvalues of the matrix using the QR algorithm. -
eigenvectors(
{int maxIterations = 1000, double tolerance = 1e-10}) → List< Matrix> -
Available on Matrix, provided by the MatrixOperationExtension extension
Computes the eigenvectors of the matrix using the QR algorithm. -
elementAt(
int row, int col) → dynamic -
Available on Matrix, provided by the MatrixManipulationExtension extension
Retrieves the element of the matrix at the specified row and column indices. -
elementAt(
int index) → List -
Returns the
index
th element.inherited -
elementDivide(
Matrix other) → Matrix -
Available on Matrix, provided by the MatrixOperationExtension extension
Divides the corresponding elements of this matrix by the elements of the given matrix. -
elementMultiply(
Matrix other) → Matrix -
Available on Matrix, provided by the MatrixOperationExtension extension
Returns a new matrix with the exponential of each element of the matrix. -
elementWise(
Matrix other, dynamic f(dynamic, dynamic)) → Matrix -
Available on Matrix, provided by the MatrixOperationExtension extension
applies the given binary function element-wise on this matrix and the given matrix. -
equal(
Object other) → bool - Compares two matrices for inequality. Returns true if the matrices have different dimensions or any elements are not equal, otherwise false.
-
every(
bool test(List element)) → bool -
Checks whether every element of this iterable satisfies
test
.inherited -
exp(
) → Matrix -
Available on Matrix, provided by the MatrixFunctions extension
Element-wise exponential -
expand<
T> (Iterable< T> toElements(List element)) → Iterable<T> -
Expands each element of this Iterable into zero or more elements.
inherited
-
findMaxInMatrixRegion(
int startRow, int startCol) → List< int> -
Available on Matrix, provided by the MatrixStatsExtension extension
Finds the maximum absolute value in the matrix starting from the given row and column indices (inclusive). -
findMinInMatrixRegion(
int startRow, int startCol) → List< int> -
Available on Matrix, provided by the MatrixStatsExtension extension
Finds the minimum absolute value in the matrix starting from the given row and column indices (inclusive). -
findSmallestPeriod(
{num tolerance = 1e-10, int maxPeriod = 100}) → int -
Available on Matrix, provided by the MatrixStructure extension
Finds the smallest period of the matrix. -
firstWhere(
bool test(List element), {List orElse()?}) → List -
The first element that satisfies the given predicate
test
.inherited -
flatten(
) → List -
Available on Matrix, provided by the MatrixManipulationExtension extension
Flattens the matrix into a single row. -
flip(
{int axis = 0}) → Matrix -
Available on Matrix, provided by the MatrixManipulationExtension extension
Flips the matrix along the specified axis. -
fold<
T> (T initialValue, T combine(T previousValue, List element)) → T -
Reduces a collection to a single value by iteratively combining each
element of the collection with an existing value
inherited
-
followedBy(
Iterable< List> other) → Iterable<List> -
Creates the lazy concatenation of this iterable and
other
.inherited -
forEach(
void action(List element)) → void -
Invokes
action
on each element of this iterable in iteration order.inherited -
hasDominantEigenvalue(
{num tolerance = 1e-10}) → bool -
Available on Matrix, provided by the MatrixStructure extension
Checks if the matrix has a dominant eigenvalue. Returns true if the matrix has a dominant eigenvalue, false otherwise. -
hessenberg(
{num tol = 1e-15}) → HessenbergResult -
Available on Matrix, provided by the MatrixOperationExtension extension
-
indexOf(
dynamic element, {bool findAll = false}) → dynamic -
Returns the indices of occurrences of the specified element in the matrix.
If
findAll
is set to true, returns aList<List<int>>
of all indices where the element was found. IffindAll
is false or not provided, returns aList<int>
of the first occurrence. Returns null if the element is not found. -
insertColumn(
int columnIndex, List newValues) → Matrix -
Available on Matrix, provided by the MatrixManipulationExtension extension
Inserts a new column at the specified position in the matrix with the values provided in new Values. -
insertRow(
int rowIndex, List newValues) → Matrix -
Available on Matrix, provided by the MatrixManipulationExtension extension
Inserts a new row at the specified position in the matrix with the values provided in new Values. -
inverse(
{double conditionThreshold = 1e-3}) → Matrix -
Available on Matrix, provided by the MatrixOperationExtension extension
Calculates the inverse of a square matrix, falling back to SVD-based inversion or generalized pseudo-inversion if necessary. -
isAlmostEqual(
Matrix other, {num tolerance = 1e-10}) → bool -
Available on Matrix, provided by the MatrixStructure extension
Checks if two matrices are approximately equal within the given tolerance. -
isBidiagonalMatrix(
{num tolerance = 1e-12}) → bool -
Available on Matrix, provided by the MatrixStructure extension
Checks if the matrix is a Bidiagonal matrix. -
isCirculantMatrix(
{num tolerance = 1e-10}) → bool -
Available on Matrix, provided by the MatrixStructure extension
Checks if the matrix is a Circulant matrix. -
isColumnMatrix(
) → bool -
Available on Matrix, provided by the MatrixStructure extension
Check if the matrix is a column matrix (n rows, 1 column). -
isCompatibleForBroadcastWith(
Matrix b) → bool -
Available on Matrix, provided by the MatrixManipulationExtension extension
Determines whether the current matrix and matrixb
are compatible for broadcasting. -
isDerogatoryMatrix(
) → bool -
Available on Matrix, provided by the MatrixStructure extension
Checks if the matrix is a derogatory matrix. -
isDiagonallyDominantMatrix(
) → bool -
Available on Matrix, provided by the MatrixStructure extension
Checks if the matrix is a diagonally dominant matrix. -
isDiagonalMatrix(
{num tolerance = 1e-10}) → bool -
Available on Matrix, provided by the MatrixStructure extension
Check if the matrix is a diagonal matrix. -
isFullRank(
) → bool -
Available on Matrix, provided by the MatrixStructure extension
Checks if the matrix has full rank. -
isHankelMatrix(
{num tolerance = 1e-10}) → bool -
Available on Matrix, provided by the MatrixStructure extension
Checks if the matrix is a Hankel matrix. -
isHermitianMatrix(
{num tolerance = 1e-10}) → bool -
Available on Matrix, provided by the MatrixStructure extension
Checks if the matrix is Hermitian (equal to its conjugate transpose). Returns true if the matrix is Hermitian, false otherwise. -
isHorizontalMatrix(
) → bool -
Available on Matrix, provided by the MatrixStructure extension
Check if the matrix is a horizontal matrix (rows < columns). -
isIdempotentMatrix(
{num tolerance = 1e-10}) → bool -
Available on Matrix, provided by the MatrixStructure extension
Checks if the matrix is an idempotent matrix. -
isIdentityMatrix(
{num tolerance = 1e-10}) → bool -
Available on Matrix, provided by the MatrixStructure extension
Check if the matrix is an identity matrix. -
isInvolutoryMatrix(
{num tolerance = 1e-10}) → bool -
Available on Matrix, provided by the MatrixStructure extension
Checks if the matrix is an involutory matrix. -
isLowerTriangular(
[num tolerance = 1e-10]) → bool -
Available on Matrix, provided by the MatrixStructure extension
-
isMagicMatrix(
) → bool -
Available on Matrix, provided by the MatrixStructure extension
Checks if the matrix is a magic square. -
isNegativeDefiniteMatrix(
) → bool -
Available on Matrix, provided by the MatrixStructure extension
Checks if the matrix is a negative definite matrix. -
isNilpotentMatrix(
{int maxIterations = 100}) → bool -
Available on Matrix, provided by the MatrixStructure extension
Checks if the matrix is a nilpotent matrix. -
isNonSingularMatrix(
) → bool -
Available on Matrix, provided by the MatrixStructure extension
Checks if the matrix is a NonSingularMatrix matrix. -
isNullMatrix(
{num tolerance = 1e-10}) → bool -
Available on Matrix, provided by the MatrixStructure extension
Check if the matrix is a null matrix (all elements are zero). Example: -
isOrthogonalMatrix(
{num tolerance = 1e-10}) → bool -
Available on Matrix, provided by the MatrixStructure extension
Checks if the matrix is an orthogonal matrix. -
isPeriodicMatrix(
int period, {num tolerance = 1e-10}) → bool -
Available on Matrix, provided by the MatrixStructure extension
Checks if the matrix is a periodic matrix. -
isPermutationMatrix(
{num tolerance = 1e-10}) → bool -
Available on Matrix, provided by the MatrixStructure extension
Checks if the matrix is a Permutation matrix. -
isPositiveDefiniteMatrix(
) → bool -
Available on Matrix, provided by the MatrixStructure extension
Checks if the matrix is a positive definite matrix. -
isRowMatrix(
) → bool -
Available on Matrix, provided by the MatrixStructure extension
Check if the matrix is a row matrix (1 row, n columns). -
isScalarMatrix(
{num tolerance = 1e-10}) → bool -
Available on Matrix, provided by the MatrixStructure extension
Check if the matrix is a scalar matrix. -
isSingularMatrix(
) → bool -
Available on Matrix, provided by the MatrixStructure extension
Checks if the matrix is a singular matrix. -
isSkewSymmetricMatrix(
{num tolerance = 1e-10}) → bool -
Available on Matrix, provided by the MatrixStructure extension
Checks if the matrix is a skew symmetric matrix. -
isSparseMatrix(
{num threshold = 0.5}) → bool -
Available on Matrix, provided by the MatrixStructure extension
Checks if the matrix is sparse. Returns true if the matrix is sparse, false otherwise. -
isSquareMatrix(
) → bool -
Available on Matrix, provided by the MatrixStructure extension
Check if the matrix is a square matrix (n rows, n columns). -
isStrictlyDiagonallyDominantMatrix(
) → bool -
Available on Matrix, provided by the MatrixStructure extension
Checks if the matrix is a strictly diagonally dominant matrix. -
isSubMatrix(
Matrix parent) → bool -
Available on Matrix, provided by the MatrixStructure extension
Checks if the current matrix is a submatrix ofparent
. -
isSymmetricMatrix(
{num tolerance = 1e-10}) → bool -
Available on Matrix, provided by the MatrixStructure extension
Checks if the matrix is a symmetric matrix. -
isToeplitzMatrix(
{num tolerance = 1e-10}) → bool -
Available on Matrix, provided by the MatrixStructure extension
Checks if the matrix is a Toeplitz matrix. -
isTridiagonal(
{num tolerance = 1e-10}) → bool -
Available on Matrix, provided by the MatrixStructure extension
Checks if the matrix is a Tridiagonal matrix. -
isUnitaryMatrix(
{num tolerance = 1e-12}) → bool -
Available on Matrix, provided by the MatrixStructure extension
Checks if the matrix is a Unitary matrix. -
isUpperTriangular(
[num tolerance = 1e-10]) → bool -
Available on Matrix, provided by the MatrixStructure extension
Checks if the matrix is upper triangular within the given tolerance. -
isVandermondeMatrix(
{num tolerance = 1e-10}) → bool -
Available on Matrix, provided by the MatrixStructure extension
Checks if the matrix is a Vandermonde matrix. -
isVerticalMatrix(
) → bool -
Available on Matrix, provided by the MatrixStructure extension
Check if the matrix is a vertical matrix (rows > columns). -
isZeroMatrix(
{num tolerance = 1e-10}) → bool -
Available on Matrix, provided by the MatrixStructure extension
Checks if the matrix is a zero matrix. -
join(
[String separator = ""]) → String -
Converts each element to a String and concatenates the strings.
inherited
-
kurtosis(
) → num -
Available on Matrix, provided by the MatrixStatsExtension extension
Returns the kurtosis of the elements in the matrix. -
lastWhere(
bool test(List element), {List orElse()?}) → List -
The last element that satisfies the given predicate
test
.inherited -
log(
) → Matrix -
Available on Matrix, provided by the MatrixFunctions extension
Element-wise natural logarithm -
logn(
num base) → Matrix -
Available on Matrix, provided by the MatrixFunctions extension
Element-wise logarithm for any base -
map<
T> (T toElement(List e)) → Iterable< T> -
The current elements of this iterable modified by
toElement
.inherited -
matrixProperties(
) → List< String> -
Available on Matrix, provided by the MatrixStructure extension
Returns a list of all the properties of the matrix. -
max(
{int? axis}) → dynamic -
Available on Matrix, provided by the MatrixStatsExtension extension
Returns the largest numeric value in the matrix along the specified axis. -
mean(
) → dynamic -
Available on Matrix, provided by the MatrixStatsExtension extension
Returns the mean of all elements in the matrix. -
median(
) → dynamic -
Available on Matrix, provided by the MatrixStatsExtension extension
Returns the median of all elements in the matrix. -
min(
{int? axis}) → dynamic -
Available on Matrix, provided by the MatrixStatsExtension extension
Returns the smallest value in the matrix along the specified axis. -
multiply(
Vector vector) → Vector -
Available on Matrix, provided by the MatrixVectorOperations extension
-
norm(
[Norm normType = Norm.frobenius]) → dynamic -
Available on Matrix, provided by the MatrixOperationExtension extension
-
normalize(
[Norm? normType]) → Matrix -
Available on Matrix, provided by the MatrixOperationExtension extension
Normalizes the matrix by dividing each element by the maximum element value. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notEqual(
Object other) → bool - Compares two matrices for inequality. Returns true if the matrices have different dimensions or any elements are not equal, otherwise false.
-
notIn(
List< Matrix> matrices) → bool -
Available on Matrix, provided by the MatrixOperationExtension extension
Checks if the current matrix is not contained in and is not a subMatrix of any matrix inmatrices
. -
nullity(
) → int -
Available on Matrix, provided by the MatrixOperationExtension extension
Returns the nullity of the matrix. -
nullSpace(
) → Matrix -
Available on Matrix, provided by the MatrixOperationExtension extension
Returns the null space (also known as kernel) of the matrix. -
pearsonCorrelationCoefficient(
) → Matrix -
Available on Matrix, provided by the MatrixStatsExtension extension
Returns the Pearson correlation coefficient matrix of the input matrix. -
pow(
num power) → Matrix -
Available on Matrix, provided by the MatrixFunctions extension
Raises this matrix to a given power. Uses eigenvalue decomposition for non-integer powers and binary exponentiation for integer powers. -
pow(
num exponent) → Matrix -
Available on Matrix, provided by the MatrixOperationExtension extension
Returns a new matrix with each element raised to the power ofexponent
. -
prettyPrint(
{String separator = ' ', bool isPrettyMatrix = true, MatrixAlign alignment = MatrixAlign.right}) → void - Print a string representation of the matrix with its shape and elements separated by the specified separator.
-
product(
) → dynamic -
Available on Matrix, provided by the MatrixOperationExtension extension
Returns the product of all elements in the matrix. -
pseudoInverse(
) → Matrix -
Available on Matrix, provided by the MatrixOperationExtension extension
Computes the pseudo-inverse of a matrix using Singular Value Decomposition (SVD). -
rank(
) → int -
Available on Matrix, provided by the MatrixStatsExtension extension
Returns the rank of the matrix. -
reciprocal(
) → Matrix -
Available on Matrix, provided by the MatrixOperationExtension extension
Calculates the element-wise reciprocal of the matrix. -
reduce(
List combine(List value, List element)) → List -
Reduces a collection to a single value by iteratively combining elements
of the collection using the provided function.
inherited
-
reducedRowEchelonForm(
) → Matrix -
Available on Matrix, provided by the MatrixStatsExtension extension
Returns the reduced row echelon form (RREF) of the current matrix. -
removeColumn(
int columnIndex) → Matrix -
Available on Matrix, provided by the MatrixManipulationExtension extension
Removes the column at the specified index from the matrix. -
removeColumns(
List< int> columnIndices) → Matrix -
Available on Matrix, provided by the MatrixManipulationExtension extension
Removes the columns at the specified indices from the matrix. -
removeRow(
int rowIndex) → Matrix -
Available on Matrix, provided by the MatrixManipulationExtension extension
Removes the row at the specified index from the matrix. -
removeRows(
List< int> rowIndices) → Matrix -
Available on Matrix, provided by the MatrixManipulationExtension extension
Removes the rows at the specified indices from the matrix. -
replace(
List< int> rowIndices, List<int> colIndices, dynamic value) → Matrix -
Available on Matrix, provided by the MatrixManipulationExtension extension
Replaces the elements in the specified rows and columns with the given value. -
replicateMatrix(
int numRows, int numCols) → Matrix -
Available on Matrix, provided by the MatrixManipulationExtension extension
Replicates the current matrix to create a new matrix with the desired dimensions. -
rescale(
{Rescale rescaleBy = Rescale.column}) → Matrix -
Available on Matrix, provided by the MatrixOperationExtension extension
Rescales each column of the matrix to the range 0-1. -
reshape(
int newRowCount, int newColumnCount) → Matrix -
Available on Matrix, provided by the MatrixManipulationExtension extension
Reshapes the matrix to have the specified number of rows and columns. -
reshapeList(
List< int> newShape) → Matrix -
Available on Matrix, provided by the MatrixManipulationExtension extension
Reshapes the matrix to have the specified shape provided in the form of a list. -
roll(
dynamic shift, {dynamic axis}) → Matrix -
Available on Matrix, provided by the MatrixManipulationExtension extension
Rolls the elements in the matrix along the specified axis or axes. -
rotate(
int p, int q, double c, double s) → Matrix -
Available on Matrix, provided by the MatrixOperationExtension extension
-
round(
[int decimalPlaces = 0]) → Matrix -
Available on Matrix, provided by the MatrixOperationExtension extension
Rounds each element in the matrix to the specified number of decimal places. -
row(
int index) → RowMatrix - Returns the row at the specified index as a Row object.
-
rowEchelonForm(
) → Matrix -
Available on Matrix, provided by the MatrixStatsExtension extension
Returns the row echelon form (REF) of the current matrix. -
rowMaxs(
) → List -
Available on Matrix, provided by the MatrixStatsExtension extension
Calculates the maximum value for each row in the matrix. -
rowMeans(
) → List< double> -
Available on Matrix, provided by the MatrixStatsExtension extension
Calculates the mean value for each row in the matrix. -
rowMins(
) → List -
Available on Matrix, provided by the MatrixStatsExtension extension
Calculates the minimum value for each row in the matrix. -
rowSpace(
) → Matrix -
Available on Matrix, provided by the MatrixOperationExtension extension
Returns the row space of the matrix. -
rowStdDevs(
) → List -
Available on Matrix, provided by the MatrixStatsExtension extension
Calculates the standard deviation for each row in the matrix. -
scale(
dynamic scaleFactor) → Matrix -
Available on Matrix, provided by the MatrixOperationExtension extension
Scales a matrix by a given factor. -
scaleRow(
int rowIndex, dynamic scaleFactor) → void -
Available on Matrix, provided by the MatrixOperationExtension extension
Scales the elements of the specified row by a given factor. -
setColumn(
int columnIndex, List newValues) → Matrix -
Available on Matrix, provided by the MatrixManipulationExtension extension
Sets the specified column in the matrix with the new values provided in new Values. -
setRow(
int rowIndex, List newValues) → Matrix -
Available on Matrix, provided by the MatrixManipulationExtension extension
Sets the specified row in the matrix with the new values provided in new Values. -
setSubMatrix(
int startRow, int startCol, Matrix subMatrix) → void -
Available on Matrix, provided by the MatrixManipulationExtension extension
Sets the values of the subMatrix at the specified position. -
sin(
) → Matrix -
Available on Matrix, provided by the MatrixFunctions extension
Element-wise sine -
singleWhere(
bool test(List element), {List orElse()?}) → List -
The single element that satisfies
test
.inherited -
sinh(
) → Matrix -
Available on Matrix, provided by the MatrixFunctions extension
Element-wise sinh -
skewness(
) → num -
Available on Matrix, provided by the MatrixStatsExtension extension
Returns the skewness of the elements in the matrix. -
skip(
int count) → Iterable< List> -
Creates an Iterable that provides all but the first
count
elements.inherited -
skipWhile(
bool test(List value)) → Iterable< List> -
Creates an
Iterable
that skips leading elements whiletest
is satisfied.inherited -
slice(
int startRow, int endRow, [int? startCol, int? endCol]) → Matrix -
Available on Matrix, provided by the MatrixManipulationExtension extension
Returns a subMatrix that is a portion of the original matrix. -
sort(
{List< int> ? columnIndices, bool ascending = true}) → Matrix -
Available on Matrix, provided by the MatrixManipulationExtension extension
Sorts the matrix in ascending or descending order. -
split(
int axis, int splits) → List< Matrix> -
Available on Matrix, provided by the MatrixManipulationExtension extension
Splits the matrix into smaller matrices along the specified axis. -
standardDeviation(
) → dynamic -
Available on Matrix, provided by the MatrixStatsExtension extension
Returns the standard deviation of the elements in the matrix. -
subMatrix(
{List< int> ? rowIndices, List<int> ? columnIndices, String rowRange = '', String colRange = '', int? rowStart, int? rowEnd, int? colStart, int? colEnd}) → Matrix -
Available on Matrix, provided by the MatrixManipulationExtension extension
Extracts a subMatrix from the given matrix using the specified row and column indices or ranges. -
subtractVector(
Vector vector) → Matrix -
Available on Matrix, provided by the MatrixVectorOperations extension
Subtract a vector from a matrix -
sum(
{bool absolute = false, int? axis}) → dynamic -
Available on Matrix, provided by the MatrixOperationExtension extension
Calculates the sum of the elements in the matrix along the specified axis. -
swapColumns(
int col1, int col2) → void -
Available on Matrix, provided by the MatrixManipulationExtension extension
Swaps the position of two columns in the current matrix. -
swapRows(
int row1, int row2) → void -
Available on Matrix, provided by the MatrixManipulationExtension extension
Swaps the position of two rows in the current matrix. -
take(
int count) → Iterable< List> -
Creates a lazy iterable of the
count
first elements of this iterable.inherited -
takeWhile(
bool test(List value)) → Iterable< List> -
Creates a lazy iterable of the leading elements satisfying
test
.inherited -
tan(
) → Matrix -
Available on Matrix, provided by the MatrixFunctions extension
Element-wise tangent -
tanh(
) → Matrix -
Available on Matrix, provided by the MatrixFunctions extension
Element-wise tanh -
toBinary(
{bool jsonFormat = false}) → ByteData - Exporting to binary jsonFormat (optional): Set to true to use JSON string format, false to use binary format (default: false)
-
toCSV(
{String delimiter = ',', String? outputFilePath}) → Future< String> - Converts the Matrix to a CSV string and optionally saves it to a file.
-
toJSON(
{String? outputFilePath}) → String - Exporting to JSON
-
toList(
{bool growable = true}) → List< List> -
Creates a List containing the elements of this Iterable.
inherited
-
toSet(
) → Set< List> -
Creates a Set containing the same elements as this iterable.
inherited
-
toString(
{String separator = ' ', bool isPrettyMatrix = true, MatrixAlign alignment = MatrixAlign.right}) → String -
Returns a string representation of the matrix with its shape and elements separated by the specified separator.
override
-
toVector(
) → Vector -
Available on Matrix, provided by the MatrixVectorConversion extension
-
trace(
) → dynamic -
Available on Matrix, provided by the MatrixOperationExtension extension
Calculates the trace of a square matrix. -
transpose(
) → Matrix -
Available on Matrix, provided by the MatrixOperationExtension extension
Transposes the matrix by swapping rows and columns. -
tridiagonalize(
) → Matrix -
Available on Matrix, provided by the MatrixOperationExtension extension
Creates a tridiagonal matrix using the main diagonal, sub-diagonal, and super-diagonal elements of the current matrix. -
variance(
) → dynamic -
Available on Matrix, provided by the MatrixStatsExtension extension
Returns the variance of the elements in the matrix. -
where(
bool test(List element)) → Iterable< List> -
Creates a new lazy Iterable with all elements that satisfy the
predicate
test
.inherited -
whereType<
T> () → Iterable< T> -
Creates a new lazy Iterable with all elements that have type
T
.inherited
Operators
-
operator *(
dynamic other) → Matrix -
Available on Matrix, provided by the MatrixOperationExtension extension
Multiplies this matrix with another matrix or a scalar value. -
operator +(
dynamic other) → Matrix -
Available on Matrix, provided by the MatrixOperationExtension extension
Adds the given matrix to this matrix element-wise. -
operator -(
dynamic other) → Matrix -
Available on Matrix, provided by the MatrixOperationExtension extension
Subtracts the given matrix from this matrix element-wise. -
operator /(
dynamic other) → Matrix -
Available on Matrix, provided by the MatrixOperationExtension extension
Divides this matrix by a scalar value. -
operator ==(
Object other) → bool -
Compares two matrices for equality. Returns true if the matrices have the same dimensions and all elements are equal, otherwise false.
override
-
operator [](
int index) → List - Retrieves the specified row from the matrix.
-
operator []=(
int index, List value) → void - Assigns the value to the specified row index of the matrix.
-
operator ^(
int exponent) → Matrix -
Available on Matrix, provided by the MatrixOperationExtension extension
Raises this matrix to the power of the given exponent using exponentiation by squaring. -
operator unary-(
) → Matrix -
Available on Matrix, provided by the MatrixOperationExtension extension
Negates this matrix element-wise.
Static Properties
- factory → MatrixFactory
-
Static getter to retrieve the MatrixFactory object.
This object provides methods for generating special kinds of matrices like diagonal, identity etc.
no setter
Static Methods
-
compare(
Matrix matrix, String operator, dynamic value, {double tolerance = 1e-6}) → Matrix - Compares each element of the matrix to the specified value using the given comparison operator. Returns a new Matrix with boolean values as a result of the comparison.
-
distance(
Matrix m1, Matrix m2, {DistanceType distance = DistanceType.frobenius}) → dynamic - Computes the distance between two matrices.
-
fromBinary(
ByteData byteData, {bool jsonFormat = false}) → Matrix - Importing from binary byteData: ByteData object containing the matrix data jsonFormat (optional): Set to true to use JSON string format, false to use binary format (default: false)
-
fromCSV(
{String? csv, String delimiter = ',', String? inputFilePath}) → Future< Matrix> - Creates a Matrix object from a CSV string or a CSV file.
-
fromJSON(
{String? jsonString, String? inputFilePath}) → Matrix - Importing from JSON