#[non_exhaustive]pub enum LaError {
#[non_exhaustive] Singular {
pivot_col: usize,
reason: SingularityReason,
},
#[non_exhaustive] NonFinite {
location: NonFiniteLocation,
origin: NonFiniteOrigin,
},
#[non_exhaustive] Unrepresentable {
index: Option<usize>,
reason: UnrepresentableReason,
},
#[non_exhaustive] DeterminantScaleOverflow {
dim: usize,
min_exponent: i32,
},
#[non_exhaustive] UnsupportedDimension {
requested: usize,
max: usize,
},
#[non_exhaustive] IndexOutOfBounds {
row: usize,
col: usize,
dim: usize,
},
#[non_exhaustive] InvalidTolerance {
value: f64,
reason: InvalidToleranceReason,
},
#[non_exhaustive] Asymmetric {
row: usize,
col: usize,
dim: usize,
upper: f64,
lower: f64,
allowed_abs_diff: f64,
},
#[non_exhaustive] NotPositiveSemidefinite {
pivot_col: usize,
violation: PositiveSemidefiniteViolation,
},
}Expand description
Linear algebra errors.
This enum and each struct-style variant are #[non_exhaustive] so downstream
matches must retain a wildcard for future error categories and fields.
§Examples
use la_stack::prelude::*;
match LaError::singular_exact(2) {
LaError::Singular {
pivot_col,
reason: SingularityReason::Exact,
..
} => assert_eq!(pivot_col, 2),
_ => unreachable!("constructor returns an exact singularity"),
}Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
#[non_exhaustive]Singular
A matrix is exactly or numerically singular.
Fields
This variant is marked as non-exhaustive
reason: SingularityReasonTyped reason for the singularity classification.
#[non_exhaustive]NonFinite
A caller input or arithmetic result is NaN or infinite.
Fields
This variant is marked as non-exhaustive
location: NonFiniteLocationTyped location of the value.
origin: NonFiniteOriginWhether the value came from input or a particular computation.
#[non_exhaustive]Unrepresentable
An exact result cannot satisfy the requested finite-f64 conversion.
Fields
This variant is marked as non-exhaustive
reason: UnrepresentableReasonReason the conversion contract cannot be satisfied.
#[non_exhaustive]DeterminantScaleOverflow
Exact determinant scaling overflowed the internal exponent representation.
Fields
This variant is marked as non-exhaustive
#[non_exhaustive]UnsupportedDimension
A runtime matrix dimension has no stack-dispatch arm.
Fields
This variant is marked as non-exhaustive
#[non_exhaustive]IndexOutOfBounds
A matrix index is outside the D×D storage domain.
Fields
This variant is marked as non-exhaustive
#[non_exhaustive]InvalidTolerance
A raw tolerance is negative or non-finite.
Fields
This variant is marked as non-exhaustive
reason: InvalidToleranceReasonTyped reason the value violates the tolerance invariant.
#[non_exhaustive]Asymmetric
A matrix required to be symmetric has an asymmetric off-diagonal pair.
Fields
This variant is marked as non-exhaustive
#[non_exhaustive]NotPositiveSemidefinite
A computed LDLT pivot violates the no-pivot positive-semidefinite factorization requirements.
This diagnoses a binary64 factorization rejection; it is not an exact certificate that the stored matrix is indefinite.
Fields
This variant is marked as non-exhaustive
violation: PositiveSemidefiniteViolationTyped PSD-domain violation.
Implementations§
Source§impl LaError
impl LaError
Sourcepub const fn singular_exact(pivot_col: usize) -> Self
pub const fn singular_exact(pivot_col: usize) -> Self
Construct a LaError::Singular error proving that the pivot at
pivot_col is exactly zero.
Sourcepub const fn singular_numerical(
pivot_col: usize,
factorization: FactorizationKind,
pivot_magnitude: f64,
tolerance: f64,
) -> Self
pub const fn singular_numerical( pivot_col: usize, factorization: FactorizationKind, pivot_magnitude: f64, tolerance: f64, ) -> Self
Construct a LaError::Singular error for a pivot rejected by a
factorization tolerance, preserving the factorization, pivot magnitude,
and tolerance in SingularityReason::Numerical.
Sourcepub const fn non_finite_input_matrix(row: usize, col: usize) -> Self
pub const fn non_finite_input_matrix(row: usize, col: usize) -> Self
Construct a LaError::NonFinite input error located at matrix cell
(row, col).
Sourcepub const fn non_finite_input_vector(index: usize) -> Self
pub const fn non_finite_input_vector(index: usize) -> Self
Construct a LaError::NonFinite input error located at vector entry
index.
Sourcepub const fn non_finite_input_scalar() -> Self
pub const fn non_finite_input_scalar() -> Self
Construct a LaError::NonFinite input error for a scalar without an
index or matrix coordinate.
Sourcepub const fn non_finite_computation_matrix(
operation: ArithmeticOperation,
row: usize,
col: usize,
) -> Self
pub const fn non_finite_computation_matrix( operation: ArithmeticOperation, row: usize, col: usize, ) -> Self
Construct a LaError::NonFinite computation error at matrix cell
(row, col), retaining the originating operation.
Sourcepub const fn non_finite_computation_step(
operation: ArithmeticOperation,
index: usize,
) -> Self
pub const fn non_finite_computation_step( operation: ArithmeticOperation, index: usize, ) -> Self
Construct a LaError::NonFinite computation error at index,
retaining the originating operation.
Sourcepub const fn non_finite_computation_scalar(
operation: ArithmeticOperation,
) -> Self
pub const fn non_finite_computation_scalar( operation: ArithmeticOperation, ) -> Self
Construct a scalar LaError::NonFinite computation error retaining
the originating operation.
Sourcepub const fn unrepresentable(
index: Option<usize>,
reason: UnrepresentableReason,
) -> Self
pub const fn unrepresentable( index: Option<usize>, reason: UnrepresentableReason, ) -> Self
Construct a LaError::Unrepresentable conversion failure for a scalar
(index = None) or vector component (index = Some(_)).
Sourcepub const fn unrepresentable_reason(&self) -> Option<UnrepresentableReason>
pub const fn unrepresentable_reason(&self) -> Option<UnrepresentableReason>
Return the typed exact-to-f64 conversion reason, or None for every
other error variant.
Sourcepub const fn requires_rounding(&self) -> bool
pub const fn requires_rounding(&self) -> bool
Return whether this is a RequiresRounding conversion failure for which
retrying with an explicit rounded API may succeed.
Sourcepub const fn determinant_scale_overflow(dim: usize, min_exponent: i32) -> Self
pub const fn determinant_scale_overflow(dim: usize, min_exponent: i32) -> Self
Construct a LaError::DeterminantScaleOverflow retaining the matrix
dimension and minimum decomposed entry exponent.
Sourcepub const fn unsupported_dimension(requested: usize, max: usize) -> Self
pub const fn unsupported_dimension(requested: usize, max: usize) -> Self
Construct a LaError::UnsupportedDimension retaining the requested
and maximum supported dimensions.
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 retaining the requested matrix
coordinates and dimension.
Sourcepub const fn invalid_tolerance(value: f64) -> Self
pub const fn invalid_tolerance(value: f64) -> Self
Construct an invalid-tolerance error and classify its typed reason.
This low-level constructor assumes value has already failed the
tolerance invariant; raw caller input should normally be parsed through
crate::Tolerance::try_new.
Non-finiteness takes precedence over negativity, so negative infinity is
classified as InvalidToleranceReason::NotFinite.
Sourcepub const fn asymmetric(
row: usize,
col: usize,
dim: usize,
upper: f64,
lower: f64,
allowed_abs_diff: f64,
) -> Self
pub const fn asymmetric( row: usize, col: usize, dim: usize, upper: f64, lower: f64, allowed_abs_diff: f64, ) -> Self
Construct a LaError::Asymmetric error for the pair (row, col) and
(col, row), retaining both observed values and the effective absolute
difference bound.
Sourcepub const fn not_positive_semidefinite_negative(
pivot_col: usize,
value: f64,
) -> Self
pub const fn not_positive_semidefinite_negative( pivot_col: usize, value: f64, ) -> Self
Construct a LaError::NotPositiveSemidefinite error for a computed
negative LDLT diagonal pivot.
Sourcepub const fn not_positive_semidefinite_zero_coupling(
pivot_col: usize,
row: usize,
value: f64,
) -> Self
pub const fn not_positive_semidefinite_zero_coupling( pivot_col: usize, row: usize, value: f64, ) -> Self
Construct a LaError::NotPositiveSemidefinite error for a computed
zero LDLT diagonal with a non-zero coupling at row, distinguishing the
observed factorization violation from an uncoupled singular pivot.
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()