Mila
Deep Neural Network Library
|
Singleton class providing centralized random number generation. More...
Public Member Functions | |
std::mt19937 | getGenerator () const |
Gets a random number generator initialized with the global seed. | |
unsigned int | getSeed () const |
Gets the currently set random seed. | |
void | setSeed (unsigned int seed) |
Sets the global random seed. | |
Static Public Member Functions | |
static RandomGenerator & | getInstance () |
Gets the singleton instance of the RandomGenerator. | |
Private Member Functions | |
RandomGenerator () | |
RandomGenerator (const RandomGenerator &)=delete | |
RandomGenerator & | operator= (const RandomGenerator &)=delete |
Private Attributes | |
std::mt19937 | generator_ |
std::mutex | mutex_ |
unsigned int | seed_ |
Singleton class providing centralized random number generation.
This class manages random number generation for the entire codebase, allowing control over reproducibility through seed management.
|
inlineprivate |
|
privatedelete |
|
inline |
Gets a random number generator initialized with the global seed.
This returns a copy of the generator, so subsequent calls to setSeed won't affect already obtained generators.
|
inlinestatic |
Gets the singleton instance of the RandomGenerator.
|
inline |
Gets the currently set random seed.
|
privatedelete |
|
inline |
Sets the global random seed.
seed | The seed value (use 0 for non-deterministic behavior from std::random_device) |
|
private |
|
mutableprivate |
|
private |