ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/random.h
Revision: 2.9
Committed: Tue Feb 25 02:47:21 2003 UTC (21 years, 2 months ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad3R5
Changes since 2.8: +2 -57 lines
Log Message:
Replaced inline copyright notice with #include "copyright.h"

File Contents

# Content
1 /* RCSid $Id$ */
2 /*
3 * random.h - header file for random(3) and urand() function.
4 */
5
6 #include "copyright.h"
7
8 #ifdef NORANDOM
9
10 #undef random
11 #define random() 1073741820
12 #undef srandom
13 #define srandom(s) (s)
14 #define frandom() 0.5
15 #define urand(i) 0.5
16 #define initurand(n) (n)
17
18 #else
19
20 #ifdef MSDOS
21
22 #define random() ((long)rand()<<16^(long)rand()<<6^(long)rand()>>4)
23 #define srandom(s) srand((unsigned)(s))
24
25 #define frandom() (rand()*(1./32768.))
26
27 #else
28 #ifdef BSD
29
30 extern long random();
31
32 #define frandom() (random()*(1./2147483648.))
33
34 #else
35
36 extern long lrand48();
37 extern double drand48();
38
39 #define random() lrand48()
40 #define srandom(s) srand48((long)(s))
41 #define frandom() drand48()
42
43 #endif
44 #endif
45
46 #ifdef MC
47
48 #define urand(i) frandom()
49 #define initurand(n) (n)
50
51 #else
52
53 extern unsigned short *urperm;
54 extern int urmask;
55
56 #define urand(i) ((urperm[(i)&urmask]+frandom())/(urmask+1))
57
58 #endif
59
60 #endif
61
62 #ifdef NOPROTO
63
64 extern int initurand();
65 extern int ilhash();
66 extern int urind();
67 extern void multisamp();
68
69 #else
70 /* defined in urand.c */
71 extern int initurand(int size);
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 #endif