File: test_mixmax.cpp

package info (click to toggle)
boost1.90 1.90.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 593,156 kB
  • sloc: cpp: 4,190,642; xml: 196,648; python: 34,618; ansic: 23,145; asm: 5,468; sh: 3,776; makefile: 1,161; perl: 1,020; sql: 728; ruby: 676; yacc: 478; java: 77; lisp: 24; csh: 6
file content (52 lines) | stat: -rw-r--r-- 1,688 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/* test_mixmax.cpp
 *
 * Copyright Kostas Savvidis 2019
 * Distributed under the Boost Software License, Version 1.0. (See
 * accompanying file LICENSE_1_0.txt or copy at
 * http://www.boost.org/LICENSE_1_0.txt)
 *
 * $Id$
 *
 */

#include <boost/random/mixmax.hpp>
#include <cmath>

#define BOOST_RANDOM_URNG boost::random::mixmax

#define BOOST_RANDOM_SEED_WORDS 4

//#define BOOST_RANDOM_VALIDATION_VALUE 1U
#define BOOST_RANDOM_SEED_SEQ_VALIDATION_VALUE 48757672604362303ULL
#define BOOST_RANDOM_ITERATOR_VALIDATION_VALUE 3802490769389764ULL

// 10000th invocation of MIXMAX with N=17, with default constructor should give:
#define BOOST_RANDOM_VALIDATION_VALUE UINT64_C(1842572666014501720)
#define BOOST_RANDOM_GENERATE_VALUES {  3132207748, 2861541672, 3191701354, 4046050275 }

#include "test_generator.ipp"

struct seed_seq_0 {
    template<class It>
    void generate(It begin, It end) const {
        std::fill(begin, end, boost::uint32_t(0xFFFFFFFF));
    }
};

BOOST_AUTO_TEST_CASE(test_special_seed) {
    {
        seed_seq_0 seed;
        std::vector<boost::uint32_t> vec(17);
        seed.generate(vec.begin(), vec.end()); // fill vec with ones
        std::vector<boost::uint32_t>::iterator it = vec.begin();
        boost::random::mixmax gen1(it, vec.end()); // init gen1 with vec iterator
        BOOST_CHECK_EQUAL(gen1(), 775778250716139533ULL);
        BOOST_CHECK_EQUAL(gen1(), 846264592759195742ULL);

        boost::random::mixmax gen2(seed); // init gen2 with seeq_seq, should be the same as gen1!
        BOOST_CHECK_EQUAL(gen2(), 775778250716139533ULL);
        BOOST_CHECK_EQUAL(gen2(), 846264592759195742ULL);

        BOOST_CHECK_EQUAL(gen1, gen2);
    }
}