linear_congruential_engine クラス
線形合同法アルゴリズムでランダム シーケンスを生成します。
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 エンジン パラメーター。
解説
このテンプレート クラスは、ユーザーによって指定された符号なし整数型の値を、循環関係 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