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

Seed generator. More...

#include <vsmc/rng/seed.hpp>

Public Types

using result_type = ResultType
 

Public Member Functions

 SeedGenerator (const SeedGenerator< ID, ResultType > &)=delete
 
result_type divisor () const
 The divisor of the output seed. More...
 
result_type get ()
 Get a seed. More...
 
result_type max () const
 The maximum of the seed. More...
 
void modulo (result_type divisor, result_type remainder)
 Set the divisor and the remainder. More...
 
template<typename RNGType >
void operator() (RNGType &rng)
 Seed a single RNG. More...
 
template<typename OutputIter >
OutputIter operator() (std::size_t n, OutputIter first)
 Seed a sequence of RNGs. More...
 
SeedGenerator< ID, ResultType > & operator= (const SeedGenerator< ID, ResultType > &)=delete
 
result_type remainder () const
 The remainder of the output seed. More...
 
void set (result_type s)
 Set the seed to s % max() * divisor() + remainder() More...
 

Static Public Member Functions

static SeedGenerator< ID, ResultType > & instance ()
 

Friends

template<typename CharT , typename Traits >
std::basic_ostream< CharT, Traits > & operator<< (std::basic_ostream< CharT, Traits > &os, const SeedGenerator< ID, ResultType > &sg)
 
template<typename CharT , typename Traits >
std::basic_istream< CharT, Traits > & operator>> (std::basic_istream< CharT, Traits > &is, SeedGenerator< ID, ResultType > &sg)
 

Detailed Description

template<typename ID, typename ResultType = unsigned>
class vsmc::SeedGenerator< ID, ResultType >

Seed generator.

The sequence of seeds are belongs to the equivalent class \(s \mod D \equiv R\) where \(D > 0\), \(R \ge 0\). The defaults are \(1\) and \(0\) respectively. Each time get() is called, a new seed is returned.

The method operator()(RNGType &rng) is equivalent to rng.seed(static_cast<typename RNGType::result_type>(get())).

Definition at line 68 of file seed.hpp.

Member Typedef Documentation

template<typename ID, typename ResultType = unsigned>
using vsmc::SeedGenerator< ID, ResultType >::result_type = ResultType

Definition at line 75 of file seed.hpp.

Constructor & Destructor Documentation

template<typename ID, typename ResultType = unsigned>
vsmc::SeedGenerator< ID, ResultType >::SeedGenerator ( const SeedGenerator< ID, ResultType > &  )
delete

Member Function Documentation

template<typename ID, typename ResultType = unsigned>
result_type vsmc::SeedGenerator< ID, ResultType >::divisor ( ) const
inline

The divisor of the output seed.

Definition at line 125 of file seed.hpp.

template<typename ID, typename ResultType = unsigned>
result_type vsmc::SeedGenerator< ID, ResultType >::get ( )
inline

Get a seed.

Definition at line 112 of file seed.hpp.

template<typename ID, typename ResultType = unsigned>
static SeedGenerator<ID, ResultType>& vsmc::SeedGenerator< ID, ResultType >::instance ( )
inlinestatic

Definition at line 82 of file seed.hpp.

template<typename ID, typename ResultType = unsigned>
result_type vsmc::SeedGenerator< ID, ResultType >::max ( ) const
inline

The maximum of the seed.

Definition at line 122 of file seed.hpp.

template<typename ID, typename ResultType = unsigned>
void vsmc::SeedGenerator< ID, ResultType >::modulo ( result_type  divisor,
result_type  remainder 
)
inline

Set the divisor and the remainder.

Definition at line 131 of file seed.hpp.

template<typename ID, typename ResultType = unsigned>
template<typename RNGType >
void vsmc::SeedGenerator< ID, ResultType >::operator() ( RNGType &  rng)
inline

Seed a single RNG.

Definition at line 91 of file seed.hpp.

template<typename ID, typename ResultType = unsigned>
template<typename OutputIter >
OutputIter vsmc::SeedGenerator< ID, ResultType >::operator() ( std::size_t  n,
OutputIter  first 
)
inline

Seed a sequence of RNGs.

Definition at line 98 of file seed.hpp.

template<typename ID, typename ResultType = unsigned>
SeedGenerator<ID, ResultType>& vsmc::SeedGenerator< ID, ResultType >::operator= ( const SeedGenerator< ID, ResultType > &  )
delete
template<typename ID, typename ResultType = unsigned>
result_type vsmc::SeedGenerator< ID, ResultType >::remainder ( ) const
inline

The remainder of the output seed.

Definition at line 128 of file seed.hpp.

template<typename ID, typename ResultType = unsigned>
void vsmc::SeedGenerator< ID, ResultType >::set ( result_type  s)
inline

Set the seed to s % max() * divisor() + remainder()

Definition at line 109 of file seed.hpp.

Friends And Related Function Documentation

template<typename ID, typename ResultType = unsigned>
template<typename CharT , typename Traits >
std::basic_ostream<CharT, Traits>& operator<< ( std::basic_ostream< CharT, Traits > &  os,
const SeedGenerator< ID, ResultType > &  sg 
)
friend

Definition at line 145 of file seed.hpp.

template<typename ID, typename ResultType = unsigned>
template<typename CharT , typename Traits >
std::basic_istream<CharT, Traits>& operator>> ( std::basic_istream< CharT, Traits > &  is,
SeedGenerator< ID, ResultType > &  sg 
)
friend

Definition at line 161 of file seed.hpp.