]> www.ginac.de Git - cln.git/blob - tests/timeRAtoLF.cc
Enable modifying operators by default.
[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 using namespace cln;
12
13 int main (int argc, char * argv[])
14 {
15         int repetitions = 1;
16         if ((argc >= 3) && !strcmp(argv[1],"-r")) {
17                 repetitions = atoi(argv[2]);
18                 argc -= 2; argv += 2;
19         }
20         if (argc < 4)
21                 exit(1);
22         uintL m1 = atoi(argv[1]);
23         cl_I m2 = cl_I(argv[2]);
24         cl_I M2 = (cl_I)1 << (intDsize*m2);
25         cl_I m3 = cl_I(argv[3]);
26         cl_I M3 = (cl_I)1 << (intDsize*m3);
27         float_format_t M1 = (float_format_t)(m1*intDsize);
28         cl_I u;
29         cl_I v;
30         do { u = random_I(M2); } while (zerop(u));
31         do { v = random_I(M3); } while (zerop(v) || gcd(u,v) > 1);
32         cl_RA y = u / v;
33         cl_F p;
34         { CL_TIMING;
35           for (int rep = repetitions; rep > 0; rep--)
36             { p = cl_float(u,M1)/cl_float(v,M1); }
37         }
38         cout << p << endl;
39         { CL_TIMING;
40           for (int rep = repetitions; rep > 0; rep--)
41             { p = cl_float(y,M1); }
42         }
43         cout << p << endl;
44 }