-
Notifications
You must be signed in to change notification settings - Fork 249
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2142 from fredrik-johansson/sinc2
Handle 0-containing constant term in arb_poly_sinc_pi_series; add acb_poly_sinc_pi_series
- Loading branch information
Showing
6 changed files
with
198 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
Copyright (C) 2016 Fredrik Johansson | ||
Copyright (C) 2019 D.H.J. Polymath | ||
This file is part of FLINT. | ||
FLINT is free software: you can redistribute it and/or modify it under | ||
the terms of the GNU Lesser General Public License (LGPL) as published | ||
by the Free Software Foundation; either version 3 of the License, or | ||
(at your option) any later version. See <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "acb_poly.h" | ||
|
||
void | ||
_acb_poly_sinc_pi_series(acb_ptr g, acb_srcptr h, slong hlen, slong n, slong prec) | ||
{ | ||
hlen = FLINT_MIN(hlen, n); | ||
|
||
if (hlen == 1) | ||
{ | ||
acb_sinc_pi(g, h, prec); | ||
_acb_vec_zero(g + 1, n - 1); | ||
} | ||
else | ||
{ | ||
acb_t pi; | ||
acb_ptr t, u; | ||
|
||
acb_init(pi); | ||
t = _acb_vec_init(n + 1); | ||
u = _acb_vec_init(hlen); | ||
|
||
acb_const_pi(pi, prec); | ||
_acb_vec_set(u, h, hlen); | ||
|
||
if (acb_is_zero(h)) | ||
{ | ||
_acb_poly_sin_pi_series(t, u, hlen, n + 1, prec); | ||
_acb_poly_div_series(g, t + 1, n, u + 1, hlen - 1, n, prec); | ||
_acb_vec_scalar_div(g, g, n, pi, prec); | ||
} | ||
else if (acb_contains_zero(h)) | ||
{ | ||
_acb_vec_scalar_mul(u, h, hlen, pi, prec); | ||
_acb_poly_sinc_series(g, u, hlen, n, prec); | ||
} | ||
else | ||
{ | ||
_acb_poly_sin_pi_series(t, u, hlen, n, prec); | ||
_acb_poly_div_series(g, t, n, u, hlen, n, prec); | ||
_acb_vec_scalar_div(g, g, n, pi, prec); | ||
} | ||
|
||
acb_clear(pi); | ||
_acb_vec_clear(t, n + 1); | ||
_acb_vec_clear(u, hlen); | ||
} | ||
} | ||
|
||
void | ||
acb_poly_sinc_pi_series(acb_poly_t g, const acb_poly_t h, slong n, slong prec) | ||
{ | ||
slong hlen = h->length; | ||
|
||
if (n == 0) | ||
{ | ||
acb_poly_zero(g); | ||
return; | ||
} | ||
|
||
if (hlen == 0) | ||
{ | ||
acb_poly_one(g); | ||
return; | ||
} | ||
|
||
if (hlen == 1) | ||
n = 1; | ||
|
||
acb_poly_fit_length(g, n); | ||
_acb_poly_sinc_pi_series(g->coeffs, h->coeffs, hlen, n, prec); | ||
_acb_poly_set_length(g, n); | ||
_acb_poly_normalise(g); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/* | ||
Copyright (C) 2012, 2013 Fredrik Johansson | ||
Copyright (C) 2019 D.H.J. Polymath | ||
This file is part of FLINT. | ||
FLINT is free software: you can redistribute it and/or modify it under | ||
the terms of the GNU Lesser General Public License (LGPL) as published | ||
by the Free Software Foundation; either version 3 of the License, or | ||
(at your option) any later version. See <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "test_helpers.h" | ||
#include "acb_poly.h" | ||
|
||
TEST_FUNCTION_START(acb_poly_sinc_pi_series, state) | ||
{ | ||
slong iter; | ||
|
||
for (iter = 0; iter < 200 * 0.1 * flint_test_multiplier(); iter++) | ||
{ | ||
slong m, n1, n2, rbits1, rbits2, rbits3, rbits4; | ||
acb_poly_t a, b, c, d; | ||
acb_t pi; | ||
|
||
rbits1 = 2 + n_randint(state, 300); | ||
rbits2 = 2 + n_randint(state, 300); | ||
rbits3 = 2 + n_randint(state, 300); | ||
rbits4 = 2 + n_randint(state, 300); | ||
|
||
m = n_randint(state, 15); | ||
n1 = n_randint(state, 15); | ||
n2 = n_randint(state, 15); | ||
|
||
acb_poly_init(a); | ||
acb_poly_init(b); | ||
acb_poly_init(c); | ||
acb_poly_init(d); | ||
acb_init(pi); | ||
|
||
acb_poly_randtest(a, state, m, rbits1, 10); | ||
acb_poly_randtest(b, state, 10, rbits1, 10); | ||
acb_poly_randtest(c, state, 10, rbits1, 10); | ||
|
||
acb_poly_sinc_pi_series(b, a, n1, rbits2); | ||
acb_poly_sinc_pi_series(c, a, n2, rbits3); | ||
|
||
acb_poly_set(d, b); | ||
acb_poly_truncate(d, FLINT_MIN(n1, n2)); | ||
acb_poly_truncate(c, FLINT_MIN(n1, n2)); | ||
|
||
acb_const_pi(pi, rbits4); | ||
|
||
if (!acb_poly_overlaps(c, d)) | ||
{ | ||
flint_printf("FAIL\n\n"); | ||
flint_printf("n1 = %wd, n2 = %wd, bits2 = %wd, bits3 = %wd, bits4 = %wd\n", n1, n2, rbits2, rbits3, rbits4); | ||
flint_printf("a = "); acb_poly_printd(a, 50); flint_printf("\n\n"); | ||
flint_printf("b = "); acb_poly_printd(b, 50); flint_printf("\n\n"); | ||
flint_printf("c = "); acb_poly_printd(c, 50); flint_printf("\n\n"); | ||
flint_abort(); | ||
} | ||
|
||
/* check pi x sinc_pi(x) = sin_pi(x) */ | ||
acb_poly_mullow(c, b, a, n1, rbits2); | ||
acb_poly_scalar_mul(c, c, pi, rbits2); | ||
acb_poly_sin_pi_series(d, a, n1, rbits2); | ||
|
||
if (!acb_poly_overlaps(c, d)) | ||
{ | ||
flint_printf("FAIL (functional equation)\n\n"); | ||
flint_printf("a = "); acb_poly_printd(a, 15); flint_printf("\n\n"); | ||
flint_printf("b = "); acb_poly_printd(b, 15); flint_printf("\n\n"); | ||
flint_printf("c = "); acb_poly_printd(c, 15); flint_printf("\n\n"); | ||
flint_printf("d = "); acb_poly_printd(d, 15); flint_printf("\n\n"); | ||
flint_abort(); | ||
} | ||
|
||
acb_poly_sinc_pi_series(a, a, n1, rbits2); | ||
|
||
if (!acb_poly_overlaps(a, b)) | ||
{ | ||
flint_printf("FAIL (aliasing)\n\n"); | ||
flint_abort(); | ||
} | ||
|
||
acb_poly_clear(a); | ||
acb_poly_clear(b); | ||
acb_poly_clear(c); | ||
acb_poly_clear(d); | ||
acb_clear(pi); | ||
} | ||
|
||
TEST_FUNCTION_END(state); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters