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