vSMC
vSMC: Scalable Monte Carlo
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Friends | List of all members
vsmc::XorshiftEngine< ResultType, K, A, B, C, D, R, S > Class Template Reference

Xorshift RNG engine. More...

#include <vsmc/rng/xorshift.hpp>

Public Types

typedef ResultType result_type
 

Public Member Functions

 XorshiftEngine (result_type s=1)
 
template<typename SeedSeq >
 XorshiftEngine (SeedSeq &seq, typename cxx11::enable_if< internal::is_seed_seq< SeedSeq, result_type, XorshiftEngine< ResultType, K, A, B, C, D, R, S > >::value >::type *=nullptr)
 
void discard (std::size_t nskip)
 
result_type operator() ()
 
void seed (result_type s)
 
template<typename SeedSeq >
void seed (SeedSeq &seq, typename cxx11::enable_if< internal::is_seed_seq< SeedSeq, result_type, XorshiftEngine< ResultType, K, A, B, C, D, R, S > >::value >::type *=nullptr)
 

Static Public Member Functions

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

Static Public Attributes

static constexpr const result_type _Max
 
static constexpr const result_type _Min = 0
 

Friends

bool operator!= (const XorshiftEngine< ResultType, K, A, B, C, D, R, S > &eng1, const XorshiftEngine< ResultType, K, A, B, C, D, R, S > &eng2)
 
template<typename CharT , typename Traits >
std::basic_ostream< CharT, Traits > & operator<< (std::basic_ostream< CharT, Traits > &os, const XorshiftEngine< ResultType, K, A, B, C, D, R, S > &eng)
 
bool operator== (const XorshiftEngine< ResultType, K, A, B, C, D, R, S > &eng1, const XorshiftEngine< ResultType, K, A, B, C, D, R, S > &eng2)
 
template<typename CharT , typename Traits >
std::basic_istream< CharT, Traits > & operator>> (std::basic_istream< CharT, Traits > &is, XorshiftEngine< ResultType, K, A, B, C, D, R, S > &eng)
 

Detailed Description

template<typename ResultType, std::size_t K, unsigned A, unsigned B, unsigned C, unsigned D, std::size_t R, std::size_t S>
class vsmc::XorshiftEngine< ResultType, K, A, B, C, D, R, S >

Xorshift RNG engine.

Use Marsaglia's Xorshift algorithm if K == 1, otherwise use Brent's improvement. Marsaglia's multi-words version is equivalent to set C = 0, R = K, and S = 1.

Template Parameters
ResultTypeAn unsigned 32- or 64-bits integer type
KNumber of integers of type ResultType representing the states
ABits of first left shift
BBits of first right shift
CBits of second left shift
DBits of second right shift (unused if K = 1)
RIndex of first xorshift (unused if K = 1)
SIndex of second xorshift (unused if K = 1)

Definition at line 214 of file xorshift.hpp.

Member Typedef Documentation

template<typename ResultType, std::size_t K, unsigned A, unsigned B, unsigned C, unsigned D, std::size_t R, std::size_t S>
typedef ResultType vsmc::XorshiftEngine< ResultType, K, A, B, C, D, R, S >::result_type

Definition at line 218 of file xorshift.hpp.

Constructor & Destructor Documentation

template<typename ResultType, std::size_t K, unsigned A, unsigned B, unsigned C, unsigned D, std::size_t R, std::size_t S>
vsmc::XorshiftEngine< ResultType, K, A, B, C, D, R, S >::XorshiftEngine ( result_type  s = 1)
inlineexplicit

Definition at line 220 of file xorshift.hpp.

template<typename ResultType, std::size_t K, unsigned A, unsigned B, unsigned C, unsigned D, std::size_t R, std::size_t S>
template<typename SeedSeq >
vsmc::XorshiftEngine< ResultType, K, A, B, C, D, R, S >::XorshiftEngine ( SeedSeq &  seq,
typename cxx11::enable_if< internal::is_seed_seq< SeedSeq, result_type, XorshiftEngine< ResultType, K, A, B, C, D, R, S > >::value >::type = nullptr 
)
inlineexplicit

Definition at line 229 of file xorshift.hpp.

Member Function Documentation

template<typename ResultType, std::size_t K, unsigned A, unsigned B, unsigned C, unsigned D, std::size_t R, std::size_t S>
void vsmc::XorshiftEngine< ResultType, K, A, B, C, D, R, S >::discard ( std::size_t  nskip)
inline

Definition at line 263 of file xorshift.hpp.

template<typename ResultType, std::size_t K, unsigned A, unsigned B, unsigned C, unsigned D, std::size_t R, std::size_t S>
static constexpr result_type vsmc::XorshiftEngine< ResultType, K, A, B, C, D, R, S >::max ( )
inlinestatic

Definition at line 274 of file xorshift.hpp.

template<typename ResultType, std::size_t K, unsigned A, unsigned B, unsigned C, unsigned D, std::size_t R, std::size_t S>
static constexpr result_type vsmc::XorshiftEngine< ResultType, K, A, B, C, D, R, S >::min ( )
inlinestatic

Definition at line 273 of file xorshift.hpp.

template<typename ResultType, std::size_t K, unsigned A, unsigned B, unsigned C, unsigned D, std::size_t R, std::size_t S>
result_type vsmc::XorshiftEngine< ResultType, K, A, B, C, D, R, S >::operator() ( )
inline

Definition at line 260 of file xorshift.hpp.

template<typename ResultType, std::size_t K, unsigned A, unsigned B, unsigned C, unsigned D, std::size_t R, std::size_t S>
void vsmc::XorshiftEngine< ResultType, K, A, B, C, D, R, S >::seed ( result_type  s)
inline

Definition at line 238 of file xorshift.hpp.

template<typename ResultType, std::size_t K, unsigned A, unsigned B, unsigned C, unsigned D, std::size_t R, std::size_t S>
template<typename SeedSeq >
void vsmc::XorshiftEngine< ResultType, K, A, B, C, D, R, S >::seed ( SeedSeq &  seq,
typename cxx11::enable_if< internal::is_seed_seq< SeedSeq, result_type, XorshiftEngine< ResultType, K, A, B, C, D, R, S > >::value >::type = nullptr 
)
inline

Definition at line 250 of file xorshift.hpp.

Friends And Related Function Documentation

template<typename ResultType, std::size_t K, unsigned A, unsigned B, unsigned C, unsigned D, std::size_t R, std::size_t S>
bool operator!= ( const XorshiftEngine< ResultType, K, A, B, C, D, R, S > &  eng1,
const XorshiftEngine< ResultType, K, A, B, C, D, R, S > &  eng2 
)
friend

Definition at line 281 of file xorshift.hpp.

template<typename ResultType, std::size_t K, unsigned A, unsigned B, unsigned C, unsigned D, std::size_t R, std::size_t S>
template<typename CharT , typename Traits >
std::basic_ostream<CharT, Traits>& operator<< ( std::basic_ostream< CharT, Traits > &  os,
const XorshiftEngine< ResultType, K, A, B, C, D, R, S > &  eng 
)
friend

Definition at line 287 of file xorshift.hpp.

template<typename ResultType, std::size_t K, unsigned A, unsigned B, unsigned C, unsigned D, std::size_t R, std::size_t S>
bool operator== ( const XorshiftEngine< ResultType, K, A, B, C, D, R, S > &  eng1,
const XorshiftEngine< ResultType, K, A, B, C, D, R, S > &  eng2 
)
friend

Definition at line 276 of file xorshift.hpp.

template<typename ResultType, std::size_t K, unsigned A, unsigned B, unsigned C, unsigned D, std::size_t R, std::size_t S>
template<typename CharT , typename Traits >
std::basic_istream<CharT, Traits>& operator>> ( std::basic_istream< CharT, Traits > &  is,
XorshiftEngine< ResultType, K, A, B, C, D, R, S > &  eng 
)
friend

Definition at line 300 of file xorshift.hpp.

Member Data Documentation

template<typename ResultType, std::size_t K, unsigned A, unsigned B, unsigned C, unsigned D, std::size_t R, std::size_t S>
constexpr const result_type vsmc::XorshiftEngine< ResultType, K, A, B, C, D, R, S >::_Max
static
Initial value:
= static_cast<result_type>(
~(static_cast<result_type>(0)))

Definition at line 270 of file xorshift.hpp.

template<typename ResultType, std::size_t K, unsigned A, unsigned B, unsigned C, unsigned D, std::size_t R, std::size_t S>
constexpr const result_type vsmc::XorshiftEngine< ResultType, K, A, B, C, D, R, S >::_Min = 0
static

Definition at line 269 of file xorshift.hpp.