Expand description
§embedded-matrix
Matrices 2×2 et 3×3 en f32 pour systèmes embarqués no_std.
Sans dépendance, sans unsafe, sans allocation.
use embedded_matrix::{Matrix2x2, Matrix3x3, MatrixError};
// Produit matriciel avec l'opérateur *
let a = Matrix3x3::new([
[1.0, 2.0, 3.0],
[4.0, 5.0, 6.0],
[7.0, 8.0, 9.0],
]);
let b = Matrix3x3::identity();
assert_eq!(a * b, a);
// Addition, soustraction, scalaire
assert_eq!((a + b) - b, a);
let _double = a * 2.0;
// Matrice × vecteur
let v = Matrix2x2::identity() * [1.0, 2.0];
assert_eq!(v, [1.0, 2.0]);
// Inversion (Err si singulière ou non finie)
match Matrix2x2::new([[2.0, 0.0], [0.0, 4.0]]).inv() {
Ok(inv) => assert_eq!(inv, Matrix2x2::new([[0.5, 0.0], [0.0, 0.25]])),
Err(MatrixError::SingularMatrix) => { /* gérer */ }
Err(e) => panic!("{e}"),
}§Détection des matrices singulières
inv compare |det| à une borne relative à la taille des termes du
déterminant (et non à une constante absolue) : une matrice 1e-4 · I
reste inversible, alors qu’une matrice de grands coefficients dont le
déterminant n’est que du bruit d’arrondi est correctement rejetée.
Structs§
- Matrix2x2
- Matrice 2×2 en
f32, stockée en row-major. - Matrix3x3
- Matrice 3×3 en
f32, stockée en row-major.
Enums§
- Matrix
Error - Erreur retournée lors d’une opération invalide sur une matrice.