clatm4.c
Go to the documentation of this file.
00001 /* clatm4.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 integer c__3 = 3;
00020 
00021 /* Subroutine */ int clatm4_(integer *itype, integer *n, integer *nz1, 
00022         integer *nz2, logical *rsign, real *amagn, real *rcond, real *triang, 
00023         integer *idist, integer *iseed, complex *a, integer *lda)
00024 {
00025     /* System generated locals */
00026     integer a_dim1, a_offset, i__1, i__2, i__3, i__4;
00027     real r__1;
00028     doublereal d__1, d__2;
00029     complex q__1, q__2;
00030 
00031     /* Builtin functions */
00032     double pow_dd(doublereal *, doublereal *), log(doublereal), exp(
00033             doublereal), c_abs(complex *);
00034 
00035     /* Local variables */
00036     integer i__, k, jc, jd, jr, kbeg, isdb, kend, isde, klen;
00037     real alpha;
00038     complex ctemp;
00039     extern /* Complex */ VOID clarnd_(complex *, integer *, integer *);
00040     extern /* Subroutine */ int claset_(char *, integer *, integer *, complex 
00041             *, complex *, complex *, integer *);
00042     extern doublereal slaran_(integer *);
00043 
00044 
00045 /*  -- LAPACK auxiliary test routine (version 3.1) -- */
00046 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00047 /*     November 2006 */
00048 
00049 /*     .. Scalar Arguments .. */
00050 /*     .. */
00051 /*     .. Array Arguments .. */
00052 /*     .. */
00053 
00054 /*  Purpose */
00055 /*  ======= */
00056 
00057 /*  CLATM4 generates basic square matrices, which may later be */
00058 /*  multiplied by others in order to produce test matrices.  It is */
00059 /*  intended mainly to be used to test the generalized eigenvalue */
00060 /*  routines. */
00061 
00062 /*  It first generates the diagonal and (possibly) subdiagonal, */
00063 /*  according to the value of ITYPE, NZ1, NZ2, RSIGN, AMAGN, and RCOND. */
00064 /*  It then fills in the upper triangle with random numbers, if TRIANG is */
00065 /*  non-zero. */
00066 
00067 /*  Arguments */
00068 /*  ========= */
00069 
00070 /*  ITYPE   (input) INTEGER */
00071 /*          The "type" of matrix on the diagonal and sub-diagonal. */
00072 /*          If ITYPE < 0, then type abs(ITYPE) is generated and then */
00073 /*             swapped end for end (A(I,J) := A'(N-J,N-I).)  See also */
00074 /*             the description of AMAGN and RSIGN. */
00075 
00076 /*          Special types: */
00077 /*          = 0:  the zero matrix. */
00078 /*          = 1:  the identity. */
00079 /*          = 2:  a transposed Jordan block. */
00080 /*          = 3:  If N is odd, then a k+1 x k+1 transposed Jordan block */
00081 /*                followed by a k x k identity block, where k=(N-1)/2. */
00082 /*                If N is even, then k=(N-2)/2, and a zero diagonal entry */
00083 /*                is tacked onto the end. */
00084 
00085 /*          Diagonal types.  The diagonal consists of NZ1 zeros, then */
00086 /*             k=N-NZ1-NZ2 nonzeros.  The subdiagonal is zero.  ITYPE */
00087 /*             specifies the nonzero diagonal entries as follows: */
00088 /*          = 4:  1, ..., k */
00089 /*          = 5:  1, RCOND, ..., RCOND */
00090 /*          = 6:  1, ..., 1, RCOND */
00091 /*          = 7:  1, a, a^2, ..., a^(k-1)=RCOND */
00092 /*          = 8:  1, 1-d, 1-2*d, ..., 1-(k-1)*d=RCOND */
00093 /*          = 9:  random numbers chosen from (RCOND,1) */
00094 /*          = 10: random numbers with distribution IDIST (see CLARND.) */
00095 
00096 /*  N       (input) INTEGER */
00097 /*          The order of the matrix. */
00098 
00099 /*  NZ1     (input) INTEGER */
00100 /*          If abs(ITYPE) > 3, then the first NZ1 diagonal entries will */
00101 /*          be zero. */
00102 
00103 /*  NZ2     (input) INTEGER */
00104 /*          If abs(ITYPE) > 3, then the last NZ2 diagonal entries will */
00105 /*          be zero. */
00106 
00107 /*  RSIGN   (input) LOGICAL */
00108 /*          = .TRUE.:  The diagonal and subdiagonal entries will be */
00109 /*                     multiplied by random numbers of magnitude 1. */
00110 /*          = .FALSE.: The diagonal and subdiagonal entries will be */
00111 /*                     left as they are (usually non-negative real.) */
00112 
00113 /*  AMAGN   (input) REAL */
00114 /*          The diagonal and subdiagonal entries will be multiplied by */
00115 /*          AMAGN. */
00116 
00117 /*  RCOND   (input) REAL */
00118 /*          If abs(ITYPE) > 4, then the smallest diagonal entry will be */
00119 /*          RCOND.  RCOND must be between 0 and 1. */
00120 
00121 /*  TRIANG  (input) REAL */
00122 /*          The entries above the diagonal will be random numbers with */
00123 /*          magnitude bounded by TRIANG (i.e., random numbers multiplied */
00124 /*          by TRIANG.) */
00125 
00126 /*  IDIST   (input) INTEGER */
00127 /*          On entry, DIST specifies the type of distribution to be used */
00128 /*          to generate a random matrix . */
00129 /*          = 1: real and imaginary parts each UNIFORM( 0, 1 ) */
00130 /*          = 2: real and imaginary parts each UNIFORM( -1, 1 ) */
00131 /*          = 3: real and imaginary parts each NORMAL( 0, 1 ) */
00132 /*          = 4: complex number uniform in DISK( 0, 1 ) */
00133 
00134 /*  ISEED   (input/output) INTEGER array, dimension (4) */
00135 /*          On entry ISEED specifies the seed of the random number */
00136 /*          generator.  The values of ISEED are changed on exit, and can */
00137 /*          be used in the next call to CLATM4 to continue the same */
00138 /*          random number sequence. */
00139 /*          Note: ISEED(4) should be odd, for the random number generator */
00140 /*          used at present. */
00141 
00142 /*  A       (output) COMPLEX array, dimension (LDA, N) */
00143 /*          Array to be computed. */
00144 
00145 /*  LDA     (input) INTEGER */
00146 /*          Leading dimension of A.  Must be at least 1 and at least N. */
00147 
00148 /*  ===================================================================== */
00149 
00150 /*     .. Parameters .. */
00151 /*     .. */
00152 /*     .. Local Scalars .. */
00153 /*     .. */
00154 /*     .. External Functions .. */
00155 /*     .. */
00156 /*     .. External Subroutines .. */
00157 /*     .. */
00158 /*     .. Intrinsic Functions .. */
00159 /*     .. */
00160 /*     .. Executable Statements .. */
00161 
00162     /* Parameter adjustments */
00163     --iseed;
00164     a_dim1 = *lda;
00165     a_offset = 1 + a_dim1;
00166     a -= a_offset;
00167 
00168     /* Function Body */
00169     if (*n <= 0) {
00170         return 0;
00171     }
00172     claset_("Full", n, n, &c_b1, &c_b1, &a[a_offset], lda);
00173 
00174 /*     Insure a correct ISEED */
00175 
00176     if (iseed[4] % 2 != 1) {
00177         ++iseed[4];
00178     }
00179 
00180 /*     Compute diagonal and subdiagonal according to ITYPE, NZ1, NZ2, */
00181 /*     and RCOND */
00182 
00183     if (*itype != 0) {
00184         if (abs(*itype) >= 4) {
00185 /* Computing MAX */
00186 /* Computing MIN */
00187             i__3 = *n, i__4 = *nz1 + 1;
00188             i__1 = 1, i__2 = min(i__3,i__4);
00189             kbeg = max(i__1,i__2);
00190 /* Computing MAX */
00191 /* Computing MIN */
00192             i__3 = *n, i__4 = *n - *nz2;
00193             i__1 = kbeg, i__2 = min(i__3,i__4);
00194             kend = max(i__1,i__2);
00195             klen = kend + 1 - kbeg;
00196         } else {
00197             kbeg = 1;
00198             kend = *n;
00199             klen = *n;
00200         }
00201         isdb = 1;
00202         isde = 0;
00203         switch (abs(*itype)) {
00204             case 1:  goto L10;
00205             case 2:  goto L30;
00206             case 3:  goto L50;
00207             case 4:  goto L80;
00208             case 5:  goto L100;
00209             case 6:  goto L120;
00210             case 7:  goto L140;
00211             case 8:  goto L160;
00212             case 9:  goto L180;
00213             case 10:  goto L200;
00214         }
00215 
00216 /*        abs(ITYPE) = 1: Identity */
00217 
00218 L10:
00219         i__1 = *n;
00220         for (jd = 1; jd <= i__1; ++jd) {
00221             i__2 = jd + jd * a_dim1;
00222             a[i__2].r = 1.f, a[i__2].i = 0.f;
00223 /* L20: */
00224         }
00225         goto L220;
00226 
00227 /*        abs(ITYPE) = 2: Transposed Jordan block */
00228 
00229 L30:
00230         i__1 = *n - 1;
00231         for (jd = 1; jd <= i__1; ++jd) {
00232             i__2 = jd + 1 + jd * a_dim1;
00233             a[i__2].r = 1.f, a[i__2].i = 0.f;
00234 /* L40: */
00235         }
00236         isdb = 1;
00237         isde = *n - 1;
00238         goto L220;
00239 
00240 /*        abs(ITYPE) = 3: Transposed Jordan block, followed by the */
00241 /*                        identity. */
00242 
00243 L50:
00244         k = (*n - 1) / 2;
00245         i__1 = k;
00246         for (jd = 1; jd <= i__1; ++jd) {
00247             i__2 = jd + 1 + jd * a_dim1;
00248             a[i__2].r = 1.f, a[i__2].i = 0.f;
00249 /* L60: */
00250         }
00251         isdb = 1;
00252         isde = k;
00253         i__1 = (k << 1) + 1;
00254         for (jd = k + 2; jd <= i__1; ++jd) {
00255             i__2 = jd + jd * a_dim1;
00256             a[i__2].r = 1.f, a[i__2].i = 0.f;
00257 /* L70: */
00258         }
00259         goto L220;
00260 
00261 /*        abs(ITYPE) = 4: 1,...,k */
00262 
00263 L80:
00264         i__1 = kend;
00265         for (jd = kbeg; jd <= i__1; ++jd) {
00266             i__2 = jd + jd * a_dim1;
00267             i__3 = jd - *nz1;
00268             q__1.r = (real) i__3, q__1.i = 0.f;
00269             a[i__2].r = q__1.r, a[i__2].i = q__1.i;
00270 /* L90: */
00271         }
00272         goto L220;
00273 
00274 /*        abs(ITYPE) = 5: One large D value: */
00275 
00276 L100:
00277         i__1 = kend;
00278         for (jd = kbeg + 1; jd <= i__1; ++jd) {
00279             i__2 = jd + jd * a_dim1;
00280             q__1.r = *rcond, q__1.i = 0.f;
00281             a[i__2].r = q__1.r, a[i__2].i = q__1.i;
00282 /* L110: */
00283         }
00284         i__1 = kbeg + kbeg * a_dim1;
00285         a[i__1].r = 1.f, a[i__1].i = 0.f;
00286         goto L220;
00287 
00288 /*        abs(ITYPE) = 6: One small D value: */
00289 
00290 L120:
00291         i__1 = kend - 1;
00292         for (jd = kbeg; jd <= i__1; ++jd) {
00293             i__2 = jd + jd * a_dim1;
00294             a[i__2].r = 1.f, a[i__2].i = 0.f;
00295 /* L130: */
00296         }
00297         i__1 = kend + kend * a_dim1;
00298         q__1.r = *rcond, q__1.i = 0.f;
00299         a[i__1].r = q__1.r, a[i__1].i = q__1.i;
00300         goto L220;
00301 
00302 /*        abs(ITYPE) = 7: Exponentially distributed D values: */
00303 
00304 L140:
00305         i__1 = kbeg + kbeg * a_dim1;
00306         a[i__1].r = 1.f, a[i__1].i = 0.f;
00307         if (klen > 1) {
00308             d__1 = (doublereal) (*rcond);
00309             d__2 = (doublereal) (1.f / (real) (klen - 1));
00310             alpha = pow_dd(&d__1, &d__2);
00311             i__1 = klen;
00312             for (i__ = 2; i__ <= i__1; ++i__) {
00313                 i__2 = *nz1 + i__ + (*nz1 + i__) * a_dim1;
00314                 d__1 = (doublereal) alpha;
00315                 d__2 = (doublereal) ((real) (i__ - 1));
00316                 r__1 = pow_dd(&d__1, &d__2);
00317                 q__1.r = r__1, q__1.i = 0.f;
00318                 a[i__2].r = q__1.r, a[i__2].i = q__1.i;
00319 /* L150: */
00320             }
00321         }
00322         goto L220;
00323 
00324 /*        abs(ITYPE) = 8: Arithmetically distributed D values: */
00325 
00326 L160:
00327         i__1 = kbeg + kbeg * a_dim1;
00328         a[i__1].r = 1.f, a[i__1].i = 0.f;
00329         if (klen > 1) {
00330             alpha = (1.f - *rcond) / (real) (klen - 1);
00331             i__1 = klen;
00332             for (i__ = 2; i__ <= i__1; ++i__) {
00333                 i__2 = *nz1 + i__ + (*nz1 + i__) * a_dim1;
00334                 r__1 = (real) (klen - i__) * alpha + *rcond;
00335                 q__1.r = r__1, q__1.i = 0.f;
00336                 a[i__2].r = q__1.r, a[i__2].i = q__1.i;
00337 /* L170: */
00338             }
00339         }
00340         goto L220;
00341 
00342 /*        abs(ITYPE) = 9: Randomly distributed D values on ( RCOND, 1): */
00343 
00344 L180:
00345         alpha = log(*rcond);
00346         i__1 = kend;
00347         for (jd = kbeg; jd <= i__1; ++jd) {
00348             i__2 = jd + jd * a_dim1;
00349             r__1 = exp(alpha * slaran_(&iseed[1]));
00350             a[i__2].r = r__1, a[i__2].i = 0.f;
00351 /* L190: */
00352         }
00353         goto L220;
00354 
00355 /*        abs(ITYPE) = 10: Randomly distributed D values from DIST */
00356 
00357 L200:
00358         i__1 = kend;
00359         for (jd = kbeg; jd <= i__1; ++jd) {
00360             i__2 = jd + jd * a_dim1;
00361             clarnd_(&q__1, idist, &iseed[1]);
00362             a[i__2].r = q__1.r, a[i__2].i = q__1.i;
00363 /* L210: */
00364         }
00365 
00366 L220:
00367 
00368 /*        Scale by AMAGN */
00369 
00370         i__1 = kend;
00371         for (jd = kbeg; jd <= i__1; ++jd) {
00372             i__2 = jd + jd * a_dim1;
00373             i__3 = jd + jd * a_dim1;
00374             r__1 = *amagn * a[i__3].r;
00375             a[i__2].r = r__1, a[i__2].i = 0.f;
00376 /* L230: */
00377         }
00378         i__1 = isde;
00379         for (jd = isdb; jd <= i__1; ++jd) {
00380             i__2 = jd + 1 + jd * a_dim1;
00381             i__3 = jd + 1 + jd * a_dim1;
00382             r__1 = *amagn * a[i__3].r;
00383             a[i__2].r = r__1, a[i__2].i = 0.f;
00384 /* L240: */
00385         }
00386 
00387 /*        If RSIGN = .TRUE., assign random signs to diagonal and */
00388 /*        subdiagonal */
00389 
00390         if (*rsign) {
00391             i__1 = kend;
00392             for (jd = kbeg; jd <= i__1; ++jd) {
00393                 i__2 = jd + jd * a_dim1;
00394                 if (a[i__2].r != 0.f) {
00395                     clarnd_(&q__1, &c__3, &iseed[1]);
00396                     ctemp.r = q__1.r, ctemp.i = q__1.i;
00397                     r__1 = c_abs(&ctemp);
00398                     q__1.r = ctemp.r / r__1, q__1.i = ctemp.i / r__1;
00399                     ctemp.r = q__1.r, ctemp.i = q__1.i;
00400                     i__2 = jd + jd * a_dim1;
00401                     i__3 = jd + jd * a_dim1;
00402                     r__1 = a[i__3].r;
00403                     q__1.r = r__1 * ctemp.r, q__1.i = r__1 * ctemp.i;
00404                     a[i__2].r = q__1.r, a[i__2].i = q__1.i;
00405                 }
00406 /* L250: */
00407             }
00408             i__1 = isde;
00409             for (jd = isdb; jd <= i__1; ++jd) {
00410                 i__2 = jd + 1 + jd * a_dim1;
00411                 if (a[i__2].r != 0.f) {
00412                     clarnd_(&q__1, &c__3, &iseed[1]);
00413                     ctemp.r = q__1.r, ctemp.i = q__1.i;
00414                     r__1 = c_abs(&ctemp);
00415                     q__1.r = ctemp.r / r__1, q__1.i = ctemp.i / r__1;
00416                     ctemp.r = q__1.r, ctemp.i = q__1.i;
00417                     i__2 = jd + 1 + jd * a_dim1;
00418                     i__3 = jd + 1 + jd * a_dim1;
00419                     r__1 = a[i__3].r;
00420                     q__1.r = r__1 * ctemp.r, q__1.i = r__1 * ctemp.i;
00421                     a[i__2].r = q__1.r, a[i__2].i = q__1.i;
00422                 }
00423 /* L260: */
00424             }
00425         }
00426 
00427 /*        Reverse if ITYPE < 0 */
00428 
00429         if (*itype < 0) {
00430             i__1 = (kbeg + kend - 1) / 2;
00431             for (jd = kbeg; jd <= i__1; ++jd) {
00432                 i__2 = jd + jd * a_dim1;
00433                 ctemp.r = a[i__2].r, ctemp.i = a[i__2].i;
00434                 i__2 = jd + jd * a_dim1;
00435                 i__3 = kbeg + kend - jd + (kbeg + kend - jd) * a_dim1;
00436                 a[i__2].r = a[i__3].r, a[i__2].i = a[i__3].i;
00437                 i__2 = kbeg + kend - jd + (kbeg + kend - jd) * a_dim1;
00438                 a[i__2].r = ctemp.r, a[i__2].i = ctemp.i;
00439 /* L270: */
00440             }
00441             i__1 = (*n - 1) / 2;
00442             for (jd = 1; jd <= i__1; ++jd) {
00443                 i__2 = jd + 1 + jd * a_dim1;
00444                 ctemp.r = a[i__2].r, ctemp.i = a[i__2].i;
00445                 i__2 = jd + 1 + jd * a_dim1;
00446                 i__3 = *n + 1 - jd + (*n - jd) * a_dim1;
00447                 a[i__2].r = a[i__3].r, a[i__2].i = a[i__3].i;
00448                 i__2 = *n + 1 - jd + (*n - jd) * a_dim1;
00449                 a[i__2].r = ctemp.r, a[i__2].i = ctemp.i;
00450 /* L280: */
00451             }
00452         }
00453 
00454     }
00455 
00456 /*     Fill in upper triangle */
00457 
00458     if (*triang != 0.f) {
00459         i__1 = *n;
00460         for (jc = 2; jc <= i__1; ++jc) {
00461             i__2 = jc - 1;
00462             for (jr = 1; jr <= i__2; ++jr) {
00463                 i__3 = jr + jc * a_dim1;
00464                 clarnd_(&q__2, idist, &iseed[1]);
00465                 q__1.r = *triang * q__2.r, q__1.i = *triang * q__2.i;
00466                 a[i__3].r = q__1.r, a[i__3].i = q__1.i;
00467 /* L290: */
00468             }
00469 /* L300: */
00470         }
00471     }
00472 
00473     return 0;
00474 
00475 /*     End of CLATM4 */
00476 
00477 } /* clatm4_ */


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