|
|
1.1 root 1: /*
2: char id_rand[] = "@(#)rand_.c 1.1";
3: *
4: * Routines to return random values
5: *
6: * calling sequence:
7: * double precision d, drand
8: * i = irand(iflag)
9: * x = rand(iflag)
10: * d = drand(iflag)
11: * where:
12: * If arg is 1, generator is restarted. If arg is 0, next value
13: * is returned. Any other arg is a new seed for the generator.
14: * Integer values will range from 0 thru 2147483647.
15: * Real values will range from 0.0 thru 1.0
16: * (see rand(3))
17: */
18:
19: #define RANDMAX 2147483647
20:
21: long irand_(iarg)
22: long *iarg;
23: {
24: if (*iarg) srand((int)*iarg);
25: return( rand() );
26: }
27:
28: float rand_(iarg)
29: long *iarg;
30: {
31: if (*iarg) srand((int)*iarg);
32: return( (float)(rand())/(float)RANDMAX );
33: }
34:
35: double drand_(iarg)
36: long *iarg;
37: {
38: if (*iarg) srand((int)*iarg);
39: return( (double)(rand())/(double)RANDMAX );
40: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.