BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bdlb::PcgRandomGenerator Class Reference

#include <bdlb_pcgrandomgenerator.h>

Public Member Functions

 PcgRandomGenerator ()
 
 PcgRandomGenerator (bsl::uint64_t initState, bsl::uint64_t streamSelector)
 
 PcgRandomGenerator (const PcgRandomGenerator &original)=default
 
PcgRandomGeneratoroperator= (const PcgRandomGenerator &rhs)=default
 
bsl::uint32_t generate ()
 
void seed (bsl::uint64_t initState, bsl::uint64_t streamSelector)
 

Friends

bool operator== (const PcgRandomGenerator &lhs, const PcgRandomGenerator &rhs)
 

Detailed Description

This class implements a random number generator (RNG) based on the PCG algorithm.

See bdlb_pcgrandomgenerator

Constructor & Destructor Documentation

◆ PcgRandomGenerator() [1/3]

bdlb::PcgRandomGenerator::PcgRandomGenerator ( )
inline

◆ PcgRandomGenerator() [2/3]

bdlb::PcgRandomGenerator::PcgRandomGenerator ( bsl::uint64_t  initState,
bsl::uint64_t  streamSelector 
)
inline

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().

◆ PcgRandomGenerator() [3/3]

bdlb::PcgRandomGenerator::PcgRandomGenerator ( const PcgRandomGenerator original)
default

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.

Member Function Documentation

◆ generate()

bsl::uint32_t bdlb::PcgRandomGenerator::generate ( )
inline

Return the next random number in the sequence generated by this object.

◆ operator=()

PcgRandomGenerator & bdlb::PcgRandomGenerator::operator= ( const PcgRandomGenerator rhs)
default

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.

◆ seed()

void bdlb::PcgRandomGenerator::seed ( bsl::uint64_t  initState,
bsl::uint64_t  streamSelector 
)
inline

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).

Friends And Related Symbol Documentation

◆ operator==

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().


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