Skip to main content

qr

Function qr 

Source
pub fn qr<B: Backend, T: LinalgScalar>(
    x: &Array<B, T>,
    full_matrices: bool,
) -> (Array<B, T>, Array<B, T>)
Expand description

The QR decomposition of each matrix, as lax.linalg.qr: q with orthonormal columns and an upper triangular r (x = q r), with the signs of LAPACK’s Householder reflectors. With full_matrices, q is [..., m, m] and r is [..., m, n]; otherwise [..., m, k] and [..., k, n] for k = min(m, n).

§Panics

Panics if x is not a batch of matrices.

§Examples

use ruxla_core::{Array, Native, lax};

let a = Array::<Native, f64>::from_vec(vec![3.0, 4.0], [2, 1]);
let (q, r) = lax::linalg::qr(&a, false);
assert_eq!(r.to_vec(), [-5.0]);
assert!((q.to_vec()[0] + 0.6).abs() < 1e-15);