通过减去生成一个随机顺序与具有算法。保留为TR1兼容性。请改用 subtract_with_carry_engine Class。
template<class IntType,
IntType M, int S, int R>
class subtract_with_carry {
public:
typedef IntType result_type;
typedef subtract_with_carry<IntType, M, S, R> _Myt;
static const IntType modulus = M;
static const IntType default_seed = 19780503U;
static const int short_lag = S;
static const int long_lag = R;
subtract_with_carry();
explicit subtract_with_carry(unsigned long x0 = default_seed);
template<class Gen>
subtract_with_carry(Gen& gen);
subtract_with_carry(const subtract_with_carry& right);
subtract_with_carry(subtract_with_carry& right);
void seed(unsigned long x0 = 19780503UL);
template<class Gen>
void seed(Gen& gen);
result_type min() const;
result_type max() const;
result_type operator()();
};
参数
IntType
整数结果类型。M
M引擎参数。S
引擎的参数。R
R引擎参数。
备注
模板选件类描述使用重复关系 x(i) = (x(i - R) - x(i - S) - cy(i - 1)) mod M,生成一个用户指定的整型值,cy(i) 具有值 1,如果 x(i - S) - x(i - R) - cy(i - 1) < 0,否则 0的简单引擎。引擎处理状态是返回的最后 R 值,如果 operator() 调用至少 R 时,否则返回的 M 值和一个种子的最后一 R - M 值。
模板参数 IntType 必须足够大表示值到 M - 1。模板参数 S 和 R 的值大于0和 S 必须小于 R输入到。
要求
标头: <random>
命名空间: std