slatm1.c
Go to the documentation of this file.
00001 /* slatm1.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 /* Subroutine */ int slatm1_(integer *mode, real *cond, integer *irsign, 
00017         integer *idist, integer *iseed, real *d__, integer *n, integer *info)
00018 {
00019     /* System generated locals */
00020     integer i__1, i__2;
00021     doublereal d__1, d__2;
00022 
00023     /* Builtin functions */
00024     double pow_dd(doublereal *, doublereal *), pow_ri(real *, integer *), log(
00025             doublereal), exp(doublereal);
00026 
00027     /* Local variables */
00028     integer i__;
00029     real temp, alpha;
00030     extern /* Subroutine */ int xerbla_(char *, integer *);
00031     extern doublereal slaran_(integer *);
00032     extern /* Subroutine */ int slarnv_(integer *, integer *, integer *, real 
00033             *);
00034 
00035 
00036 /*  -- LAPACK auxiliary test routine (version 3.1) -- */
00037 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00038 /*     November 2006 */
00039 
00040 /*     .. Scalar Arguments .. */
00041 /*     .. */
00042 /*     .. Array Arguments .. */
00043 /*     .. */
00044 
00045 /*  Purpose */
00046 /*  ======= */
00047 
00048 /*     SLATM1 computes the entries of D(1..N) as specified by */
00049 /*     MODE, COND and IRSIGN. IDIST and ISEED determine the generation */
00050 /*     of random numbers. SLATM1 is called by SLATMR to generate */
00051 /*     random test matrices for LAPACK programs. */
00052 
00053 /*  Arguments */
00054 /*  ========= */
00055 
00056 /*  MODE   - INTEGER */
00057 /*           On entry describes how D is to be computed: */
00058 /*           MODE = 0 means do not change D. */
00059 /*           MODE = 1 sets D(1)=1 and D(2:N)=1.0/COND */
00060 /*           MODE = 2 sets D(1:N-1)=1 and D(N)=1.0/COND */
00061 /*           MODE = 3 sets D(I)=COND**(-(I-1)/(N-1)) */
00062 /*           MODE = 4 sets D(i)=1 - (i-1)/(N-1)*(1 - 1/COND) */
00063 /*           MODE = 5 sets D to random numbers in the range */
00064 /*                    ( 1/COND , 1 ) such that their logarithms */
00065 /*                    are uniformly distributed. */
00066 /*           MODE = 6 set D to random numbers from same distribution */
00067 /*                    as the rest of the matrix. */
00068 /*           MODE < 0 has the same meaning as ABS(MODE), except that */
00069 /*              the order of the elements of D is reversed. */
00070 /*           Thus if MODE is positive, D has entries ranging from */
00071 /*              1 to 1/COND, if negative, from 1/COND to 1, */
00072 /*           Not modified. */
00073 
00074 /*  COND   - REAL */
00075 /*           On entry, used as described under MODE above. */
00076 /*           If used, it must be >= 1. Not modified. */
00077 
00078 /*  IRSIGN - INTEGER */
00079 /*           On entry, if MODE neither -6, 0 nor 6, determines sign of */
00080 /*           entries of D */
00081 /*           0 => leave entries of D unchanged */
00082 /*           1 => multiply each entry of D by 1 or -1 with probability .5 */
00083 
00084 /*  IDIST  - CHARACTER*1 */
00085 /*           On entry, IDIST specifies the type of distribution to be */
00086 /*           used to generate a random matrix . */
00087 /*           1 => UNIFORM( 0, 1 ) */
00088 /*           2 => UNIFORM( -1, 1 ) */
00089 /*           3 => NORMAL( 0, 1 ) */
00090 /*           Not modified. */
00091 
00092 /*  ISEED  - INTEGER array, dimension ( 4 ) */
00093 /*           On entry ISEED specifies the seed of the random number */
00094 /*           generator. The random number generator uses a */
00095 /*           linear congruential sequence limited to small */
00096 /*           integers, and so should produce machine independent */
00097 /*           random numbers. The values of ISEED are changed on */
00098 /*           exit, and can be used in the next call to SLATM1 */
00099 /*           to continue the same random number sequence. */
00100 /*           Changed on exit. */
00101 
00102 /*  D      - REAL array, dimension ( MIN( M , N ) ) */
00103 /*           Array to be computed according to MODE, COND and IRSIGN. */
00104 /*           May be changed on exit if MODE is nonzero. */
00105 
00106 /*  N      - INTEGER */
00107 /*           Number of entries of D. Not modified. */
00108 
00109 /*  INFO   - INTEGER */
00110 /*            0  => normal termination */
00111 /*           -1  => if MODE not in range -6 to 6 */
00112 /*           -2  => if MODE neither -6, 0 nor 6, and */
00113 /*                  IRSIGN neither 0 nor 1 */
00114 /*           -3  => if MODE neither -6, 0 nor 6 and COND less than 1 */
00115 /*           -4  => if MODE equals 6 or -6 and IDIST not in range 1 to 3 */
00116 /*           -7  => if N negative */
00117 
00118 /*  ===================================================================== */
00119 
00120 /*     .. Parameters .. */
00121 /*     .. */
00122 /*     .. Local Scalars .. */
00123 /*     .. */
00124 /*     .. External Functions .. */
00125 /*     .. */
00126 /*     .. External Subroutines .. */
00127 /*     .. */
00128 /*     .. Intrinsic Functions .. */
00129 /*     .. */
00130 /*     .. Executable Statements .. */
00131 
00132 /*     Decode and Test the input parameters. Initialize flags & seed. */
00133 
00134     /* Parameter adjustments */
00135     --d__;
00136     --iseed;
00137 
00138     /* Function Body */
00139     *info = 0;
00140 
00141 /*     Quick return if possible */
00142 
00143     if (*n == 0) {
00144         return 0;
00145     }
00146 
00147 /*     Set INFO if an error */
00148 
00149     if (*mode < -6 || *mode > 6) {
00150         *info = -1;
00151     } else if (*mode != -6 && *mode != 0 && *mode != 6 && (*irsign != 0 && *
00152             irsign != 1)) {
00153         *info = -2;
00154     } else if (*mode != -6 && *mode != 0 && *mode != 6 && *cond < 1.f) {
00155         *info = -3;
00156     } else if ((*mode == 6 || *mode == -6) && (*idist < 1 || *idist > 3)) {
00157         *info = -4;
00158     } else if (*n < 0) {
00159         *info = -7;
00160     }
00161 
00162     if (*info != 0) {
00163         i__1 = -(*info);
00164         xerbla_("SLATM1", &i__1);
00165         return 0;
00166     }
00167 
00168 /*     Compute D according to COND and MODE */
00169 
00170     if (*mode != 0) {
00171         switch (abs(*mode)) {
00172             case 1:  goto L10;
00173             case 2:  goto L30;
00174             case 3:  goto L50;
00175             case 4:  goto L70;
00176             case 5:  goto L90;
00177             case 6:  goto L110;
00178         }
00179 
00180 /*        One large D value: */
00181 
00182 L10:
00183         i__1 = *n;
00184         for (i__ = 1; i__ <= i__1; ++i__) {
00185             d__[i__] = 1.f / *cond;
00186 /* L20: */
00187         }
00188         d__[1] = 1.f;
00189         goto L120;
00190 
00191 /*        One small D value: */
00192 
00193 L30:
00194         i__1 = *n;
00195         for (i__ = 1; i__ <= i__1; ++i__) {
00196             d__[i__] = 1.f;
00197 /* L40: */
00198         }
00199         d__[*n] = 1.f / *cond;
00200         goto L120;
00201 
00202 /*        Exponentially distributed D values: */
00203 
00204 L50:
00205         d__[1] = 1.f;
00206         if (*n > 1) {
00207             d__1 = (doublereal) (*cond);
00208             d__2 = (doublereal) (-1.f / (real) (*n - 1));
00209             alpha = pow_dd(&d__1, &d__2);
00210             i__1 = *n;
00211             for (i__ = 2; i__ <= i__1; ++i__) {
00212                 i__2 = i__ - 1;
00213                 d__[i__] = pow_ri(&alpha, &i__2);
00214 /* L60: */
00215             }
00216         }
00217         goto L120;
00218 
00219 /*        Arithmetically distributed D values: */
00220 
00221 L70:
00222         d__[1] = 1.f;
00223         if (*n > 1) {
00224             temp = 1.f / *cond;
00225             alpha = (1.f - temp) / (real) (*n - 1);
00226             i__1 = *n;
00227             for (i__ = 2; i__ <= i__1; ++i__) {
00228                 d__[i__] = (real) (*n - i__) * alpha + temp;
00229 /* L80: */
00230             }
00231         }
00232         goto L120;
00233 
00234 /*        Randomly distributed D values on ( 1/COND , 1): */
00235 
00236 L90:
00237         alpha = log(1.f / *cond);
00238         i__1 = *n;
00239         for (i__ = 1; i__ <= i__1; ++i__) {
00240             d__[i__] = exp(alpha * slaran_(&iseed[1]));
00241 /* L100: */
00242         }
00243         goto L120;
00244 
00245 /*        Randomly distributed D values from IDIST */
00246 
00247 L110:
00248         slarnv_(idist, &iseed[1], n, &d__[1]);
00249 
00250 L120:
00251 
00252 /*        If MODE neither -6 nor 0 nor 6, and IRSIGN = 1, assign */
00253 /*        random signs to D */
00254 
00255         if (*mode != -6 && *mode != 0 && *mode != 6 && *irsign == 1) {
00256             i__1 = *n;
00257             for (i__ = 1; i__ <= i__1; ++i__) {
00258                 temp = slaran_(&iseed[1]);
00259                 if (temp > .5f) {
00260                     d__[i__] = -d__[i__];
00261                 }
00262 /* L130: */
00263             }
00264         }
00265 
00266 /*        Reverse if MODE < 0 */
00267 
00268         if (*mode < 0) {
00269             i__1 = *n / 2;
00270             for (i__ = 1; i__ <= i__1; ++i__) {
00271                 temp = d__[i__];
00272                 d__[i__] = d__[*n + 1 - i__];
00273                 d__[*n + 1 - i__] = temp;
00274 /* L140: */
00275             }
00276         }
00277 
00278     }
00279 
00280     return 0;
00281 
00282 /*     End of SLATM1 */
00283 
00284 } /* slatm1_ */


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