slarfg.f.html

来自「famous linear algebra library (LAPACK) p」· HTML 代码 · 共 162 行

HTML
162
字号
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
 <head>
  <title>slarfg.f</title>
 <meta name="generator" content="emacs 21.3.1; htmlfontify 0.20">
<style type="text/css"><!-- 
body { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.default   { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.default a { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
span.string   { color: rgb(188, 143, 143);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.string a { color: rgb(188, 143, 143);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
span.comment   { color: rgb(178, 34, 34);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.comment a { color: rgb(178, 34, 34);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
 --></style>

 </head>
  <body>

<pre>
      SUBROUTINE <a name="SLARFG.1"></a><a href="slarfg.f.html#SLARFG.1">SLARFG</a>( N, ALPHA, X, INCX, TAU )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  -- LAPACK auxiliary routine (version 3.1) --
</span><span class="comment">*</span><span class="comment">     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
</span><span class="comment">*</span><span class="comment">     November 2006
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     .. Scalar Arguments ..
</span>      INTEGER            INCX, N
      REAL               ALPHA, TAU
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Array Arguments ..
</span>      REAL               X( * )
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Purpose
</span><span class="comment">*</span><span class="comment">  =======
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  <a name="SLARFG.18"></a><a href="slarfg.f.html#SLARFG.1">SLARFG</a> generates a real elementary reflector H of order n, such
</span><span class="comment">*</span><span class="comment">  that
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        H * ( alpha ) = ( beta ),   H' * H = I.
</span><span class="comment">*</span><span class="comment">            (   x   )   (   0  )
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  where alpha and beta are scalars, and x is an (n-1)-element real
</span><span class="comment">*</span><span class="comment">  vector. H is represented in the form
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        H = I - tau * ( 1 ) * ( 1 v' ) ,
</span><span class="comment">*</span><span class="comment">                      ( v )
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  where tau is a real scalar and v is a real (n-1)-element
</span><span class="comment">*</span><span class="comment">  vector.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  If the elements of x are all zero, then tau = 0 and H is taken to be
</span><span class="comment">*</span><span class="comment">  the unit matrix.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Otherwise  1 &lt;= tau &lt;= 2.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Arguments
</span><span class="comment">*</span><span class="comment">  =========
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  N       (input) INTEGER
</span><span class="comment">*</span><span class="comment">          The order of the elementary reflector.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  ALPHA   (input/output) REAL
</span><span class="comment">*</span><span class="comment">          On entry, the value alpha.
</span><span class="comment">*</span><span class="comment">          On exit, it is overwritten with the value beta.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  X       (input/output) REAL array, dimension
</span><span class="comment">*</span><span class="comment">                         (1+(N-2)*abs(INCX))
</span><span class="comment">*</span><span class="comment">          On entry, the vector x.
</span><span class="comment">*</span><span class="comment">          On exit, it is overwritten with the vector v.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  INCX    (input) INTEGER
</span><span class="comment">*</span><span class="comment">          The increment between elements of X. INCX &gt; 0.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  TAU     (output) REAL
</span><span class="comment">*</span><span class="comment">          The value tau.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  =====================================================================
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     .. Parameters ..
</span>      REAL               ONE, ZERO
      PARAMETER          ( ONE = 1.0E+0, ZERO = 0.0E+0 )
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Local Scalars ..
</span>      INTEGER            J, KNT
      REAL               BETA, RSAFMN, SAFMIN, XNORM
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. External Functions ..
</span>      REAL               <a name="SLAMCH.70"></a><a href="slamch.f.html#SLAMCH.1">SLAMCH</a>, <a name="SLAPY2.70"></a><a href="slapy2.f.html#SLAPY2.1">SLAPY2</a>, SNRM2
      EXTERNAL           <a name="SLAMCH.71"></a><a href="slamch.f.html#SLAMCH.1">SLAMCH</a>, <a name="SLAPY2.71"></a><a href="slapy2.f.html#SLAPY2.1">SLAPY2</a>, SNRM2
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Intrinsic Functions ..
</span>      INTRINSIC          ABS, SIGN
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. External Subroutines ..
</span>      EXTERNAL           SSCAL
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Executable Statements ..
</span><span class="comment">*</span><span class="comment">
</span>      IF( N.LE.1 ) THEN
         TAU = ZERO
         RETURN
      END IF
<span class="comment">*</span><span class="comment">
</span>      XNORM = SNRM2( N-1, X, INCX )
<span class="comment">*</span><span class="comment">
</span>      IF( XNORM.EQ.ZERO ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        H  =  I
</span><span class="comment">*</span><span class="comment">
</span>         TAU = ZERO
      ELSE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        general case
</span><span class="comment">*</span><span class="comment">
</span>         BETA = -SIGN( <a name="SLAPY2.97"></a><a href="slapy2.f.html#SLAPY2.1">SLAPY2</a>( ALPHA, XNORM ), ALPHA )
         SAFMIN = <a name="SLAMCH.98"></a><a href="slamch.f.html#SLAMCH.1">SLAMCH</a>( <span class="string">'S'</span> ) / <a name="SLAMCH.98"></a><a href="slamch.f.html#SLAMCH.1">SLAMCH</a>( <span class="string">'E'</span> )
         IF( ABS( BETA ).LT.SAFMIN ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           XNORM, BETA may be inaccurate; scale X and recompute them
</span><span class="comment">*</span><span class="comment">
</span>            RSAFMN = ONE / SAFMIN
            KNT = 0
   10       CONTINUE
            KNT = KNT + 1
            CALL SSCAL( N-1, RSAFMN, X, INCX )
            BETA = BETA*RSAFMN
            ALPHA = ALPHA*RSAFMN
            IF( ABS( BETA ).LT.SAFMIN )
     $         GO TO 10
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           New BETA is at most 1, at least SAFMIN
</span><span class="comment">*</span><span class="comment">
</span>            XNORM = SNRM2( N-1, X, INCX )
            BETA = -SIGN( <a name="SLAPY2.116"></a><a href="slapy2.f.html#SLAPY2.1">SLAPY2</a>( ALPHA, XNORM ), ALPHA )
            TAU = ( BETA-ALPHA ) / BETA
            CALL SSCAL( N-1, ONE / ( ALPHA-BETA ), X, INCX )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           If ALPHA is subnormal, it may lose relative accuracy
</span><span class="comment">*</span><span class="comment">
</span>            ALPHA = BETA
            DO 20 J = 1, KNT
               ALPHA = ALPHA*SAFMIN
   20       CONTINUE
         ELSE
            TAU = ( BETA-ALPHA ) / BETA
            CALL SSCAL( N-1, ONE / ( ALPHA-BETA ), X, INCX )
            ALPHA = BETA
         END IF
      END IF
<span class="comment">*</span><span class="comment">
</span>      RETURN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     End of <a name="SLARFG.135"></a><a href="slarfg.f.html#SLARFG.1">SLARFG</a>
</span><span class="comment">*</span><span class="comment">
</span>      END

</pre>

 </body>
</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?