Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Generates a random sequence by the linear congruential algorithm.
template<class UIntType, UIntType A, UIntType C, UIntType M>
class linear_congruential_engine;
Parameters
UIntType
The unsigned integer result type. For possible types, see <random>.A
Multiplier. Precondition: See Remarks section.C
Increment. Precondition: See Remarks section.M
Modulus. Precondition: See remarks.
Members
linear_congruential_engine::linear_congruential_engine |
linear_congruential_engine::min |
linear_congruential_engine::discard |
linear_congruential_engine::operator() |
linear_congruential_engine::max |
linear_congruential_engine::seed |
default_seed is a member constant, defined as 1u, used as the default parameter value for linear_congruential_engine::seed and the single value constructor. |
For more information about engine members, see <random>.
Remarks
The linear_congruential_engine template class is the simplest generator engine, but not the fastest or highest quality. An improvement over this engine is the substract_with_carry_engine. Neither of these engines is as fast or with as high quality results as the mersenne_twister_engine.
This engine produces values of a user-specified unsigned integral type using the recurrence relation (period) x(i) = (A * x(i-1) + C) mod M.
If M is zero, the value used for this modulus operation is numeric_limits<result_type>::max() + 1. The engine's state is the last value returned, or the seed value if no call has been made to operator().
If M is not zero, the values of the template arguments A and C must be less than M.
Although you can construct a generator from this engine directly, you can also use one of the predefined typedefs in the following table.
Name |
Description |
|---|---|
minstd_rand0 |
1988 minimal standard engine (Lewis, Goodman, and Miller, 1969). |
minstd_rand |
Updated minimal standard engine minstd_rand0 (Park, Miller, and Stockmeyer, 1993). |
For detailed information about the linear congruential engine algorithm, see the Wikipedia article Linear congruential generator.
Requirements
Header: <random>
Namespace: std