linear_congruential クラス
線形合同法アルゴリズムでランダム シーケンスを生成します。TR1 との互換性のために保持されています。代わりに linear_congruential_engine クラス を使用してください。
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