LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
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).

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

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.
!> 
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.

Definition at line 103 of file zlarfg.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 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*
complex *16 function zladiv(x, y)
ZLADIV performs complex division in real arithmetic, avoiding unnecessary overflow.
Definition zladiv.f:62
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:66
real(wp) function dznrm2(n, x, incx)
DZNRM2
Definition dznrm2.f90:90
subroutine zdscal(n, da, zx, incx)
ZDSCAL
Definition zdscal.f:78
subroutine zscal(n, za, zx, incx)
ZSCAL
Definition zscal.f:78
Here is the call graph for this function:
Here is the caller graph for this function: