SUNphi  1.0
SUNphi::Sitmo::Rng Class Reference

Class encapsulating the Sitmo random generator. More...

#include <Sitmo2.hpp>

Inheritance diagram for SUNphi::Sitmo::Rng:
SUNphi::SerializableClass< Rng >

Classes

class  State
 Holds the state of the generator. More...
 

Public Types

using ResultType = uint32_t
 Type returned.
 

Public Member Functions

auto serializableMembers ()
 
auto serializableMembers () const
 
template<typename F >
void seed (F &f)
 Draw a seed from a random generator. More...
 
void seed (const uint32_t &s)
 Seed from a seed. More...
 
ResultType generateNth (const uint64_t &offset)
 Generate a number with a given offset w.r.t current state. More...
 
bool reserve (const uint64_t &n)
 Reserve a number of random number.
 
bool release ()
 Release the reserved number of random number, increasing the state.
 
auto scopeReserve (const uint64_t &n)
 
void skip (const uint64_t &n)
 Skip n numbers.
 
ResultType generateNext ()
 Generate a number in the current stream and increase of 1. More...
 
 Rng (const uint32_t &s=DEFAULT_SEED)
 Default constructor.
 
Rngoperator~ ()
 
const Rngoperator~ () const
 
bool isDefault () const
 Check if the class is default. More...
 
YAML::Node serialize (YAML::Node &node, const bool &onlyNonDefault=false) const
 Convert to YAML node. More...
 
YAML::Node serialize (const bool &onlyNonDefault=false) const
 Convert to YAML node. More...
 
void putToDefault ()
 Put the class to the default value.
 
void checkNoSpuriousSubNodes (const YAML::Node &node)
 Check that no spurious subnodes are contained. More...
 
bool deSerialize (const YAML::Node &node)
 Convert from a YAML node. More...
 
Binarizerbinarize (B &&out={}) const
 Convert to binary. More...
 
BinarizerdeBinarize (B &&in)
 Convert from binary. More...
 

Private Member Functions

bool lock ()
 Lock the generator.
 
bool unLock ()
 Unlock the generator.
 

Private Attributes

SerializableSequence< Keykey { "seed" ,}
 Seed, used to encrypt.
 
SerializableSequence< Statestate { "state" , }
 State of the random number generator.
 
uint64_t nReserved {0}
 Number of reserved random number.
 
bool locked {false}
 State whether the rng is locked or not.
 

Static Private Attributes

static constexpr uint32_t DEFAULT_SEED
 Default seed. More...
 

Detailed Description

Class encapsulating the Sitmo random generator.

Definition at line 38 of file Sitmo2.hpp.

Member Function Documentation

Binarizer& SUNphi::SerializableClass< Rng >::binarize ( B &&  out = {}) const
inlineinherited

Convert to binary.

Parameters
outOutput

Definition at line 165 of file Map.hpp.

void SUNphi::SerializableClass< Rng >::checkNoSpuriousSubNodes ( const YAML::Node &  node)
inlineinherited

Check that no spurious subnodes are contained.

Spurious list

Mark found or not

Expected name

Parameters
nodeNode to be checked

Definition at line 108 of file Map.hpp.

Binarizer& SUNphi::SerializableClass< Rng >::deBinarize ( B &&  in)
inlineinherited

Convert from binary.

Parameters
inInput

Definition at line 180 of file Map.hpp.

bool SUNphi::SerializableClass< Rng >::deSerialize ( const YAML::Node &  node)
inlineinherited

Convert from a YAML node.

Parameters
nodeNode from which to convert

Definition at line 146 of file Map.hpp.

ResultType SUNphi::Sitmo::Rng::generateNext ( )
inline

Generate a number in the current stream and increase of 1.

Holds the lock on the stream

Definition at line 262 of file Sitmo2.hpp.

ResultType SUNphi::Sitmo::Rng::generateNth ( const uint64_t &  offset)
inline

Generate a number with a given offset w.r.t current state.

Temporary result of the encyipter

Output to be returned

Shifted state

Definition at line 185 of file Sitmo2.hpp.

bool SUNphi::SerializableClass< Rng >::isDefault ( ) const
inlineinherited

Check if the class is default.

Default value

Definition at line 53 of file Map.hpp.

Rng & SUNphi::SerializableClass< Rng >::operator~ ( )
inlineinherited

Cast operator to class T

Definition at line 50 of file Map.hpp.

const Rng & SUNphi::SerializableClass< Rng >::operator~ ( ) const
inlineinherited

Constant cast operator to class T

Definition at line 50 of file Map.hpp.

auto SUNphi::Sitmo::Rng::scopeReserve ( const uint64_t &  n)
inline

Reserves, returning a scope-locker

Automatically releases the lock and advances when the locker goes out of scope

Definition at line 239 of file Sitmo2.hpp.

template<typename F >
void SUNphi::Sitmo::Rng::seed ( F &  f)
inline

Draw a seed from a random generator.

Result type of the callabale generator

Number of calls to be issued to fill the state

Partial key

Access to the key in a way which allows to fill with the generator

Fill the key

Definition at line 145 of file Sitmo2.hpp.

void SUNphi::Sitmo::Rng::seed ( const uint32_t &  s)
inline

Seed from a seed.

Partial word to be used

Definition at line 174 of file Sitmo2.hpp.

auto SUNphi::Sitmo::Rng::serializableMembers ( ) const
inline

Gets the reference to the serializable members

Definition at line 141 of file Sitmo2.hpp.

auto SUNphi::Sitmo::Rng::serializableMembers ( )
inline

Gets the reference to the serializable members

Definition at line 141 of file Sitmo2.hpp.

YAML::Node SUNphi::SerializableClass< Rng >::serialize ( YAML::Node &  node,
const bool &  onlyNonDefault = false 
) const
inlineinherited

Convert to YAML node.

Parameters
nodeResulting node
onlyNonDefaultPrints only non-default

Definition at line 72 of file Map.hpp.

YAML::Node SUNphi::SerializableClass< Rng >::serialize ( const bool &  onlyNonDefault = false) const
inlineinherited

Convert to YAML node.

Resulting node

Parameters
onlyNonDefaultPrints only non-default

Definition at line 87 of file Map.hpp.

Member Data Documentation

constexpr uint32_t SUNphi::Sitmo::Rng::DEFAULT_SEED
staticprivate
Initial value:
=
3472291050

Default seed.

Definition at line 41 of file Sitmo2.hpp.


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