kblib 0.2.3
General utilities library for modern C++
random.h File Reference

Provides utilities to correctly and expressively use C++11's random number generation library, without requiring a PhD. More...

#include "algorithm.h"
#include "iterators.h"
#include "memory.h"
#include "simple.h"
#include "stats.h"
#include "tdecl.h"
#include <limits>
#include <random>
#include <vector>
Include dependency graph for random.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  kblib::trivial_seed_seq
 
struct  kblib::state_size< std::mersenne_twister_engine< UIntType, w, n, m, r, a, u, d, s, b, t, c, l, f > >
 
struct  kblib::state_size< std::linear_congruential_engine< UIntType, a, c, m > >
 
struct  kblib::state_size< std::subtract_with_carry_engine< UIntType, w, s, r > >
 
struct  kblib::state_size< std::discard_block_engine< Engine, P, R > >
 
struct  kblib::state_size< std::independent_bits_engine< Engine, W, UIntType > >
 
struct  kblib::state_size< std::shuffle_order_engine< Engine, K > >
 
class  kblib::transform_engine< URBG, Transform >
 
struct  kblib::state_size< transform_engine< Engine, Transform > >
 
struct  kblib::shift_mask< UIntType, shift, mask >
 

Namespaces

namespace  kblib
 The main namespace in which all entities from kblib are defined.
 
namespace  kblib::lcgs
 
namespace  kblib::lcgs::common_lcgs
 
namespace  kblib::lcgs::best_lcgs
 

Typedefs

template<typename UIntType , UIntType a, UIntType c, UIntType b>
using kblib::lcgs::lcg_p2 = std::linear_congruential_engine< UIntType, a, c, ipow2(b)>
 
using kblib::lcgs::common_lcgs::rand48 = transform_engine< lcg_p2< std::uint_fast64_t, 25214903917u, 11u, 48u >, shift_mask< std::uint_fast32_t, 16u > >
 
using kblib::lcgs::common_lcgs::java_rand = rand48
 
using 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 > >
 
using 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 > >
 
using kblib::lcgs::common_lcgs::knuth_lcg = std::linear_congruential_engine< uint64_t, 6364136223846793005U, 1442695040888963407U, 0U >
 
using kblib::lcgs::best_lcgs::lcg32 = lcg_p2< std::uint_fast32_t, 0xa13fc965u, 1u, 32u >
 
using kblib::lcgs::best_lcgs::mcg32 = lcg_p2< std::uint_fast32_t, 0x93d765ddu, 0u, 32u >
 
using kblib::lcgs::best_lcgs::lcg48 = lcg_p2< std::uint_fast64_t, 0xb67a49a5466du, 1u, 48u >
 
using kblib::lcgs::best_lcgs::mcg48 = lcg_p2< std::uint_fast64_t, 0xbdcdbb079f8du, 0u, 48u >
 
using kblib::lcgs::best_lcgs::lcg64 = lcg_p2< std::uint_fast64_t, 0xaf251af3b0f025b5u, 1u, 64u >
 
using kblib::lcgs::best_lcgs::mcg64 = lcg_p2< std::uint_fast64_t, 0xf1357aea2e62a9c5u, 0u, 64u >
 

Functions

template<typename Array , typename RandomGenerator , typename freqtype = double>
constexpr auto kblib::chooseCategorical (Array &&cats, RandomGenerator &r) -> decltype(cats.size())
 Given a categorical distribution cats, selects one category. More...
 
template<typename Gen , typename Source >
auto kblib::seeded (Source &&s) -> Gen
 
template<typename Gen >
auto kblib::seeded () -> Gen
 
template<typename UIntType >
constexpr auto kblib::ipow2 (UIntType b) noexcept -> UIntType
 

Variables

template<typename T >
constexpr std::size_t kblib::state_size_v = state_size<T>::value
 
template<typename T , typename = void>
constexpr std::size_t kblib::seed_discard_v = 0
 

Detailed Description

Provides utilities to correctly and expressively use C++11's random number generation library, without requiring a PhD.

Author
killerbee
Date
2019-2021

Definition in file random.h.