#[non_exhaustive]pub enum LaError {
Singular {
pivot_col: usize,
},
NonFinite {
row: Option<usize>,
col: usize,
},
Overflow {
index: Option<usize>,
},
UnsupportedDimension {
requested: usize,
max: usize,
},
IndexOutOfBounds {
row: usize,
col: usize,
dim: usize,
},
InvalidTolerance {
value: f64,
},
Asymmetric {
row: usize,
col: usize,
dim: usize,
},
NotPositiveSemidefinite {
pivot_col: usize,
value: f64,
},
}Expand description
Linear algebra errors.
This enum is #[non_exhaustive] — downstream match arms must include a
wildcard (_) pattern to compile, allowing new variants to be added in
future minor releases without breaking existing code.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Singular
The matrix is (numerically) singular.
Fields
NonFinite
A non-finite value (NaN/∞) was encountered.
The (row, col) coordinate follows a consistent convention across the crate:
row: Some(r), col: c— the non-finite value is tied to a matrix/factor cell at(r, c), either because a stored input/factor cell is already non-finite or because factorization computed a non-finite value for that cell before storing it.row: None, col: c— the non-finite value is tied to a vector entry, determinant product, tolerance-scale accumulator, solve accumulator, or other scalar/intermediate that has no matrix row coordinate.
Fields
Overflow
The exact result overflows the target representation (e.g. f64).
Returned by Matrix::det_exact_f64 and Matrix::solve_exact_f64
(requires exact feature) when an exact value is too large to
represent as a finite f64.
Fields
UnsupportedDimension
A requested runtime matrix dimension has no stack-dispatch arm.
Fields
IndexOutOfBounds
A matrix index is outside the D×D storage domain.
Fields
InvalidTolerance
A tolerance value is not finite and non-negative.
Asymmetric
A matrix required to be symmetric has an asymmetric off-diagonal pair.
Fields
NotPositiveSemidefinite
A symmetric matrix failed the positive-semidefinite LDLT domain check.
Implementations§
Source§impl LaError
impl LaError
Sourcepub const fn non_finite_cell(row: usize, col: usize) -> Self
pub const fn non_finite_cell(row: usize, col: usize) -> Self
Construct a LaError::NonFinite pinpointing a stored matrix cell at (row, col).
Use this for non-finite values read from a stored Matrix entry or
factorization cell, and for non-finite factorization updates that would
be stored at (row, col) if accepted. The resulting error has
row: Some(row), col, matching the matrix/factor-cell convention
documented on NonFinite. For vector-input entries
or scalar intermediates without a matrix row coordinate, use
non_finite_at.
§Examples
use la_stack::prelude::*;
assert_eq!(
LaError::non_finite_cell(1, 2),
LaError::NonFinite {
row: Some(1),
col: 2,
}
);Sourcepub const fn non_finite_at(col: usize) -> Self
pub const fn non_finite_at(col: usize) -> Self
Construct a LaError::NonFinite pinpointing a vector-input entry or
computed scalar/intermediate at index col.
Use this for non-finite values in a Vector input, determinant scalar,
tolerance-scale accumulator, or solve accumulator that overflowed during
forward/back substitution. The resulting error has row: None, col,
matching the vector/scalar-intermediate convention documented on
NonFinite. For stored matrix cells or computed
factorization updates tied to a matrix cell, use
non_finite_cell.
§Examples
use la_stack::prelude::*;
assert_eq!(
LaError::non_finite_at(2),
LaError::NonFinite { row: None, col: 2 }
);Sourcepub const fn unsupported_dimension(requested: usize, max: usize) -> Self
pub const fn unsupported_dimension(requested: usize, max: usize) -> Self
Construct a LaError::UnsupportedDimension for runtime stack dispatch.
§Examples
use la_stack::prelude::*;
assert_eq!(
LaError::unsupported_dimension(8, MAX_STACK_MATRIX_DISPATCH_DIM),
LaError::UnsupportedDimension {
requested: 8,
max: MAX_STACK_MATRIX_DISPATCH_DIM,
}
);Sourcepub const fn index_out_of_bounds(row: usize, col: usize, dim: usize) -> Self
pub const fn index_out_of_bounds(row: usize, col: usize, dim: usize) -> Self
Construct a LaError::IndexOutOfBounds for a D×D matrix index.
§Examples
use la_stack::prelude::*;
assert_eq!(
LaError::index_out_of_bounds(2, 0, 2),
LaError::IndexOutOfBounds {
row: 2,
col: 0,
dim: 2,
}
);Sourcepub const fn invalid_tolerance(value: f64) -> Self
pub const fn invalid_tolerance(value: f64) -> Self
Construct a LaError::InvalidTolerance for a raw tolerance value.
§Examples
use la_stack::prelude::*;
assert_eq!(
LaError::invalid_tolerance(-1.0),
LaError::InvalidTolerance { value: -1.0 }
);Sourcepub const fn asymmetric(row: usize, col: usize, dim: usize) -> Self
pub const fn asymmetric(row: usize, col: usize, dim: usize) -> Self
Construct a LaError::Asymmetric for a D×D matrix.
§Examples
use la_stack::prelude::*;
assert_eq!(
LaError::asymmetric(0, 1, 3),
LaError::Asymmetric {
row: 0,
col: 1,
dim: 3,
}
);Sourcepub const fn not_positive_semidefinite(pivot_col: usize, value: f64) -> Self
pub const fn not_positive_semidefinite(pivot_col: usize, value: f64) -> Self
Construct a LaError::NotPositiveSemidefinite for LDLT factorization.
§Examples
use la_stack::prelude::*;
assert_eq!(
LaError::not_positive_semidefinite(1, -3.0),
LaError::NotPositiveSemidefinite {
pivot_col: 1,
value: -3.0,
}
);Sourcepub const fn validate_tolerance(value: f64) -> Result<Tolerance, Self>
pub const fn validate_tolerance(value: f64) -> Result<Tolerance, Self>
Parse a raw tolerance into a finite, non-negative Tolerance.
§Examples
use la_stack::prelude::*;
assert_eq!(LaError::validate_tolerance(1e-12)?.get(), 1e-12);
let raw = 0.0;
let tol = LaError::validate_tolerance(raw)?;
let _lu = Matrix::<2>::identity().lu(tol)?;
assert_eq!(
LaError::validate_tolerance(-1.0),
Err(LaError::InvalidTolerance { value: -1.0 })
);§Errors
Returns LaError::InvalidTolerance when value is NaN, infinite, or
negative.
Trait Implementations§
impl Copy for LaError
Source§impl Error for LaError
impl Error for LaError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()