cungbr.f.html

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

HTML
270
字号
</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
      WANTQ = <a name="LSAME.122"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( VECT, <span class="string">'Q'</span> )
      MN = MIN( M, N )
      LQUERY = ( LWORK.EQ.-1 )
      IF( .NOT.WANTQ .AND. .NOT.<a name="LSAME.125"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( VECT, <span class="string">'P'</span> ) ) THEN
         INFO = -1
      ELSE IF( M.LT.0 ) THEN
         INFO = -2
      ELSE IF( N.LT.0 .OR. ( WANTQ .AND. ( N.GT.M .OR. N.LT.MIN( M,
     $         K ) ) ) .OR. ( .NOT.WANTQ .AND. ( M.GT.N .OR. M.LT.
     $         MIN( N, K ) ) ) ) THEN
         INFO = -3
      ELSE IF( K.LT.0 ) THEN
         INFO = -4
      ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
         INFO = -6
      ELSE IF( LWORK.LT.MAX( 1, MN ) .AND. .NOT.LQUERY ) THEN
         INFO = -9
      END IF
<span class="comment">*</span><span class="comment">
</span>      IF( INFO.EQ.0 ) THEN
         IF( WANTQ ) THEN
            NB = <a name="ILAENV.143"></a><a href="hfy-index.html#ILAENV">ILAENV</a>( 1, <span class="string">'<a name="CUNGQR.143"></a><a href="cungqr.f.html#CUNGQR.1">CUNGQR</a>'</span>, <span class="string">' '</span>, M, N, K, -1 )
         ELSE
            NB = <a name="ILAENV.145"></a><a href="hfy-index.html#ILAENV">ILAENV</a>( 1, <span class="string">'<a name="CUNGLQ.145"></a><a href="cunglq.f.html#CUNGLQ.1">CUNGLQ</a>'</span>, <span class="string">' '</span>, M, N, K, -1 )
         END IF
         LWKOPT = MAX( 1, MN )*NB
         WORK( 1 ) = LWKOPT
      END IF
<span class="comment">*</span><span class="comment">
</span>      IF( INFO.NE.0 ) THEN
         CALL <a name="XERBLA.152"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>( <span class="string">'<a name="CUNGBR.152"></a><a href="cungbr.f.html#CUNGBR.1">CUNGBR</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( M.EQ.0 .OR. N.EQ.0 ) THEN
         WORK( 1 ) = 1
         RETURN
      END IF
<span class="comment">*</span><span class="comment">
</span>      IF( WANTQ ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Form Q, determined by a call to <a name="CGEBRD.167"></a><a href="cgebrd.f.html#CGEBRD.1">CGEBRD</a> to reduce an m-by-k
</span><span class="comment">*</span><span class="comment">        matrix
</span><span class="comment">*</span><span class="comment">
</span>         IF( M.GE.K ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           If m &gt;= k, assume m &gt;= n &gt;= k
</span><span class="comment">*</span><span class="comment">
</span>            CALL <a name="CUNGQR.174"></a><a href="cungqr.f.html#CUNGQR.1">CUNGQR</a>( M, N, K, A, LDA, TAU, WORK, LWORK, IINFO )
<span class="comment">*</span><span class="comment">
</span>         ELSE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           If m &lt; k, assume m = n
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           Shift the vectors which define the elementary reflectors one
</span><span class="comment">*</span><span class="comment">           column to the right, and set the first row and column of Q
</span><span class="comment">*</span><span class="comment">           to those of the unit matrix
</span><span class="comment">*</span><span class="comment">
</span>            DO 20 J = M, 2, -1
               A( 1, J ) = ZERO
               DO 10 I = J + 1, M
                  A( I, J ) = A( I, J-1 )
   10          CONTINUE
   20       CONTINUE
            A( 1, 1 ) = ONE
            DO 30 I = 2, M
               A( I, 1 ) = ZERO
   30       CONTINUE
            IF( M.GT.1 ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">              Form Q(2:m,2:m)
</span><span class="comment">*</span><span class="comment">
</span>               CALL <a name="CUNGQR.198"></a><a href="cungqr.f.html#CUNGQR.1">CUNGQR</a>( M-1, M-1, M-1, A( 2, 2 ), LDA, TAU, WORK,
     $                      LWORK, IINFO )
            END IF
         END IF
      ELSE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Form P', determined by a call to <a name="CGEBRD.204"></a><a href="cgebrd.f.html#CGEBRD.1">CGEBRD</a> to reduce a k-by-n
</span><span class="comment">*</span><span class="comment">        matrix
</span><span class="comment">*</span><span class="comment">
</span>         IF( K.LT.N ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           If k &lt; n, assume k &lt;= m &lt;= n
</span><span class="comment">*</span><span class="comment">
</span>            CALL <a name="CUNGLQ.211"></a><a href="cunglq.f.html#CUNGLQ.1">CUNGLQ</a>( M, N, K, A, LDA, TAU, WORK, LWORK, IINFO )
<span class="comment">*</span><span class="comment">
</span>         ELSE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           If k &gt;= n, assume m = n
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           Shift the vectors which define the elementary reflectors one
</span><span class="comment">*</span><span class="comment">           row downward, and set the first row and column of P' to
</span><span class="comment">*</span><span class="comment">           those of the unit matrix
</span><span class="comment">*</span><span class="comment">
</span>            A( 1, 1 ) = ONE
            DO 40 I = 2, N
               A( I, 1 ) = ZERO
   40       CONTINUE
            DO 60 J = 2, N
               DO 50 I = J - 1, 2, -1
                  A( I, J ) = A( I-1, J )
   50          CONTINUE
               A( 1, J ) = ZERO
   60       CONTINUE
            IF( N.GT.1 ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">              Form P'(2:n,2:n)
</span><span class="comment">*</span><span class="comment">
</span>               CALL <a name="CUNGLQ.235"></a><a href="cunglq.f.html#CUNGLQ.1">CUNGLQ</a>( N-1, N-1, N-1, A( 2, 2 ), LDA, TAU, WORK,
     $                      LWORK, IINFO )
            END IF
         END IF
      END IF
      WORK( 1 ) = LWKOPT
      RETURN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     End of <a name="CUNGBR.243"></a><a href="cungbr.f.html#CUNGBR.1">CUNGBR</a>
</span><span class="comment">*</span><span class="comment">
</span>      END

</pre>

 </body>
</html>

⌨️ 快捷键说明

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