// for each seed an unique random number generator is created,
// which is initialized with the seed itself
+ // we could use std::mt19937 but doing so results in compiler-dependent
+ // output.
static std::map<double, boost::random::mt19937> rng_map;
if (rng_map.find(seed) == rng_map.end())
// in a thread context. one could use rand_r, but this does not
// produce reproducible results between threads either (though at
// least it is reentrant). these two approaches being
- // non-workable, use a thread-local random number generator here
+ // non-workable, use a thread-local random number generator here.
+ // we could use std::mt19937 but doing so results in compiler-dependent
+ // output.
static Threads::ThreadLocalStorage<boost::mt19937> random_number_generator;
return boost::normal_distribution<>(a,
sigma)(random_number_generator.get());
Assert(new_indices.size() == n_dofs,
ExcDimensionMismatch(new_indices.size(), n_dofs));
- for (unsigned int i = 0; i < n_dofs; ++i)
- new_indices[i] = i;
+ std::iota(new_indices.begin(),
+ new_indices.end(),
+ types::global_dof_index(0));
// shuffle the elements; the following is essentially std::shuffle (which
// is new in C++11) but with a boost URNG
+ // we could use std::mt19937 here but doing so results in compiler-dependent
+ // output
::boost::mt19937 random_number_generator;
for (unsigned int i = 1; i < n_dofs; ++i)
{
Assert(new_indices.size() == n_dofs,
ExcDimensionMismatch(new_indices.size(), n_dofs));
- for (unsigned int i = 0; i < n_dofs; ++i)
- new_indices[i] = i;
+ std::iota(new_indices.begin(),
+ new_indices.end(),
+ types::global_dof_index(0));
// shuffle the elements; the following is essentially std::shuffle (which
// is new in C++11) but with a boost URNG
+ // we could use std::mt19937 here but doing so results in
+ // compiler-dependent output
::boost::mt19937 random_number_generator;
for (unsigned int i = 1; i < n_dofs; ++i)
{
// if you call the function twice on the same mesh, then you will
// get the same mesh. this would not be the case if you used
// the rand() function, which carries around some internal state
+ // we could use std::mt19937 but doing so results in compiler-dependent
+ // output.
boost::random::mt19937 rng;
boost::random::uniform_real_distribution<> uniform_distribution(-1, 1);