slatrd.f.html

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

HTML
283
字号
</span><span class="comment">*</span><span class="comment">  if UPLO = 'U':                       if UPLO = 'L':
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">    (  a   a   a   v4  v5 )              (  d                  )
</span><span class="comment">*</span><span class="comment">    (      a   a   v4  v5 )              (  1   d              )
</span><span class="comment">*</span><span class="comment">    (          a   1   v5 )              (  v1  1   a          )
</span><span class="comment">*</span><span class="comment">    (              d   1  )              (  v1  v2  a   a      )
</span><span class="comment">*</span><span class="comment">    (                  d  )              (  v1  v2  a   a   a  )
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  where d denotes a diagonal element of the reduced matrix, a denotes
</span><span class="comment">*</span><span class="comment">  an element of the original matrix that is unchanged, and vi denotes
</span><span class="comment">*</span><span class="comment">  an element of the vector defining H(i).
</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               ZERO, ONE, HALF
      PARAMETER          ( ZERO = 0.0E+0, ONE = 1.0E+0, HALF = 0.5E+0 )
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Local Scalars ..
</span>      INTEGER            I, IW
      REAL               ALPHA
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. External Subroutines ..
</span>      EXTERNAL           SAXPY, SGEMV, <a name="SLARFG.147"></a><a href="slarfg.f.html#SLARFG.1">SLARFG</a>, SSCAL, SSYMV
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. External Functions ..
</span>      LOGICAL            <a name="LSAME.150"></a><a href="lsame.f.html#LSAME.1">LSAME</a>
      REAL               SDOT
      EXTERNAL           <a name="LSAME.152"></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">     .. Intrinsic Functions ..
</span>      INTRINSIC          MIN
<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">     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( <a name="LSAME.164"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( UPLO, <span class="string">'U'</span> ) ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Reduce last NB columns of upper triangle
</span><span class="comment">*</span><span class="comment">
</span>         DO 10 I = N, N - NB + 1, -1
            IW = I - N + NB
            IF( I.LT.N ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">              Update A(1:i,i)
</span><span class="comment">*</span><span class="comment">
</span>               CALL SGEMV( <span class="string">'No transpose'</span>, I, N-I, -ONE, A( 1, I+1 ),
     $                     LDA, W( I, IW+1 ), LDW, ONE, A( 1, I ), 1 )
               CALL SGEMV( <span class="string">'No transpose'</span>, I, N-I, -ONE, W( 1, IW+1 ),
     $                     LDW, A( I, I+1 ), LDA, ONE, A( 1, I ), 1 )
            END IF
            IF( I.GT.1 ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">              Generate elementary reflector H(i) to annihilate
</span><span class="comment">*</span><span class="comment">              A(1:i-2,i)
</span><span class="comment">*</span><span class="comment">
</span>               CALL <a name="SLARFG.184"></a><a href="slarfg.f.html#SLARFG.1">SLARFG</a>( I-1, A( I-1, I ), A( 1, I ), 1, TAU( I-1 ) )
               E( I-1 ) = A( I-1, I )
               A( I-1, I ) = ONE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">              Compute W(1:i-1,i)
</span><span class="comment">*</span><span class="comment">
</span>               CALL SSYMV( <span class="string">'Upper'</span>, I-1, ONE, A, LDA, A( 1, I ), 1,
     $                     ZERO, W( 1, IW ), 1 )
               IF( I.LT.N ) THEN
                  CALL SGEMV( <span class="string">'Transpose'</span>, I-1, N-I, ONE, W( 1, IW+1 ),
     $                        LDW, A( 1, I ), 1, ZERO, W( I+1, IW ), 1 )
                  CALL SGEMV( <span class="string">'No transpose'</span>, I-1, N-I, -ONE,
     $                        A( 1, I+1 ), LDA, W( I+1, IW ), 1, ONE,
     $                        W( 1, IW ), 1 )
                  CALL SGEMV( <span class="string">'Transpose'</span>, I-1, N-I, ONE, A( 1, I+1 ),
     $                        LDA, A( 1, I ), 1, ZERO, W( I+1, IW ), 1 )
                  CALL SGEMV( <span class="string">'No transpose'</span>, I-1, N-I, -ONE,
     $                        W( 1, IW+1 ), LDW, W( I+1, IW ), 1, ONE,
     $                        W( 1, IW ), 1 )
               END IF
               CALL SSCAL( I-1, TAU( I-1 ), W( 1, IW ), 1 )
               ALPHA = -HALF*TAU( I-1 )*SDOT( I-1, W( 1, IW ), 1,
     $                 A( 1, I ), 1 )
               CALL SAXPY( I-1, ALPHA, A( 1, I ), 1, W( 1, IW ), 1 )
            END IF
<span class="comment">*</span><span class="comment">
</span>   10    CONTINUE
      ELSE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Reduce first NB columns of lower triangle
</span><span class="comment">*</span><span class="comment">
</span>         DO 20 I = 1, NB
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           Update A(i:n,i)
</span><span class="comment">*</span><span class="comment">
</span>            CALL SGEMV( <span class="string">'No transpose'</span>, N-I+1, I-1, -ONE, A( I, 1 ),
     $                  LDA, W( I, 1 ), LDW, ONE, A( I, I ), 1 )
            CALL SGEMV( <span class="string">'No transpose'</span>, N-I+1, I-1, -ONE, W( I, 1 ),
     $                  LDW, A( I, 1 ), LDA, ONE, A( I, I ), 1 )
            IF( I.LT.N ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">              Generate elementary reflector H(i) to annihilate
</span><span class="comment">*</span><span class="comment">              A(i+2:n,i)
</span><span class="comment">*</span><span class="comment">
</span>               CALL <a name="SLARFG.228"></a><a href="slarfg.f.html#SLARFG.1">SLARFG</a>( N-I, A( I+1, I ), A( MIN( I+2, N ), I ), 1,
     $                      TAU( I ) )
               E( I ) = A( I+1, I )
               A( I+1, I ) = ONE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">              Compute W(i+1:n,i)
</span><span class="comment">*</span><span class="comment">
</span>               CALL SSYMV( <span class="string">'Lower'</span>, N-I, ONE, A( I+1, I+1 ), LDA,
     $                     A( I+1, I ), 1, ZERO, W( I+1, I ), 1 )
               CALL SGEMV( <span class="string">'Transpose'</span>, N-I, I-1, ONE, W( I+1, 1 ), LDW,
     $                     A( I+1, I ), 1, ZERO, W( 1, I ), 1 )
               CALL SGEMV( <span class="string">'No transpose'</span>, N-I, I-1, -ONE, A( I+1, 1 ),
     $                     LDA, W( 1, I ), 1, ONE, W( I+1, I ), 1 )
               CALL SGEMV( <span class="string">'Transpose'</span>, N-I, I-1, ONE, A( I+1, 1 ), LDA,
     $                     A( I+1, I ), 1, ZERO, W( 1, I ), 1 )
               CALL SGEMV( <span class="string">'No transpose'</span>, N-I, I-1, -ONE, W( I+1, 1 ),
     $                     LDW, W( 1, I ), 1, ONE, W( I+1, I ), 1 )
               CALL SSCAL( N-I, TAU( I ), W( I+1, I ), 1 )
               ALPHA = -HALF*TAU( I )*SDOT( N-I, W( I+1, I ), 1,
     $                 A( I+1, I ), 1 )
               CALL SAXPY( N-I, ALPHA, A( I+1, I ), 1, W( I+1, I ), 1 )
            END IF
<span class="comment">*</span><span class="comment">
</span>   20    CONTINUE
      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="SLATRD.256"></a><a href="slatrd.f.html#SLATRD.1">SLATRD</a>
</span><span class="comment">*</span><span class="comment">
</span>      END

</pre>

 </body>
</html>

⌨️ 快捷键说明

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