1#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_TESTING_PRNG_XOSHIRO_HPP_
2#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_TESTING_PRNG_XOSHIRO_HPP_
4#include "arene/base/array/array.hpp"
5#include "arene/base/stdlib_choice/cstdint.hpp"
31 array<std::uint64_t, 4> state_{};
37 template <std::uint8_t N>
38 static constexpr auto rotate_left(std::uint64_t arg) -> std::uint64_t {
39 constexpr auto upper_limit = 64U;
40 static_assert(N < upper_limit,
"rotation amount must be less than 64");
42 return N == 0U ? arg : ((arg << N) | (arg >> (upper_limit - N)));
50 std::uint64_t state{};
55 constexpr auto next()
noexcept -> std::uint64_t {
58 auto mixed = (state += std::uint64_t{0x9e3779b97f4a7c15ULL});
59 mixed = (mixed ^ (mixed >> 30U)) * std::uint64_t{0xbf58476d1ce4e5b9ULL};
60 mixed = (mixed ^ (mixed >> 27U)) * std::uint64_t{0x94d049bb133111ebULL};
61 return mixed ^ (mixed >> 31U);
76 auto seeder = splitmix64{initial_seed};
77 for (
auto& state : state_) {
78 state = seeder.next();
94 auto const result = rotate_left<23>(state_[0] + state_[3]) + state_[0];
96 auto const shifted = state_[1] << 17U;
98 state_[2] ^= state_[0];
99 state_[3] ^= state_[1];
100 state_[1] ^= state_[2];
101 state_[0] ^= state_[3];
103 state_[2] ^= shifted;
105 state_[3] = rotate_left<45>(state_[3]);
pseudorandom number generator implementing the xoshiro256++ algorithm
Definition prng_xoshiro.hpp:29
constexpr auto operator()() noexcept -> result_type
generate the next pseudorandom value and advance the internal state
Definition prng_xoshiro.hpp:91
static constexpr auto min() noexcept -> result_type
smallest value that operator() can return
Definition prng_xoshiro.hpp:113
constexpr prng_xoshiro() noexcept
construct the generator with a seed of zero
Definition prng_xoshiro.hpp:83
static constexpr auto max() noexcept -> result_type
largest value that operator() can return
Definition prng_xoshiro.hpp:117
constexpr prng_xoshiro(seed_type initial_seed) noexcept
construct the generator with an explicit seed
Definition prng_xoshiro.hpp:75
Definition customization.hpp:36
Definition array_exceptions_disabled.cpp:11
Copyright 2026, Toyota Motor Corporation.
Definition array_exceptions_disabled.cpp:10