ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/random.h
Revision: 2.15
Committed: Mon Jun 13 20:07:56 2005 UTC (18 years, 10 months ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad3R7P2, rad3R7P1
Changes since 2.14: +1 -24 lines
Log Message:
Added -R option for pure Monte Carlo rendering, replacing -DMC compile option

File Contents

# Content
1 /* RCSid $Id: random.h,v 2.14 2003/06/29 16:51:48 greg 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 _WIN32
12
13 #if (RAND_MAX <= 65536)
14 #define random() ((long)rand()<<16^(long)rand()<<6^(long)rand()>>4)
15 #else
16 #define random() rand()
17 #endif
18 #define srandom(s) srand((unsigned)(s))
19
20 #define frandom() (rand()*(1./RAND_MAX))
21
22 #else
23 #ifdef BSD
24
25 extern long random();
26
27 #define frandom() (random()*(1./2147483648.))
28
29 #else
30
31 extern long lrand48();
32 extern double drand48();
33
34 #define random() lrand48()
35 #define srandom(s) srand48((long)(s))
36 #define frandom() drand48()
37
38 #endif
39 #endif
40
41 extern unsigned short *urperm;
42 extern int urmask;
43
44 #define urand(i) ((urperm[(i)&urmask]+frandom())/(urmask+1))
45
46 extern int initurand(int size);
47
48 /* defined in urand.c */
49 extern int ilhash(int *d, int n);
50 /* defined in urind.c */
51 extern int urind(int s, int i);
52 /* defined in multisamp.c */
53 extern void multisamp(double t[], int n, double r);
54
55
56 #ifdef __cplusplus
57 }
58 #endif
59 #endif /* _RAD_RANDOM_H_ */
60