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


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