由线性congruential算法生成一个随机顺序。保留为TR1兼容性。请改用 linear_congruential_engine Class。
template<class UIntType,
UIntType A, UIntType C, UIntType M>
class linear_congruential {
public:
typedef linear_congruential<UIntType, A, C, M> _MyT;
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(UIntType x0 = default_seed)
linear_congruential(const linear_congruential& right);
linear_congruential(linear_congruential& right);
template<class Gen>
linear_congruential(Gen& gen);
void seed(UIntType x0 = default_seed);
template<class Gen>
void seed(Gen& gen);
result_type min() const;
result_type max() const;
result_type operator()();
private:
result_type stored_value; // exposition only
};
参数
UIntType
无符号整数结果类型。A
A引擎参数。C
C引擎参数。M
M引擎参数。
备注
此模板选件类描述使用重复关系 x(i) = (A * x(i-1) + C) mod M,生成一个用户指定的无符号整型值的简单引擎。引擎处理状态是返回的最后一个值,或者种子值,如果未调用对 operator()。
模板参数 UIntType 必须足够大表示值到 M - 1。模板参数 A 和 C 的值大于 M必须小于。
要求
标头: <random>
命名空间: std
请参见
参考
linear_congruential::linear_congruential