LAPACK  3.4.0
LAPACK: Linear Algebra PACKage
zunmlq.f
Go to the documentation of this file.
00001 *> \brief \b ZUNMLQ
00002 *
00003 *  =========== DOCUMENTATION ===========
00004 *
00005 * Online html documentation available at 
00006 *            http://www.netlib.org/lapack/explore-html/ 
00007 *
00008 *> \htmlonly
00009 *> Download ZUNMLQ + dependencies 
00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zunmlq.f"> 
00011 *> [TGZ]</a> 
00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zunmlq.f"> 
00013 *> [ZIP]</a> 
00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zunmlq.f"> 
00015 *> [TXT]</a>
00016 *> \endhtmlonly 
00017 *
00018 *  Definition:
00019 *  ===========
00020 *
00021 *       SUBROUTINE ZUNMLQ( 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 *> ZUNMLQ 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(k)**H . . . H(2)**H H(1)**H
00048 *>
00049 *> as returned by ZGELQF. 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
00094 *>                               (LDA,M) if SIDE = 'L',
00095 *>                               (LDA,N) if SIDE = 'R'
00096 *>          The i-th row must contain the vector which defines the
00097 *>          elementary reflector H(i), for i = 1,2,...,k, as returned by
00098 *>          ZGELQF in the first k rows of its array argument A.
00099 *>          A is modified by the routine but restored on exit.
00100 *> \endverbatim
00101 *>
00102 *> \param[in] LDA
00103 *> \verbatim
00104 *>          LDA is INTEGER
00105 *>          The leading dimension of the array A. LDA >= max(1,K).
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 ZGELQF.
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 ZUNMLQ( 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       CHARACTER          TRANST
00195       INTEGER            I, I1, I2, I3, IB, IC, IINFO, IWS, JC, LDWORK,
00196      $                   LWKOPT, MI, NB, NBMIN, NI, NQ, NW
00197 *     ..
00198 *     .. Local Arrays ..
00199       COMPLEX*16         T( LDT, NBMAX )
00200 *     ..
00201 *     .. External Functions ..
00202       LOGICAL            LSAME
00203       INTEGER            ILAENV
00204       EXTERNAL           LSAME, ILAENV
00205 *     ..
00206 *     .. External Subroutines ..
00207       EXTERNAL           XERBLA, ZLARFB, ZLARFT, ZUNML2
00208 *     ..
00209 *     .. Intrinsic Functions ..
00210       INTRINSIC          MAX, MIN
00211 *     ..
00212 *     .. Executable Statements ..
00213 *
00214 *     Test the input arguments
00215 *
00216       INFO = 0
00217       LEFT = LSAME( SIDE, 'L' )
00218       NOTRAN = LSAME( TRANS, 'N' )
00219       LQUERY = ( LWORK.EQ.-1 )
00220 *
00221 *     NQ is the order of Q and NW is the minimum dimension of WORK
00222 *
00223       IF( LEFT ) THEN
00224          NQ = M
00225          NW = N
00226       ELSE
00227          NQ = N
00228          NW = M
00229       END IF
00230       IF( .NOT.LEFT .AND. .NOT.LSAME( SIDE, 'R' ) ) THEN
00231          INFO = -1
00232       ELSE IF( .NOT.NOTRAN .AND. .NOT.LSAME( TRANS, 'C' ) ) THEN
00233          INFO = -2
00234       ELSE IF( M.LT.0 ) THEN
00235          INFO = -3
00236       ELSE IF( N.LT.0 ) THEN
00237          INFO = -4
00238       ELSE IF( K.LT.0 .OR. K.GT.NQ ) THEN
00239          INFO = -5
00240       ELSE IF( LDA.LT.MAX( 1, K ) ) THEN
00241          INFO = -7
00242       ELSE IF( LDC.LT.MAX( 1, M ) ) THEN
00243          INFO = -10
00244       ELSE IF( LWORK.LT.MAX( 1, NW ) .AND. .NOT.LQUERY ) THEN
00245          INFO = -12
00246       END IF
00247 *
00248       IF( INFO.EQ.0 ) THEN
00249 *
00250 *        Determine the block size.  NB may be at most NBMAX, where NBMAX
00251 *        is used to define the local array T.
00252 *
00253          NB = MIN( NBMAX, ILAENV( 1, 'ZUNMLQ', SIDE // TRANS, M, N, K,
00254      $        -1 ) )
00255          LWKOPT = MAX( 1, NW )*NB
00256          WORK( 1 ) = LWKOPT
00257       END IF
00258 *
00259       IF( INFO.NE.0 ) THEN
00260          CALL XERBLA( 'ZUNMLQ', -INFO )
00261          RETURN
00262       ELSE IF( LQUERY ) THEN
00263          RETURN
00264       END IF
00265 *
00266 *     Quick return if possible
00267 *
00268       IF( M.EQ.0 .OR. N.EQ.0 .OR. K.EQ.0 ) THEN
00269          WORK( 1 ) = 1
00270          RETURN
00271       END IF
00272 *
00273       NBMIN = 2
00274       LDWORK = NW
00275       IF( NB.GT.1 .AND. NB.LT.K ) THEN
00276          IWS = NW*NB
00277          IF( LWORK.LT.IWS ) THEN
00278             NB = LWORK / LDWORK
00279             NBMIN = MAX( 2, ILAENV( 2, 'ZUNMLQ', SIDE // TRANS, M, N, K,
00280      $              -1 ) )
00281          END IF
00282       ELSE
00283          IWS = NW
00284       END IF
00285 *
00286       IF( NB.LT.NBMIN .OR. NB.GE.K ) THEN
00287 *
00288 *        Use unblocked code
00289 *
00290          CALL ZUNML2( SIDE, TRANS, M, N, K, A, LDA, TAU, C, LDC, WORK,
00291      $                IINFO )
00292       ELSE
00293 *
00294 *        Use blocked code
00295 *
00296          IF( ( LEFT .AND. NOTRAN ) .OR.
00297      $       ( .NOT.LEFT .AND. .NOT.NOTRAN ) ) THEN
00298             I1 = 1
00299             I2 = K
00300             I3 = NB
00301          ELSE
00302             I1 = ( ( K-1 ) / NB )*NB + 1
00303             I2 = 1
00304             I3 = -NB
00305          END IF
00306 *
00307          IF( LEFT ) THEN
00308             NI = N
00309             JC = 1
00310          ELSE
00311             MI = M
00312             IC = 1
00313          END IF
00314 *
00315          IF( NOTRAN ) THEN
00316             TRANST = 'C'
00317          ELSE
00318             TRANST = 'N'
00319          END IF
00320 *
00321          DO 10 I = I1, I2, I3
00322             IB = MIN( NB, K-I+1 )
00323 *
00324 *           Form the triangular factor of the block reflector
00325 *           H = H(i) H(i+1) . . . H(i+ib-1)
00326 *
00327             CALL ZLARFT( 'Forward', 'Rowwise', NQ-I+1, IB, A( I, I ),
00328      $                   LDA, TAU( I ), T, LDT )
00329             IF( LEFT ) THEN
00330 *
00331 *              H or H**H is applied to C(i:m,1:n)
00332 *
00333                MI = M - I + 1
00334                IC = I
00335             ELSE
00336 *
00337 *              H or H**H is applied to C(1:m,i:n)
00338 *
00339                NI = N - I + 1
00340                JC = I
00341             END IF
00342 *
00343 *           Apply H or H**H
00344 *
00345             CALL ZLARFB( SIDE, TRANST, 'Forward', 'Rowwise', MI, NI, IB,
00346      $                   A( I, I ), LDA, T, LDT, C( IC, JC ), LDC, WORK,
00347      $                   LDWORK )
00348    10    CONTINUE
00349       END IF
00350       WORK( 1 ) = LWKOPT
00351       RETURN
00352 *
00353 *     End of ZUNMLQ
00354 *
00355       END
 All Files Functions