zunmql.c
Go to the documentation of this file.
00001 /* zunmql.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 zunmql_(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 zunm2l_(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     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 /*     November 2006 */
00065 
00066 /*     .. Scalar Arguments .. */
00067 /*     .. */
00068 /*     .. Array Arguments .. */
00069 /*     .. */
00070 
00071 /*  Purpose */
00072 /*  ======= */
00073 
00074 /*  ZUNMQL 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(k) . . . H(2) H(1) */
00084 
00085 /*  as returned by ZGEQLF. 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':  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 /*  A       (input) COMPLEX*16 array, dimension (LDA,K) */
00112 /*          The i-th column must contain the vector which defines the */
00113 /*          elementary reflector H(i), for i = 1,2,...,k, as returned by */
00114 /*          ZGEQLF in the last k columns 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. */
00119 /*          If SIDE = 'L', LDA >= max(1,M); */
00120 /*          if SIDE = 'R', LDA >= max(1,N). */
00121 
00122 /*  TAU     (input) COMPLEX*16 array, dimension (K) */
00123 /*          TAU(i) must contain the scalar factor of the elementary */
00124 /*          reflector H(i), as returned by ZGEQLF. */
00125 
00126 /*  C       (input/output) COMPLEX*16 array, dimension (LDC,N) */
00127 /*          On entry, the M-by-N matrix C. */
00128 /*          On exit, C is overwritten by Q*C or Q**H*C or C*Q**H or C*Q. */
00129 
00130 /*  LDC     (input) INTEGER */
00131 /*          The leading dimension of the array C. LDC >= max(1,M). */
00132 
00133 /*  WORK    (workspace/output) COMPLEX*16 array, dimension (MAX(1,LWORK)) */
00134 /*          On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */
00135 
00136 /*  LWORK   (input) INTEGER */
00137 /*          The dimension of the array WORK. */
00138 /*          If SIDE = 'L', LWORK >= max(1,N); */
00139 /*          if SIDE = 'R', LWORK >= max(1,M). */
00140 /*          For optimum performance LWORK >= N*NB if SIDE = 'L', and */
00141 /*          LWORK >= M*NB if SIDE = 'R', where NB is the optimal */
00142 /*          blocksize. */
00143 
00144 /*          If LWORK = -1, then a workspace query is assumed; the routine */
00145 /*          only calculates the optimal size of the WORK array, returns */
00146 /*          this value as the first entry of the WORK array, and no error */
00147 /*          message related to LWORK is issued by XERBLA. */
00148 
00149 /*  INFO    (output) INTEGER */
00150 /*          = 0:  successful exit */
00151 /*          < 0:  if INFO = -i, the i-th argument had an illegal value */
00152 
00153 /*  ===================================================================== */
00154 
00155 /*     .. Parameters .. */
00156 /*     .. */
00157 /*     .. Local Scalars .. */
00158 /*     .. */
00159 /*     .. Local Arrays .. */
00160 /*     .. */
00161 /*     .. External Functions .. */
00162 /*     .. */
00163 /*     .. External Subroutines .. */
00164 /*     .. */
00165 /*     .. Intrinsic Functions .. */
00166 /*     .. */
00167 /*     .. Executable Statements .. */
00168 
00169 /*     Test the input arguments */
00170 
00171     /* Parameter adjustments */
00172     a_dim1 = *lda;
00173     a_offset = 1 + a_dim1;
00174     a -= a_offset;
00175     --tau;
00176     c_dim1 = *ldc;
00177     c_offset = 1 + c_dim1;
00178     c__ -= c_offset;
00179     --work;
00180 
00181     /* Function Body */
00182     *info = 0;
00183     left = lsame_(side, "L");
00184     notran = lsame_(trans, "N");
00185     lquery = *lwork == -1;
00186 
00187 /*     NQ is the order of Q and NW is the minimum dimension of WORK */
00188 
00189     if (left) {
00190         nq = *m;
00191         nw = max(1,*n);
00192     } else {
00193         nq = *n;
00194         nw = max(1,*m);
00195     }
00196     if (! left && ! lsame_(side, "R")) {
00197         *info = -1;
00198     } else if (! notran && ! lsame_(trans, "C")) {
00199         *info = -2;
00200     } else if (*m < 0) {
00201         *info = -3;
00202     } else if (*n < 0) {
00203         *info = -4;
00204     } else if (*k < 0 || *k > nq) {
00205         *info = -5;
00206     } else if (*lda < max(1,nq)) {
00207         *info = -7;
00208     } else if (*ldc < max(1,*m)) {
00209         *info = -10;
00210     }
00211 
00212     if (*info == 0) {
00213         if (*m == 0 || *n == 0) {
00214             lwkopt = 1;
00215         } else {
00216 
00217 /*           Determine the block size.  NB may be at most NBMAX, where */
00218 /*           NBMAX is used to define the local array T. */
00219 
00220 /* Computing MIN */
00221 /* Writing concatenation */
00222             i__3[0] = 1, a__1[0] = side;
00223             i__3[1] = 1, a__1[1] = trans;
00224             s_cat(ch__1, a__1, i__3, &c__2, (ftnlen)2);
00225             i__1 = 64, i__2 = ilaenv_(&c__1, "ZUNMQL", ch__1, m, n, k, &c_n1);
00226             nb = min(i__1,i__2);
00227             lwkopt = nw * nb;
00228         }
00229         work[1].r = (doublereal) lwkopt, work[1].i = 0.;
00230 
00231         if (*lwork < nw && ! lquery) {
00232             *info = -12;
00233         }
00234     }
00235 
00236     if (*info != 0) {
00237         i__1 = -(*info);
00238         xerbla_("ZUNMQL", &i__1);
00239         return 0;
00240     } else if (lquery) {
00241         return 0;
00242     }
00243 
00244 /*     Quick return if possible */
00245 
00246     if (*m == 0 || *n == 0) {
00247         return 0;
00248     }
00249 
00250     nbmin = 2;
00251     ldwork = nw;
00252     if (nb > 1 && nb < *k) {
00253         iws = nw * nb;
00254         if (*lwork < iws) {
00255             nb = *lwork / ldwork;
00256 /* Computing MAX */
00257 /* Writing concatenation */
00258             i__3[0] = 1, a__1[0] = side;
00259             i__3[1] = 1, a__1[1] = trans;
00260             s_cat(ch__1, a__1, i__3, &c__2, (ftnlen)2);
00261             i__1 = 2, i__2 = ilaenv_(&c__2, "ZUNMQL", ch__1, m, n, k, &c_n1);
00262             nbmin = max(i__1,i__2);
00263         }
00264     } else {
00265         iws = nw;
00266     }
00267 
00268     if (nb < nbmin || nb >= *k) {
00269 
00270 /*        Use unblocked code */
00271 
00272         zunm2l_(side, trans, m, n, k, &a[a_offset], lda, &tau[1], &c__[
00273                 c_offset], ldc, &work[1], &iinfo);
00274     } else {
00275 
00276 /*        Use blocked code */
00277 
00278         if (left && notran || ! left && ! notran) {
00279             i1 = 1;
00280             i2 = *k;
00281             i3 = nb;
00282         } else {
00283             i1 = (*k - 1) / nb * nb + 1;
00284             i2 = 1;
00285             i3 = -nb;
00286         }
00287 
00288         if (left) {
00289             ni = *n;
00290         } else {
00291             mi = *m;
00292         }
00293 
00294         i__1 = i2;
00295         i__2 = i3;
00296         for (i__ = i1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) {
00297 /* Computing MIN */
00298             i__4 = nb, i__5 = *k - i__ + 1;
00299             ib = min(i__4,i__5);
00300 
00301 /*           Form the triangular factor of the block reflector */
00302 /*           H = H(i+ib-1) . . . H(i+1) H(i) */
00303 
00304             i__4 = nq - *k + i__ + ib - 1;
00305             zlarft_("Backward", "Columnwise", &i__4, &ib, &a[i__ * a_dim1 + 1]
00306 , lda, &tau[i__], t, &c__65);
00307             if (left) {
00308 
00309 /*              H or H' is applied to C(1:m-k+i+ib-1,1:n) */
00310 
00311                 mi = *m - *k + i__ + ib - 1;
00312             } else {
00313 
00314 /*              H or H' is applied to C(1:m,1:n-k+i+ib-1) */
00315 
00316                 ni = *n - *k + i__ + ib - 1;
00317             }
00318 
00319 /*           Apply H or H' */
00320 
00321             zlarfb_(side, trans, "Backward", "Columnwise", &mi, &ni, &ib, &a[
00322                     i__ * a_dim1 + 1], lda, t, &c__65, &c__[c_offset], ldc, &
00323                     work[1], &ldwork);
00324 /* L10: */
00325         }
00326     }
00327     work[1].r = (doublereal) lwkopt, work[1].i = 0.;
00328     return 0;
00329 
00330 /*     End of ZUNMQL */
00331 
00332 } /* zunmql_ */


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