Механизмlinear_congruential_engine случайных чисел производит беззнаковые целые случайные числа. Состояние из объекта имеет размер и состоит из одного целого числа. Алгоритм перехода представляет собой модульную линейную функцию формы ; алгоритм генерации есть . xilinear_congruential_engine x1TA(xi)=(a⋅xi+c)modmGA(xi)=xi+1
template<class UIntType, UIntType a, UIntType c, UIntType m> class linear_congruential_engine { public: // types using result_type = UIntType; // engine characteristics static constexpr result_type multiplier = a; static constexpr result_type increment = c; static constexpr result_type modulus = m; static constexpr result_type min() { return c == 0u ? 1u: 0u; } static constexpr result_type max() { return m - 1u; } static constexpr result_type default_seed = 1u; // constructors and seeding functions explicit linear_congruential_engine(result_type s = default_seed); template<class Sseq> explicit linear_congruential_engine(Sseq& q); void seed(result_type s = default_seed); template<class Sseq> void seed(Sseq& q); // generating functions result_type operator()(); void discard(unsigned long long z); };
Если параметр шаблона m равен0, модуль,m используемый в этом разделе, равен плюсу . [ не обязательно представлять как значение типа . ][rand.eng.lcong] numeric_limits<result_type>::max() 1 Note: m result_type — end note
explicit linear_congruential_engine(result_type s = default_seed);
Effects: Создаетlinear_congruential_engine объект. Еслиcmodm есть0 иsmodm есть0, устанавливает состояние двигателя в1, в противном случае устанавливает состояние двигателя вsmodm.
template<class Sseq> explicit linear_congruential_engine(Sseq& q);