sggsvd.f.html

来自「famous linear algebra library (LAPACK) p」· HTML 代码 · 共 360 行 · 第 1/2 页

HTML
360
字号
</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) REAL array, dimension (LDU,M)
</span><span class="comment">*</span><span class="comment">          If JOBU = 'U', U contains the M-by-M orthogonal 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 &gt;= max(1,M) if
</span><span class="comment">*</span><span class="comment">          JOBU = 'U'; LDU &gt;= 1 otherwise.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  V       (output) REAL array, dimension (LDV,P)
</span><span class="comment">*</span><span class="comment">          If JOBV = 'V', V contains the P-by-P orthogonal 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 &gt;= max(1,P) if
</span><span class="comment">*</span><span class="comment">          JOBV = 'V'; LDV &gt;= 1 otherwise.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Q       (output) REAL array, dimension (LDQ,N)
</span><span class="comment">*</span><span class="comment">          If JOBQ = 'Q', Q contains the N-by-N orthogonal 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 &gt;= max(1,N) if
</span><span class="comment">*</span><span class="comment">          JOBQ = 'Q'; LDQ &gt;= 1 otherwise.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  WORK    (workspace) REAL array,
</span><span class="comment">*</span><span class="comment">                      dimension (max(3*N,M,P)+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) &gt;= ALPHA(2) &gt;= ... &gt;= 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">          &lt; 0:  if INFO = -i, the i-th argument had an illegal value.
</span><span class="comment">*</span><span class="comment">          &gt; 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="STGSJA.203"></a><a href="stgsja.f.html#STGSJA.1">STGSJA</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="SLAMCH.233"></a><a href="slamch.f.html#SLAMCH.1">SLAMCH</a>, <a name="SLANGE.233"></a><a href="slange.f.html#SLANGE.1">SLANGE</a>
      EXTERNAL           <a name="LSAME.234"></a><a href="lsame.f.html#LSAME.1">LSAME</a>, <a name="SLAMCH.234"></a><a href="slamch.f.html#SLAMCH.1">SLAMCH</a>, <a name="SLANGE.234"></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">     .. External Subroutines ..
</span>      EXTERNAL           SCOPY, <a name="SGGSVP.237"></a><a href="sggsvp.f.html#SGGSVP.1">SGGSVP</a>, <a name="STGSJA.237"></a><a href="stgsja.f.html#STGSJA.1">STGSJA</a>, <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">     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="SGGSVD.275"></a><a href="sggsvd.f.html#SGGSVD.1">SGGSVD</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="SLANGE.281"></a><a href="slange.f.html#SLANGE.1">SLANGE</a>( <span class="string">'1'</span>, M, N, A, LDA, WORK )
      BNORM = <a name="SLANGE.282"></a><a href="slange.f.html#SLANGE.1">SLANGE</a>( <span class="string">'1'</span>, P, N, B, LDB, WORK )
<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><span class="comment">*</span><span class="comment">     Preprocessing
</span><span class="comment">*</span><span class="comment">
</span>      CALL <a name="SGGSVP.294"></a><a href="sggsvp.f.html#SGGSVP.1">SGGSVP</a>( JOBU, JOBV, JOBQ, M, P, N, A, LDA, B, LDB, TOLA,
     $             TOLB, K, L, U, LDU, V, LDV, Q, LDQ, IWORK, 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 &quot;triangular&quot; matrices
</span><span class="comment">*</span><span class="comment">
</span>      CALL <a name="STGSJA.300"></a><a href="stgsja.f.html#STGSJA.1">STGSJA</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 WORK, then sort ALPHA in WORK
</span><span class="comment">*</span><span class="comment">
</span>      CALL SCOPY( N, ALPHA, 1, WORK, 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 = WORK( K+I )
         DO 10 J = I + 1, IBND
            TEMP = WORK( K+J )
            IF( TEMP.GT.SMAX ) THEN
               ISUB = J
               SMAX = TEMP
            END IF
   10    CONTINUE
         IF( ISUB.NE.I ) THEN
            WORK( K+ISUB ) = WORK( K+I )
            WORK( 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="SGGSVD.333"></a><a href="sggsvd.f.html#SGGSVD.1">SGGSVD</a>
</span><span class="comment">*</span><span class="comment">
</span>      END

</pre>

 </body>
</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?