vSMC  v3.0.0
Scalable Monte Carlo
Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
vsmc::CounterEngine< ResultType, Generator > Class Template Reference

Counter based RNG engine. More...

#include <vsmc/rng/counter.hpp>

Public Types

using ctr_type = typename generator_type::ctr_type
 
using generator_type = Generator
 
using key_type = typename generator_type::key_type
 
using result_type = ResultType
 
using skip_type = typename ctr_type::value_type
 

Public Member Functions

 CounterEngine (result_type s=1)
 
template<typename SeedSeq >
 CounterEngine (SeedSeq &seq, typename std::enable_if< internal::is_seed_seq< SeedSeq, ResultType, key_type, CounterEngine< ResultType, Generator >>::value >::type *=nullptr)
 
 CounterEngine (const key_type &k)
 
void ctr (const ctr_type &c)
 
std::size_t discard ()
 Discard the buffer. More...
 
void discard (skip_type nskip)
 
void key (const key_type &k)
 
result_type operator() ()
 
void operator() (std::size_t n, result_type *r)
 
void seed (result_type s)
 
template<typename SeedSeq >
void seed (SeedSeq &seq, typename std::enable_if< internal::is_seed_seq< SeedSeq, ResultType, key_type >::value >::type *=nullptr)
 
void seed (const key_type &key)
 

Static Public Member Functions

static constexpr result_type max ()
 
static constexpr result_type min ()
 

Friends

bool operator!= (const CounterEngine< ResultType, Generator > &eng1, const CounterEngine< ResultType, Generator > &eng2)
 eng1 != eng2 is a necessary condition for subsequent call of operator() output different results. But it is not a sufficient condition. More...
 
template<typename CharT , typename Traits >
std::basic_ostream< CharT, Traits > & operator<< (std::basic_ostream< CharT, Traits > &os, const CounterEngine< ResultType, Generator > &eng)
 
bool operator== (const CounterEngine< ResultType, Generator > &eng1, const CounterEngine< ResultType, Generator > &eng2)
 eng1 == eng2 is a sufficent condition for subsequent call of operator() output the same results. But it is not a necessary condition. More...
 
template<typename CharT , typename Traits >
std::basic_istream< CharT, Traits > & operator>> (std::basic_istream< CharT, Traits > &is, CounterEngine< ResultType, Generator > &eng)
 

Detailed Description

template<typename ResultType, typename Generator>
class vsmc::CounterEngine< ResultType, Generator >

Counter based RNG engine.

Template Parameters
ResultTypeThe ouptut integer type of the counter-based RNG engine
GeneratorThe generator that transfer counter and key to random integer buffer.
  • Requirement
    ctr_type; // counter type
    key_type; // key type
    static constexpr std::size_t size(); // Size of buffer in bytes
    void reset(const key_type &key); // reset generator key
    // Increment counter and generate one random buffer
    std::array<ResultType, size() / sizeof(ResultType)> &buffer);
    // Increment counter and generate n random buffers
    void operator()(ctr_type &ctr, std::size_t n,
    std::array<ResultType, size() / sizeof(ResultType)> *buffer);
  • Restrictions: size() % sizeof(ResultType) == 0

Definition at line 187 of file counter.hpp.

Member Typedef Documentation

template<typename ResultType, typename Generator>
using vsmc::CounterEngine< ResultType, Generator >::ctr_type = typename generator_type::ctr_type

Definition at line 200 of file counter.hpp.

template<typename ResultType, typename Generator>
using vsmc::CounterEngine< ResultType, Generator >::generator_type = Generator

Definition at line 199 of file counter.hpp.

template<typename ResultType, typename Generator>
using vsmc::CounterEngine< ResultType, Generator >::key_type = typename generator_type::key_type

Definition at line 201 of file counter.hpp.

template<typename ResultType, typename Generator>
using vsmc::CounterEngine< ResultType, Generator >::result_type = ResultType

Definition at line 198 of file counter.hpp.

template<typename ResultType, typename Generator>
using vsmc::CounterEngine< ResultType, Generator >::skip_type = typename ctr_type::value_type

Definition at line 202 of file counter.hpp.

Constructor & Destructor Documentation

template<typename ResultType, typename Generator>
vsmc::CounterEngine< ResultType, Generator >::CounterEngine ( result_type  s = 1)
inlineexplicit

Definition at line 204 of file counter.hpp.

template<typename ResultType, typename Generator>
template<typename SeedSeq >
vsmc::CounterEngine< ResultType, Generator >::CounterEngine ( SeedSeq &  seq,
typename std::enable_if< internal::is_seed_seq< SeedSeq, ResultType, key_type, CounterEngine< ResultType, Generator >>::value >::type *  = nullptr 
)
inlineexplicit

Definition at line 207 of file counter.hpp.

template<typename ResultType, typename Generator>
vsmc::CounterEngine< ResultType, Generator >::CounterEngine ( const key_type k)
inlineexplicit

Definition at line 216 of file counter.hpp.

Member Function Documentation

template<typename ResultType, typename Generator>
void vsmc::CounterEngine< ResultType, Generator >::ctr ( const ctr_type c)
inline

Definition at line 242 of file counter.hpp.

template<typename ResultType, typename Generator>
std::size_t vsmc::CounterEngine< ResultType, Generator >::discard ( )
inline

Discard the buffer.

Definition at line 284 of file counter.hpp.

template<typename ResultType, typename Generator>
void vsmc::CounterEngine< ResultType, Generator >::discard ( skip_type  nskip)
inline

Definition at line 292 of file counter.hpp.

template<typename ResultType, typename Generator>
void vsmc::CounterEngine< ResultType, Generator >::key ( const key_type k)
inline

Definition at line 240 of file counter.hpp.

template<typename ResultType, typename Generator>
static constexpr result_type vsmc::CounterEngine< ResultType, Generator >::max ( )
inlinestatic

Definition at line 319 of file counter.hpp.

template<typename ResultType, typename Generator>
static constexpr result_type vsmc::CounterEngine< ResultType, Generator >::min ( )
inlinestatic

Definition at line 314 of file counter.hpp.

template<typename ResultType, typename Generator>
result_type vsmc::CounterEngine< ResultType, Generator >::operator() ( )
inline

Definition at line 248 of file counter.hpp.

template<typename ResultType, typename Generator>
void vsmc::CounterEngine< ResultType, Generator >::operator() ( std::size_t  n,
result_type r 
)
inline

Definition at line 258 of file counter.hpp.

template<typename ResultType, typename Generator>
void vsmc::CounterEngine< ResultType, Generator >::seed ( result_type  s)
inline

Definition at line 218 of file counter.hpp.

template<typename ResultType, typename Generator>
template<typename SeedSeq >
void vsmc::CounterEngine< ResultType, Generator >::seed ( SeedSeq &  seq,
typename std::enable_if< internal::is_seed_seq< SeedSeq, ResultType, key_type >::value >::type *  = nullptr 
)
inline

Definition at line 227 of file counter.hpp.

template<typename ResultType, typename Generator>
void vsmc::CounterEngine< ResultType, Generator >::seed ( const key_type key)
inline

Definition at line 238 of file counter.hpp.

Friends And Related Function Documentation

template<typename ResultType, typename Generator>
bool operator!= ( const CounterEngine< ResultType, Generator > &  eng1,
const CounterEngine< ResultType, Generator > &  eng2 
)
friend

eng1 != eng2 is a necessary condition for subsequent call of operator() output different results. But it is not a sufficient condition.

Definition at line 344 of file counter.hpp.

template<typename ResultType, typename Generator>
template<typename CharT , typename Traits >
std::basic_ostream<CharT, Traits>& operator<< ( std::basic_ostream< CharT, Traits > &  os,
const CounterEngine< ResultType, Generator > &  eng 
)
friend

Definition at line 351 of file counter.hpp.

template<typename ResultType, typename Generator>
bool operator== ( const CounterEngine< ResultType, Generator > &  eng1,
const CounterEngine< ResultType, Generator > &  eng2 
)
friend

eng1 == eng2 is a sufficent condition for subsequent call of operator() output the same results. But it is not a necessary condition.

Definition at line 327 of file counter.hpp.

template<typename ResultType, typename Generator>
template<typename CharT , typename Traits >
std::basic_istream<CharT, Traits>& operator>> ( std::basic_istream< CharT, Traits > &  is,
CounterEngine< ResultType, Generator > &  eng 
)
friend

Definition at line 367 of file counter.hpp.