1 /*
2 Copyright (C) 2012 Sebastian Pancratz
3 Copyright (C) 2013 Mike Hansen
4
5 This file is part of FLINT.
6
7 FLINT is free software: you can redistribute it and/or modify it under
8 the terms of the GNU Lesser General Public License (LGPL) as published
9 by the Free Software Foundation; either version 2.1 of the License, or
10 (at your option) any later version. See <https://www.gnu.org/licenses/>.
11 */
12
13 #ifdef T
14
15 #include "templates.h"
16
17 #include <stdio.h>
18 #include <stdlib.h>
19
20 #include "ulong_extras.h"
21 #include "long_extras.h"
22
23 int
main(void)24 main(void)
25 {
26 int i, result;
27 FLINT_TEST_INIT(state);
28
29 flint_printf("mullow... ");
30 fflush(stdout);
31
32 /* Compare with truncated product of a and b */
33 for (i = 0; i < 200 * flint_test_multiplier(); i++)
34 {
35 TEMPLATE(T, ctx_t) ctx;
36
37 TEMPLATE(T, poly_t) a, b, c, d;
38 slong n;
39
40 TEMPLATE(T, ctx_randtest) (ctx, state);
41
42 TEMPLATE(T, poly_init) (a, ctx);
43 TEMPLATE(T, poly_init) (b, ctx);
44 TEMPLATE(T, poly_init) (c, ctx);
45 TEMPLATE(T, poly_init) (d, ctx);
46
47 TEMPLATE(T, poly_randtest) (a, state, n_randint(state, 100), ctx);
48 TEMPLATE(T, poly_randtest) (b, state, n_randint(state, 100), ctx);
49 n = n_randint(state, 100);
50
51 TEMPLATE(T, poly_mullow) (c, a, b, n, ctx);
52 TEMPLATE(T, poly_mul) (d, a, b, ctx);
53 TEMPLATE(T, poly_truncate) (d, n, ctx);
54
55 result = (TEMPLATE(T, poly_equal) (c, d, ctx));
56 if (!result)
57 {
58 flint_printf("FAIL:\n\n");
59 flint_printf("a = "), TEMPLATE(T, poly_print_pretty) (a, "X", ctx),
60 flint_printf("\n");
61 flint_printf("b = "), TEMPLATE(T, poly_print_pretty) (b, "X", ctx),
62 flint_printf("\n");
63 flint_printf("c = "), TEMPLATE(T, poly_print_pretty) (c, "X", ctx),
64 flint_printf("\n");
65 flint_printf("d = "), TEMPLATE(T, poly_print_pretty) (d, "X", ctx),
66 flint_printf("\n");
67 abort();
68 }
69
70 TEMPLATE(T, poly_clear) (a, ctx);
71 TEMPLATE(T, poly_clear) (b, ctx);
72 TEMPLATE(T, poly_clear) (c, ctx);
73 TEMPLATE(T, poly_clear) (d, ctx);
74
75 TEMPLATE(T, ctx_clear) (ctx);
76 }
77
78 FLINT_TEST_CLEANUP(state);
79 flint_printf("PASS\n");
80 return EXIT_SUCCESS;
81 }
82
83
84
85 #endif
86