cunmqr.c
Go to the documentation of this file.
00001 /* cunmqr.f -- translated by f2c (version 20061008).
00002    You must link the resulting object file with libf2c:
00003         on Microsoft Windows system, link with libf2c.lib;
00004         on Linux or Unix systems, link with .../path/to/libf2c.a -lm
00005         or, if you install libf2c.a in a standard place, with -lf2c -lm
00006         -- in that order, at the end of the command line, as in
00007                 cc *.o -lf2c -lm
00008         Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
00009 
00010                 http://www.netlib.org/f2c/libf2c.zip
00011 */
00012 
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015 
00016 /* Table of constant values */
00017 
00018 static integer c__1 = 1;
00019 static integer c_n1 = -1;
00020 static integer c__2 = 2;
00021 static integer c__65 = 65;
00022 
00023 /* Subroutine */ int cunmqr_(char *side, char *trans, integer *m, integer *n, 
00024         integer *k, complex *a, integer *lda, complex *tau, complex *c__, 
00025         integer *ldc, complex *work, integer *lwork, integer *info)
00026 {
00027     /* System generated locals */
00028     address a__1[2];
00029     integer a_dim1, a_offset, c_dim1, c_offset, i__1, i__2, i__3[2], i__4, 
00030             i__5;
00031     char ch__1[2];
00032 
00033     /* Builtin functions */
00034     /* Subroutine */ int s_cat(char *, char **, integer *, integer *, ftnlen);
00035 
00036     /* Local variables */
00037     integer i__;
00038     complex t[4160]     /* was [65][64] */;
00039     integer i1, i2, i3, ib, ic, jc, nb, mi, ni, nq, nw, iws;
00040     logical left;
00041     extern logical lsame_(char *, char *);
00042     integer nbmin, iinfo;
00043     extern /* Subroutine */ int cunm2r_(char *, char *, integer *, integer *, 
00044             integer *, complex *, integer *, complex *, complex *, integer *, 
00045             complex *, integer *), clarfb_(char *, char *, 
00046             char *, char *, integer *, integer *, integer *, complex *, 
00047             integer *, complex *, integer *, complex *, integer *, complex *, 
00048             integer *), clarft_(char *, char *
00049 , integer *, integer *, complex *, integer *, complex *, complex *
00050 , integer *), xerbla_(char *, integer *);
00051     extern integer ilaenv_(integer *, char *, char *, integer *, integer *, 
00052             integer *, integer *);
00053     logical notran;
00054     integer ldwork, lwkopt;
00055     logical lquery;
00056 
00057 
00058 /*  -- LAPACK routine (version 3.2) -- */
00059 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00060 /*     November 2006 */
00061 
00062 /*     .. Scalar Arguments .. */
00063 /*     .. */
00064 /*     .. Array Arguments .. */
00065 /*     .. */
00066 
00067 /*  Purpose */
00068 /*  ======= */
00069 
00070 /*  CUNMQR overwrites the general complex M-by-N matrix C with */
00071 
00072 /*                  SIDE = 'L'     SIDE = 'R' */
00073 /*  TRANS = 'N':      Q * C          C * Q */
00074 /*  TRANS = 'C':      Q**H * C       C * Q**H */
00075 
00076 /*  where Q is a complex unitary matrix defined as the product of k */
00077 /*  elementary reflectors */
00078 
00079 /*        Q = H(1) H(2) . . . H(k) */
00080 
00081 /*  as returned by CGEQRF. Q is of order M if SIDE = 'L' and of order N */
00082 /*  if SIDE = 'R'. */
00083 
00084 /*  Arguments */
00085 /*  ========= */
00086 
00087 /*  SIDE    (input) CHARACTER*1 */
00088 /*          = 'L': apply Q or Q**H from the Left; */
00089 /*          = 'R': apply Q or Q**H from the Right. */
00090 
00091 /*  TRANS   (input) CHARACTER*1 */
00092 /*          = 'N':  No transpose, apply Q; */
00093 /*          = 'C':  Conjugate transpose, apply Q**H. */
00094 
00095 /*  M       (input) INTEGER */
00096 /*          The number of rows of the matrix C. M >= 0. */
00097 
00098 /*  N       (input) INTEGER */
00099 /*          The number of columns of the matrix C. N >= 0. */
00100 
00101 /*  K       (input) INTEGER */
00102 /*          The number of elementary reflectors whose product defines */
00103 /*          the matrix Q. */
00104 /*          If SIDE = 'L', M >= K >= 0; */
00105 /*          if SIDE = 'R', N >= K >= 0. */
00106 
00107 /*  A       (input) COMPLEX array, dimension (LDA,K) */
00108 /*          The i-th column must contain the vector which defines the */
00109 /*          elementary reflector H(i), for i = 1,2,...,k, as returned by */
00110 /*          CGEQRF in the first k columns of its array argument A. */
00111 /*          A is modified by the routine but restored on exit. */
00112 
00113 /*  LDA     (input) INTEGER */
00114 /*          The leading dimension of the array A. */
00115 /*          If SIDE = 'L', LDA >= max(1,M); */
00116 /*          if SIDE = 'R', LDA >= max(1,N). */
00117 
00118 /*  TAU     (input) COMPLEX array, dimension (K) */
00119 /*          TAU(i) must contain the scalar factor of the elementary */
00120 /*          reflector H(i), as returned by CGEQRF. */
00121 
00122 /*  C       (input/output) COMPLEX array, dimension (LDC,N) */
00123 /*          On entry, the M-by-N matrix C. */
00124 /*          On exit, C is overwritten by Q*C or Q**H*C or C*Q**H or C*Q. */
00125 
00126 /*  LDC     (input) INTEGER */
00127 /*          The leading dimension of the array C. LDC >= max(1,M). */
00128 
00129 /*  WORK    (workspace/output) COMPLEX array, dimension (MAX(1,LWORK)) */
00130 /*          On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */
00131 
00132 /*  LWORK   (input) INTEGER */
00133 /*          The dimension of the array WORK. */
00134 /*          If SIDE = 'L', LWORK >= max(1,N); */
00135 /*          if SIDE = 'R', LWORK >= max(1,M). */
00136 /*          For optimum performance LWORK >= N*NB if SIDE = 'L', and */
00137 /*          LWORK >= M*NB if SIDE = 'R', where NB is the optimal */
00138 /*          blocksize. */
00139 
00140 /*          If LWORK = -1, then a workspace query is assumed; the routine */
00141 /*          only calculates the optimal size of the WORK array, returns */
00142 /*          this value as the first entry of the WORK array, and no error */
00143 /*          message related to LWORK is issued by XERBLA. */
00144 
00145 /*  INFO    (output) INTEGER */
00146 /*          = 0:  successful exit */
00147 /*          < 0:  if INFO = -i, the i-th argument had an illegal value */
00148 
00149 /*  ===================================================================== */
00150 
00151 /*     .. Parameters .. */
00152 /*     .. */
00153 /*     .. Local Scalars .. */
00154 /*     .. */
00155 /*     .. Local Arrays .. */
00156 /*     .. */
00157 /*     .. External Functions .. */
00158 /*     .. */
00159 /*     .. External Subroutines .. */
00160 /*     .. */
00161 /*     .. Intrinsic Functions .. */
00162 /*     .. */
00163 /*     .. Executable Statements .. */
00164 
00165 /*     Test the input arguments */
00166 
00167     /* Parameter adjustments */
00168     a_dim1 = *lda;
00169     a_offset = 1 + a_dim1;
00170     a -= a_offset;
00171     --tau;
00172     c_dim1 = *ldc;
00173     c_offset = 1 + c_dim1;
00174     c__ -= c_offset;
00175     --work;
00176 
00177     /* Function Body */
00178     *info = 0;
00179     left = lsame_(side, "L");
00180     notran = lsame_(trans, "N");
00181     lquery = *lwork == -1;
00182 
00183 /*     NQ is the order of Q and NW is the minimum dimension of WORK */
00184 
00185     if (left) {
00186         nq = *m;
00187         nw = *n;
00188     } else {
00189         nq = *n;
00190         nw = *m;
00191     }
00192     if (! left && ! lsame_(side, "R")) {
00193         *info = -1;
00194     } else if (! notran && ! lsame_(trans, "C")) {
00195         *info = -2;
00196     } else if (*m < 0) {
00197         *info = -3;
00198     } else if (*n < 0) {
00199         *info = -4;
00200     } else if (*k < 0 || *k > nq) {
00201         *info = -5;
00202     } else if (*lda < max(1,nq)) {
00203         *info = -7;
00204     } else if (*ldc < max(1,*m)) {
00205         *info = -10;
00206     } else if (*lwork < max(1,nw) && ! lquery) {
00207         *info = -12;
00208     }
00209 
00210     if (*info == 0) {
00211 
00212 /*        Determine the block size.  NB may be at most NBMAX, where NBMAX */
00213 /*        is used to define the local array T. */
00214 
00215 /* Computing MIN */
00216 /* Writing concatenation */
00217         i__3[0] = 1, a__1[0] = side;
00218         i__3[1] = 1, a__1[1] = trans;
00219         s_cat(ch__1, a__1, i__3, &c__2, (ftnlen)2);
00220         i__1 = 64, i__2 = ilaenv_(&c__1, "CUNMQR", ch__1, m, n, k, &c_n1);
00221         nb = min(i__1,i__2);
00222         lwkopt = max(1,nw) * nb;
00223         work[1].r = (real) lwkopt, work[1].i = 0.f;
00224     }
00225 
00226     if (*info != 0) {
00227         i__1 = -(*info);
00228         xerbla_("CUNMQR", &i__1);
00229         return 0;
00230     } else if (lquery) {
00231         return 0;
00232     }
00233 
00234 /*     Quick return if possible */
00235 
00236     if (*m == 0 || *n == 0 || *k == 0) {
00237         work[1].r = 1.f, work[1].i = 0.f;
00238         return 0;
00239     }
00240 
00241     nbmin = 2;
00242     ldwork = nw;
00243     if (nb > 1 && nb < *k) {
00244         iws = nw * nb;
00245         if (*lwork < iws) {
00246             nb = *lwork / ldwork;
00247 /* Computing MAX */
00248 /* Writing concatenation */
00249             i__3[0] = 1, a__1[0] = side;
00250             i__3[1] = 1, a__1[1] = trans;
00251             s_cat(ch__1, a__1, i__3, &c__2, (ftnlen)2);
00252             i__1 = 2, i__2 = ilaenv_(&c__2, "CUNMQR", ch__1, m, n, k, &c_n1);
00253             nbmin = max(i__1,i__2);
00254         }
00255     } else {
00256         iws = nw;
00257     }
00258 
00259     if (nb < nbmin || nb >= *k) {
00260 
00261 /*        Use unblocked code */
00262 
00263         cunm2r_(side, trans, m, n, k, &a[a_offset], lda, &tau[1], &c__[
00264                 c_offset], ldc, &work[1], &iinfo);
00265     } else {
00266 
00267 /*        Use blocked code */
00268 
00269         if (left && ! notran || ! left && notran) {
00270             i1 = 1;
00271             i2 = *k;
00272             i3 = nb;
00273         } else {
00274             i1 = (*k - 1) / nb * nb + 1;
00275             i2 = 1;
00276             i3 = -nb;
00277         }
00278 
00279         if (left) {
00280             ni = *n;
00281             jc = 1;
00282         } else {
00283             mi = *m;
00284             ic = 1;
00285         }
00286 
00287         i__1 = i2;
00288         i__2 = i3;
00289         for (i__ = i1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) {
00290 /* Computing MIN */
00291             i__4 = nb, i__5 = *k - i__ + 1;
00292             ib = min(i__4,i__5);
00293 
00294 /*           Form the triangular factor of the block reflector */
00295 /*           H = H(i) H(i+1) . . . H(i+ib-1) */
00296 
00297             i__4 = nq - i__ + 1;
00298             clarft_("Forward", "Columnwise", &i__4, &ib, &a[i__ + i__ * 
00299                     a_dim1], lda, &tau[i__], t, &c__65)
00300                     ;
00301             if (left) {
00302 
00303 /*              H or H' is applied to C(i:m,1:n) */
00304 
00305                 mi = *m - i__ + 1;
00306                 ic = i__;
00307             } else {
00308 
00309 /*              H or H' is applied to C(1:m,i:n) */
00310 
00311                 ni = *n - i__ + 1;
00312                 jc = i__;
00313             }
00314 
00315 /*           Apply H or H' */
00316 
00317             clarfb_(side, trans, "Forward", "Columnwise", &mi, &ni, &ib, &a[
00318                     i__ + i__ * a_dim1], lda, t, &c__65, &c__[ic + jc * 
00319                     c_dim1], ldc, &work[1], &ldwork);
00320 /* L10: */
00321         }
00322     }
00323     work[1].r = (real) lwkopt, work[1].i = 0.f;
00324     return 0;
00325 
00326 /*     End of CUNMQR */
00327 
00328 } /* cunmqr_ */


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:55:35