LAPACK 3.3.0

zunmql.f

Go to the documentation of this file.
00001       SUBROUTINE ZUNMQL( SIDE, TRANS, M, N, K, A, LDA, TAU, C, LDC,
00002      $                   WORK, LWORK, INFO )
00003 *
00004 *  -- LAPACK routine (version 3.2) --
00005 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00006 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00007 *     November 2006
00008 *
00009 *     .. Scalar Arguments ..
00010       CHARACTER          SIDE, TRANS
00011       INTEGER            INFO, K, LDA, LDC, LWORK, M, N
00012 *     ..
00013 *     .. Array Arguments ..
00014       COMPLEX*16         A( LDA, * ), C( LDC, * ), TAU( * ), WORK( * )
00015 *     ..
00016 *
00017 *  Purpose
00018 *  =======
00019 *
00020 *  ZUNMQL overwrites the general complex M-by-N matrix C with
00021 *
00022 *                  SIDE = 'L'     SIDE = 'R'
00023 *  TRANS = 'N':      Q * C          C * Q
00024 *  TRANS = 'C':      Q**H * C       C * Q**H
00025 *
00026 *  where Q is a complex unitary matrix defined as the product of k
00027 *  elementary reflectors
00028 *
00029 *        Q = H(k) . . . H(2) H(1)
00030 *
00031 *  as returned by ZGEQLF. Q is of order M if SIDE = 'L' and of order N
00032 *  if SIDE = 'R'.
00033 *
00034 *  Arguments
00035 *  =========
00036 *
00037 *  SIDE    (input) CHARACTER*1
00038 *          = 'L': apply Q or Q**H from the Left;
00039 *          = 'R': apply Q or Q**H from the Right.
00040 *
00041 *  TRANS   (input) CHARACTER*1
00042 *          = 'N':  No transpose, apply Q;
00043 *          = 'C':  Transpose, apply Q**H.
00044 *
00045 *  M       (input) INTEGER
00046 *          The number of rows of the matrix C. M >= 0.
00047 *
00048 *  N       (input) INTEGER
00049 *          The number of columns of the matrix C. N >= 0.
00050 *
00051 *  K       (input) INTEGER
00052 *          The number of elementary reflectors whose product defines
00053 *          the matrix Q.
00054 *          If SIDE = 'L', M >= K >= 0;
00055 *          if SIDE = 'R', N >= K >= 0.
00056 *
00057 *  A       (input) COMPLEX*16 array, dimension (LDA,K)
00058 *          The i-th column must contain the vector which defines the
00059 *          elementary reflector H(i), for i = 1,2,...,k, as returned by
00060 *          ZGEQLF in the last k columns of its array argument A.
00061 *          A is modified by the routine but restored on exit.
00062 *
00063 *  LDA     (input) INTEGER
00064 *          The leading dimension of the array A.
00065 *          If SIDE = 'L', LDA >= max(1,M);
00066 *          if SIDE = 'R', LDA >= max(1,N).
00067 *
00068 *  TAU     (input) COMPLEX*16 array, dimension (K)
00069 *          TAU(i) must contain the scalar factor of the elementary
00070 *          reflector H(i), as returned by ZGEQLF.
00071 *
00072 *  C       (input/output) COMPLEX*16 array, dimension (LDC,N)
00073 *          On entry, the M-by-N matrix C.
00074 *          On exit, C is overwritten by Q*C or Q**H*C or C*Q**H or C*Q.
00075 *
00076 *  LDC     (input) INTEGER
00077 *          The leading dimension of the array C. LDC >= max(1,M).
00078 *
00079 *  WORK    (workspace/output) COMPLEX*16 array, dimension (MAX(1,LWORK))
00080 *          On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
00081 *
00082 *  LWORK   (input) INTEGER
00083 *          The dimension of the array WORK.
00084 *          If SIDE = 'L', LWORK >= max(1,N);
00085 *          if SIDE = 'R', LWORK >= max(1,M).
00086 *          For optimum performance LWORK >= N*NB if SIDE = 'L', and
00087 *          LWORK >= M*NB if SIDE = 'R', where NB is the optimal
00088 *          blocksize.
00089 *
00090 *          If LWORK = -1, then a workspace query is assumed; the routine
00091 *          only calculates the optimal size of the WORK array, returns
00092 *          this value as the first entry of the WORK array, and no error
00093 *          message related to LWORK is issued by XERBLA.
00094 *
00095 *  INFO    (output) INTEGER
00096 *          = 0:  successful exit
00097 *          < 0:  if INFO = -i, the i-th argument had an illegal value
00098 *
00099 *  =====================================================================
00100 *
00101 *     .. Parameters ..
00102       INTEGER            NBMAX, LDT
00103       PARAMETER          ( NBMAX = 64, LDT = NBMAX+1 )
00104 *     ..
00105 *     .. Local Scalars ..
00106       LOGICAL            LEFT, LQUERY, NOTRAN
00107       INTEGER            I, I1, I2, I3, IB, IINFO, IWS, LDWORK, LWKOPT,
00108      $                   MI, NB, NBMIN, NI, NQ, NW
00109 *     ..
00110 *     .. Local Arrays ..
00111       COMPLEX*16         T( LDT, NBMAX )
00112 *     ..
00113 *     .. External Functions ..
00114       LOGICAL            LSAME
00115       INTEGER            ILAENV
00116       EXTERNAL           LSAME, ILAENV
00117 *     ..
00118 *     .. External Subroutines ..
00119       EXTERNAL           XERBLA, ZLARFB, ZLARFT, ZUNM2L
00120 *     ..
00121 *     .. Intrinsic Functions ..
00122       INTRINSIC          MAX, MIN
00123 *     ..
00124 *     .. Executable Statements ..
00125 *
00126 *     Test the input arguments
00127 *
00128       INFO = 0
00129       LEFT = LSAME( SIDE, 'L' )
00130       NOTRAN = LSAME( TRANS, 'N' )
00131       LQUERY = ( LWORK.EQ.-1 )
00132 *
00133 *     NQ is the order of Q and NW is the minimum dimension of WORK
00134 *
00135       IF( LEFT ) THEN
00136          NQ = M
00137          NW = MAX( 1, N )
00138       ELSE
00139          NQ = N
00140          NW = MAX( 1, M )
00141       END IF
00142       IF( .NOT.LEFT .AND. .NOT.LSAME( SIDE, 'R' ) ) THEN
00143          INFO = -1
00144       ELSE IF( .NOT.NOTRAN .AND. .NOT.LSAME( TRANS, 'C' ) ) THEN
00145          INFO = -2
00146       ELSE IF( M.LT.0 ) THEN
00147          INFO = -3
00148       ELSE IF( N.LT.0 ) THEN
00149          INFO = -4
00150       ELSE IF( K.LT.0 .OR. K.GT.NQ ) THEN
00151          INFO = -5
00152       ELSE IF( LDA.LT.MAX( 1, NQ ) ) THEN
00153          INFO = -7
00154       ELSE IF( LDC.LT.MAX( 1, M ) ) THEN
00155          INFO = -10
00156       END IF
00157 *
00158       IF( INFO.EQ.0 ) THEN
00159          IF( M.EQ.0 .OR. N.EQ.0 ) THEN
00160             LWKOPT = 1
00161          ELSE
00162 *
00163 *           Determine the block size.  NB may be at most NBMAX, where
00164 *           NBMAX is used to define the local array T.
00165 *
00166             NB = MIN( NBMAX, ILAENV( 1, 'ZUNMQL', SIDE // TRANS, M, N,
00167      $                               K, -1 ) )
00168             LWKOPT = NW*NB
00169          END IF
00170          WORK( 1 ) = LWKOPT
00171 *
00172          IF( LWORK.LT.NW .AND. .NOT.LQUERY ) THEN
00173             INFO = -12
00174          END IF
00175       END IF
00176 *
00177       IF( INFO.NE.0 ) THEN
00178          CALL XERBLA( 'ZUNMQL', -INFO )
00179          RETURN
00180       ELSE IF( LQUERY ) THEN
00181          RETURN
00182       END IF
00183 *
00184 *     Quick return if possible
00185 *
00186       IF( M.EQ.0 .OR. N.EQ.0 ) THEN
00187          RETURN
00188       END IF
00189 *
00190       NBMIN = 2
00191       LDWORK = NW
00192       IF( NB.GT.1 .AND. NB.LT.K ) THEN
00193          IWS = NW*NB
00194          IF( LWORK.LT.IWS ) THEN
00195             NB = LWORK / LDWORK
00196             NBMIN = MAX( 2, ILAENV( 2, 'ZUNMQL', SIDE // TRANS, M, N, K,
00197      $              -1 ) )
00198          END IF
00199       ELSE
00200          IWS = NW
00201       END IF
00202 *
00203       IF( NB.LT.NBMIN .OR. NB.GE.K ) THEN
00204 *
00205 *        Use unblocked code
00206 *
00207          CALL ZUNM2L( SIDE, TRANS, M, N, K, A, LDA, TAU, C, LDC, WORK,
00208      $                IINFO )
00209       ELSE
00210 *
00211 *        Use blocked code
00212 *
00213          IF( ( LEFT .AND. NOTRAN ) .OR.
00214      $       ( .NOT.LEFT .AND. .NOT.NOTRAN ) ) THEN
00215             I1 = 1
00216             I2 = K
00217             I3 = NB
00218          ELSE
00219             I1 = ( ( K-1 ) / NB )*NB + 1
00220             I2 = 1
00221             I3 = -NB
00222          END IF
00223 *
00224          IF( LEFT ) THEN
00225             NI = N
00226          ELSE
00227             MI = M
00228          END IF
00229 *
00230          DO 10 I = I1, I2, I3
00231             IB = MIN( NB, K-I+1 )
00232 *
00233 *           Form the triangular factor of the block reflector
00234 *           H = H(i+ib-1) . . . H(i+1) H(i)
00235 *
00236             CALL ZLARFT( 'Backward', 'Columnwise', NQ-K+I+IB-1, IB,
00237      $                   A( 1, I ), LDA, TAU( I ), T, LDT )
00238             IF( LEFT ) THEN
00239 *
00240 *              H or H' is applied to C(1:m-k+i+ib-1,1:n)
00241 *
00242                MI = M - K + I + IB - 1
00243             ELSE
00244 *
00245 *              H or H' is applied to C(1:m,1:n-k+i+ib-1)
00246 *
00247                NI = N - K + I + IB - 1
00248             END IF
00249 *
00250 *           Apply H or H'
00251 *
00252             CALL ZLARFB( SIDE, TRANS, 'Backward', 'Columnwise', MI, NI,
00253      $                   IB, A( 1, I ), LDA, T, LDT, C, LDC, WORK,
00254      $                   LDWORK )
00255    10    CONTINUE
00256       END IF
00257       WORK( 1 ) = LWKOPT
00258       RETURN
00259 *
00260 *     End of ZUNMQL
00261 *
00262       END
 All Files Functions