For the latest documentation on Visual Studio 2017 RC, see Visual Studio 2017 RC Documentation.
Generates a random sequence by the subtract-with-carry (lagged Fibonacci) algorithm.
template <class UIntType, size_t W, size_t S, size_t R> class subtract_with_carry_engine;
The unsigned integer result type. For possible types, see <random>.
Word size. Size of each word, in bits, of the state sequence. Precondition:
0 < W ≤ numeric_limits<UIntType>::digits
Short lag. Number of integer values. Precondition:
0 < S < R
Long lag. Determines recurrence in the series generated.
For more information about engine members, see <random>.
substract_with_carry_engine template class is an improvement over the linear_congruential_engine. Neither for 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) = (x(i - R) - x(i - S) - cy(i - 1)) mod M, where
cy(i) has the value
x(i - S) - x(i - R) - cy(i - 1) < 0, otherwise
M has the value
2W. The engine's state is a carry indicator plus
R values. These values consist of the last
R values returned if
operator() has been called at least
R times, otherwise the
N values that have been returned and the last
R - N values of the seed.
The template argument
UIntType must be large enough to hold values up to
M - 1.
Although you can construct a generator from this engine directly, you can also use one of these predefined typedefs:
ranlux24_base: Used as a base for
typedef subtract_with_carry_engine<unsigned int, 24, 10, 24> ranlux24_base;
ranlux48_base: Used as a base for
typedef subtract_with_carry_engine<unsigned long long, 48, 5, 12> ranlux48_base;
For detailed information about the subract with carry engine algorithm, see the Wikipedia article Lagged Fibonacci generator.