共用方式為


subtract_with_carry Class

由減去產生隨機序列使用帶有演算法。 保留為 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
    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 的值 S 大於 0 且必須小於 R必須大於零。

需求

標題: <random>

命名空間: std

請參閱

參考

<random>

subtract_with_carry_01 Class

subtract_with_carry::operator()

subtract_with_carry::seed

subtract_with_carry::subtract_with_carry