]> www.ginac.de Git - cln.git/blob - tests/timeRALFdiv.cc
Fetch imported m4 files during autogen.sh invocation.
[cln.git] / tests / timeRALFdiv.cc
1 #include <cln/number.h>
2 #include <cln/io.h>
3 #include <cln/integer.h>
4 #include <cln/lfloat.h>
5 #include "float/lfloat/cl_LF.h"
6 #include <cln/rational.h>
7 #include <cln/float_io.h>
8 #include <cln/random.h>
9 #include <cstdlib>
10 #include <cstring>
11 #include <cln/timing.h>
12 #include <iostream>
13 using namespace cln;
14 using namespace std;
15
16 int main (int argc, char * argv[])
17 {
18         int repetitions = 1;
19         if ((argc >= 3) && !strcmp(argv[1],"-r")) {
20                 repetitions = atoi(argv[2]);
21                 argc -= 2; argv += 2;
22         }
23         if (argc < 4)
24                 exit(1);
25         cl_I m1 = cl_I(argv[1]);
26         cl_I M1 = (cl_I)1 << (intDsize*m1);
27         cl_I m2 = cl_I(argv[2]);
28         cl_I M2 = (cl_I)1 << (intDsize*m2);
29         uintL m3 = atoi(argv[1]);
30         cl_I u;
31         cl_I v;
32         do { u = random_I(M1); } while (zerop(u));
33         do { v = random_I(M2); } while (zerop(v) || gcd(u,v) > 1);
34         cl_RA x = u / v;
35         cl_LF y = The(cl_LF)(random_F(cl_I_to_LF(1,m3)));
36         cl_F p;
37         { CL_TIMING;
38           for (int rep = repetitions; rep > 0; rep--)
39             { p = The(cl_LF)(cl_I_LF_div(u,The(cl_LF)(cl_LF_I_mul(y,v)))); }
40         }
41         cout << p << endl;
42         { CL_TIMING;
43           for (int rep = repetitions; rep > 0; rep--)
44             { p = cl_RA_to_LF(x,TheLfloat(y)->len) / y; }
45         }
46         cout << p << endl;
47 }