rl_matrix 0.0.1 rl_matrix: ^0.0.1 copied to clipboard
Provides an immutable matrix implementation for Dart, based on Java's JAMA package.
RL-matrix #
Provides an immutable matrix implementation for Dart, based on Java's JAMA package.
Usage #
Example:
var matrix = new Matrix([1, 2, 3,
4, 5, 6], 3);
var transpose = matrix.transpose;
var product = matrix * transpose;
For a complete overview of the operations available, have a look at the API documentation.
Dimension specific matrix classes #
You may want to create a custom matrix class, either to be able to leverage
Dart's type checker to enforce specific matrix dimensions, or to override
certain algorithms with more effective dimension specific implementations.
The abstract GenericMatrix
class can be extended for this purpose. The
GenericMatrix
class takes 2 type parameters: the extending class' type
(a self-bound) and the extending class' tranpose type. Also, two abstract
methods will need to be defined:
withValues
: needs to return a new matrix of the same type and with the same dimensions, with the given values.transposeWithValues
: needs to return a new matrix of the matrix's transpose type, with transposed dimensions, with the given values.
The following example implements a column vector:
class ColumnVector extends GenericMatrix<ColumnVector, RowVector> {
ColumnVector(List<num> values) : super.fromList(values, 1);
ColumnVector withValues(List<num> newValues) =>
new ColumnVector(newValues);
RowVector transposeWithValues(List<num> newValues) =>
new RowVector(newValues);
}