ssptrd.f.html

来自「famous linear algebra library (LAPACK) p」· HTML 代码 · 共 252 行 · 第 1/2 页

HTML
252
字号
</span><span class="comment">*</span><span class="comment">     .. External Functions ..
</span>      LOGICAL            <a name="LSAME.109"></a><a href="lsame.f.html#LSAME.1">LSAME</a>
      REAL               SDOT
      EXTERNAL           <a name="LSAME.111"></a><a href="lsame.f.html#LSAME.1">LSAME</a>, SDOT
<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><span class="comment">*</span><span class="comment">     Test the input parameters
</span><span class="comment">*</span><span class="comment">
</span>      INFO = 0
      UPPER = <a name="LSAME.118"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( UPLO, <span class="string">'U'</span> )
      IF( .NOT.UPPER .AND. .NOT.<a name="LSAME.119"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( UPLO, <span class="string">'L'</span> ) ) THEN
         INFO = -1
      ELSE IF( N.LT.0 ) THEN
         INFO = -2
      END IF
      IF( INFO.NE.0 ) THEN
         CALL <a name="XERBLA.125"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>( <span class="string">'<a name="SSPTRD.125"></a><a href="ssptrd.f.html#SSPTRD.1">SSPTRD</a>'</span>, -INFO )
         RETURN
      END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Quick return if possible
</span><span class="comment">*</span><span class="comment">
</span>      IF( N.LE.0 )
     $   RETURN
<span class="comment">*</span><span class="comment">
</span>      IF( UPPER ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Reduce the upper triangle of A.
</span><span class="comment">*</span><span class="comment">        I1 is the index in AP of A(1,I+1).
</span><span class="comment">*</span><span class="comment">
</span>         I1 = N*( N-1 ) / 2 + 1
         DO 10 I = N - 1, 1, -1
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           Generate elementary reflector H(i) = I - tau * v * v'
</span><span class="comment">*</span><span class="comment">           to annihilate A(1:i-1,i+1)
</span><span class="comment">*</span><span class="comment">
</span>            CALL <a name="SLARFG.145"></a><a href="slarfg.f.html#SLARFG.1">SLARFG</a>( I, AP( I1+I-1 ), AP( I1 ), 1, TAUI )
            E( I ) = AP( I1+I-1 )
<span class="comment">*</span><span class="comment">
</span>            IF( TAUI.NE.ZERO ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">              Apply H(i) from both sides to A(1:i,1:i)
</span><span class="comment">*</span><span class="comment">
</span>               AP( I1+I-1 ) = ONE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">              Compute  y := tau * A * v  storing y in TAU(1:i)
</span><span class="comment">*</span><span class="comment">
</span>               CALL SSPMV( UPLO, I, TAUI, AP, AP( I1 ), 1, ZERO, TAU,
     $                     1 )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">              Compute  w := y - 1/2 * tau * (y'*v) * v
</span><span class="comment">*</span><span class="comment">
</span>               ALPHA = -HALF*TAUI*SDOT( I, TAU, 1, AP( I1 ), 1 )
               CALL SAXPY( I, ALPHA, AP( I1 ), 1, TAU, 1 )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">              Apply the transformation as a rank-2 update:
</span><span class="comment">*</span><span class="comment">                 A := A - v * w' - w * v'
</span><span class="comment">*</span><span class="comment">
</span>               CALL SSPR2( UPLO, I, -ONE, AP( I1 ), 1, TAU, 1, AP )
<span class="comment">*</span><span class="comment">
</span>               AP( I1+I-1 ) = E( I )
            END IF
            D( I+1 ) = AP( I1+I )
            TAU( I ) = TAUI
            I1 = I1 - I
   10    CONTINUE
         D( 1 ) = AP( 1 )
      ELSE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Reduce the lower triangle of A. II is the index in AP of
</span><span class="comment">*</span><span class="comment">        A(i,i) and I1I1 is the index of A(i+1,i+1).
</span><span class="comment">*</span><span class="comment">
</span>         II = 1
         DO 20 I = 1, N - 1
            I1I1 = II + N - I + 1
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           Generate elementary reflector H(i) = I - tau * v * v'
</span><span class="comment">*</span><span class="comment">           to annihilate A(i+2:n,i)
</span><span class="comment">*</span><span class="comment">
</span>            CALL <a name="SLARFG.188"></a><a href="slarfg.f.html#SLARFG.1">SLARFG</a>( N-I, AP( II+1 ), AP( II+2 ), 1, TAUI )
            E( I ) = AP( II+1 )
<span class="comment">*</span><span class="comment">
</span>            IF( TAUI.NE.ZERO ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">              Apply H(i) from both sides to A(i+1:n,i+1:n)
</span><span class="comment">*</span><span class="comment">
</span>               AP( II+1 ) = ONE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">              Compute  y := tau * A * v  storing y in TAU(i:n-1)
</span><span class="comment">*</span><span class="comment">
</span>               CALL SSPMV( UPLO, N-I, TAUI, AP( I1I1 ), AP( II+1 ), 1,
     $                     ZERO, TAU( I ), 1 )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">              Compute  w := y - 1/2 * tau * (y'*v) * v
</span><span class="comment">*</span><span class="comment">
</span>               ALPHA = -HALF*TAUI*SDOT( N-I, TAU( I ), 1, AP( II+1 ),
     $                 1 )
               CALL SAXPY( N-I, ALPHA, AP( II+1 ), 1, TAU( I ), 1 )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">              Apply the transformation as a rank-2 update:
</span><span class="comment">*</span><span class="comment">                 A := A - v * w' - w * v'
</span><span class="comment">*</span><span class="comment">
</span>               CALL SSPR2( UPLO, N-I, -ONE, AP( II+1 ), 1, TAU( I ), 1,
     $                     AP( I1I1 ) )
<span class="comment">*</span><span class="comment">
</span>               AP( II+1 ) = E( I )
            END IF
            D( I ) = AP( II )
            TAU( I ) = TAUI
            II = I1I1
   20    CONTINUE
         D( N ) = AP( II )
      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="SSPTRD.225"></a><a href="ssptrd.f.html#SSPTRD.1">SSPTRD</a>
</span><span class="comment">*</span><span class="comment">
</span>      END

</pre>

 </body>
</html>

⌨️ 快捷键说明

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