]> www.ginac.de Git - cln.git/blob - tests/timeRALFdiv.cc
Initial revision
[cln.git] / tests / timeRALFdiv.cc
1 #include <cl_number.h>
2 #include <cl_io.h>
3 #include <cl_integer.h>
4 #include <cl_lfloat.h>
5 #include "cl_LF.h"
6 #include <cl_rational.h>
7 #include <cl_float_io.h>
8 #include <cl_random.h>
9 #include <stdlib.h>
10 #include <string.h>
11 #include <cl_timing.h>
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         cl_I m1 = cl_I(argv[1]);
23         cl_I M1 = (cl_I)1 << (intDsize*m1);
24         cl_I m2 = cl_I(argv[2]);
25         cl_I M2 = (cl_I)1 << (intDsize*m2);
26         uintL m3 = atoi(argv[1]);
27         cl_I u;
28         cl_I v;
29         do { u = random_I(M1); } while (zerop(u));
30         do { v = random_I(M2); } while (zerop(v) || gcd(u,v) > 1);
31         cl_RA x = u / v;
32         cl_LF y = The(cl_LF)(random_F(cl_I_to_LF(1,m3)));
33         cl_F p;
34         { CL_TIMING;
35           for (int rep = repetitions; rep > 0; rep--)
36             { p = The(cl_LF)(cl_I_LF_div(u,The(cl_LF)(cl_LF_I_mul(y,v)))); }
37         }
38         cout << p << endl;
39         { CL_TIMING;
40           for (int rep = repetitions; rep > 0; rep--)
41             { p = cl_RA_to_LF(x,TheLfloat(y)->len) / y; }
42         }
43         cout << p << endl;
44 }