linalg::factor::cholesky
Cholesky (A = L L^H) and the square-root-free LDL^H, both row by row (left-looking: each entry is one inner product of rows already done), reading only the lower triangle. Cholesky is backward stable for any positive definite matrix; O(n^3/3).
Structs
CholeskySource
pub struct Cholesky<T>A = L L^H of a Hermitian (real: symmetric) positive definite
matrix, L lower triangular with a positive diagonal. Only the lower
triangle of A is read.
use core::array::{Matrix, Vector};
let a: Matrix<f64> = [[4, 2], [2, 5]];
let c = try linalg::cholesky(a);
assert(c.l()[1, 0] == 1.0 && c.l()[1, 1] == 2.0);
let b: Vector<f64> = [6, 7];
assert(try c.solve(b) == Vector::<f64>::from([1.0, 1.0]));
The lower factor
L.
Sourcepub fn solve<B: Rhs<T>>(§self, b: B) throws (LinalgError) -> B xwithA x = b.
Sourcepub fn inv(§self) throws (LinalgError) -> Matrix<T> A^-1.det(A), the squared product ofL's diagonal.ln det(A), without the overflow ofdetfor large matrices.
LdltSource
pub struct Ldlt<T>A = L D L^H without pivoting: L unit lower triangular, D real
diagonal. Needs nonzero leading minors (true for positive definite
and quasi-definite matrices); for a general symmetric indefinite
matrix use lu, which pivots. Only the lower triangle is read.
use core::array::Matrix;
let a: Matrix<f64> = [[4, 2], [2, -1]];
let f = try linalg::ldlt(a);
assert(f.d()[0] == 4.0 && f.d()[1] == -2.0);
The unit lower factor
L.The diagonal of
D.
Sourcepub fn solve<B: Rhs<T>>(§self, b: B) throws (LinalgError) -> B xwithA x = b.det(A), the product ofD.