slaed9.f.html

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

HTML
230
字号
</span><span class="comment">*</span><span class="comment">     .. Intrinsic Functions ..
</span>      INTRINSIC          MAX, SIGN, SQRT
<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
<span class="comment">*</span><span class="comment">
</span>      IF( K.LT.0 ) THEN
         INFO = -1
      ELSE IF( KSTART.LT.1 .OR. KSTART.GT.MAX( 1, K ) ) THEN
         INFO = -2
      ELSE IF( MAX( 1, KSTOP ).LT.KSTART .OR. KSTOP.GT.MAX( 1, K ) )
     $          THEN
         INFO = -3
      ELSE IF( N.LT.K ) THEN
         INFO = -4
      ELSE IF( LDQ.LT.MAX( 1, K ) ) THEN
         INFO = -7
      ELSE IF( LDS.LT.MAX( 1, K ) ) THEN
         INFO = -12
      END IF
      IF( INFO.NE.0 ) THEN
         CALL <a name="XERBLA.121"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>( <span class="string">'<a name="SLAED9.121"></a><a href="slaed9.f.html#SLAED9.1">SLAED9</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( K.EQ.0 )
     $   RETURN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Modify values DLAMDA(i) to make sure all DLAMDA(i)-DLAMDA(j) can
</span><span class="comment">*</span><span class="comment">     be computed with high relative accuracy (barring over/underflow).
</span><span class="comment">*</span><span class="comment">     This is a problem on machines without a guard digit in
</span><span class="comment">*</span><span class="comment">     add/subtract (Cray XMP, Cray YMP, Cray C 90 and Cray 2).
</span><span class="comment">*</span><span class="comment">     The following code replaces DLAMDA(I) by 2*DLAMDA(I)-DLAMDA(I),
</span><span class="comment">*</span><span class="comment">     which on any of these machines zeros out the bottommost
</span><span class="comment">*</span><span class="comment">     bit of DLAMDA(I) if it is 1; this makes the subsequent
</span><span class="comment">*</span><span class="comment">     subtractions DLAMDA(I)-DLAMDA(J) unproblematic when cancellation
</span><span class="comment">*</span><span class="comment">     occurs. On binary machines with a guard digit (almost all
</span><span class="comment">*</span><span class="comment">     machines) it does not change DLAMDA(I) at all. On hexadecimal
</span><span class="comment">*</span><span class="comment">     and decimal machines with a guard digit, it slightly
</span><span class="comment">*</span><span class="comment">     changes the bottommost bits of DLAMDA(I). It does not account
</span><span class="comment">*</span><span class="comment">     for hexadecimal or decimal machines without guard digits
</span><span class="comment">*</span><span class="comment">     (we know of none). We use a subroutine call to compute
</span><span class="comment">*</span><span class="comment">     2*DLAMBDA(I) to prevent optimizing compilers from eliminating
</span><span class="comment">*</span><span class="comment">     this code.
</span><span class="comment">*</span><span class="comment">
</span>      DO 10 I = 1, N
         DLAMDA( I ) = <a name="SLAMC3.148"></a><a href="slamch.f.html#SLAMC3.574">SLAMC3</a>( DLAMDA( I ), DLAMDA( I ) ) - DLAMDA( I )
   10 CONTINUE
<span class="comment">*</span><span class="comment">
</span>      DO 20 J = KSTART, KSTOP
         CALL <a name="SLAED4.152"></a><a href="slaed4.f.html#SLAED4.1">SLAED4</a>( K, J, DLAMDA, W, Q( 1, J ), RHO, D( J ), INFO )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        If the zero finder fails, the computation is terminated.
</span><span class="comment">*</span><span class="comment">
</span>         IF( INFO.NE.0 )
     $      GO TO 120
   20 CONTINUE
<span class="comment">*</span><span class="comment">
</span>      IF( K.EQ.1 .OR. K.EQ.2 ) THEN
         DO 40 I = 1, K
            DO 30 J = 1, K
               S( J, I ) = Q( J, I )
   30       CONTINUE
   40    CONTINUE
         GO TO 120
      END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Compute updated W.
</span><span class="comment">*</span><span class="comment">
</span>      CALL SCOPY( K, W, 1, S, 1 )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Initialize W(I) = Q(I,I)
</span><span class="comment">*</span><span class="comment">
</span>      CALL SCOPY( K, Q, LDQ+1, W, 1 )
      DO 70 J = 1, K
         DO 50 I = 1, J - 1
            W( I ) = W( I )*( Q( I, J ) / ( DLAMDA( I )-DLAMDA( J ) ) )
   50    CONTINUE
         DO 60 I = J + 1, K
            W( I ) = W( I )*( Q( I, J ) / ( DLAMDA( I )-DLAMDA( J ) ) )
   60    CONTINUE
   70 CONTINUE
      DO 80 I = 1, K
         W( I ) = SIGN( SQRT( -W( I ) ), S( I, 1 ) )
   80 CONTINUE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Compute eigenvectors of the modified rank-1 modification.
</span><span class="comment">*</span><span class="comment">
</span>      DO 110 J = 1, K
         DO 90 I = 1, K
            Q( I, J ) = W( I ) / Q( I, J )
   90    CONTINUE
         TEMP = SNRM2( K, Q( 1, J ), 1 )
         DO 100 I = 1, K
            S( I, J ) = Q( I, J ) / TEMP
  100    CONTINUE
  110 CONTINUE
<span class="comment">*</span><span class="comment">
</span>  120 CONTINUE
      RETURN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     End of <a name="SLAED9.203"></a><a href="slaed9.f.html#SLAED9.1">SLAED9</a>
</span><span class="comment">*</span><span class="comment">
</span>      END

</pre>

 </body>
</html>

⌨️ 快捷键说明

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