pub fn qr<N, V, M>(m: &M) -> (M, M)
    where N: BaseFloat,
          V: Indexable<usize, N> + Norm<NormType = N>,
          M: Copy + Eye + ColumnSlice<V> + Transpose + Indexable<(usize, usize), N> +
             Mul<M, Output = M> {
    let (rows, cols) = m.shape();
    assert!(rows >= cols);
    let mut q : M = Eye::new_identity(rows);
    let mut r = *m;

    for ite in 0 .. cmp::min(rows - 1, cols) {
        let mut v = r.column_slice(ite, ite, rows);
        let alpha =
            if unsafe { v.unsafe_at(ite) } >= ::zero() {
                -Norm::norm(&v)
            }
            else {
                Norm::norm(&v)
            };
        unsafe {
            let x = v.unsafe_at(0);
            v.unsafe_set(0, x - alpha);
        }
        if !::is_zero(&v.normalize_mut()) {
            let qk: M = householder_matrix(rows, ite, v);
            r = qk * r;
            q = q * Transpose::transpose(&qk);
        }
    }

    (q, r)
}
/// QR decomposition using Householder reflections.
///
/// # Arguments
/// * `m` - matrix to decompose
QR decomposition using Householder reflections.
QR decomposition using Householder reflections .
pub fn qr<N, V, M>(m: &M) -> (M, M)
    where N: BaseFloat,
          V: Indexable<usize, N> + Norm<NormType = N>,
          M: Copy + Eye + ColumnSlice<V> + Transpose + Indexable<(usize, usize), N> +
             Mul<M, Output = M> {
    let (rows, cols) = m.shape();
    assert!(rows >= cols);
    let mut q : M = Eye::new_identity(rows);
    let mut r = *m;
    for ite in 0 .. cmp::min(rows - 1, cols) {
        let mut v = r.column_slice(ite, ite, rows);
        let alpha =
            if unsafe { v.unsafe_at(ite) } >= ::zero() {
                -Norm::norm(&v)
            }
            else {
                Norm::norm(&v)
            };
        unsafe {
            let x = v.unsafe_at(0);
            v.unsafe_set(0, x - alpha);
        }
        if !::is_zero(&v.normalize_mut()) {
            let qk: M = householder_matrix(rows, ite, v);
            r = qk * r;
            q = q * Transpose::transpose(&qk);
        }
    }
    (q, r)
}
pub fn qr < N , V , M > ( m : & M ) -> ( M , M ) where N : BaseFloat , V : Indexable < usize , N > + Norm < NormType = N > , M : Copy + Eye + ColumnSlice < V > + Transpose + Indexable < ( usize , usize ) , N > + Mul < M , Output = M > { let ( rows , cols ) = m . shape ( ) ; assert ! ( rows cols ) ; let mut q : M = Eye :: new_identity ( rows ) ; let mut r = * m ; for ite in 0 .. cmp :: min ( rows - 1 , cols ) { let mut v = r . column_slice ( ite , ite , rows ) ; let alpha = if unsafe { v . unsafe_at ( ite ) } >= :: zero ( ) { - Norm :: norm ( & v ) } else { Norm :: norm ( & v ) } ; unsafe { let x = v . unsafe_at ( 0 ) ; v . unsafe_set ( 0 , x - alpha ) ; } if ! :: is_zero ( & v . normalize_mut ( ) ) { let qk : M = householder_matrix ( rows , ite , v ) ; r = qk * r ; q = q * Transpose :: transpose ( & qk ) ; } } ( q , r ) }
QR decomposition using Householder reflections.
QR decomposition using Householder reflections .
m
&M
m
&M