20#include "arcane/std/PDESRandomNumberGeneratorService.h"
35 m_seed =
options()->getInitialSeed();
69 return m_size_of_seed;
78 _ran4(&m_seed, leap - 1);
90 if (parent_seed.
size() != m_size_of_seed) {
97 _ran4(i_seed, leap - 1);
108 return _ran4(&m_seed, leap);
115 if (seed.
size() != m_size_of_seed) {
134_breakupUInt64(uint64_t uint64_in, uint32_t* front_bits, uint32_t* back_bits)
136 *front_bits =
static_cast<uint32_t
>(uint64_in >> 32);
137 *back_bits =
static_cast<uint32_t
>(uint64_in & 0xffffffff);
150 uint64_t reconstructed, temp;
151 reconstructed =
static_cast<uint64_t
>(front_bits);
152 temp =
static_cast<uint64_t
>(back_bits);
155 reconstructed = reconstructed << 32;
159 reconstructed |= (temp & 0x00000000ffffffff);
161 return reconstructed;
176_psdes(uint32_t* lword, uint32_t* irword)
179 const uint32_t c1[] = { 0xbaa96887L, 0x1e17d32cL, 0x03bcdc3cL, 0x0f33d1b2L };
180 const uint32_t c2[] = { 0x4b0f3b58L, 0xe874f0c3L, 0x6955c5a6L, 0x55a7ca46L };
182 for (
Integer i = 0; i < NITER; i++) {
183 uint32_t iswap = (*irword);
184 uint32_t ia = iswap ^ c1[i];
185 uint32_t itmpl = ia & 0xffff;
186 uint32_t itmph = ia >> 16;
187 uint32_t ib = itmpl * itmpl + ~(itmph * itmph);
189 *irword = (*lword) ^ (((ia = (ib >> 16) | ((ib & 0xffff) << 16)) ^ c2[i]) + itmpl * itmph);
203 uint32_t front_bits, back_bits;
206 _psdes(&front_bits, &back_bits);
228 uint32_t front_bits, back_bits, irword, lword;
#define ARCANE_FATAL(...)
Macro throwing a FatalErrorException.
CaseOptionsPDESRandomNumberGenerator * options() const
Options du jeu de données du service.
constexpr const_pointer data() const noexcept
Pointer to the start of the view.
constexpr Integer size() const noexcept
Returns the size of the array.
ByteConstArrayView viewSeed() override
Method allowing retrieval of a constant view of the current seed.
ByteUniqueArray generateRandomSeed(Integer leap=0) override
Method allowing generation of a "child" seed from a "parent" seed.
uint64_t _hashState(uint64_t initial_number)
Method to generate a new seed using the pseudo-DES algorithm.
Real generateRandomNumber(Integer leap) override
Method allowing generation of a random number using the seed in memory.
Integer neededSizeOfSeed() override
Method allowing knowledge of the seed size required for the implementation.
bool initSeed() override
Method allowing initialization of the service.
void _psdes(uint32_t *lword, uint32_t *irword)
Pseudo-DES algorithm from the book: Numerical Recipes in C The Art of Scientific Computing Second Edi...
uint64_t _reconstructUInt64(uint32_t front_bits, uint32_t back_bits)
Method to combine two uint32s into a uint64.
ByteUniqueArray emptySeed() override
Method allowing retrieval of an empty seed of the correct size.
void _breakupUInt64(uint64_t uint64_in, uint32_t *front_bits, uint32_t *back_bits)
Method to split a uint64 into two uint32s.
Real _ran4(Int64 *seed, Integer leap)
Method to generate pseudo-random numbers from a seed.
Class allowing easy manipulation of a seed.
bool value(T &value_out, bool without_size_check=true) const
Method allowing retrieval of the seed value.
Integer sizeOfSeed() const
Method allowing retrieval of the seed size.
ByteConstArrayView constView() const
Method allowing retrieval of a constant view.
ByteUniqueArray copy()
Method allowing retrieval of a copy of the Byte array.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
ArrayView< Byte > ByteArrayView
C equivalent of a 1D array of characters.
std::int64_t Int64
Signed integer type of 64 bits.
Int32 Integer
Type representing an integer.
UniqueArray< Byte > ByteUniqueArray
Dynamic 1D array of characters.
double Real
Type representing a real number.
ConstArrayView< Byte > ByteConstArrayView
C equivalent of a 1D array of characters.