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