]> www.ginac.de Git - cln.git/blob - tests/timeMImisc5.cc
benchmarks: time{catalan,euler,exp1,zeta3}.cc actually compile and work now.
[cln.git] / tests / timeMImisc5.cc
1 #include <cln/number.h>
2 #include <cln/io.h>
3 #include <cln/integer.h>
4 #include <cln/modinteger.h>
5 #include <cstdlib>
6 #include <cstring>
7 #include <cln/timing.h>
8 using namespace cln;
9 #include <iostream>
10 using namespace std;
11
12 int main (int argc, char * argv[])
13 {
14         int repetitions = 1;
15         if ((argc >= 3) && !strcmp(argv[1],"-r")) {
16                 repetitions = atoi(argv[2]);
17                 argc -= 2; argv += 2;
18         }
19         if (argc < 1)
20                 exit(1);
21         cl_I p = "1269281897404513557783934075031171555202695168107";
22         cl_modint_ring R = find_modint_ring(p);
23         {
24                 cl_MI a = R->canonhom("1111111111111111111111111111111111111111111111111");
25                 cl_MI b = R->canonhom("777777777777777777777777777777777777777777777777");
26                 cout << "product modulo p" << endl;
27                 { CL_TIMING;
28                   for (int rep = repetitions; rep > 0; rep--)
29                     { cl_MI c = R->mul(a,b); }
30                 }
31                 cout << "square modulo p" << endl;
32                 { CL_TIMING;
33                   for (int rep = repetitions; rep > 0; rep--)
34                     { cl_MI c = R->square(a); }
35                 }
36                 cout << "quotient modulo p" << endl;
37                 { CL_TIMING;
38                   for (int rep = repetitions; rep > 0; rep--)
39                     { cl_MI c = R->div(a,b); }
40                 }
41         }
42         {
43                 cl_MI a = R->canonhom("1234567890123456789012345678901234567890123456789");
44                 cl_MI b = R->canonhom("909090909090909090909090909090909090909090909090");
45                 cout << "product modulo p" << endl;
46                 { CL_TIMING;
47                   for (int rep = repetitions; rep > 0; rep--)
48                     { cl_MI c = R->mul(a,b); }
49                 }
50                 cout << "square modulo p" << endl;
51                 { CL_TIMING;
52                   for (int rep = repetitions; rep > 0; rep--)
53                     { cl_MI c = R->square(a); }
54                 }
55                 cout << "quotient modulo p" << endl;
56                 { CL_TIMING;
57                   for (int rep = repetitions; rep > 0; rep--)
58                     { cl_MI c = R->div(a,b); }
59                 }
60         }
61 }