ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/random.h
Revision: 2.14
Committed: Sun Jun 29 16:51:48 2003 UTC (20 years, 9 months ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad3R6, rad3R6P1
Changes since 2.13: +7 -6 lines
Log Message:
Fixed compile error with -DMC

File Contents

# Content
1 /* RCSid $Id: random.h,v 2.13 2003/06/27 06:53:21 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 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 /* ! NORANDOM */
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 /* ! MC */
59
60 extern unsigned short *urperm;
61 extern int urmask;
62
63 #define urand(i) ((urperm[(i)&urmask]+frandom())/(urmask+1))
64
65 extern int initurand(int size);
66
67 #endif /* ! MC */
68
69 #endif /* ! NORANDOM */
70
71 /* defined in urand.c */
72 extern int ilhash(int *d, int n);
73 /* defined in urind.c */
74 extern int urind(int s, int i);
75 /* defined in multisamp.c */
76 extern void multisamp(double t[], int n, double r);
77
78
79 #ifdef __cplusplus
80 }
81 #endif
82 #endif /* _RAD_RANDOM_H_ */
83