15#ifndef ARCANE_CORE_RANDOM_INVERSIVECONGRUENTIAL_H
16#define ARCANE_CORE_RANDOM_INVERSIVECONGRUENTIAL_H
20#include "arcane/utils/FatalErrorException.h"
22#include "arcane/core/random/RandomGlobal.h"
27namespace Arcane::random
48template <
typename IntType, IntType a, IntType c, IntType m, IntType val>
53 typedef IntType result_type;
54 static const bool has_fixed_range =
true;
55 static const result_type min_value = (c == 0 ? 1 : 0);
56 static const result_type max_value = m - 1;
66 result_type
min()
const {
return c == 0 ? 1 : 0; }
76 result_type
max()
const {
return m - 1; }
100 void seed(IntType x0) { _x = x0; }
140 return x = do_mod::mult_add(a, do_mod::invert(x), c);
174typedef InversiveCongruential<
Int32, 9102, 2147483647 - 36884165,
result_type max() const
Returns the maximum possible value of a sequence.
result_type min() const
Returns the minimum possible value of a sequence.
IntType operator()()
Overriding the operator () which returns the pseudo random value of the generator....
bool validation(IntType x) const
Validation function (I don't really know what it is for!).
static IntType apply(IntType x)
Returns the pseudo-random value from the state x. The private member _x of the generator is not used ...
void seed(IntType x0)
Initialization of the generator seed from the value x0.
bool operator==(const InversiveCongruential &rhs) const
Overriding the == operator.
IntType getState() const
Method that returns the generator state.
InversiveCongruential(IntType x0=1)
Constructor with seed initialization from the value x0.
std::int32_t Int32
Signed integer type of 32 bits.