Skip to main content

embedded_matrix/
error.rs

1use core::fmt;
2
3/// Error returned when a matrix operation is invalid.
4#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
5#[non_exhaustive]
6pub enum MatrixError {
7    /// The matrix is singular (its determinant is zero or dominated by
8    /// rounding error): inversion or solving (`inv`, `solve`) is impossible.
9    SingularMatrix,
10    /// The matrix (or the right-hand side of `solve`) contains NaN or ±∞,
11    /// or the calculation overflowed.
12    NonFiniteValue,
13}
14
15impl fmt::Display for MatrixError {
16    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
17        match self {
18            MatrixError::SingularMatrix => f.write_str("matrice singulière : inversion ou résolution impossible"),
19            MatrixError::NonFiniteValue => f.write_str("valeur non finie (NaN ou infini) ou débordement"),
20        }
21    }
22}
23
24impl core::error::Error for MatrixError {}