1 #include "flint.h"
2 #include "fq_poly.h"
3 #include "profiler.h"
4
5 #define nalgs 2
6 #define ncases 10
7 #define cpumin 2
8
9 int
main(int argc,char ** argv)10 main(int argc, char** argv)
11 {
12 double s[nalgs];
13
14 int c, n, lenf, leng, ext, reps = 0;
15 fmpz_t p, temp;
16 fq_poly_t f, g, h;
17 fq_ctx_t ctx;
18
19 FLINT_TEST_INIT(state);
20
21 fmpz_init(p);
22 fmpz_set_str(p, argv[1], 10);
23
24 fmpz_init(temp);
25
26 fmpz_set_str(temp, argv[2], 10);
27 ext = fmpz_get_si(temp);
28
29 lenf = atol(argv[3]);
30 leng = atol(argv[4]);
31
32 fq_ctx_init(ctx, p, ext, "a");
33
34 fq_poly_init(f, ctx);
35 fq_poly_init(g, ctx);
36 fq_poly_init(h, ctx);
37
38 for (c = 0; c < nalgs; c++)
39 {
40 s[c] = 0.0;
41 }
42
43 for (n = 0; n < ncases; n++)
44 {
45 double t[nalgs];
46 int l, loops = 1;
47
48 /*
49 Construct random elements of fq
50 */
51 {
52 fq_poly_randtest_monic(f, state, lenf, ctx);
53 fq_poly_randtest_monic(g, state, leng, ctx);
54 }
55
56 loop:
57 t[0] = 0.0;
58 init_clock(0);
59 prof_start();
60 for (l = 0; l < loops; l++)
61 {
62 fq_poly_mul_classical(h, f, g, ctx);
63 }
64 prof_stop();
65 t[0] += get_clock(0);
66
67 t[1] = 0.0;
68 init_clock(0);
69 prof_start();
70 for (l = 0; l < loops; l++)
71 {
72 fq_poly_mul_univariate(h, f, g, ctx);
73 }
74 prof_stop();
75 t[1] += get_clock(0);
76
77 for (c = 0; c < nalgs; c++)
78 if (t[c] * FLINT_CLOCK_SCALE_FACTOR <= cpumin)
79 {
80 loops *= 10;
81 goto loop;
82 }
83
84 for (c = 0; c < nalgs; c++)
85 s[c] += t[c];
86 reps += loops;
87 }
88
89 for (c = 0; c < nalgs; c++)
90 {
91 flint_printf("%20f ", s[c] / (double) reps);
92 fflush(stdout);
93 }
94 printf("\n");
95
96 fq_poly_clear(h, ctx);
97 fq_poly_clear(f, ctx);
98 fq_poly_clear(g, ctx);
99 fq_ctx_clear(ctx);
100 fmpz_clear(p);
101 fmpz_clear(temp);
102
103 FLINT_TEST_CLEANUP(state);
104
105 return 0;
106 }
107