Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

subtract_with_carry_01 Class

Generates a random sequence by the floating-point subtract with carry algorithm.

template<class RealType,
   int W, int S, int R>
   class subtract_with_carry_01 {
   typedef RealType result_type;
   static const int word_size = W;
   static const int short_lag = S;
   static const int long_lag = R;
   explicit subtract_with_carry_01(unsigned long x0);
   template<class Gen>
      subtract_with_carry_01(Gen& gen);
   subtract_with_carry_01(const subtract_with_carry_01& right);
   subtract_with_carry_01(subtract_with_carry_01& 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()();


The floating-point result type.


The W engine parameter.


The S engine parameter.


The R engine parameter.

The template class decribes a simple engine that produces values of a user-specified floating-point type using the recurrence relation x(i) = (x(i - R) - x(i - S) - cy(i - 1)) mod 1, where cy(i) has the value 2-W 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 RealType must be large enough to hold values with W fraction bits. The values of the template arguments S and R must be greater than 0 and S must be less than R.

Header: <random>

Namespace: std::tr1

Community Additions

© 2015 Microsoft