You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
808 B
38 lines
808 B
#pragma once
|
|
|
|
#include "common.h"
|
|
|
|
namespace rng
|
|
{
|
|
template<typename T>
|
|
struct seed_gen
|
|
{
|
|
virtual T generate_seed() = 0;
|
|
|
|
inline virtual ~seed_gen(){}
|
|
};
|
|
|
|
namespace seed
|
|
{
|
|
struct splitmix64 : public virtual seed_gen<u64>
|
|
{
|
|
inline splitmix64(const splitmix64&) = default;
|
|
explicit inline splitmix64(seed_gen<u64>& from) : m_state(from.generate_seed()){}
|
|
splitmix64(u64 i);
|
|
|
|
u64 generate_seed() override;
|
|
f64 generate_f64();
|
|
|
|
inline virtual ~splitmix64() override{}
|
|
|
|
static u64 oneshot(u64& state);
|
|
inline static u64 oneshot(const u64& state) { u64 s = state; return oneshot(s); }
|
|
static f64 oneshotf(u64& state);
|
|
inline static f64 oneshotf(const u64& state) { u64 s = state; return oneshotf(s); }
|
|
static splitmix64 random();
|
|
private:
|
|
u64 m_state;
|
|
};
|
|
}
|
|
}
|