]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/compute/test/test_mersenne_twister_engine.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / compute / test / test_mersenne_twister_engine.cpp
1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2013 Kyle Lutz <kyle.r.lutz@gmail.com>
3 //
4 // Distributed under the Boost Software License, Version 1.0
5 // See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt
7 //
8 // See http://boostorg.github.com/compute for more information.
9 //---------------------------------------------------------------------------//
10
11 #define BOOST_TEST_MODULE TestMersenneTwisterEngine
12 #include <boost/test/unit_test.hpp>
13
14 #include <boost/compute/random/mersenne_twister_engine.hpp>
15 #include <boost/compute/container/vector.hpp>
16
17 #include "check_macros.hpp"
18 #include "context_setup.hpp"
19
20 BOOST_AUTO_TEST_CASE(generate_uint)
21 {
22 using boost::compute::uint_;
23
24 boost::compute::mt19937 rng(queue);
25
26 boost::compute::vector<uint_> vector(10, context);
27
28 rng.generate(vector.begin(), vector.end(), queue);
29
30 CHECK_RANGE_EQUAL(
31 uint_, 10, vector,
32 (uint_(3499211612),
33 uint_(581869302),
34 uint_(3890346734),
35 uint_(3586334585),
36 uint_(545404204),
37 uint_(4161255391),
38 uint_(3922919429),
39 uint_(949333985),
40 uint_(2715962298),
41 uint_(1323567403))
42 );
43 }
44
45 BOOST_AUTO_TEST_CASE(discard_uint)
46 {
47 using boost::compute::uint_;
48
49 boost::compute::mt19937 rng(queue);
50
51 boost::compute::vector<uint_> vector(5, context);
52
53 rng.discard(5, queue);
54 rng.generate(vector.begin(), vector.end(), queue);
55
56 CHECK_RANGE_EQUAL(
57 uint_, 5, vector,
58 (uint_(4161255391),
59 uint_(3922919429),
60 uint_(949333985),
61 uint_(2715962298),
62 uint_(1323567403))
63 );
64 }
65
66 BOOST_AUTO_TEST_CASE(copy_ctor)
67 {
68 using boost::compute::uint_;
69
70 boost::compute::mt19937 rng(queue);
71 boost::compute::mt19937 rng_copy(rng);
72
73 boost::compute::vector<uint_> vector(10, context);
74
75 rng_copy.generate(vector.begin(), vector.end(), queue);
76
77 CHECK_RANGE_EQUAL(
78 uint_, 10, vector,
79 (uint_(3499211612),
80 uint_(581869302),
81 uint_(3890346734),
82 uint_(3586334585),
83 uint_(545404204),
84 uint_(4161255391),
85 uint_(3922919429),
86 uint_(949333985),
87 uint_(2715962298),
88 uint_(1323567403))
89 );
90 }
91
92 BOOST_AUTO_TEST_CASE(assign_op)
93 {
94 using boost::compute::uint_;
95
96 boost::compute::mt19937 rng(queue);
97 boost::compute::mt19937 rng_copy(queue);
98
99 boost::compute::vector<uint_> vector(10, context);
100
101 rng_copy.discard(5, queue);
102 rng_copy = rng;
103 rng_copy.generate(vector.begin(), vector.end(), queue);
104
105 CHECK_RANGE_EQUAL(
106 uint_, 10, vector,
107 (uint_(3499211612),
108 uint_(581869302),
109 uint_(3890346734),
110 uint_(3586334585),
111 uint_(545404204),
112 uint_(4161255391),
113 uint_(3922919429),
114 uint_(949333985),
115 uint_(2715962298),
116 uint_(1323567403))
117 );
118 }
119
120 BOOST_AUTO_TEST_SUITE_END()