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 2.9 by greg, Tue Feb 25 02:47:21 2003 UTC vs.
Revision 2.19 by greg, Mon Jan 26 20:04:30 2015 UTC

# Line 2 | Line 2
2   /*
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 < #include "copyright.h"
11 > #ifdef  _WIN32
12  
13 < #ifdef  NORANDOM
13 > #include <stdlib.h>
14  
15 < #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 <
15 > #if (RAND_MAX <= 65536)
16   #define random()        ((long)rand()<<16^(long)rand()<<6^(long)rand()>>4)
17 + #else
18 + #define random()        rand()
19 + #endif
20   #define srandom(s)      srand((unsigned)(s))
21  
22 < #define frandom()       (rand()*(1./32768.))
22 > #define frandom()       (rand()*(1./(RAND_MAX+.5)))
23  
24   #else
25   #ifdef  BSD
# Line 43 | Line 40 | extern double  drand48();
40   #endif
41   #endif
42  
46 #ifdef  MC
47
48 #define  urand(i)       frandom()
49 #define  initurand(n)   (n)
50
51 #else
52
43   extern unsigned short   *urperm;
44   extern int      urmask;
45  
46 < #define  urand(i)       ((urperm[(i)&urmask]+frandom())/(urmask+1))
46 > #define  urand(i)       (urmask ? (urperm[(i)&urmask]+frandom())/(urmask+1) \
47 >                                : frandom())
48  
49 < #endif
49 > extern int      initurand(int size);
50  
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
51                                  /* defined in urand.c */
71 extern int      initurand(int size);
52   extern int      ilhash(int *d, int n);
53                                  /* defined in urind.c */
54   extern int      urind(int s, int i);
55                                  /* defined in multisamp.c */
56   extern void     multisamp(double t[], int n, double r);
57  
58 +
59 + #ifdef __cplusplus
60 + }
61   #endif
62 + #endif /* _RAD_RANDOM_H_ */
63 +

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines