1 /*
2 Copyright (C) 2013 Fredrik Johansson
3
4 This file is part of Arb.
5
6 Arb is free software: you can redistribute it and/or modify it under
7 the terms of the GNU Lesser General Public License (LGPL) as published
8 by the Free Software Foundation; either version 2.1 of the License, or
9 (at your option) any later version. See <http://www.gnu.org/licenses/>.
10 */
11
12 #include "arb_poly.h"
13
main()14 int main()
15 {
16 slong iter;
17 flint_rand_t state;
18
19 flint_printf("cos_pi_series....");
20 fflush(stdout);
21
22 flint_randinit(state);
23
24 for (iter = 0; iter < 1000 * arb_test_multiplier(); iter++)
25 {
26 slong m, n1, n2, bits1, bits2, bits3;
27 arb_poly_t S, A, B, C;
28 arb_t pi;
29
30 bits1 = 2 + n_randint(state, 200);
31 bits2 = 2 + n_randint(state, 200);
32 bits3 = 2 + n_randint(state, 200);
33
34 m = 1 + n_randint(state, 30);
35 n1 = 1 + n_randint(state, 30);
36 n2 = 1 + n_randint(state, 30);
37
38 arb_poly_init(S);
39 arb_poly_init(A);
40 arb_poly_init(B);
41 arb_poly_init(C);
42 arb_init(pi);
43
44 arb_poly_randtest(S, state, m, bits1, 3);
45 arb_poly_randtest(A, state, m, bits1, 3);
46 arb_poly_randtest(B, state, m, bits1, 3);
47
48 arb_poly_cos_pi_series(A, S, n1, bits2);
49
50 arb_const_pi(pi, bits3);
51 arb_poly_set_arb(B, pi);
52 arb_poly_mul(B, S, B, bits3);
53 arb_poly_cos_series(B, B, n2, bits3);
54
55 arb_poly_set(C, A);
56 arb_poly_truncate(C, FLINT_MIN(n1, n2));
57 arb_poly_truncate(B, FLINT_MIN(n1, n2));
58
59 if (!arb_poly_overlaps(B, C))
60 {
61 flint_printf("FAIL\n\n");
62 flint_printf("S = "); arb_poly_printd(S, 15); flint_printf("\n\n");
63 flint_printf("A = "); arb_poly_printd(A, 15); flint_printf("\n\n");
64 flint_printf("B = "); arb_poly_printd(B, 15); flint_printf("\n\n");
65 flint_abort();
66 }
67
68 arb_poly_cos_pi_series(S, S, n1, bits2);
69
70 if (!arb_poly_overlaps(A, S))
71 {
72 flint_printf("FAIL (aliasing)\n\n");
73 flint_abort();
74 }
75
76 arb_poly_clear(S);
77 arb_poly_clear(A);
78 arb_poly_clear(B);
79 arb_poly_clear(C);
80 arb_clear(pi);
81 }
82
83 flint_randclear(state);
84 flint_cleanup();
85 flint_printf("PASS\n");
86 return EXIT_SUCCESS;
87 }
88