LAPACK  3.4.0
LAPACK: Linear Algebra PACKage
dorgbr.f
Go to the documentation of this file.
00001 *> \brief \b DORGBR
00002 *
00003 *  =========== DOCUMENTATION ===========
00004 *
00005 * Online html documentation available at 
00006 *            http://www.netlib.org/lapack/explore-html/ 
00007 *
00008 *> \htmlonly
00009 *> Download DORGBR + dependencies 
00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dorgbr.f"> 
00011 *> [TGZ]</a> 
00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dorgbr.f"> 
00013 *> [ZIP]</a> 
00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dorgbr.f"> 
00015 *> [TXT]</a>
00016 *> \endhtmlonly 
00017 *
00018 *  Definition:
00019 *  ===========
00020 *
00021 *       SUBROUTINE DORGBR( VECT, M, N, K, A, LDA, TAU, WORK, LWORK, INFO )
00022 * 
00023 *       .. Scalar Arguments ..
00024 *       CHARACTER          VECT
00025 *       INTEGER            INFO, K, LDA, LWORK, M, N
00026 *       ..
00027 *       .. Array Arguments ..
00028 *       DOUBLE PRECISION   A( LDA, * ), TAU( * ), WORK( * )
00029 *       ..
00030 *  
00031 *
00032 *> \par Purpose:
00033 *  =============
00034 *>
00035 *> \verbatim
00036 *>
00037 *> DORGBR generates one of the real orthogonal matrices Q or P**T
00038 *> determined by DGEBRD when reducing a real matrix A to bidiagonal
00039 *> form: A = Q * B * P**T.  Q and P**T are defined as products of
00040 *> elementary reflectors H(i) or G(i) respectively.
00041 *>
00042 *> If VECT = 'Q', A is assumed to have been an M-by-K matrix, and Q
00043 *> is of order M:
00044 *> if m >= k, Q = H(1) H(2) . . . H(k) and DORGBR returns the first n
00045 *> columns of Q, where m >= n >= k;
00046 *> if m < k, Q = H(1) H(2) . . . H(m-1) and DORGBR returns Q as an
00047 *> M-by-M matrix.
00048 *>
00049 *> If VECT = 'P', A is assumed to have been a K-by-N matrix, and P**T
00050 *> is of order N:
00051 *> if k < n, P**T = G(k) . . . G(2) G(1) and DORGBR returns the first m
00052 *> rows of P**T, where n >= m >= k;
00053 *> if k >= n, P**T = G(n-1) . . . G(2) G(1) and DORGBR returns P**T as
00054 *> an N-by-N matrix.
00055 *> \endverbatim
00056 *
00057 *  Arguments:
00058 *  ==========
00059 *
00060 *> \param[in] VECT
00061 *> \verbatim
00062 *>          VECT is CHARACTER*1
00063 *>          Specifies whether the matrix Q or the matrix P**T is
00064 *>          required, as defined in the transformation applied by DGEBRD:
00065 *>          = 'Q':  generate Q;
00066 *>          = 'P':  generate P**T.
00067 *> \endverbatim
00068 *>
00069 *> \param[in] M
00070 *> \verbatim
00071 *>          M is INTEGER
00072 *>          The number of rows of the matrix Q or P**T to be returned.
00073 *>          M >= 0.
00074 *> \endverbatim
00075 *>
00076 *> \param[in] N
00077 *> \verbatim
00078 *>          N is INTEGER
00079 *>          The number of columns of the matrix Q or P**T to be returned.
00080 *>          N >= 0.
00081 *>          If VECT = 'Q', M >= N >= min(M,K);
00082 *>          if VECT = 'P', N >= M >= min(N,K).
00083 *> \endverbatim
00084 *>
00085 *> \param[in] K
00086 *> \verbatim
00087 *>          K is INTEGER
00088 *>          If VECT = 'Q', the number of columns in the original M-by-K
00089 *>          matrix reduced by DGEBRD.
00090 *>          If VECT = 'P', the number of rows in the original K-by-N
00091 *>          matrix reduced by DGEBRD.
00092 *>          K >= 0.
00093 *> \endverbatim
00094 *>
00095 *> \param[in,out] A
00096 *> \verbatim
00097 *>          A is DOUBLE PRECISION array, dimension (LDA,N)
00098 *>          On entry, the vectors which define the elementary reflectors,
00099 *>          as returned by DGEBRD.
00100 *>          On exit, the M-by-N matrix Q or P**T.
00101 *> \endverbatim
00102 *>
00103 *> \param[in] LDA
00104 *> \verbatim
00105 *>          LDA is INTEGER
00106 *>          The leading dimension of the array A. LDA >= max(1,M).
00107 *> \endverbatim
00108 *>
00109 *> \param[in] TAU
00110 *> \verbatim
00111 *>          TAU is DOUBLE PRECISION array, dimension
00112 *>                                (min(M,K)) if VECT = 'Q'
00113 *>                                (min(N,K)) if VECT = 'P'
00114 *>          TAU(i) must contain the scalar factor of the elementary
00115 *>          reflector H(i) or G(i), which determines Q or P**T, as
00116 *>          returned by DGEBRD in its array argument TAUQ or TAUP.
00117 *> \endverbatim
00118 *>
00119 *> \param[out] WORK
00120 *> \verbatim
00121 *>          WORK is DOUBLE PRECISION array, dimension (MAX(1,LWORK))
00122 *>          On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
00123 *> \endverbatim
00124 *>
00125 *> \param[in] LWORK
00126 *> \verbatim
00127 *>          LWORK is INTEGER
00128 *>          The dimension of the array WORK. LWORK >= max(1,min(M,N)).
00129 *>          For optimum performance LWORK >= min(M,N)*NB, where NB
00130 *>          is the optimal blocksize.
00131 *>
00132 *>          If LWORK = -1, then a workspace query is assumed; the routine
00133 *>          only calculates the optimal size of the WORK array, returns
00134 *>          this value as the first entry of the WORK array, and no error
00135 *>          message related to LWORK is issued by XERBLA.
00136 *> \endverbatim
00137 *>
00138 *> \param[out] INFO
00139 *> \verbatim
00140 *>          INFO is INTEGER
00141 *>          = 0:  successful exit
00142 *>          < 0:  if INFO = -i, the i-th argument had an illegal value
00143 *> \endverbatim
00144 *
00145 *  Authors:
00146 *  ========
00147 *
00148 *> \author Univ. of Tennessee 
00149 *> \author Univ. of California Berkeley 
00150 *> \author Univ. of Colorado Denver 
00151 *> \author NAG Ltd. 
00152 *
00153 *> \date November 2011
00154 *
00155 *> \ingroup doubleGBcomputational
00156 *
00157 *  =====================================================================
00158       SUBROUTINE DORGBR( VECT, M, N, K, A, LDA, TAU, WORK, LWORK, INFO )
00159 *
00160 *  -- LAPACK computational routine (version 3.4.0) --
00161 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00162 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00163 *     November 2011
00164 *
00165 *     .. Scalar Arguments ..
00166       CHARACTER          VECT
00167       INTEGER            INFO, K, LDA, LWORK, M, N
00168 *     ..
00169 *     .. Array Arguments ..
00170       DOUBLE PRECISION   A( LDA, * ), TAU( * ), WORK( * )
00171 *     ..
00172 *
00173 *  =====================================================================
00174 *
00175 *     .. Parameters ..
00176       DOUBLE PRECISION   ZERO, ONE
00177       PARAMETER          ( ZERO = 0.0D+0, ONE = 1.0D+0 )
00178 *     ..
00179 *     .. Local Scalars ..
00180       LOGICAL            LQUERY, WANTQ
00181       INTEGER            I, IINFO, J, LWKOPT, MN, NB
00182 *     ..
00183 *     .. External Functions ..
00184       LOGICAL            LSAME
00185       INTEGER            ILAENV
00186       EXTERNAL           LSAME, ILAENV
00187 *     ..
00188 *     .. External Subroutines ..
00189       EXTERNAL           DORGLQ, DORGQR, XERBLA
00190 *     ..
00191 *     .. Intrinsic Functions ..
00192       INTRINSIC          MAX, MIN
00193 *     ..
00194 *     .. Executable Statements ..
00195 *
00196 *     Test the input arguments
00197 *
00198       INFO = 0
00199       WANTQ = LSAME( VECT, 'Q' )
00200       MN = MIN( M, N )
00201       LQUERY = ( LWORK.EQ.-1 )
00202       IF( .NOT.WANTQ .AND. .NOT.LSAME( VECT, 'P' ) ) THEN
00203          INFO = -1
00204       ELSE IF( M.LT.0 ) THEN
00205          INFO = -2
00206       ELSE IF( N.LT.0 .OR. ( WANTQ .AND. ( N.GT.M .OR. N.LT.MIN( M,
00207      $         K ) ) ) .OR. ( .NOT.WANTQ .AND. ( M.GT.N .OR. M.LT.
00208      $         MIN( N, K ) ) ) ) THEN
00209          INFO = -3
00210       ELSE IF( K.LT.0 ) THEN
00211          INFO = -4
00212       ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
00213          INFO = -6
00214       ELSE IF( LWORK.LT.MAX( 1, MN ) .AND. .NOT.LQUERY ) THEN
00215          INFO = -9
00216       END IF
00217 *
00218       IF( INFO.EQ.0 ) THEN
00219          WORK( 1 ) = 1
00220          IF( WANTQ ) THEN
00221             IF( M.GE.K ) THEN
00222                CALL DORGQR( M, N, K, A, LDA, TAU, WORK, -1, IINFO )
00223             ELSE
00224                IF( M.GT.1 ) THEN
00225                   CALL DORGQR( M-1, M-1, M-1, A( 2, 2 ), LDA, TAU, WORK,
00226      $                         -1, IINFO )
00227                END IF
00228             END IF
00229          ELSE
00230             IF( K.LT.N ) THEN
00231                CALL DORGLQ( M, N, K, A, LDA, TAU, WORK, -1, IINFO )
00232             ELSE
00233                IF( N.GT.1 ) THEN
00234                   CALL DORGLQ( N-1, N-1, N-1, A( 2, 2 ), LDA, TAU, WORK,
00235      $                         -1, IINFO )
00236                END IF
00237             END IF
00238          END IF
00239          LWKOPT = WORK( 1 )
00240       END IF
00241 *
00242       IF( INFO.NE.0 ) THEN
00243          CALL XERBLA( 'DORGBR', -INFO )
00244          RETURN
00245       ELSE IF( LQUERY ) THEN
00246          RETURN
00247       END IF
00248 *
00249 *     Quick return if possible
00250 *
00251       IF( M.EQ.0 .OR. N.EQ.0 ) THEN
00252          WORK( 1 ) = 1
00253          RETURN
00254       END IF
00255 *
00256       IF( WANTQ ) THEN
00257 *
00258 *        Form Q, determined by a call to DGEBRD to reduce an m-by-k
00259 *        matrix
00260 *
00261          IF( M.GE.K ) THEN
00262 *
00263 *           If m >= k, assume m >= n >= k
00264 *
00265             CALL DORGQR( M, N, K, A, LDA, TAU, WORK, LWORK, IINFO )
00266 *
00267          ELSE
00268 *
00269 *           If m < k, assume m = n
00270 *
00271 *           Shift the vectors which define the elementary reflectors one
00272 *           column to the right, and set the first row and column of Q
00273 *           to those of the unit matrix
00274 *
00275             DO 20 J = M, 2, -1
00276                A( 1, J ) = ZERO
00277                DO 10 I = J + 1, M
00278                   A( I, J ) = A( I, J-1 )
00279    10          CONTINUE
00280    20       CONTINUE
00281             A( 1, 1 ) = ONE
00282             DO 30 I = 2, M
00283                A( I, 1 ) = ZERO
00284    30       CONTINUE
00285             IF( M.GT.1 ) THEN
00286 *
00287 *              Form Q(2:m,2:m)
00288 *
00289                CALL DORGQR( M-1, M-1, M-1, A( 2, 2 ), LDA, TAU, WORK,
00290      $                      LWORK, IINFO )
00291             END IF
00292          END IF
00293       ELSE
00294 *
00295 *        Form P**T, determined by a call to DGEBRD to reduce a k-by-n
00296 *        matrix
00297 *
00298          IF( K.LT.N ) THEN
00299 *
00300 *           If k < n, assume k <= m <= n
00301 *
00302             CALL DORGLQ( M, N, K, A, LDA, TAU, WORK, LWORK, IINFO )
00303 *
00304          ELSE
00305 *
00306 *           If k >= n, assume m = n
00307 *
00308 *           Shift the vectors which define the elementary reflectors one
00309 *           row downward, and set the first row and column of P**T to
00310 *           those of the unit matrix
00311 *
00312             A( 1, 1 ) = ONE
00313             DO 40 I = 2, N
00314                A( I, 1 ) = ZERO
00315    40       CONTINUE
00316             DO 60 J = 2, N
00317                DO 50 I = J - 1, 2, -1
00318                   A( I, J ) = A( I-1, J )
00319    50          CONTINUE
00320                A( 1, J ) = ZERO
00321    60       CONTINUE
00322             IF( N.GT.1 ) THEN
00323 *
00324 *              Form P**T(2:n,2:n)
00325 *
00326                CALL DORGLQ( N-1, N-1, N-1, A( 2, 2 ), LDA, TAU, WORK,
00327      $                      LWORK, IINFO )
00328             END IF
00329          END IF
00330       END IF
00331       WORK( 1 ) = LWKOPT
00332       RETURN
00333 *
00334 *     End of DORGBR
00335 *
00336       END
 All Files Functions