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


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