ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/random.h
(Generate patch)

Comparing ray/src/common/random.h (file contents):
Revision 1.2 by greg, Tue Sep 26 08:28:53 1989 UTC vs.
Revision 2.12 by schorsch, Fri Jun 6 16:38:47 2003 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1986 Regents of the University of California */
2 <
3 < /* SCCSid "$SunId$ LBL" */
4 <
1 > /* RCSid $Id$ */
2   /*
3 < *  random.h - header file for random(3) function.
7 < *
8 < *     10/1/85
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 +
12 + #include "copyright.h"
13 +
14 + #ifdef  NORANDOM
15 +
16 + #undef  random
17 + #define  random()       1073741820
18 + #undef  srandom
19 + #define  srandom(s)     (s)
20 + #define  frandom()      0.5
21 + #define  urand(i)       0.5
22 + #define  initurand(n)   (n)
23 +
24 + #else
25 +
26 + #ifdef  _WIN32
27 +
28 + #if (RAND_MAX <= 65536)
29 + #define random()        ((long)rand()<<16^(long)rand()<<6^(long)rand()>>4)
30 + #else
31 + #define random()        rand()
32 + #endif
33 + #define srandom(s)      srand((unsigned)(s))
34 +
35 + #define frandom()       (rand()*(1./RAND_MAX))
36 +
37 + #else
38 + #ifdef  BSD
39 +
40   extern long  random();
41  
42 < #define  frandom()      (random()*(1./2147483648.))
42 > #define  frandom()      (random()*(1./2147483648.))
43 >
44 > #else
45 >
46 > extern long  lrand48();
47 > extern double  drand48();
48 >
49 > #define  random()       lrand48()
50 > #define  srandom(s)     srand48((long)(s))
51 > #define  frandom()      drand48()
52 >
53 > #endif
54 > #endif
55 >
56 > #ifdef  MC
57 >
58 > #define  urand(i)       frandom()
59 > #define  initurand(n)   (n)
60 >
61 > #else
62 >
63 > extern unsigned short   *urperm;
64 > extern int      urmask;
65 >
66 > #define  urand(i)       ((urperm[(i)&urmask]+frandom())/(urmask+1))
67 >
68 > #endif
69 >
70 > #endif
71 >
72 >                                /* defined in urand.c */
73 > extern int      initurand(int size);
74 > extern int      ilhash(int *d, int n);
75 >                                /* defined in urind.c */
76 > extern int      urind(int s, int i);
77 >                                /* defined in multisamp.c */
78 > extern void     multisamp(double t[], int n, double r);
79 >
80 >
81 > #ifdef __cplusplus
82 > }
83 > #endif
84 > #endif /* _RAD_RANDOM_H_ */
85 >

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines