27 static inline void seed(
unsigned long n) { srand(n); }
28 static inline long int maxValue() {
return RAND_MAX; }
29 static inline long int randInt() {
return rand(); }
30 static inline float randFloat() {
return float(rand())/float(RAND_MAX); }
31 static inline double randDouble() {
return double(rand())/double(RAND_MAX); }
35 static inline float randFloat(
float a,
float b) {
36 float t = randFloat();
39 static inline double randDouble(
double a,
double b) {
40 double t = randDouble();
51 inline void seed(
unsigned long n) { state = n; }
52 inline unsigned int maxValue()
const {
return UINT_MAX; }
53 inline unsigned long randLong()
55 state = 1664525L*state + 1013904223L;
58 inline long int randInt() {
return (
long int)randLong(); }
59 inline float randFloat()
62 static unsigned long jflone = 0x3f800000;
63 static unsigned long jflmsk = 0x007fffff;
65 itemp = jflone | (jflmsk & randLong());
66 return (*(
float *)&itemp)-1.0f;
70 inline double randDouble()
75 static unsigned long jflone = 0x3ff00000;
76 static unsigned long jflmsk = 0x000fffff;
77 r[0] = jflone | (jflmsk & r[0]);
78 double d = *(
double*)&r[0];
83 inline long int randInt(
int n) {
return randInt()%n; }
84 inline float randFloat(
float a,
float b) {
85 float t = randFloat();
88 inline double randDouble(
double a,
double b) {
89 double t = randDouble();
101 static inline void seed(
unsigned long n) { srand48(n); }
102 static inline long int maxValue() {
return INT_MAX; }
103 static inline long int randInt() {
return lrand48(); }
104 static inline float randFloat() {
return (
float)drand48(); }
105 static inline double randDouble() {
return drand48(); }
107 static inline long int randInt(
int n) {
return randInt()%n; }
108 static inline float randFloat(
float a,
float b) {
109 float t = randFloat();
112 static inline double randDouble(
double a,
double b) {
113 double t = randDouble();
uses the ANSI C rand48 functions
Definition: utils/random.h:99
Interface for a random number generator.
Definition: utils/random.h:25
static long int randInt(long int n)
helpers
Definition: utils/random.h:34