Udostępnij za pośrednictwem


linear_congruential Class

Generuje losowe liniowej algorytm złożony.Zachowane zgodności TR1.Użyj linear_congruential_engine Class zamiast.

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

Parametry

  • UIntType
    Typ wyniku liczba całkowita bez znaku.

  • A
    Parametr silnika A.

  • C
    Parametr c silnika.

  • M
    Parametr m silnika.

Uwagi

Ta klasa szablonu opisuje proste aparat, który produkuje wartości określone przez użytkownika niepodpisane integralną typu przy użyciu relacji ponownego x(i) = (A * x(i-1) + C) mod M.Stan silnika jest ostatnia wartość zwracana lub wartości materiału siewnego, jeżeli zostały złożone nie wywołania operator().

Argument szablonu UIntType musi być wystarczająco duży, aby pomieścić do wartości M - 1.Wartości argumentów szablonu A i C musi być mniejsza niż M.

Wymagania

Nagłówek: <random>

Obszar nazw: std

Zobacz też

Informacje

<random>

linear_congruential::linear_congruential

linear_congruential::operator()

linear_congruential::seed