Quick Links: |
#include <bdlb_pcgrandomgenerator.h>
Public Member Functions | |
PcgRandomGenerator () | |
PcgRandomGenerator (bsl::uint64_t initState, bsl::uint64_t streamSelector) | |
PcgRandomGenerator (const PcgRandomGenerator &original) | |
PcgRandomGenerator & | operator= (const PcgRandomGenerator &rhs) |
bsl::uint32_t | generate () |
void | seed (bsl::uint64_t initState, bsl::uint64_t streamSelector) |
Friends | |
bool | operator== (const PcgRandomGenerator &lhs, const PcgRandomGenerator &rhs) |
This class implements a random number generator (RNG) based on the PCG algorithm.
See Component bdlb_pcgrandomgenerator
bdlb::PcgRandomGenerator::PcgRandomGenerator | ( | ) |
bdlb::PcgRandomGenerator::PcgRandomGenerator | ( | bsl::uint64_t | initState, | |
bsl::uint64_t | streamSelector | |||
) |
Create a PcgRandomGenerator
object and seed it with the optionally specified initState
and streamSelector
. If initState
and streamSelector
are not specified, 0 is used for both. The highest-order bit of streamSelector
is ignored. Note that invoking different instances created with the identical initState
and streamSelector
will result in the same sequence of random numbers from subsequent invocations of generate()
.
bdlb::PcgRandomGenerator::PcgRandomGenerator | ( | const PcgRandomGenerator & | original | ) |
Create a PcgRandomGenerator
object having the same value as the specified original
object. Note that this newly created object will generate the same sequence of numbers as original
.
PcgRandomGenerator& bdlb::PcgRandomGenerator::operator= | ( | const PcgRandomGenerator & | rhs | ) |
Assign to this object the value of the specified rhs
object, and return a non-'const' reference to this object. Note that the object after assignment will generate the same sequence of numbers as rhs
.
bsl::uint32_t bdlb::PcgRandomGenerator::generate | ( | ) |
Return the next random number in the sequence generated by this object.
void bdlb::PcgRandomGenerator::seed | ( | bsl::uint64_t | initState, | |
bsl::uint64_t | streamSelector | |||
) |
Seed this generator with the specified new initState
and streamSelector
. Note that the sequence of random numbers produced from subsequent invocations of generate()
will be the same as that produced by an object created by PcgRandomGenerator(initState, streamSelector)
.
bool operator== | ( | const PcgRandomGenerator & | lhs, | |
const PcgRandomGenerator & | rhs | |||
) | [friend] |
Return true
if the specified lhs
and rhs
objects have the same value, and false
otherwise. Two PcgRandomGenerator
objects have the same value if they would produce the same sequence of random numbers from subsequent invocations of generate()
.