1 *> \brief \b DLARFG generates an elementary reflector (Householder matrix).
3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download DLARFG + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlarfg.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlarfg.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlarfg.f">
21 * SUBROUTINE DLARFG( N, ALPHA, X, INCX, TAU )
23 * .. Scalar Arguments ..
25 * DOUBLE PRECISION ALPHA, TAU
27 * .. Array Arguments ..
28 * DOUBLE PRECISION X( * )
37 *> DLARFG generates a real elementary reflector H of order n, such
40 *> H * ( alpha ) = ( beta ), H**T * H = I.
43 *> where alpha and beta are scalars, and x is an (n-1)-element real
44 *> vector. H is represented in the form
46 *> H = I - tau * ( 1 ) * ( 1 v**T ) ,
49 *> where tau is a real scalar and v is a real (n-1)-element
52 *> If the elements of x are all zero, then tau = 0 and H is taken to be
55 *> Otherwise 1 <= tau <= 2.
64 *> The order of the elementary reflector.
67 *> \param[in,out] ALPHA
69 *> ALPHA is DOUBLE PRECISION
70 *> On entry, the value alpha.
71 *> On exit, it is overwritten with the value beta.
76 *> X is DOUBLE PRECISION array, dimension
77 *> (1+(N-2)*abs(INCX))
78 *> On entry, the vector x.
79 *> On exit, it is overwritten with the vector v.
85 *> The increment between elements of X. INCX > 0.
90 *> TAU is DOUBLE PRECISION
97 *> \author Univ. of Tennessee
98 *> \author Univ. of California Berkeley
99 *> \author Univ. of Colorado Denver
102 *> \date September 2012
104 *> \ingroup doubleOTHERauxiliary
106 * =====================================================================
107 SUBROUTINE DLARFG( N, ALPHA, X, INCX, TAU )
109 * -- LAPACK auxiliary routine (version 3.4.2) --
110 * -- LAPACK is a software package provided by Univ. of Tennessee, --
111 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
114 * .. Scalar Arguments ..
116 DOUBLE PRECISION ALPHA, TAU
118 * .. Array Arguments ..
119 DOUBLE PRECISION X( * )
122 * =====================================================================
125 DOUBLE PRECISION ONE, ZERO
126 PARAMETER ( ONE = 1.0D+0, ZERO = 0.0D+0 )
128 * .. Local Scalars ..
130 DOUBLE PRECISION BETA, RSAFMN, SAFMIN, XNORM
132 * .. External Functions ..
133 DOUBLE PRECISION DLAMCH, DLAPY2, DNRM2
134 EXTERNAL DLAMCH, DLAPY2, DNRM2
136 * .. Intrinsic Functions ..
139 * .. External Subroutines ..
142 * .. Executable Statements ..
149 XNORM = DNRM2( N-1, X, INCX )
151 IF( XNORM.EQ.ZERO ) THEN
160 BETA = -SIGN( DLAPY2( ALPHA, XNORM ), ALPHA )
161 SAFMIN = DLAMCH( 'S' ) / DLAMCH( 'E' )
163 IF( ABS( BETA ).LT.SAFMIN ) THEN
165 * XNORM, BETA may be inaccurate; scale X and recompute them
167 RSAFMN = ONE / SAFMIN
170 CALL DSCAL( N-1, RSAFMN, X, INCX )
173 IF( ABS( BETA ).LT.SAFMIN )
176 * New BETA is at most 1, at least SAFMIN
178 XNORM = DNRM2( N-1, X, INCX )
179 BETA = -SIGN( DLAPY2( ALPHA, XNORM ), ALPHA )
181 TAU = ( BETA-ALPHA ) / BETA
182 CALL DSCAL( N-1, ONE / ( ALPHA-BETA ), X, INCX )
184 * If ALPHA is subnormal, it may lose relative accuracy