sorgql.f.html

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

HTML
247
字号
</span>      IF( INFO.EQ.0 ) THEN
         IF( N.EQ.0 ) THEN
            LWKOPT = 1
         ELSE
            NB = <a name="ILAENV.110"></a><a href="hfy-index.html#ILAENV">ILAENV</a>( 1, <span class="string">'<a name="SORGQL.110"></a><a href="sorgql.f.html#SORGQL.1">SORGQL</a>'</span>, <span class="string">' '</span>, M, N, K, -1 )
            LWKOPT = N*NB
         END IF
         WORK( 1 ) = LWKOPT
<span class="comment">*</span><span class="comment">
</span>         IF( LWORK.LT.MAX( 1, N ) .AND. .NOT.LQUERY ) THEN
            INFO = -8
         END IF
      END IF
<span class="comment">*</span><span class="comment">
</span>      IF( INFO.NE.0 ) THEN
         CALL <a name="XERBLA.121"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>( <span class="string">'<a name="SORGQL.121"></a><a href="sorgql.f.html#SORGQL.1">SORGQL</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.LE.0 ) THEN
         RETURN
      END IF
<span class="comment">*</span><span class="comment">
</span>      NBMIN = 2
      NX = 0
      IWS = N
      IF( NB.GT.1 .AND. NB.LT.K ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Determine when to cross over from blocked to unblocked code.
</span><span class="comment">*</span><span class="comment">
</span>         NX = MAX( 0, <a name="ILAENV.140"></a><a href="hfy-index.html#ILAENV">ILAENV</a>( 3, <span class="string">'<a name="SORGQL.140"></a><a href="sorgql.f.html#SORGQL.1">SORGQL</a>'</span>, <span class="string">' '</span>, M, N, K, -1 ) )
         IF( NX.LT.K ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           Determine if workspace is large enough for blocked code.
</span><span class="comment">*</span><span class="comment">
</span>            LDWORK = N
            IWS = LDWORK*NB
            IF( LWORK.LT.IWS ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">              Not enough workspace to use optimal NB:  reduce NB and
</span><span class="comment">*</span><span class="comment">              determine the minimum value of NB.
</span><span class="comment">*</span><span class="comment">
</span>               NB = LWORK / LDWORK
               NBMIN = MAX( 2, <a name="ILAENV.153"></a><a href="hfy-index.html#ILAENV">ILAENV</a>( 2, <span class="string">'<a name="SORGQL.153"></a><a href="sorgql.f.html#SORGQL.1">SORGQL</a>'</span>, <span class="string">' '</span>, M, N, K, -1 ) )
            END IF
         END IF
      END IF
<span class="comment">*</span><span class="comment">
</span>      IF( NB.GE.NBMIN .AND. NB.LT.K .AND. NX.LT.K ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Use blocked code after the first block.
</span><span class="comment">*</span><span class="comment">        The last kk columns are handled by the block method.
</span><span class="comment">*</span><span class="comment">
</span>         KK = MIN( K, ( ( K-NX+NB-1 ) / NB )*NB )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Set A(m-kk+1:m,1:n-kk) to zero.
</span><span class="comment">*</span><span class="comment">
</span>         DO 20 J = 1, N - KK
            DO 10 I = M - KK + 1, M
               A( I, J ) = ZERO
   10       CONTINUE
   20    CONTINUE
      ELSE
         KK = 0
      END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Use unblocked code for the first or only block.
</span><span class="comment">*</span><span class="comment">
</span>      CALL <a name="SORG2L.178"></a><a href="sorg2l.f.html#SORG2L.1">SORG2L</a>( M-KK, N-KK, K-KK, A, LDA, TAU, WORK, IINFO )
<span class="comment">*</span><span class="comment">
</span>      IF( KK.GT.0 ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Use blocked code
</span><span class="comment">*</span><span class="comment">
</span>         DO 50 I = K - KK + 1, K, NB
            IB = MIN( NB, K-I+1 )
            IF( N-K+I.GT.1 ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">              Form the triangular factor of the block reflector
</span><span class="comment">*</span><span class="comment">              H = H(i+ib-1) . . . H(i+1) H(i)
</span><span class="comment">*</span><span class="comment">
</span>               CALL <a name="SLARFT.191"></a><a href="slarft.f.html#SLARFT.1">SLARFT</a>( <span class="string">'Backward'</span>, <span class="string">'Columnwise'</span>, M-K+I+IB-1, IB,
     $                      A( 1, N-K+I ), LDA, TAU( I ), WORK, LDWORK )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">              Apply H to A(1:m-k+i+ib-1,1:n-k+i-1) from the left
</span><span class="comment">*</span><span class="comment">
</span>               CALL <a name="SLARFB.196"></a><a href="slarfb.f.html#SLARFB.1">SLARFB</a>( <span class="string">'Left'</span>, <span class="string">'No transpose'</span>, <span class="string">'Backward'</span>,
     $                      <span class="string">'Columnwise'</span>, M-K+I+IB-1, N-K+I-1, IB,
     $                      A( 1, N-K+I ), LDA, WORK, LDWORK, A, LDA,
     $                      WORK( IB+1 ), LDWORK )
            END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           Apply H to rows 1:m-k+i+ib-1 of current block
</span><span class="comment">*</span><span class="comment">
</span>            CALL <a name="SORG2L.204"></a><a href="sorg2l.f.html#SORG2L.1">SORG2L</a>( M-K+I+IB-1, IB, IB, A( 1, N-K+I ), LDA,
     $                   TAU( I ), WORK, IINFO )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           Set rows m-k+i+ib:m of current block to zero
</span><span class="comment">*</span><span class="comment">
</span>            DO 40 J = N - K + I, N - K + I + IB - 1
               DO 30 L = M - K + I + IB, M
                  A( L, J ) = ZERO
   30          CONTINUE
   40       CONTINUE
   50    CONTINUE
      END IF
<span class="comment">*</span><span class="comment">
</span>      WORK( 1 ) = IWS
      RETURN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     End of <a name="SORGQL.220"></a><a href="sorgql.f.html#SORGQL.1">SORGQL</a>
</span><span class="comment">*</span><span class="comment">
</span>      END

</pre>

 </body>
</html>

⌨️ 快捷键说明

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