pub struct CholeskyFactorizer<T> { /* private fields */ }Expand description
Cholesky factoriser
Implementations§
Source§impl<T: Float> CholeskyFactorizer<T>
impl<T: Float> CholeskyFactorizer<T>
Sourcepub fn new(n: usize) -> Self
pub fn new(n: usize) -> Self
Create a factorizer with storage preallocated for an n x n matrix.
Sourcepub fn factorize(&mut self, a: &[T]) -> Result<(), CholeskyError>
pub fn factorize(&mut self, a: &[T]) -> Result<(), CholeskyError>
Compute the Cholesky factorization $A = L L^\intercal$ from a square matrix in row-major order.
The input matrix must have dimension equal to the one used in new(n).
Sourcepub fn cholesky_factor(&self) -> &[T]
pub fn cholesky_factor(&self) -> &[T]
Cholesky factor, L
Sourcepub fn solve(&self, b: &[T]) -> Result<Vec<T>, CholeskyError>
pub fn solve(&self, b: &[T]) -> Result<Vec<T>, CholeskyError>
Solves the linear system $A x = b$ using the stored Cholesky factorization $A = L L^\intercal$.
This method assumes that Self::factorize has already been called successfully,
so that the lower-triangular Cholesky factor L is available internally.
The solution is computed in two steps:
- Forward substitution to solve $L y = b$
- Back substitution to solve $L^\intercal x = y$
§Arguments
b- Right-hand-side vector of lengthn
§Returns
Returns the solution vector x such that $A x = b$.
§Errors
Returns an error in the following cases:
CholeskyError::NotFactorizedif no valid Cholesky factorization is currently stored in the factorizerCholeskyError::DimensionMismatchifb.len() != n, wherenis the matrix dimension
§Notes
- The matrix
Aitself is not accessed directly; only its Cholesky factorLis used. - The Cholesky factor is stored internally in row-major order.
- This method allocates temporary vectors for the intermediate solution
yand the final solutionx.
Trait Implementations§
Source§impl<T: Clone> Clone for CholeskyFactorizer<T>
impl<T: Clone> Clone for CholeskyFactorizer<T>
Source§fn clone(&self) -> CholeskyFactorizer<T>
fn clone(&self) -> CholeskyFactorizer<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl<T> Freeze for CholeskyFactorizer<T>
impl<T> RefUnwindSafe for CholeskyFactorizer<T>where
T: RefUnwindSafe,
impl<T> Send for CholeskyFactorizer<T>where
T: Send,
impl<T> Sync for CholeskyFactorizer<T>where
T: Sync,
impl<T> Unpin for CholeskyFactorizer<T>where
T: Unpin,
impl<T> UnsafeUnpin for CholeskyFactorizer<T>
impl<T> UnwindSafe for CholeskyFactorizer<T>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
Mutably borrows from an owned value. Read more