sstedc.f.html
来自「famous linear algebra library (LAPACK) p」· HTML 代码 · 共 431 行 · 第 1/3 页
HTML
431 行
</span> REAL ZERO, ONE, TWO
PARAMETER ( ZERO = 0.0E0, ONE = 1.0E0, TWO = 2.0E0 )
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. Local Scalars ..
</span> LOGICAL LQUERY
INTEGER FINISH, I, ICOMPZ, II, J, K, LGN, LIWMIN,
$ LWMIN, M, SMLSIZ, START, STOREZ, STRTRW
REAL EPS, ORGNRM, P, TINY
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. External Functions ..
</span> LOGICAL <a name="LSAME.136"></a><a href="lsame.f.html#LSAME.1">LSAME</a>
INTEGER <a name="ILAENV.137"></a><a href="hfy-index.html#ILAENV">ILAENV</a>
REAL <a name="SLAMCH.138"></a><a href="slamch.f.html#SLAMCH.1">SLAMCH</a>, <a name="SLANST.138"></a><a href="slanst.f.html#SLANST.1">SLANST</a>
EXTERNAL <a name="ILAENV.139"></a><a href="hfy-index.html#ILAENV">ILAENV</a>, <a name="LSAME.139"></a><a href="lsame.f.html#LSAME.1">LSAME</a>, <a name="SLAMCH.139"></a><a href="slamch.f.html#SLAMCH.1">SLAMCH</a>, <a name="SLANST.139"></a><a href="slanst.f.html#SLANST.1">SLANST</a>
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. External Subroutines ..
</span> EXTERNAL SGEMM, <a name="SLACPY.142"></a><a href="slacpy.f.html#SLACPY.1">SLACPY</a>, <a name="SLAED0.142"></a><a href="slaed0.f.html#SLAED0.1">SLAED0</a>, <a name="SLASCL.142"></a><a href="slascl.f.html#SLASCL.1">SLASCL</a>, <a name="SLASET.142"></a><a href="slaset.f.html#SLASET.1">SLASET</a>, <a name="SLASRT.142"></a><a href="slasrt.f.html#SLASRT.1">SLASRT</a>,
$ <a name="SSTEQR.143"></a><a href="ssteqr.f.html#SSTEQR.1">SSTEQR</a>, <a name="SSTERF.143"></a><a href="ssterf.f.html#SSTERF.1">SSTERF</a>, SSWAP, <a name="XERBLA.143"></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"> .. Intrinsic Functions ..
</span> INTRINSIC ABS, INT, LOG, MAX, MOD, REAL, 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 parameters.
</span><span class="comment">*</span><span class="comment">
</span> INFO = 0
LQUERY = ( LWORK.EQ.-1 .OR. LIWORK.EQ.-1 )
<span class="comment">*</span><span class="comment">
</span> IF( <a name="LSAME.155"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( COMPZ, <span class="string">'N'</span> ) ) THEN
ICOMPZ = 0
ELSE IF( <a name="LSAME.157"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( COMPZ, <span class="string">'V'</span> ) ) THEN
ICOMPZ = 1
ELSE IF( <a name="LSAME.159"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( COMPZ, <span class="string">'I'</span> ) ) THEN
ICOMPZ = 2
ELSE
ICOMPZ = -1
END IF
IF( ICOMPZ.LT.0 ) THEN
INFO = -1
ELSE IF( N.LT.0 ) THEN
INFO = -2
ELSE IF( ( LDZ.LT.1 ) .OR.
$ ( ICOMPZ.GT.0 .AND. LDZ.LT.MAX( 1, N ) ) ) THEN
INFO = -6
END IF
<span class="comment">*</span><span class="comment">
</span> IF( INFO.EQ.0 ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Compute the workspace requirements
</span><span class="comment">*</span><span class="comment">
</span> SMLSIZ = <a name="ILAENV.177"></a><a href="hfy-index.html#ILAENV">ILAENV</a>( 9, <span class="string">'<a name="SSTEDC.177"></a><a href="sstedc.f.html#SSTEDC.1">SSTEDC</a>'</span>, <span class="string">' '</span>, 0, 0, 0, 0 )
IF( N.LE.1 .OR. ICOMPZ.EQ.0 ) THEN
LIWMIN = 1
LWMIN = 1
ELSE IF( N.LE.SMLSIZ ) THEN
LIWMIN = 1
LWMIN = 2*( N - 1 )
ELSE
LGN = INT( LOG( REAL( N ) )/LOG( TWO ) )
IF( 2**LGN.LT.N )
$ LGN = LGN + 1
IF( 2**LGN.LT.N )
$ LGN = LGN + 1
IF( ICOMPZ.EQ.1 ) THEN
LWMIN = 1 + 3*N + 2*N*LGN + 3*N**2
LIWMIN = 6 + 6*N + 5*N*LGN
ELSE IF( ICOMPZ.EQ.2 ) THEN
LWMIN = 1 + 4*N + N**2
LIWMIN = 3 + 5*N
END IF
END IF
WORK( 1 ) = LWMIN
IWORK( 1 ) = LIWMIN
<span class="comment">*</span><span class="comment">
</span> IF( LWORK.LT.LWMIN .AND. .NOT. LQUERY ) THEN
INFO = -8
ELSE IF( LIWORK.LT.LIWMIN .AND. .NOT. LQUERY ) THEN
INFO = -10
END IF
END IF
<span class="comment">*</span><span class="comment">
</span> IF( INFO.NE.0 ) THEN
CALL <a name="XERBLA.209"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>( <span class="string">'<a name="SSTEDC.209"></a><a href="sstedc.f.html#SSTEDC.1">SSTEDC</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
IF( N.EQ.1 ) THEN
IF( ICOMPZ.NE.0 )
$ Z( 1, 1 ) = ONE
RETURN
END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> If the following conditional clause is removed, then the routine
</span><span class="comment">*</span><span class="comment"> will use the Divide and Conquer routine to compute only the
</span><span class="comment">*</span><span class="comment"> eigenvalues, which requires (3N + 3N**2) real workspace and
</span><span class="comment">*</span><span class="comment"> (2 + 5N + 2N lg(N)) integer workspace.
</span><span class="comment">*</span><span class="comment"> Since on many architectures <a name="SSTERF.229"></a><a href="ssterf.f.html#SSTERF.1">SSTERF</a> is much faster than any other
</span><span class="comment">*</span><span class="comment"> algorithm for finding eigenvalues only, it is used here
</span><span class="comment">*</span><span class="comment"> as the default. If the conditional clause is removed, then
</span><span class="comment">*</span><span class="comment"> information on the size of workspace needs to be changed.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> If COMPZ = 'N', use <a name="SSTERF.234"></a><a href="ssterf.f.html#SSTERF.1">SSTERF</a> to compute the eigenvalues.
</span><span class="comment">*</span><span class="comment">
</span> IF( ICOMPZ.EQ.0 ) THEN
CALL <a name="SSTERF.237"></a><a href="ssterf.f.html#SSTERF.1">SSTERF</a>( N, D, E, INFO )
GO TO 50
END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> If N is smaller than the minimum divide size (SMLSIZ+1), then
</span><span class="comment">*</span><span class="comment"> solve the problem with another solver.
</span><span class="comment">*</span><span class="comment">
</span> IF( N.LE.SMLSIZ ) THEN
<span class="comment">*</span><span class="comment">
</span> CALL <a name="SSTEQR.246"></a><a href="ssteqr.f.html#SSTEQR.1">SSTEQR</a>( COMPZ, N, D, E, Z, LDZ, WORK, INFO )
<span class="comment">*</span><span class="comment">
</span> ELSE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> If COMPZ = 'V', the Z matrix must be stored elsewhere for later
</span><span class="comment">*</span><span class="comment"> use.
</span><span class="comment">*</span><span class="comment">
</span> IF( ICOMPZ.EQ.1 ) THEN
STOREZ = 1 + N*N
ELSE
STOREZ = 1
END IF
<span class="comment">*</span><span class="comment">
</span> IF( ICOMPZ.EQ.2 ) THEN
CALL <a name="SLASET.260"></a><a href="slaset.f.html#SLASET.1">SLASET</a>( <span class="string">'Full'</span>, N, N, ZERO, ONE, Z, LDZ )
END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Scale.
</span><span class="comment">*</span><span class="comment">
</span> ORGNRM = <a name="SLANST.265"></a><a href="slanst.f.html#SLANST.1">SLANST</a>( <span class="string">'M'</span>, N, D, E )
IF( ORGNRM.EQ.ZERO )
$ GO TO 50
<span class="comment">*</span><span class="comment">
</span> EPS = <a name="SLAMCH.269"></a><a href="slamch.f.html#SLAMCH.1">SLAMCH</a>( <span class="string">'Epsilon'</span> )
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?