sgelsy.f.html

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

HTML
416
字号
</span><span class="comment">*</span><span class="comment">        Scale matrix norm down to BIGNUM
</span><span class="comment">*</span><span class="comment">
</span>         CALL <a name="SLASCL.262"></a><a href="slascl.f.html#SLASCL.1">SLASCL</a>( <span class="string">'G'</span>, 0, 0, BNRM, BIGNUM, M, NRHS, B, LDB, INFO )
         IBSCL = 2
      END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Compute QR factorization with column pivoting of A:
</span><span class="comment">*</span><span class="comment">        A * P = Q * R
</span><span class="comment">*</span><span class="comment">
</span>      CALL <a name="SGEQP3.269"></a><a href="sgeqp3.f.html#SGEQP3.1">SGEQP3</a>( M, N, A, LDA, JPVT, WORK( 1 ), WORK( MN+1 ),
     $             LWORK-MN, INFO )
      WSIZE = MN + WORK( MN+1 )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     workspace: MN+2*N+NB*(N+1).
</span><span class="comment">*</span><span class="comment">     Details of Householder rotations stored in WORK(1:MN).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Determine RANK using incremental condition estimation
</span><span class="comment">*</span><span class="comment">
</span>      WORK( ISMIN ) = ONE
      WORK( ISMAX ) = ONE
      SMAX = ABS( A( 1, 1 ) )
      SMIN = SMAX
      IF( ABS( A( 1, 1 ) ).EQ.ZERO ) THEN
         RANK = 0
         CALL <a name="SLASET.284"></a><a href="slaset.f.html#SLASET.1">SLASET</a>( <span class="string">'F'</span>, MAX( M, N ), NRHS, ZERO, ZERO, B, LDB )
         GO TO 70
      ELSE
         RANK = 1
      END IF
<span class="comment">*</span><span class="comment">
</span>   10 CONTINUE
      IF( RANK.LT.MN ) THEN
         I = RANK + 1
         CALL <a name="SLAIC1.293"></a><a href="slaic1.f.html#SLAIC1.1">SLAIC1</a>( IMIN, RANK, WORK( ISMIN ), SMIN, A( 1, I ),
     $                A( I, I ), SMINPR, S1, C1 )
         CALL <a name="SLAIC1.295"></a><a href="slaic1.f.html#SLAIC1.1">SLAIC1</a>( IMAX, RANK, WORK( ISMAX ), SMAX, A( 1, I ),
     $                A( I, I ), SMAXPR, S2, C2 )
<span class="comment">*</span><span class="comment">
</span>         IF( SMAXPR*RCOND.LE.SMINPR ) THEN
            DO 20 I = 1, RANK
               WORK( ISMIN+I-1 ) = S1*WORK( ISMIN+I-1 )
               WORK( ISMAX+I-1 ) = S2*WORK( ISMAX+I-1 )
   20       CONTINUE
            WORK( ISMIN+RANK ) = C1
            WORK( ISMAX+RANK ) = C2
            SMIN = SMINPR
            SMAX = SMAXPR
            RANK = RANK + 1
            GO TO 10
         END IF
      END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     workspace: 3*MN.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Logically partition R = [ R11 R12 ]
</span><span class="comment">*</span><span class="comment">                             [  0  R22 ]
</span><span class="comment">*</span><span class="comment">     where R11 = R(1:RANK,1:RANK)
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     [R11,R12] = [ T11, 0 ] * Y
</span><span class="comment">*</span><span class="comment">
</span>      IF( RANK.LT.N )
     $   CALL <a name="STZRZF.321"></a><a href="stzrzf.f.html#STZRZF.1">STZRZF</a>( RANK, N, A, LDA, WORK( MN+1 ), WORK( 2*MN+1 ),
     $                LWORK-2*MN, INFO )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     workspace: 2*MN.
</span><span class="comment">*</span><span class="comment">     Details of Householder rotations stored in WORK(MN+1:2*MN)
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     B(1:M,1:NRHS) := Q' * B(1:M,1:NRHS)
</span><span class="comment">*</span><span class="comment">
</span>      CALL <a name="SORMQR.329"></a><a href="sormqr.f.html#SORMQR.1">SORMQR</a>( <span class="string">'Left'</span>, <span class="string">'Transpose'</span>, M, NRHS, MN, A, LDA, WORK( 1 ),
     $             B, LDB, WORK( 2*MN+1 ), LWORK-2*MN, INFO )
      WSIZE = MAX( WSIZE, 2*MN+WORK( 2*MN+1 ) )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     workspace: 2*MN+NB*NRHS.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     B(1:RANK,1:NRHS) := inv(T11) * B(1:RANK,1:NRHS)
</span><span class="comment">*</span><span class="comment">
</span>      CALL STRSM( <span class="string">'Left'</span>, <span class="string">'Upper'</span>, <span class="string">'No transpose'</span>, <span class="string">'Non-unit'</span>, RANK,
     $            NRHS, ONE, A, LDA, B, LDB )
<span class="comment">*</span><span class="comment">
</span>      DO 40 J = 1, NRHS
         DO 30 I = RANK + 1, N
            B( I, J ) = ZERO
   30    CONTINUE
   40 CONTINUE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     B(1:N,1:NRHS) := Y' * B(1:N,1:NRHS)
</span><span class="comment">*</span><span class="comment">
</span>      IF( RANK.LT.N ) THEN
         CALL <a name="SORMRZ.349"></a><a href="sormrz.f.html#SORMRZ.1">SORMRZ</a>( <span class="string">'Left'</span>, <span class="string">'Transpose'</span>, N, NRHS, RANK, N-RANK, A,
     $                LDA, WORK( MN+1 ), B, LDB, WORK( 2*MN+1 ),
     $                LWORK-2*MN, INFO )
      END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     workspace: 2*MN+NRHS.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     B(1:N,1:NRHS) := P * B(1:N,1:NRHS)
</span><span class="comment">*</span><span class="comment">
</span>      DO 60 J = 1, NRHS
         DO 50 I = 1, N
            WORK( JPVT( I ) ) = B( I, J )
   50    CONTINUE
         CALL SCOPY( N, WORK( 1 ), 1, B( 1, J ), 1 )
   60 CONTINUE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     workspace: N.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Undo scaling
</span><span class="comment">*</span><span class="comment">
</span>      IF( IASCL.EQ.1 ) THEN
         CALL <a name="SLASCL.370"></a><a href="slascl.f.html#SLASCL.1">SLASCL</a>( <span class="string">'G'</span>, 0, 0, ANRM, SMLNUM, N, NRHS, B, LDB, INFO )
         CALL <a name="SLASCL.371"></a><a href="slascl.f.html#SLASCL.1">SLASCL</a>( <span class="string">'U'</span>, 0, 0, SMLNUM, ANRM, RANK, RANK, A, LDA,
     $                INFO )
      ELSE IF( IASCL.EQ.2 ) THEN
         CALL <a name="SLASCL.374"></a><a href="slascl.f.html#SLASCL.1">SLASCL</a>( <span class="string">'G'</span>, 0, 0, ANRM, BIGNUM, N, NRHS, B, LDB, INFO )
         CALL <a name="SLASCL.375"></a><a href="slascl.f.html#SLASCL.1">SLASCL</a>( <span class="string">'U'</span>, 0, 0, BIGNUM, ANRM, RANK, RANK, A, LDA,
     $                INFO )
      END IF
      IF( IBSCL.EQ.1 ) THEN
         CALL <a name="SLASCL.379"></a><a href="slascl.f.html#SLASCL.1">SLASCL</a>( <span class="string">'G'</span>, 0, 0, SMLNUM, BNRM, N, NRHS, B, LDB, INFO )
      ELSE IF( IBSCL.EQ.2 ) THEN
         CALL <a name="SLASCL.381"></a><a href="slascl.f.html#SLASCL.1">SLASCL</a>( <span class="string">'G'</span>, 0, 0, BIGNUM, BNRM, N, NRHS, B, LDB, INFO )
      END IF
<span class="comment">*</span><span class="comment">
</span>   70 CONTINUE
      WORK( 1 ) = LWKOPT
<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="SGELSY.389"></a><a href="sgelsy.f.html#SGELSY.1">SGELSY</a>
</span><span class="comment">*</span><span class="comment">
</span>      END

</pre>

 </body>
</html>

⌨️ 快捷键说明

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