11.07.2015 Views

A Random Number Generator Test Suite for the C++ ... - ETH Zürich

A Random Number Generator Test Suite for the C++ ... - ETH Zürich

A Random Number Generator Test Suite for the C++ ... - ETH Zürich

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

4. Using <strong>the</strong> “<strong>Random</strong> <strong>Number</strong> <strong>Generator</strong> <strong>Test</strong> <strong>Suite</strong>”4.3. <strong>Test</strong>ing Parallel <strong>Random</strong> <strong>Number</strong> <strong>Generator</strong>sTo test a parallel application using different random number generators in different threads,<strong>the</strong>re is a class called parallel_rng_imitator(from parallel_rng_imitator.h)which simulates such an application. The class contains a collection of definable generatorsand calls one after ano<strong>the</strong>r. This generator fulfils <strong>the</strong> Boost specification and can be used ina normal way.There are some preconditions to keep in mind when using such a random number generator.All random number generators used in this parallel random number generator musthave <strong>the</strong> same result_type. Un<strong>for</strong>tunately <strong>the</strong> boost::uni<strong>for</strong>m_01type doesnot support an default constructor, so it is not possible to map <strong>the</strong> result type to an o<strong>the</strong>rtype. To do this, a converter which fulfils <strong>the</strong> specified interface <strong>for</strong> generators has tobe written.All random number generators must have <strong>the</strong> same maximum and minimum value.Pre-seeded random number generators should be favoured because of a better controlover seeding <strong>the</strong> particular generators.// include Boosts RNGs#include // include parallel generator#include "parallel_rng_imitator.h"// import RNGs from Boostusing boost::minstd_rand0;using boost::lagged_fibonacci19937;using boost::lagged_fibonacci23209;using boost::lagged_fibonacci44497;using boost::mt19937;using boost::ecuyer1988;// make a RNG from two different Lagged Fibonacci RNGsparallel_rng_imitator parallelRNG;// does not compile, because <strong>the</strong> enlisted generators do not// have same result_typeparallel_rng_imitator parallelRNG_error_compile;// does compile, but throws an exception because <strong>the</strong> RNGs// does not have same min() or max() valueparallel_rng_imitator

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!