LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches

◆ clarfg()

subroutine clarfg ( integer n,
complex alpha,
complex, dimension( * ) x,
integer incx,
complex tau )

CLARFG generates an elementary reflector (Householder matrix).

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

Purpose:
!>
!> CLARFG 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
!>          On entry, the value alpha.
!>          On exit, it is overwritten with the value beta.
!> 
[in,out]X
!>          X is COMPLEX 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
!>          The value tau.
!> 
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.

Definition at line 103 of file clarfg.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 ALPHA, TAU
112* ..
113* .. Array Arguments ..
114 COMPLEX X( * )
115* ..
116*
117* =====================================================================
118*
119* .. Parameters ..
120 REAL ONE, ZERO
121 parameter( one = 1.0e+0, zero = 0.0e+0 )
122* ..
123* .. Local Scalars ..
124 INTEGER J, KNT
125 REAL ALPHI, ALPHR, BETA, RSAFMN, SAFMIN, XNORM
126* ..
127* .. External Functions ..
128 REAL SCNRM2, SLAMCH, SLAPY3
129 COMPLEX CLADIV
130 EXTERNAL scnrm2, slamch, slapy3, cladiv
131* ..
132* .. Intrinsic Functions ..
133 INTRINSIC abs, aimag, cmplx, real, sign
134* ..
135* .. External Subroutines ..
136 EXTERNAL cscal, csscal
137* ..
138* .. Executable Statements ..
139*
140 IF( n.LE.0 ) THEN
141 tau = zero
142 RETURN
143 END IF
144*
145 xnorm = scnrm2( n-1, x, incx )
146 alphr = real( alpha )
147 alphi = aimag( 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( slapy3( alphr, alphi, xnorm ), alphr )
159 safmin = slamch( 'S' ) / slamch( '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 csscal( 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 = scnrm2( n-1, x, incx )
179 alpha = cmplx( alphr, alphi )
180 beta = -sign( slapy3( alphr, alphi, xnorm ), alphr )
181 END IF
182 tau = cmplx( ( beta-alphr ) / beta, -alphi / beta )
183 alpha = cladiv( cmplx( one ), alpha-beta )
184 CALL cscal( 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 CLARFG
197*
complex function cladiv(x, y)
CLADIV performs complex division in real arithmetic, avoiding unnecessary overflow.
Definition cladiv.f:62
real function slamch(cmach)
SLAMCH
Definition slamch.f:68
real function slapy3(x, y, z)
SLAPY3 returns sqrt(x2+y2+z2).
Definition slapy3.f:66
real(wp) function scnrm2(n, x, incx)
SCNRM2
Definition scnrm2.f90:90
subroutine csscal(n, sa, cx, incx)
CSSCAL
Definition csscal.f:78
subroutine cscal(n, ca, cx, incx)
CSCAL
Definition cscal.f:78
Here is the call graph for this function:
Here is the caller graph for this function: