X-Git-Url: https://git.donarmstrong.com/?p=rsem.git;a=blobdiff_plain;f=simul.h;h=b62132a66a636115c3484073d7277bc5898d0eeb;hp=2719b3c9fb46fd67e6479775e3dfc6a1c113945f;hb=f0f013a727d36ba4c63edfcee634b4aeef960750;hpb=a95154919f950f86de9104b2b9dcf1f0c7e83387 diff --git a/simul.h b/simul.h index 2719b3c..b62132a 100644 --- a/simul.h +++ b/simul.h @@ -3,11 +3,14 @@ #include +#include "boost/random.hpp" class simul { public: - virtual ~simul() {} + simul(unsigned int seed) : engine(seed), rg(engine, boost::random::uniform_01<>()) { + } + // interval : [,) // random number should be in [0, arr[len - 1]) // If by chance arr[len - 1] == 0.0, one possibility is to sample uniformly from 0 ... len - 1 @@ -29,9 +32,11 @@ public: return l; } - virtual double random() { return 0.0; }; + double random() { return rg(); }; private: + boost::random::mt19937 engine; + boost::random::variate_generator > rg; }; #endif /* SIMUL_H_ */