Mila
Deep Neural Network Library
Loading...
Searching...
No Matches
Mila::Core::RandomGenerator Class Referenceexport

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.

Detailed Description

Singleton class providing centralized random number generation.

This class manages random number generation for the entire codebase, allowing control over reproducibility through seed management.

Member Function Documentation

◆ getGenerator()

std::mt19937 Mila::Core::RandomGenerator::getGenerator ( ) const
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.

Returns
A copy of the random number generator

◆ getInstance()

RandomGenerator & Mila::Core::RandomGenerator::getInstance ( )
inlinestatic

Gets the singleton instance of the RandomGenerator.

Returns
Reference to the singleton instance

◆ getSeed()

unsigned int Mila::Core::RandomGenerator::getSeed ( ) const
inline

Gets the currently set random seed.

Returns
The currently used seed value

◆ setSeed()

void Mila::Core::RandomGenerator::setSeed ( unsigned int seed)
inline

Sets the global random seed.

Parameters
seedThe seed value (use 0 for non-deterministic behavior from std::random_device)

The documentation for this class was generated from the following file: