LAPACK 3.3.1
Linear Algebra PACKage

zunmrq.f

Go to the documentation of this file.
00001       SUBROUTINE ZUNMRQ( SIDE, TRANS, M, N, K, A, LDA, TAU, C, LDC,
00002      $                   WORK, LWORK, INFO )
00003 *
00004 *  -- LAPACK routine (version 3.3.1) --
00005 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00006 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00007 *  -- April 2011                                                      --
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 *  ZUNMRQ 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(1)**H H(2)**H . . . H(k)**H
00030 *
00031 *  as returned by ZGERQF. 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
00058 *                               (LDA,M) if SIDE = 'L',
00059 *                               (LDA,N) if SIDE = 'R'
00060 *          The i-th row must contain the vector which defines the
00061 *          elementary reflector H(i), for i = 1,2,...,k, as returned by
00062 *          ZGERQF in the last k rows of its array argument A.
00063 *          A is modified by the routine but restored on exit.
00064 *
00065 *  LDA     (input) INTEGER
00066 *          The leading dimension of the array A. LDA >= max(1,K).
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 ZGERQF.
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       CHARACTER          TRANST
00108       INTEGER            I, I1, I2, I3, IB, IINFO, IWS, LDWORK, LWKOPT,
00109      $                   MI, NB, NBMIN, NI, NQ, NW
00110 *     ..
00111 *     .. Local Arrays ..
00112       COMPLEX*16         T( LDT, NBMAX )
00113 *     ..
00114 *     .. External Functions ..
00115       LOGICAL            LSAME
00116       INTEGER            ILAENV
00117       EXTERNAL           LSAME, ILAENV
00118 *     ..
00119 *     .. External Subroutines ..
00120       EXTERNAL           XERBLA, ZLARFB, ZLARFT, ZUNMR2
00121 *     ..
00122 *     .. Intrinsic Functions ..
00123       INTRINSIC          MAX, MIN
00124 *     ..
00125 *     .. Executable Statements ..
00126 *
00127 *     Test the input arguments
00128 *
00129       INFO = 0
00130       LEFT = LSAME( SIDE, 'L' )
00131       NOTRAN = LSAME( TRANS, 'N' )
00132       LQUERY = ( LWORK.EQ.-1 )
00133 *
00134 *     NQ is the order of Q and NW is the minimum dimension of WORK
00135 *
00136       IF( LEFT ) THEN
00137          NQ = M
00138          NW = MAX( 1, N )
00139       ELSE
00140          NQ = N
00141          NW = MAX( 1, M )
00142       END IF
00143       IF( .NOT.LEFT .AND. .NOT.LSAME( SIDE, 'R' ) ) THEN
00144          INFO = -1
00145       ELSE IF( .NOT.NOTRAN .AND. .NOT.LSAME( TRANS, 'C' ) ) THEN
00146          INFO = -2
00147       ELSE IF( M.LT.0 ) THEN
00148          INFO = -3
00149       ELSE IF( N.LT.0 ) THEN
00150          INFO = -4
00151       ELSE IF( K.LT.0 .OR. K.GT.NQ ) THEN
00152          INFO = -5
00153       ELSE IF( LDA.LT.MAX( 1, K ) ) THEN
00154          INFO = -7
00155       ELSE IF( LDC.LT.MAX( 1, M ) ) THEN
00156          INFO = -10
00157       END IF
00158 *
00159       IF( INFO.EQ.0 ) THEN
00160          IF( M.EQ.0 .OR. N.EQ.0 ) THEN
00161             LWKOPT = 1
00162          ELSE
00163 *
00164 *           Determine the block size.  NB may be at most NBMAX, where
00165 *           NBMAX is used to define the local array T.
00166 *
00167             NB = MIN( NBMAX, ILAENV( 1, 'ZUNMRQ', SIDE // TRANS, M, N,
00168      $                               K, -1 ) )
00169             LWKOPT = NW*NB
00170          END IF
00171          WORK( 1 ) = LWKOPT
00172 *
00173          IF( LWORK.LT.NW .AND. .NOT.LQUERY ) THEN
00174             INFO = -12
00175          END IF
00176       END IF
00177 *
00178       IF( INFO.NE.0 ) THEN
00179          CALL XERBLA( 'ZUNMRQ', -INFO )
00180          RETURN
00181       ELSE IF( LQUERY ) THEN
00182          RETURN
00183       END IF
00184 *
00185 *     Quick return if possible
00186 *
00187       IF( M.EQ.0 .OR. N.EQ.0 ) THEN
00188          RETURN
00189       END IF
00190 *
00191       NBMIN = 2
00192       LDWORK = NW
00193       IF( NB.GT.1 .AND. NB.LT.K ) THEN
00194          IWS = NW*NB
00195          IF( LWORK.LT.IWS ) THEN
00196             NB = LWORK / LDWORK
00197             NBMIN = MAX( 2, ILAENV( 2, 'ZUNMRQ', SIDE // TRANS, M, N, K,
00198      $              -1 ) )
00199          END IF
00200       ELSE
00201          IWS = NW
00202       END IF
00203 *
00204       IF( NB.LT.NBMIN .OR. NB.GE.K ) THEN
00205 *
00206 *        Use unblocked code
00207 *
00208          CALL ZUNMR2( SIDE, TRANS, M, N, K, A, LDA, TAU, C, LDC, WORK,
00209      $                IINFO )
00210       ELSE
00211 *
00212 *        Use blocked code
00213 *
00214          IF( ( LEFT .AND. .NOT.NOTRAN ) .OR.
00215      $       ( .NOT.LEFT .AND. NOTRAN ) ) THEN
00216             I1 = 1
00217             I2 = K
00218             I3 = NB
00219          ELSE
00220             I1 = ( ( K-1 ) / NB )*NB + 1
00221             I2 = 1
00222             I3 = -NB
00223          END IF
00224 *
00225          IF( LEFT ) THEN
00226             NI = N
00227          ELSE
00228             MI = M
00229          END IF
00230 *
00231          IF( NOTRAN ) THEN
00232             TRANST = 'C'
00233          ELSE
00234             TRANST = 'N'
00235          END IF
00236 *
00237          DO 10 I = I1, I2, I3
00238             IB = MIN( NB, K-I+1 )
00239 *
00240 *           Form the triangular factor of the block reflector
00241 *           H = H(i+ib-1) . . . H(i+1) H(i)
00242 *
00243             CALL ZLARFT( 'Backward', 'Rowwise', NQ-K+I+IB-1, IB,
00244      $                   A( I, 1 ), LDA, TAU( I ), T, LDT )
00245             IF( LEFT ) THEN
00246 *
00247 *              H or H**H is applied to C(1:m-k+i+ib-1,1:n)
00248 *
00249                MI = M - K + I + IB - 1
00250             ELSE
00251 *
00252 *              H or H**H is applied to C(1:m,1:n-k+i+ib-1)
00253 *
00254                NI = N - K + I + IB - 1
00255             END IF
00256 *
00257 *           Apply H or H**H
00258 *
00259             CALL ZLARFB( SIDE, TRANST, 'Backward', 'Rowwise', MI, NI,
00260      $                   IB, A( I, 1 ), LDA, T, LDT, C, LDC, WORK,
00261      $                   LDWORK )
00262    10    CONTINUE
00263       END IF
00264       WORK( 1 ) = LWKOPT
00265       RETURN
00266 *
00267 *     End of ZUNMRQ
00268 *
00269       END
 All Files Functions