]> www.ginac.de Git - cln.git/blob - tests/timeUPMImul.cc
* Fix typo.
[cln.git] / tests / timeUPMImul.cc
1 #include <cln/number.h>
2 #include <cln/io.h>
3 #include <cln/integer.h>
4 #include <cln/modinteger.h>
5 #include <cln/univpoly.h>
6 #include <cstdlib>
7 #include <cstring>
8 #include <cln/timing.h>
9 using namespace cln;
10
11 int main (int argc, char * argv[])
12 {
13         int repetitions = 1;
14         if ((argc >= 3) && !strcmp(argv[1],"-r")) {
15                 repetitions = atoi(argv[2]);
16                 argc -= 2; argv += 2;
17         }
18         if (argc < 2)
19                 exit(1);
20
21         int n = atoi(argv[1]);
22         cl_I m = 100001;
23         int i;
24
25         cl_modint_ring R1 = find_modint_ring(m);
26         cl_univpoly_ring PR1 = find_univpoly_ring(R1);
27         cl_UP p1 = PR1->create(n-1);
28         for (i = 0; i < n; i++)
29                 p1.set_coeff(i, R1->canonhom((int)(1.618033989*i*i)));
30         p1.finalize();
31
32         cout << p1 << endl;
33
34         cl_UP sp1 = PR1->zero();
35         { CL_TIMING;
36           for (int rep = repetitions; rep > 0; rep--)
37             { sp1 = square(p1); }
38         }
39
40         cout << sp1 << endl;
41 }
42
43 // Time:
44 //    n      modint    modint2   neu
45 //    2      0.000123  0.000082  0.000086
46 //    5      0.00051   0.00031   0.00032
47 //   10      0.00169   0.00095   0.00100
48 //   25      0.0089    0.0049    0.0053
49 //   50      0.031     0.018     0.020
50 //  100      0.118     0.070     0.079
51 //  250      0.72      0.43      0.48
52 //  500      2.87      1.76      1.91
53 // 1000     11.4       7.0       8.0