aGrUM  0.18.1
a C++ library for (probabilistic) graphical models
utils_random.cpp
Go to the documentation of this file.
1 
29 #include <chrono>
30 
31 #include <agrum/agrum.h>
33 
34 #ifdef GUM_NO_INLINE
36 #endif // GUM_NO_INLINE
37 
38 namespace gum {
39 
40  // returns the aGrUM's seed used by the std::generators
41  unsigned int randomGeneratorSeed() {
42  return (unsigned int)((GUM_RANDOMSEED == 0) ? std::chrono::system_clock::now()
43  .time_since_epoch()
44  .count()
45  : GUM_RANDOMSEED);
46  }
47 
48 
49  std::default_random_engine getRandomGenerator(unsigned int seed) {
50  std::default_random_engine generator;
51  generator.seed(seed ? seed : randomGeneratorSeed());
52  return generator;
53  }
54 
55 } /* namespace gum */
Copyright 2005-2020 Pierre-Henri WUILLEMIN() & Christophe GONZALES() info_at_agrum_dot_org.
Copyright 2005-2020 Pierre-Henri WUILLEMIN() & Christophe GONZALES() info_at_agrum_dot_org.
Definition: agrum.h:25
unsigned int randomGeneratorSeed()
Returns the aGrUM&#39;s seed used by the std::generators.
std::default_random_engine getRandomGenerator(unsigned int seed)
define a random_engine with correct seed
Copyright 2005-2020 Pierre-Henri WUILLEMIN() & Christophe GONZALES() info_at_agrum_dot_org.