LAPACK 3.12.0
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches

◆ dlarfg()

subroutine dlarfg ( integer  n,
double precision  alpha,
double precision, dimension( * )  x,
integer  incx,
double precision  tau 
)

DLARFG generates an elementary reflector (Householder matrix).

Download DLARFG + dependencies [TGZ] [ZIP] [TXT]

Purpose:
 DLARFG generates a real elementary reflector H of order n, such
 that

       H * ( alpha ) = ( beta ),   H**T * H = I.
           (   x   )   (   0  )

 where alpha and beta are scalars, and x is an (n-1)-element real
 vector. H is represented in the form

       H = I - tau * ( 1 ) * ( 1 v**T ) ,
                     ( v )

 where tau is a real scalar and v is a real (n-1)-element
 vector.

 If the elements of x are all zero, then tau = 0 and H is taken to be
 the unit matrix.

 Otherwise  1 <= tau <= 2.
Parameters
[in]N
          N is INTEGER
          The order of the elementary reflector.
[in,out]ALPHA
          ALPHA is DOUBLE PRECISION
          On entry, the value alpha.
          On exit, it is overwritten with the value beta.
[in,out]X
          X is DOUBLE PRECISION array, dimension
                         (1+(N-2)*abs(INCX))
          On entry, the vector x.
          On exit, it is overwritten with the vector v.
[in]INCX
          INCX is INTEGER
          The increment between elements of X. INCX > 0.
[out]TAU
          TAU is DOUBLE PRECISION
          The value tau.
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.

Definition at line 105 of file dlarfg.f.

106*
107* -- LAPACK auxiliary routine --
108* -- LAPACK is a software package provided by Univ. of Tennessee, --
109* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
110*
111* .. Scalar Arguments ..
112 INTEGER INCX, N
113 DOUBLE PRECISION ALPHA, TAU
114* ..
115* .. Array Arguments ..
116 DOUBLE PRECISION X( * )
117* ..
118*
119* =====================================================================
120*
121* .. Parameters ..
122 DOUBLE PRECISION ONE, ZERO
123 parameter( one = 1.0d+0, zero = 0.0d+0 )
124* ..
125* .. Local Scalars ..
126 INTEGER J, KNT
127 DOUBLE PRECISION BETA, RSAFMN, SAFMIN, XNORM
128* ..
129* .. External Functions ..
130 DOUBLE PRECISION DLAMCH, DLAPY2, DNRM2
131 EXTERNAL dlamch, dlapy2, dnrm2
132* ..
133* .. Intrinsic Functions ..
134 INTRINSIC abs, sign
135* ..
136* .. External Subroutines ..
137 EXTERNAL dscal
138* ..
139* .. Executable Statements ..
140*
141 IF( n.LE.1 ) THEN
142 tau = zero
143 RETURN
144 END IF
145*
146 xnorm = dnrm2( n-1, x, incx )
147*
148 IF( xnorm.EQ.zero ) THEN
149*
150* H = I
151*
152 tau = zero
153 ELSE
154*
155* general case
156*
157 beta = -sign( dlapy2( alpha, xnorm ), alpha )
158 safmin = dlamch( 'S' ) / dlamch( 'E' )
159 knt = 0
160 IF( abs( beta ).LT.safmin ) THEN
161*
162* XNORM, BETA may be inaccurate; scale X and recompute them
163*
164 rsafmn = one / safmin
165 10 CONTINUE
166 knt = knt + 1
167 CALL dscal( n-1, rsafmn, x, incx )
168 beta = beta*rsafmn
169 alpha = alpha*rsafmn
170 IF( (abs( beta ).LT.safmin) .AND. (knt .LT. 20) )
171 $ GO TO 10
172*
173* New BETA is at most 1, at least SAFMIN
174*
175 xnorm = dnrm2( n-1, x, incx )
176 beta = -sign( dlapy2( alpha, xnorm ), alpha )
177 END IF
178 tau = ( beta-alpha ) / beta
179 CALL dscal( n-1, one / ( alpha-beta ), x, incx )
180*
181* If ALPHA is subnormal, it may lose relative accuracy
182*
183 DO 20 j = 1, knt
184 beta = beta*safmin
185 20 CONTINUE
186 alpha = beta
187 END IF
188*
189 RETURN
190*
191* End of DLARFG
192*
double precision function dlamch(cmach)
DLAMCH
Definition dlamch.f:69
double precision function dlapy2(x, y)
DLAPY2 returns sqrt(x2+y2).
Definition dlapy2.f:63
real(wp) function dnrm2(n, x, incx)
DNRM2
Definition dnrm2.f90:89
subroutine dscal(n, da, dx, incx)
DSCAL
Definition dscal.f:79
Here is the call graph for this function:
Here is the caller graph for this function: