https://github.com/p2js/mat-rs
no_std implementation of mathematical matrix types in Rust
https://github.com/p2js/mat-rs
determinant-calculation matrices matrix matrix-library rust
Last synced: 3 months ago
JSON representation
no_std implementation of mathematical matrix types in Rust
- Host: GitHub
- URL: https://github.com/p2js/mat-rs
- Owner: p2js
- Created: 2024-01-16T10:31:30.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-01-16T10:48:18.000Z (over 1 year ago)
- Last Synced: 2025-01-16T06:56:45.417Z (4 months ago)
- Topics: determinant-calculation, matrices, matrix, matrix-library, rust
- Language: Rust
- Homepage: https://crates.io/crates/mat-rs
- Size: 13.7 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# mat-rs
A `no_std` implementation of mathematical matrix types in rust
## ⚠️ WIP
This library is functional, but not done. There are a couple of things on the to-do list:
- Implement the `to_inverse` (if even possible) and `inverse` methods for DMat
- Add doc comments for types and operations
- Add one-way interoperability between DMat and Mat (possibly through a common Matrix trait)## Features
This library crate implements two types of matrices:
- `Mat`, statically sized matrix types using const generics
- `DMat`, a dynamically sized matrix typeBoth of the matrix variants store `f64` values internally.
## Usage
Matrices can be initialised using the provided `mat![]` and `dmat![]` macros, or using some of the types' provided functions:
```rs
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::<3, 3>::identity(); //3x3 identity matrix
assert_eq(a*b, a);
println!("{}", a.determinant()); //0
```## Operations
For the statically sized `Mat`s, operations are defined only on valid corresponding types.
For example, `Mat::add` will be defined only on matrices of the same size.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.