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