zgeqrf.f.html

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

HTML
221
字号
<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 arguments
</span><span class="comment">*</span><span class="comment">
</span>      INFO = 0
      NB = <a name="ILAENV.99"></a><a href="hfy-index.html#ILAENV">ILAENV</a>( 1, <span class="string">'<a name="ZGEQRF.99"></a><a href="zgeqrf.f.html#ZGEQRF.1">ZGEQRF</a>'</span>, <span class="string">' '</span>, M, N, -1, -1 )
      LWKOPT = N*NB
      WORK( 1 ) = LWKOPT
      LQUERY = ( LWORK.EQ.-1 )
      IF( M.LT.0 ) THEN
         INFO = -1
      ELSE IF( N.LT.0 ) THEN
         INFO = -2
      ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
         INFO = -4
      ELSE IF( LWORK.LT.MAX( 1, N ) .AND. .NOT.LQUERY ) THEN
         INFO = -7
      END IF
      IF( INFO.NE.0 ) THEN
         CALL <a name="XERBLA.113"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>( <span class="string">'<a name="ZGEQRF.113"></a><a href="zgeqrf.f.html#ZGEQRF.1">ZGEQRF</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>      K = MIN( M, N )
      IF( K.EQ.0 ) THEN
         WORK( 1 ) = 1
         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.134"></a><a href="hfy-index.html#ILAENV">ILAENV</a>( 3, <span class="string">'<a name="ZGEQRF.134"></a><a href="zgeqrf.f.html#ZGEQRF.1">ZGEQRF</a>'</span>, <span class="string">' '</span>, M, N, -1, -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.147"></a><a href="hfy-index.html#ILAENV">ILAENV</a>( 2, <span class="string">'<a name="ZGEQRF.147"></a><a href="zgeqrf.f.html#ZGEQRF.1">ZGEQRF</a>'</span>, <span class="string">' '</span>, M, N, -1,
     $                 -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 initially
</span><span class="comment">*</span><span class="comment">
</span>         DO 10 I = 1, K - NX, NB
            IB = MIN( K-I+1, NB )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           Compute the QR factorization of the current block
</span><span class="comment">*</span><span class="comment">           A(i:m,i:i+ib-1)
</span><span class="comment">*</span><span class="comment">
</span>            CALL <a name="ZGEQR2.163"></a><a href="zgeqr2.f.html#ZGEQR2.1">ZGEQR2</a>( M-I+1, IB, A( I, I ), LDA, TAU( I ), WORK,
     $                   IINFO )
            IF( I+IB.LE.N ) 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) H(i+1) . . . H(i+ib-1)
</span><span class="comment">*</span><span class="comment">
</span>               CALL <a name="ZLARFT.170"></a><a href="zlarft.f.html#ZLARFT.1">ZLARFT</a>( <span class="string">'Forward'</span>, <span class="string">'Columnwise'</span>, M-I+1, IB,
     $                      A( I, 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(i:m,i+ib:n) from the left
</span><span class="comment">*</span><span class="comment">
</span>               CALL <a name="ZLARFB.175"></a><a href="zlarfb.f.html#ZLARFB.1">ZLARFB</a>( <span class="string">'Left'</span>, <span class="string">'Conjugate transpose'</span>, <span class="string">'Forward'</span>,
     $                      <span class="string">'Columnwise'</span>, M-I+1, N-I-IB+1, IB,
     $                      A( I, I ), LDA, WORK, LDWORK, A( I, I+IB ),
     $                      LDA, WORK( IB+1 ), LDWORK )
            END IF
   10    CONTINUE
      ELSE
         I = 1
      END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Use unblocked code to factor the last or only block.
</span><span class="comment">*</span><span class="comment">
</span>      IF( I.LE.K )
     $   CALL <a name="ZGEQR2.188"></a><a href="zgeqr2.f.html#ZGEQR2.1">ZGEQR2</a>( M-I+1, N-I+1, A( I, I ), LDA, TAU( I ), WORK,
     $                IINFO )
<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="ZGEQRF.194"></a><a href="zgeqrf.f.html#ZGEQRF.1">ZGEQRF</a>
</span><span class="comment">*</span><span class="comment">
</span>      END

</pre>

 </body>
</html>

⌨️ 快捷键说明

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