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


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