SUNphi  1.0
SUNphi::Sitmo Class Reference

Class encapsulating the Sitmo random generator. More...

#include <Sitmo.hpp>

Public Types

using Key = std::array< uint64_t, 5 >
 Type of the key.
 
using Word = std::array< uint64_t, 4 >
 Encrypted word.
 

Public Member Functions

 Sitmo (const Sitmo &oth)
 Copy constructor. More...
 
 Sitmo (const uint32_t &s=0)
 Construct from a seed.
 
void setKey (const uint32_t &k0=0, const uint32_t &k1=0, const uint32_t &k2=0, const uint32_t &k3=0)
 Sets the key.
 
void seed (const uint32_t &s=0)
 Init using the passed seed.
 
uint32_t operator() ()
 Returns one of the 8 chunks.
 
void discard (uint64_t z)
 Advances e’s state ei to ei+z.
 
bool operator== (const Sitmo &y)
 Check that the two generators are the same.
 
bool operator!= (const Sitmo &y)
 Check that the two generators are different.
 
void set_counter (uint64_t s0=0, uint64_t s1=0, uint64_t s2=0, uint64_t s3=0, unsigned short o_counter=0)
 Set the counter.
 
Sitmooperator+= (const uint64_t z)
 Increments the counter by a given amount. More...
 
Sitmooperator++ (int)
 Unitary increment.
 

Static Public Attributes

static constexpr uint32_t max
 Maximal output. More...
 

Private Member Functions

void encryptCounter (std::array< uint64_t, 4 > &outputState) const
 Encrypts the counter, to set the state. More...
 

Private Attributes

std::array< uint64_t, 5 > key
 Key.
 
std::array< uint64_t, 4 > state
 State (counter)
 
union {
   std::array< uint64_t, 4 >   state
 
   std::array< uint32_t, 8 >   output
 
ciphered
 Cipher output: 4*64 bit=256 bit output.
 
unsigned short iChunk
 Output chunk counter: determines wihch 32 of the 256 random bits in cipheredState is returned.
 

Friends

template<class CharT , class Traits >
std::basic_ostream< CharT, Traits > & operator<< (std::basic_ostream< CharT, Traits > &os, const Sitmo &s)
 Output.
 
template<class CharT , class Traits >
std::basic_istream< CharT, Traits > & operator>> (std::basic_istream< CharT, Traits > &is, Sitmo &s)
 Input.
 

Detailed Description

Class encapsulating the Sitmo random generator.

Definition at line 43 of file Sitmo.hpp.

Constructor & Destructor Documentation

SUNphi::Sitmo::Sitmo ( const Sitmo oth)

Copy constructor.

Other engine

Member Function Documentation

void SUNphi::Sitmo::encryptCounter ( std::array< uint64_t, 4 > &  outputState) const
inlineprivate

Encrypts the counter, to set the state.

Copy of the state, to be modififed

Parameters
outputStateOutput state

Definition at line 62 of file Sitmo.hpp.

Sitmo& SUNphi::Sitmo::operator+= ( const uint64_t  z)
inline

Increments the counter by a given amount.

Take note of old value, to check for overflow

Digit to increment

Parameters
zAmount to increment

Definition at line 291 of file Sitmo.hpp.

Member Data Documentation

constexpr uint32_t SUNphi::Sitmo::max
static
Initial value:
=
0xFFFFFFFF

Maximal output.

Definition at line 132 of file Sitmo.hpp.


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