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


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