25 #include <randutils/randutils.hpp> 40 for (
size_t i = 0; i < size(); ++i) {
41 status = status && ((*this)[i] == other[i]);
52 for (
auto& e : *
this) {
66 this->resize(m_stream_count);
72 std::vector<unsigned int> seseq_init_vec;
73 const auto string_vec{
Split(m_seed_seq_init,
",")};
74 for (
const auto& e :
Split(m_seed_seq_init,
",")) {
76 throw std::runtime_error(
"Rn::Seed> Error in seeding definiton: " + e);
78 seseq_init_vec.push_back(FromString<unsigned int>(e));
80 randutils::seed_seq_fe128 seseq(seseq_init_vec.begin(), seseq_init_vec.end());
84 std::stringstream ss(state);
85 for (
size_t i = 0; i < m_stream_count; ++i) {
86 ss >> (*this)[i].engine();
94 if (2 * m_stream_count > 64) {
95 throw std::runtime_error(
"RnPcg64 generate seed vector, cannot handle large n.");
97 auto seeds = pcg_extras::generate_vector<pcg64::state_type, 64>(seseq);
98 for (
size_t i = 0; i < m_stream_count; ++i) {
99 (*this)[i].engine().seed(seeds[i + 1], seeds[i]);
103 template <
typename E>
106 auto seeds = pcg_extras::generate_one<unsigned long>(seseq);
107 for (
size_t i = 0; i < m_stream_count; ++i) {
108 (*this)[i].engine().seed(seeds);
109 (*this)[i].engine().split(m_stream_count, i);
std::string m_seed_seq_init
Seed for the engine.
std::vector< std::string > Split(const std::string &s, const std::string &delimiters)
Split a string (in order of occurence) by splitting it on the given delimiters.
unsigned int m_stream_count
Number of streams set up with the engine.
Manages random number generation in parallel (OpenMP) calculations.
bool operator==(const SegmentedVector< T, N, Safe > &lhs, const SegmentedVector< T, N, Safe > &rhs)
Helper function for equality test (equal size and all elements equal).
Miscellaneous string utilities.
Namespace for the simulator and related classes.
std::string m_state
Long string representing current state.
Information on random number management state.
bool CheckAllDigits(const std::string &s)
All characters in string are digits (or string is empty)
unsigned int m_stream_count
Number of threads/streams set up with the engine.