slagv2.f.html

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

HTML
312
字号
         CSL = ONE
         SNL = ZERO
         CSR = ONE
         SNR = ZERO
         A( 2, 1 ) = ZERO
         B( 2, 1 ) = ZERO
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Check if B is singular
</span><span class="comment">*</span><span class="comment">
</span>      ELSE IF( ABS( B( 1, 1 ) ).LE.ULP ) THEN
         CALL <a name="SLARTG.148"></a><a href="slartg.f.html#SLARTG.1">SLARTG</a>( A( 1, 1 ), A( 2, 1 ), CSL, SNL, R )
         CSR = ONE
         SNR = ZERO
         CALL SROT( 2, A( 1, 1 ), LDA, A( 2, 1 ), LDA, CSL, SNL )
         CALL SROT( 2, B( 1, 1 ), LDB, B( 2, 1 ), LDB, CSL, SNL )
         A( 2, 1 ) = ZERO
         B( 1, 1 ) = ZERO
         B( 2, 1 ) = ZERO
<span class="comment">*</span><span class="comment">
</span>      ELSE IF( ABS( B( 2, 2 ) ).LE.ULP ) THEN
         CALL <a name="SLARTG.158"></a><a href="slartg.f.html#SLARTG.1">SLARTG</a>( A( 2, 2 ), A( 2, 1 ), CSR, SNR, T )
         SNR = -SNR
         CALL SROT( 2, A( 1, 1 ), 1, A( 1, 2 ), 1, CSR, SNR )
         CALL SROT( 2, B( 1, 1 ), 1, B( 1, 2 ), 1, CSR, SNR )
         CSL = ONE
         SNL = ZERO
         A( 2, 1 ) = ZERO
         B( 2, 1 ) = ZERO
         B( 2, 2 ) = ZERO
<span class="comment">*</span><span class="comment">
</span>      ELSE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        B is nonsingular, first compute the eigenvalues of (A,B)
</span><span class="comment">*</span><span class="comment">
</span>         CALL <a name="SLAG2.172"></a><a href="slag2.f.html#SLAG2.1">SLAG2</a>( A, LDA, B, LDB, SAFMIN, SCALE1, SCALE2, WR1, WR2,
     $               WI )
<span class="comment">*</span><span class="comment">
</span>         IF( WI.EQ.ZERO ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           two real eigenvalues, compute s*A-w*B
</span><span class="comment">*</span><span class="comment">
</span>            H1 = SCALE1*A( 1, 1 ) - WR1*B( 1, 1 )
            H2 = SCALE1*A( 1, 2 ) - WR1*B( 1, 2 )
            H3 = SCALE1*A( 2, 2 ) - WR1*B( 2, 2 )
<span class="comment">*</span><span class="comment">
</span>            RR = <a name="SLAPY2.183"></a><a href="slapy2.f.html#SLAPY2.1">SLAPY2</a>( H1, H2 )
            QQ = <a name="SLAPY2.184"></a><a href="slapy2.f.html#SLAPY2.1">SLAPY2</a>( SCALE1*A( 2, 1 ), H3 )
<span class="comment">*</span><span class="comment">
</span>            IF( RR.GT.QQ ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">              find right rotation matrix to zero 1,1 element of
</span><span class="comment">*</span><span class="comment">              (sA - wB)
</span><span class="comment">*</span><span class="comment">
</span>               CALL <a name="SLARTG.191"></a><a href="slartg.f.html#SLARTG.1">SLARTG</a>( H2, H1, CSR, SNR, T )
<span class="comment">*</span><span class="comment">
</span>            ELSE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">              find right rotation matrix to zero 2,1 element of
</span><span class="comment">*</span><span class="comment">              (sA - wB)
</span><span class="comment">*</span><span class="comment">
</span>               CALL <a name="SLARTG.198"></a><a href="slartg.f.html#SLARTG.1">SLARTG</a>( H3, SCALE1*A( 2, 1 ), CSR, SNR, T )
<span class="comment">*</span><span class="comment">
</span>            END IF
<span class="comment">*</span><span class="comment">
</span>            SNR = -SNR
            CALL SROT( 2, A( 1, 1 ), 1, A( 1, 2 ), 1, CSR, SNR )
            CALL SROT( 2, B( 1, 1 ), 1, B( 1, 2 ), 1, CSR, SNR )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           compute inf norms of A and B
</span><span class="comment">*</span><span class="comment">
</span>            H1 = MAX( ABS( A( 1, 1 ) )+ABS( A( 1, 2 ) ),
     $           ABS( A( 2, 1 ) )+ABS( A( 2, 2 ) ) )
            H2 = MAX( ABS( B( 1, 1 ) )+ABS( B( 1, 2 ) ),
     $           ABS( B( 2, 1 ) )+ABS( B( 2, 2 ) ) )
<span class="comment">*</span><span class="comment">
</span>            IF( ( SCALE1*H1 ).GE.ABS( WR1 )*H2 ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">              find left rotation matrix Q to zero out B(2,1)
</span><span class="comment">*</span><span class="comment">
</span>               CALL <a name="SLARTG.217"></a><a href="slartg.f.html#SLARTG.1">SLARTG</a>( B( 1, 1 ), B( 2, 1 ), CSL, SNL, R )
<span class="comment">*</span><span class="comment">
</span>            ELSE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">              find left rotation matrix Q to zero out A(2,1)
</span><span class="comment">*</span><span class="comment">
</span>               CALL <a name="SLARTG.223"></a><a href="slartg.f.html#SLARTG.1">SLARTG</a>( A( 1, 1 ), A( 2, 1 ), CSL, SNL, R )
<span class="comment">*</span><span class="comment">
</span>            END IF
<span class="comment">*</span><span class="comment">
</span>            CALL SROT( 2, A( 1, 1 ), LDA, A( 2, 1 ), LDA, CSL, SNL )
            CALL SROT( 2, B( 1, 1 ), LDB, B( 2, 1 ), LDB, CSL, SNL )
<span class="comment">*</span><span class="comment">
</span>            A( 2, 1 ) = ZERO
            B( 2, 1 ) = ZERO
<span class="comment">*</span><span class="comment">
</span>         ELSE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           a pair of complex conjugate eigenvalues
</span><span class="comment">*</span><span class="comment">           first compute the SVD of the matrix B
</span><span class="comment">*</span><span class="comment">
</span>            CALL <a name="SLASV2.238"></a><a href="slasv2.f.html#SLASV2.1">SLASV2</a>( B( 1, 1 ), B( 1, 2 ), B( 2, 2 ), R, T, SNR,
     $                   CSR, SNL, CSL )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           Form (A,B) := Q(A,B)Z' where Q is left rotation matrix and
</span><span class="comment">*</span><span class="comment">           Z is right rotation matrix computed from <a name="SLASV2.242"></a><a href="slasv2.f.html#SLASV2.1">SLASV2</a>
</span><span class="comment">*</span><span class="comment">
</span>            CALL SROT( 2, A( 1, 1 ), LDA, A( 2, 1 ), LDA, CSL, SNL )
            CALL SROT( 2, B( 1, 1 ), LDB, B( 2, 1 ), LDB, CSL, SNL )
            CALL SROT( 2, A( 1, 1 ), 1, A( 1, 2 ), 1, CSR, SNR )
            CALL SROT( 2, B( 1, 1 ), 1, B( 1, 2 ), 1, CSR, SNR )
<span class="comment">*</span><span class="comment">
</span>            B( 2, 1 ) = ZERO
            B( 1, 2 ) = ZERO
<span class="comment">*</span><span class="comment">
</span>         END IF
<span class="comment">*</span><span class="comment">
</span>      END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Unscaling
</span><span class="comment">*</span><span class="comment">
</span>      A( 1, 1 ) = ANORM*A( 1, 1 )
      A( 2, 1 ) = ANORM*A( 2, 1 )
      A( 1, 2 ) = ANORM*A( 1, 2 )
      A( 2, 2 ) = ANORM*A( 2, 2 )
      B( 1, 1 ) = BNORM*B( 1, 1 )
      B( 2, 1 ) = BNORM*B( 2, 1 )
      B( 1, 2 ) = BNORM*B( 1, 2 )
      B( 2, 2 ) = BNORM*B( 2, 2 )
<span class="comment">*</span><span class="comment">
</span>      IF( WI.EQ.ZERO ) THEN
         ALPHAR( 1 ) = A( 1, 1 )
         ALPHAR( 2 ) = A( 2, 2 )
         ALPHAI( 1 ) = ZERO
         ALPHAI( 2 ) = ZERO
         BETA( 1 ) = B( 1, 1 )
         BETA( 2 ) = B( 2, 2 )
      ELSE
         ALPHAR( 1 ) = ANORM*WR1 / SCALE1 / BNORM
         ALPHAI( 1 ) = ANORM*WI / SCALE1 / BNORM
         ALPHAR( 2 ) = ALPHAR( 1 )
         ALPHAI( 2 ) = -ALPHAI( 1 )
         BETA( 1 ) = ONE
         BETA( 2 ) = ONE
      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="SLAGV2.285"></a><a href="slagv2.f.html#SLAGV2.1">SLAGV2</a>
</span><span class="comment">*</span><span class="comment">
</span>      END

</pre>

 </body>
</html>

⌨️ 快捷键说明

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