Compartilhar via


subtract_with_carry Class

Generates a random sequence by the subtract with carry algorithm. Retained for TR1 compatibility. Use subtract_with_carry_engine Class instead.

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()();
   };

Parameters

  • IntType
    The integer result type.

  • M
    The M engine parameter.

  • S
    The S engine parameter.

  • R
    The R engine parameter.

Remarks

The template class decribes a simple engine that produces values of a user-specified integral type using the recurrence relation x(i) = (x(i - R) - x(i - S) - cy(i - 1)) mod M, where cy(i) has the value 1 if x(i - S) - x(i - R) - cy(i - 1) < 0, otherwise 0. The engine's state is the last R values returned if operator() has been called at least R times, otherwise the M values that have been returned and the last R - M values of the seed.

The template argument IntType must be large enough to hold values up to M - 1. The values of the template arguments S and R must be greater than 0 and S must be less than R.

Requirements

Header: <random>

Namespace: std

See Also

Reference

<random>

subtract_with_carry_01 Class

subtract_with_carry::operator()

subtract_with_carry::seed

subtract_with_carry::subtract_with_carry

Other Resources

<random> Members