LAPACK 3.3.1
Linear Algebra PACKage

cunmqr.f

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