Gromacs
2023.1

#include <gromacs/random/threefry.h>
ThreeFry2x64 random engine with 13 iteractions.
internalCounterBits,default  64. 
This class provides relatively high quality random numbers that only fail one BigCrush test, and it is a bit faster than the 20round version. It works with two 64bit 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 Types  
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.  
Public Member Functions  
ThreeFry2x64Fast (uint64_t key0=0, RandomDomain domain=RandomDomain::Other)  
Construct ThreeFry random engine with 2x64 key values, 13 rounds. More...  
ThreeFry2x64Fast (uint64_t key0, uint64_t key1)  
Construct ThreeFry random engine from 2x64bit unsigned integers, 13 rounds. More...  
void  seed (uint64_t key0=0, RandomDomain domain=RandomDomain::Other) 
Seed 2x64 random engine with two 64bit key values. More...  
void  seed (uint64_t key0, uint64_t key1) 
Seed random engine from 2x64bit unsigned integers. More...  
void  restart (uint64_t ctr0=0, uint64_t ctr1=0) 
Restart 2x64 random engine counter from 2 64bit 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...  
Static Public Member Functions  
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.  

inline 
Construct ThreeFry random engine with 2x64 key values, 13 rounds.
key0  Random seed in the form of a 64bit unsigned value. 
domain  Random 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. 
InternalError  if the high bits needed to encode the number of counter bits are nonzero. 

inline 
Construct ThreeFry random engine from 2x64bit unsigned integers, 13 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.
key0  First word of key/random seed. 
key1  Second word of key/random seed. 
InternalError  if the high bits needed to encode the number of counter bits are nonzero. To test arbitrary values, use 0 internal counter bits. 

inlineinherited 
Skip next n random numbers.
Moves the internal random stream for the give key/counter value n positions forward. The count is based on the number of random values returned, such that skipping 5 values gives exactly the same result as drawing 5 values that are ignored.
n  Number of values to jump forward. 
InternalError  if the internal counter space is exhausted. 

inlineinherited 
Return true of two ThreeFry2x64 engines are not identical.
x  Instance to compare with. 
This routine should return true if the two engines will generate different random streams when drawing.

inlineinherited 
Generate the next random number.
This will return the next stored 64bit value if one is available, and otherwise generate a new block, update the internal counters, and return the first value while storing the others.
InternalError  if the internal counter space is exhausted. 

inlineinherited 
Return true if two ThreeFry2x64 engines are identical.
x  Instance to compare with. 
This routine should return true if the two engines will generate identical random streams when drawing.

inlineinherited 
Restart 2x64 random engine counter from 2 64bit values.
ctr0  First word of new counter, in the form of 64bit unsigned values. 
ctr1  Second word of new counter 
Restarting the engine with a new counter is extremely fast with ThreeFry64, and basically just consists of storing the counter value, so you should use this liberally in your innermost loops to restart the engine with e.g. the current step and atom index as counter values.
InternalError  if any of the highest bits that are reserved for the internal part of the counter are set. The number of reserved bits is to the last template parameter to the class. 

inlineinherited 
Seed 2x64 random engine with two 64bit key values.
key0  First word of random seed, in the form of 64bit unsigned values. 
domain  Random 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. 
Reinitialized the seed similar to the counter constructor. Same rules apply: The highest few bits of the last word are reserved to encode the number of internal counter bits, but to save the user the trouble of making sure these are zero when using e.g. a random device, we just ignore them.

inlineinherited 
Seed random engine from 2x64bit unsigned integers.
This 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.
key0  First word of key/random seed. 
key1  Second word of key/random seed. 
InternalError  if the high bits needed to encode the number of counter bits are nonzero. To test arbitrary values, use 0 internal counter bits. 