Make Qt4 work
[ipdf/code.git] / src / tests / rationalrange.cpp
1 #include "main.h"
2 #include "rational.h"
3 #include <cassert>
4 #include <list>
5
6 using namespace std;
7 using namespace IPDF;
8
9 int main(int argc, char ** argv)
10 {
11         typedef uint64_t Uint;
12         typedef pair<pair<Uint, Uint>, Rational<Uint> > RatPear;
13
14         for (int i = 0; i < (int)(1e4); ++i)
15         {
16                 double test = double(rand() % (int)(1e12)) * double(rand() % (int)(1e12)) / double(rand() % (int)1e12);
17                 Rational<Uint> r(test);
18                 printf("%f\t%f\t%f\t%lu\t%lu\n", test, r.ToDouble(), fabs(r.ToDouble() - test), r.P, r.Q);
19         }
20
21 #if 0
22         list<RatPear> space;
23         for (Uint p = 0; p < 128; ++p)
24         {
25                 for (Uint q = 0; q < 128; ++q)
26                 {
27                         space.push_back(RatPear(pair<Uint, Uint>(p,q), Rational<Uint>(p,q)));
28                 }
29         }
30         space.sort([=](const RatPear & a, const RatPear & b){return a.second < b.second;});
31         for (auto i = space.begin(); i != space.end(); ++i)
32         {
33                 if (i->second.Q != 0)
34                         printf("%li\t%li\t%li\t%li\t%f\n", i->first.first, i->first.second, i->second.P, i->second.Q, i->second.ToDouble());
35         }
36 #endif
37 }

UCC git Repository :: git.ucc.asn.au