31#ifndef ETL_RANDOM_INCLUDED
32#define ETL_RANDOM_INCLUDED
41#if defined(ETL_POLYMORPHIC_RANDOM)
53 virtual void initialise(uint32_t seed) = 0;
54 virtual uint32_t operator()() = 0;
55 virtual uint32_t range(uint32_t low, uint32_t high) = 0;
116 state[3] = seed + 11;
131 n ^= state[0] >> 19U;
192 seed = (seed == 0) ? 1 : seed;
193 value = (seed > m) ? m : seed;
201 value = (a * value) % m;
221 static ETL_CONSTANT
uint32_t a = 40014U;
222 static ETL_CONSTANT
uint32_t m = 2147483563UL;
264 seed = (seed == 0) ? 1 : seed;
265 value1 = (seed > m1) ? m1 : seed;
266 value2 = (seed > m1) ? m1 : seed;
274 static ETL_CONSTANT
uint32_t m = ((m1 > m2) ? m1 : m2);
276 value1 = (a1 * value1) % m1;
277 value2 = (a2 * value2) % m2;
279 return (value1 + value2) % m;
297 static ETL_CONSTANT
uint32_t a1 = 40014U;
298 static ETL_CONSTANT
uint32_t m1 = 2147483563UL;
300 static ETL_CONSTANT
uint32_t a2 = 40692U;
301 static ETL_CONSTANT
uint32_t m2 = 2147483399UL;
357 if ((value & 1UL) == 1UL)
428 value1 = 36969UL * (value1 & 0xFFFFUL) + (value1 >> 16U);
429 value2 = 18000UL * (value2 & 0xFFFFUL) + (value2 >> 16U);
431 return (value1 << 16U) + value2;
453#if ETL_USING_64BIT_TYPES
497 unsigned count = (
unsigned)(value >> 59U);
499 value = (x * multiplier) + increment;
519 static ETL_CONSTANT
uint64_t multiplier = 6364136223846793005ULL;
520 static ETL_CONSTANT
uint64_t increment = 1ULL;
526#if ETL_USING_8BIT_TYPES
532 template <
typename THash>
533 class random_hash :
public random
random_clcg()
Definition random.h:240
void initialise(uint32_t seed)
Definition random.h:262
random_clcg(uint32_t seed)
Definition random.h:253
uint32_t range(uint32_t low, uint32_t high)
Get the next random_clcg number in a specified inclusive range.
Definition random.h:285
uint32_t operator()()
Get the next random_clcg number.
Definition random.h:272
random_lcg(uint32_t seed)
Definition random.h:181
random_lcg()
Definition random.h:168
void initialise(uint32_t seed)
Definition random.h:190
uint32_t operator()()
Get the next random_clcg number.
Definition random.h:199
uint32_t range(uint32_t low, uint32_t high)
Get the next random_clcg number in a specified inclusive range.
Definition random.h:209
random_lsfr(uint32_t seed)
Definition random.h:334
random_lsfr()
Definition random.h:321
void initialise(uint32_t seed)
Definition random.h:343
uint32_t range(uint32_t low, uint32_t high)
Get the next random_lsfr number in a specified inclusive range.
Definition random.h:368
uint32_t operator()()
Get the next random_lsfr number.
Definition random.h:351
random_mwc()
Definition random.h:395
uint32_t range(uint32_t low, uint32_t high)
Get the next random_lsfr number in a specified inclusive range.
Definition random.h:437
uint32_t operator()()
Get the next random_lsfr number.
Definition random.h:426
random_mwc(uint32_t seed)
Definition random.h:408
void initialise(uint32_t seed)
Definition random.h:417
random_pcg(uint32_t seed)
Definition random.h:477
void initialise(uint32_t seed)
Definition random.h:486
uint32_t operator()()
Get the next random_lsfr number.
Definition random.h:494
uint32_t range(uint32_t low, uint32_t high)
Get the next random_lsfr number in a specified inclusive range.
Definition random.h:507
uint32_t operator()()
Get the next random_xorshift number.
Definition random.h:122
random_xorshift(uint32_t seed)
Definition random.h:101
random_xorshift()
Definition random.h:88
uint32_t range(uint32_t low, uint32_t high)
Get the next random_xorshift number in a specified inclusive range.
Definition random.h:140
void initialise(uint32_t seed)
Definition random.h:110
ETL_CONSTEXPR14 T rotate_right(T value)
Definition binary.h:161
bitset_ext
Definition absolute.h:38
pair holds two objects of arbitrary type
Definition utility.h:164
ETL_CONSTEXPR pair()
Default constructor.
Definition utility.h:176