8#ifndef INCLUDED_BDLB_PCGRANDOMGENERATOR
9#define INCLUDED_BDLB_PCGRANDOMGENERATOR
225#include <bdlscm_version.h>
229#include <bsl_cstdint.h>
245 bsl::uint64_t d_state;
246 bsl::uint64_t d_streamSelector;
290 void seed(bsl::uint64_t initState, bsl::uint64_t streamSelector);
324 bsl::uint64_t streamSelector)
326 seed(initState, streamSelector);
333 static const bsl::uint64_t k_MULTIPLIER = 6364136223846793005ULL;
335 bsl::uint64_t oldstate = d_state;
338 d_state = oldstate * k_MULTIPLIER + d_streamSelector;
341 bsl::uint32_t xorshifted =
342 static_cast<bsl::uint32_t
>(((oldstate >> 18u) ^ oldstate) >> 27u);
343 bsl::uint32_t rot =
static_cast<bsl::uint32_t
>(oldstate >> 59u);
344 return (xorshifted >> rot) | (xorshifted << ((0u - rot) & 31u));
349 bsl::uint64_t streamSelector)
351 d_streamSelector = (streamSelector << 1u) | 1u;
355 d_state += initState;
364 const PcgRandomGenerator& rhs)
366 return lhs.d_state == rhs.d_state &&
367 lhs.d_streamSelector == rhs.d_streamSelector;
372 const PcgRandomGenerator& rhs)
Definition bdlb_pcgrandomgenerator.h:242
void seed(bsl::uint64_t initState, bsl::uint64_t streamSelector)
Definition bdlb_pcgrandomgenerator.h:348
PcgRandomGenerator(const PcgRandomGenerator &original)=default
friend bool operator==(const PcgRandomGenerator &lhs, const PcgRandomGenerator &rhs)
PcgRandomGenerator()
Definition bdlb_pcgrandomgenerator.h:317
PcgRandomGenerator & operator=(const PcgRandomGenerator &rhs)=default
bsl::uint32_t generate()
Definition bdlb_pcgrandomgenerator.h:331
#define BSLS_IDENT(str)
BSLS_IDENT() - insert string into .comment binary segment (if supported)
Definition bsls_ident.h:238
Definition bdlb_algorithmworkaroundutil.h:74
bool operator!=(const BigEndianInt16 &lhs, const BigEndianInt16 &rhs)
bool operator==(const BigEndianInt16 &lhs, const BigEndianInt16 &rhs)
ALLOCATOR const STRING_VIEW_LIKE_TYPE & rhs
Definition bslstl_string.h:3918
ALLOCATOR & lhs
Definition bslstl_string.h:3917