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


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:56:44