dlaed2.f.html

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

HTML
459
字号
</span><span class="comment">*</span><span class="comment">
</span>      IMAX = IDAMAX( N, Z, 1 )
      JMAX = IDAMAX( N, D, 1 )
      EPS = <a name="DLAMCH.215"></a><a href="dlamch.f.html#DLAMCH.1">DLAMCH</a>( <span class="string">'Epsilon'</span> )
      TOL = EIGHT*EPS*MAX( ABS( D( JMAX ) ), ABS( Z( IMAX ) ) )
<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
         IQ2 = 1
         DO 40 J = 1, N
            I = INDX( J )
            CALL DCOPY( N, Q( 1, I ), 1, Q2( IQ2 ), 1 )
            DLAMDA( J ) = D( I )
            IQ2 = IQ2 + N
   40    CONTINUE
         CALL <a name="DLACPY.231"></a><a href="dlacpy.f.html#DLACPY.1">DLACPY</a>( <span class="string">'A'</span>, N, N, Q2, N, Q, LDQ )
         CALL DCOPY( N, DLAMDA, 1, D, 1 )
         GO TO 190
      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>      DO 50 I = 1, N1
         COLTYP( I ) = 1
   50 CONTINUE
      DO 60 I = N1P1, N
         COLTYP( I ) = 3
   60 CONTINUE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">
</span>      K = 0
      K2 = N + 1
      DO 70 J = 1, N
         NJ = INDX( J )
         IF( RHO*ABS( Z( NJ ) ).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
            COLTYP( NJ ) = 4
            INDXP( K2 ) = NJ
            IF( J.EQ.N )
     $         GO TO 100
         ELSE
            PJ = NJ
            GO TO 80
         END IF
   70 CONTINUE
   80 CONTINUE
      J = J + 1
      NJ = INDX( J )
      IF( J.GT.N )
     $   GO TO 100
      IF( RHO*ABS( Z( NJ ) ).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
         COLTYP( NJ ) = 4
         INDXP( K2 ) = NJ
      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( PJ )
         C = Z( NJ )
<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="DLAPY2.290"></a><a href="dlapy2.f.html#DLAPY2.1">DLAPY2</a>( C, S )
         T = D( NJ ) - D( PJ )
         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( NJ ) = TAU
            Z( PJ ) = ZERO
            IF( COLTYP( NJ ).NE.COLTYP( PJ ) )
     $         COLTYP( NJ ) = 2
            COLTYP( PJ ) = 4
            CALL DROT( N, Q( 1, PJ ), 1, Q( 1, NJ ), 1, C, S )
            T = D( PJ )*C**2 + D( NJ )*S**2
            D( NJ ) = D( PJ )*S**2 + D( NJ )*C**2
            D( PJ ) = T
            K2 = K2 - 1
            I = 1
   90       CONTINUE
            IF( K2+I.LE.N ) THEN
               IF( D( PJ ).LT.D( INDXP( K2+I ) ) ) THEN
                  INDXP( K2+I-1 ) = INDXP( K2+I )
                  INDXP( K2+I ) = PJ
                  I = I + 1
                  GO TO 90
               ELSE
                  INDXP( K2+I-1 ) = PJ
               END IF
            ELSE
               INDXP( K2+I-1 ) = PJ
            END IF
            PJ = NJ
         ELSE
            K = K + 1
            DLAMDA( K ) = D( PJ )
            W( K ) = Z( PJ )
            INDXP( K ) = PJ
            PJ = NJ
         END IF
      END IF
      GO TO 80
  100 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
      DLAMDA( K ) = D( PJ )
      W( K ) = Z( PJ )
      INDXP( K ) = PJ
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Count up the total number of the various types of columns, then
</span><span class="comment">*</span><span class="comment">     form a permutation which positions the four column types into
</span><span class="comment">*</span><span class="comment">     four uniform groups (although one or more of these groups may be
</span><span class="comment">*</span><span class="comment">     empty).
</span><span class="comment">*</span><span class="comment">
</span>      DO 110 J = 1, 4
         CTOT( J ) = 0
  110 CONTINUE
      DO 120 J = 1, N
         CT = COLTYP( J )
         CTOT( CT ) = CTOT( CT ) + 1
  120 CONTINUE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     PSM(*) = Position in SubMatrix (of types 1 through 4)
</span><span class="comment">*</span><span class="comment">
</span>      PSM( 1 ) = 1
      PSM( 2 ) = 1 + CTOT( 1 )
      PSM( 3 ) = PSM( 2 ) + CTOT( 2 )
      PSM( 4 ) = PSM( 3 ) + CTOT( 3 )
      K = N - CTOT( 4 )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Fill out the INDXC array so that the permutation which it induces
</span><span class="comment">*</span><span class="comment">     will place all type-1 columns first, all type-2 columns next,
</span><span class="comment">*</span><span class="comment">     then all type-3's, and finally all type-4's.
</span><span class="comment">*</span><span class="comment">
</span>      DO 130 J = 1, N
         JS = INDXP( J )
         CT = COLTYP( JS )
         INDX( PSM( CT ) ) = JS
         INDXC( PSM( CT ) ) = J
         PSM( CT ) = PSM( CT ) + 1
  130 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>      I = 1
      IQ1 = 1
      IQ2 = 1 + ( CTOT( 1 )+CTOT( 2 ) )*N1
      DO 140 J = 1, CTOT( 1 )
         JS = INDX( I )
         CALL DCOPY( N1, Q( 1, JS ), 1, Q2( IQ1 ), 1 )
         Z( I ) = D( JS )
         I = I + 1
         IQ1 = IQ1 + N1
  140 CONTINUE
<span class="comment">*</span><span class="comment">
</span>      DO 150 J = 1, CTOT( 2 )
         JS = INDX( I )
         CALL DCOPY( N1, Q( 1, JS ), 1, Q2( IQ1 ), 1 )
         CALL DCOPY( N2, Q( N1+1, JS ), 1, Q2( IQ2 ), 1 )
         Z( I ) = D( JS )
         I = I + 1
         IQ1 = IQ1 + N1
         IQ2 = IQ2 + N2
  150 CONTINUE
<span class="comment">*</span><span class="comment">
</span>      DO 160 J = 1, CTOT( 3 )
         JS = INDX( I )
         CALL DCOPY( N2, Q( N1+1, JS ), 1, Q2( IQ2 ), 1 )
         Z( I ) = D( JS )
         I = I + 1
         IQ2 = IQ2 + N2
  160 CONTINUE
<span class="comment">*</span><span class="comment">
</span>      IQ1 = IQ2
      DO 170 J = 1, CTOT( 4 )
         JS = INDX( I )
         CALL DCOPY( N, Q( 1, JS ), 1, Q2( IQ2 ), 1 )
         IQ2 = IQ2 + N
         Z( I ) = D( JS )
         I = I + 1
  170 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>      CALL <a name="DLACPY.420"></a><a href="dlacpy.f.html#DLACPY.1">DLACPY</a>( <span class="string">'A'</span>, N, CTOT( 4 ), Q2( IQ1 ), N, Q( 1, K+1 ), LDQ )
      CALL DCOPY( N-K, Z( K+1 ), 1, D( K+1 ), 1 )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Copy CTOT into COLTYP for referencing in <a name="DLAED3.423"></a><a href="dlaed3.f.html#DLAED3.1">DLAED3</a>.
</span><span class="comment">*</span><span class="comment">
</span>      DO 180 J = 1, 4
         COLTYP( J ) = CTOT( J )
  180 CONTINUE
<span class="comment">*</span><span class="comment">
</span>  190 CONTINUE
      RETURN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     End of <a name="DLAED2.432"></a><a href="dlaed2.f.html#DLAED2.1">DLAED2</a>
</span><span class="comment">*</span><span class="comment">
</span>      END

</pre>

 </body>
</html>

⌨️ 快捷键说明

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