| 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 |
|
|
| 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 |
– |
|
| 11 |
|
#ifdef _WIN32 |
| 12 |
|
|
| 13 |
|
#if (RAND_MAX <= 65536) |
| 38 |
|
#endif |
| 39 |
|
#endif |
| 40 |
|
|
| 50 |
– |
#ifdef MC |
| 51 |
– |
|
| 52 |
– |
#define urand(i) frandom() |
| 53 |
– |
#define initurand(n) (n) |
| 54 |
– |
|
| 55 |
– |
#else |
| 56 |
– |
|
| 41 |
|
extern unsigned short *urperm; |
| 42 |
|
extern int urmask; |
| 43 |
|
|
| 44 |
< |
#define urand(i) ((urperm[(i)&urmask]+frandom())/(urmask+1)) |
| 44 |
> |
#define urand(i) (urmask ? (urperm[(i)&urmask]+frandom())/(urmask+1) \ |
| 45 |
> |
: frandom()) |
| 46 |
|
|
| 47 |
< |
#endif |
| 47 |
> |
extern int initurand(int size); |
| 48 |
|
|
| 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 |
| 49 |
|
/* defined in urand.c */ |
| 75 |
– |
extern int initurand(int size); |
| 50 |
|
extern int ilhash(int *d, int n); |
| 51 |
|
/* defined in urind.c */ |
| 52 |
|
extern int urind(int s, int i); |
| 53 |
|
/* defined in multisamp.c */ |
| 54 |
|
extern void multisamp(double t[], int n, double r); |
| 55 |
|
|
| 56 |
+ |
|
| 57 |
+ |
#ifdef __cplusplus |
| 58 |
+ |
} |
| 59 |
|
#endif |
| 60 |
+ |
#endif /* _RAD_RANDOM_H_ */ |
| 61 |
+ |
|