QuickCppLib 0.10
Eliminate all the tedious hassle when making state-of-the-art C++ 14 - 23 libraries!
Loading...
Searching...
No Matches
quickcpplib::_xxx::algorithm::small_prng::small_prng Class Reference

From http://burtleburtle.net/bob/rand/smallprng.html, a not awful fast random number source. More...

#include "small_prng.hpp"

Public Types

using value_type = uint32_t
 The type produced by the small prng.
 

Public Member Functions

 small_prng (uint32_t seed=0xdeadbeef) noexcept
 Construct an instance with seed
 
uint32_t operator() () noexcept
 Return value_type of pseudo-randomness.
 

Static Protected Member Functions

static uint32_t rot (uint32_t x, uint32_t k) noexcept
 

Protected Attributes

uint32_t a
 
uint32_t b
 
uint32_t c
 
uint32_t d
 

Detailed Description

From http://burtleburtle.net/bob/rand/smallprng.html, a not awful fast random number source.

Member Typedef Documentation

◆ value_type

The type produced by the small prng.

Constructor & Destructor Documentation

◆ small_prng()

quickcpplib::_xxx::algorithm::small_prng::small_prng::small_prng ( uint32_t  seed = 0xdeadbeef)
inlineexplicitnoexcept

Construct an instance with seed

58 {
59 a = 0xf1ea5eed;
60 b = c = d = seed;
61 for(size_t i = 0; i < 20; ++i)
62 (*this)();
63 }
uint32_t d
Definition small_prng.hpp:49
uint32_t a
Definition small_prng.hpp:46
uint32_t c
Definition small_prng.hpp:48
uint32_t b
Definition small_prng.hpp:47

Member Function Documentation

◆ rot()

static uint32_t quickcpplib::_xxx::algorithm::small_prng::small_prng::rot ( uint32_t  x,
uint32_t  k 
)
inlinestaticprotectednoexcept
51{ return (((x) << (k)) | ((x) >> (32 - (k)))); }

◆ operator()()

uint32_t quickcpplib::_xxx::algorithm::small_prng::small_prng::operator() ( )
inlinenoexcept

Return value_type of pseudo-randomness.

67 {
68 uint32_t e = a - rot(b, 27);
69 a = b ^ rot(c, 17);
70 b = c + d;
71 c = d + e;
72 d = e + a;
73 return d;
74 }
static uint32_t rot(uint32_t x, uint32_t k) noexcept
Definition small_prng.hpp:51

Member Data Documentation

◆ a

uint32_t quickcpplib::_xxx::algorithm::small_prng::small_prng::a
protected

◆ b

uint32_t quickcpplib::_xxx::algorithm::small_prng::small_prng::b
protected

◆ c

uint32_t quickcpplib::_xxx::algorithm::small_prng::small_prng::c
protected

◆ d

uint32_t quickcpplib::_xxx::algorithm::small_prng::small_prng::d
protected

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