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>
impl<const D: usize> Lu<D>
Sourcepub const fn solve_vec(&self, b: Vector<D>) -> Result<Vector<D>, LaError>
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.
Sourcepub const fn det(&self) -> Result<f64, LaError>
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.