]> www.ginac.de Git - cln.git/blob - tests/timeRAtoLF.cc
benchmarks: time{catalan,euler,exp1,zeta3}.cc actually compile and work now.
[cln.git] / tests / timeRAtoLF.cc
1 #include <cln/number.h>
2 #include <cln/io.h>
3 #include <cln/integer.h>
4 #include <cln/lfloat.h>
5 #include <cln/rational.h>
6 #include <cln/float_io.h>
7 #include <cln/random.h>
8 #include <cstdlib>
9 #include <cstring>
10 #include <cln/timing.h>
11 #include <iostream>
12 using namespace cln;
13 using namespace std;
14
15 int main (int argc, char * argv[])
16 {
17         int repetitions = 1;
18         if ((argc >= 3) && !strcmp(argv[1],"-r")) {
19                 repetitions = atoi(argv[2]);
20                 argc -= 2; argv += 2;
21         }
22         if (argc < 4)
23                 exit(1);
24         uintL m1 = atoi(argv[1]);
25         cl_I m2 = cl_I(argv[2]);
26         cl_I M2 = (cl_I)1 << (intDsize*m2);
27         cl_I m3 = cl_I(argv[3]);
28         cl_I M3 = (cl_I)1 << (intDsize*m3);
29         float_format_t M1 = (float_format_t)(m1*intDsize);
30         cl_I u;
31         cl_I v;
32         do { u = random_I(M2); } while (zerop(u));
33         do { v = random_I(M3); } while (zerop(v) || gcd(u,v) > 1);
34         cl_RA y = u / v;
35         cl_F p;
36         { CL_TIMING;
37           for (int rep = repetitions; rep > 0; rep--)
38             { p = cl_float(u,M1)/cl_float(v,M1); }
39         }
40         cout << p << endl;
41         { CL_TIMING;
42           for (int rep = repetitions; rep > 0; rep--)
43             { p = cl_float(y,M1); }
44         }
45         cout << p << endl;
46 }