dorgql.c
Go to the documentation of this file.
00001 /* dorgql.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__3 = 3;
00021 static integer c__2 = 2;
00022 
00023 /* Subroutine */ int dorgql_(integer *m, integer *n, integer *k, doublereal *
00024         a, integer *lda, doublereal *tau, doublereal *work, integer *lwork, 
00025         integer *info)
00026 {
00027     /* System generated locals */
00028     integer a_dim1, a_offset, i__1, i__2, i__3, i__4;
00029 
00030     /* Local variables */
00031     integer i__, j, l, ib, nb, kk, nx, iws, nbmin, iinfo;
00032     extern /* Subroutine */ int dorg2l_(integer *, integer *, integer *, 
00033             doublereal *, integer *, doublereal *, doublereal *, integer *), 
00034             dlarfb_(char *, char *, char *, char *, integer *, integer *, 
00035             integer *, doublereal *, integer *, doublereal *, integer *, 
00036             doublereal *, integer *, doublereal *, integer *), dlarft_(char *, char *, integer *, integer *, 
00037             doublereal *, integer *, doublereal *, doublereal *, integer *), xerbla_(char *, integer *);
00038     extern integer ilaenv_(integer *, char *, char *, integer *, integer *, 
00039             integer *, integer *);
00040     integer ldwork, lwkopt;
00041     logical lquery;
00042 
00043 
00044 /*  -- LAPACK routine (version 3.2) -- */
00045 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00046 /*     November 2006 */
00047 
00048 /*     .. Scalar Arguments .. */
00049 /*     .. */
00050 /*     .. Array Arguments .. */
00051 /*     .. */
00052 
00053 /*  Purpose */
00054 /*  ======= */
00055 
00056 /*  DORGQL generates an M-by-N real matrix Q with orthonormal columns, */
00057 /*  which is defined as the last N columns of a product of K elementary */
00058 /*  reflectors of order M */
00059 
00060 /*        Q  =  H(k) . . . H(2) H(1) */
00061 
00062 /*  as returned by DGEQLF. */
00063 
00064 /*  Arguments */
00065 /*  ========= */
00066 
00067 /*  M       (input) INTEGER */
00068 /*          The number of rows of the matrix Q. M >= 0. */
00069 
00070 /*  N       (input) INTEGER */
00071 /*          The number of columns of the matrix Q. M >= N >= 0. */
00072 
00073 /*  K       (input) INTEGER */
00074 /*          The number of elementary reflectors whose product defines the */
00075 /*          matrix Q. N >= K >= 0. */
00076 
00077 /*  A       (input/output) DOUBLE PRECISION array, dimension (LDA,N) */
00078 /*          On entry, the (n-k+i)-th column must contain the vector which */
00079 /*          defines the elementary reflector H(i), for i = 1,2,...,k, as */
00080 /*          returned by DGEQLF in the last k columns of its array */
00081 /*          argument A. */
00082 /*          On exit, the M-by-N matrix Q. */
00083 
00084 /*  LDA     (input) INTEGER */
00085 /*          The first dimension of the array A. LDA >= max(1,M). */
00086 
00087 /*  TAU     (input) DOUBLE PRECISION array, dimension (K) */
00088 /*          TAU(i) must contain the scalar factor of the elementary */
00089 /*          reflector H(i), as returned by DGEQLF. */
00090 
00091 /*  WORK    (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK)) */
00092 /*          On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */
00093 
00094 /*  LWORK   (input) INTEGER */
00095 /*          The dimension of the array WORK. LWORK >= max(1,N). */
00096 /*          For optimum performance LWORK >= N*NB, where NB is the */
00097 /*          optimal blocksize. */
00098 
00099 /*          If LWORK = -1, then a workspace query is assumed; the routine */
00100 /*          only calculates the optimal size of the WORK array, returns */
00101 /*          this value as the first entry of the WORK array, and no error */
00102 /*          message related to LWORK is issued by XERBLA. */
00103 
00104 /*  INFO    (output) INTEGER */
00105 /*          = 0:  successful exit */
00106 /*          < 0:  if INFO = -i, the i-th argument has an illegal value */
00107 
00108 /*  ===================================================================== */
00109 
00110 /*     .. Parameters .. */
00111 /*     .. */
00112 /*     .. Local Scalars .. */
00113 /*     .. */
00114 /*     .. External Subroutines .. */
00115 /*     .. */
00116 /*     .. Intrinsic Functions .. */
00117 /*     .. */
00118 /*     .. External Functions .. */
00119 /*     .. */
00120 /*     .. Executable Statements .. */
00121 
00122 /*     Test the input arguments */
00123 
00124     /* Parameter adjustments */
00125     a_dim1 = *lda;
00126     a_offset = 1 + a_dim1;
00127     a -= a_offset;
00128     --tau;
00129     --work;
00130 
00131     /* Function Body */
00132     *info = 0;
00133     lquery = *lwork == -1;
00134     if (*m < 0) {
00135         *info = -1;
00136     } else if (*n < 0 || *n > *m) {
00137         *info = -2;
00138     } else if (*k < 0 || *k > *n) {
00139         *info = -3;
00140     } else if (*lda < max(1,*m)) {
00141         *info = -5;
00142     }
00143 
00144     if (*info == 0) {
00145         if (*n == 0) {
00146             lwkopt = 1;
00147         } else {
00148             nb = ilaenv_(&c__1, "DORGQL", " ", m, n, k, &c_n1);
00149             lwkopt = *n * nb;
00150         }
00151         work[1] = (doublereal) lwkopt;
00152 
00153         if (*lwork < max(1,*n) && ! lquery) {
00154             *info = -8;
00155         }
00156     }
00157 
00158     if (*info != 0) {
00159         i__1 = -(*info);
00160         xerbla_("DORGQL", &i__1);
00161         return 0;
00162     } else if (lquery) {
00163         return 0;
00164     }
00165 
00166 /*     Quick return if possible */
00167 
00168     if (*n <= 0) {
00169         return 0;
00170     }
00171 
00172     nbmin = 2;
00173     nx = 0;
00174     iws = *n;
00175     if (nb > 1 && nb < *k) {
00176 
00177 /*        Determine when to cross over from blocked to unblocked code. */
00178 
00179 /* Computing MAX */
00180         i__1 = 0, i__2 = ilaenv_(&c__3, "DORGQL", " ", m, n, k, &c_n1);
00181         nx = max(i__1,i__2);
00182         if (nx < *k) {
00183 
00184 /*           Determine if workspace is large enough for blocked code. */
00185 
00186             ldwork = *n;
00187             iws = ldwork * nb;
00188             if (*lwork < iws) {
00189 
00190 /*              Not enough workspace to use optimal NB:  reduce NB and */
00191 /*              determine the minimum value of NB. */
00192 
00193                 nb = *lwork / ldwork;
00194 /* Computing MAX */
00195                 i__1 = 2, i__2 = ilaenv_(&c__2, "DORGQL", " ", m, n, k, &c_n1);
00196                 nbmin = max(i__1,i__2);
00197             }
00198         }
00199     }
00200 
00201     if (nb >= nbmin && nb < *k && nx < *k) {
00202 
00203 /*        Use blocked code after the first block. */
00204 /*        The last kk columns are handled by the block method. */
00205 
00206 /* Computing MIN */
00207         i__1 = *k, i__2 = (*k - nx + nb - 1) / nb * nb;
00208         kk = min(i__1,i__2);
00209 
00210 /*        Set A(m-kk+1:m,1:n-kk) to zero. */
00211 
00212         i__1 = *n - kk;
00213         for (j = 1; j <= i__1; ++j) {
00214             i__2 = *m;
00215             for (i__ = *m - kk + 1; i__ <= i__2; ++i__) {
00216                 a[i__ + j * a_dim1] = 0.;
00217 /* L10: */
00218             }
00219 /* L20: */
00220         }
00221     } else {
00222         kk = 0;
00223     }
00224 
00225 /*     Use unblocked code for the first or only block. */
00226 
00227     i__1 = *m - kk;
00228     i__2 = *n - kk;
00229     i__3 = *k - kk;
00230     dorg2l_(&i__1, &i__2, &i__3, &a[a_offset], lda, &tau[1], &work[1], &iinfo)
00231             ;
00232 
00233     if (kk > 0) {
00234 
00235 /*        Use blocked code */
00236 
00237         i__1 = *k;
00238         i__2 = nb;
00239         for (i__ = *k - kk + 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += 
00240                 i__2) {
00241 /* Computing MIN */
00242             i__3 = nb, i__4 = *k - i__ + 1;
00243             ib = min(i__3,i__4);
00244             if (*n - *k + i__ > 1) {
00245 
00246 /*              Form the triangular factor of the block reflector */
00247 /*              H = H(i+ib-1) . . . H(i+1) H(i) */
00248 
00249                 i__3 = *m - *k + i__ + ib - 1;
00250                 dlarft_("Backward", "Columnwise", &i__3, &ib, &a[(*n - *k + 
00251                         i__) * a_dim1 + 1], lda, &tau[i__], &work[1], &ldwork);
00252 
00253 /*              Apply H to A(1:m-k+i+ib-1,1:n-k+i-1) from the left */
00254 
00255                 i__3 = *m - *k + i__ + ib - 1;
00256                 i__4 = *n - *k + i__ - 1;
00257                 dlarfb_("Left", "No transpose", "Backward", "Columnwise", &
00258                         i__3, &i__4, &ib, &a[(*n - *k + i__) * a_dim1 + 1], 
00259                         lda, &work[1], &ldwork, &a[a_offset], lda, &work[ib + 
00260                         1], &ldwork);
00261             }
00262 
00263 /*           Apply H to rows 1:m-k+i+ib-1 of current block */
00264 
00265             i__3 = *m - *k + i__ + ib - 1;
00266             dorg2l_(&i__3, &ib, &ib, &a[(*n - *k + i__) * a_dim1 + 1], lda, &
00267                     tau[i__], &work[1], &iinfo);
00268 
00269 /*           Set rows m-k+i+ib:m of current block to zero */
00270 
00271             i__3 = *n - *k + i__ + ib - 1;
00272             for (j = *n - *k + i__; j <= i__3; ++j) {
00273                 i__4 = *m;
00274                 for (l = *m - *k + i__ + ib; l <= i__4; ++l) {
00275                     a[l + j * a_dim1] = 0.;
00276 /* L30: */
00277                 }
00278 /* L40: */
00279             }
00280 /* L50: */
00281         }
00282     }
00283 
00284     work[1] = (doublereal) iws;
00285     return 0;
00286 
00287 /*     End of DORGQL */
00288 
00289 } /* dorgql_ */


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