slag2.f.html

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

HTML
323
字号
      B11 = B11*BSCALE
      B12 = B12*BSCALE
      B22 = B22*BSCALE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Compute larger eigenvalue by method described by C. van Loan
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     ( AS is A shifted by -SHIFT*B )
</span><span class="comment">*</span><span class="comment">
</span>      BINV11 = ONE / B11
      BINV22 = ONE / B22
      S1 = A11*BINV11
      S2 = A22*BINV22
      IF( ABS( S1 ).LE.ABS( S2 ) ) THEN
         AS12 = A12 - S1*B12
         AS22 = A22 - S1*B22
         SS = A21*( BINV11*BINV22 )
         ABI22 = AS22*BINV22 - SS*B12
         PP = HALF*ABI22
         SHIFT = S1
      ELSE
         AS12 = A12 - S2*B12
         AS11 = A11 - S2*B11
         SS = A21*( BINV11*BINV22 )
         ABI22 = -SS*B12
         PP = HALF*( AS11*BINV11+ABI22 )
         SHIFT = S2
      END IF
      QQ = SS*AS12
      IF( ABS( PP*RTMIN ).GE.ONE ) THEN
         DISCR = ( RTMIN*PP )**2 + QQ*SAFMIN
         R = SQRT( ABS( DISCR ) )*RTMAX
      ELSE
         IF( PP**2+ABS( QQ ).LE.SAFMIN ) THEN
            DISCR = ( RTMAX*PP )**2 + QQ*SAFMAX
            R = SQRT( ABS( DISCR ) )*RTMIN
         ELSE
            DISCR = PP**2 + QQ
            R = SQRT( ABS( DISCR ) )
         END IF
      END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Note: the test of R in the following IF is to cover the case when
</span><span class="comment">*</span><span class="comment">           DISCR is small and negative and is flushed to zero during
</span><span class="comment">*</span><span class="comment">           the calculation of R.  On machines which have a consistent
</span><span class="comment">*</span><span class="comment">           flush-to-zero threshhold and handle numbers above that
</span><span class="comment">*</span><span class="comment">           threshhold correctly, it would not be necessary.
</span><span class="comment">*</span><span class="comment">
</span>      IF( DISCR.GE.ZERO .OR. R.EQ.ZERO ) THEN
         SUM = PP + SIGN( R, PP )
         DIFF = PP - SIGN( R, PP )
         WBIG = SHIFT + SUM
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Compute smaller eigenvalue
</span><span class="comment">*</span><span class="comment">
</span>         WSMALL = SHIFT + DIFF
         IF( HALF*ABS( WBIG ).GT.MAX( ABS( WSMALL ), SAFMIN ) ) THEN
            WDET = ( A11*A22-A12*A21 )*( BINV11*BINV22 )
            WSMALL = WDET / WBIG
         END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Choose (real) eigenvalue closest to 2,2 element of A*B**(-1)
</span><span class="comment">*</span><span class="comment">        for WR1.
</span><span class="comment">*</span><span class="comment">
</span>         IF( PP.GT.ABI22 ) THEN
            WR1 = MIN( WBIG, WSMALL )
            WR2 = MAX( WBIG, WSMALL )
         ELSE
            WR1 = MAX( WBIG, WSMALL )
            WR2 = MIN( WBIG, WSMALL )
         END IF
         WI = ZERO
      ELSE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Complex eigenvalues
</span><span class="comment">*</span><span class="comment">
</span>         WR1 = SHIFT + PP
         WR2 = WR1
         WI = R
      END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Further scaling to avoid underflow and overflow in computing
</span><span class="comment">*</span><span class="comment">     SCALE1 and overflow in computing w*B.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     This scale factor (WSCALE) is bounded from above using C1 and C2,
</span><span class="comment">*</span><span class="comment">     and from below using C3 and C4.
</span><span class="comment">*</span><span class="comment">        C1 implements the condition  s A  must never overflow.
</span><span class="comment">*</span><span class="comment">        C2 implements the condition  w B  must never overflow.
</span><span class="comment">*</span><span class="comment">        C3, with C2,
</span><span class="comment">*</span><span class="comment">           implement the condition that s A - w B must never overflow.
</span><span class="comment">*</span><span class="comment">        C4 implements the condition  s    should not underflow.
</span><span class="comment">*</span><span class="comment">        C5 implements the condition  max(s,|w|) should be at least 2.
</span><span class="comment">*</span><span class="comment">
</span>      C1 = BSIZE*( SAFMIN*MAX( ONE, ASCALE ) )
      C2 = SAFMIN*MAX( ONE, BNORM )
      C3 = BSIZE*SAFMIN
      IF( ASCALE.LE.ONE .AND. BSIZE.LE.ONE ) THEN
         C4 = MIN( ONE, ( ASCALE / SAFMIN )*BSIZE )
      ELSE
         C4 = ONE
      END IF
      IF( ASCALE.LE.ONE .OR. BSIZE.LE.ONE ) THEN
         C5 = MIN( ONE, ASCALE*BSIZE )
      ELSE
         C5 = ONE
      END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Scale first eigenvalue
</span><span class="comment">*</span><span class="comment">
</span>      WABS = ABS( WR1 ) + ABS( WI )
      WSIZE = MAX( SAFMIN, C1, FUZZY1*( WABS*C2+C3 ),
     $        MIN( C4, HALF*MAX( WABS, C5 ) ) )
      IF( WSIZE.NE.ONE ) THEN
         WSCALE = ONE / WSIZE
         IF( WSIZE.GT.ONE ) THEN
            SCALE1 = ( MAX( ASCALE, BSIZE )*WSCALE )*
     $               MIN( ASCALE, BSIZE )
         ELSE
            SCALE1 = ( MIN( ASCALE, BSIZE )*WSCALE )*
     $               MAX( ASCALE, BSIZE )
         END IF
         WR1 = WR1*WSCALE
         IF( WI.NE.ZERO ) THEN
            WI = WI*WSCALE
            WR2 = WR1
            SCALE2 = SCALE1
         END IF
      ELSE
         SCALE1 = ASCALE*BSIZE
         SCALE2 = SCALE1
      END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Scale second eigenvalue (if real)
</span><span class="comment">*</span><span class="comment">
</span>      IF( WI.EQ.ZERO ) THEN
         WSIZE = MAX( SAFMIN, C1, FUZZY1*( ABS( WR2 )*C2+C3 ),
     $           MIN( C4, HALF*MAX( ABS( WR2 ), C5 ) ) )
         IF( WSIZE.NE.ONE ) THEN
            WSCALE = ONE / WSIZE
            IF( WSIZE.GT.ONE ) THEN
               SCALE2 = ( MAX( ASCALE, BSIZE )*WSCALE )*
     $                  MIN( ASCALE, BSIZE )
            ELSE
               SCALE2 = ( MIN( ASCALE, BSIZE )*WSCALE )*
     $                  MAX( ASCALE, BSIZE )
            END IF
            WR2 = WR2*WSCALE
         ELSE
            SCALE2 = ASCALE*BSIZE
         END IF
      END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     End of <a name="SLAG2.297"></a><a href="slag2.f.html#SLAG2.1">SLAG2</a>
</span><span class="comment">*</span><span class="comment">
</span>      RETURN
      END

</pre>

 </body>
</html>

⌨️ 快捷键说明

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