| 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  _WIN32 | 
| 12 | + |  | 
| 13 | + | #if (RAND_MAX <= 65536) | 
| 14 | + | #define random()        ((long)rand()<<16^(long)rand()<<6^(long)rand()>>4) | 
| 15 | + | #else | 
| 16 | + | #define random()        rand() | 
| 17 | + | #endif | 
| 18 | + | #define srandom(s)      srand((unsigned)(s)) | 
| 19 | + |  | 
| 20 | + | #define frandom()       (rand()*(1./(RAND_MAX+.5))) | 
| 21 | + |  | 
| 22 | + | #else | 
| 23 | + | #ifdef  BSD | 
| 24 | + |  | 
| 25 |  | extern long  random(); | 
| 26 |  |  | 
| 27 | < | #define  frandom()      (random()*(1./2147483648.)) | 
| 27 | > | #define  frandom()      (random()*(1./2147483648.)) | 
| 28 | > |  | 
| 29 | > | #else | 
| 30 | > |  | 
| 31 | > | extern long  lrand48(); | 
| 32 | > | extern double  drand48(); | 
| 33 | > |  | 
| 34 | > | #define  random()       lrand48() | 
| 35 | > | #define  srandom(s)     srand48((long)(s)) | 
| 36 | > | #define  frandom()      drand48() | 
| 37 | > |  | 
| 38 | > | #endif | 
| 39 | > | #endif | 
| 40 | > |  | 
| 41 | > | extern unsigned short   *urperm; | 
| 42 | > | extern int      urmask; | 
| 43 | > |  | 
| 44 | > | #define  urand(i)       (urmask ? (urperm[(i)&urmask]+frandom())/(urmask+1) \ | 
| 45 | > | : frandom()) | 
| 46 | > |  | 
| 47 | > | extern int      initurand(int size); | 
| 48 | > |  | 
| 49 | > | /* defined in urand.c */ | 
| 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 | > |  |