]>
Commit | Line | Data |
---|---|---|
1860430a UD |
1 | // { dg-options "-std=c++0x" } |
2 | // { dg-require-cstdint "" } | |
eeeef8f4 | 3 | // { dg-require-little-endian "" } |
1860430a UD |
4 | // |
5 | // 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> | |
6 | // 2012-08-28 Ulrich Drepper <drepper@gmail.com>, adapted for SFMT | |
7 | // | |
405feeb8 | 8 | // Copyright (C) 2008-2013 Free Software Foundation, Inc. |
1860430a UD |
9 | // |
10 | // This file is part of the GNU ISO C++ Library. This library is free | |
11 | // software; you can redistribute it and/or modify it under the | |
12 | // terms of the GNU General Public License as published by the | |
13 | // Free Software Foundation; either version 3, or (at your option) | |
14 | // any later version. | |
15 | // | |
16 | // This library is distributed in the hope that it will be useful, | |
17 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 | // GNU General Public License for more details. | |
20 | // | |
21 | // You should have received a copy of the GNU General Public License along | |
22 | // with this library; see the file COPYING3. If not see | |
23 | // <http://www.gnu.org/licenses/>. | |
24 | ||
25 | #include <iostream> | |
26 | #include <ext/random> | |
27 | #include <testsuite_hooks.h> | |
28 | ||
29 | ||
30 | template<class SFMT> | |
31 | void run_test(std::initializer_list<typename SFMT::result_type> vals) | |
32 | { | |
33 | typedef typename SFMT::result_type result_type; | |
34 | SFMT e; | |
35 | ||
36 | e.seed(sizeof(result_type) == 4 ? 1234 : 4321); | |
37 | e.discard(990); | |
38 | bool success = true; | |
39 | for (auto i : vals) | |
40 | { | |
41 | result_type r = e(); | |
42 | success &= r == i; | |
43 | std::cout << r << " vs " << i << std::endl; | |
44 | } | |
45 | VERIFY( success ); | |
46 | } | |
47 | ||
48 | ||
49 | void | |
50 | test01() | |
51 | { | |
52 | bool test __attribute__((unused)) = true; | |
53 | ||
54 | __gnu_cxx::sfmt19937 e; | |
55 | ||
56 | VERIFY( e.min() == 0 ); | |
57 | VERIFY( e.max() == std::numeric_limits<uint32_t>::max() ); | |
58 | ||
59 | run_test<__gnu_cxx::sfmt607>({ UINT32_C(1318548553), UINT32_C(1985957974), | |
60 | UINT32_C(1367744196), UINT32_C(3463392791), UINT32_C(2780736231), | |
61 | UINT32_C(3894488561), UINT32_C(3157036262), UINT32_C(3491812767), | |
62 | UINT32_C(1724574180), UINT32_C(3645035493) }); | |
63 | ||
64 | run_test<__gnu_cxx::sfmt607_64>({UINT64_C(15510024334182072935), | |
65 | UINT64_C(5793753331747412752), UINT64_C(16198353238554625740), | |
66 | UINT64_C(2233208824926016498), UINT64_C(3566091399820823780), | |
67 | UINT64_C(16608268514591292798), UINT64_C(10684941689666043359), | |
68 | UINT64_C(12463424292910456802), UINT64_C(5902567440240131366), | |
69 | UINT64_C(7228030834036501150) }); | |
70 | ||
71 | run_test<__gnu_cxx::sfmt1279>({ UINT32_C(66657331), UINT32_C(637106837), | |
72 | UINT32_C(406927341), UINT32_C(3964420203), UINT32_C(2127134160), | |
73 | UINT32_C(1327235047), UINT32_C(227339400), UINT32_C(97109542), | |
74 | UINT32_C(1814799261), UINT32_C(340888197) }); | |
75 | ||
76 | run_test<__gnu_cxx::sfmt1279_64>({ UINT64_C(16431921382083697129), | |
77 | UINT64_C(3107599092104940900), UINT64_C(4055245506102959965), | |
78 | UINT64_C(16096064917153424198), UINT64_C(14429331498726837109), | |
79 | UINT64_C(9539664361920633782), UINT64_C(1435296568185387099), | |
80 | UINT64_C(15922567183295047131), UINT64_C(641988285517426228), | |
81 | UINT64_C(15936274870984512675) }); | |
82 | ||
83 | run_test<__gnu_cxx::sfmt2281>({ UINT32_C(2662391944), UINT32_C(1176696104), | |
84 | UINT32_C(3587947451), UINT32_C(4098993357), UINT32_C(3140998698), | |
85 | UINT32_C(870759742), UINT32_C(623529127), UINT32_C(3458807285), | |
86 | UINT32_C(3341615957), UINT32_C(195614711) }); | |
87 | ||
88 | run_test<__gnu_cxx::sfmt2281_64>({ UINT64_C(16747191622237074632), | |
89 | UINT64_C(15804170396401370381), UINT64_C(3395175278324920203), | |
90 | UINT64_C(1541877340159274442), UINT64_C(14176322102994316687), | |
91 | UINT64_C(5130618305074712143), UINT64_C(6769693652413407081), | |
92 | UINT64_C(17733765687477661079), UINT64_C(5189766940360047353), | |
93 | UINT64_C(1333654688569723389) }); | |
94 | ||
95 | run_test<__gnu_cxx::sfmt4253>({ UINT32_C(90342133), UINT32_C(1083987943), | |
96 | UINT32_C(1785481425), UINT32_C(1921212667), UINT32_C(3164342992), | |
97 | UINT32_C(1489324569), UINT32_C(603530523), UINT32_C(952851722), | |
98 | UINT32_C(2380944844), UINT32_C(3335854133) }); | |
99 | ||
100 | run_test<__gnu_cxx::sfmt4253_64>({ UINT64_C(11570915401962514263), | |
101 | UINT64_C(206693220452528225), UINT64_C(16553299974633247759), | |
102 | UINT64_C(1069562842508952901), UINT64_C(7203975672387749585), | |
103 | UINT64_C(7552781925224963166), UINT64_C(16865729458807008705), | |
104 | UINT64_C(7848963629493506078), UINT64_C(9282397173969292817), | |
105 | UINT64_C(10738488504584559289) }); | |
106 | ||
107 | run_test<__gnu_cxx::sfmt11213>({ UINT32_C(2072997009), UINT32_C(1332330347), | |
108 | UINT32_C(179681555), UINT32_C(2315290438), UINT32_C(2429393974), | |
109 | UINT32_C(509881964), UINT32_C(3807607878), UINT32_C(3055319970), | |
110 | UINT32_C(671840881), UINT32_C(3477325874) }); | |
111 | ||
112 | run_test<__gnu_cxx::sfmt11213_64>({ UINT64_C(373867573626408653), | |
113 | UINT64_C(4732829340233638861), UINT64_C(16174630176505735656), | |
114 | UINT64_C(10063018133994900869), UINT64_C(17308645173308419196), | |
115 | UINT64_C(11091353816581371951), UINT64_C(15078420471318089727), | |
116 | UINT64_C(17965717592743818706), UINT64_C(12301543162252389155), | |
117 | UINT64_C(1724943167823308511) }); | |
118 | ||
119 | run_test<__gnu_cxx::sfmt19937>({ UINT32_C(4002809368), UINT32_C(421169044), | |
120 | UINT32_C(1112642589), UINT32_C(3076213779), UINT32_C(3387033971), | |
121 | UINT32_C(2499610950), UINT32_C(3057240914), UINT32_C(1662679783), | |
122 | UINT32_C(461224431), UINT32_C(1168395933) }); | |
123 | ||
124 | run_test<__gnu_cxx::sfmt19937_64>({ UINT64_C(8032857516355555296), | |
125 | UINT64_C(14023605983059313116), UINT64_C(1032336061815461376), | |
126 | UINT64_C(9840995337876562612), UINT64_C(9869256223029203587), | |
127 | UINT64_C(12227975697177267636), UINT64_C(12728115115844186033), | |
128 | UINT64_C(7752058479783205470), UINT64_C(729733219713393087), | |
129 | UINT64_C(12954017801239007622) }); | |
130 | ||
131 | run_test<__gnu_cxx::sfmt44497>({ UINT32_C(1483092082), UINT32_C(1895679637), | |
132 | UINT32_C(9122740), UINT32_C(635864575), UINT32_C(320732971), | |
133 | UINT32_C(4253159584), UINT32_C(30097521), UINT32_C(839233316), | |
134 | UINT32_C(1431693534), UINT32_C(645981752) }); | |
135 | ||
136 | run_test<__gnu_cxx::sfmt44497_64>({ UINT64_C(6246103978016445638), | |
137 | UINT64_C(4198275826138953222), UINT64_C(12473679170573289212), | |
138 | UINT64_C(14745709982748360209), UINT64_C(3630790792408208113), | |
139 | UINT64_C(4195294399578350499), UINT64_C(3742595698794327253), | |
140 | UINT64_C(17388385867517445933), UINT64_C(4261866397667814669), | |
141 | UINT64_C(17394085161690598095) }); | |
142 | ||
143 | run_test<__gnu_cxx::sfmt86243>({ UINT32_C(3910985535), UINT32_C(100094501), | |
144 | UINT32_C(3120362616), UINT32_C(1854432382), UINT32_C(314688154), | |
145 | UINT32_C(522122712), UINT32_C(3026095676), UINT32_C(3681962735), | |
146 | UINT32_C(1851548627), UINT32_C(2153846465) }); | |
147 | ||
148 | run_test<__gnu_cxx::sfmt86243_64>({ UINT64_C(250135615696586029), | |
149 | UINT64_C(4836277875486422184), UINT64_C(12389320296183057446), | |
150 | UINT64_C(7983028875884559442), UINT64_C(10079555227308335361), | |
151 | UINT64_C(14829333386540244214), UINT64_C(12159744972103351172), | |
152 | UINT64_C(4932579842314286356), UINT64_C(5200375244476537050), | |
153 | UINT64_C(11795681221121010641) }); | |
154 | ||
155 | run_test<__gnu_cxx::sfmt132049>({ UINT32_C(1551023420), UINT32_C(1462317554), | |
156 | UINT32_C(2882528449), UINT32_C(1136299843), UINT32_C(292840589), | |
157 | UINT32_C(1307775247), UINT32_C(463274356), UINT32_C(1430357686), | |
158 | UINT32_C(3907607055), UINT32_C(3462509184) }); | |
159 | ||
160 | run_test<__gnu_cxx::sfmt132049_64>({ UINT64_C(649482638765113922), | |
161 | UINT64_C(14205859353699897918), UINT64_C(14077261854908137257), | |
162 | UINT64_C(9564785861212212042), UINT64_C(7310747921257808846), | |
163 | UINT64_C(13759009477111470372), UINT64_C(11942123860149328831), | |
164 | UINT64_C(12868386070200572127), UINT64_C(18348617059674004332), | |
165 | UINT64_C(4233208019331956061) }); | |
166 | ||
167 | run_test<__gnu_cxx::sfmt216091>({ UINT32_C(4171954654), UINT32_C(2938491210), | |
168 | UINT32_C(1356393891), UINT32_C(3558249995), UINT32_C(3711769979), | |
169 | UINT32_C(3434953144), UINT32_C(1601628304), UINT32_C(2187495640), | |
170 | UINT32_C(1762169715), UINT32_C(2141213778) }); | |
171 | ||
172 | run_test<__gnu_cxx::sfmt216091_64>({ UINT64_C(11322404276387828766), | |
173 | UINT64_C(9653391575000195546), UINT64_C(1767839622905368464), | |
174 | UINT64_C(1690838241348740821), UINT64_C(817628268513271254), | |
175 | UINT64_C(15111277786569319196), UINT64_C(15817118810543358764), | |
176 | UINT64_C(5639001693408668083), UINT64_C(9959854003669400568), | |
177 | UINT64_C(13675983279642398887) }); | |
178 | } | |
179 | ||
180 | int main() | |
181 | { | |
182 | test01(); | |
183 | return 0; | |
184 | } |