ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/random.h
Revision: 2.22
Committed: Thu Jul 16 05:08:57 2015 UTC (8 years, 9 months ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad5R0
Changes since 2.21: +4 -3 lines
Log Message:
Added required #include for drand48()

File Contents

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