STE-Industries: utilities testing
GraphicSpace::RandomGenerator Class Reference

#include "RandomGenerator.h"

Collaboration diagram for GraphicSpace::RandomGenerator:
Collaboration graph

Public Member Functions

 RandomGenerator (const RandomGenerator &Argument) noexcept=default
 
 RandomGenerator (RandomGenerator &&Argument) noexcept=default
 
 RandomGenerator (void) noexcept
 
 ~RandomGenerator (void) noexcept=default
 
uint_fast32_t Generate (uint_fast32_t Maximum) noexcept
 
void GetSeed (uint_fast32_t Seed[NUMBER_OF_GENERATORS+1]) const noexcept
 
void ModifySeed (uint_fast32_t Value) noexcept
 
RandomGeneratoroperator= (const RandomGenerator &Argument) noexcept=default
 
RandomGeneratoroperator= (RandomGenerator &&Argument) noexcept=default
 
unsigned int Select (register const uint_fast32_t *Probability, unsigned int Elements) noexcept
 
void SetSeed (const uint_fast32_t Seed[NUMBER_OF_GENERATORS+1]) noexcept
 

Static Public Attributes

static constexpr unsigned int MINIMUM_MODULE
 
static constexpr unsigned int NUMBER_OF_GENERATORS
 

Private Attributes

SimpleRandomGenerator Generator [NUMBER_OF_GENERATORS]
 
SimpleRandomGenerator Selector
 

Detailed Description

The RandomGenerator class represents a random numbers generator, based upon an array of linear congruent random numbers generator.
Proper choice of the parameter ensures that the cycle of generated numbers does not repeats itself with Universe existence.

Definition at line 31 of file RandomGenerator.h.

Constructor & Destructor Documentation

◆ RandomGenerator() [1/3]

GraphicSpace::RandomGenerator::RandomGenerator ( void  )
inlinenoexcept
Description:
Constructor.
Exceptions
None.
Returns
Not applicable.
See also
NUMBER_OF_GENERATORS

Definition at line 29 of file RandomGenerator.inl.

◆ RandomGenerator() [2/3]

GraphicSpace::RandomGenerator::RandomGenerator ( const RandomGenerator Argument)
defaultnoexcept

◆ RandomGenerator() [3/3]

GraphicSpace::RandomGenerator::RandomGenerator ( RandomGenerator &&  Argument)
defaultnoexcept

◆ ~RandomGenerator()

GraphicSpace::RandomGenerator::~RandomGenerator ( void  )
defaultnoexcept

Member Function Documentation

◆ Generate()

uint_fast32_t GraphicSpace::RandomGenerator::Generate ( uint_fast32_t  Maximum)
inlinenoexcept
Description:
Generate a new random number, between 0 and Maximum, with uniform probability.
Parameters
MaximumThe maximum number that can be generated; if it is zero, zero is generated;
Exceptions
None.
Returns
uint_fast32_t The generated number.
Note
A new value is computed selecting generator with the Selector generator and then using it to generate the number.
If Maximum is not less than MINIMUM_MODULE, the behavior is undefined.
See also
NUMBER_OF_GENERATORS

Definition at line 160 of file RandomGenerator.inl.

Referenced by GraphicSpace::Bitmap::Randomize().

Here is the caller graph for this function:

◆ GetSeed()

void GraphicSpace::RandomGenerator::GetSeed ( uint_fast32_t  Seed[NUMBER_OF_GENERATORS+1]) const
inlinenoexcept
Description:
Get the seeds of the generator.
Parameters
SeedArray that will contain the seeds.
Exceptions
None.
Returns
None.
See also
NUMBER_OF_GENERATORS

Definition at line 104 of file RandomGenerator.inl.

References Generator, GraphicSpace::SimpleRandomGenerator::GetValue(), NUMBER_OF_GENERATORS, and Selector.

Here is the call graph for this function:

◆ ModifySeed()

void GraphicSpace::RandomGenerator::ModifySeed ( uint_fast32_t  Value)
inlinenoexcept
Description:
Modify the seeds of the generator, xor-ing them with a given value.
Parameters
ValueThe value to be xor-ed with the seeds.
Exceptions
None.
Returns
None.
See also
NUMBER_OF_GENERATORS

Definition at line 128 of file RandomGenerator.inl.

Referenced by GraphicSpace::Bitmap::CorrectStrip().

Here is the caller graph for this function:

◆ operator=() [1/2]

RandomGenerator& GraphicSpace::RandomGenerator::operator= ( const RandomGenerator Argument)
defaultnoexcept

◆ operator=() [2/2]

RandomGenerator& GraphicSpace::RandomGenerator::operator= ( RandomGenerator &&  Argument)
defaultnoexcept

◆ Select()

unsigned int GraphicSpace::RandomGenerator::Select ( register const uint_fast32_t *  Probability,
unsigned int  Elements 
)
inlinenoexcept
Description:
Select among some alternatives, with a given probability distribution.
Parameters
ProbabilityPointer to the array of probabilities, which specify the probability distribution.
ElementsNumber of emenents among which the choice is made.
Exceptions
None.
Returns
unsigned int The selected item; the value is in the range [0 .. Elements - 1], or UINT_MAX, if all elements of the Probability array are zero.
Note
If Pointer is not a pointer to an array of at least Elements values, the behavior is undefined.
If the sum of all the probabilities is not less than MINIMUM_MODULE, the behavior is undefined.
See also
UINT_MAX
UINT_MAX

Definition at line 195 of file RandomGenerator.inl.

◆ SetSeed()

void GraphicSpace::RandomGenerator::SetSeed ( const uint_fast32_t  Seed[NUMBER_OF_GENERATORS+1])
inlinenoexcept
Description:
Set the seeds of the generator.
Parameters
SeedInitial value.
Exceptions
None.
Returns
None.
See also
NUMBER_OF_GENERATORS

Definition at line 80 of file RandomGenerator.inl.

References Generator, NUMBER_OF_GENERATORS, Selector, and GraphicSpace::SimpleRandomGenerator::SetSeed().

Referenced by GraphicSpace::Bitmap::Randomize().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ Generator

GraphicSpace::RandomGenerator::Generator
private

Random number generator, used to select one of the generators in the Generator array.

Definition at line 55 of file RandomGenerator.h.

Referenced by GetSeed(), and SetSeed().

◆ MINIMUM_MODULE

GraphicSpace::RandomGenerator::MINIMUM_MODULE
staticconstexpr
Initial value:
=
4273367641

Minimum module of the generators.

Definition at line 42 of file RandomGenerator.h.

◆ NUMBER_OF_GENERATORS

GraphicSpace::RandomGenerator::NUMBER_OF_GENERATORS
staticconstexpr
Initial value:
=
29

Number of linear congruent generators used.

Definition at line 37 of file RandomGenerator.h.

Referenced by GetSeed(), Randomize(), and SetSeed().

◆ Selector

GraphicSpace::RandomGenerator::Selector
private

Random number generator, used to select one of the generators in the Generator array.

Definition at line 50 of file RandomGenerator.h.

Referenced by GetSeed(), and SetSeed().


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