ssygvd.f.html
来自「famous linear algebra library (LAPACK) p」· HTML 代码 · 共 307 行 · 第 1/2 页
HTML
307 行
</span><span class="comment">*</span><span class="comment"> Further Details
</span><span class="comment">*</span><span class="comment"> ===============
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Based on contributions by
</span><span class="comment">*</span><span class="comment"> Mark Fahey, Department of Mathematics, Univ. of Kentucky, USA
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Modified so that no backsubstitution is performed if <a name="SSYEVD.142"></a><a href="ssyevd.f.html#SSYEVD.1">SSYEVD</a> fails to
</span><span class="comment">*</span><span class="comment"> converge (NEIG in old code could be greater than N causing out of
</span><span class="comment">*</span><span class="comment"> bounds reference to A - reported by Ralf Meyer). Also corrected the
</span><span class="comment">*</span><span class="comment"> description of INFO and the test on ITYPE. Sven, 16 Feb 05.
</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 ONE
PARAMETER ( ONE = 1.0E+0 )
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. Local Scalars ..
</span> LOGICAL LQUERY, UPPER, WANTZ
CHARACTER TRANS
INTEGER LIOPT, LIWMIN, LOPT, LWMIN
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. External Functions ..
</span> LOGICAL <a name="LSAME.158"></a><a href="lsame.f.html#LSAME.1">LSAME</a>
EXTERNAL <a name="LSAME.159"></a><a href="lsame.f.html#LSAME.1">LSAME</a>
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. External Subroutines ..
</span> EXTERNAL <a name="SPOTRF.162"></a><a href="spotrf.f.html#SPOTRF.1">SPOTRF</a>, <a name="SSYEVD.162"></a><a href="ssyevd.f.html#SSYEVD.1">SSYEVD</a>, <a name="SSYGST.162"></a><a href="ssygst.f.html#SSYGST.1">SSYGST</a>, STRMM, STRSM, <a name="XERBLA.162"></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 MAX, REAL
<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.171"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( JOBZ, <span class="string">'V'</span> )
UPPER = <a name="LSAME.172"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( UPLO, <span class="string">'U'</span> )
LQUERY = ( LWORK.EQ.-1 .OR. LIWORK.EQ.-1 )
<span class="comment">*</span><span class="comment">
</span> INFO = 0
IF( N.LE.1 ) THEN
LIWMIN = 1
LWMIN = 1
ELSE IF( WANTZ ) THEN
LIWMIN = 3 + 5*N
LWMIN = 1 + 6*N + 2*N**2
ELSE
LIWMIN = 1
LWMIN = 2*N + 1
END IF
LOPT = LWMIN
LIOPT = LIWMIN
IF( ITYPE.LT.1 .OR. ITYPE.GT.3 ) THEN
INFO = -1
ELSE IF( .NOT.( WANTZ .OR. <a name="LSAME.190"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( JOBZ, <span class="string">'N'</span> ) ) ) THEN
INFO = -2
ELSE IF( .NOT.( UPPER .OR. <a name="LSAME.192"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( UPLO, <span class="string">'L'</span> ) ) ) THEN
INFO = -3
ELSE IF( N.LT.0 ) THEN
INFO = -4
ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
INFO = -6
ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
INFO = -8
END IF
<span class="comment">*</span><span class="comment">
</span> IF( INFO.EQ.0 ) THEN
WORK( 1 ) = LOPT
IWORK( 1 ) = LIOPT
<span class="comment">*</span><span class="comment">
</span> IF( LWORK.LT.LWMIN .AND. .NOT.LQUERY ) THEN
INFO = -11
ELSE IF( LIWORK.LT.LIWMIN .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.214"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>( <span class="string">'<a name="SSYGVD.214"></a><a href="ssygvd.f.html#SSYGVD.1">SSYGVD</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"> Form a Cholesky factorization of B.
</span><span class="comment">*</span><span class="comment">
</span> CALL <a name="SPOTRF.227"></a><a href="spotrf.f.html#SPOTRF.1">SPOTRF</a>( UPLO, N, B, LDB, INFO )
IF( INFO.NE.0 ) THEN
INFO = N + INFO
RETURN
END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Transform problem to standard eigenvalue problem and solve.
</span><span class="comment">*</span><span class="comment">
</span> CALL <a name="SSYGST.235"></a><a href="ssygst.f.html#SSYGST.1">SSYGST</a>( ITYPE, UPLO, N, A, LDA, B, LDB, INFO )
CALL <a name="SSYEVD.236"></a><a href="ssyevd.f.html#SSYEVD.1">SSYEVD</a>( JOBZ, UPLO, N, A, LDA, W, WORK, LWORK, IWORK, LIWORK,
$ INFO )
LOPT = MAX( REAL( LOPT ), REAL( WORK( 1 ) ) )
LIOPT = MAX( REAL( LIOPT ), REAL( IWORK( 1 ) ) )
<span class="comment">*</span><span class="comment">
</span> IF( WANTZ .AND. INFO.EQ.0 ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Backtransform eigenvectors to the original problem.
</span><span class="comment">*</span><span class="comment">
</span> IF( ITYPE.EQ.1 .OR. ITYPE.EQ.2 ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> For A*x=(lambda)*B*x and A*B*x=(lambda)*x;
</span><span class="comment">*</span><span class="comment"> backtransform eigenvectors: x = inv(L)'*y or inv(U)*y
</span><span class="comment">*</span><span class="comment">
</span> IF( UPPER ) THEN
TRANS = <span class="string">'N'</span>
ELSE
TRANS = <span class="string">'T'</span>
END IF
<span class="comment">*</span><span class="comment">
</span> CALL STRSM( <span class="string">'Left'</span>, UPLO, TRANS, <span class="string">'Non-unit'</span>, N, N, ONE,
$ B, LDB, A, LDA )
<span class="comment">*</span><span class="comment">
</span> ELSE IF( ITYPE.EQ.3 ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> For B*A*x=(lambda)*x;
</span><span class="comment">*</span><span class="comment"> backtransform eigenvectors: x = L*y or U'*y
</span><span class="comment">*</span><span class="comment">
</span> IF( UPPER ) THEN
TRANS = <span class="string">'T'</span>
ELSE
TRANS = <span class="string">'N'</span>
END IF
<span class="comment">*</span><span class="comment">
</span> CALL STRMM( <span class="string">'Left'</span>, UPLO, TRANS, <span class="string">'Non-unit'</span>, N, N, ONE,
$ B, LDB, A, LDA )
END IF
END IF
<span class="comment">*</span><span class="comment">
</span> WORK( 1 ) = LOPT
IWORK( 1 ) = LIOPT
<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="SSYGVD.280"></a><a href="ssygvd.f.html#SSYGVD.1">SSYGVD</a>
</span><span class="comment">*</span><span class="comment">
</span> END
</pre>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?