5#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_TESTING_PRNG_XOSHIRO_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_TESTING_PRNG_XOSHIRO_HPP_
9#include "arene/base/stdlib_choice/cstdint.hpp"
41 template <std::u
int8_t N>
43 constexpr auto upper_limit = 64U;
44 static_assert(N < upper_limit,
"rotation amount must be less than 64");
46 return N == 0U ? arg : ((arg << N) | (arg >> (upper_limit - N)));
63 mixed = (mixed ^ (mixed >> 30U)) *
std::uint64_t{0xbf58476d1ce4e5b9ULL};
64 mixed = (mixed ^ (mixed >> 27U)) *
std::uint64_t{0x94d049bb133111ebULL};
65 return mixed ^ (mixed >> 31U);
80 auto seeder = splitmix64{initial_seed};
81 for (
auto& state : state_) {
82 state = seeder.next();
98 auto const result = rotate_left<23>(state_[0] + state_[3]) + state_[0];
100 auto const shifted = state_[1] << 17U;
102 state_[2] ^= state_[0];
103 state_[3] ^= state_[1];
104 state_[1] ^= state_[2];
105 state_[0] ^= state_[3];
107 state_[2] ^= shifted;
109 state_[3] = rotate_left<45>(state_[3]);
A fixed-size array of T objects.
Definition array.hpp:77
A sum type which can hold either a value or an error. Similar to std::expected.
Definition result.hpp:104
std::uint64_t result_type
prng result type
Definition prng_xoshiro.hpp:75
constexpr auto operator()() noexcept -> result_type
generate the next pseudorandom value and advance the internal state
Definition prng_xoshiro.hpp:95
static constexpr auto min() noexcept -> result_type
smallest value that operator() can return
Definition prng_xoshiro.hpp:117
constexpr prng_xoshiro() noexcept
construct the generator with a seed of zero
Definition prng_xoshiro.hpp:87
std::uint64_t seed_type
seed argument type
Definition prng_xoshiro.hpp:72
static constexpr auto max() noexcept -> result_type
largest value that operator() can return
Definition prng_xoshiro.hpp:121
constexpr prng_xoshiro(seed_type initial_seed) noexcept
construct the generator with an explicit seed
Definition prng_xoshiro.hpp:79
Definition customization.hpp:31
Definition accumulate.hpp:37
ARENE_NODISCARD constexpr auto next(Iterator itr, typename std::iterator_traits< Iterator >::difference_type steps=1) noexcept(noexcept(::arene::base::advance(itr, steps))) -> Iterator
Produces the Nth successor (or predecessor if steps is negative) of an iterator.
Definition next.hpp:38
Definition accumulate.hpp:36
::uint64_t uint64_t
A 64-bit unsigned integer type.
Definition cstdint.hpp:47