11#include "vipra/concepts/numeric.hpp"
12#include "vipra/types/float.hpp"
13#include "vipra/types/size.hpp"
15namespace VIPRA::Random {
23 using seed = __uint128_t;
26 using result_type = uint64_t;
28 Engine() : _currVal(DEFAULT_SEED) {}
29 explicit Engine(uint64_t seedVal) : _currVal(seedVal)
33 _currVal <<= SHIFT_NUM;
36 static constexpr uint64_t DEFAULT_SEED = 12345;
45 assert(_currVal != 0);
48 return _currVal >> SHIFT_NUM;
56 void reseed(uint64_t seedNum)
noexcept
59 _currVal <<= SHIFT_NUM;
61 assert(_currVal != 0);
69 static inline constexpr auto min() noexcept -> uint64_t {
return 0; }
76 static inline constexpr auto max() noexcept -> uint64_t
78 return std::numeric_limits<uint64_t>::max();
83 static constexpr uint64_t MULT_NUM = 0xda942042e4dd58b5;
84 static constexpr uint64_t SHIFT_NUM = 64;
104template <typename dist_t, Concepts::Numeric data_t = VIPRA::f_pnt>
105inline auto make_distribution(dist_t&& distr, VIPRA::size count,
106 VIPRA::Random::
Engine& engine) -> std::vector<data_t>
108 std::vector<data_t> ret(count);
110 std::transform(ret.cbegin(), ret.cend(), ret.begin(), [&](data_t) {
111 data_t val = distr(engine);
Psuedo Random number engine.
Definition random.hpp:22
static constexpr auto min() noexcept -> uint64_t
Returns the minimum number possible.
Definition random.hpp:69
void reseed(uint64_t seedNum) noexcept
Restarts the number generator with a new seed.
Definition random.hpp:56
auto operator()() noexcept -> uint64_t
Produces the next pseudo random number in the sequence, uses Lehmer's generator.
Definition random.hpp:43
static constexpr auto max() noexcept -> uint64_t
Returns the maximum number possible.
Definition random.hpp:76