pub struct LUDecomposition<T: Copy, const N: usize> {
pub lu: Matrix<T, N, N>,
pub idx: Vector<usize, N>,
pub parity: Parity,
}
Expand description
The result of the LU decomposition of a matrix.
This struct provides a convenient way to reuse one LU decomposition to solve multiple matrix equations. You likely do not need to worry about its contents.
See LU decomposition on wikipedia for more information
Fields§
§lu: Matrix<T, N, N>
The $bbL$ and $bbU$ matrices combined into one
for example if
$ bbU = [[u_{11}, u_{12}, cdots, u_{1n} ], [0, u_{22}, cdots, u_{2n} ], [vdots, vdots, ddots, vdots ], [0, 0, cdots, u_{mn} ]] $ and $ bbL = [[1, 0, cdots, 0 ], [l_{21}, 1, cdots, 0 ], [vdots, vdots, ddots, vdots ], [l_{m1}, l_{m2}, cdots, 1 ]] $, then $ bb{LU} = [[u_{11}, u_{12}, cdots, u_{1n} ], [l_{21}, u_{22}, cdots, u_{2n} ], [vdots, vdots, ddots, vdots ], [l_{m1}, l_{m2}, cdots, u_{mn} ]] $
note that the diagonals of the $bbL$ matrix are always 1, so no information is lost
idx: Vector<usize, N>
The indices of the permutation matrix $bbP$, such that $bbP xx bbA$ = $bbL xx bbU$
The permutation matrix rearranges the rows of the original matrix in order to produce the LU decomposition. This makes calculation simpler, but makes the result (known as an LUP decomposition) no longer unique
parity: Parity
The parity of the decomposition.
Implementations§
Source§impl<T: Copy + Default + Real, const N: usize> LUDecomposition<T, N>
impl<T: Copy + Default + Real, const N: usize> LUDecomposition<T, N>
Sourcepub fn solve<const M: usize>(&self, b: &Matrix<T, N, M>) -> Matrix<T, N, M>
pub fn solve<const M: usize>(&self, b: &Matrix<T, N, M>) -> Matrix<T, N, M>
Solve for $x$ in $bbM xx x = b$, where $bbM$ is the original matrix this is a decomposition of.
This is equivalent to LUDecompose::solve
while allowing the LU decomposition
to be reused
Sourcepub fn det(&self) -> T
pub fn det(&self) -> T
Calculate the determinant $|M|$ of the matrix $M$. If the matrix is singular, the determinant is 0.
This is equivalent to LUDecompose::det
while allowing the LU decomposition
to be reused
Sourcepub fn inv(&self) -> Matrix<T, N, N>
pub fn inv(&self) -> Matrix<T, N, N>
Calculate the inverse of the original matrix, such that $bbM xx bbM^{-1} = bbI$
This is equivalent to Matrix::inv
while allowing the LU decomposition to be reused
Sourcepub fn separate(&self) -> (Matrix<T, N, N>, Matrix<T, N, N>)
pub fn separate(&self) -> (Matrix<T, N, N>, Matrix<T, N, N>)
Separate the $L$ and $U$ sides of the $LU$ matrix.
See the lu
field for more information
Trait Implementations§
Source§impl<T: Clone + Copy, const N: usize> Clone for LUDecomposition<T, N>
impl<T: Clone + Copy, const N: usize> Clone for LUDecomposition<T, N>
Source§fn clone(&self) -> LUDecomposition<T, N>
fn clone(&self) -> LUDecomposition<T, N>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreimpl<T: Copy + Copy, const N: usize> Copy for LUDecomposition<T, N>
impl<T: Copy, const N: usize> StructuralPartialEq for LUDecomposition<T, N>
Auto Trait Implementations§
impl<T, const N: usize> Freeze for LUDecomposition<T, N>where
T: Freeze,
impl<T, const N: usize> RefUnwindSafe for LUDecomposition<T, N>where
T: RefUnwindSafe,
impl<T, const N: usize> Send for LUDecomposition<T, N>where
T: Send,
impl<T, const N: usize> Sync for LUDecomposition<T, N>where
T: Sync,
impl<T, const N: usize> Unpin for LUDecomposition<T, N>where
T: Unpin,
impl<T, const N: usize> UnwindSafe for LUDecomposition<T, N>where
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more