\hypertarget{random_8h}{}\doxysection{kblib/random.h File Reference} \label{random_8h}\index{kblib/random.h@{kblib/random.h}} Provides utilities to correctly and expressively use C++11\textquotesingle{}s random number generation library, without requiring a PhD. {\ttfamily \#include \char`\"{}algorithm.\+h\char`\"{}}\newline {\ttfamily \#include \char`\"{}iterators.\+h\char`\"{}}\newline {\ttfamily \#include \char`\"{}memory.\+h\char`\"{}}\newline {\ttfamily \#include \char`\"{}simple.\+h\char`\"{}}\newline {\ttfamily \#include \char`\"{}stats.\+h\char`\"{}}\newline {\ttfamily \#include \char`\"{}tdecl.\+h\char`\"{}}\newline {\ttfamily \#include $<$limits$>$}\newline {\ttfamily \#include $<$random$>$}\newline {\ttfamily \#include $<$vector$>$}\newline Include dependency graph for random.\+h\+:\nopagebreak \begin{figure}[H] \begin{center} \leavevmode \includegraphics[width=350pt]{random_8h__incl} \end{center} \end{figure} This graph shows which files directly or indirectly include this file\+:\nopagebreak \begin{figure}[H] \begin{center} \leavevmode \includegraphics[width=181pt]{random_8h__dep__incl} \end{center} \end{figure} \doxysubsection*{Classes} \begin{DoxyCompactItemize} \item class \mbox{\hyperlink{classkblib_1_1trivial__seed__seq}{kblib\+::trivial\+\_\+seed\+\_\+seq}} \item struct \mbox{\hyperlink{structkblib_1_1state__size_3_01std_1_1mersenne__twister__engine_3_01_u_int_type_00_01w_00_01n_001aa3a5268fdc817f552102aaa663250b}{kblib\+::state\+\_\+size$<$ std\+::mersenne\+\_\+twister\+\_\+engine$<$ UInt\+Type, w, n, m, r, a, u, d, s, b, t, c, l, f $>$ $>$}} \item struct \mbox{\hyperlink{structkblib_1_1state__size_3_01std_1_1linear__congruential__engine_3_01_u_int_type_00_01a_00_01c_00_01m_01_4_01_4}{kblib\+::state\+\_\+size$<$ std\+::linear\+\_\+congruential\+\_\+engine$<$ UInt\+Type, a, c, m $>$ $>$}} \item struct \mbox{\hyperlink{structkblib_1_1state__size_3_01std_1_1subtract__with__carry__engine_3_01_u_int_type_00_01w_00_01s_00_01r_01_4_01_4}{kblib\+::state\+\_\+size$<$ std\+::subtract\+\_\+with\+\_\+carry\+\_\+engine$<$ UInt\+Type, w, s, r $>$ $>$}} \item struct \mbox{\hyperlink{structkblib_1_1state__size_3_01std_1_1discard__block__engine_3_01_engine_00_01_p_00_01_r_01_4_01_4}{kblib\+::state\+\_\+size$<$ std\+::discard\+\_\+block\+\_\+engine$<$ Engine, P, R $>$ $>$}} \item struct \mbox{\hyperlink{structkblib_1_1state__size_3_01std_1_1independent__bits__engine_3_01_engine_00_01_w_00_01_u_int_type_01_4_01_4}{kblib\+::state\+\_\+size$<$ std\+::independent\+\_\+bits\+\_\+engine$<$ Engine, W, UInt\+Type $>$ $>$}} \item struct \mbox{\hyperlink{structkblib_1_1state__size_3_01std_1_1shuffle__order__engine_3_01_engine_00_01_k_01_4_01_4}{kblib\+::state\+\_\+size$<$ std\+::shuffle\+\_\+order\+\_\+engine$<$ Engine, K $>$ $>$}} \item class \mbox{\hyperlink{classkblib_1_1transform__engine}{kblib\+::transform\+\_\+engine$<$ URBG, Transform $>$}} \item struct \mbox{\hyperlink{structkblib_1_1state__size_3_01transform__engine_3_01_engine_00_01_transform_01_4_01_4}{kblib\+::state\+\_\+size$<$ transform\+\_\+engine$<$ Engine, Transform $>$ $>$}} \item struct \mbox{\hyperlink{structkblib_1_1shift__mask}{kblib\+::shift\+\_\+mask$<$ UInt\+Type, shift, mask $>$}} \end{DoxyCompactItemize} \doxysubsection*{Namespaces} \begin{DoxyCompactItemize} \item namespace \mbox{\hyperlink{namespacekblib}{kblib}} \begin{DoxyCompactList}\small\item\em The main namespace in which all entities from kblib are defined. \end{DoxyCompactList}\item namespace \mbox{\hyperlink{namespacekblib_1_1lcgs}{kblib\+::lcgs}} \item namespace \mbox{\hyperlink{namespacekblib_1_1lcgs_1_1common__lcgs}{kblib\+::lcgs\+::common\+\_\+lcgs}} \item namespace \mbox{\hyperlink{namespacekblib_1_1lcgs_1_1best__lcgs}{kblib\+::lcgs\+::best\+\_\+lcgs}} \end{DoxyCompactItemize} \doxysubsection*{Typedefs} \begin{DoxyCompactItemize} \item {\footnotesize template$<$typename UInt\+Type , UInt\+Type a, UInt\+Type c, UInt\+Type b$>$ }\\using \mbox{\hyperlink{namespacekblib_1_1lcgs_af914852ecbe5eada9a34db51c5f5cc1f}{kblib\+::lcgs\+::lcg\+\_\+p2}} = std\+::linear\+\_\+congruential\+\_\+engine$<$ UInt\+Type, a, c, ipow2(b)$>$ \item using \mbox{\hyperlink{namespacekblib_1_1lcgs_1_1common__lcgs_adaa60c018d398bb950f65b173d86e9b6}{kblib\+::lcgs\+::common\+\_\+lcgs\+::rand48}} = transform\+\_\+engine$<$ lcg\+\_\+p2$<$ std\+::uint\+\_\+fast64\+\_\+t, 25214903917u, 11u, 48u $>$, shift\+\_\+mask$<$ std\+::uint\+\_\+fast32\+\_\+t, 16u $>$ $>$ \item using \mbox{\hyperlink{namespacekblib_1_1lcgs_1_1common__lcgs_a071dc57b04c71a980f66921ab268e13f}{kblib\+::lcgs\+::common\+\_\+lcgs\+::java\+\_\+rand}} = rand48 \item using \mbox{\hyperlink{namespacekblib_1_1lcgs_1_1common__lcgs_ad24856b64aaf15c7ca9850a32d769b0a}{kblib\+::lcgs\+::common\+\_\+lcgs\+::glibc\+\_\+rand0}} = transform\+\_\+engine$<$ lcg\+\_\+p2$<$ std\+::uint\+\_\+fast32\+\_\+t, 1103515245, 12345, 31u $>$, shift\+\_\+mask$<$ std\+::uint\+\_\+fast32\+\_\+t, 0, ipow2(30) -\/ 1 $>$ $>$ \item using \mbox{\hyperlink{namespacekblib_1_1lcgs_1_1common__lcgs_ad990fdc385e29a01cf7592c042eed05e}{kblib\+::lcgs\+::common\+\_\+lcgs\+::ansic\+\_\+rand}} = transform\+\_\+engine$<$ lcg\+\_\+p2$<$ std\+::uint\+\_\+fast32\+\_\+t, 1103515245, 12345, 31u $>$, shift\+\_\+mask$<$ std\+::uint\+\_\+fast32\+\_\+t, 16, ipow2(14) -\/ 1 $>$ $>$ \item using \mbox{\hyperlink{namespacekblib_1_1lcgs_1_1common__lcgs_a3ad3ced72aa1cb9b9a3e4cbd984c3839}{kblib\+::lcgs\+::common\+\_\+lcgs\+::knuth\+\_\+lcg}} = std\+::linear\+\_\+congruential\+\_\+engine$<$ uint64\+\_\+t, 6364136223846793005U, 1442695040888963407U, 0U $>$ \item using \mbox{\hyperlink{namespacekblib_1_1lcgs_1_1best__lcgs_ab60a688256bee47233387411e5afd7fe}{kblib\+::lcgs\+::best\+\_\+lcgs\+::lcg32}} = lcg\+\_\+p2$<$ std\+::uint\+\_\+fast32\+\_\+t, 0xa13fc965u, 1u, 32u $>$ \item using \mbox{\hyperlink{namespacekblib_1_1lcgs_1_1best__lcgs_ab5965534219bd68a26722774684acd60}{kblib\+::lcgs\+::best\+\_\+lcgs\+::mcg32}} = lcg\+\_\+p2$<$ std\+::uint\+\_\+fast32\+\_\+t, 0x93d765ddu, 0u, 32u $>$ \item using \mbox{\hyperlink{namespacekblib_1_1lcgs_1_1best__lcgs_aa55fbc84bf1ec46b260eb49216346a4e}{kblib\+::lcgs\+::best\+\_\+lcgs\+::lcg48}} = lcg\+\_\+p2$<$ std\+::uint\+\_\+fast64\+\_\+t, 0xb67a49a5466du, 1u, 48u $>$ \item using \mbox{\hyperlink{namespacekblib_1_1lcgs_1_1best__lcgs_a3e2b07fbd94b01abf25d1904fe9992f7}{kblib\+::lcgs\+::best\+\_\+lcgs\+::mcg48}} = lcg\+\_\+p2$<$ std\+::uint\+\_\+fast64\+\_\+t, 0xbdcdbb079f8du, 0u, 48u $>$ \item using \mbox{\hyperlink{namespacekblib_1_1lcgs_1_1best__lcgs_afe793993d3d6cba804a0a4bcf6bd5529}{kblib\+::lcgs\+::best\+\_\+lcgs\+::lcg64}} = lcg\+\_\+p2$<$ std\+::uint\+\_\+fast64\+\_\+t, 0xaf251af3b0f025b5u, 1u, 64u $>$ \item using \mbox{\hyperlink{namespacekblib_1_1lcgs_1_1best__lcgs_a52e7c8798d17e80f55ebe006b4ec1e6d}{kblib\+::lcgs\+::best\+\_\+lcgs\+::mcg64}} = lcg\+\_\+p2$<$ std\+::uint\+\_\+fast64\+\_\+t, 0xf1357aea2e62a9c5u, 0u, 64u $>$ \end{DoxyCompactItemize} \doxysubsection*{Functions} \begin{DoxyCompactItemize} \item {\footnotesize template$<$typename Array , typename Random\+Generator , typename freqtype = double$>$ }\\constexpr auto \mbox{\hyperlink{namespacekblib_af901ee65b94ee7e3a2537b6ea846ba28}{kblib\+::choose\+Categorical}} (Array \&\&cats, Random\+Generator \&r) -\/$>$ decltype(cats.\+size()) \begin{DoxyCompactList}\small\item\em Given a categorical distribution cats, selects one category. \end{DoxyCompactList}\item {\footnotesize template$<$typename Gen , typename Source $>$ }\\auto \mbox{\hyperlink{namespacekblib_a57f70c5d0b049085ef57f5e892834e64}{kblib\+::seeded}} (Source \&\&s) -\/$>$ Gen \item {\footnotesize template$<$typename Gen $>$ }\\auto \mbox{\hyperlink{namespacekblib_a5057ba63335ea5487c0370c3ce5bc332}{kblib\+::seeded}} () -\/$>$ Gen \item {\footnotesize template$<$typename UInt\+Type $>$ }\\constexpr auto \mbox{\hyperlink{namespacekblib_a5a9fb5dbd7082695242567ef3bdfe89c}{kblib\+::ipow2}} (UInt\+Type b) noexcept -\/$>$ UInt\+Type \end{DoxyCompactItemize} \doxysubsection*{Variables} \begin{DoxyCompactItemize} \item {\footnotesize template$<$typename T $>$ }\\constexpr std\+::size\+\_\+t \mbox{\hyperlink{namespacekblib_ac35f43d37c7552bbbbe7ff67cff88bc8}{kblib\+::state\+\_\+size\+\_\+v}} = state\+\_\+size$<$T$>$\+::value \item {\footnotesize template$<$typename T , typename = void$>$ }\\constexpr std\+::size\+\_\+t \mbox{\hyperlink{namespacekblib_acfb1b995fef3970d7ece0836d0b8b232}{kblib\+::seed\+\_\+discard\+\_\+v}} = 0 \end{DoxyCompactItemize} \doxysubsection{Detailed Description} Provides utilities to correctly and expressively use C++11\textquotesingle{}s random number generation library, without requiring a PhD. \begin{DoxyAuthor}{Author} killerbee \end{DoxyAuthor} \begin{DoxyDate}{Date} 2019-\/2021 \end{DoxyDate} \begin{DoxyCopyright}{Copyright} GNU General Public Licence v3.\+0 \end{DoxyCopyright} Definition in file \mbox{\hyperlink{random_8h_source}{random.\+h}}.