LAPACK  3.6.1 LAPACK: Linear Algebra PACKage
 subroutine clarfg ( integer N, complex ALPHA, complex, dimension( * ) X, integer INCX, complex TAU )

CLARFG generates an elementary reflector (Householder matrix).

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.```
Date
September 2012

Definition at line 108 of file clarfg.f.

108 *
109 * -- LAPACK auxiliary routine (version 3.4.2) --
110 * -- LAPACK is a software package provided by Univ. of Tennessee, --
111 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
112 * September 2012
113 *
114 * .. Scalar Arguments ..
115  INTEGER incx, n
116  COMPLEX alpha, tau
117 * ..
118 * .. Array Arguments ..
119  COMPLEX x( * )
120 * ..
121 *
122 * =====================================================================
123 *
124 * .. Parameters ..
125  REAL one, zero
126  parameter ( one = 1.0e+0, zero = 0.0e+0 )
127 * ..
128 * .. Local Scalars ..
129  INTEGER j, knt
130  REAL alphi, alphr, beta, rsafmn, safmin, xnorm
131 * ..
132 * .. External Functions ..
133  REAL scnrm2, slamch, slapy3
135  EXTERNAL scnrm2, slamch, slapy3, cladiv
136 * ..
137 * .. Intrinsic Functions ..
138  INTRINSIC abs, aimag, cmplx, REAL, sign
139 * ..
140 * .. External Subroutines ..
141  EXTERNAL cscal, csscal
142 * ..
143 * .. Executable Statements ..
144 *
145  IF( n.LE.0 ) THEN
146  tau = zero
147  RETURN
148  END IF
149 *
150  xnorm = scnrm2( n-1, x, incx )
151  alphr = REAL( alpha )
152  alphi = aimag( alpha )
153 *
154  IF( xnorm.EQ.zero .AND. alphi.EQ.zero ) THEN
155 *
156 * H = I
157 *
158  tau = zero
159  ELSE
160 *
161 * general case
162 *
163  beta = -sign( slapy3( alphr, alphi, xnorm ), alphr )
164  safmin = slamch( 'S' ) / slamch( 'E' )
165  rsafmn = one / safmin
166 *
167  knt = 0
168  IF( abs( beta ).LT.safmin ) THEN
169 *
170 * XNORM, BETA may be inaccurate; scale X and recompute them
171 *
172  10 CONTINUE
173  knt = knt + 1
174  CALL csscal( n-1, rsafmn, x, incx )
175  beta = beta*rsafmn
176  alphi = alphi*rsafmn
177  alphr = alphr*rsafmn
178  IF( abs( beta ).LT.safmin )
179  \$ GO TO 10
180 *
181 * New BETA is at most 1, at least SAFMIN
182 *
183  xnorm = scnrm2( n-1, x, incx )
184  alpha = cmplx( alphr, alphi )
185  beta = -sign( slapy3( alphr, alphi, xnorm ), alphr )
186  END IF
187  tau = cmplx( ( beta-alphr ) / beta, -alphi / beta )
188  alpha = cladiv( cmplx( one ), alpha-beta )
189  CALL cscal( n-1, alpha, x, incx )
190 *
191 * If ALPHA is subnormal, it may lose relative accuracy
192 *
193  DO 20 j = 1, knt
194  beta = beta*safmin
195  20 CONTINUE
196  alpha = beta
197  END IF
198 *
199  RETURN
200 *
201 * End of CLARFG
202 *
real function scnrm2(N, X, INCX)
SCNRM2
Definition: scnrm2.f:56
real function slapy3(X, Y, Z)
SLAPY3 returns sqrt(x2+y2+z2).
Definition: slapy3.f:70
subroutine cscal(N, CA, CX, INCX)
CSCAL
Definition: cscal.f:54