LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
zlarfg.f
Go to the documentation of this file.
1*> \brief \b ZLARFG generates an elementary reflector (Householder matrix).
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> Download ZLARFG + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlarfg.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlarfg.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlarfg.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* SUBROUTINE ZLARFG( N, ALPHA, X, INCX, TAU )
20*
21* .. Scalar Arguments ..
22* INTEGER INCX, N
23* COMPLEX*16 ALPHA, TAU
24* ..
25* .. Array Arguments ..
26* COMPLEX*16 X( * )
27* ..
28*
29*
30*> \par Purpose:
31* =============
32*>
33*> \verbatim
34*>
35*> ZLARFG generates a complex elementary reflector H of order n, such
36*> that
37*>
38*> H**H * ( alpha ) = ( beta ), H**H * H = I.
39*> ( x ) ( 0 )
40*>
41*> where alpha and beta are scalars, with beta real, and x is an
42*> (n-1)-element complex vector. H is represented in the form
43*>
44*> H = I - tau * ( 1 ) * ( 1 v**H ) ,
45*> ( v )
46*>
47*> where tau is a complex scalar and v is a complex (n-1)-element
48*> vector. Note that H is not hermitian.
49*>
50*> If the elements of x are all zero and alpha is real, then tau = 0
51*> and H is taken to be the unit matrix.
52*>
53*> Otherwise 1 <= real(tau) <= 2 and abs(tau-1) <= 1 .
54*> \endverbatim
55*
56* Arguments:
57* ==========
58*
59*> \param[in] N
60*> \verbatim
61*> N is INTEGER
62*> The order of the elementary reflector.
63*> \endverbatim
64*>
65*> \param[in,out] ALPHA
66*> \verbatim
67*> ALPHA is COMPLEX*16
68*> On entry, the value alpha.
69*> On exit, it is overwritten with the value beta.
70*> \endverbatim
71*>
72*> \param[in,out] X
73*> \verbatim
74*> X is COMPLEX*16 array, dimension
75*> (1+(N-2)*abs(INCX))
76*> On entry, the vector x.
77*> On exit, it is overwritten with the vector v.
78*> \endverbatim
79*>
80*> \param[in] INCX
81*> \verbatim
82*> INCX is INTEGER
83*> The increment between elements of X. INCX > 0.
84*> \endverbatim
85*>
86*> \param[out] TAU
87*> \verbatim
88*> TAU is COMPLEX*16
89*> The value tau.
90*> \endverbatim
91*
92* Authors:
93* ========
94*
95*> \author Univ. of Tennessee
96*> \author Univ. of California Berkeley
97*> \author Univ. of Colorado Denver
98*> \author NAG Ltd.
99*
100*> \ingroup larfg
101*
102* =====================================================================
103 SUBROUTINE zlarfg( N, ALPHA, X, INCX, TAU )
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 COMPLEX*16 ALPHA, TAU
112* ..
113* .. Array Arguments ..
114 COMPLEX*16 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 ALPHI, ALPHR, BETA, RSAFMN, SAFMIN, XNORM
126* ..
127* .. External Functions ..
128 DOUBLE PRECISION DLAMCH, DLAPY3, DZNRM2
129 COMPLEX*16 ZLADIV
130 EXTERNAL dlamch, dlapy3, dznrm2, zladiv
131* ..
132* .. Intrinsic Functions ..
133 INTRINSIC abs, dble, dcmplx, dimag, sign
134* ..
135* .. External Subroutines ..
136 EXTERNAL zdscal, zscal
137* ..
138* .. Executable Statements ..
139*
140 IF( n.LE.0 ) THEN
141 tau = zero
142 RETURN
143 END IF
144*
145 xnorm = dznrm2( n-1, x, incx )
146 alphr = dble( alpha )
147 alphi = dimag( alpha )
148*
149 IF( xnorm.EQ.zero .AND. alphi.EQ.zero ) THEN
150*
151* H = I
152*
153 tau = zero
154 ELSE
155*
156* general case
157*
158 beta = -sign( dlapy3( alphr, alphi, xnorm ), alphr )
159 safmin = dlamch( 'S' ) / dlamch( 'E' )
160 rsafmn = one / safmin
161*
162 knt = 0
163 IF( abs( beta ).LT.safmin ) THEN
164*
165* XNORM, BETA may be inaccurate; scale X and recompute them
166*
167 10 CONTINUE
168 knt = knt + 1
169 CALL zdscal( n-1, rsafmn, x, incx )
170 beta = beta*rsafmn
171 alphi = alphi*rsafmn
172 alphr = alphr*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 = dznrm2( n-1, x, incx )
179 alpha = dcmplx( alphr, alphi )
180 beta = -sign( dlapy3( alphr, alphi, xnorm ), alphr )
181 END IF
182 tau = dcmplx( ( beta-alphr ) / beta, -alphi / beta )
183 alpha = zladiv( dcmplx( one ), alpha-beta )
184 CALL zscal( n-1, alpha, x, incx )
185*
186* If ALPHA is subnormal, it may lose relative accuracy
187*
188 DO 20 j = 1, knt
189 beta = beta*safmin
190 20 CONTINUE
191 alpha = beta
192 END IF
193*
194 RETURN
195*
196* End of ZLARFG
197*
198 END
subroutine zlarfg(n, alpha, x, incx, tau)
ZLARFG generates an elementary reflector (Householder matrix).
Definition zlarfg.f:104
subroutine zdscal(n, da, zx, incx)
ZDSCAL
Definition zdscal.f:78
subroutine zscal(n, za, zx, incx)
ZSCAL
Definition zscal.f:78