13#ifndef ARCANE_CORE_RANDOM_MRG32K3A_H
14#define ARCANE_CORE_RANDOM_MRG32K3A_H
18#include "arcane/utils/FatalErrorException.h"
20#include "arcane/core/random/RandomGlobal.h"
25namespace Arcane::random
48template <
typename RealType, Int32 val>
53 typedef RealType result_type;
54 typedef RealType state_type;
55 static const bool has_fixed_range =
true;
56 static const Int32 min_value = 0;
57 static const Int32 max_value = 1;
100 _state[0] = (state_type)x0;
101 _state[1] = _state[0];
102 _state[2] = _state[1];
103 _state[3] = _state[2];
104 _state[4] = _state[3];
105 _state[5] = _state[4];
145 static RealType
apply(state_type* state)
149 p = 1403580.0 * state[1] - 810728.0 * state[0];
150 k =
static_cast<long>(p / 4294967087.0);
151 p -= k * 4294967087.0;
158 p = 527612.0 * state[5] - 1370589.0 * state[3];
159 k =
static_cast<long>(p / 4294944443.0);
160 p -= k * 4294944443.0;
167 if (state[2] <= state[5])
168 return ((state[2] - state[5] + 4294967087.0) / 4294967087.0);
170 return ((state[2] - state[5]) / 4294967087.0);
181 result_type
min()
const {
return static_cast<result_type
>(min_value); }
191 result_type
max()
const {
return static_cast<result_type
>(max_value); }
213 return (_state[0] == rhs._state[0]) && (_state[1] == rhs._state[1]) && (_state[2] == rhs._state[2]) && (_state[3] == rhs._state[3]) && (_state[4] == rhs._state[4]) && (_state[5] == rhs._state[5]);
218 state_type _state[6];
224typedef TMrg32k3a<Real, 0> Mrg32k3a;
bool operator==(const TMrg32k3a &rhs) const
Overloading of the == operator.
static RealType apply(state_type *state)
Returns the pseudo-random value from the state. The generator state state must consist of six element...
result_type max() const
Returns the maximum possible value of a sequence.
result_type min() const
Returns the minimum possible value of a sequence.
RealType getState(Integer i) const
Method that returns the generator state for index i. The complete state of the generator is given by ...
TMrg32k3a(state_type *state)
Constructor initializing the seed array from the state array. state must be an array of six elements.
void seed(Int32 x0)
Initialization of the seed array from the value x0. The seed array of this generator consists of six ...
TMrg32k3a(Int32 x0=1)
Constructor initializing the seed array from the value x0. The seed(x0) method is called.
bool validation(RealType x) const
Validation function (I'm not sure what it's for!).
RealType operator()()
Overloading of the () operator which returns the pseudo random value of the generator....
Int32 Integer
Type representing an integer.
double Real
Type representing a real number.
std::int32_t Int32
Signed integer type of 32 bits.