pub struct Qr<T> { /* private fields */ }Expand description
The QR decomposition A = Q·R of an m × n matrix by Householder reflections: Q of
m × min(m, n) with orthonormal columns (unitary for complex elements), R of
min(m, n) × n upper triangular with a real diagonal. From Matrix::qr.
§Examples
use a::math::matrix::Matrix;
let a: Matrix<f64> = Matrix::from_rows(&[[3.0, 1.0], [4.0, 2.0]]);
let qr = a.qr();
let (q, r) = (qr.q(), qr.r());
assert!((&q * &r - &a).as_slice().iter().all(|x| x.abs() < 1e-15));
assert!((&q.transpose() * &q - Matrix::identity(2)).as_slice().iter().all(|x| x.abs() < 1e-15));
assert!((r[(0, 0)].abs() - 5.0).abs() < 1e-15);Implementations§
Source§impl<T: Scalar> Qr<T>
impl<T: Scalar> Qr<T>
Sourcepub fn q_full(&self) -> Matrix<T>
pub fn q_full(&self) -> Matrix<T>
The whole m × m unitary Q, whose first min(m, n) columns are q.
Sourcepub fn solve(&self, b: &Matrix<T>) -> Option<Matrix<T>>
pub fn solve(&self, b: &Matrix<T>) -> Option<Matrix<T>>
The X of the least squares, which makes ‖A·X - B‖ the smallest, for m ≥ n: the
solution of R·X = Q*·B, or None when a diagonal element of R is zero, the
columns of A dependent. For a square matrix it solves A·X = B.
§Panics
Panics if the matrix has fewer rows than columns, or B not as many rows as it.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Qr<T>
impl<T> RefUnwindSafe for Qr<T>
impl<T> Send for Qr<T>
impl<T> Sync for Qr<T>
impl<T> Unpin for Qr<T>
impl<T> UnsafeUnpin for Qr<T>
impl<T> UnwindSafe for Qr<T>
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