Skip to main content

LaError

Enum LaError 

Source
#[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
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.
§

Singular

The matrix is (numerically) singular.

Fields

§pivot_col: usize

The factorization column/step where a suitable pivot/diagonal could not be found.

§

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

§row: Option<usize>

Row of the non-finite entry for a stored matrix cell, or None for a vector-input entry or a computed intermediate. See the variant docs for the full convention.

§col: usize

Column index (stored cell), vector index, or factorization/solve step where the non-finite value was detected.

§

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

§index: Option<usize>

For vector results (e.g. solve_exact_f64), the index of the component that overflowed. None for scalar results.

§

UnsupportedDimension

A requested runtime matrix dimension has no stack-dispatch arm.

Fields

§requested: usize

Runtime dimension requested by the caller.

§max: usize

Largest runtime dimension supported by the dispatch helper.

§

IndexOutOfBounds

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

Fields

§row: usize

Requested row index.

§col: usize

Requested column index.

§dim: usize

Matrix dimension D; valid row and column indices are < dim.

§

InvalidTolerance

A tolerance value is not finite and non-negative.

Fields

§value: f64

Raw tolerance supplied by the caller.

§

Asymmetric

A matrix required to be symmetric has an asymmetric off-diagonal pair.

Fields

§row: usize

Row index of the first asymmetric pair.

§col: usize

Column index of the first asymmetric pair.

§dim: usize

Matrix dimension D.

§

NotPositiveSemidefinite

A symmetric matrix failed the positive-semidefinite LDLT domain check.

Fields

§pivot_col: usize

Factorization column/step where a negative LDLT diagonal was found.

§value: f64

Negative diagonal value observed at that step.

Implementations§

Source§

impl LaError

Source

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,
    }
);
Source

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 }
);
Source

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,
    }
);
Source

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,
    }
);
Source

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 }
);
Source

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,
    }
);
Source

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,
    }
);
Source

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§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
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.