Gromacs  2020.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
List of all members | Public Member Functions
gmx::ThreeFry2x64< internalCounterBits > Class Template Reference

#include <gromacs/random/threefry.h>

+ Inheritance diagram for gmx::ThreeFry2x64< internalCounterBits >:
+ Collaboration diagram for gmx::ThreeFry2x64< internalCounterBits >:

Description

template<unsigned int internalCounterBits = 64>
class gmx::ThreeFry2x64< internalCounterBits >

ThreeFry2x64 random engine with 20 iteractions.

Template Parameters
internalCounterBits,default64.

This class provides very high quality random numbers that pass all BigCrush tests, it works with two 64-bit values each for keys and counters, and is most efficient when we only need a few random values before restarting the counters with new values.

Public Member Functions

 ThreeFry2x64 (uint64_t key0=0, RandomDomain domain=RandomDomain::Other)
 Construct ThreeFry random engine with 2x64 key values, 20 rounds. More...
 
 ThreeFry2x64 (uint64_t key0, uint64_t key1)
 Construct random engine from 2x64-bit unsigned integers, 20 rounds. More...
 
- Public Member Functions inherited from gmx::ThreeFry2x64General< 20, internalCounterBits >
 ThreeFry2x64General (uint64_t key0=0, RandomDomain domain=RandomDomain::Other)
 Construct random engine with 2x64 key values. More...
 
 ThreeFry2x64General (uint64_t key0, uint64_t key1)
 Construct random engine from 2x64-bit unsigned integers. More...
 
void seed (uint64_t key0=0, RandomDomain domain=RandomDomain::Other)
 Seed 2x64 random engine with two 64-bit key values. More...
 
void seed (uint64_t key0, uint64_t key1)
 Seed random engine from 2x64-bit unsigned integers. More...
 
void restart (uint64_t ctr0=0, uint64_t ctr1=0)
 Restart 2x64 random engine counter from 2 64-bit values. More...
 
result_type operator() ()
 Generate the next random number. More...
 
void discard (uint64_t n)
 Skip next n random numbers. More...
 
bool operator== (const ThreeFry2x64General< rounds, internalCounterBits > &x) const
 Return true if two ThreeFry2x64 engines are identical. More...
 
bool operator!= (const ThreeFry2x64General< rounds, internalCounterBits > &x) const
 Return true of two ThreeFry2x64 engines are not identical. More...
 

Additional Inherited Members

- Public Types inherited from gmx::ThreeFry2x64General< 20, internalCounterBits >
typedef uint64_t result_type
 Integer type for output.
 
typedef std::array
< result_type, 2 > 
counter_type
 Use array for counter & key states so it is allocated on the stack.
 
- Static Public Member Functions inherited from gmx::ThreeFry2x64General< 20, internalCounterBits >
static constexpr result_type min ()
 Smallest value that can be returned from random engine.
 
static constexpr result_type max ()
 Largest value that can be returned from random engine.
 

Constructor & Destructor Documentation

template<unsigned int internalCounterBits = 64>
gmx::ThreeFry2x64< internalCounterBits >::ThreeFry2x64 ( uint64_t  key0 = 0,
RandomDomain  domain = RandomDomain::Other 
)
inline

Construct ThreeFry random engine with 2x64 key values, 20 rounds.

Parameters
key0Random seed in the form of a 64-bit unsigned value.
domainRandom domain. This is used to guarantee that different applications of a random engine inside the code get different streams of random numbers, without requiring the user to provide lots of random seeds. Pick a value from the RandomDomain class, or RandomDomain::Other if it is not important. In the latter case you might want to use gmx::DefaultRandomEngine instead.
Note
The random domain is really another 64-bit seed value.
Exceptions
InternalErrorif the high bits needed to encode the number of counter bits are nonzero.
template<unsigned int internalCounterBits = 64>
gmx::ThreeFry2x64< internalCounterBits >::ThreeFry2x64 ( uint64_t  key0,
uint64_t  key1 
)
inline

Construct random engine from 2x64-bit unsigned integers, 20 rounds.

This constructor assigns the raw 128 bit key data from unsigned integers. It is meant for the case when you want full control over the key, for instance to compare with reference values of the ThreeFry function during testing.

Parameters
key0First word of key/random seed.
key1Second word of key/random seed.
Exceptions
InternalErrorif the high bits needed to encode the number of counter bits are nonzero. To test arbitrary values, use 0 internal counter bits.

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