refactored random subsystem

added compile-time seed support
This commit is contained in:
2016-04-26 15:15:28 +02:00
parent 8f6bfa917f
commit 62d8d6b36b
17 changed files with 163 additions and 29 deletions

View File

@@ -3,6 +3,9 @@
#include <cmath>
#include <random>
#include "../Random.h"
#include <type_traits>
namespace Distribution {
@@ -11,14 +14,17 @@ namespace Distribution {
private:
std::minstd_rand gen;
std::uniform_real_distribution<T> dist;
RandomGenerator gen;
/** depending on T, Dist is either a uniform_real or uniform_int distribution */
typedef typename std::conditional< std::is_floating_point<T>::value, std::uniform_real_distribution<T>, std::uniform_int_distribution<T> >::type Dist;
Dist dist;
public:
/** ctor */
Uniform(const T min, const T max) :
gen(1234), dist(min, max) {
Uniform(const T min, const T max) : gen(RANDOM_SEED), dist(min, max) {
}
/** get a uniformaly distributed random number */