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