sgees.f.html
来自「famous linear algebra library (LAPACK) p」· HTML 代码 · 共 459 行 · 第 1/3 页
HTML
459 行
</span><span class="comment">*</span><span class="comment"> could also be caused by underflow due to scaling.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> =====================================================================
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> .. Parameters ..
</span> REAL ZERO, ONE
PARAMETER ( ZERO = 0.0E0, ONE = 1.0E0 )
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. Local Scalars ..
</span> LOGICAL CURSL, LASTSL, LQUERY, LST2SL, SCALEA, WANTST,
$ WANTVS
INTEGER HSWORK, I, I1, I2, IBAL, ICOND, IERR, IEVAL,
$ IHI, ILO, INXT, IP, ITAU, IWRK, MAXWRK, MINWRK
REAL ANRM, BIGNUM, CSCALE, EPS, S, SEP, SMLNUM
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. Local Arrays ..
</span> INTEGER IDUM( 1 )
REAL DUM( 1 )
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. External Subroutines ..
</span> EXTERNAL SCOPY, <a name="SGEBAK.155"></a><a href="sgebak.f.html#SGEBAK.1">SGEBAK</a>, <a name="SGEBAL.155"></a><a href="sgebal.f.html#SGEBAL.1">SGEBAL</a>, <a name="SGEHRD.155"></a><a href="sgehrd.f.html#SGEHRD.1">SGEHRD</a>, <a name="SHSEQR.155"></a><a href="shseqr.f.html#SHSEQR.1">SHSEQR</a>, <a name="SLABAD.155"></a><a href="slabad.f.html#SLABAD.1">SLABAD</a>,
$ <a name="SLACPY.156"></a><a href="slacpy.f.html#SLACPY.1">SLACPY</a>, <a name="SLASCL.156"></a><a href="slascl.f.html#SLASCL.1">SLASCL</a>, <a name="SORGHR.156"></a><a href="sorghr.f.html#SORGHR.1">SORGHR</a>, SSWAP, <a name="STRSEN.156"></a><a href="strsen.f.html#STRSEN.1">STRSEN</a>, <a name="XERBLA.156"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. External Functions ..
</span> LOGICAL <a name="LSAME.159"></a><a href="lsame.f.html#LSAME.1">LSAME</a>
INTEGER <a name="ILAENV.160"></a><a href="hfy-index.html#ILAENV">ILAENV</a>
REAL <a name="SLAMCH.161"></a><a href="slamch.f.html#SLAMCH.1">SLAMCH</a>, <a name="SLANGE.161"></a><a href="slange.f.html#SLANGE.1">SLANGE</a>
EXTERNAL <a name="LSAME.162"></a><a href="lsame.f.html#LSAME.1">LSAME</a>, <a name="ILAENV.162"></a><a href="hfy-index.html#ILAENV">ILAENV</a>, <a name="SLAMCH.162"></a><a href="slamch.f.html#SLAMCH.1">SLAMCH</a>, <a name="SLANGE.162"></a><a href="slange.f.html#SLANGE.1">SLANGE</a>
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. Intrinsic Functions ..
</span> INTRINSIC MAX, SQRT
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. Executable Statements ..
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Test the input arguments
</span><span class="comment">*</span><span class="comment">
</span> INFO = 0
LQUERY = ( LWORK.EQ.-1 )
WANTVS = <a name="LSAME.173"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( JOBVS, <span class="string">'V'</span> )
WANTST = <a name="LSAME.174"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( SORT, <span class="string">'S'</span> )
IF( ( .NOT.WANTVS ) .AND. ( .NOT.<a name="LSAME.175"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( JOBVS, <span class="string">'N'</span> ) ) ) THEN
INFO = -1
ELSE IF( ( .NOT.WANTST ) .AND. ( .NOT.<a name="LSAME.177"></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 = -11
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.192"></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="SHSEQR.193"></a><a href="shseqr.f.html#SHSEQR.1">SHSEQR</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 = 2*N + N*<a name="ILAENV.202"></a><a href="hfy-index.html#ILAENV">ILAENV</a>( 1, <span class="string">'<a name="SGEHRD.202"></a><a href="sgehrd.f.html#SGEHRD.1">SGEHRD</a>'</span>, <span class="string">' '</span>, N, 1, N, 0 )
MINWRK = 3*N
<span class="comment">*</span><span class="comment">
</span> CALL <a name="SHSEQR.205"></a><a href="shseqr.f.html#SHSEQR.1">SHSEQR</a>( <span class="string">'S'</span>, JOBVS, N, 1, N, A, LDA, WR, WI, VS, LDVS,
$ WORK, -1, IEVAL )
HSWORK = WORK( 1 )
<span class="comment">*</span><span class="comment">
</span> IF( .NOT.WANTVS ) THEN
MAXWRK = MAX( MAXWRK, N + HSWORK )
ELSE
MAXWRK = MAX( MAXWRK, 2*N + ( N - 1 )*<a name="ILAENV.212"></a><a href="hfy-index.html#ILAENV">ILAENV</a>( 1,
$ <span class="string">'<a name="SORGHR.213"></a><a href="sorghr.f.html#SORGHR.1">SORGHR</a>'</span>, <span class="string">' '</span>, N, 1, N, -1 ) )
MAXWRK = MAX( MAXWRK, N + 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 = -13
END IF
END IF
<span class="comment">*</span><span class="comment">
</span> IF( INFO.NE.0 ) THEN
CALL <a name="XERBLA.225"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>( <span class="string">'<a name="SGEES.225"></a><a href="sgees.f.html#SGEES.1">SGEES</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.240"></a><a href="slamch.f.html#SLAMCH.1">SLAMCH</a>( <span class="string">'P'</span> )
SMLNUM = <a name="SLAMCH.241"></a><a href="slamch.f.html#SLAMCH.1">SLAMCH</a>( <span class="string">'S'</span> )
BIGNUM = ONE / SMLNUM
CALL <a name="SLABAD.243"></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="SLANGE.249"></a><a href="slange.f.html#SLANGE.1">SLANGE</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="SLASCL.259"></a><a href="slascl.f.html#SLASCL.1">SLASCL</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"> (Workspace: need N)
</span><span class="comment">*</span><span class="comment">
</span> IBAL = 1
CALL <a name="SGEBAL.265"></a><a href="sgebal.f.html#SGEBAL.1">SGEBAL</a>( <span class="string">'P'</span>, N, A, LDA, ILO, IHI, WORK( 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"> (Workspace: need 3*N, prefer 2*N+N*NB)
</span><span class="comment">*</span><span class="comment">
</span> ITAU = N + IBAL
IWRK = N + ITAU
CALL <a name="SGEHRD.272"></a><a href="sgehrd.f.html#SGEHRD.1">SGEHRD</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="SLACPY.279"></a><a href="slacpy.f.html#SLACPY.1">SLACPY</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 orthogonal matrix in VS
</span><span class="comment">*</span><span class="comment"> (Workspace: need 3*N-1, prefer 2*N+(N-1)*NB)
</span><span class="comment">*</span><span class="comment">
</span> CALL <a name="SORGHR.284"></a><a href="sorghr.f.html#SORGHR.1">SORGHR</a>( N, ILO, IHI, VS, LDVS, WORK( ITAU ), WORK( IWRK ),
$ LWORK-IWRK+1, IERR )
END IF
<span class="comment">*</span><span class="comment">
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?