Compartir a través de


linear_congruential Class

Genera una secuencia aleatoria el algoritmo congruential lineal.Retenido por compatibilidad TR1.Utilice linear_congruential_engine Class en su lugar.

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

Parámetros

  • UIntType
    El tipo de resultado de entero sin signo.

  • A
    El parámetro del motor de A.

  • C
    El parámetro del motor de C.

  • M
    El parámetro del motor de m.

Comentarios

Esta clase de plantilla describe un motor simple que genere valores de entero sin signo definido por el usuario escribe utilizando la relación de frecuencia x(i) = (A * x(i-1) + C) mod M.El estado del motor es el valor devuelto último, o el valor de inicialización si no se ha realizado ninguna llamada a operator().

El argumento UIntType template debería ser lo bastante grande para contener valores hasta M - 1.Los valores de los argumentos A y C de plantilla deben ser menor que M.

Requisitos

encabezado: <aleatorio>

espacio de nombres: std

Vea también

Referencia

<random>

linear_congruential::linear_congruential

linear_congruential::operator()

linear_congruential::seed