\hypertarget{random_8cpp_source}{}\doxysection{random.\+cpp}
\label{random_8cpp_source}\index{tests/random.cpp@{tests/random.cpp}}
\mbox{\hyperlink{random_8cpp}{Go to the documentation of this file.}}
\begin{DoxyCode}{0}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00001}\mbox{\hyperlink{random_8cpp_a0c968fa74dfb6f8a44bc50be7a214173}{00001}} \textcolor{preprocessor}{\#define KBLIB\_DEBUG\_SEED\_SEQ 1}}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00002}00002 }
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00003}00003 \textcolor{preprocessor}{\#include "{}\mbox{\hyperlink{random_8h}{kblib/random.h}}"{}}}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00004}00004 \textcolor{preprocessor}{\#include "{}catch.hpp"{}}}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00005}00005 }
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00006}00006 \textcolor{preprocessor}{\#include <iostream>}}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00007}00007 \textcolor{preprocessor}{\#include <sstream>}}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00008}00008 }
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00009}00009 \textcolor{keyword}{template} <std::\textcolor{keywordtype}{size\_t}>}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00010}00010 \textcolor{keyword}{struct }\mbox{\hyperlink{structprint}{print}};}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00011}00011 }
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00012}\mbox{\hyperlink{random_8cpp_a7da4eb9327c01da6ca569d546afe3e15}{00012}} \mbox{\hyperlink{random_8cpp_a7da4eb9327c01da6ca569d546afe3e15}{TEST\_CASE}}(\textcolor{stringliteral}{"{}Random engine seeding"{}}) \{}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00013}00013    SECTION(\textcolor{stringliteral}{"{}Mersenne Twister Engine"{}}) \{}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00014}00014       std::clog << \textcolor{stringliteral}{"{}MT: "{}};}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00015}00015       \mbox{\hyperlink{tdecl_8h_a607cffc585fe3bfcb06b63be2948de4a}{KBLIB\_UNUSED}} \textcolor{keyword}{auto} gen = kblib::seeded<std::mt19937>();}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00016}00016       std::clog << \textcolor{charliteral}{'\(\backslash\)n'};}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00017}00017       \textcolor{keyword}{static\_assert}(kblib::state\_size\_v<std::mt19937> == 624, \textcolor{stringliteral}{"{}."{}});}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00018}00018       \textcolor{keyword}{static\_assert}(kblib::state\_size\_v<std::mt19937\_64> == 624, \textcolor{stringliteral}{"{}."{}});}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00019}00019    \}}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00020}00020    SECTION(\textcolor{stringliteral}{"{}Linear Congruential Engine"{}}) \{}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00021}00021       std::clog << \textcolor{stringliteral}{"{}LCG: "{}};}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00022}00022       \mbox{\hyperlink{tdecl_8h_a607cffc585fe3bfcb06b63be2948de4a}{KBLIB\_UNUSED}} \textcolor{keyword}{auto} gen = kblib::seeded<std::minstd\_rand>();}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00023}00023       std::clog << \textcolor{charliteral}{'\(\backslash\)n'};}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00024}00024       \textcolor{keyword}{static\_assert}(kblib::state\_size\_v<std::minstd\_rand> == 1, \textcolor{stringliteral}{"{}."{}});}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00025}00025       \textcolor{keyword}{static\_assert}(kblib::state\_size\_v<std::minstd\_rand0> == 1, \textcolor{stringliteral}{"{}."{}});}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00026}00026       std::clog << \textcolor{stringliteral}{"{}LCG(64): "{}};}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00027}00027       \mbox{\hyperlink{tdecl_8h_a607cffc585fe3bfcb06b63be2948de4a}{KBLIB\_UNUSED}} \textcolor{keyword}{auto} gen2 = kblib::seeded<kblib::lcgs::java\_rand>();}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00028}00028       std::clog << \textcolor{charliteral}{'\(\backslash\)n'};}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00029}00029       \textcolor{keyword}{static\_assert}(kblib::state\_size\_v<kblib::lcgs::java\_rand> == 2, \textcolor{stringliteral}{"{}."{}});}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00030}00030    \}}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00031}00031    SECTION(\textcolor{stringliteral}{"{}Subtract with Carry Engine"{}}) \{}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00032}00032       std::clog << \textcolor{stringliteral}{"{}SwCE 24: "{}};}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00033}00033       \mbox{\hyperlink{tdecl_8h_a607cffc585fe3bfcb06b63be2948de4a}{KBLIB\_UNUSED}} \textcolor{keyword}{auto} gen = kblib::seeded<std::ranlux24\_base>();}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00034}00034       std::clog << \textcolor{stringliteral}{"{}SwCE 48: "{}};}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00035}00035       \mbox{\hyperlink{tdecl_8h_a607cffc585fe3bfcb06b63be2948de4a}{KBLIB\_UNUSED}} \textcolor{keyword}{auto} gen2 = kblib::seeded<std::ranlux24\_base>();}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00036}00036       std::clog << \textcolor{charliteral}{'\(\backslash\)n'};}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00037}00037       \textcolor{keyword}{static\_assert}(kblib::state\_size\_v<std::ranlux24\_base> == 24, \textcolor{stringliteral}{"{}."{}});}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00038}00038       \textcolor{keyword}{static\_assert}(kblib::state\_size\_v<std::ranlux48\_base> == 24, \textcolor{stringliteral}{"{}."{}});}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00039}00039    \}}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00040}00040    SECTION(\textcolor{stringliteral}{"{}Discard Block Engine"{}}) \{}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00041}00041       std::clog << \textcolor{stringliteral}{"{}DBE: "{}};}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00042}00042       \mbox{\hyperlink{tdecl_8h_a607cffc585fe3bfcb06b63be2948de4a}{KBLIB\_UNUSED}} \textcolor{keyword}{auto} gen}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00043}00043           = kblib::seeded<std::discard\_block\_engine<std::minstd\_rand, 16, 8>>();}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00044}00044       std::clog << \textcolor{charliteral}{'\(\backslash\)n'};}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00045}00045       std::clog << \textcolor{stringliteral}{"{}RANLUX 24: "{}};}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00046}00046       \mbox{\hyperlink{tdecl_8h_a607cffc585fe3bfcb06b63be2948de4a}{KBLIB\_UNUSED}} \textcolor{keyword}{auto} gen2 = kblib::seeded<std::ranlux24>();}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00047}00047       std::clog << \textcolor{charliteral}{'\(\backslash\)n'};}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00048}00048       \textcolor{keyword}{static\_assert}(}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00049}00049           \mbox{\hyperlink{namespacekblib_ac35f43d37c7552bbbbe7ff67cff88bc8}{kblib::state\_size\_v}}<}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00050}00050               std::discard\_block\_engine<std::minstd\_rand, 16, 8>> == 1,}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00051}00051           \textcolor{stringliteral}{"{}."{}});}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00052}00052       \textcolor{keyword}{static\_assert}(\mbox{\hyperlink{namespacekblib_ac35f43d37c7552bbbbe7ff67cff88bc8}{kblib::state\_size\_v}}<}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00053}00053                         std::discard\_block\_engine<std::mt19937, 16, 8>> == 624,}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00054}00054                     \textcolor{stringliteral}{"{}."{}});}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00055}00055       \textcolor{keyword}{static\_assert}(kblib::state\_size\_v<std::ranlux24> == 24, \textcolor{stringliteral}{"{}."{}});}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00056}00056    \}}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00057}00057    SECTION(\textcolor{stringliteral}{"{}Independent Bits Engine"{}}) \{}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00058}00058       std::clog << \textcolor{stringliteral}{"{}IBE: "{}};}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00059}00059       \mbox{\hyperlink{tdecl_8h_a607cffc585fe3bfcb06b63be2948de4a}{KBLIB\_UNUSED}} \textcolor{keyword}{auto} gen}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00060}00060           = \mbox{\hyperlink{namespacekblib_a57f70c5d0b049085ef57f5e892834e64}{kblib::seeded}}<std::independent\_bits\_engine<std::ranlux24, 32,}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00061}00061                                                        std::uint\_fast32\_t>>();}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00062}00062       std::clog << \textcolor{charliteral}{'\(\backslash\)n'};}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00063}00063       \textcolor{keyword}{static\_assert}(\mbox{\hyperlink{namespacekblib_ac35f43d37c7552bbbbe7ff67cff88bc8}{kblib::state\_size\_v}}<std::independent\_bits\_engine<}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00064}00064                             std::ranlux24, 32, std::uint\_fast32\_t>> == 24,}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00065}00065                     \textcolor{stringliteral}{"{}."{}});}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00066}00066       \textcolor{keyword}{static\_assert}(\mbox{\hyperlink{namespacekblib_ac35f43d37c7552bbbbe7ff67cff88bc8}{kblib::state\_size\_v}}<std::independent\_bits\_engine<}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00067}00067                             std::mt19937, 32, std::uint\_fast32\_t>> == 624,}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00068}00068                     \textcolor{stringliteral}{"{}."{}});}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00069}00069       \textcolor{keyword}{static\_assert}(\mbox{\hyperlink{namespacekblib_ac35f43d37c7552bbbbe7ff67cff88bc8}{kblib::state\_size\_v}}<std::independent\_bits\_engine<}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00070}00070                             std::minstd\_rand, 32, std::uint\_fast32\_t>> == 1,}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00071}00071                     \textcolor{stringliteral}{"{}."{}});}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00072}00072    \}}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00073}00073    SECTION(\textcolor{stringliteral}{"{}Shuffle Order Engine"{}}) \{}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00074}00074       std::clog << \textcolor{stringliteral}{"{}SOE: "{}};}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00075}00075       \mbox{\hyperlink{tdecl_8h_a607cffc585fe3bfcb06b63be2948de4a}{KBLIB\_UNUSED}} \textcolor{keyword}{auto} gen}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00076}00076           = kblib::seeded<std::shuffle\_order\_engine<std::ranlux24, 32>>();}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00077}00077       std::clog << \textcolor{charliteral}{'\(\backslash\)n'};}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00078}00078       \textcolor{keyword}{static\_assert}(\mbox{\hyperlink{namespacekblib_ac35f43d37c7552bbbbe7ff67cff88bc8}{kblib::state\_size\_v}}<}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00079}00079                         std::shuffle\_order\_engine<std::ranlux24, 32>> == 24,}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00080}00080                     \textcolor{stringliteral}{"{}."{}});}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00081}00081       \textcolor{keyword}{static\_assert}(\mbox{\hyperlink{namespacekblib_ac35f43d37c7552bbbbe7ff67cff88bc8}{kblib::state\_size\_v}}<}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00082}00082                         std::shuffle\_order\_engine<std::mt19937, 32>> == 624,}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00083}00083                     \textcolor{stringliteral}{"{}."{}});}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00084}00084       \textcolor{keyword}{static\_assert}(\mbox{\hyperlink{namespacekblib_ac35f43d37c7552bbbbe7ff67cff88bc8}{kblib::state\_size\_v}}<}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00085}00085                         std::shuffle\_order\_engine<std::minstd\_rand, 32>> == 1,}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00086}00086                     \textcolor{stringliteral}{"{}."{}});}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00087}00087    \}}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00088}00088 \}}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00089}00089 }
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00090}\mbox{\hyperlink{random_8cpp_a4f5eebbec23757652decba35390b8c08}{00090}} \mbox{\hyperlink{random_8cpp_a7da4eb9327c01da6ca569d546afe3e15}{TEST\_CASE}}(\textcolor{stringliteral}{"{}transform\_engine"{}}) \{}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00091}00091    \textcolor{keyword}{using }E}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00092}00092        = \mbox{\hyperlink{classkblib_1_1transform__engine}{kblib::transform\_engine}}<std::ranlux24,}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00093}00093                                  \mbox{\hyperlink{structkblib_1_1shift__mask}{kblib::shift\_mask<std::uint\_fast32\_t, 16u>}}>;}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00094}00094    \textcolor{keyword}{auto} gen = kblib::seeded<E>();}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00095}00095    \textcolor{keyword}{static\_assert}(\mbox{\hyperlink{namespacekblib_1_1nums_a24555c4b07301e176bf192adf4e80499}{E::min}}() == 0, \textcolor{stringliteral}{"{}."{}});}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00096}00096    \textcolor{keyword}{static\_assert}(\mbox{\hyperlink{namespacekblib_1_1nums_a64067ecc4167ce1cfe32860ef5c1dc47}{E::max}}() == ((\mbox{\hyperlink{namespacekblib_1_1nums_a64067ecc4167ce1cfe32860ef5c1dc47}{std::ranlux24::max}}() >> 16u)), \textcolor{stringliteral}{"{}."{}});}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00097}00097    SECTION(\textcolor{stringliteral}{"{}copying"{}}) \{}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00098}00098       \textcolor{keyword}{auto} gen1 = gen;}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00099}00099       REQUIRE(gen == gen1);}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00100}00100    \}}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00101}00101    SECTION(\textcolor{stringliteral}{"{}i/o"{}}) \{}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00102}00102       \textcolor{keyword}{decltype}(gen) gen1, gen2;}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00103}00103       REQUIRE(gen1 == gen2);}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00104}00104       REQUIRE(gen != gen1);}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00105}00105       REQUIRE(gen != gen2);}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00106}00106       std::stringstream ss;}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00107}00107       ss << gen;}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00108}00108       ss >> gen1;}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00109}00109       REQUIRE(gen == gen1);}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00110}00110       REQUIRE(gen != gen2);}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00111}00111       REQUIRE(gen1 != gen2);}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00112}00112    \}}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00113}00113    std::uniform\_int\_distribution<int> dist;}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00114}00114    (void)dist(gen);}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00115}00115 \}}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00116}00116 }
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00117}\mbox{\hyperlink{random_8cpp_a9e9c2062f6bc12cb5246c485bb599d05}{00117}} \mbox{\hyperlink{random_8cpp_a7da4eb9327c01da6ca569d546afe3e15}{TEST\_CASE}}(\textcolor{stringliteral}{"{}LCG verification"{}}) \{}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00118}00118    \textcolor{comment}{//}}
\DoxyCodeLine{\Hypertarget{random_8cpp_source_l00119}00119 \}}

\end{DoxyCode}
