56struct RanluxppData<24> {
57 static const uint64_t kA[9];
59const uint64_t RanluxppData<24>::kA[] = {
60 0x0000000000000000, 0x0000000000000000, 0x0000000000010000, 0xfffe000000000000, 0xffffffffffffffff,
61 0xffffffffffffffff, 0xffffffffffffffff, 0xfffffffeffffffff, 0xffffffffffffffff,
65struct RanluxppData<2048> {
66 static const uint64_t kA[9];
68const uint64_t RanluxppData<2048>::kA[] = {
69 0xed7faa90747aaad9, 0x4cec2c78af55c101, 0xe64dcb31c48228ec, 0x6d8a15a13bee7cb0, 0x20b2ca60cb78c509,
70 0x256c3d3c662ea36c, 0xff74e54107684ed2, 0x492edfcc0cc8e753, 0xb48c187cf5b22097,
78template <
int w,
int p>
86 static constexpr const uint64_t *
kA = RanluxppData<p>::kA;
109 int numBits = 64 - offset;
111 uint64_t bits =
fState[idx] >> offset;
113 bits |=
fState[idx + 1] << numBits;
115 bits &= ((uint64_t(1) << w) - 1);
126 static constexpr double div = 1.0 / (uint64_t(1) << w);
136 for (
int i = 1; i < 9; i++) {
143 powermod(a_seed, a_seed, uint64_t(1) << 48);
156 assert(left >= 0 &&
"position was out of range!");
157 if (
n < (uint64_t)left) {
167 int skip = (
n / nPerState);
178 int remaining =
n - skip * nPerState;
179 assert(remaining >= 0 &&
"should not end up at a negative position!");
188 fImpl->SetSeed(seed);
203 return fImpl->NextRandomFloat();
209 return fImpl->NextRandomBits();
215 fImpl->SetSeed(seed);
unsigned fCarry
Carry bit of the RANLUX state.
uint64_t fState[9]
RANLUX state of the generator.
void Skip(uint64_t n)
Skip n random numbers without generating them.
static constexpr int kMaxPos
static constexpr const uint64_t * kA
uint64_t NextRandomBits()
Return the next random bits, generate a new block if necessary.
void SetSeed(uint64_t s)
Initialize and seed the state of the generator.
int fPosition
Current position in bits.
double NextRandomFloat()
Return a floating point number, converted from the next random bits.
void Advance()
Produce next block of random bits.
Implementation of the RANLUX++ generator.
uint64_t IntRndm()
Generate a random integer value with 48 bits.
std::unique_ptr< RanluxppEngineImpl< 48, p > > fImpl
double Rndm() override
Generate a double-precision random number with 48 bits of randomness.
void Skip(uint64_t n)
Skip n random numbers without generating them.
void SetSeed(uint64_t seed)
Initialize and seed the state of the generator.
double operator()()
Generate a double-precision random number (non-virtual method)
RanluxppEngine(uint64_t seed=314159265)
virtual ~RanluxppEngine()
static void mulmod(const uint64_t *in1, uint64_t *inout)
Combine multiply9x9 and mod_m with internal temporary storage.
static void powermod(const uint64_t *base, uint64_t *res, uint64_t n)
Compute base to the n modulo m.
Namespace for new Math classes and functions.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
static void to_lcg(const uint64_t *ranlux, unsigned c, uint64_t *lcg)
Convert RANLUX numbers to an LCG state.
static void to_ranlux(const uint64_t *lcg, uint64_t *ranlux, unsigned &c_out)
Convert an LCG state to RANLUX numbers.