int main() { slong iter; flint_rand_t state; flint_printf("si_series...."); fflush(stdout); flint_randinit(state); for (iter = 0; iter < 200 * arb_test_multiplier(); iter++) { slong m, n1, n2, n3, bits1, bits2, bits3; acb_poly_t S, A, B, C, T, U; bits1 = 2 + n_randint(state, 200); bits2 = 2 + n_randint(state, 200); bits3 = 2 + n_randint(state, 200); m = 1 + n_randint(state, 10); n1 = 1 + n_randint(state, 10); n2 = 1 + n_randint(state, 10); n3 = FLINT_MIN(n1, n2); acb_poly_init(S); acb_poly_init(A); acb_poly_init(B); acb_poly_init(C); acb_poly_init(T); acb_poly_init(U); acb_poly_randtest(S, state, m, bits1, 3); acb_poly_randtest(A, state, m, bits1, 3); acb_poly_randtest(B, state, m, bits1, 3); acb_hypgeom_si_series(A, S, n1, bits2); acb_hypgeom_si_series(B, S, n2, bits3); acb_poly_set(C, A); acb_poly_truncate(C, n3); acb_poly_truncate(B, n3); /* [Si(h(x))]' h(x) = sin(h(x)) h'(x) */ acb_poly_sin_series(U, S, n3, bits2); acb_poly_derivative(T, S, bits2); acb_poly_mullow(U, U, T, FLINT_MAX(0, n3 - 1), bits2); acb_poly_derivative(T, A, bits2); acb_poly_mullow(T, T, S, FLINT_MAX(0, n3 - 1), bits2); if (!acb_poly_overlaps(B, C) || !acb_poly_overlaps(T, U)) { flint_printf("FAIL\n\n"); flint_printf("S = "); acb_poly_printd(S, 15); flint_printf("\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("T = "); acb_poly_printd(T, 15); flint_printf("\n\n"); flint_printf("U = "); acb_poly_printd(U, 15); flint_printf("\n\n"); abort(); } acb_hypgeom_si_series(S, S, n1, bits2); if (!acb_poly_overlaps(A, S)) { flint_printf("FAIL (aliasing)\n\n"); abort(); } acb_poly_clear(S); acb_poly_clear(A); acb_poly_clear(B); acb_poly_clear(C); acb_poly_clear(T); acb_poly_clear(U); } flint_randclear(state); flint_cleanup(); flint_printf("PASS\n"); return EXIT_SUCCESS; }
int main() { slong iter; flint_rand_t state; flint_printf("sinc_series...."); fflush(stdout); flint_randinit(state); for (iter = 0; iter < 200 * arb_test_multiplier(); iter++) { slong m, n1, n2, rbits1, rbits2, rbits3; acb_poly_t a, b, c, d; rbits1 = 2 + n_randint(state, 300); rbits2 = 2 + n_randint(state, 300); rbits3 = 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_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_series(b, a, n1, rbits2); acb_poly_sinc_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)); if (!acb_poly_overlaps(c, d)) { flint_printf("FAIL\n\n"); flint_printf("n1 = %wd, n2 = %wd, bits2 = %wd, bits3 = %wd\n", n1, n2, rbits2, rbits3); 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 x sinc(x) = sin(x) */ acb_poly_mullow(c, b, a, n1, rbits2); acb_poly_sin_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_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); } flint_randclear(state); flint_cleanup(); flint_printf("PASS\n"); return EXIT_SUCCESS; }
int main() { long iter; flint_rand_t state; printf("sin_pi_series...."); fflush(stdout); flint_randinit(state); for (iter = 0; iter < 1000; iter++) { long m, n1, n2, bits1, bits2, bits3; acb_poly_t S, A, B, C; acb_t pi; bits1 = 2 + n_randint(state, 200); bits2 = 2 + n_randint(state, 200); bits3 = 2 + n_randint(state, 200); m = 1 + n_randint(state, 30); n1 = 1 + n_randint(state, 30); n2 = 1 + n_randint(state, 30); acb_poly_init(S); acb_poly_init(A); acb_poly_init(B); acb_poly_init(C); acb_init(pi); acb_poly_randtest(S, state, m, bits1, 3); acb_poly_randtest(A, state, m, bits1, 3); acb_poly_randtest(B, state, m, bits1, 3); acb_poly_sin_pi_series(A, S, n1, bits2); acb_const_pi(pi, bits3); acb_poly_set_acb(B, pi); acb_poly_mul(B, S, B, bits3); acb_poly_sin_series(B, B, n2, bits3); acb_poly_set(C, A); acb_poly_truncate(C, FLINT_MIN(n1, n2)); acb_poly_truncate(B, FLINT_MIN(n1, n2)); if (!acb_poly_overlaps(B, C)) { printf("FAIL\n\n"); printf("S = "); acb_poly_printd(S, 15); printf("\n\n"); printf("A = "); acb_poly_printd(A, 15); printf("\n\n"); printf("B = "); acb_poly_printd(B, 15); printf("\n\n"); abort(); } acb_poly_sin_pi_series(S, S, n1, bits2); if (!acb_poly_overlaps(A, S)) { printf("FAIL (aliasing)\n\n"); abort(); } acb_poly_clear(S); acb_poly_clear(A); acb_poly_clear(B); acb_poly_clear(C); acb_clear(pi); } flint_randclear(state); flint_cleanup(); printf("PASS\n"); return EXIT_SUCCESS; }