ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/random.h
Revision: 2.10
Committed: Thu Mar 27 16:33:38 2003 UTC (21 years, 1 month ago) by greg
Content type: text/plain
Branch: MAIN
Changes since 2.9: +5 -1 lines
Log Message:
Fixed bug introduced in last update and potential bug in random.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 #if (RAND_MAX <= 65536)
23 #define random() ((long)rand()<<16^(long)rand()<<6^(long)rand()>>4)
24 #else
25 #define random() rand()
26 #endif
27 #define srandom(s) srand((unsigned)(s))
28
29 #define frandom() (rand()*(1./RAND_MAX))
30
31 #else
32 #ifdef BSD
33
34 extern long random();
35
36 #define frandom() (random()*(1./2147483648.))
37
38 #else
39
40 extern long lrand48();
41 extern double drand48();
42
43 #define random() lrand48()
44 #define srandom(s) srand48((long)(s))
45 #define frandom() drand48()
46
47 #endif
48 #endif
49
50 #ifdef MC
51
52 #define urand(i) frandom()
53 #define initurand(n) (n)
54
55 #else
56
57 extern unsigned short *urperm;
58 extern int urmask;
59
60 #define urand(i) ((urperm[(i)&urmask]+frandom())/(urmask+1))
61
62 #endif
63
64 #endif
65
66 #ifdef NOPROTO
67
68 extern int initurand();
69 extern int ilhash();
70 extern int urind();
71 extern void multisamp();
72
73 #else
74 /* defined in urand.c */
75 extern int initurand(int size);
76 extern int ilhash(int *d, int n);
77 /* defined in urind.c */
78 extern int urind(int s, int i);
79 /* defined in multisamp.c */
80 extern void multisamp(double t[], int n, double r);
81
82 #endif