std::linear_congruential_engine

From Cppreference

Jump to: navigation, search
Defined in header <random>

template<class UIntType, UIntType a, UIntType c, UIntType m>
  class linear_congruential_engine;
(C++11 feature)

A linear_congruential_engine produces unsigned integer pseudorandom numbers. The state of a LCG is of size 1 and consists of a single integer.

The transition algorithm of the LCG function is <math>x_{i+1}\leftarrow(ax_{i} + c) \bmod m</math>.

Contents

[edit] Member types

Member type Definition
result_type The integral type generated by the engine. Results are undefined if this is not an unsigned integral type.

[edit] Member variables

multiplier
The multiplier term (a).
(public static member constant)
increment
The increment term (c).
(public static member constant)
modulus
The modulus term (m).
(public static member constant)
default_seed
The default seed (1).
(public static member constant)

[edit] Member functions

Construction and Seeding
(constructor)
Constructs the engine.
(public member function)
seed
Sets the current state of the engine.
(public member function)
Generation
operator()
Advances the engine's state and returns the generated value.
(public member function)
discard
Advances the engine's state by a specified amount.
(public member function)
Characteristics
min
Gets the smallest possible value in the output range.
(public member function)
max
Gets the largest possible value in the output range.
(public member function)

[edit] Non-member functions

operator==
Compare two LCGs for equality.
(function)
operator<<
Marshalls the engine state to an output stream.
(function)
operator>>
Unmarshalls the engine state from an input stream.
(function)