 LAPACK  3.8.0 LAPACK: Linear Algebra PACKage

## ◆ 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.```
Date
November 2017

Definition at line 108 of file dlarfg.f.

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