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


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