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: #if vax
20: #define RANDMAX 2147483647
21: #else vax
22: #if pdp11
23: #define RANDMAX 32767
24: #else pdp11
25: UNKNOWN MACHINE!
26: #endif pdp11
27: #endif vax
28:
29: long irand_(iarg)
30: long *iarg;
31: {
32: if (*iarg) srand((int)*iarg);
33: #if pdp11
34: return(( ((long)rand()) << 16) | rand());
35: #else pdp11
36: return( rand() );
37: #endif pdp11
38: }
39:
40: float rand_(iarg)
41: long *iarg;
42: {
43: if (*iarg) srand((int)*iarg);
44: return( (float)(rand())/(float)RANDMAX );
45: }
46:
47: double drand_(iarg)
48: long *iarg;
49: {
50: if (*iarg) srand((int)*iarg);
51: return( (double)(rand())/(double)RANDMAX );
52: }
Defined functions
rand_
defined in line
40;
never used
Defined macros