다음을 통해 공유


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 0 보다 커야 합니다 및 S 해야 보다 R.

요구 사항

헤더: <random>

네임 스페이스: std

참고 항목

참조

<random>

subtract_with_carry_01 Class

subtract_with_carry::operator()

subtract_with_carry::seed

subtract_with_carry::subtract_with_carry