Struct LUDecomposition

Source
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>

Source

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

Source

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

Source

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

Source

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>

Source§

fn clone(&self) -> LUDecomposition<T, N>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug + Copy, const N: usize> Debug for LUDecomposition<T, N>

Source§

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

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

impl<T: PartialEq + Copy, const N: usize> PartialEq for LUDecomposition<T, N>

Source§

fn eq(&self, other: &LUDecomposition<T, N>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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<T: Copy + Copy, const N: usize> Copy for LUDecomposition<T, N>

Source§

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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