LAPACK 3.12.1
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 103 of file dlarfg.f.

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