 LAPACK 3.11.0 LAPACK: Linear Algebra PACKage
Searching...
No Matches

## ◆ zlarfg()

 subroutine zlarfg ( integer N, complex*16 ALPHA, complex*16, dimension( * ) X, integer INCX, complex*16 TAU )

ZLARFG generates an elementary reflector (Householder matrix).

Purpose:
``` ZLARFG generates a complex elementary reflector H of order n, such
that

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

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

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

where tau is a complex scalar and v is a complex (n-1)-element
vector. Note that H is not hermitian.

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

Otherwise  1 <= real(tau) <= 2  and  abs(tau-1) <= 1 .```
Parameters
 [in] N ``` N is INTEGER The order of the elementary reflector.``` [in,out] ALPHA ``` ALPHA is COMPLEX*16 On entry, the value alpha. On exit, it is overwritten with the value beta.``` [in,out] X ``` X is COMPLEX*16 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 COMPLEX*16 The value tau.```

Definition at line 105 of file zlarfg.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 COMPLEX*16 ALPHA, TAU
114* ..
115* .. Array Arguments ..
116 COMPLEX*16 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 ALPHI, ALPHR, BETA, RSAFMN, SAFMIN, XNORM
128* ..
129* .. External Functions ..
130 DOUBLE PRECISION DLAMCH, DLAPY3, DZNRM2
132 EXTERNAL dlamch, dlapy3, dznrm2, zladiv
133* ..
134* .. Intrinsic Functions ..
135 INTRINSIC abs, dble, dcmplx, dimag, sign
136* ..
137* .. External Subroutines ..
138 EXTERNAL zdscal, zscal
139* ..
140* .. Executable Statements ..
141*
142 IF( n.LE.0 ) THEN
143 tau = zero
144 RETURN
145 END IF
146*
147 xnorm = dznrm2( n-1, x, incx )
148 alphr = dble( alpha )
149 alphi = dimag( alpha )
150*
151 IF( xnorm.EQ.zero .AND. alphi.EQ.zero ) THEN
152*
153* H = I
154*
155 tau = zero
156 ELSE
157*
158* general case
159*
160 beta = -sign( dlapy3( alphr, alphi, xnorm ), alphr )
161 safmin = dlamch( 'S' ) / dlamch( 'E' )
162 rsafmn = one / safmin
163*
164 knt = 0
165 IF( abs( beta ).LT.safmin ) THEN
166*
167* XNORM, BETA may be inaccurate; scale X and recompute them
168*
169 10 CONTINUE
170 knt = knt + 1
171 CALL zdscal( n-1, rsafmn, x, incx )
172 beta = beta*rsafmn
173 alphi = alphi*rsafmn
174 alphr = alphr*rsafmn
175 IF( (abs( beta ).LT.safmin) .AND. (knt .LT. 20) )
176 \$ GO TO 10
177*
178* New BETA is at most 1, at least SAFMIN
179*
180 xnorm = dznrm2( n-1, x, incx )
181 alpha = dcmplx( alphr, alphi )
182 beta = -sign( dlapy3( alphr, alphi, xnorm ), alphr )
183 END IF
184 tau = dcmplx( ( beta-alphr ) / beta, -alphi / beta )
185 alpha = zladiv( dcmplx( one ), alpha-beta )
186 CALL zscal( n-1, alpha, x, incx )
187*
188* If ALPHA is subnormal, it may lose relative accuracy
189*
190 DO 20 j = 1, knt
191 beta = beta*safmin
192 20 CONTINUE
193 alpha = beta
194 END IF
195*
196 RETURN
197*
198* End of ZLARFG
199*
double precision function dlamch(CMACH)
DLAMCH
Definition: dlamch.f:69
double precision function dlapy3(X, Y, Z)
DLAPY3 returns sqrt(x2+y2+z2).
Definition: dlapy3.f:68
subroutine zdscal(N, DA, ZX, INCX)
ZDSCAL
Definition: zdscal.f:78
subroutine zscal(N, ZA, ZX, INCX)
ZSCAL
Definition: zscal.f:78