|
libstdc++
|
Public Types | |
| typedef _UIntType | result_type |
Public Member Functions | |
| linear_congruential (unsigned long __x0=1) | |
| template<class _Gen > | |
| linear_congruential (_Gen &__g) | |
| result_type | max () const |
| result_type | min () const |
| result_type | operator() () |
| void | seed (unsigned long __s=1) |
| template<class _Gen > | |
| void | seed (_Gen &__g) |
Static Public Attributes | |
| static const _UIntType | increment |
| static const _UIntType | modulus |
| static const _UIntType | multiplier |
Friends | |
| bool | operator!= (const linear_congruential &__lhs, const linear_congruential &__rhs) |
| template<class _UIntType1 , _UIntType1 __a1, _UIntType1 __c1, _UIntType1 __m1, typename _CharT , typename _Traits > | |
| std::basic_ostream< _CharT, _Traits > & | operator<< (std::basic_ostream< _CharT, _Traits > &__os, const linear_congruential< _UIntType1, __a1, __c1, __m1 > &__lcr) |
| bool | operator== (const linear_congruential &__lhs, const linear_congruential &__rhs) |
| template<class _UIntType1 , _UIntType1 __a1, _UIntType1 __c1, _UIntType1 __m1, typename _CharT , typename _Traits > | |
| std::basic_istream< _CharT, _Traits > & | operator>> (std::basic_istream< _CharT, _Traits > &__is, linear_congruential< _UIntType1, __a1, __c1, __m1 > &__lcr) |
A model of a linear congruential random number generator.
A random number generator that produces pseudorandom numbers using the linear function
.
The template parameter _UIntType must be an unsigned integral type large enough to store values up to (__m-1). If the template parameter __m is 0, the modulus __m used is std::numeric_limits<_UIntType>::max() plus 1. Otherwise, the template parameters __a and __c must be less than __m.
The size of the state is
.
Definition at line 346 of file tr1_impl/random.
| typedef _UIntType std::linear_congruential< _UIntType, __a, __c, __m >::result_type |
The type of the generated random value.
Definition at line 353 of file tr1_impl/random.
|
inlineexplicit |
Constructs a linear_congruential random number generator engine with seed __s. The default seed value is 1.
| __s | The initial seed value. |
Definition at line 369 of file tr1_impl/random.
References std::linear_congruential< _UIntType, __a, __c, __m >::seed().
|
inline |
Constructs a linear_congruential random number generator engine seeded from the generator function __g.
| __g | The seed generator function. |
Definition at line 379 of file tr1_impl/random.
References std::linear_congruential< _UIntType, __a, __c, __m >::seed().
|
inline |
Gets the largest possible value in the output range.
Definition at line 416 of file tr1_impl/random.
|
inline |
Gets the smallest possible value in the output range.
The minimum depends on the __c parameter: if it is zero, the minimum generated must be > 0, otherwise 0 is allowed.
Definition at line 409 of file tr1_impl/random.
| linear_congruential< _UIntType, __a, __c, __m >::result_type std::linear_congruential< _UIntType, __a, __c, __m >::operator() | ( | ) |
Gets the next random number in the sequence.
Gets the next generated value in sequence.
Definition at line 130 of file random.tcc.
| void std::linear_congruential< _UIntType, __a, __c, __m >::seed | ( | unsigned long | __x0 = 1 | ) |
Reseeds the linear_congruential random number generator engine sequence to the seed __s.
| __s | The new seed. |
Seeds the LCR with integral value __x0, adjusted so that the ring identity is never a member of the convergence set.
Definition at line 98 of file random.tcc.
Referenced by std::linear_congruential< _UIntType, __a, __c, __m >::linear_congruential(), and std::linear_congruential< _UIntType, __a, __c, __m >::seed().
|
inline |
Reseeds the linear_congruential random number generator engine sequence using values from the generator function __g.
| __g | the seed generator function. |
Definition at line 399 of file tr1_impl/random.
References std::linear_congruential< _UIntType, __a, __c, __m >::seed().
|
friend |
Compares two linear congruential random number generator objects of the same type for inequality.
| __lhs | A linear congruential random number generator object. |
| __rhs | Another linear congruential random number generator obj. |
Definition at line 449 of file tr1_impl/random.
|
friend |
Writes the textual representation of the state x(i) of x to __os.
| __os | The output stream. |
| __lcr | A % linear_congruential random number generator. |
|
friend |
Compares two linear congruential random number generator objects of the same type for equality.
| __lhs | A linear congruential random number generator object. |
| __rhs | Another linear congruential random number generator obj. |
Definition at line 435 of file tr1_impl/random.
|
friend |
Sets the state of the engine by reading its textual representation from __is.
The textual representation must have been previously written using an output stream whose imbued locale and whose type's template specialization arguments _CharT and _Traits were the same as those of __is.
| __is | The input stream. |
| __lcr | A % linear_congruential random number generator. |
|
static |
An increment.
Definition at line 358 of file tr1_impl/random.
|
static |
The modulus.
Definition at line 360 of file tr1_impl/random.
|
static |
The multiplier.
Definition at line 356 of file tr1_impl/random.