| 43 |
|
#define MATH_RANDNUMGEN_HPP |
| 44 |
|
|
| 45 |
|
#include <vector> |
| 46 |
+ |
#include "config.h" |
| 47 |
|
#include "MersenneTwister.hpp" |
| 48 |
|
#include "utils/simError.h" |
| 49 |
|
|
| 64 |
|
} |
| 65 |
|
|
| 66 |
|
/** Returns a real number in [0,1] */ |
| 67 |
< |
double rand() { |
| 67 |
> |
RealType rand() { |
| 68 |
|
return mtRand_->rand(); |
| 69 |
|
} |
| 70 |
|
|
| 71 |
|
/** Returns a real number in [0, n] */ |
| 72 |
< |
double rand( const double& n ) { |
| 72 |
> |
RealType rand( const RealType& n ) { |
| 73 |
|
return mtRand_->rand(n); |
| 74 |
|
} |
| 75 |
|
|
| 76 |
|
/** Returns a real number in [0, 1) */ |
| 77 |
< |
double randExc() { |
| 77 |
> |
RealType randExc() { |
| 78 |
|
return mtRand_->randExc(); |
| 79 |
|
} |
| 80 |
|
|
| 81 |
|
/** Returns a real number in [0, n) */ |
| 82 |
< |
double randExc( const double& n ) { |
| 82 |
> |
RealType randExc( const RealType& n ) { |
| 83 |
|
return mtRand_->randExc(n); |
| 84 |
|
} |
| 85 |
|
|
| 86 |
|
/** Returns a real number in (0, 1) */ |
| 87 |
< |
double randDblExc() { |
| 87 |
> |
RealType randDblExc() { |
| 88 |
|
return mtRand_->randDblExc(); |
| 89 |
|
} |
| 90 |
|
|
| 91 |
|
/** Returns a real number in (0, n) */ |
| 92 |
< |
double randDblExc( const double& n ) { |
| 92 |
> |
RealType randDblExc( const RealType& n ) { |
| 93 |
|
return mtRand_->randDblExc(n); |
| 94 |
|
} |
| 95 |
|
|
| 103 |
|
return mtRand_->randInt(n); |
| 104 |
|
} |
| 105 |
|
|
| 106 |
< |
/** Returns a 53-bitreal number in [0,1) (capacity of IEEE double precision) */ |
| 107 |
< |
double rand53() { |
| 106 |
> |
/** Returns a 53-bitreal number in [0,1) (capacity of IEEE RealType precision) */ |
| 107 |
> |
RealType rand53() { |
| 108 |
|
return mtRand_->rand53(); |
| 109 |
|
} |
| 110 |
|
|
| 111 |
|
/** Access to nonuniform random number distributions */ |
| 112 |
< |
double randNorm( const double mean, const double variance) { |
| 112 |
> |
RealType randNorm( const RealType mean, const RealType variance) { |
| 113 |
|
return mtRand_->randNorm(mean, variance); |
| 114 |
|
} |
| 115 |
|
|