std::tr1::subtract_with_carry

NAME

std::tr1::subtract_with_carry -

SYNOPSIS


Detailed Description

template<typename _IntType, _IntType __m, int __s, int __r> class std::tr1::subtract_with_carry< _IntType, __m, __s, __r >

This is a model of a Generalized Fibonacci discrete random number generator, sometimes referred to as the SWC generator.
A discrete random number generator that produces pseudorandom numbers using $x_{i}\leftarrow(x_{i - s} - x_{i - r} - carry_{i-1}) \bmod m $.
The size of the state is $ r $ and the maximum period of the generator is $ m^r - m^s -1 $.
N1688[4.13] says 'the template parameter _IntType shall denote an integral type large enough to store values up to m.'
Definition at line 668 of file random.

Public Types

typedef _IntType result_type

Public Member Functions

result_type max () const
result_type min () const
result_type operator() ()
template<class _Gen> void seed (_Gen &__g)
void seed (unsigned long __value=19780503)
template<class _Gen> subtract_with_carry (_Gen &__g)
subtract_with_carry (unsigned long __value)
subtract_with_carry ()

Static Public Attributes

static const int long_lag
static const _IntType modulus
static const int short_lag

Friends

bool operator!= (const subtract_with_carry &__lhs, const subtract_with_carry &__rhs)
template<typename _IntType1, _IntType1 __m1, int __s1, int __r1, typename _CharT, typename _Traits> std::basic_ostream< _CharT, _Traits > & operator<< (std::basic_ostream< _CharT, _Traits > &__os, const subtract_with_carry< _IntType1, __m1, __s1, __r1 > &__x)
bool operator== (const subtract_with_carry &__lhs, const subtract_with_carry &__rhs)
template<typename _IntType1, _IntType1 __m1, int __s1, int __r1, typename _CharT, typename _Traits> std::basic_istream< _CharT, _Traits > & operator>> (std::basic_istream< _CharT, _Traits > &__is, subtract_with_carry< _IntType1, __m1, __s1, __r1 > &__x)

Member Typedef Documentation

template<typename _IntType, _IntType __m, int __s, int __r> typedef _IntType std::tr1::subtract_with_carry< _IntType, __m, __s, __r >::result_type

The type of the generated random value.
Definition at line 674 of file random.

Constructor & Destructor Documentation

template<typename _IntType, _IntType __m, int __s, int __r> std::tr1::subtract_with_carry< _IntType, __m, __s, __r >::subtract_with_carry () [inline]

Constructs a default-initialized % subtract_with_carry random number generator.
Definition at line 685 of file random.

template<typename _IntType, _IntType __m, int __s, int __r> std::tr1::subtract_with_carry< _IntType, __m, __s, __r >::subtract_with_carry (unsigned long __value) [inline, explicit]

Constructs an explicitly seeded % subtract_with_carry random number generator.
Definition at line 693 of file random.

template<typename _IntType, _IntType __m, int __s, int __r> template<class _Gen> std::tr1::subtract_with_carry< _IntType, __m, __s, __r >::subtract_with_carry (_Gen & __g) [inline]

Constructs a subtract_with_carry random number generator engine seeded from the generator function __g.
Parameters:
__g The seed generator function.
Definition at line 703 of file random.

Member Function Documentation

template<typename _IntType, _IntType __m, int __s, int __r> result_type std::tr1::subtract_with_carry< _IntType, __m, __s, __r >::max () const [inline]

Gets the inclusive maximum value of the range of random integers returned by this generator.
Definition at line 742 of file random.

template<typename _IntType, _IntType __m, int __s, int __r> result_type std::tr1::subtract_with_carry< _IntType, __m, __s, __r >::min () const [inline]

Gets the inclusive minimum value of the range of random integers returned by this generator.
Definition at line 734 of file random.

template<typename _IntType, _IntType __m, int __s, int __r> subtract_with_carry< _IntType, __m, __s, __r >::result_type std::tr1::subtract_with_carry< _IntType, __m, __s, __r >::operator() () [inline]

Gets the next random number in the sequence.
Definition at line 362 of file random.tcc.
References std::tr1::subtract_with_carry< _IntType, __m, __s, __r >::short_lag.

template<typename _IntType, _IntType __m, int __s, int __r> template<class _Gen> void std::tr1::subtract_with_carry< _IntType, __m, __s, __r >::seed (_Gen & __g) [inline]

Seeds the initial state $ x_0 $ of the % subtract_with_carry random number generator.
Definition at line 726 of file random.

template<typename _IntType, _IntType __m, int __s, int __r> void std::tr1::subtract_with_carry< _IntType, __m, __s, __r >::seed (unsigned long __value = 19780503) [inline]

Seeds the initial state $ x_0 $ of the random number generator.
N1688[4.19] modifies this as follows. If __value == 0, sets value to 19780503. In any case, with a linear congruential generator lcg(i) having parameters $ m_{lcg} = 2147483563, a_{lcg} = 40014, c_{lcg} = 0, and lcg(0) = value $, sets $ x_{-r} \dots x_{-1} $ to $ lcg(1) \bmod m \dots lcg(r) \bmod m $ respectively. If $ x_{-1} = 0 $ set carry to 1, otherwise sets carry to 0.
Definition at line 320 of file random.tcc.
References std::tr1::subtract_with_carry< _IntType, __m, __s, __r >::long_lag.

Friends And Related Function Documentation

template<typename _IntType, _IntType __m, int __s, int __r> bool operator!= (const subtract_with_carry< _IntType, __m, __s, __r > & __lhs, const subtract_with_carry< _IntType, __m, __s, __r > & __rhs) [friend]

Compares two % subtract_with_carry random number generator objects of the same type for inequality.
Parameters:
__lhs A % subtract_with_carry random number generator object.
__rhs Another % subtract_with_carry random number generator object.
Returns:
true if the two objects are not equal, false otherwise.
Definition at line 777 of file random.

template<typename _IntType, _IntType __m, int __s, int __r> template<typename _IntType1, _IntType1 __m1, int __s1, int __r1, typename _CharT, typename _Traits> std::basic_ostream<_CharT, _Traits>& operator<< (std::basic_ostream< _CharT, _Traits > & __os, const subtract_with_carry< _IntType1, __m1, __s1, __r1 > & __x) [friend]

Inserts the current state of a % subtract_with_carry random number generator engine __x into the output stream __os.
Parameters:
__os An output stream.
__x A % subtract_with_carry random number generator engine.
Returns:
The output stream with the state of __x inserted or in an error state.

template<typename _IntType, _IntType __m, int __s, int __r> bool operator== (const subtract_with_carry< _IntType, __m, __s, __r > & __lhs, const subtract_with_carry< _IntType, __m, __s, __r > & __rhs) [friend]

Compares two % subtract_with_carry random number generator objects of the same type for equality.
Parameters:
__lhs A % subtract_with_carry random number generator object.
__rhs Another % subtract_with_carry random number generator object.
Returns:
true if the two objects are equal, false otherwise.
Definition at line 762 of file random.

template<typename _IntType, _IntType __m, int __s, int __r> template<typename _IntType1, _IntType1 __m1, int __s1, int __r1, typename _CharT, typename _Traits> std::basic_istream<_CharT, _Traits>& operator>> (std::basic_istream< _CharT, _Traits > & __is, subtract_with_carry< _IntType1, __m1, __s1, __r1 > & __x) [friend]

Extracts the current state of a % subtract_with_carry random number generator engine __x from the input stream __is.
Parameters:
__is An input stream.
__x A % subtract_with_carry random number generator engine.
Returns:
The input stream with the state of __x extracted or in an error state.

Author

Generated automatically by Doxygen for libstdc++ from the source code.