ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/random.h
Revision: 2.13
Committed: Fri Jun 27 06:53:21 2003 UTC (20 years, 10 months ago) by greg
Content type: text/plain
Branch: MAIN
Changes since 2.12: +1 -4 lines
Log Message:
Broke standard.h into rtio.h, rterror.h, rtmath.h, and rtmisc.h

File Contents

# Content
1 /* RCSid $Id: random.h,v 2.12 2003/06/06 16:38:47 schorsch Exp $ */
2 /*
3 * random.h - header file for random(3) and urand() function.
4 */
5 #ifndef _RAD_RANDOM_H_
6 #define _RAD_RANDOM_H_
7 #ifdef __cplusplus
8 extern "C" {
9 #endif
10
11 #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 #ifdef _WIN32
24
25 #if (RAND_MAX <= 65536)
26 #define random() ((long)rand()<<16^(long)rand()<<6^(long)rand()>>4)
27 #else
28 #define random() rand()
29 #endif
30 #define srandom(s) srand((unsigned)(s))
31
32 #define frandom() (rand()*(1./RAND_MAX))
33
34 #else
35 #ifdef BSD
36
37 extern long random();
38
39 #define frandom() (random()*(1./2147483648.))
40
41 #else
42
43 extern long lrand48();
44 extern double drand48();
45
46 #define random() lrand48()
47 #define srandom(s) srand48((long)(s))
48 #define frandom() drand48()
49
50 #endif
51 #endif
52
53 #ifdef MC
54
55 #define urand(i) frandom()
56 #define initurand(n) (n)
57
58 #else
59
60 extern unsigned short *urperm;
61 extern int urmask;
62
63 #define urand(i) ((urperm[(i)&urmask]+frandom())/(urmask+1))
64
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
77
78 #ifdef __cplusplus
79 }
80 #endif
81 #endif /* _RAD_RANDOM_H_ */
82