6#ifndef THEORETICA_PSEUDORANDOM_H
7#define THEORETICA_PSEUDORANDOM_H
12#include "../core/bit_op.h"
13#include "../core/error.h"
45 return (a * x + c) %
m;
59 if(
state.size() != 3) {
114 if(
state.size() != 4) {
132 x += 0x9e3779b97f4a7c15;
135 res = (
res ^ (
res >> 30)) * 0xbf58476d1ce4e5b9;
136 res = (
res ^ (
res >> 27)) * 0x94d049bb133111eb;
200 return (
high << 32) | (
low >> 32);
213 TH_MATH_ERROR(
"randgen_middlesquare",
p.size(), INVALID_ARGUMENT);
#define TH_MATH_ERROR(F_NAME, VALUE, EXCEPTION)
TH_MATH_ERROR is a macro which throws exceptions or modifies errno (depending on which compiling opti...
Definition error.h:219
Main namespace of the library which contains all functions and objects.
Definition algebra.h:27
uint64_t randgen_xoshiro(uint64_t &a, uint64_t &b, uint64_t &c, uint64_t &d)
Generate a pseudorandom natural number using the xoshiro256++ pseudorandom number generation algorith...
Definition pseudorandom.h:86
std::remove_reference_t< decltype(std::declval< Structure >()[0])> vector_element_t
Extract the type of a vector (or any indexable container) from its operator[].
Definition core_traits.h:134
TH_CONSTEXPR UnsignedIntType bit_rotate(UnsignedIntType x, unsigned int i)
Bit rotation of unsigned integer types using shifts.
Definition bit_op.h:78
uint64_t mix_mum(uint64_t a, uint64_t b)
MUM bit mixing function, computes the 128-bit product of a and b and the XOR of their high and low 64...
Definition bit_op.h:62
auto max(const Vector &X)
Finds the maximum value inside a dataset.
Definition dataset.h:330
uint64_t randgen_splitmix64(uint64_t x)
Generate a pseudorandom natural number using the SplitMix64 pseudorandom number generation algorithm.
Definition pseudorandom.h:130
uint64_t(*)(uint64_t, std::vector< uint64_t > &) pseudorandom_function
A function pointer which wraps a pseudorandom generator, taking as input the previous generated value...
Definition pseudorandom.h:23
uint64_t randgen_middlesquare(uint64_t seed, uint64_t offset=765872292751861)
Generate a pseudorandom natural number using the middle-square pseudorandom number generation algorit...
Definition pseudorandom.h:194
uint64_t randgen_congruential(uint64_t x, uint64_t a=48271, uint64_t c=0, uint64_t m=((uint64_t) 1<< 31) - 1)
Generate a pseudorandom natural number using the congruential pseudorandom number generation algorith...
Definition pseudorandom.h:39
void mul_uint128(uint64_t a, uint64_t b, uint64_t &c_low, uint64_t &c_high)
Multiply two 64-bit unsigned integers and store the result in two 64-bit variables,...
Definition bit_op.h:24
uint64_t randgen_wyrand(uint64_t &seed, uint64_t p1, uint64_t p2)
Generate a pseudorandom natural number using the Wyrand pseudorandom number generation,...
Definition pseudorandom.h:160