由线性congruential算法生成一个随机顺序。
template<class UIntType,
UIntType A, UIntType C, UIntType M>
class linear_congruential_engine {
public:
typedef UIntType result_type;
static const UIntType multiplier = A;
static const UIntType increment = C;
static const UIntType modulus = M;
static const UIntType default_seed = 1U;
explicit linear_congruential_engine(result_type x0 = default_seed);
explicit linear_congruential_engine(seed_seq& seq);
void seed(result_type x0 = default_seed);
void seed(seed_seq& seq);
static const result_type min();
static const result_type max();
result_type operator()();
void discard(unsigned long long count)();
private:
result_type stored_value;
};
参数
UIntType
无符号整数结果类型。A
A引擎参数。C
C引擎参数。M
M引擎参数。
备注
使用重复relationrecurrence关系 x(i) = (A * x(i-1) + C) mod M,生成一个用户指定的无符号整型值的模板选件类描述 <random>。引擎处理状态是返回的最后一个值,或者种子值,如果未调用对 operator()。
模板参数UIntType必须足够大表示值到M - 1。模板参数 A 和 C 的值大于 M必须小于。
要求
标头: <random>
命名空间: std
请参见
参考
linear_congruential_engine::discard
linear_congruential_engine::linear_congruential_engine