14 #ifndef __INCLUDED__SCOPIRA_TOOL_LINCONRANDOM_H__ 15 #define __INCLUDED__SCOPIRA_TOOL_LINCONRANDOM_H__ 19 #include <scopira/tool/constmod.h> 20 #include <scopira/tool/platform.h> 26 template<
class IntType, IntType a, IntType c, IntType m, IntType val>
50 template<
class IntType, IntType a, IntType c, IntType m, IntType val>
54 typedef IntType result_type;
56 static const bool has_fixed_range =
true;
57 static const result_type min_value = ( c == 0 ? 1 : 0 );
58 static const result_type max_value = m-1;
70 void seed(IntType x0) { assert(c || x0); _x = x0; }
71 result_type min(
void)
const {
return c == 0 ? 1 : 0; }
72 result_type max(
void)
const {
return m-1; }
80 bool validation(IntType x)
const {
return val == x; }
96 typedef int32_t result_type;
97 static const bool has_fixed_range =
true;
98 static const int32_t min_value = 0;
101 int32_t min(
void)
const {
return 0; }
102 int32_t max(
void)
const {
return std::numeric_limits<int32_t>::max(); }
104 explicit rand48(int32_t x0 = 1) : lcf(cnv(x0)) { }
105 explicit rand48(uint64_t x0) : lcf(x0) { }
110 void seed(int32_t x0 = 1) { lcf.seed(cnv(x0)); }
111 void seed(uint64_t x0) { lcf.seed(x0); }
114 int32_t
operator()(
void) {
return static_cast<int32_t
>(lcf() >> 17); }
118 0xB, uint64_t(1)<<48, 0> lcf;
121 static uint64_t cnv(int32_t x) {
return (static_cast<uint64_t>(x) << 16) | 0x330e; }
Definition: archiveflow.h:20