#include <LinearCongruentialRandomGenerator.h>
A simple deterministic and portable random number generator. More...
A simple deterministic and portable random number generator.
This class implements a Linear Congruential Generator (LCG) algorithm to generate pseudo-random numbers. It is designed to provide deterministic and portable random number generation, making it well-suited for testing purposes.
Public Member Functions | |
| LinearCongruentialRandomGenerator (unsigned int initialSeed) | |
| unsigned int | generateRandom () |
| Generates the next pseudo-random number. More... | |
| template<class Scalar > | |
| Scalar | generateInUnitRange () |
| Generates a pseudo-random value within the unit interval [0, 1]. More... | |
| double | generateInRange (double rmin, double rmax) |
| Generates a pseudo-random double value within a specified range. More... | |
| float | generateInRange (float rmin, float rmax) |
| Generates a pseudo-random float value within a specified range. More... | |
|
explicit |
| double sofa::testing::LinearCongruentialRandomGenerator::generateInRange | ( | double | rmin, |
| double | rmax | ||
| ) |
Generates a pseudo-random double value within a specified range.
This function generates a pseudo-random double value between the provided minimum (rmin) and maximum (rmax) values.
| rmin | The minimum value of the desired range (inclusive). |
| rmax | The maximum value of the desired range (inclusive). |
Example usage:
Generates a pseudo-random float value within a specified range.
This function generates a pseudo-random float value between the provided minimum (rmin) and maximum (rmax) values.
| rmin | The minimum value of the desired range (inclusive). |
| rmax | The maximum value of the desired range (inclusive). |
Example usage:
|
inline |
Generates a pseudo-random value within the unit interval [0, 1].
This templated function generates a pseudo-random value of the specified scalar type within the unit interval [0, 1]. It utilizes the underlying random number generator to produce a normalized random value within the unit range.
| Scalar | The scalar type for the generated value (e.g., float, double). |
Example usage:
| unsigned sofa::testing::LinearCongruentialRandomGenerator::generateRandom | ( | ) |
Generates the next pseudo-random number.
This method uses a Linear Congruential Generator (LCG) algorithm to update the seed and produce the next pseudo-random number.