libcruft-util/rand/xoshiro.hpp

51 lines
1.2 KiB
C++

/*
* Written in 2019 by David Blackman and Sebastiano Vigna (vigna@acm.org)
*
* To the extent possible under law, the author has dedicated all copyright
* and related and neighboring rights to this software to the public domain
* worldwide. This software is distributed without any warranty.
*/
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* Copyright 2020, Danny Robson <danny@nerdcruft.net>
*/
#pragma once
#include "../std.hpp"
#include <limits>
///////////////////////////////////////////////////////////////////////////////
namespace cruft::rand {
class xoshiro256plusplus {
public:
using result_type = u64;
xoshiro256plusplus (u64 seed);
static constexpr result_type min (void)
{
return std::numeric_limits<result_type>::min ();
}
static constexpr result_type max (void)
{
return std::numeric_limits<result_type>::max ();
}
result_type operator() (void);
void jump (void);
void long_jump (void);
private:
u64 m_state[4];
};
}