25 #include <trng/discrete_dist.hpp> 26 #include <trng/lcg64.hpp> 27 #include <trng/uniform01_dist.hpp> 28 #include <trng/uniform_int_dist.hpp> 30 #include <pcg/pcg_random.hpp> 31 #include <randutils/randutils.hpp> 42 class Rn :
protected std::vector<randutils::random_generator<E, randutils::seed_seq_fe128>>
46 using RnType = randutils::random_generator<E, randutils::seed_seq_fe128>;
47 using ContainerType = std::vector<randutils::random_generator<E, randutils::seed_seq_fe128>>;
49 using ContainerType::operator[];
50 using ContainerType::at;
51 using ContainerType::size;
66 Rn(
const Rn&) =
delete;
80 return ContainerType::at(i).variate_generator(trng::uniform01_dist<double>());
86 return ContainerType::at(i).variate_generator(trng::uniform_int_dist(a, b));
99 return ContainerType::at(i).variate_generator(trng::discrete_dist(begin, end));
109 void Shuffle(std::vector<unsigned int>& indices,
unsigned int i)
111 ContainerType::at(i).shuffle(indices.begin(), indices.end());
116 void Seed(randutils::seed_seq_fe128& seseq);
std::function< double()> GetUniform01Generator(unsigned int i=0U)
Return a generator for uniform doubles in [0, 1[ using i-th random engine.
std::function< int()> GetDiscreteGenerator(It begin, It end, unsigned int i=0U)
Return generator for integers [0, n-1[ with non-negative weights p_j (i=0,..,n-1) using i-th random e...
std::function< int()> GetUniformIntGenerator(int a, int b, unsigned int i=0U)
Return a generator for uniform ints in [a, b[ (a < b) using i-th random engine.
void Seed(randutils::seed_seq_fe128 &seseq)
Actual first-time seeding. Procedure varies according to engine type, see specialisations.
randutils::random_generator< pcg64, randutils::seed_seq_fe128 > RnType
void Initialize(const RnInfo &info)
Initalize with data in Info.
std::vector< randutils::random_generator< pcg64, randutils::seed_seq_fe128 >> ContainerType
Rn(const RnInfo &info)
Initializes.
Rn()
Default constructor build empty manager.
bool operator==(const Rn &other)
Equality of states.
std::string m_seed_seq_init
Seed sequence initializer used with engines.
Rn & operator=(const Rn &)=delete
No copy assignment.
bool IsEmpty() const
Is this een empty (i.e. non-initialized Rn)?
Manages random number generation in parallel (OpenMP) calculations.
RnInfo GetInfo() const
Return the state of the random engines.
void Shuffle(std::vector< unsigned int > &indices, unsigned int i)
Random shuffle of vector of unsigned int indices using i-th engine.
Namespace for the simulator and related classes.
Information on random number management state.
unsigned int m_stream_count
Number of threads/streams set up with the engine.