Skip to main content

Lu

Struct Lu 

Source
pub struct Lu<const D: usize> { /* private fields */ }
Expand description

LU decomposition (PA = LU) with partial pivoting.

Implementations§

Source§

impl<const D: usize> Lu<D>

Source

pub const fn solve_vec(&self, b: Vector<D>) -> Result<Vector<D>, LaError>

Solve A x = b using this LU factorization.

solve_vec performs floating-point forward/back substitution and does not provide a certified absolute rounding-error bound for the returned solution. Callers should not expect an absolute error bound like Matrix::det_errbound or the ERR_COEFF_* determinant constants provide.

§Examples
use la_stack::prelude::*;

let a = Matrix::<2>::try_from_rows([[1.0, 2.0], [3.0, 4.0]])?;
let lu = a.lu(DEFAULT_PIVOT_TOL)?;

let b = Vector::<2>::try_new([5.0, 11.0])?;
let x = lu.solve_vec(b)?.into_array();

assert!((x[0] - 1.0).abs() <= 1e-12);
assert!((x[1] - 2.0).abs() <= 1e-12);
§Errors

Returns LaError::NonFinite if the right-hand side contains NaN/infinity or a computed substitution intermediate overflows to NaN or infinity. The right-hand side is revalidated at this boundary before entering substitution; public callers normally encounter the same rejection earlier through Vector::try_new.

Source

pub const fn det(&self) -> Result<f64, LaError>

Determinant of the original matrix.

§Examples
use la_stack::prelude::*;

let a = Matrix::<2>::try_from_rows([[1.0, 2.0], [3.0, 4.0]])?;
let lu = a.lu(DEFAULT_PIVOT_TOL)?;

let det = lu.det()?;
assert!((det - (-2.0)).abs() <= 1e-12);
§Errors

Returns LaError::NonFinite if the determinant product overflows to NaN or infinity.

Trait Implementations§

Source§

impl<const D: usize> Clone for Lu<D>

Source§

fn clone(&self) -> Lu<D>

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<const D: usize> Copy for Lu<D>

Source§

impl<const D: usize> Debug for Lu<D>

Source§

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

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

impl<const D: usize> PartialEq for Lu<D>

Source§

fn eq(&self, other: &Lu<D>) -> 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<const D: usize> StructuralPartialEq for Lu<D>

Auto Trait Implementations§

§

impl<const D: usize> Freeze for Lu<D>

§

impl<const D: usize> RefUnwindSafe for Lu<D>

§

impl<const D: usize> Send for Lu<D>

§

impl<const D: usize> Sync for Lu<D>

§

impl<const D: usize> Unpin for Lu<D>

§

impl<const D: usize> UnsafeUnpin for Lu<D>

§

impl<const D: usize> UnwindSafe for Lu<D>

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, 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.