dlatm1.c
Go to the documentation of this file.
00001 /* dlatm1.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 dlatm1_(integer *mode, doublereal *cond, integer *irsign, 
00017          integer *idist, integer *iseed, doublereal *d__, integer *n, integer 
00018         *info)
00019 {
00020     /* System generated locals */
00021     integer i__1, i__2;
00022     doublereal d__1;
00023 
00024     /* Builtin functions */
00025     double pow_dd(doublereal *, doublereal *), pow_di(doublereal *, integer *)
00026             , log(doublereal), exp(doublereal);
00027 
00028     /* Local variables */
00029     integer i__;
00030     doublereal temp, alpha;
00031     extern doublereal dlaran_(integer *);
00032     extern /* Subroutine */ int xerbla_(char *, integer *), dlarnv_(
00033             integer *, integer *, integer *, doublereal *);
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 /*     DLATM1 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. DLATM1 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   - DOUBLE PRECISION */
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 DLATM1 */
00099 /*           to continue the same random number sequence. */
00100 /*           Changed on exit. */
00101 
00102 /*  D      - DOUBLE PRECISION 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.) {
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_("DLATM1", &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. / *cond;
00186 /* L20: */
00187         }
00188         d__[1] = 1.;
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.;
00197 /* L40: */
00198         }
00199         d__[*n] = 1. / *cond;
00200         goto L120;
00201 
00202 /*        Exponentially distributed D values: */
00203 
00204 L50:
00205         d__[1] = 1.;
00206         if (*n > 1) {
00207             d__1 = -1. / (doublereal) (*n - 1);
00208             alpha = pow_dd(cond, &d__1);
00209             i__1 = *n;
00210             for (i__ = 2; i__ <= i__1; ++i__) {
00211                 i__2 = i__ - 1;
00212                 d__[i__] = pow_di(&alpha, &i__2);
00213 /* L60: */
00214             }
00215         }
00216         goto L120;
00217 
00218 /*        Arithmetically distributed D values: */
00219 
00220 L70:
00221         d__[1] = 1.;
00222         if (*n > 1) {
00223             temp = 1. / *cond;
00224             alpha = (1. - temp) / (doublereal) (*n - 1);
00225             i__1 = *n;
00226             for (i__ = 2; i__ <= i__1; ++i__) {
00227                 d__[i__] = (doublereal) (*n - i__) * alpha + temp;
00228 /* L80: */
00229             }
00230         }
00231         goto L120;
00232 
00233 /*        Randomly distributed D values on ( 1/COND , 1): */
00234 
00235 L90:
00236         alpha = log(1. / *cond);
00237         i__1 = *n;
00238         for (i__ = 1; i__ <= i__1; ++i__) {
00239             d__[i__] = exp(alpha * dlaran_(&iseed[1]));
00240 /* L100: */
00241         }
00242         goto L120;
00243 
00244 /*        Randomly distributed D values from IDIST */
00245 
00246 L110:
00247         dlarnv_(idist, &iseed[1], n, &d__[1]);
00248 
00249 L120:
00250 
00251 /*        If MODE neither -6 nor 0 nor 6, and IRSIGN = 1, assign */
00252 /*        random signs to D */
00253 
00254         if (*mode != -6 && *mode != 0 && *mode != 6 && *irsign == 1) {
00255             i__1 = *n;
00256             for (i__ = 1; i__ <= i__1; ++i__) {
00257                 temp = dlaran_(&iseed[1]);
00258                 if (temp > .5) {
00259                     d__[i__] = -d__[i__];
00260                 }
00261 /* L130: */
00262             }
00263         }
00264 
00265 /*        Reverse if MODE < 0 */
00266 
00267         if (*mode < 0) {
00268             i__1 = *n / 2;
00269             for (i__ = 1; i__ <= i__1; ++i__) {
00270                 temp = d__[i__];
00271                 d__[i__] = d__[*n + 1 - i__];
00272                 d__[*n + 1 - i__] = temp;
00273 /* L140: */
00274             }
00275         }
00276 
00277     }
00278 
00279     return 0;
00280 
00281 /*     End of DLATM1 */
00282 
00283 } /* dlatm1_ */


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