|
FEAT 3
Finite Element Analysis Toolbox
|
Pseudo-Random Number Generator. More...
#include <random.hpp>
Public Types | |
| typedef std::uint64_t | SeedType |
| seed type More... | |
Public Member Functions | |
| Random () | |
| Default constructor that seeds the RNG with the current high-resolution clock time. More... | |
| Random (SeedType seed) | |
| Constructor. More... | |
| SeedType | get_seed () const |
| uint64_t | next () |
| Returns the next number in the stream. More... | |
| template<typename T_ > | |
| T_ | operator() (T_ a, T_ b) |
| Ranged evaluation operator. More... | |
| template<typename T_ > | |
| Random & | operator>> (T_ &x) |
| Extraction operator. More... | |
Static Public Attributes | |
| static constexpr SeedType | xor_mult = SeedType(2685821657736338717ull) |
| internal multiplier More... | |
Private Attributes | |
| std::uint64_t | _seed |
| the rng's original seed More... | |
| std::uint64_t | _x |
| the rng's working values More... | |
Pseudo-Random Number Generator.
This class implements a 64-bit XOR-Shift* pseudo-random number generator with a 64-bit cycle.
The intention of this class is to provide a pseudo-random number generator which generates (warning: paradox ahead) a reproducible random number stream independent of the platform and the compiler in use.
xorshift64* example in Figure 10 of the first article by Vigna mentioned above.Definition at line 53 of file random.hpp.
| typedef std::uint64_t FEAT::Random::SeedType |
seed type
Definition at line 57 of file random.hpp.
|
inlineexplicit |
Default constructor that seeds the RNG with the current high-resolution clock time.
Definition at line 72 of file random.hpp.
|
inlineexplicit |
Constructor.
| [in] | seed | The seed for the random number generator; must not be 0. |
Definition at line 87 of file random.hpp.
References XASSERTM.
|
inline |
Definition at line 95 of file random.hpp.
References _seed.
|
inline |
Returns the next number in the stream.
This function returns the next unsigned 32-bit integer in the random number stream and advances the stream.
Definition at line 106 of file random.hpp.
|
inline |
Ranged evaluation operator.
This operator returns a random number in the range passed to this operator.
| T_ | The type of the value to be extracted. Is determined automatically by a and b. |
| [in] | a,b | The minimum and maximum values for the range of the random number to be generated. |
b < a, then a and b are swapped. a = b, then the returned value will be equal to a, however, the generator will still advance its position within the random number stream.Definition at line 157 of file random.hpp.
|
inline |
Extraction operator.
This function extracts the next random number in the stream.
| T_ | The type of the value to be extracted. Must be either of integral or floating point type. |
| [out] | x | The transient reference to an object receiving the extracted value. |
*this Definition at line 133 of file random.hpp.
|
private |
the rng's original seed
Definition at line 64 of file random.hpp.
Referenced by Random(), and get_seed().
|
private |
the rng's working values
Definition at line 66 of file random.hpp.