|
| 1 | +/* |
| 2 | + Copyright (C) 2012, 2013 Fredrik Johansson |
| 3 | + Copyright (C) 2019 D.H.J. Polymath |
| 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 3 of the License, or |
| 10 | + (at your option) any later version. See <https://www.gnu.org/licenses/>. |
| 11 | +*/ |
| 12 | + |
| 13 | +#include "test_helpers.h" |
| 14 | +#include "acb_poly.h" |
| 15 | + |
| 16 | +TEST_FUNCTION_START(acb_poly_sinc_pi_series, state) |
| 17 | +{ |
| 18 | + slong iter; |
| 19 | + |
| 20 | + for (iter = 0; iter < 200 * 0.1 * flint_test_multiplier(); iter++) |
| 21 | + { |
| 22 | + slong m, n1, n2, rbits1, rbits2, rbits3, rbits4; |
| 23 | + acb_poly_t a, b, c, d; |
| 24 | + acb_t pi; |
| 25 | + |
| 26 | + rbits1 = 2 + n_randint(state, 300); |
| 27 | + rbits2 = 2 + n_randint(state, 300); |
| 28 | + rbits3 = 2 + n_randint(state, 300); |
| 29 | + rbits4 = 2 + n_randint(state, 300); |
| 30 | + |
| 31 | + m = n_randint(state, 15); |
| 32 | + n1 = n_randint(state, 15); |
| 33 | + n2 = n_randint(state, 15); |
| 34 | + |
| 35 | + acb_poly_init(a); |
| 36 | + acb_poly_init(b); |
| 37 | + acb_poly_init(c); |
| 38 | + acb_poly_init(d); |
| 39 | + acb_init(pi); |
| 40 | + |
| 41 | + acb_poly_randtest(a, state, m, rbits1, 10); |
| 42 | + acb_poly_randtest(b, state, 10, rbits1, 10); |
| 43 | + acb_poly_randtest(c, state, 10, rbits1, 10); |
| 44 | + |
| 45 | + acb_poly_sinc_pi_series(b, a, n1, rbits2); |
| 46 | + acb_poly_sinc_pi_series(c, a, n2, rbits3); |
| 47 | + |
| 48 | + acb_poly_set(d, b); |
| 49 | + acb_poly_truncate(d, FLINT_MIN(n1, n2)); |
| 50 | + acb_poly_truncate(c, FLINT_MIN(n1, n2)); |
| 51 | + |
| 52 | + acb_const_pi(pi, rbits4); |
| 53 | + |
| 54 | + if (!acb_poly_overlaps(c, d)) |
| 55 | + { |
| 56 | + flint_printf("FAIL\n\n"); |
| 57 | + flint_printf("n1 = %wd, n2 = %wd, bits2 = %wd, bits3 = %wd, bits4 = %wd\n", n1, n2, rbits2, rbits3, rbits4); |
| 58 | + flint_printf("a = "); acb_poly_printd(a, 50); flint_printf("\n\n"); |
| 59 | + flint_printf("b = "); acb_poly_printd(b, 50); flint_printf("\n\n"); |
| 60 | + flint_printf("c = "); acb_poly_printd(c, 50); flint_printf("\n\n"); |
| 61 | + flint_abort(); |
| 62 | + } |
| 63 | + |
| 64 | + /* check pi x sinc_pi(x) = sin_pi(x) */ |
| 65 | + acb_poly_mullow(c, b, a, n1, rbits2); |
| 66 | + acb_poly_scalar_mul(c, c, pi, rbits2); |
| 67 | + acb_poly_sin_pi_series(d, a, n1, rbits2); |
| 68 | + |
| 69 | + if (!acb_poly_overlaps(c, d)) |
| 70 | + { |
| 71 | + flint_printf("FAIL (functional equation)\n\n"); |
| 72 | + flint_printf("a = "); acb_poly_printd(a, 15); flint_printf("\n\n"); |
| 73 | + flint_printf("b = "); acb_poly_printd(b, 15); flint_printf("\n\n"); |
| 74 | + flint_printf("c = "); acb_poly_printd(c, 15); flint_printf("\n\n"); |
| 75 | + flint_printf("d = "); acb_poly_printd(d, 15); flint_printf("\n\n"); |
| 76 | + flint_abort(); |
| 77 | + } |
| 78 | + |
| 79 | + acb_poly_sinc_pi_series(a, a, n1, rbits2); |
| 80 | + |
| 81 | + if (!acb_poly_overlaps(a, b)) |
| 82 | + { |
| 83 | + flint_printf("FAIL (aliasing)\n\n"); |
| 84 | + flint_abort(); |
| 85 | + } |
| 86 | + |
| 87 | + acb_poly_clear(a); |
| 88 | + acb_poly_clear(b); |
| 89 | + acb_poly_clear(c); |
| 90 | + acb_poly_clear(d); |
| 91 | + acb_clear(pi); |
| 92 | + } |
| 93 | + |
| 94 | + TEST_FUNCTION_END(state); |
| 95 | +} |
0 commit comments