chpev.f.html
来自「famous linear algebra library (LAPACK) p」· HTML 代码 · 共 221 行 · 第 1/2 页
HTML
221 行
</span><span class="comment">*</span><span class="comment"> .. External Subroutines ..
</span> EXTERNAL <a name="CHPTRD.94"></a><a href="chptrd.f.html#CHPTRD.1">CHPTRD</a>, CSSCAL, <a name="CSTEQR.94"></a><a href="csteqr.f.html#CSTEQR.1">CSTEQR</a>, <a name="CUPGTR.94"></a><a href="cupgtr.f.html#CUPGTR.1">CUPGTR</a>, SSCAL, <a name="SSTERF.94"></a><a href="ssterf.f.html#SSTERF.1">SSTERF</a>,
$ <a name="XERBLA.95"></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 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> WANTZ = <a name="LSAME.104"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( JOBZ, <span class="string">'V'</span> )
<span class="comment">*</span><span class="comment">
</span> INFO = 0
IF( .NOT.( WANTZ .OR. <a name="LSAME.107"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( JOBZ, <span class="string">'N'</span> ) ) ) THEN
INFO = -1
ELSE IF( .NOT.( <a name="LSAME.109"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( UPLO, <span class="string">'L'</span> ) .OR. <a name="LSAME.109"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( UPLO, <span class="string">'U'</span> ) ) )
$ THEN
INFO = -2
ELSE IF( N.LT.0 ) THEN
INFO = -3
ELSE IF( LDZ.LT.1 .OR. ( WANTZ .AND. LDZ.LT.N ) ) THEN
INFO = -7
END IF
<span class="comment">*</span><span class="comment">
</span> IF( INFO.NE.0 ) THEN
CALL <a name="XERBLA.119"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>( <span class="string">'<a name="CHPEV.119"></a><a href="chpev.f.html#CHPEV.1">CHPEV</a> '</span>, -INFO )
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> IF( N.EQ.1 ) THEN
W( 1 ) = AP( 1 )
RWORK( 1 ) = 1
IF( WANTZ )
$ Z( 1, 1 ) = ONE
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> SAFMIN = <a name="SLAMCH.138"></a><a href="slamch.f.html#SLAMCH.1">SLAMCH</a>( <span class="string">'Safe minimum'</span> )
EPS = <a name="SLAMCH.139"></a><a href="slamch.f.html#SLAMCH.1">SLAMCH</a>( <span class="string">'Precision'</span> )
SMLNUM = SAFMIN / EPS
BIGNUM = ONE / SMLNUM
RMIN = SQRT( SMLNUM )
RMAX = SQRT( BIGNUM )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Scale matrix to allowable range, if necessary.
</span><span class="comment">*</span><span class="comment">
</span> ANRM = <a name="CLANHP.147"></a><a href="clanhp.f.html#CLANHP.1">CLANHP</a>( <span class="string">'M'</span>, UPLO, N, AP, RWORK )
ISCALE = 0
IF( ANRM.GT.ZERO .AND. ANRM.LT.RMIN ) THEN
ISCALE = 1
SIGMA = RMIN / ANRM
ELSE IF( ANRM.GT.RMAX ) THEN
ISCALE = 1
SIGMA = RMAX / ANRM
END IF
IF( ISCALE.EQ.1 ) THEN
CALL CSSCAL( ( N*( N+1 ) ) / 2, SIGMA, AP, 1 )
END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Call <a name="CHPTRD.160"></a><a href="chptrd.f.html#CHPTRD.1">CHPTRD</a> to reduce Hermitian packed matrix to tridiagonal form.
</span><span class="comment">*</span><span class="comment">
</span> INDE = 1
INDTAU = 1
CALL <a name="CHPTRD.164"></a><a href="chptrd.f.html#CHPTRD.1">CHPTRD</a>( UPLO, N, AP, W, RWORK( INDE ), WORK( INDTAU ),
$ IINFO )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> For eigenvalues only, call <a name="SSTERF.167"></a><a href="ssterf.f.html#SSTERF.1">SSTERF</a>. For eigenvectors, first call
</span><span class="comment">*</span><span class="comment"> <a name="CUPGTR.168"></a><a href="cupgtr.f.html#CUPGTR.1">CUPGTR</a> to generate the orthogonal matrix, then call <a name="CSTEQR.168"></a><a href="csteqr.f.html#CSTEQR.1">CSTEQR</a>.
</span><span class="comment">*</span><span class="comment">
</span> IF( .NOT.WANTZ ) THEN
CALL <a name="SSTERF.171"></a><a href="ssterf.f.html#SSTERF.1">SSTERF</a>( N, W, RWORK( INDE ), INFO )
ELSE
INDWRK = INDTAU + N
CALL <a name="CUPGTR.174"></a><a href="cupgtr.f.html#CUPGTR.1">CUPGTR</a>( UPLO, N, AP, WORK( INDTAU ), Z, LDZ,
$ WORK( INDWRK ), IINFO )
INDRWK = INDE + N
CALL <a name="CSTEQR.177"></a><a href="csteqr.f.html#CSTEQR.1">CSTEQR</a>( JOBZ, N, W, RWORK( INDE ), Z, LDZ,
$ RWORK( INDRWK ), INFO )
END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> If matrix was scaled, then rescale eigenvalues appropriately.
</span><span class="comment">*</span><span class="comment">
</span> IF( ISCALE.EQ.1 ) THEN
IF( INFO.EQ.0 ) THEN
IMAX = N
ELSE
IMAX = INFO - 1
END IF
CALL SSCAL( IMAX, ONE / SIGMA, W, 1 )
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="CHPEV.194"></a><a href="chpev.f.html#CHPEV.1">CHPEV</a>
</span><span class="comment">*</span><span class="comment">
</span> END
</pre>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?