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