32 #ifndef VSMC_RNG_UNIFORM_BITS_DISTRIBUTION_HPP    33 #define VSMC_RNG_UNIFORM_BITS_DISTRIBUTION_HPP    47 template <
typename UIntType>
    50     static_assert(std::is_unsigned<UIntType>::value,
    51         "**UniformBits** USED WITH UIntType OTHER THAN UNSIGNED INTEGER "    55     template <
typename RNGType>
    56     static UIntType 
eval(RNGType &rng)
    58         static constexpr 
int w = std::numeric_limits<UIntType>::digits;
    61         return eval(rng, std::integral_constant<
bool, w <= p>());
    65     template <
typename RNGType>
    66     static UIntType 
eval(RNGType &rng, std::true_type)
    70         return static_cast<UIntType
>(rng() >> r);
    73     template <
typename RNGType>
    74     static UIntType 
eval(RNGType &rng, std::false_type)
    76         return patch<0>(rng, std::true_type());
    79     template <
int, 
typename RNGType>
    80     static UIntType patch(RNGType &, std::false_type)
    85     template <
int N, 
typename RNGType>
    86     static UIntType patch(RNGType &rng, std::true_type)
    88         static constexpr 
int w = std::numeric_limits<UIntType>::digits;
    89         static constexpr 
int v =
    90             std::numeric_limits<typename RNGType::result_type>::digits;
    94         static constexpr 
int q = p + RNGBits<RNGType>::value;
    96         UIntType u = 
static_cast<UIntType
>((rng() << l) >> r);
    99             patch<N + 1>(rng, std::integral_constant<bool, (q < w)>());
   110 template <
typename UIntType>
   117     result_type min()
 const { 
return std::numeric_limits<result_type>::min(); }
   124     template <
typename RNGType>
   134 template <
typename UIntType, 
typename RNGType>
   136     RNGType &rng, std::size_t n, UIntType *r, std::false_type)
   138     for (std::size_t i = 0; i != n; ++i)
   142 template <
typename UIntType, 
typename RNGType>
   144     RNGType &rng, std::size_t n, UIntType *r, std::true_type)
   146     rng_rand(rng, n, reinterpret_cast<typename RNGType::result_type *>(r));
   151 template <
typename UIntType, 
typename RNGType>
   154     static_assert(std::is_unsigned<UIntType>::value,
   155         "**uniform_bits_distribution** USED WITH UIntType OTHER THAN UNSIGNED "   159     static constexpr 
bool eq_bits =
   161     static constexpr 
bool eq_size =
   162         sizeof(
typename RNGType::result_type) == 
sizeof(UIntType);
   163     static constexpr 
bool eq_align =
   164         alignof(
typename RNGType::result_type) == 
alignof(UIntType);
   167         rng, n, r, std::integral_constant<
bool,
   168                        (zero_min && eq_bits && eq_size && eq_align)>());
   175 #endif // VSMC_RNG_UNIFORM_BITS_DISTRIBUTION_HPP 
void uniform_bits_distribution_impl(RNGType &rng, std::size_t n, UIntType *r, std::false_type)
 
#define VSMC_DEFINE_RNG_DISTRIBUTION_RAND_0(Name, name, T)                                    
 
#define VSMC_DEFINE_RNG_DISTRIBUTION_0(Name, name, T, t, Type)                            
 
Find the smallest N such that (RNGType::min() >> N) == 0 
 
Find the largest N such that RNGType::max() >= (M >> (W - N)) where M = std::numeric_limits<typename ...
 
void rng_rand(RNGType &rng, BetaDistribution< RealType > &dist, std::size_t n, RealType *r)
 
void uniform_bits_distribution_impl(RNGType &rng, std::size_t n, UIntType *r, std::true_type)
 
void uniform_bits_distribution(RNGType &, std::size_t, UIntType *)
 
The value of RNGMaxBits<RNGType>::value - RNGMinBits<RNGType>::value.