1 |
greg |
2.13 |
/* RCSid $Id: random.h,v 2.12 2003/06/06 16:38:47 schorsch Exp $ */ |
2 |
greg |
1.1 |
/* |
3 |
greg |
1.4 |
* random.h - header file for random(3) and urand() function. |
4 |
greg |
2.8 |
*/ |
5 |
schorsch |
2.12 |
#ifndef _RAD_RANDOM_H_ |
6 |
|
|
#define _RAD_RANDOM_H_ |
7 |
|
|
#ifdef __cplusplus |
8 |
|
|
extern "C" { |
9 |
|
|
#endif |
10 |
greg |
1.1 |
|
11 |
greg |
2.8 |
#ifdef NORANDOM |
12 |
|
|
|
13 |
|
|
#undef random |
14 |
|
|
#define random() 1073741820 |
15 |
|
|
#undef srandom |
16 |
|
|
#define srandom(s) (s) |
17 |
|
|
#define frandom() 0.5 |
18 |
|
|
#define urand(i) 0.5 |
19 |
|
|
#define initurand(n) (n) |
20 |
|
|
|
21 |
|
|
#else |
22 |
|
|
|
23 |
schorsch |
2.11 |
#ifdef _WIN32 |
24 |
greg |
1.3 |
|
25 |
greg |
2.10 |
#if (RAND_MAX <= 65536) |
26 |
greg |
2.3 |
#define random() ((long)rand()<<16^(long)rand()<<6^(long)rand()>>4) |
27 |
greg |
2.10 |
#else |
28 |
|
|
#define random() rand() |
29 |
|
|
#endif |
30 |
gwlarson |
2.7 |
#define srandom(s) srand((unsigned)(s)) |
31 |
greg |
2.2 |
|
32 |
greg |
2.10 |
#define frandom() (rand()*(1./RAND_MAX)) |
33 |
greg |
2.2 |
|
34 |
|
|
#else |
35 |
|
|
#ifdef BSD |
36 |
|
|
|
37 |
greg |
1.1 |
extern long random(); |
38 |
|
|
|
39 |
greg |
2.2 |
#define frandom() (random()*(1./2147483648.)) |
40 |
greg |
1.3 |
|
41 |
|
|
#else |
42 |
|
|
|
43 |
|
|
extern long lrand48(); |
44 |
|
|
extern double drand48(); |
45 |
|
|
|
46 |
greg |
2.2 |
#define random() lrand48() |
47 |
gwlarson |
2.7 |
#define srandom(s) srand48((long)(s)) |
48 |
greg |
2.2 |
#define frandom() drand48() |
49 |
greg |
1.3 |
|
50 |
|
|
#endif |
51 |
greg |
2.2 |
#endif |
52 |
greg |
1.4 |
|
53 |
greg |
2.4 |
#ifdef MC |
54 |
gregl |
2.5 |
|
55 |
greg |
2.4 |
#define urand(i) frandom() |
56 |
gregl |
2.5 |
#define initurand(n) (n) |
57 |
|
|
|
58 |
greg |
2.4 |
#else |
59 |
gregl |
2.5 |
|
60 |
gregl |
2.6 |
extern unsigned short *urperm; |
61 |
greg |
2.8 |
extern int urmask; |
62 |
gregl |
2.5 |
|
63 |
greg |
2.2 |
#define urand(i) ((urperm[(i)&urmask]+frandom())/(urmask+1)) |
64 |
greg |
2.8 |
|
65 |
|
|
#endif |
66 |
|
|
|
67 |
|
|
#endif |
68 |
|
|
|
69 |
|
|
/* defined in urand.c */ |
70 |
|
|
extern int initurand(int size); |
71 |
|
|
extern int ilhash(int *d, int n); |
72 |
|
|
/* defined in urind.c */ |
73 |
|
|
extern int urind(int s, int i); |
74 |
|
|
/* defined in multisamp.c */ |
75 |
|
|
extern void multisamp(double t[], int n, double r); |
76 |
gregl |
2.5 |
|
77 |
schorsch |
2.12 |
|
78 |
|
|
#ifdef __cplusplus |
79 |
|
|
} |
80 |
greg |
2.4 |
#endif |
81 |
schorsch |
2.12 |
#endif /* _RAD_RANDOM_H_ */ |
82 |
|
|
|