A small 2D f64 matrix library.
There are many like it, but this one is mine.
```rust use matrijs::Matrix;
// m = | 0.0 1.0 | // |-1.0 0.0 | let mut m = Matrix::new(2, 2, &[0.0, 1.0, -1.0, 0.0]); m += 1.0; assert_eq!(m, Matrix::new(2, 2, &[1.0, 2.0, 0.0, 1.0]));
// a = | 0.0 1.0 | // | 2.0 3.0 | // b = | 4.0 5.0 6.0 | // | 7.0 8.0 9.0 | let a = Matrix::new(2, 2, &[0.0, 1.0, 2.0, 3.0]); let b = Matrix::new(2, 3, &[4.0, 5.0, 6.0, 7.0, 8.0, 9.0]);
// Multiplication of i
and a
should be idempotent.
let i = Matrix::identity(2);
assert_eq!(i.dot(&a), a);
assert_eq!(a.dot(&b), Matrix::new(2, 3, &[7.0, 8.0, 9.0, 29.0, 34.0, 39.0])); ```
Matrix::new(3, 2, &[0.0, 1.0, 2.0, 3.0, 4.0, 5.0])
Matrix::with_value(3, 16.1)
Matrix::zero(3)
Matrix::one(3)
Matrix::identity(3)
Matrix::diagonal(&[1.0, 3.0, 1.0, 2.0])
m.transpose();
m.t()
b = a + 1.0
, b *= 2
a + b
a.dot(&b)
The internal data structure is a Vec
of entries, row after row.
That means that this is a row-major implementation.
In Dutch, there is a word matrijs (pronounce mat-rice) which has a common ancestor with the word matrix. Matrijs refers to molds or stamps, often when laid out in arrays.
I like the name for this library, because it contains the 'ij' digraph, which is very similar to the letters i and j as seen in notation for entries in a matrix, such as aij.