]> www.ginac.de Git - cln.git/blob - tests/timeMImisc5.cc
* Last bits for release 1.1.5.
[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 <stdlib.h>
6 #include <string.h>
7 #include <cln/timing.h>
8 using namespace cln;
9
10 int main (int argc, char * argv[])
11 {
12         int repetitions = 1;
13         if ((argc >= 3) && !strcmp(argv[1],"-r")) {
14                 repetitions = atoi(argv[2]);
15                 argc -= 2; argv += 2;
16         }
17         if (argc < 1)
18                 exit(1);
19         cl_I p = "1269281897404513557783934075031171555202695168107";
20         cl_modint_ring R = find_modint_ring(p);
21         {
22                 cl_MI a = R->canonhom("1111111111111111111111111111111111111111111111111");
23                 cl_MI b = R->canonhom("777777777777777777777777777777777777777777777777");
24                 cout << "product modulo p" << endl;
25                 { CL_TIMING;
26                   for (int rep = repetitions; rep > 0; rep--)
27                     { cl_MI c = R->mul(a,b); }
28                 }
29                 cout << "square modulo p" << endl;
30                 { CL_TIMING;
31                   for (int rep = repetitions; rep > 0; rep--)
32                     { cl_MI c = R->square(a); }
33                 }
34                 cout << "quotient modulo p" << endl;
35                 { CL_TIMING;
36                   for (int rep = repetitions; rep > 0; rep--)
37                     { cl_MI c = R->div(a,b); }
38                 }
39         }
40         {
41                 cl_MI a = R->canonhom("1234567890123456789012345678901234567890123456789");
42                 cl_MI b = R->canonhom("909090909090909090909090909090909090909090909090");
43                 cout << "product modulo p" << endl;
44                 { CL_TIMING;
45                   for (int rep = repetitions; rep > 0; rep--)
46                     { cl_MI c = R->mul(a,b); }
47                 }
48                 cout << "square modulo p" << endl;
49                 { CL_TIMING;
50                   for (int rep = repetitions; rep > 0; rep--)
51                     { cl_MI c = R->square(a); }
52                 }
53                 cout << "quotient modulo p" << endl;
54                 { CL_TIMING;
55                   for (int rep = repetitions; rep > 0; rep--)
56                     { cl_MI c = R->div(a,b); }
57                 }
58         }
59 }