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


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