Loading...
Searching...
No Matches
PLMD::Threefry2x64 Class Reference

Counter-based random numbers: Threefry2x64-20 (Salmon, Moraes, Dror and Shaw, "Parallel random numbers: as easy as 1, 2, 3", SC'11; the Random123 library). More...

#include <Threefry.h>

Public Types

using Block = std::array<std::uint64_t,2>
 

Public Member Functions

 Threefry2x64 (std::uint64_t key0=0, std::uint64_t key1=0)
 
std::uint64_t next ()
 Next 64 random bits of the stream.
 
void restart (std::uint64_t c0)
 Restart the stream at the counters (c0,0), (c0,1), ...
 
double U01 ()
 Uniform number in the open interval (0,1), 53-bit resolution (as Random::U01)
 

Static Public Member Functions

static Block block (const Block &counter, const Block &key)
 The Threefry2x64-20 function: one block of 128 random bits.
 

Private Attributes

Block buffer {}
 
Block counter {}
 
Block key
 
unsigned used = 2
 

Detailed Description

Counter-based random numbers: Threefry2x64-20 (Salmon, Moraes, Dror and Shaw, "Parallel random numbers: as easy as 1, 2, 3", SC'11; the Random123 library).

Each 128-bit output block is a function of a 128-bit key and a 128-bit counter only, and any keys and counters (also consecutive ones) give independent numbers. This gives reproducible numbers without storing a state, e.g. one stream per step with restart(step), as GROMACS does for replica exchange.

Member Typedef Documentation

◆ Block

using PLMD::Threefry2x64::Block = std::array<std::uint64_t,2>

Constructor & Destructor Documentation

◆ Threefry2x64()

PLMD::Threefry2x64::Threefry2x64 ( std::uint64_t key0 = 0,
std::uint64_t key1 = 0 )
explicit

Member Function Documentation

◆ block()

Threefry2x64::Block PLMD::Threefry2x64::block ( const Block & counter,
const Block & key )
static

The Threefry2x64-20 function: one block of 128 random bits.

◆ next()

std::uint64_t PLMD::Threefry2x64::next ( )

Next 64 random bits of the stream.

◆ restart()

void PLMD::Threefry2x64::restart ( std::uint64_t c0)

Restart the stream at the counters (c0,0), (c0,1), ...

◆ U01()

double PLMD::Threefry2x64::U01 ( )

Uniform number in the open interval (0,1), 53-bit resolution (as Random::U01)

Member Data Documentation

◆ buffer

Block PLMD::Threefry2x64::buffer {}
private

◆ counter

Block PLMD::Threefry2x64::counter {}
private

◆ key

Block PLMD::Threefry2x64::key
private

◆ used

unsigned PLMD::Threefry2x64::used = 2
private

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