cggevx.f.html
来自「famous linear algebra library (LAPACK) p」· HTML 代码 · 共 677 行 · 第 1/4 页
HTML
677 行
</span> INFO = 0
LQUERY = ( LWORK.EQ.-1 )
IF( .NOT.( NOSCL .OR. <a name="LSAME.324"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( BALANC,<span class="string">'S'</span> ) .OR.
$ <a name="LSAME.325"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( BALANC, <span class="string">'B'</span> ) ) ) THEN
INFO = -1
ELSE IF( IJOBVL.LE.0 ) THEN
INFO = -2
ELSE IF( IJOBVR.LE.0 ) THEN
INFO = -3
ELSE IF( .NOT.( WANTSN .OR. WANTSE .OR. WANTSB .OR. WANTSV ) )
$ THEN
INFO = -4
ELSE IF( N.LT.0 ) THEN
INFO = -5
ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
INFO = -7
ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
INFO = -9
ELSE IF( LDVL.LT.1 .OR. ( ILVL .AND. LDVL.LT.N ) ) THEN
INFO = -13
ELSE IF( LDVR.LT.1 .OR. ( ILVR .AND. LDVR.LT.N ) ) THEN
INFO = -15
END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Compute workspace
</span><span class="comment">*</span><span class="comment"> (Note: Comments in the code beginning "Workspace:" describe the
</span><span class="comment">*</span><span class="comment"> minimal amount of workspace needed at that point in the code,
</span><span class="comment">*</span><span class="comment"> as well as the preferred amount for good performance.
</span><span class="comment">*</span><span class="comment"> NB refers to the optimal block size for the immediately
</span><span class="comment">*</span><span class="comment"> following subroutine, as returned by <a name="ILAENV.351"></a><a href="hfy-index.html#ILAENV">ILAENV</a>. The workspace is
</span><span class="comment">*</span><span class="comment"> computed assuming ILO = 1 and IHI = N, the worst case.)
</span><span class="comment">*</span><span class="comment">
</span> IF( INFO.EQ.0 ) THEN
IF( N.EQ.0 ) THEN
MINWRK = 1
MAXWRK = 1
ELSE
MINWRK = 2*N
IF( WANTSE ) THEN
MINWRK = 4*N
ELSE IF( WANTSV .OR. WANTSB ) THEN
MINWRK = 2*N*( N + 1)
END IF
MAXWRK = MINWRK
MAXWRK = MAX( MAXWRK,
$ N + N*<a name="ILAENV.367"></a><a href="hfy-index.html#ILAENV">ILAENV</a>( 1, <span class="string">'<a name="CGEQRF.367"></a><a href="cgeqrf.f.html#CGEQRF.1">CGEQRF</a>'</span>, <span class="string">' '</span>, N, 1, N, 0 ) )
MAXWRK = MAX( MAXWRK,
$ N + N*<a name="ILAENV.369"></a><a href="hfy-index.html#ILAENV">ILAENV</a>( 1, <span class="string">'<a name="CUNMQR.369"></a><a href="cunmqr.f.html#CUNMQR.1">CUNMQR</a>'</span>, <span class="string">' '</span>, N, 1, N, 0 ) )
IF( ILVL ) THEN
MAXWRK = MAX( MAXWRK, N +
$ N*<a name="ILAENV.372"></a><a href="hfy-index.html#ILAENV">ILAENV</a>( 1, <span class="string">'<a name="CUNGQR.372"></a><a href="cungqr.f.html#CUNGQR.1">CUNGQR</a>'</span>, <span class="string">' '</span>, N, 1, N, 0 ) )
END IF
END IF
WORK( 1 ) = MAXWRK
<span class="comment">*</span><span class="comment">
</span> IF( LWORK.LT.MINWRK .AND. .NOT.LQUERY ) THEN
INFO = -25
END IF
END IF
<span class="comment">*</span><span class="comment">
</span> IF( INFO.NE.0 ) THEN
CALL <a name="XERBLA.383"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>( <span class="string">'<a name="CGGEVX.383"></a><a href="cggevx.f.html#CGGEVX.1">CGGEVX</a>'</span>, -INFO )
RETURN
ELSE IF( LQUERY ) THEN
RETURN
END IF
<span class="comment">*</span><span class="comment">
</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><span class="comment">*</span><span class="comment"> Get machine constants
</span><span class="comment">*</span><span class="comment">
</span> EPS = <a name="SLAMCH.396"></a><a href="slamch.f.html#SLAMCH.1">SLAMCH</a>( <span class="string">'P'</span> )
SMLNUM = <a name="SLAMCH.397"></a><a href="slamch.f.html#SLAMCH.1">SLAMCH</a>( <span class="string">'S'</span> )
BIGNUM = ONE / SMLNUM
CALL <a name="SLABAD.399"></a><a href="slabad.f.html#SLABAD.1">SLABAD</a>( SMLNUM, BIGNUM )
SMLNUM = SQRT( SMLNUM ) / EPS
BIGNUM = ONE / SMLNUM
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Scale A if max element outside range [SMLNUM,BIGNUM]
</span><span class="comment">*</span><span class="comment">
</span> ANRM = <a name="CLANGE.405"></a><a href="clange.f.html#CLANGE.1">CLANGE</a>( <span class="string">'M'</span>, N, N, A, LDA, RWORK )
ILASCL = .FALSE.
IF( ANRM.GT.ZERO .AND. ANRM.LT.SMLNUM ) THEN
ANRMTO = SMLNUM
ILASCL = .TRUE.
ELSE IF( ANRM.GT.BIGNUM ) THEN
ANRMTO = BIGNUM
ILASCL = .TRUE.
END IF
IF( ILASCL )
$ CALL <a name="CLASCL.415"></a><a href="clascl.f.html#CLASCL.1">CLASCL</a>( <span class="string">'G'</span>, 0, 0, ANRM, ANRMTO, N, N, A, LDA, IERR )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Scale B if max element outside range [SMLNUM,BIGNUM]
</span><span class="comment">*</span><span class="comment">
</span> BNRM = <a name="CLANGE.419"></a><a href="clange.f.html#CLANGE.1">CLANGE</a>( <span class="string">'M'</span>, N, N, B, LDB, RWORK )
ILBSCL = .FALSE.
IF( BNRM.GT.ZERO .AND. BNRM.LT.SMLNUM ) THEN
BNRMTO = SMLNUM
ILBSCL = .TRUE.
ELSE IF( BNRM.GT.BIGNUM ) THEN
BNRMTO = BIGNUM
ILBSCL = .TRUE.
END IF
IF( ILBSCL )
$ CALL <a name="CLASCL.429"></a><a href="clascl.f.html#CLASCL.1">CLASCL</a>( <span class="string">'G'</span>, 0, 0, BNRM, BNRMTO, N, N, B, LDB, IERR )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Permute and/or balance the matrix pair (A,B)
</span><span class="comment">*</span><span class="comment"> (Real Workspace: need 6*N if BALANC = 'S' or 'B', 1 otherwise)
</span><span class="comment">*</span><span class="comment">
</span> CALL <a name="CGGBAL.434"></a><a href="cggbal.f.html#CGGBAL.1">CGGBAL</a>( BALANC, N, A, LDA, B, LDB, ILO, IHI, LSCALE, RSCALE,
$ RWORK, IERR )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Compute ABNRM and BBNRM
</span><span class="comment">*</span><span class="comment">
</span> ABNRM = <a name="CLANGE.439"></a><a href="clange.f.html#CLANGE.1">CLANGE</a>( <span class="string">'1'</span>, N, N, A, LDA, RWORK( 1 ) )
IF( ILASCL ) THEN
RWORK( 1 ) = ABNRM
CALL <a name="SLASCL.442"></a><a href="slascl.f.html#SLASCL.1">SLASCL</a>( <span class="string">'G'</span>, 0, 0, ANRMTO, ANRM, 1, 1, RWORK( 1 ), 1,
$ IERR )
ABNRM = RWORK( 1 )
END IF
<span class="comment">*</span><span class="comment">
</span> BBNRM = <a name="CLANGE.447"></a><a href="clange.f.html#CLANGE.1">CLANGE</a>( <span class="string">'1'</span>, N, N, B, LDB, RWORK( 1 ) )
IF( ILBSCL ) THEN
RWORK( 1 ) = BBNRM
CALL <a name="SLASCL.450"></a><a href="slascl.f.html#SLASCL.1">SLASCL</a>( <span class="string">'G'</span>, 0, 0, BNRMTO, BNRM, 1, 1, RWORK( 1 ), 1,
$ IERR )
BBNRM = RWORK( 1 )
END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Reduce B to triangular form (QR decomposition of B)
</span><span class="comment">*</span><span class="comment"> (Complex Workspace: need N, prefer N*NB )
</span><span class="comment">*</span><span class="comment">
</span> IROWS = IHI + 1 - ILO
IF( ILV .OR. .NOT.WANTSN ) THEN
ICOLS = N + 1 - ILO
ELSE
ICOLS = IROWS
END IF
ITAU = 1
IWRK = ITAU + IROWS
CALL <a name="CGEQRF.466"></a><a href="cgeqrf.f.html#CGEQRF.1">CGEQRF</a>( IROWS, ICOLS, B( ILO, ILO ), LDB, WORK( ITAU ),
$ WORK( IWRK ), LWORK+1-IWRK, IERR )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Apply the unitary transformation to A
</span><span class="comment">*</span><span class="comment"> (Complex Workspace: need N, prefer N*NB)
</span><span class="comment">*</span><span class="comment">
</span> CALL <a name="CUNMQR.472"></a><a href="cunmqr.f.html#CUNMQR.1">CUNMQR</a>( <span class="string">'L'</span>, <span class="string">'C'</span>, IROWS, ICOLS, IROWS, B( ILO, ILO ), LDB,
$ WORK( ITAU ), A( ILO, ILO ), LDA, WORK( IWRK ),
$ LWORK+1-IWRK, IERR )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Initialize VL and/or VR
</span><span class="comment">*</span><span class="comment"> (Workspace: need N, prefer N*NB)
</span><span class="comment">*</span><span class="comment">
</span> IF( ILVL ) THEN
CALL <a name="CLASET.480"></a><a href="claset.f.html#CLASET.1">CLASET</a>( <span class="string">'Full'</span>, N, N, CZERO, CONE, VL, LDVL )
IF( IROWS.GT.1 ) THEN
CALL <a name="CLACPY.482"></a><a href="clacpy.f.html#CLACPY.1">CLACPY</a>( <span class="string">'L'</span>, IROWS-1, IROWS-1, B( ILO+1, ILO ), LDB,
$ VL( ILO+1, ILO ), LDVL )
END IF
CALL <a name="CUNGQR.485"></a><a href="cungqr.f.html#CUNGQR.1">CUNGQR</a>( IROWS, IROWS, IROWS, VL( ILO, ILO ), LDVL,
$ WORK( ITAU ), WORK( IWRK ), LWORK+1-IWRK, IERR )
END IF
<span class="comment">*</span><span class="comment">
</span> IF( ILVR )
$ CALL <a name="CLASET.490"></a><a href="claset.f.html#CLASET.1">CLASET</a>( <span class="string">'Full'</span>, N, N, CZERO, CONE, VR, LDVR )
<span class="comment">*</span><span class="comment">
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?