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...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

4. Using <strong>the</strong> “<strong>Random</strong> <strong>Number</strong> <strong>Generator</strong> <strong>Test</strong> <strong>Suite</strong>”4.2.3. SeedsAdding seeds is not such an easy task, because <strong>the</strong> Pseudo-random number engine requirementsdoes only specify <strong>the</strong> iterator based seeding, nothing else. But most generators supportalso a seed(seedType) method. So it is possible to add multiple seeds to use with <strong>the</strong>generators. If a generator does not support <strong>the</strong> seed(seedType) method <strong>the</strong> test suiteuses a pseudo-DES algorithm (see [25], sec. 7.5) to create a set of numbers and feeds <strong>the</strong>senumbers into <strong>the</strong> generator with <strong>the</strong> mandatory iterator based seed method.void add_seed(uint32_t seed)The o<strong>the</strong>r way to seed <strong>the</strong> generator is filling its buffer with values. To do this <strong>the</strong>reis <strong>the</strong> seed(iterator, iterator) method. This method must be supported by allgenerators from Boost. The user has to check himself if <strong>the</strong>re are enough values between <strong>the</strong>two iterators to fill <strong>the</strong> buffer. If <strong>the</strong>re are insufficient values an exception might be thrown.template void add_seed_iterators(const seedIter begin, const seedIter end) type of iteratorbegin iterator to <strong>the</strong> begin of <strong>the</strong> buffer with seedsend iterator to <strong>the</strong> end of <strong>the</strong> buffer with seeds starting <strong>the</strong> testBe<strong>for</strong>e a random number generator is seeded, it is reset to <strong>the</strong> initial state. This means to<strong>the</strong> same state as it was while adding to <strong>the</strong> test suite. This guarantees <strong>the</strong> repeatability <strong>for</strong>different seeding. If no seeds are added, <strong>the</strong> tests run with <strong>the</strong> initial state of <strong>the</strong> generator.If a generator has to be tested in a special state, e. g. with a special seeded buffer, <strong>the</strong>re is<strong>the</strong> method register_seeded_rng to handle this case.4.2.4. <strong>Random</strong> <strong>Number</strong> <strong>Generator</strong>sTo register <strong>the</strong> random number generators which have to be tested, <strong>the</strong> test suite provides <strong>the</strong>following two methods. (The requirements of a random number generator are described insection 6.4)template void register_rng(std::string rng_name, uint64_t warmup = 0) type of <strong>the</strong> random number generator to testrng_name name of <strong>the</strong> generator, should be uniquewarmup number of random numbers to produce with <strong>the</strong> generator be<strong>for</strong>e starting <strong>the</strong> testThis method takes <strong>the</strong> type of <strong>the</strong> random number generator as a template parameter. Theconcrete generator object is created inside <strong>the</strong> test suite with <strong>the</strong> default constructor. Theseed calls are done in this initial state.template void register_seeded_rng(T mrng,std::string rng_name,std::string description,uint64_t warmup = 0)12

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

Saved successfully!

Ooh no, something went wrong!