xor_combine::xor_combine

ジェネレーターを構築します。

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

パラメーター

  • eng1
    格納されている 1 つ目のエンジン オブジェクト。

  • eng2
    格納されている 2 つ目のエンジン オブジェクト。

  • Gen
    シードの乱数エンジンの型。

  • gen
    シードの乱数エンジン。

  • right
    xor_combine オブジェクト。

解説

1 つ目のコンストラクターは、格納されている値 stored_eng1 および stored_eng2 で xor_combine オブジェクトを構築します。2 つのオブジェクトは、それぞれ既定のコンストラクターで構築されます。2 つ目のコンストラクターは、格納されている値 stored_eng1 と stored_eng2 にそれぞれ eng1 と eng2 のコピーを保持する xor_combine オブジェクトを構築します。3 つ目のコンストラクターは、xor_combine オブジェクトを構築し、seed(gen) を呼び出します。4 つ目と 5 つ目のコンストラクターは、xor_combine オブジェクトから xor_combine オブジェクトを作成します。

使用例

 

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

必要条件

ヘッダー : <random>

名前空間: std

参照

関連項目

<random>

xor_combine クラス