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.3 by greg, Tue Dec 4 11:23:58 1990 UTC vs.
Revision 2.19 by greg, Mon Jan 26 20:04:30 2015 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 < #ifdef  BSD
11 > #ifdef  _WIN32
12  
13 + #include <stdlib.h>
14 +
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./(RAND_MAX+.5)))
23 +
24 + #else
25 + #ifdef  BSD
26 +
27   extern long  random();
28  
29 < #define  frandom()      (random()*(1./2147483648.))
29 > #define  frandom()      (random()*(1./2147483648.))
30  
31   #else
32  
33   extern long  lrand48();
34   extern double  drand48();
35  
36 < #define  random()       lrand48()
37 < #define  frandom()      drand48()
36 > #define  random()       lrand48()
37 > #define  srandom(s)     srand48((long)(s))
38 > #define  frandom()      drand48()
39  
40   #endif
41 + #endif
42 +
43 + extern unsigned short   *urperm;
44 + extern int      urmask;
45 +
46 + #define  urand(i)       (urmask ? (urperm[(i)&urmask]+frandom())/(urmask+1) \
47 +                                : frandom())
48 +
49 + extern int      initurand(int size);
50 +
51 +                                /* defined in urand.c */
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