zunmrz.c
Go to the documentation of this file.
00001 /* zunmrz.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 zunmrz_(char *side, char *trans, integer *m, integer *n, 
00024         integer *k, integer *l, doublecomplex *a, integer *lda, doublecomplex 
00025         *tau, doublecomplex *c__, integer *ldc, doublecomplex *work, integer *
00026         lwork, 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, ic, ja, jc, nb, mi, ni, nq, nw, iws;
00041     logical left;
00042     extern logical lsame_(char *, char *);
00043     integer nbmin, iinfo;
00044     extern /* Subroutine */ int zunmr3_(char *, char *, integer *, integer *, 
00045             integer *, 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     logical notran;
00050     integer ldwork;
00051     extern /* Subroutine */ int zlarzb_(char *, char *, char *, char *, 
00052             integer *, integer *, integer *, integer *, doublecomplex *, 
00053             integer *, doublecomplex *, integer *, doublecomplex *, integer *, 
00054              doublecomplex *, integer *);
00055     char transt[1];
00056     integer lwkopt;
00057     logical lquery;
00058     extern /* Subroutine */ int zlarzt_(char *, char *, integer *, integer *, 
00059             doublecomplex *, integer *, doublecomplex *, doublecomplex *, 
00060             integer *);
00061 
00062 
00063 /*  -- LAPACK routine (version 3.2) -- */
00064 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00065 /*     January 2007 */
00066 
00067 /*     .. Scalar Arguments .. */
00068 /*     .. */
00069 /*     .. Array Arguments .. */
00070 /*     .. */
00071 
00072 /*  Purpose */
00073 /*  ======= */
00074 
00075 /*  ZUNMRZ 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 ZTZRZF. 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':  Conjugate 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 /*  L       (input) INTEGER */
00113 /*          The number of columns of the matrix A containing */
00114 /*          the meaningful part of the Householder reflectors. */
00115 /*          If SIDE = 'L', M >= L >= 0, if SIDE = 'R', N >= L >= 0. */
00116 
00117 /*  A       (input) COMPLEX*16 array, dimension */
00118 /*                               (LDA,M) if SIDE = 'L', */
00119 /*                               (LDA,N) if SIDE = 'R' */
00120 /*          The i-th row must contain the vector which defines the */
00121 /*          elementary reflector H(i), for i = 1,2,...,k, as returned by */
00122 /*          ZTZRZF in the last k rows of its array argument A. */
00123 /*          A is modified by the routine but restored on exit. */
00124 
00125 /*  LDA     (input) INTEGER */
00126 /*          The leading dimension of the array A. LDA >= max(1,K). */
00127 
00128 /*  TAU     (input) COMPLEX*16 array, dimension (K) */
00129 /*          TAU(i) must contain the scalar factor of the elementary */
00130 /*          reflector H(i), as returned by ZTZRZF. */
00131 
00132 /*  C       (input/output) COMPLEX*16 array, dimension (LDC,N) */
00133 /*          On entry, the M-by-N matrix C. */
00134 /*          On exit, C is overwritten by Q*C or Q**H*C or C*Q**H or C*Q. */
00135 
00136 /*  LDC     (input) INTEGER */
00137 /*          The leading dimension of the array C. LDC >= max(1,M). */
00138 
00139 /*  WORK    (workspace/output) COMPLEX*16 array, dimension (MAX(1,LWORK)) */
00140 /*          On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */
00141 
00142 /*  LWORK   (input) INTEGER */
00143 /*          The dimension of the array WORK. */
00144 /*          If SIDE = 'L', LWORK >= max(1,N); */
00145 /*          if SIDE = 'R', LWORK >= max(1,M). */
00146 /*          For optimum performance LWORK >= N*NB if SIDE = 'L', and */
00147 /*          LWORK >= M*NB if SIDE = 'R', where NB is the optimal */
00148 /*          blocksize. */
00149 
00150 /*          If LWORK = -1, then a workspace query is assumed; the routine */
00151 /*          only calculates the optimal size of the WORK array, returns */
00152 /*          this value as the first entry of the WORK array, and no error */
00153 /*          message related to LWORK is issued by XERBLA. */
00154 
00155 /*  INFO    (output) INTEGER */
00156 /*          = 0:  successful exit */
00157 /*          < 0:  if INFO = -i, the i-th argument had an illegal value */
00158 
00159 /*  Further Details */
00160 /*  =============== */
00161 
00162 /*  Based on contributions by */
00163 /*    A. Petitet, Computer Science Dept., Univ. of Tenn., Knoxville, USA */
00164 
00165 /*  ===================================================================== */
00166 
00167 /*     .. Parameters .. */
00168 /*     .. */
00169 /*     .. Local Scalars .. */
00170 /*     .. */
00171 /*     .. Local Arrays .. */
00172 /*     .. */
00173 /*     .. External Functions .. */
00174 /*     .. */
00175 /*     .. External Subroutines .. */
00176 /*     .. */
00177 /*     .. Intrinsic Functions .. */
00178 /*     .. */
00179 /*     .. Executable Statements .. */
00180 
00181 /*     Test the input arguments */
00182 
00183     /* Parameter adjustments */
00184     a_dim1 = *lda;
00185     a_offset = 1 + a_dim1;
00186     a -= a_offset;
00187     --tau;
00188     c_dim1 = *ldc;
00189     c_offset = 1 + c_dim1;
00190     c__ -= c_offset;
00191     --work;
00192 
00193     /* Function Body */
00194     *info = 0;
00195     left = lsame_(side, "L");
00196     notran = lsame_(trans, "N");
00197     lquery = *lwork == -1;
00198 
00199 /*     NQ is the order of Q and NW is the minimum dimension of WORK */
00200 
00201     if (left) {
00202         nq = *m;
00203         nw = max(1,*n);
00204     } else {
00205         nq = *n;
00206         nw = max(1,*m);
00207     }
00208     if (! left && ! lsame_(side, "R")) {
00209         *info = -1;
00210     } else if (! notran && ! lsame_(trans, "C")) {
00211         *info = -2;
00212     } else if (*m < 0) {
00213         *info = -3;
00214     } else if (*n < 0) {
00215         *info = -4;
00216     } else if (*k < 0 || *k > nq) {
00217         *info = -5;
00218     } else if (*l < 0 || left && *l > *m || ! left && *l > *n) {
00219         *info = -6;
00220     } else if (*lda < max(1,*k)) {
00221         *info = -8;
00222     } else if (*ldc < max(1,*m)) {
00223         *info = -11;
00224     }
00225 
00226     if (*info == 0) {
00227         if (*m == 0 || *n == 0) {
00228             lwkopt = 1;
00229         } else {
00230 
00231 /*           Determine the block size.  NB may be at most NBMAX, where */
00232 /*           NBMAX is used to define the local array T. */
00233 
00234 /* Computing MIN */
00235 /* Writing concatenation */
00236             i__3[0] = 1, a__1[0] = side;
00237             i__3[1] = 1, a__1[1] = trans;
00238             s_cat(ch__1, a__1, i__3, &c__2, (ftnlen)2);
00239             i__1 = 64, i__2 = ilaenv_(&c__1, "ZUNMRQ", ch__1, m, n, k, &c_n1);
00240             nb = min(i__1,i__2);
00241             lwkopt = nw * nb;
00242         }
00243         work[1].r = (doublereal) lwkopt, work[1].i = 0.;
00244 
00245         if (*lwork < max(1,nw) && ! lquery) {
00246             *info = -13;
00247         }
00248     }
00249 
00250     if (*info != 0) {
00251         i__1 = -(*info);
00252         xerbla_("ZUNMRZ", &i__1);
00253         return 0;
00254     } else if (lquery) {
00255         return 0;
00256     }
00257 
00258 /*     Quick return if possible */
00259 
00260     if (*m == 0 || *n == 0) {
00261         return 0;
00262     }
00263 
00264 /*     Determine the block size.  NB may be at most NBMAX, where NBMAX */
00265 /*     is used to define the local array T. */
00266 
00267 /* Computing MIN */
00268 /* Writing concatenation */
00269     i__3[0] = 1, a__1[0] = side;
00270     i__3[1] = 1, a__1[1] = trans;
00271     s_cat(ch__1, a__1, i__3, &c__2, (ftnlen)2);
00272     i__1 = 64, i__2 = ilaenv_(&c__1, "ZUNMRQ", ch__1, m, n, k, &c_n1);
00273     nb = min(i__1,i__2);
00274     nbmin = 2;
00275     ldwork = nw;
00276     if (nb > 1 && nb < *k) {
00277         iws = nw * nb;
00278         if (*lwork < iws) {
00279             nb = *lwork / ldwork;
00280 /* Computing MAX */
00281 /* Writing concatenation */
00282             i__3[0] = 1, a__1[0] = side;
00283             i__3[1] = 1, a__1[1] = trans;
00284             s_cat(ch__1, a__1, i__3, &c__2, (ftnlen)2);
00285             i__1 = 2, i__2 = ilaenv_(&c__2, "ZUNMRQ", ch__1, m, n, k, &c_n1);
00286             nbmin = max(i__1,i__2);
00287         }
00288     } else {
00289         iws = nw;
00290     }
00291 
00292     if (nb < nbmin || nb >= *k) {
00293 
00294 /*        Use unblocked code */
00295 
00296         zunmr3_(side, trans, m, n, k, l, &a[a_offset], lda, &tau[1], &c__[
00297                 c_offset], ldc, &work[1], &iinfo);
00298     } else {
00299 
00300 /*        Use blocked code */
00301 
00302         if (left && ! notran || ! left && notran) {
00303             i1 = 1;
00304             i2 = *k;
00305             i3 = nb;
00306         } else {
00307             i1 = (*k - 1) / nb * nb + 1;
00308             i2 = 1;
00309             i3 = -nb;
00310         }
00311 
00312         if (left) {
00313             ni = *n;
00314             jc = 1;
00315             ja = *m - *l + 1;
00316         } else {
00317             mi = *m;
00318             ic = 1;
00319             ja = *n - *l + 1;
00320         }
00321 
00322         if (notran) {
00323             *(unsigned char *)transt = 'C';
00324         } else {
00325             *(unsigned char *)transt = 'N';
00326         }
00327 
00328         i__1 = i2;
00329         i__2 = i3;
00330         for (i__ = i1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) {
00331 /* Computing MIN */
00332             i__4 = nb, i__5 = *k - i__ + 1;
00333             ib = min(i__4,i__5);
00334 
00335 /*           Form the triangular factor of the block reflector */
00336 /*           H = H(i+ib-1) . . . H(i+1) H(i) */
00337 
00338             zlarzt_("Backward", "Rowwise", l, &ib, &a[i__ + ja * a_dim1], lda, 
00339                      &tau[i__], t, &c__65);
00340 
00341             if (left) {
00342 
00343 /*              H or H' is applied to C(i:m,1:n) */
00344 
00345                 mi = *m - i__ + 1;
00346                 ic = i__;
00347             } else {
00348 
00349 /*              H or H' is applied to C(1:m,i:n) */
00350 
00351                 ni = *n - i__ + 1;
00352                 jc = i__;
00353             }
00354 
00355 /*           Apply H or H' */
00356 
00357             zlarzb_(side, transt, "Backward", "Rowwise", &mi, &ni, &ib, l, &a[
00358                     i__ + ja * a_dim1], lda, t, &c__65, &c__[ic + jc * c_dim1]
00359 , ldc, &work[1], &ldwork);
00360 /* L10: */
00361         }
00362 
00363     }
00364 
00365     work[1].r = (doublereal) lwkopt, work[1].i = 0.;
00366 
00367     return 0;
00368 
00369 /*     End of ZUNMRZ */
00370 
00371 } /* zunmrz_ */


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