共用方式為


linear_congruential_engine Class

是由線性 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

請參閱

參考

<random>

linear_congruential_engine::discard

linear_congruential_engine::linear_congruential_engine

linear_congruential_engine::operator()

linear_congruential_engine::seed