dlagv2.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="DLARTG.148"></a><a href="dlartg.f.html#DLARTG.1">DLARTG</a>( A( 1, 1 ), A( 2, 1 ), CSL, SNL, R )
         CSR = ONE
         SNR = ZERO
         CALL DROT( 2, A( 1, 1 ), LDA, A( 2, 1 ), LDA, CSL, SNL )
         CALL DROT( 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="DLARTG.158"></a><a href="dlartg.f.html#DLARTG.1">DLARTG</a>( A( 2, 2 ), A( 2, 1 ), CSR, SNR, T )
         SNR = -SNR
         CALL DROT( 2, A( 1, 1 ), 1, A( 1, 2 ), 1, CSR, SNR )
         CALL DROT( 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="DLAG2.172"></a><a href="dlag2.f.html#DLAG2.1">DLAG2</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="DLAPY2.183"></a><a href="dlapy2.f.html#DLAPY2.1">DLAPY2</a>( H1, H2 )
            QQ = <a name="DLAPY2.184"></a><a href="dlapy2.f.html#DLAPY2.1">DLAPY2</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="DLARTG.191"></a><a href="dlartg.f.html#DLARTG.1">DLARTG</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="DLARTG.198"></a><a href="dlartg.f.html#DLARTG.1">DLARTG</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 DROT( 2, A( 1, 1 ), 1, A( 1, 2 ), 1, CSR, SNR )
            CALL DROT( 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="DLARTG.217"></a><a href="dlartg.f.html#DLARTG.1">DLARTG</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="DLARTG.223"></a><a href="dlartg.f.html#DLARTG.1">DLARTG</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 DROT( 2, A( 1, 1 ), LDA, A( 2, 1 ), LDA, CSL, SNL )
            CALL DROT( 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="DLASV2.238"></a><a href="dlasv2.f.html#DLASV2.1">DLASV2</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="DLASV2.242"></a><a href="dlasv2.f.html#DLASV2.1">DLASV2</a>
</span><span class="comment">*</span><span class="comment">
</span>            CALL DROT( 2, A( 1, 1 ), LDA, A( 2, 1 ), LDA, CSL, SNL )
            CALL DROT( 2, B( 1, 1 ), LDB, B( 2, 1 ), LDB, CSL, SNL )
            CALL DROT( 2, A( 1, 1 ), 1, A( 1, 2 ), 1, CSR, SNR )
            CALL DROT( 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="DLAGV2.285"></a><a href="dlagv2.f.html#DLAGV2.1">DLAGV2</a>
</span><span class="comment">*</span><span class="comment">
</span>      END

</pre>

 </body>
</html>

⌨️ 快捷键说明

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