共用方式為


linear_congruential Class

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

請參閱

參考

<random>

linear_congruential::linear_congruential

linear_congruential::operator()

linear_congruential::seed