pub struct Lu<T> { /* private fields */ }Expand description
The LU decomposition P·A = L·U of an m × n matrix, by Gaussian elimination with partial
pivoting: P a permutation, L of m × min(m, n) lower triangular with ones on its
diagonal, U of min(m, n) × n upper triangular. From Matrix::lu.
§Examples
use a::math::matrix::Matrix;
let a = Matrix::from_rows(&[[2.0, 1.0], [4.0, 3.0]]);
let lu = a.lu();
// The larger first column's element is the pivot: the rows are swapped.
assert_eq!(lu.permutation(), [1, 0]);
assert_eq!(lu.l(), Matrix::from_rows(&[[1.0, 0.0], [0.5, 1.0]]));
assert_eq!(lu.u(), Matrix::from_rows(&[[4.0, 3.0], [0.0, -0.5]]));
assert_eq!(&lu.p() * &a, &lu.l() * &lu.u());
assert_eq!(lu.det(), 2.0);
let x = lu.solve(&Matrix::from_rows(&[[3.0], [7.0]])).unwrap();
assert_eq!(x, Matrix::from_rows(&[[1.0], [1.0]]));Implementations§
Source§impl<T: Scalar> Lu<T>
impl<T: Scalar> Lu<T>
Sourcepub fn permutation(&self) -> &[usize]
pub fn permutation(&self) -> &[usize]
The permutation: row i of P·A is row permutation()[i] of A.
Sourcepub fn is_singular(&self) -> bool
pub fn is_singular(&self) -> bool
Whether a pivot is zero, which for a square matrix makes it singular.
Sourcepub fn det(&self) -> T
pub fn det(&self) -> T
The determinant of the square matrix: the product of the pivots, negated for an odd permutation.
§Panics
Panics if the matrix is not square.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Lu<T>
impl<T> RefUnwindSafe for Lu<T>where
Matrix<T>: RefUnwindSafe,
impl<T> Send for Lu<T>
impl<T> Sync for Lu<T>
impl<T> Unpin for Lu<T>
impl<T> UnsafeUnpin for Lu<T>where
Matrix<T>: UnsafeUnpin,
impl<T> UnwindSafe for Lu<T>where
Matrix<T>: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more