ATLAS Offline Software
Loading...
Searching...
No Matches
FastReseededPRNG Class Reference

#include <FastReseededPRNG.h>

Collaboration diagram for FastReseededPRNG:

Public Types

using result_type = std::uint64_t

Public Member Functions

template<typename... Int>
 FastReseededPRNG (Int... seed)
 FastReseededPRNG ()=delete
result_type operator() ()

Static Public Member Functions

static constexpr result_type min ()
static constexpr result_type max ()

Private Member Functions

void set_seed (const std::uint64_t *start, std::size_t len)
std::uint64_t next ()

Private Attributes

std::array< std::uint64_t, 2 > m_seed_arr

Detailed Description

Definition at line 28 of file FastReseededPRNG.h.

Member Typedef Documentation

◆ result_type

using FastReseededPRNG::result_type = std::uint64_t

Definition at line 30 of file FastReseededPRNG.h.

Constructor & Destructor Documentation

◆ FastReseededPRNG() [1/2]

template<typename... Int>
FastReseededPRNG::FastReseededPRNG ( Int... seed)
inline

Definition at line 32 of file FastReseededPRNG.h.

32 {
33 const std::array<std::uint64_t, sizeof...(seed)> seed_array{
34 static_cast<std::uint64_t>(seed)...};
35 set_seed(seed_array.data(), seed_array.size());
36 }
void set_seed(const std::uint64_t *start, std::size_t len)

◆ FastReseededPRNG() [2/2]

FastReseededPRNG::FastReseededPRNG ( )
delete

Member Function Documentation

◆ max()

constexpr result_type FastReseededPRNG::max ( )
inlinestaticconstexpr

Definition at line 40 of file FastReseededPRNG.h.

40 {
41 return std::numeric_limits<std::uint64_t>::max();
42 }

◆ min()

constexpr result_type FastReseededPRNG::min ( )
inlinestaticconstexpr

Definition at line 39 of file FastReseededPRNG.h.

39{ return 0; }

◆ next()

std::uint64_t FastReseededPRNG::next ( )
private

Definition at line 46 of file FastReseededPRNG.cxx.

46 {
47 const std::uint64_t s0 = m_seed_arr[0];
48 std::uint64_t s1 = m_seed_arr[1];
49 const std::uint64_t result = rotl(s0 * 5, 7) * 9;
50
51 s1 ^= s0;
52 m_seed_arr[0] = rotl(s0, 24) ^ s1 ^ (s1 << 16); // a, b
53 m_seed_arr[1] = rotl(s1, 37); // c
54
55 return result;
56}
static Double_t s0
std::array< std::uint64_t, 2 > m_seed_arr

◆ operator()()

FastReseededPRNG::result_type FastReseededPRNG::operator() ( )

Definition at line 28 of file FastReseededPRNG.cxx.

28 {
29 return next();
30}
std::uint64_t next()

◆ set_seed()

void FastReseededPRNG::set_seed ( const std::uint64_t * start,
std::size_t len )
private

Definition at line 33 of file FastReseededPRNG.cxx.

33 {
34 const auto hash = XXH3_128bits(start, sizeof(std::uint64_t) * len);
35 m_seed_arr[0] = hash.high64;
36 m_seed_arr[1] = hash.low64;
37}
XXH_PUBLIC_API XXH_PUREF XXH128_hash_t XXH3_128bits(XXH_NOESCAPE const void *data, size_t len)
Unseeded 128-bit variant of XXH3.

Member Data Documentation

◆ m_seed_arr

std::array<std::uint64_t, 2> FastReseededPRNG::m_seed_arr
private

Definition at line 47 of file FastReseededPRNG.h.


The documentation for this class was generated from the following files: