slagge.c
Go to the documentation of this file.
00001 /* slagge.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__3 = 3;
00019 static integer c__1 = 1;
00020 static real c_b11 = 1.f;
00021 static real c_b13 = 0.f;
00022 
00023 /* Subroutine */ int slagge_(integer *m, integer *n, integer *kl, integer *ku, 
00024          real *d__, real *a, integer *lda, integer *iseed, real *work, 
00025         integer *info)
00026 {
00027     /* System generated locals */
00028     integer a_dim1, a_offset, i__1, i__2, i__3;
00029     real r__1;
00030 
00031     /* Builtin functions */
00032     double r_sign(real *, real *);
00033 
00034     /* Local variables */
00035     integer i__, j;
00036     real wa, wb, wn, tau;
00037     extern /* Subroutine */ int sger_(integer *, integer *, real *, real *, 
00038             integer *, real *, integer *, real *, integer *);
00039     extern doublereal snrm2_(integer *, real *, integer *);
00040     extern /* Subroutine */ int sscal_(integer *, real *, real *, integer *), 
00041             sgemv_(char *, integer *, integer *, real *, real *, integer *, 
00042             real *, integer *, real *, real *, integer *), xerbla_(
00043             char *, integer *), slarnv_(integer *, integer *, integer 
00044             *, real *);
00045 
00046 
00047 /*  -- LAPACK auxiliary test routine (version 3.1) */
00048 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00049 /*     November 2006 */
00050 
00051 /*     .. Scalar Arguments .. */
00052 /*     .. */
00053 /*     .. Array Arguments .. */
00054 /*     .. */
00055 
00056 /*  Purpose */
00057 /*  ======= */
00058 
00059 /*  SLAGGE generates a real general m by n matrix A, by pre- and post- */
00060 /*  multiplying a real diagonal matrix D with random orthogonal matrices: */
00061 /*  A = U*D*V. The lower and upper bandwidths may then be reduced to */
00062 /*  kl and ku by additional orthogonal transformations. */
00063 
00064 /*  Arguments */
00065 /*  ========= */
00066 
00067 /*  M       (input) INTEGER */
00068 /*          The number of rows of the matrix A.  M >= 0. */
00069 
00070 /*  N       (input) INTEGER */
00071 /*          The number of columns of the matrix A.  N >= 0. */
00072 
00073 /*  KL      (input) INTEGER */
00074 /*          The number of nonzero subdiagonals within the band of A. */
00075 /*          0 <= KL <= M-1. */
00076 
00077 /*  KU      (input) INTEGER */
00078 /*          The number of nonzero superdiagonals within the band of A. */
00079 /*          0 <= KU <= N-1. */
00080 
00081 /*  D       (input) REAL array, dimension (min(M,N)) */
00082 /*          The diagonal elements of the diagonal matrix D. */
00083 
00084 /*  A       (output) REAL array, dimension (LDA,N) */
00085 /*          The generated m by n matrix A. */
00086 
00087 /*  LDA     (input) INTEGER */
00088 /*          The leading dimension of the array A.  LDA >= M. */
00089 
00090 /*  ISEED   (input/output) INTEGER array, dimension (4) */
00091 /*          On entry, the seed of the random number generator; the array */
00092 /*          elements must be between 0 and 4095, and ISEED(4) must be */
00093 /*          odd. */
00094 /*          On exit, the seed is updated. */
00095 
00096 /*  WORK    (workspace) REAL array, dimension (M+N) */
00097 
00098 /*  INFO    (output) INTEGER */
00099 /*          = 0: successful exit */
00100 /*          < 0: if INFO = -i, the i-th argument had an illegal value */
00101 
00102 /*  ===================================================================== */
00103 
00104 /*     .. Parameters .. */
00105 /*     .. */
00106 /*     .. Local Scalars .. */
00107 /*     .. */
00108 /*     .. External Subroutines .. */
00109 /*     .. */
00110 /*     .. Intrinsic Functions .. */
00111 /*     .. */
00112 /*     .. External Functions .. */
00113 /*     .. */
00114 /*     .. Executable Statements .. */
00115 
00116 /*     Test the input arguments */
00117 
00118     /* Parameter adjustments */
00119     --d__;
00120     a_dim1 = *lda;
00121     a_offset = 1 + a_dim1;
00122     a -= a_offset;
00123     --iseed;
00124     --work;
00125 
00126     /* Function Body */
00127     *info = 0;
00128     if (*m < 0) {
00129         *info = -1;
00130     } else if (*n < 0) {
00131         *info = -2;
00132     } else if (*kl < 0 || *kl > *m - 1) {
00133         *info = -3;
00134     } else if (*ku < 0 || *ku > *n - 1) {
00135         *info = -4;
00136     } else if (*lda < max(1,*m)) {
00137         *info = -7;
00138     }
00139     if (*info < 0) {
00140         i__1 = -(*info);
00141         xerbla_("SLAGGE", &i__1);
00142         return 0;
00143     }
00144 
00145 /*     initialize A to diagonal matrix */
00146 
00147     i__1 = *n;
00148     for (j = 1; j <= i__1; ++j) {
00149         i__2 = *m;
00150         for (i__ = 1; i__ <= i__2; ++i__) {
00151             a[i__ + j * a_dim1] = 0.f;
00152 /* L10: */
00153         }
00154 /* L20: */
00155     }
00156     i__1 = min(*m,*n);
00157     for (i__ = 1; i__ <= i__1; ++i__) {
00158         a[i__ + i__ * a_dim1] = d__[i__];
00159 /* L30: */
00160     }
00161 
00162 /*     pre- and post-multiply A by random orthogonal matrices */
00163 
00164     for (i__ = min(*m,*n); i__ >= 1; --i__) {
00165         if (i__ < *m) {
00166 
00167 /*           generate random reflection */
00168 
00169             i__1 = *m - i__ + 1;
00170             slarnv_(&c__3, &iseed[1], &i__1, &work[1]);
00171             i__1 = *m - i__ + 1;
00172             wn = snrm2_(&i__1, &work[1], &c__1);
00173             wa = r_sign(&wn, &work[1]);
00174             if (wn == 0.f) {
00175                 tau = 0.f;
00176             } else {
00177                 wb = work[1] + wa;
00178                 i__1 = *m - i__;
00179                 r__1 = 1.f / wb;
00180                 sscal_(&i__1, &r__1, &work[2], &c__1);
00181                 work[1] = 1.f;
00182                 tau = wb / wa;
00183             }
00184 
00185 /*           multiply A(i:m,i:n) by random reflection from the left */
00186 
00187             i__1 = *m - i__ + 1;
00188             i__2 = *n - i__ + 1;
00189             sgemv_("Transpose", &i__1, &i__2, &c_b11, &a[i__ + i__ * a_dim1], 
00190                     lda, &work[1], &c__1, &c_b13, &work[*m + 1], &c__1);
00191             i__1 = *m - i__ + 1;
00192             i__2 = *n - i__ + 1;
00193             r__1 = -tau;
00194             sger_(&i__1, &i__2, &r__1, &work[1], &c__1, &work[*m + 1], &c__1, 
00195                     &a[i__ + i__ * a_dim1], lda);
00196         }
00197         if (i__ < *n) {
00198 
00199 /*           generate random reflection */
00200 
00201             i__1 = *n - i__ + 1;
00202             slarnv_(&c__3, &iseed[1], &i__1, &work[1]);
00203             i__1 = *n - i__ + 1;
00204             wn = snrm2_(&i__1, &work[1], &c__1);
00205             wa = r_sign(&wn, &work[1]);
00206             if (wn == 0.f) {
00207                 tau = 0.f;
00208             } else {
00209                 wb = work[1] + wa;
00210                 i__1 = *n - i__;
00211                 r__1 = 1.f / wb;
00212                 sscal_(&i__1, &r__1, &work[2], &c__1);
00213                 work[1] = 1.f;
00214                 tau = wb / wa;
00215             }
00216 
00217 /*           multiply A(i:m,i:n) by random reflection from the right */
00218 
00219             i__1 = *m - i__ + 1;
00220             i__2 = *n - i__ + 1;
00221             sgemv_("No transpose", &i__1, &i__2, &c_b11, &a[i__ + i__ * 
00222                     a_dim1], lda, &work[1], &c__1, &c_b13, &work[*n + 1], &
00223                     c__1);
00224             i__1 = *m - i__ + 1;
00225             i__2 = *n - i__ + 1;
00226             r__1 = -tau;
00227             sger_(&i__1, &i__2, &r__1, &work[*n + 1], &c__1, &work[1], &c__1, 
00228                     &a[i__ + i__ * a_dim1], lda);
00229         }
00230 /* L40: */
00231     }
00232 
00233 /*     Reduce number of subdiagonals to KL and number of superdiagonals */
00234 /*     to KU */
00235 
00236 /* Computing MAX */
00237     i__2 = *m - 1 - *kl, i__3 = *n - 1 - *ku;
00238     i__1 = max(i__2,i__3);
00239     for (i__ = 1; i__ <= i__1; ++i__) {
00240         if (*kl <= *ku) {
00241 
00242 /*           annihilate subdiagonal elements first (necessary if KL = 0) */
00243 
00244 /* Computing MIN */
00245             i__2 = *m - 1 - *kl;
00246             if (i__ <= min(i__2,*n)) {
00247 
00248 /*              generate reflection to annihilate A(kl+i+1:m,i) */
00249 
00250                 i__2 = *m - *kl - i__ + 1;
00251                 wn = snrm2_(&i__2, &a[*kl + i__ + i__ * a_dim1], &c__1);
00252                 wa = r_sign(&wn, &a[*kl + i__ + i__ * a_dim1]);
00253                 if (wn == 0.f) {
00254                     tau = 0.f;
00255                 } else {
00256                     wb = a[*kl + i__ + i__ * a_dim1] + wa;
00257                     i__2 = *m - *kl - i__;
00258                     r__1 = 1.f / wb;
00259                     sscal_(&i__2, &r__1, &a[*kl + i__ + 1 + i__ * a_dim1], &
00260                             c__1);
00261                     a[*kl + i__ + i__ * a_dim1] = 1.f;
00262                     tau = wb / wa;
00263                 }
00264 
00265 /*              apply reflection to A(kl+i:m,i+1:n) from the left */
00266 
00267                 i__2 = *m - *kl - i__ + 1;
00268                 i__3 = *n - i__;
00269                 sgemv_("Transpose", &i__2, &i__3, &c_b11, &a[*kl + i__ + (i__ 
00270                         + 1) * a_dim1], lda, &a[*kl + i__ + i__ * a_dim1], &
00271                         c__1, &c_b13, &work[1], &c__1);
00272                 i__2 = *m - *kl - i__ + 1;
00273                 i__3 = *n - i__;
00274                 r__1 = -tau;
00275                 sger_(&i__2, &i__3, &r__1, &a[*kl + i__ + i__ * a_dim1], &
00276                         c__1, &work[1], &c__1, &a[*kl + i__ + (i__ + 1) * 
00277                         a_dim1], lda);
00278                 a[*kl + i__ + i__ * a_dim1] = -wa;
00279             }
00280 
00281 /* Computing MIN */
00282             i__2 = *n - 1 - *ku;
00283             if (i__ <= min(i__2,*m)) {
00284 
00285 /*              generate reflection to annihilate A(i,ku+i+1:n) */
00286 
00287                 i__2 = *n - *ku - i__ + 1;
00288                 wn = snrm2_(&i__2, &a[i__ + (*ku + i__) * a_dim1], lda);
00289                 wa = r_sign(&wn, &a[i__ + (*ku + i__) * a_dim1]);
00290                 if (wn == 0.f) {
00291                     tau = 0.f;
00292                 } else {
00293                     wb = a[i__ + (*ku + i__) * a_dim1] + wa;
00294                     i__2 = *n - *ku - i__;
00295                     r__1 = 1.f / wb;
00296                     sscal_(&i__2, &r__1, &a[i__ + (*ku + i__ + 1) * a_dim1], 
00297                             lda);
00298                     a[i__ + (*ku + i__) * a_dim1] = 1.f;
00299                     tau = wb / wa;
00300                 }
00301 
00302 /*              apply reflection to A(i+1:m,ku+i:n) from the right */
00303 
00304                 i__2 = *m - i__;
00305                 i__3 = *n - *ku - i__ + 1;
00306                 sgemv_("No transpose", &i__2, &i__3, &c_b11, &a[i__ + 1 + (*
00307                         ku + i__) * a_dim1], lda, &a[i__ + (*ku + i__) * 
00308                         a_dim1], lda, &c_b13, &work[1], &c__1);
00309                 i__2 = *m - i__;
00310                 i__3 = *n - *ku - i__ + 1;
00311                 r__1 = -tau;
00312                 sger_(&i__2, &i__3, &r__1, &work[1], &c__1, &a[i__ + (*ku + 
00313                         i__) * a_dim1], lda, &a[i__ + 1 + (*ku + i__) * 
00314                         a_dim1], lda);
00315                 a[i__ + (*ku + i__) * a_dim1] = -wa;
00316             }
00317         } else {
00318 
00319 /*           annihilate superdiagonal elements first (necessary if */
00320 /*           KU = 0) */
00321 
00322 /* Computing MIN */
00323             i__2 = *n - 1 - *ku;
00324             if (i__ <= min(i__2,*m)) {
00325 
00326 /*              generate reflection to annihilate A(i,ku+i+1:n) */
00327 
00328                 i__2 = *n - *ku - i__ + 1;
00329                 wn = snrm2_(&i__2, &a[i__ + (*ku + i__) * a_dim1], lda);
00330                 wa = r_sign(&wn, &a[i__ + (*ku + i__) * a_dim1]);
00331                 if (wn == 0.f) {
00332                     tau = 0.f;
00333                 } else {
00334                     wb = a[i__ + (*ku + i__) * a_dim1] + wa;
00335                     i__2 = *n - *ku - i__;
00336                     r__1 = 1.f / wb;
00337                     sscal_(&i__2, &r__1, &a[i__ + (*ku + i__ + 1) * a_dim1], 
00338                             lda);
00339                     a[i__ + (*ku + i__) * a_dim1] = 1.f;
00340                     tau = wb / wa;
00341                 }
00342 
00343 /*              apply reflection to A(i+1:m,ku+i:n) from the right */
00344 
00345                 i__2 = *m - i__;
00346                 i__3 = *n - *ku - i__ + 1;
00347                 sgemv_("No transpose", &i__2, &i__3, &c_b11, &a[i__ + 1 + (*
00348                         ku + i__) * a_dim1], lda, &a[i__ + (*ku + i__) * 
00349                         a_dim1], lda, &c_b13, &work[1], &c__1);
00350                 i__2 = *m - i__;
00351                 i__3 = *n - *ku - i__ + 1;
00352                 r__1 = -tau;
00353                 sger_(&i__2, &i__3, &r__1, &work[1], &c__1, &a[i__ + (*ku + 
00354                         i__) * a_dim1], lda, &a[i__ + 1 + (*ku + i__) * 
00355                         a_dim1], lda);
00356                 a[i__ + (*ku + i__) * a_dim1] = -wa;
00357             }
00358 
00359 /* Computing MIN */
00360             i__2 = *m - 1 - *kl;
00361             if (i__ <= min(i__2,*n)) {
00362 
00363 /*              generate reflection to annihilate A(kl+i+1:m,i) */
00364 
00365                 i__2 = *m - *kl - i__ + 1;
00366                 wn = snrm2_(&i__2, &a[*kl + i__ + i__ * a_dim1], &c__1);
00367                 wa = r_sign(&wn, &a[*kl + i__ + i__ * a_dim1]);
00368                 if (wn == 0.f) {
00369                     tau = 0.f;
00370                 } else {
00371                     wb = a[*kl + i__ + i__ * a_dim1] + wa;
00372                     i__2 = *m - *kl - i__;
00373                     r__1 = 1.f / wb;
00374                     sscal_(&i__2, &r__1, &a[*kl + i__ + 1 + i__ * a_dim1], &
00375                             c__1);
00376                     a[*kl + i__ + i__ * a_dim1] = 1.f;
00377                     tau = wb / wa;
00378                 }
00379 
00380 /*              apply reflection to A(kl+i:m,i+1:n) from the left */
00381 
00382                 i__2 = *m - *kl - i__ + 1;
00383                 i__3 = *n - i__;
00384                 sgemv_("Transpose", &i__2, &i__3, &c_b11, &a[*kl + i__ + (i__ 
00385                         + 1) * a_dim1], lda, &a[*kl + i__ + i__ * a_dim1], &
00386                         c__1, &c_b13, &work[1], &c__1);
00387                 i__2 = *m - *kl - i__ + 1;
00388                 i__3 = *n - i__;
00389                 r__1 = -tau;
00390                 sger_(&i__2, &i__3, &r__1, &a[*kl + i__ + i__ * a_dim1], &
00391                         c__1, &work[1], &c__1, &a[*kl + i__ + (i__ + 1) * 
00392                         a_dim1], lda);
00393                 a[*kl + i__ + i__ * a_dim1] = -wa;
00394             }
00395         }
00396 
00397         i__2 = *m;
00398         for (j = *kl + i__ + 1; j <= i__2; ++j) {
00399             a[j + i__ * a_dim1] = 0.f;
00400 /* L50: */
00401         }
00402 
00403         i__2 = *n;
00404         for (j = *ku + i__ + 1; j <= i__2; ++j) {
00405             a[i__ + j * a_dim1] = 0.f;
00406 /* L60: */
00407         }
00408 /* L70: */
00409     }
00410     return 0;
00411 
00412 /*     End of SLAGGE */
00413 
00414 } /* slagge_ */


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