claed8.f.html

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

HTML
388
字号
</span><span class="comment">*</span><span class="comment">     Quick return if possible
</span><span class="comment">*</span><span class="comment">
</span>      IF( N.EQ.0 )
     $   RETURN
<span class="comment">*</span><span class="comment">
</span>      N1 = CUTPNT
      N2 = N - N1
      N1P1 = N1 + 1
<span class="comment">*</span><span class="comment">
</span>      IF( RHO.LT.ZERO ) THEN
         CALL SSCAL( N2, MONE, Z( N1P1 ), 1 )
      END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Normalize z so that norm(z) = 1
</span><span class="comment">*</span><span class="comment">
</span>      T = ONE / SQRT( TWO )
      DO 10 J = 1, N
         INDX( J ) = J
   10 CONTINUE
      CALL SSCAL( N, T, Z, 1 )
      RHO = ABS( TWO*RHO )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Sort the eigenvalues into increasing order
</span><span class="comment">*</span><span class="comment">
</span>      DO 20 I = CUTPNT + 1, N
         INDXQ( I ) = INDXQ( I ) + CUTPNT
   20 CONTINUE
      DO 30 I = 1, N
         DLAMDA( I ) = D( INDXQ( I ) )
         W( I ) = Z( INDXQ( I ) )
   30 CONTINUE
      I = 1
      J = CUTPNT + 1
      CALL <a name="SLAMRG.209"></a><a href="slamrg.f.html#SLAMRG.1">SLAMRG</a>( N1, N2, DLAMDA, 1, 1, INDX )
      DO 40 I = 1, N
         D( I ) = DLAMDA( INDX( I ) )
         Z( I ) = W( INDX( I ) )
   40 CONTINUE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Calculate the allowable deflation tolerance
</span><span class="comment">*</span><span class="comment">
</span>      IMAX = ISAMAX( N, Z, 1 )
      JMAX = ISAMAX( N, D, 1 )
      EPS = <a name="SLAMCH.219"></a><a href="slamch.f.html#SLAMCH.1">SLAMCH</a>( <span class="string">'Epsilon'</span> )
      TOL = EIGHT*EPS*ABS( D( JMAX ) )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     If the rank-1 modifier is small enough, no more needs to be done
</span><span class="comment">*</span><span class="comment">     -- except to reorganize Q so that its columns correspond with the
</span><span class="comment">*</span><span class="comment">     elements in D.
</span><span class="comment">*</span><span class="comment">
</span>      IF( RHO*ABS( Z( IMAX ) ).LE.TOL ) THEN
         K = 0
         DO 50 J = 1, N
            PERM( J ) = INDXQ( INDX( J ) )
            CALL CCOPY( QSIZ, Q( 1, PERM( J ) ), 1, Q2( 1, J ), 1 )
   50    CONTINUE
         CALL <a name="CLACPY.232"></a><a href="clacpy.f.html#CLACPY.1">CLACPY</a>( <span class="string">'A'</span>, QSIZ, N, Q2( 1, 1 ), LDQ2, Q( 1, 1 ), LDQ )
         RETURN
      END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     If there are multiple eigenvalues then the problem deflates.  Here
</span><span class="comment">*</span><span class="comment">     the number of equal eigenvalues are found.  As each equal
</span><span class="comment">*</span><span class="comment">     eigenvalue is found, an elementary reflector is computed to rotate
</span><span class="comment">*</span><span class="comment">     the corresponding eigensubspace so that the corresponding
</span><span class="comment">*</span><span class="comment">     components of Z are zero in this new basis.
</span><span class="comment">*</span><span class="comment">
</span>      K = 0
      GIVPTR = 0
      K2 = N + 1
      DO 60 J = 1, N
         IF( RHO*ABS( Z( J ) ).LE.TOL ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           Deflate due to small z component.
</span><span class="comment">*</span><span class="comment">
</span>            K2 = K2 - 1
            INDXP( K2 ) = J
            IF( J.EQ.N )
     $         GO TO 100
         ELSE
            JLAM = J
            GO TO 70
         END IF
   60 CONTINUE
   70 CONTINUE
      J = J + 1
      IF( J.GT.N )
     $   GO TO 90
      IF( RHO*ABS( Z( J ) ).LE.TOL ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Deflate due to small z component.
</span><span class="comment">*</span><span class="comment">
</span>         K2 = K2 - 1
         INDXP( K2 ) = J
      ELSE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Check if eigenvalues are close enough to allow deflation.
</span><span class="comment">*</span><span class="comment">
</span>         S = Z( JLAM )
         C = Z( J )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Find sqrt(a**2+b**2) without overflow or
</span><span class="comment">*</span><span class="comment">        destructive underflow.
</span><span class="comment">*</span><span class="comment">
</span>         TAU = <a name="SLAPY2.279"></a><a href="slapy2.f.html#SLAPY2.1">SLAPY2</a>( C, S )
         T = D( J ) - D( JLAM )
         C = C / TAU
         S = -S / TAU
         IF( ABS( T*C*S ).LE.TOL ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           Deflation is possible.
</span><span class="comment">*</span><span class="comment">
</span>            Z( J ) = TAU
            Z( JLAM ) = ZERO
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           Record the appropriate Givens rotation
</span><span class="comment">*</span><span class="comment">
</span>            GIVPTR = GIVPTR + 1
            GIVCOL( 1, GIVPTR ) = INDXQ( INDX( JLAM ) )
            GIVCOL( 2, GIVPTR ) = INDXQ( INDX( J ) )
            GIVNUM( 1, GIVPTR ) = C
            GIVNUM( 2, GIVPTR ) = S
            CALL CSROT( QSIZ, Q( 1, INDXQ( INDX( JLAM ) ) ), 1,
     $                  Q( 1, INDXQ( INDX( J ) ) ), 1, C, S )
            T = D( JLAM )*C*C + D( J )*S*S
            D( J ) = D( JLAM )*S*S + D( J )*C*C
            D( JLAM ) = T
            K2 = K2 - 1
            I = 1
   80       CONTINUE
            IF( K2+I.LE.N ) THEN
               IF( D( JLAM ).LT.D( INDXP( K2+I ) ) ) THEN
                  INDXP( K2+I-1 ) = INDXP( K2+I )
                  INDXP( K2+I ) = JLAM
                  I = I + 1
                  GO TO 80
               ELSE
                  INDXP( K2+I-1 ) = JLAM
               END IF
            ELSE
               INDXP( K2+I-1 ) = JLAM
            END IF
            JLAM = J
         ELSE
            K = K + 1
            W( K ) = Z( JLAM )
            DLAMDA( K ) = D( JLAM )
            INDXP( K ) = JLAM
            JLAM = J
         END IF
      END IF
      GO TO 70
   90 CONTINUE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Record the last eigenvalue.
</span><span class="comment">*</span><span class="comment">
</span>      K = K + 1
      W( K ) = Z( JLAM )
      DLAMDA( K ) = D( JLAM )
      INDXP( K ) = JLAM
<span class="comment">*</span><span class="comment">
</span>  100 CONTINUE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Sort the eigenvalues and corresponding eigenvectors into DLAMDA
</span><span class="comment">*</span><span class="comment">     and Q2 respectively.  The eigenvalues/vectors which were not
</span><span class="comment">*</span><span class="comment">     deflated go into the first K slots of DLAMDA and Q2 respectively,
</span><span class="comment">*</span><span class="comment">     while those which were deflated go into the last N - K slots.
</span><span class="comment">*</span><span class="comment">
</span>      DO 110 J = 1, N
         JP = INDXP( J )
         DLAMDA( J ) = D( JP )
         PERM( J ) = INDXQ( INDX( JP ) )
         CALL CCOPY( QSIZ, Q( 1, PERM( J ) ), 1, Q2( 1, J ), 1 )
  110 CONTINUE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     The deflated eigenvalues and their corresponding vectors go back
</span><span class="comment">*</span><span class="comment">     into the last N - K slots of D and Q respectively.
</span><span class="comment">*</span><span class="comment">
</span>      IF( K.LT.N ) THEN
         CALL SCOPY( N-K, DLAMDA( K+1 ), 1, D( K+1 ), 1 )
         CALL <a name="CLACPY.355"></a><a href="clacpy.f.html#CLACPY.1">CLACPY</a>( <span class="string">'A'</span>, QSIZ, N-K, Q2( 1, K+1 ), LDQ2, Q( 1, K+1 ),
     $                LDQ )
      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="CLAED8.361"></a><a href="claed8.f.html#CLAED8.1">CLAED8</a>
</span><span class="comment">*</span><span class="comment">
</span>      END

</pre>

 </body>
</html>

⌨️ 快捷键说明

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