Crates.io | mat-rs |
lib.rs | mat-rs |
version | 0.1.0 |
source | src |
created_at | 2024-01-16 10:34:43.304257 |
updated_at | 2024-01-16 10:34:43.304257 |
description | no_std implementation of mathematical matrix types |
homepage | |
repository | https://github.com/p2js/mat-rs |
max_upload_size | |
id | 1101493 |
size | 28,486 |
A no_std
implementation of mathematical matrix types in rust
This library is functional, but not done. There are a couple of things on the to-do list:
This library crate implements two types of matrices:
Mat<R, C>
, statically sized matrix types using const genericsDMat
, a dynamically sized matrix typeBoth of the matrix variants store f64
values internally.
Matrices can be initialised using the provided mat![]
and dmat![]
macros, or using some of the types' provided functions:
use mat_rs::mat::{mat, Mat};
let a = mat![
1, 2, 3;
4, 5, 6;
7, 8, 9;
]; //the type will be automatically inferred as Mat<3, 3>
let b = Mat::identity(3); //3x3 identity matrix
assert_eq(a*b, a);
println!("{}", a.determinant()); //0
For the statically sized Mat
s, operations are defined only on valid corresponding types.
For example, Mat<R, C>::add
will be defined only on matrices of the same types.
This also applies to commutative matrices for multiplication, and operations that are only valid on square matrices like determinants and inverses.
Dynamic matrices will currently panic on invalid operations, so it's up to the implementer to verify sizes if necessary before performing operations.