本文整理汇总了C++中PRNG::get_double方法的典型用法代码示例。如果您正苦于以下问题:C++ PRNG::get_double方法的具体用法?C++ PRNG::get_double怎么用?C++ PRNG::get_double使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PRNG
的用法示例。
在下文中一共展示了PRNG::get_double方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(){
unsigned int seed_value[32];
for(int i=0; i<32; i++){
seed_value[i] = i*2; // Arbitrary seed value
}
InitWELLRNG1024a(seed_value);
PRNG* rng = PRNGFactory::generatePRNG("well");
rng->set(seed_value);
for(int i=0; i<10; i++){
double original_generator = WELLRNG1024a();
double PRNGFactory_generator = rng->get_double();
std::cout << original_generator << " " << PRNGFactory_generator << "\n";
if(original_generator != PRNGFactory_generator){
std::cout << "The streams do not match\n";
exit(0);
}
}
high_resolution_clock::time_point t1, t2;
// Measure the time it takes the original generator to produce 1 billion values
t1 = high_resolution_clock::now();
for(int i=0; i<1000000000; i++){
unsigned long original_stream = WELLRNG1024a();
}
t2 = high_resolution_clock::now();
auto duration = duration_cast<microseconds>( t2 - t1 ).count();
std::cout << "Original well generator used "<< duration << " microseconds to generate 1 billion values" << std::endl;
// Measure the time it takes the new generator to produce 1 billion values
t1 = high_resolution_clock::now();
for(int i=0; i<1000000000; i++){
unsigned long PRNG_stream = rng->get_double();
}
t2 = high_resolution_clock::now();
duration = duration_cast<microseconds>( t2 - t1 ).count();
std::cout << "PRNGFactory xorgens generator used "<< duration << " microseconds to generate 1 billion values" << std::endl;
return 0;
}