pub fn larfg<A, S>(mut alpha: A, mut x: ArrayBase<S, Ix1>) -> (A::Real, ArrayBase<S, Ix1>, A)
where
    A: Scalar + Div<<A as Scalar>::Real, Output = A> + MulAssign<<A as Scalar>::Real>,
    S: DataMut<Elem = A>,
{
    let mut x_norm = blas::nrm2(&x);
    if x_norm == A::zero().re() && alpha.im() == A::zero().re() {
        return (alpha.re(), x, A::zero());
    }

    let mut beta = -lapack::lapy3(alpha.re(), alpha.im(), x_norm).copysign(alpha.re());
    let safe_min = A::Real::sfmin() / A::Real::eps();
    let mut knt = 0;
    if beta.abs() < safe_min {
        let safe_min_recip = safe_min.recip();
        loop {
            knt += 1;
            blas::scal(safe_min_recip, &mut x);
            beta *= safe_min_recip;
            alpha *= safe_min_recip;
            if beta.abs() >= safe_min || knt >= 20 {
                break;
            }
        }
        x_norm = blas::nrm2(&x);
        beta = -(alpha.square() + x_norm * x_norm).copysign(alpha.re());
    }
    let tau = (beta.into() - alpha) / beta;
    alpha = A::one() / (alpha - beta.into());
    blas::scal(alpha, &mut x);

    beta *= safe_min.powi(knt);
    (beta, x, tau)
}
/// Generates an elementary reflector (Householder matrix).
Generates an elementary reflector (Householder matrix).
Generates an elementary reflector ( Householder matrix ) .
pub fn larfg<A, S>(mut alpha: A, mut x: ArrayBase<S, Ix1>) -> (A::Real, ArrayBase<S, Ix1>, A)
where
    A: Scalar + Div<<A as Scalar>::Real, Output = A> + MulAssign<<A as Scalar>::Real>,
    S: DataMut<Elem = A>,
{
    let mut x_norm = blas::nrm2(&x);
    if x_norm == A::zero().re() && alpha.im() == A::zero().re() {
        return (alpha.re(), x, A::zero());
    }
    let mut beta = -lapack::lapy3(alpha.re(), alpha.im(), x_norm).copysign(alpha.re());
    let safe_min = A::Real::sfmin() / A::Real::eps();
    let mut knt = 0;
    if beta.abs() < safe_min {
        let safe_min_recip = safe_min.recip();
        loop {
            knt += 1;
            blas::scal(safe_min_recip, &mut x);
            beta *= safe_min_recip;
            alpha *= safe_min_recip;
            if beta.abs() >= safe_min || knt >= 20 {
                break;
            }
        }
        x_norm = blas::nrm2(&x);
        beta = -(alpha.square() + x_norm * x_norm).copysign(alpha.re());
    }
    let tau = (beta.into() - alpha) / beta;
    alpha = A::one() / (alpha - beta.into());
    blas::scal(alpha, &mut x);
    beta *= safe_min.powi(knt);
    (beta, x, tau)
}
pub fn larfg < A , S > ( mut alpha : A , mut x : ArrayBase < S , Ix1 > ) -> ( A :: Real , ArrayBase < S , Ix1 > , A ) where A : Scalar + Div < < A as Scalar > :: Real , Output = A > + MulAssign < < A as Scalar > :: Real > , S : DataMut < Elem = A > , { let mut x_norm = blas :: nrm2 ( & x ) ; if x_norm == A :: zero ( ) . re ( ) && alpha . im ( ) == A :: zero ( ) . re ( ) { return ( alpha . re ( ) , x , A :: zero ( ) ) ; } let mut beta = - lapack :: lapy3 ( alpha . re ( ) , alpha . im ( ) , x_norm ) . copysign ( alpha . re ( ) ) ; let safe_min = A :: Real :: sfmin ( ) / A :: Real :: eps ( ) ; let mut knt = 0 ; if beta . abs ( ) < safe_min { let safe_min_recip = safe_min . recip ( ) ; loop { knt += 1 ; blas :: scal ( safe_min_recip , & mut x ) ; beta *= safe_min_recip ; alpha *= safe_min_recip ; if beta . abs ( ) >= safe_min || knt >= 20 { break ; } } x_norm = blas :: nrm2 ( & x ) ; beta = - ( alpha . square ( ) + x_norm * x_norm ) . copysign ( alpha . re ( ) ) ; } let tau = ( beta . into ( ) - alpha ) / beta ; alpha = A :: one ( ) / ( alpha - beta . into ( ) ) ; blas :: scal ( alpha , & mut x ) ; beta *= safe_min . powi ( knt ) ; ( beta , x , tau ) }
Generates an elementary reflector (Householder matrix).
Generates an elementary reflector ( Householder matrix ) .
alpha
A
x
ArrayBase<S, Ix1>
alpha
A
x
ArrayBase<S, Ix1>