cgees.f.html
来自「famous linear algebra library (LAPACK) p」· HTML 代码 · 共 349 行 · 第 1/2 页
HTML
349 行
ELSE IF( ( .NOT.WANTST ) .AND. ( .NOT.<a name="LSAME.157"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( SORT, <span class="string">'N'</span> ) ) ) THEN
INFO = -2
ELSE IF( N.LT.0 ) THEN
INFO = -4
ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
INFO = -6
ELSE IF( LDVS.LT.1 .OR. ( WANTVS .AND. LDVS.LT.N ) ) THEN
INFO = -10
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"> CWorkspace refers to complex workspace, and RWorkspace to real
</span><span class="comment">*</span><span class="comment"> workspace. NB refers to the optimal block size for the
</span><span class="comment">*</span><span class="comment"> immediately following subroutine, as returned by <a name="ILAENV.173"></a><a href="hfy-index.html#ILAENV">ILAENV</a>.
</span><span class="comment">*</span><span class="comment"> HSWORK refers to the workspace preferred by <a name="CHSEQR.174"></a><a href="chseqr.f.html#CHSEQR.1">CHSEQR</a>, as
</span><span class="comment">*</span><span class="comment"> calculated below. HSWORK is computed assuming ILO=1 and IHI=N,
</span><span class="comment">*</span><span class="comment"> 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
MAXWRK = N + N*<a name="ILAENV.183"></a><a href="hfy-index.html#ILAENV">ILAENV</a>( 1, <span class="string">'<a name="CGEHRD.183"></a><a href="cgehrd.f.html#CGEHRD.1">CGEHRD</a>'</span>, <span class="string">' '</span>, N, 1, N, 0 )
MINWRK = 2*N
<span class="comment">*</span><span class="comment">
</span> CALL <a name="CHSEQR.186"></a><a href="chseqr.f.html#CHSEQR.1">CHSEQR</a>( <span class="string">'S'</span>, JOBVS, N, 1, N, A, LDA, W, VS, LDVS,
$ WORK, -1, IEVAL )
HSWORK = WORK( 1 )
<span class="comment">*</span><span class="comment">
</span> IF( .NOT.WANTVS ) THEN
MAXWRK = MAX( MAXWRK, HSWORK )
ELSE
MAXWRK = MAX( MAXWRK, N + ( N - 1 )*<a name="ILAENV.193"></a><a href="hfy-index.html#ILAENV">ILAENV</a>( 1, <span class="string">'<a name="CUNGHR.193"></a><a href="cunghr.f.html#CUNGHR.1">CUNGHR</a>'</span>,
$ <span class="string">' '</span>, N, 1, N, -1 ) )
MAXWRK = MAX( MAXWRK, HSWORK )
END IF
END IF
WORK( 1 ) = MAXWRK
<span class="comment">*</span><span class="comment">
</span> IF( LWORK.LT.MINWRK .AND. .NOT.LQUERY ) THEN
INFO = -12
END IF
END IF
<span class="comment">*</span><span class="comment">
</span> IF( INFO.NE.0 ) THEN
CALL <a name="XERBLA.206"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>( <span class="string">'<a name="CGEES.206"></a><a href="cgees.f.html#CGEES.1">CGEES</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 ) THEN
SDIM = 0
RETURN
END IF
<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.221"></a><a href="slamch.f.html#SLAMCH.1">SLAMCH</a>( <span class="string">'P'</span> )
SMLNUM = <a name="SLAMCH.222"></a><a href="slamch.f.html#SLAMCH.1">SLAMCH</a>( <span class="string">'S'</span> )
BIGNUM = ONE / SMLNUM
CALL <a name="SLABAD.224"></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.230"></a><a href="clange.f.html#CLANGE.1">CLANGE</a>( <span class="string">'M'</span>, N, N, A, LDA, DUM )
SCALEA = .FALSE.
IF( ANRM.GT.ZERO .AND. ANRM.LT.SMLNUM ) THEN
SCALEA = .TRUE.
CSCALE = SMLNUM
ELSE IF( ANRM.GT.BIGNUM ) THEN
SCALEA = .TRUE.
CSCALE = BIGNUM
END IF
IF( SCALEA )
$ CALL <a name="CLASCL.240"></a><a href="clascl.f.html#CLASCL.1">CLASCL</a>( <span class="string">'G'</span>, 0, 0, ANRM, CSCALE, N, N, A, LDA, IERR )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Permute the matrix to make it more nearly triangular
</span><span class="comment">*</span><span class="comment"> (CWorkspace: none)
</span><span class="comment">*</span><span class="comment"> (RWorkspace: need N)
</span><span class="comment">*</span><span class="comment">
</span> IBAL = 1
CALL <a name="CGEBAL.247"></a><a href="cgebal.f.html#CGEBAL.1">CGEBAL</a>( <span class="string">'P'</span>, N, A, LDA, ILO, IHI, RWORK( IBAL ), IERR )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Reduce to upper Hessenberg form
</span><span class="comment">*</span><span class="comment"> (CWorkspace: need 2*N, prefer N+N*NB)
</span><span class="comment">*</span><span class="comment"> (RWorkspace: none)
</span><span class="comment">*</span><span class="comment">
</span> ITAU = 1
IWRK = N + ITAU
CALL <a name="CGEHRD.255"></a><a href="cgehrd.f.html#CGEHRD.1">CGEHRD</a>( N, ILO, IHI, A, LDA, WORK( ITAU ), WORK( IWRK ),
$ LWORK-IWRK+1, IERR )
<span class="comment">*</span><span class="comment">
</span> IF( WANTVS ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Copy Householder vectors to VS
</span><span class="comment">*</span><span class="comment">
</span> CALL <a name="CLACPY.262"></a><a href="clacpy.f.html#CLACPY.1">CLACPY</a>( <span class="string">'L'</span>, N, N, A, LDA, VS, LDVS )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Generate unitary matrix in VS
</span><span class="comment">*</span><span class="comment"> (CWorkspace: need 2*N-1, prefer N+(N-1)*NB)
</span><span class="comment">*</span><span class="comment"> (RWorkspace: none)
</span><span class="comment">*</span><span class="comment">
</span> CALL <a name="CUNGHR.268"></a><a href="cunghr.f.html#CUNGHR.1">CUNGHR</a>( N, ILO, IHI, VS, LDVS, WORK( ITAU ), WORK( IWRK ),
$ LWORK-IWRK+1, IERR )
END IF
<span class="comment">*</span><span class="comment">
</span> SDIM = 0
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Perform QR iteration, accumulating Schur vectors in VS if desired
</span><span class="comment">*</span><span class="comment"> (CWorkspace: need 1, prefer HSWORK (see comments) )
</span><span class="comment">*</span><span class="comment"> (RWorkspace: none)
</span><span class="comment">*</span><span class="comment">
</span> IWRK = ITAU
CALL <a name="CHSEQR.279"></a><a href="chseqr.f.html#CHSEQR.1">CHSEQR</a>( <span class="string">'S'</span>, JOBVS, N, ILO, IHI, A, LDA, W, VS, LDVS,
$ WORK( IWRK ), LWORK-IWRK+1, IEVAL )
IF( IEVAL.GT.0 )
$ INFO = IEVAL
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Sort eigenvalues if desired
</span><span class="comment">*</span><span class="comment">
</span> IF( WANTST .AND. INFO.EQ.0 ) THEN
IF( SCALEA )
$ CALL <a name="CLASCL.288"></a><a href="clascl.f.html#CLASCL.1">CLASCL</a>( <span class="string">'G'</span>, 0, 0, CSCALE, ANRM, N, 1, W, N, IERR )
DO 10 I = 1, N
BWORK( I ) = SELECT( W( I ) )
10 CONTINUE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Reorder eigenvalues and transform Schur vectors
</span><span class="comment">*</span><span class="comment"> (CWorkspace: none)
</span><span class="comment">*</span><span class="comment"> (RWorkspace: none)
</span><span class="comment">*</span><span class="comment">
</span> CALL <a name="CTRSEN.297"></a><a href="ctrsen.f.html#CTRSEN.1">CTRSEN</a>( <span class="string">'N'</span>, JOBVS, BWORK, N, A, LDA, VS, LDVS, W, SDIM,
$ S, SEP, WORK( IWRK ), LWORK-IWRK+1, ICOND )
END IF
<span class="comment">*</span><span class="comment">
</span> IF( WANTVS ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Undo balancing
</span><span class="comment">*</span><span class="comment"> (CWorkspace: none)
</span><span class="comment">*</span><span class="comment"> (RWorkspace: need N)
</span><span class="comment">*</span><span class="comment">
</span> CALL <a name="CGEBAK.307"></a><a href="cgebak.f.html#CGEBAK.1">CGEBAK</a>( <span class="string">'P'</span>, <span class="string">'R'</span>, N, ILO, IHI, RWORK( IBAL ), N, VS, LDVS,
$ IERR )
END IF
<span class="comment">*</span><span class="comment">
</span> IF( SCALEA ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Undo scaling for the Schur form of A
</span><span class="comment">*</span><span class="comment">
</span> CALL <a name="CLASCL.315"></a><a href="clascl.f.html#CLASCL.1">CLASCL</a>( <span class="string">'U'</span>, 0, 0, CSCALE, ANRM, N, N, A, LDA, IERR )
CALL CCOPY( N, A, LDA+1, W, 1 )
END IF
<span class="comment">*</span><span class="comment">
</span> WORK( 1 ) = MAXWRK
RETURN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> End of <a name="CGEES.322"></a><a href="cgees.f.html#CGEES.1">CGEES</a>
</span><span class="comment">*</span><span class="comment">
</span> END
</pre>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?