#include #include #include template constexpr inline double dot(const std::array& v, const std::array& u) { double res=0; for(std::size_t i=0;i& state) { const constexpr std::array vec2 = { 12.9898, 78.223 }; return fract(sin(dot(state, vec2)) * 43758.5453); } inline void update_state(std::array& state, double r) { float v1 = (float)state[0]; float v2 = (float)state[1]; std::array nvec = { r, (double)v2, }; state[0] = sample_double(nvec); nvec[1] = (double)v1; state[1] = sample_double(nvec); } double frng::sample() { double res = sample_double(state); update_state(state, res); return res; } }