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

SLARFG generates an elementary reflector (Householder matrix).

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

Purpose:
 SLARFG generates a real elementary reflector H of order n, such
 that

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

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

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

 where tau is a real scalar and v is a real (n-1)-element
 vector.

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

 Otherwise  1 <= tau <= 2.
Parameters
[in]N
          N is INTEGER
          The order of the elementary reflector.
[in,out]ALPHA
          ALPHA is REAL
          On entry, the value alpha.
          On exit, it is overwritten with the value beta.
[in,out]X
          X is REAL 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 REAL
          The value tau.
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Date
September 2012

Definition at line 108 of file slarfg.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  REAL alpha, tau
117 * ..
118 * .. Array Arguments ..
119  REAL 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 beta, rsafmn, safmin, xnorm
131 * ..
132 * .. External Functions ..
133  REAL slamch, slapy2, snrm2
134  EXTERNAL slamch, slapy2, snrm2
135 * ..
136 * .. Intrinsic Functions ..
137  INTRINSIC abs, sign
138 * ..
139 * .. External Subroutines ..
140  EXTERNAL sscal
141 * ..
142 * .. Executable Statements ..
143 *
144  IF( n.LE.1 ) THEN
145  tau = zero
146  RETURN
147  END IF
148 *
149  xnorm = snrm2( n-1, x, incx )
150 *
151  IF( xnorm.EQ.zero ) THEN
152 *
153 * H = I
154 *
155  tau = zero
156  ELSE
157 *
158 * general case
159 *
160  beta = -sign( slapy2( alpha, xnorm ), alpha )
161  safmin = slamch( 'S' ) / slamch( 'E' )
162  knt = 0
163  IF( abs( beta ).LT.safmin ) THEN
164 *
165 * XNORM, BETA may be inaccurate; scale X and recompute them
166 *
167  rsafmn = one / safmin
168  10 CONTINUE
169  knt = knt + 1
170  CALL sscal( n-1, rsafmn, x, incx )
171  beta = beta*rsafmn
172  alpha = alpha*rsafmn
173  IF( abs( beta ).LT.safmin )
174  $ GO TO 10
175 *
176 * New BETA is at most 1, at least SAFMIN
177 *
178  xnorm = snrm2( n-1, x, incx )
179  beta = -sign( slapy2( alpha, xnorm ), alpha )
180  END IF
181  tau = ( beta-alpha ) / beta
182  CALL sscal( n-1, one / ( alpha-beta ), x, incx )
183 *
184 * If ALPHA is subnormal, it may lose relative accuracy
185 *
186  DO 20 j = 1, knt
187  beta = beta*safmin
188  20 CONTINUE
189  alpha = beta
190  END IF
191 *
192  RETURN
193 *
194 * End of SLARFG
195 *
real function slapy2(X, Y)
SLAPY2 returns sqrt(x2+y2).
Definition: slapy2.f:65
real function snrm2(N, X, INCX)
SNRM2
Definition: snrm2.f:56
subroutine sscal(N, SA, SX, INCX)
SSCAL
Definition: sscal.f:55
real function slamch(CMACH)
SLAMCH
Definition: slamch.f:69

Here is the call graph for this function:

Here is the caller graph for this function: