cxxomfort
rel.20211024
Simple backports for C++ - https://ryan.gulix.cl/fossil.cgi/cxxomfort/
|
Classes | |
struct | splitmix64 |
Pseudo-RNG generator. More... | |
Namespaces | |
cxxomfort | |
Namespace of the cxxomfort library. | |
cxxomfort::library | |
Supplements to backports and other utilities. | |
Typedefs | |
typedef std::linear_congruential_engine< uint32_t, 1664525, 1013904223, 0 > | lcg_numerical_recipes_rand |
LCG as it appears in Numerical Recipes. More... | |
typedef std::linear_congruential_engine< uint64_t, 6364136223846793005, 1, 0 > | musl_rand |
LCG specification as it appears in MUSL Libc.This is an alternative to eg.: std::minstd and other linear congruential engines. More... | |
typedef std::linear_congruential_engine< uint_least64_t, 0x00000005deece66dULL, 0xb, 0x0001000000000000ULL > | rand48 |
LCG specification as it appears in FreeBSD.This is an alternative to eg.: std::minstd and other linear congruential engines. More... | |
typedef std::linear_congruential_engine< unsigned int, 0, 4, 0 > | xkcd221_rand |
LCG specification following Randall Munroe's xkcd #221. More... | |
Functions | |
template<typename Gen , typename Integer > | |
Integer | uniform_choose (Gen &g, Integer a, Integer b) |
Given a generator g , generate and choose an integer in the range [a, b] . More... | |
template<typename Gen , typename Iterator > | |
Iterator | uniform_pick (Gen &g, Iterator ini, Iterator fin) |
Choose one in a sequence of values [ini,fin) . More... | |
lcg_numerical_recipes_rand |
LCG as it appears in Numerical Recipes.
This is an alternative to eg.: std::minstd
and other linear congruential engines, using as parameters to the generator the parameters specified in Numerical Recipes .
When invoked with operator()
returns a uint32_t
value.
musl_rand |
LCG specification as it appears in MUSL Libc.This is an alternative to eg.: std::minstd
and other linear congruential engines.
When invoked with operator()
returns a uint64_t
value.
rand48 |
LCG specification as it appears in FreeBSD.This is an alternative to eg.: std::minstd
and other linear congruential engines.
When invoked with operator()
returns a uint64_t
value within a range that uses the first (lowest) 48 bits.
xkcd221_rand |
LCG specification following Randall Munroe's xkcd #221.
This is an alternative to eg.: std::minstd
and other linear congruential engines.
When invoked with operator()
returns a unsigned
value. The generator is equivalent to the following hand-written code:
Integer cxxomfort::library::random::uniform_choose | ( | Gen & | g, |
Integer | a, | ||
Integer | b | ||
) |
Given a generator g , generate and choose an integer in the range [a, b]
.
g | A generator object (lvalue). |
Referenced by cxxomfort::library::random::uniform_choose().
Iterator cxxomfort::library::random::uniform_pick | ( | Gen & | g, |
Iterator | ini, | ||
Iterator | fin | ||
) |
Choose one in a sequence of values [ini,fin)
.
ini,fin | A sequence's begin and end iterators. |
[ini,fin)
.This function uses uniform_choose()
on the passed generator g to uniformly pick one iterator within the desired range.
Referenced by cxxomfort::library::random::uniform_pick().