Skip to main content

LaError

Enum LaError 

Source
#[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 enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

#[non_exhaustive]
Singular

A matrix is exactly or numerically singular.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§pivot_col: usize

Factorization column or step where a usable pivot was unavailable.

§reason: SingularityReason

Typed 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
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§location: NonFiniteLocation

Typed location of the value.

§origin: NonFiniteOrigin

Whether 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
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§index: Option<usize>

Failed vector component, or None for a scalar result.

§reason: UnrepresentableReason

Reason 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 enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§dim: usize

Matrix dimension D.

§min_exponent: i32

Minimum decomposed binary64 exponent among non-zero entries.

§

#[non_exhaustive]
UnsupportedDimension

A runtime matrix dimension has no stack-dispatch arm.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§requested: usize

Runtime dimension requested by the caller.

§max: usize

Largest dimension supported by the dispatch helper.

§

#[non_exhaustive]
IndexOutOfBounds

A matrix index is outside the D×D storage domain.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§row: usize

Requested row.

§col: usize

Requested column.

§dim: usize

Matrix dimension D; valid indices are less than this value.

§

#[non_exhaustive]
InvalidTolerance

A raw tolerance is negative or non-finite.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§value: f64

Raw value supplied by the caller.

§reason: InvalidToleranceReason

Typed 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 enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§row: usize

Row of the upper-triangular entry.

§col: usize

Column of the upper-triangular entry.

§dim: usize

Matrix dimension D.

§upper: f64

Observed entry at (row, col).

§lower: f64

Observed entry at (col, row).

§allowed_abs_diff: f64

Maximum absolute difference allowed by the symmetry check.

§

#[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
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§pivot_col: usize

LDLT pivot column or step where the violation was detected.

§violation: PositiveSemidefiniteViolation

Typed PSD-domain violation.

Implementations§

Source§

impl LaError

Source

pub const fn singular_exact(pivot_col: usize) -> Self

Construct a LaError::Singular error proving that the pivot at pivot_col is exactly zero.

Source

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.

Source

pub const fn non_finite_input_matrix(row: usize, col: usize) -> Self

Construct a LaError::NonFinite input error located at matrix cell (row, col).

Source

pub const fn non_finite_input_vector(index: usize) -> Self

Construct a LaError::NonFinite input error located at vector entry index.

Source

pub const fn non_finite_input_scalar() -> Self

Construct a LaError::NonFinite input error for a scalar without an index or matrix coordinate.

Source

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.

Source

pub const fn non_finite_computation_step( operation: ArithmeticOperation, index: usize, ) -> Self

Construct a LaError::NonFinite computation error at index, retaining the originating operation.

Source

pub const fn non_finite_computation_scalar( operation: ArithmeticOperation, ) -> Self

Construct a scalar LaError::NonFinite computation error retaining the originating operation.

Source

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(_)).

Source

pub const fn unrepresentable_reason(&self) -> Option<UnrepresentableReason>

Return the typed exact-to-f64 conversion reason, or None for every other error variant.

Source

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.

Source

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.

Source

pub const fn unsupported_dimension(requested: usize, max: usize) -> Self

Construct a LaError::UnsupportedDimension retaining the requested and maximum supported dimensions.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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§

Source§

impl Clone for LaError

Source§

fn clone(&self) -> LaError

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for LaError

Source§

impl Debug for LaError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for LaError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for LaError

1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl PartialEq for LaError

Source§

fn eq(&self, other: &LaError) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for LaError

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.