dartora

Matrix

Matrix represents a two‑dimensional array of numbers and supports common matrix operations. It is built on top of the Iteration<num> mixin, allowing you to iterate over its elements in row‑major order and to use slicing functionality from the collections module.

Construction

factory Matrix(List<List<num>> rows)

Creates a matrix from a list of rows. All rows must have the same length. A private constructor caches the matrix and initialises iteration state. Matrix.empty() returns a 0×0 matrix.

Properties

Element access

Matrix arithmetic

Determinant and derived matrices

Notes

Matrix is immutable; all operations return new matrices. Internally caches the determinant, transpose, inverse and other derived matrices on first computation to avoid recomputation. Iteration over a matrix yields its elements in row‑major order, making it compatible with the Iteration framework.