xor_combine::xor_combine
Konstrukcje generatora.
xor_combine();
xor_combine(const base1_type& eng1, const base2_type& eng2);
template<class Gen>
xor_combine(Gen& gen);
xor_combine(const xor_combine& right);
xor_combine(xor_combine& right);
Parametry
eng1
Pierwszy obiekt przechowywane silnika.eng2
Drugi obiekt przechowywane silnika.Gen
Typ silnika losowo materiału siewnego.gen
Aparat losowo materiału siewnego.right
xor_combine Obiektu.
Uwagi
Pierwszy konstrukcje konstruktora xor_combine obiekt z wartości przechowywane stored_eng1 i stored_eng2 z ich konstruktorów domyślnego.Drugi konstrukcje konstruktora xor_combine obiekt, którego wartość przechowywaną stored_eng1 przechowuje kopię eng1 i których wartość przechowywaną stored_eng2 przechowuje kopię eng2.Trzeci konstrukcje konstruktora xor_combine obiektu i wywołania seed(gen).Konstruktory czwartym i piątym skonstruować xor_combine obiekt z xor_combine obiektu.
Przykład
// std_tr1__random__xor_combine_construct.cpp
// compile with: /EHsc
#include <random>
#include <iostream>
typedef std::subtract_with_carry<unsigned int,
1 << 24, 10, 24> Myeng1;
typedef std::linear_congruential<unsigned int,
16807, 0, (1U << 31) - 1> Myeng2;
typedef std::xor_combine<Myeng1, 1, Myeng2, 2> Myceng;
int main()
{
Myeng1 eng1;
Myeng2 eng2;
Myceng ceng;
const Myceng::base1_type& base1 = ceng.base1(); // get base engine
const Myceng::base2_type& base2 = ceng.base2(); // get base engine
Myceng::result_type compval = ceng();
compval = compval; // to quiet "unused" warnings
base1.min();
base2.min();
std::cout << "S1 == " << Myceng::shift1 << std::endl;
std::cout << "S2 == " << Myceng::shift2 << std::endl;
std::cout << "min == " << ceng.min() << std::endl;
std::cout << "max == " << ceng.max() << std::endl;
ceng.seed(); // reseed base engine
std::cout << "a random value == " << ceng() << std::endl;
std::cout << "a random value == " << ceng() << std::endl;
std::cout << "a random value == " << ceng() << std::endl;
Myceng ceng2(eng1); // construct with generator
ceng2.seed(eng1); // seed with generator
return (0);
}
Wymagania
Nagłówek: <random>
Obszar nazw: std