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


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