ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/random.h
Revision: 2.7
Committed: Sat Jan 9 09:15:48 1999 UTC (25 years, 3 months ago) by gwlarson
Content type: text/plain
Branch: MAIN
Changes since 2.6: +3 -1 lines
Log Message:
added define for random seed function

File Contents

# Content
1 /* Copyright (c) 1999 Silicon Graphics, Inc. */
2
3 /* SCCSid "$SunId$ SGI" */
4
5 /*
6 * random.h - header file for random(3) and urand() function.
7 *
8 * 10/1/85
9 */
10
11 #ifdef MSDOS
12
13 #define random() ((long)rand()<<16^(long)rand()<<6^(long)rand()>>4)
14 #define srandom(s) srand((unsigned)(s))
15
16 #define frandom() (rand()*(1./32768.))
17
18 #else
19 #ifdef BSD
20
21 extern long random();
22
23 #define frandom() (random()*(1./2147483648.))
24
25 #else
26
27 extern long lrand48();
28 extern double drand48();
29
30 #define random() lrand48()
31 #define srandom(s) srand48((long)(s))
32 #define frandom() drand48()
33
34 #endif
35 #endif
36
37 #ifdef MC
38
39 #define urand(i) frandom()
40 #define initurand(n) (n)
41
42 #else
43
44 extern unsigned short *urperm;
45 extern int urmask, initurand();
46
47 #define urand(i) ((urperm[(i)&urmask]+frandom())/(urmask+1))
48
49 #endif