39 #define repeat for (int i = 0; i < 1000; ++i)
45 std::vector<unsigned long> v(Random::SeedVector());
46 unsigned long w = Random::SeedWord();
47 std::string s(Random::VectorToString(v));
49 { Random r(v.begin(), v.end()); }
50 int a[] = {1, 2, 3, 4};
51 { Random r(a, a + 4); }
57 r.Reseed(v.begin(), v.end());
63 r.Reseed(Random::VectorToString(v));
64 r.Reseed(Random::StringToVector(s));
74 repeat r.Integer<
signed char, 3>();
75 repeat r.Integer<
unsigned char, 3>();
76 repeat r.Integer<
signed short, 3>();
79 repeat r.Integer<
signed short>();
80 repeat r.Integer<
signed short>(52);
81 repeat r.IntegerC<
signed short>(51);
82 repeat r.IntegerC<
signed short>(1,52);
91 repeat { r.Fixed <float, 16 >(); r.Fixed <
float>(); r.Fixed (); }
92 repeat { r.FixedU<float, 16 >(); r.FixedU<
float>(); r.FixedU(); }
93 repeat { r.FixedN<float, 16 >(); r.FixedN<
float>(); r.FixedN(); }
94 repeat { r.FixedW<float, 16 >(); r.FixedW<
float>(); r.FixedW(); }
95 repeat { r.FixedS<float, 16 >(); r.FixedS<
float>(); r.FixedS(); }
96 repeat { r.FixedO<float, 16 >(); r.FixedO<
float>(); r.FixedO(); }
97 repeat { r.Float <float, 4, 2>(); r.Float <
float>(); r.Float (); }
98 repeat { r.FloatU<float, 4, 2>(); r.FloatU<
float>(); r.FloatU(); }
99 repeat { r.FloatN<float, 4, 2>(); r.FloatN<
float>(); r.FloatN(); }
100 repeat { r.FloatW<float, 4, 2>(); r.FloatW<
float>(); r.FloatW(); }
101 repeat { r.Real<
float>(); r.Real(); }
128 unsigned w[] = { 0, 0, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1 };
129 std::vector<int> wi(13);
130 std::vector<float> wf(13);
131 for (
int i = 0; i < 13; ++i) {
147 sel.
Init(wi.begin(), wi.end());
158 sel.
Init(wi.begin(), wi.end());
188 std::ostringstream os;
207 std::ostringstream os;
222 std::ostringstream os;
238 std::ostringstream os;
253 std::ostringstream os;
268 std::ostringstream os;
317 std::vector<unsigned long> v(Random::SeedVector());
318 unsigned long w = Random::SeedWord();
319 std::string s(Random::VectorToString(v));
321 { Random r(v.begin(), v.end()); }
322 int a[] = {1, 2, 3, 4};
323 { Random r(a, a + 4); }
329 r.Reseed(v.begin(), v.end());
335 r.Reseed(Random::VectorToString(v));
336 r.Reseed(Random::StringToVector(s));
346 repeat r.Integer<
signed char, 3>();
347 repeat r.Integer<
unsigned char, 3>();
348 repeat r.Integer<
signed short, 3>();
351 repeat r.Integer<
signed short>();
352 repeat r.Integer<
signed short>(52);
353 repeat r.IntegerC<
signed short>(51);
354 repeat r.IntegerC<
signed short>(1,52);
363 repeat { r.Fixed <float, 16 >(); r.Fixed <
float>(); r.Fixed (); }
364 repeat { r.FixedU<float, 16 >(); r.FixedU<
float>(); r.FixedU(); }
365 repeat { r.FixedN<float, 16 >(); r.FixedN<
float>(); r.FixedN(); }
366 repeat { r.FixedW<float, 16 >(); r.FixedW<
float>(); r.FixedW(); }
367 repeat { r.FixedS<float, 16 >(); r.FixedS<
float>(); r.FixedS(); }
368 repeat { r.FixedO<float, 16 >(); r.FixedO<
float>(); r.FixedO(); }
369 repeat { r.Float <float, 4, 2>(); r.Float <
float>(); r.Float (); }
370 repeat { r.FloatU<float, 4, 2>(); r.FloatU<
float>(); r.FloatU(); }
371 repeat { r.FloatN<float, 4, 2>(); r.FloatN<
float>(); r.FloatN(); }
372 repeat { r.FloatW<float, 4, 2>(); r.FloatW<
float>(); r.FloatW(); }
373 repeat { r.Real<
float>(); r.Real(); }
400 unsigned w[] = { 0, 0, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1 };
401 std::vector<int> wi(13);
402 std::vector<float> wf(13);
403 for (
int i = 0; i < 13; ++i) {
419 sel.
Init(wi.begin(), wi.end());
430 sel.
Init(wi.begin(), wi.end());
460 std::ostringstream os;
479 std::ostringstream os;
494 std::ostringstream os;
510 std::ostringstream os;
525 std::ostringstream os;
540 std::ostringstream os;
586 std::cout <<
"RandomLib Coverage Test\n";
591 using namespace RandomLib;
594 s(
"0x123,0x234,0x345,0x456");
596 bool pass = s() == 3460025646U;
597 std::cout <<
"Check " << s.
Name()
598 << (pass ?
" passed\n" :
" FAILED\n");
599 if (!pass) retval = 1;
603 s(
"0x12345,0,0x23456,0,0x34567,0,0x45678,0");
605 bool pass = s() == 994412663058993407ULL;
606 std::cout <<
"Check " << s.
Name()
607 << (pass ?
" passed\n" :
" FAILED\n");
608 if (!pass) retval = 1;
613 bool pass = s() == 788493625U;
614 std::cout <<
"Check " << s.
Name()
615 << (pass ?
" passed\n" :
" FAILED\n");
616 if (!pass) retval = 1;
621 bool pass = s() == 13356980519185762498ULL;
622 std::cout <<
"Check " << s.
Name()
623 << (pass ?
" passed\n" :
" FAILED\n");
624 if (!pass) retval = 1;
Header for NormalDistribution.
Header for ExponentialDistribution.
The exponential probability.
Return true with probability 1/e = exp(−1).
Generate random integers, reals, and booleans.
Infinite precision random numbers.
Random selection from a discrete set.
Header for Random, RandomGenerator.
std::pair< double, double > Range() const
const unsigned & RawDigit(unsigned k) const
The discrete normal distribution (alternate version).
Header for DiscreteNormal.
Header for ExactExponential.
The original MT19937 mixing functionality.
RealType Value(Random &r)
void SetCount(long long n)
void swap(RandomLib::RandomCanonical< Generator > &r, RandomLib::RandomCanonical< Generator > &s)
Header for ExponentialProb.
static std::string Name()
bool LessThan(Random &r, RandomNumber &t)
RandomCanonical< RandomGenerator > Random
unsigned Digit(Random &r, unsigned k)
The discrete normal distribution.
Sample exactly from a power distribution.
Uniform random number generator.
Sample exactly from an exponential distribution.
The exponential distribution.
RealType Fraction(Random &r)
Header for InversePiProb.
Sample exactly from a normal distribution.
Header for DiscreteNormalAlt.
Return true with probability 1/π.