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


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