rl_matrix 0.6.5

  • README.md
  • Installing
  • Versions
  • 50


Provides an immutable implementation for matrices of real numbers in Dart, based on Java's JAMA package.

Build Status



// Instantiates the following matrix:
//     1.0 2.0 3.0
//     4.0 5.0 6.0
var matrix = new Matrix([
  [1.0, 2.0, 3.0],
  [4.0, 5.0, 6.0]

var transpose = matrix.transpose;
var product = matrix * transpose;

For a complete overview of the operations available, have a look at the API documentation for the Matrix class.

RL-matrix Change Log


  • BREAKING: removes GenericMatrixclass. This felt like a really over-engineered solution and required some leakiness with regards to the immutability. The core of this library is now much less complex. If you were using GenericMatrix, please open an issue.

  • BREAKING: removes Matrix.withValues. Was only necessary to support the GenericMatrix construct.

  • BREAKING: removes Matrix.withValuesTranspose. Was only necessary to support the GenericMatrix construct.

  • BREAKING: removes fromFloat32List constructor. Use fromList instead.

  • BREAKING: removes [] operator from matrix class. Use Matrix.rowAt instead.

  • BREAKING: replaces Matrix's default constructor. The default constructor now takes a list of lists:

    var matrix = new Matrix([
      [1.0, 2.0, 3.0],
      [4.0, 5.0, 6.0],
      [7.0, 8.0, 9.0]

    Each list represents a row in the matrix. All row lists must of of equal length.

    The Matrix class' default constructor behaved identically to the fromList constructor. The simplest way to fix existing code that used the default constructor is to run a "replace all" for new Matrix( with new Matrix.fromList(.

This release includes some sweeping breaking changes. However, I feel these changes address most of the issues I had with the library in its prior state.


Changes the rowEnd and colEnd indices for subMatrix from being inclusive to being exclusive. This matches conventions in the Dart standard library.

This means that the rowEnd and colEnd indices need to be incremented by one, e.g.:

matrix.subMatrix(0, 2, 0, 2);


matrix.subMatrix(0, 3, 0, 3);


Adds auto-generated implementation using Float64List for better precision.


BC break: as of this version, the matrix implementation uses a Float32List for value memory. This should constitute a significant performance boost, but also means that matrices now need to be instantiated with double values and can no longer be instantiated with int values:

var matrix = new Matrix([1, 2, 3,
                         4, 5, 6], 3);

// Needs to be replaced with:

var matrix = new Matrix([1.0, 2.0, 3.0,
                         4.0, 5.0, 6.0], 3);


BC break: the brackets operator [] implementation was removed from GenericMatrix and added to Matrix. It's now up to a subclass of GenericMatrix whether or not to implement the [] operator and to decide what the return type should be:

class ColumnVector extends GenericMatrix<ColumnVector, RowVector> {

  num operator [](int index) => valueAt(index, 0);


Adds a brackets [] operator to matrices. This allows you to get the value at a specific position in the matrix:

var matrix = new Matrix([1, 2, 3,
                         4, 5, 6], 3);
print(matrix[1][2]); // 6

Rows and columns are zero indexed, so [0][0] is the top left value.

Also adds a custom equality == operator, which will find 2 matrices to be equal if their dimensions are equal and they contain the same values.

var matrix1 = new Matrix([1, 2, 3,
                          4, 5, 6], 3);
var matrix2 = new Matrix([1, 2, 3,
                          4, 5, 6], 3);
print(matrix1 == matrix2); // true

It does not check the matrix object types, so an instance of a custom subclass of GenericMatrix may still be equal to an instance of Matrix if the dimensions and values match.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  rl_matrix: "^0.6.5"

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

      import 'package:rl_matrix/rl_matrix.dart';
Version Uploaded Documentation Archive
0.6.5 Jun 29, 2017 Go to the documentation of rl_matrix 0.6.5 Download rl_matrix 0.6.5 archive
0.6.4 Dec 1, 2016 Go to the documentation of rl_matrix 0.6.4 Download rl_matrix 0.6.4 archive
0.6.3 Dec 1, 2016 Go to the documentation of rl_matrix 0.6.3 Download rl_matrix 0.6.3 archive
0.6.2 Aug 15, 2016 Go to the documentation of rl_matrix 0.6.2 Download rl_matrix 0.6.2 archive
0.6.1 Aug 4, 2016 Go to the documentation of rl_matrix 0.6.1 Download rl_matrix 0.6.1 archive
0.6.0 Aug 3, 2016 Go to the documentation of rl_matrix 0.6.0 Download rl_matrix 0.6.0 archive
0.5.4 Jul 31, 2016 Go to the documentation of rl_matrix 0.5.4 Download rl_matrix 0.5.4 archive
0.5.3 Jun 29, 2016 Go to the documentation of rl_matrix 0.5.3 Download rl_matrix 0.5.3 archive
0.5.2 May 7, 2016 Go to the documentation of rl_matrix 0.5.2 Download rl_matrix 0.5.2 archive
0.5.1 May 3, 2016 Go to the documentation of rl_matrix 0.5.1 Download rl_matrix 0.5.1 archive

All 23 versions...


We analyzed this package on Jun 19, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.63.0
  • pana: 0.11.3


Describes how popular the package is relative to other packages. [more]
1 / 100
Code health derived from static analysis. [more]
100 / 100
Reflects how tidy and up-to-date the package is. [more]
100 / 100
Overall score:
Weighted score of the above. [more]
Learn more about scoring.


Detected platforms: Flutter, web, other

No platform restriction found in primary library package:rl_matrix/rl_matrix.dart.


  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Maintain an example.

    Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use rl_matrix.dart.

  • Use analysis_options.yaml.

    Rename old .analysis_options file to analysis_options.yaml.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.19.0 <2.0.0
collection ^1.14.0 1.14.10
quiver ^0.25.0 0.25.0 0.29.0+1
Transitive dependencies
matcher 0.12.3
stack_trace 1.9.2
Dev dependencies
path ^1.4.0 1.6.1
test ^0.12.0