subtract_with_carry::seed
엔진을 시드합니다.
void seed(result_type x0 = 19780503UL);
template<class Gen>
void seed(Gen& gen);
매개 변수
Gen
시드 생성자의 형식입니다.gen
시드 생성기입니다.x0
시드 값입니다.
설명
전제 조건:0 < x0
첫 번째 시드 함수 생성 long_lag 기록 값 형식의 값을 unsigned long 의 후속 호출에 의해 반환 된 gen.각 기록 값 gen() % modulus.
두 번째 시드 함수 효과적으로 다음 코드를 실행합니다.
linear_congruential<unsigned long, 40014, 0, 2147483563> gen(x0);
seed(gen);
예제
// std_tr1__random__subtract_with_carry_seed.cpp
// compile with: /EHsc
#include <random>
#include <iostream>
typedef std::mt19937 Myeng;
typedef std::subtract_with_carry<unsigned int, 1 << 24,
10, 24> Myceng;
int main()
{
Myeng eng;
Myceng ceng;
Myceng::result_type compval = ceng();
compval = compval; // to quiet "unused" warnings
std::cout << "M == " << Myceng::modulus << std::endl;
std::cout << "S == " << Myceng::short_lag << std::endl;
std::cout << "R == " << Myceng::long_lag << 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(eng); // construct with generator
ceng2.seed(eng); // seed with generator
Myceng ceng3(5UL); // construct with unsigned long seed
ceng3.seed(5UL); // seed with unsigned long
return (0);
}
요구 사항
헤더: <random>
네임 스페이스: std