cggsvd.f.html
来自「famous linear algebra library (LAPACK) p」· HTML 代码 · 共 358 行 · 第 1/2 页
HTML
358 行
</span><span class="comment">*</span><span class="comment"> BETA(K+L+1:N) = 0
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> U (output) COMPLEX array, dimension (LDU,M)
</span><span class="comment">*</span><span class="comment"> If JOBU = 'U', U contains the M-by-M unitary matrix U.
</span><span class="comment">*</span><span class="comment"> If JOBU = 'N', U is not referenced.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> LDU (input) INTEGER
</span><span class="comment">*</span><span class="comment"> The leading dimension of the array U. LDU >= max(1,M) if
</span><span class="comment">*</span><span class="comment"> JOBU = 'U'; LDU >= 1 otherwise.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> V (output) COMPLEX array, dimension (LDV,P)
</span><span class="comment">*</span><span class="comment"> If JOBV = 'V', V contains the P-by-P unitary matrix V.
</span><span class="comment">*</span><span class="comment"> If JOBV = 'N', V is not referenced.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> LDV (input) INTEGER
</span><span class="comment">*</span><span class="comment"> The leading dimension of the array V. LDV >= max(1,P) if
</span><span class="comment">*</span><span class="comment"> JOBV = 'V'; LDV >= 1 otherwise.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Q (output) COMPLEX array, dimension (LDQ,N)
</span><span class="comment">*</span><span class="comment"> If JOBQ = 'Q', Q contains the N-by-N unitary matrix Q.
</span><span class="comment">*</span><span class="comment"> If JOBQ = 'N', Q is not referenced.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> LDQ (input) INTEGER
</span><span class="comment">*</span><span class="comment"> The leading dimension of the array Q. LDQ >= max(1,N) if
</span><span class="comment">*</span><span class="comment"> JOBQ = 'Q'; LDQ >= 1 otherwise.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> WORK (workspace) COMPLEX array, dimension (max(3*N,M,P)+N)
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> RWORK (workspace) REAL array, dimension (2*N)
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> IWORK (workspace/output) INTEGER array, dimension (N)
</span><span class="comment">*</span><span class="comment"> On exit, IWORK stores the sorting information. More
</span><span class="comment">*</span><span class="comment"> precisely, the following loop will sort ALPHA
</span><span class="comment">*</span><span class="comment"> for I = K+1, min(M,K+L)
</span><span class="comment">*</span><span class="comment"> swap ALPHA(I) and ALPHA(IWORK(I))
</span><span class="comment">*</span><span class="comment"> endfor
</span><span class="comment">*</span><span class="comment"> such that ALPHA(1) >= ALPHA(2) >= ... >= ALPHA(N).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> INFO (output) INTEGER
</span><span class="comment">*</span><span class="comment"> = 0: successful exit.
</span><span class="comment">*</span><span class="comment"> < 0: if INFO = -i, the i-th argument had an illegal value.
</span><span class="comment">*</span><span class="comment"> > 0: if INFO = 1, the Jacobi-type procedure failed to
</span><span class="comment">*</span><span class="comment"> converge. For further details, see subroutine <a name="CTGSJA.203"></a><a href="ctgsja.f.html#CTGSJA.1">CTGSJA</a>.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Internal Parameters
</span><span class="comment">*</span><span class="comment"> ===================
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> TOLA REAL
</span><span class="comment">*</span><span class="comment"> TOLB REAL
</span><span class="comment">*</span><span class="comment"> TOLA and TOLB are the thresholds to determine the effective
</span><span class="comment">*</span><span class="comment"> rank of (A',B')'. Generally, they are set to
</span><span class="comment">*</span><span class="comment"> TOLA = MAX(M,N)*norm(A)*MACHEPS,
</span><span class="comment">*</span><span class="comment"> TOLB = MAX(P,N)*norm(B)*MACHEPS.
</span><span class="comment">*</span><span class="comment"> The size of TOLA and TOLB may affect the size of backward
</span><span class="comment">*</span><span class="comment"> errors of the decomposition.
</span><span class="comment">*</span><span class="comment">
</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"> 2-96 Based on modifications by
</span><span class="comment">*</span><span class="comment"> Ming Gu and Huan Ren, Computer Science Division, University of
</span><span class="comment">*</span><span class="comment"> California at Berkeley, USA
</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"> .. Local Scalars ..
</span> LOGICAL WANTQ, WANTU, WANTV
INTEGER I, IBND, ISUB, J, NCYCLE
REAL ANORM, BNORM, SMAX, TEMP, TOLA, TOLB, ULP, UNFL
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. External Functions ..
</span> LOGICAL <a name="LSAME.232"></a><a href="lsame.f.html#LSAME.1">LSAME</a>
REAL <a name="CLANGE.233"></a><a href="clange.f.html#CLANGE.1">CLANGE</a>, <a name="SLAMCH.233"></a><a href="slamch.f.html#SLAMCH.1">SLAMCH</a>
EXTERNAL <a name="LSAME.234"></a><a href="lsame.f.html#LSAME.1">LSAME</a>, <a name="CLANGE.234"></a><a href="clange.f.html#CLANGE.1">CLANGE</a>, <a name="SLAMCH.234"></a><a href="slamch.f.html#SLAMCH.1">SLAMCH</a>
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. External Subroutines ..
</span> EXTERNAL <a name="CGGSVP.237"></a><a href="cggsvp.f.html#CGGSVP.1">CGGSVP</a>, <a name="CTGSJA.237"></a><a href="ctgsja.f.html#CTGSJA.1">CTGSJA</a>, SCOPY, <a name="XERBLA.237"></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, MIN
<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"> Decode and test the input parameters
</span><span class="comment">*</span><span class="comment">
</span> WANTU = <a name="LSAME.246"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( JOBU, <span class="string">'U'</span> )
WANTV = <a name="LSAME.247"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( JOBV, <span class="string">'V'</span> )
WANTQ = <a name="LSAME.248"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( JOBQ, <span class="string">'Q'</span> )
<span class="comment">*</span><span class="comment">
</span> INFO = 0
IF( .NOT.( WANTU .OR. <a name="LSAME.251"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( JOBU, <span class="string">'N'</span> ) ) ) THEN
INFO = -1
ELSE IF( .NOT.( WANTV .OR. <a name="LSAME.253"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( JOBV, <span class="string">'N'</span> ) ) ) THEN
INFO = -2
ELSE IF( .NOT.( WANTQ .OR. <a name="LSAME.255"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( JOBQ, <span class="string">'N'</span> ) ) ) THEN
INFO = -3
ELSE IF( M.LT.0 ) THEN
INFO = -4
ELSE IF( N.LT.0 ) THEN
INFO = -5
ELSE IF( P.LT.0 ) THEN
INFO = -6
ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
INFO = -10
ELSE IF( LDB.LT.MAX( 1, P ) ) THEN
INFO = -12
ELSE IF( LDU.LT.1 .OR. ( WANTU .AND. LDU.LT.M ) ) THEN
INFO = -16
ELSE IF( LDV.LT.1 .OR. ( WANTV .AND. LDV.LT.P ) ) THEN
INFO = -18
ELSE IF( LDQ.LT.1 .OR. ( WANTQ .AND. LDQ.LT.N ) ) THEN
INFO = -20
END IF
IF( INFO.NE.0 ) THEN
CALL <a name="XERBLA.275"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>( <span class="string">'<a name="CGGSVD.275"></a><a href="cggsvd.f.html#CGGSVD.1">CGGSVD</a>'</span>, -INFO )
RETURN
END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Compute the Frobenius norm of matrices A and B
</span><span class="comment">*</span><span class="comment">
</span> ANORM = <a name="CLANGE.281"></a><a href="clange.f.html#CLANGE.1">CLANGE</a>( <span class="string">'1'</span>, M, N, A, LDA, RWORK )
BNORM = <a name="CLANGE.282"></a><a href="clange.f.html#CLANGE.1">CLANGE</a>( <span class="string">'1'</span>, P, N, B, LDB, RWORK )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Get machine precision and set up threshold for determining
</span><span class="comment">*</span><span class="comment"> the effective numerical rank of the matrices A and B.
</span><span class="comment">*</span><span class="comment">
</span> ULP = <a name="SLAMCH.287"></a><a href="slamch.f.html#SLAMCH.1">SLAMCH</a>( <span class="string">'Precision'</span> )
UNFL = <a name="SLAMCH.288"></a><a href="slamch.f.html#SLAMCH.1">SLAMCH</a>( <span class="string">'Safe Minimum'</span> )
TOLA = MAX( M, N )*MAX( ANORM, UNFL )*ULP
TOLB = MAX( P, N )*MAX( BNORM, UNFL )*ULP
<span class="comment">*</span><span class="comment">
</span> CALL <a name="CGGSVP.292"></a><a href="cggsvp.f.html#CGGSVP.1">CGGSVP</a>( JOBU, JOBV, JOBQ, M, P, N, A, LDA, B, LDB, TOLA,
$ TOLB, K, L, U, LDU, V, LDV, Q, LDQ, IWORK, RWORK,
$ WORK, WORK( N+1 ), INFO )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Compute the GSVD of two upper "triangular" matrices
</span><span class="comment">*</span><span class="comment">
</span> CALL <a name="CTGSJA.298"></a><a href="ctgsja.f.html#CTGSJA.1">CTGSJA</a>( JOBU, JOBV, JOBQ, M, P, N, K, L, A, LDA, B, LDB,
$ TOLA, TOLB, ALPHA, BETA, U, LDU, V, LDV, Q, LDQ,
$ WORK, NCYCLE, INFO )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Sort the singular values and store the pivot indices in IWORK
</span><span class="comment">*</span><span class="comment"> Copy ALPHA to RWORK, then sort ALPHA in RWORK
</span><span class="comment">*</span><span class="comment">
</span> CALL SCOPY( N, ALPHA, 1, RWORK, 1 )
IBND = MIN( L, M-K )
DO 20 I = 1, IBND
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Scan for largest ALPHA(K+I)
</span><span class="comment">*</span><span class="comment">
</span> ISUB = I
SMAX = RWORK( K+I )
DO 10 J = I + 1, IBND
TEMP = RWORK( K+J )
IF( TEMP.GT.SMAX ) THEN
ISUB = J
SMAX = TEMP
END IF
10 CONTINUE
IF( ISUB.NE.I ) THEN
RWORK( K+ISUB ) = RWORK( K+I )
RWORK( K+I ) = SMAX
IWORK( K+I ) = K + ISUB
ELSE
IWORK( K+I ) = K + I
END IF
20 CONTINUE
<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="CGGSVD.331"></a><a href="cggsvd.f.html#CGGSVD.1">CGGSVD</a>
</span><span class="comment">*</span><span class="comment">
</span> END
</pre>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?