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


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