]> www.ginac.de Git - cln.git/blob - tests/timeLFRAmul.cc
* src/base/digitseq/cl_DS.h: #undef DS, needed for i386-Solaris.
[cln.git] / tests / timeLFRAmul.cc
1 #include <cln/number.h>
2 #include <cln/io.h>
3 #include <cln/integer.h>
4 #include <cln/lfloat.h>
5 #include "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 using namespace cln;
13
14 int main (int argc, char * argv[])
15 {
16         int repetitions = 1;
17         if ((argc >= 3) && !strcmp(argv[1],"-r")) {
18                 repetitions = atoi(argv[2]);
19                 argc -= 2; argv += 2;
20         }
21         if (argc < 4)
22                 exit(1);
23         uintL m1 = atoi(argv[1]);
24         cl_I m2 = cl_I(argv[2]);
25         cl_I M2 = (cl_I)1 << (intDsize*m2);
26         cl_I m3 = cl_I(argv[3]);
27         cl_I M3 = (cl_I)1 << (intDsize*m3);
28         cl_LF x = The(cl_LF)(random_F(cl_I_to_LF(1,m1)));
29         cl_I u;
30         cl_I v;
31         do { u = random_I(M2); } while (zerop(u));
32         do { v = random_I(M3); } while (zerop(v) || gcd(u,v) > 1);
33         cl_RA y = u / v;
34         cl_F p;
35         { CL_TIMING;
36           for (int rep = repetitions; rep > 0; rep--)
37             { p = cl_LF_I_div(The(cl_LF)(cl_LF_I_mul(x,u)),v); }
38         }
39         cout << p << endl;
40         { CL_TIMING;
41           for (int rep = repetitions; rep > 0; rep--)
42             { p = x * cl_RA_to_LF(y,TheLfloat(x)->len); }
43         }
44         cout << p << endl;
45 }