int main() { slong iter; flint_rand_t state; flint_printf("taylor_shift_convolution...."); fflush(stdout); flint_randinit(state); for (iter = 0; iter < 2000 * arb_test_multiplier(); iter++) { slong prec1, prec2; arb_poly_t f, g; arb_t c, d, e; prec1 = 2 + n_randint(state, 500); prec2 = 2 + n_randint(state, 500); arb_poly_init(f); arb_poly_init(g); arb_init(c); arb_init(d); arb_init(e); arb_poly_randtest(f, state, 1 + n_randint(state, 40), 1 + n_randint(state, 500), 10); arb_poly_randtest(g, state, 1 + n_randint(state, 20), 1 + n_randint(state, 500), 10); if (n_randint(state, 2)) arb_set_si(c, n_randint(state, 5) - 2); else arb_randtest(c, state, 1 + n_randint(state, 500), 1 + n_randint(state, 100)); if (n_randint(state, 2)) arb_set_si(d, n_randint(state, 5) - 2); else arb_randtest(d, state, 1 + n_randint(state, 500), 1 + n_randint(state, 100)); arb_add(e, c, d, prec1); /* check f(x+c)(x+d) = f(x+c+d) */ arb_poly_taylor_shift_convolution(g, f, e, prec2); arb_poly_taylor_shift_convolution(f, f, c, prec1); arb_poly_taylor_shift_convolution(f, f, d, prec1); if (!arb_poly_overlaps(f, g)) { flint_printf("FAIL\n\n"); flint_printf("c = "); arb_printd(c, 15); flint_printf("\n\n"); flint_printf("d = "); arb_printd(d, 15); flint_printf("\n\n"); flint_printf("f = "); arb_poly_printd(f, 15); flint_printf("\n\n"); flint_printf("g = "); arb_poly_printd(g, 15); flint_printf("\n\n"); abort(); } arb_poly_clear(f); arb_poly_clear(g); arb_clear(c); arb_clear(d); arb_clear(e); } flint_randclear(state); flint_cleanup(); flint_printf("PASS\n"); return EXIT_SUCCESS; }
int main() { long iter; flint_rand_t state; printf("zeta_series...."); fflush(stdout); flint_randinit(state); for (iter = 0; iter < 500; iter++) { long m, n1, n2, bits1, bits2, bits3; int deflate; arb_poly_t S, A, B, C, D, E, F; arb_t a, a1; bits1 = 2 + n_randint(state, 300); bits2 = 2 + n_randint(state, 300); bits3 = 2 + n_randint(state, 300); m = 1 + n_randint(state, 30); n1 = 1 + n_randint(state, 30); n2 = 1 + n_randint(state, 30); arb_poly_init(S); arb_poly_init(A); arb_poly_init(B); arb_poly_init(C); arb_poly_init(D); arb_poly_init(E); arb_poly_init(F); arb_init(a); arb_init(a1); deflate = n_randint(state, 2); arb_poly_randtest(S, state, m, bits1, 3); arb_randtest_precise(a, state, bits1, 3); arb_poly_set_coeff_arb(S, 0, a); if (n_randint(state, 2)) arb_randtest(a, state, bits1, 3); else arb_one(a); arb_poly_zeta_series(A, S, a, deflate, n1, bits2); arb_poly_zeta_series(B, S, a, deflate, n2, bits3); arb_poly_set(C, A); arb_poly_truncate(C, FLINT_MIN(n1, n2)); arb_poly_truncate(B, FLINT_MIN(n1, n2)); if (!arb_poly_overlaps(B, C)) { printf("FAIL\n\n"); printf("S = "); arb_poly_printd(S, 15); printf("\n\n"); printf("a = "); arb_printd(a, 15); printf("\n\n"); printf("A = "); arb_poly_printd(A, 15); printf("\n\n"); printf("B = "); arb_poly_printd(B, 15); printf("\n\n"); abort(); } /* check zeta(s,a) = zeta(s,a+1) + a^(-s) */ arb_poly_set_arb(D, a); arb_poly_log_series(D, D, n1, bits2); arb_poly_mullow(D, D, S, n1, bits2); arb_poly_neg(D, D); arb_poly_exp_series(D, D, n1, bits2); arb_add_ui(a1, a, 1, bits2); arb_poly_zeta_series(E, S, a1, deflate, n1, bits2); arb_poly_add(E, E, D, bits2); if (!arb_poly_overlaps(A, E)) { printf("FAIL (functional equation)\n\n"); printf("S = "); arb_poly_printd(S, 15); printf("\n\n"); printf("a = "); arb_printd(a, 15); printf("\n\n"); printf("A = "); arb_poly_printd(A, 15); printf("\n\n"); printf("E = "); arb_poly_printd(A, 15); printf("\n\n"); abort(); } arb_poly_zeta_series(S, S, a, deflate, n1, bits2); if (!arb_poly_overlaps(A, S)) { printf("FAIL (aliasing)\n\n"); abort(); } arb_poly_clear(S); arb_poly_clear(A); arb_poly_clear(B); arb_poly_clear(C); arb_poly_clear(D); arb_poly_clear(E); arb_poly_clear(F); arb_clear(a); arb_clear(a1); } flint_randclear(state); flint_cleanup(); printf("PASS\n"); return EXIT_SUCCESS; }
int main() { slong iter; flint_rand_t state; flint_printf("cos_pi_series...."); fflush(stdout); flint_randinit(state); for (iter = 0; iter < 1000; iter++) { slong m, n1, n2, bits1, bits2, bits3; arb_poly_t S, A, B, C; arb_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); arb_poly_init(S); arb_poly_init(A); arb_poly_init(B); arb_poly_init(C); arb_init(pi); arb_poly_randtest(S, state, m, bits1, 3); arb_poly_randtest(A, state, m, bits1, 3); arb_poly_randtest(B, state, m, bits1, 3); arb_poly_cos_pi_series(A, S, n1, bits2); arb_const_pi(pi, bits3); arb_poly_set_arb(B, pi); arb_poly_mul(B, S, B, bits3); arb_poly_cos_series(B, B, n2, bits3); arb_poly_set(C, A); arb_poly_truncate(C, FLINT_MIN(n1, n2)); arb_poly_truncate(B, FLINT_MIN(n1, n2)); if (!arb_poly_overlaps(B, C)) { flint_printf("FAIL\n\n"); flint_printf("S = "); arb_poly_printd(S, 15); flint_printf("\n\n"); flint_printf("A = "); arb_poly_printd(A, 15); flint_printf("\n\n"); flint_printf("B = "); arb_poly_printd(B, 15); flint_printf("\n\n"); abort(); } arb_poly_cos_pi_series(S, S, n1, bits2); if (!arb_poly_overlaps(A, S)) { flint_printf("FAIL (aliasing)\n\n"); abort(); } arb_poly_clear(S); arb_poly_clear(A); arb_poly_clear(B); arb_poly_clear(C); arb_clear(pi); } flint_randclear(state); flint_cleanup(); flint_printf("PASS\n"); return EXIT_SUCCESS; }
int main() { slong iter; flint_rand_t state; flint_printf("mul...."); fflush(stdout); flint_randinit(state); for (iter = 0; iter < 100000 * arb_test_multiplier(); iter++) { slong qbits1, qbits2, rbits1, rbits2, rbits3; fmpq_poly_t A, B, C; arb_poly_t a, b, c, d; qbits1 = 2 + n_randint(state, 200); qbits2 = 2 + n_randint(state, 200); rbits1 = 2 + n_randint(state, 200); rbits2 = 2 + n_randint(state, 200); rbits3 = 2 + n_randint(state, 200); fmpq_poly_init(A); fmpq_poly_init(B); fmpq_poly_init(C); arb_poly_init(a); arb_poly_init(b); arb_poly_init(c); arb_poly_init(d); fmpq_poly_randtest(A, state, 1 + n_randint(state, 10), qbits1); fmpq_poly_randtest(B, state, 1 + n_randint(state, 10), qbits2); fmpq_poly_mul(C, A, B); arb_poly_set_fmpq_poly(a, A, rbits1); arb_poly_set_fmpq_poly(b, B, rbits2); arb_poly_mul(c, a, b, rbits3); if (!arb_poly_contains_fmpq_poly(c, C)) { flint_printf("FAIL\n\n"); flint_printf("bits3 = %wd\n", rbits3); flint_printf("A = "); fmpq_poly_print(A); flint_printf("\n\n"); flint_printf("B = "); fmpq_poly_print(B); flint_printf("\n\n"); flint_printf("C = "); fmpq_poly_print(C); flint_printf("\n\n"); flint_printf("a = "); arb_poly_printd(a, 15); flint_printf("\n\n"); flint_printf("b = "); arb_poly_printd(b, 15); flint_printf("\n\n"); flint_printf("c = "); arb_poly_printd(c, 15); flint_printf("\n\n"); abort(); } arb_poly_set(d, a); arb_poly_mul(d, d, b, rbits3); if (!arb_poly_equal(d, c)) { flint_printf("FAIL (aliasing 1)\n\n"); abort(); } arb_poly_set(d, b); arb_poly_mul(d, a, d, rbits3); if (!arb_poly_equal(d, c)) { flint_printf("FAIL (aliasing 2)\n\n"); abort(); } /* test squaring */ arb_poly_set(b, a); arb_poly_mul(c, a, b, rbits3); arb_poly_mul(d, a, a, rbits3); if (!arb_poly_overlaps(c, d)) /* not guaranteed to be identical */ { flint_printf("FAIL (squaring)\n\n"); flint_printf("a = "); arb_poly_printd(a, 15); flint_printf("\n\n"); flint_printf("b = "); arb_poly_printd(b, 15); flint_printf("\n\n"); flint_printf("c = "); arb_poly_printd(c, 15); flint_printf("\n\n"); abort(); } arb_poly_mul(a, a, a, rbits3); if (!arb_poly_equal(d, a)) { flint_printf("FAIL (aliasing, squaring)\n\n"); flint_printf("a = "); arb_poly_printd(a, 15); flint_printf("\n\n"); flint_printf("b = "); arb_poly_printd(b, 15); flint_printf("\n\n"); flint_printf("d = "); arb_poly_printd(d, 15); flint_printf("\n\n"); abort(); } fmpq_poly_clear(A); fmpq_poly_clear(B); fmpq_poly_clear(C); arb_poly_clear(a); arb_poly_clear(b); arb_poly_clear(c); arb_poly_clear(d); } flint_randclear(state); flint_cleanup(); flint_printf("PASS\n"); return EXIT_SUCCESS; }
int main() { slong iter; flint_rand_t state; flint_printf("rising_ui_series...."); fflush(stdout); flint_randinit(state); /* check rf(f, a) * rf(f + a, b) = rf(f, a + b) */ for (iter = 0; iter < 1000 * arb_test_multiplier(); iter++) { slong bits, trunc; ulong a, b; arb_poly_t f, g, h1, h2, h1h2, h3; bits = 2 + n_randint(state, 200); trunc = 1 + n_randint(state, 20); a = n_randint(state, 10); b = n_randint(state, 10); arb_poly_init(f); arb_poly_init(g); arb_poly_init(h1); arb_poly_init(h2); arb_poly_init(h1h2); arb_poly_init(h3); arb_poly_randtest(f, state, 1 + n_randint(state, 20), bits, 4); arb_poly_set(g, f); /* g = f + 1 */ if (g->length == 0) { arb_poly_fit_length(g, 1); arb_set_ui(g->coeffs, a); _arb_poly_set_length(g, 1); _arb_poly_normalise(g); } else { arb_add_ui(g->coeffs, g->coeffs, a, bits); _arb_poly_normalise(g); } arb_poly_rising_ui_series(h1, f, a, trunc, bits); arb_poly_rising_ui_series(h2, g, b, trunc, bits); arb_poly_rising_ui_series(h3, f, a + b, trunc, bits); arb_poly_mullow(h1h2, h1, h2, trunc, bits); if (!arb_poly_overlaps(h1h2, h3)) { flint_printf("FAIL\n\n"); flint_printf("bits = %wd\n", bits); flint_printf("trunc = %wd\n", trunc); flint_printf("a = %wu\n", a); flint_printf("b = %wu\n", a); flint_printf("f = "); arb_poly_printd(f, 15); flint_printf("\n\n"); flint_printf("g = "); arb_poly_printd(g, 15); flint_printf("\n\n"); flint_printf("h1 = "); arb_poly_printd(h1, 15); flint_printf("\n\n"); flint_printf("h2 = "); arb_poly_printd(h2, 15); flint_printf("\n\n"); flint_printf("h1h2 = "); arb_poly_printd(h1h2, 15); flint_printf("\n\n"); flint_printf("h3 = "); arb_poly_printd(h3, 15); flint_printf("\n\n"); abort(); } arb_poly_rising_ui_series(f, f, a, trunc, bits); if (!arb_poly_equal(f, h1)) { flint_printf("FAIL (aliasing)\n\n"); flint_printf("bits = %wd\n", bits); flint_printf("trunc = %wd\n", trunc); flint_printf("a = %wu\n", a); flint_printf("b = %wu\n", a); flint_printf("f = "); arb_poly_printd(f, 15); flint_printf("\n\n"); flint_printf("h1 = "); arb_poly_printd(h1, 15); flint_printf("\n\n"); abort(); } arb_poly_clear(f); arb_poly_clear(g); arb_poly_clear(h1); arb_poly_clear(h2); arb_poly_clear(h1h2); arb_poly_clear(h3); } flint_randclear(state); flint_cleanup(); flint_printf("PASS\n"); return EXIT_SUCCESS; }
int main() { slong iter; flint_rand_t state; flint_printf("atan_series...."); fflush(stdout); flint_randinit(state); for (iter = 0; iter < 10000; iter++) { slong m, n, qbits, rbits1, rbits2; fmpq_poly_t A; arb_poly_t a, b, c, d; qbits = 2 + n_randint(state, 200); rbits1 = 2 + n_randint(state, 200); rbits2 = 2 + n_randint(state, 200); m = 1 + n_randint(state, 30); n = 1 + n_randint(state, 30); fmpq_poly_init(A); arb_poly_init(a); arb_poly_init(b); arb_poly_init(c); arb_poly_init(d); fmpq_poly_randtest(A, state, m, qbits); arb_poly_set_fmpq_poly(a, A, rbits1); arb_poly_randtest(b, state, 1 + n_randint(state, 30), rbits1, 5); arb_poly_atan_series(b, a, n, rbits2); /* Check 2 atan(x) = atan(2x/(1-x^2)) + C */ arb_poly_mullow(c, a, a, n, rbits2); arb_poly_one(d); arb_poly_sub(c, d, c, rbits2); arb_poly_add(d, a, a, rbits2); if (arb_poly_length(c) != 0) { arb_poly_div_series(c, d, c, n, rbits2); arb_poly_atan_series(c, c, n, rbits2); arb_poly_add(d, b, b, rbits2); /* TODO: also check the first coefficient */ arb_poly_set_coeff_si(c, 0, 0); arb_poly_set_coeff_si(d, 0, 0); if (!arb_poly_overlaps(c, d)) { flint_printf("FAIL\n\n"); flint_printf("bits2 = %wd\n", rbits2); flint_printf("A = "); fmpq_poly_print(A); flint_printf("\n\n"); flint_printf("a = "); arb_poly_printd(a, 15); flint_printf("\n\n"); flint_printf("b = "); arb_poly_printd(b, 15); flint_printf("\n\n"); flint_printf("c = "); arb_poly_printd(c, 15); flint_printf("\n\n"); flint_printf("d = "); arb_poly_printd(d, 15); flint_printf("\n\n"); abort(); } } arb_poly_atan_series(a, a, n, rbits2); if (!arb_poly_equal(a, b)) { flint_printf("FAIL (aliasing)\n\n"); abort(); } fmpq_poly_clear(A); arb_poly_clear(a); arb_poly_clear(b); arb_poly_clear(c); arb_poly_clear(d); } flint_randclear(state); flint_cleanup(); flint_printf("PASS\n"); return EXIT_SUCCESS; }
int main() { slong iter; flint_rand_t state; flint_printf("digamma_series...."); fflush(stdout); flint_randinit(state); for (iter = 0; iter < 1000; iter++) { slong m, n1, n2, rbits1, rbits2, rbits3; arb_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, 25); n1 = n_randint(state, 25); n2 = n_randint(state, 25); arb_poly_init(a); arb_poly_init(b); arb_poly_init(c); arb_poly_init(d); arb_poly_randtest(a, state, m, rbits1, 10); arb_poly_digamma_series(b, a, n1, rbits2); arb_poly_digamma_series(c, a, n2, rbits3); arb_poly_set(d, b); arb_poly_truncate(d, FLINT_MIN(n1, n2)); arb_poly_truncate(c, FLINT_MIN(n1, n2)); if (!arb_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 = "); arb_poly_printd(a, 50); flint_printf("\n\n"); flint_printf("b = "); arb_poly_printd(b, 50); flint_printf("\n\n"); flint_printf("c = "); arb_poly_printd(c, 50); flint_printf("\n\n"); abort(); } /* check psi(a) + 1/a = psi(a+1) */ arb_poly_inv_series(c, a, n1, rbits2); arb_poly_add(c, b, c, rbits2); arb_poly_add_si(d, a, 1, rbits2); arb_poly_digamma_series(d, d, n1, rbits2); if (!arb_poly_overlaps(c, d)) { flint_printf("FAIL (functional equation)\n\n"); flint_printf("a = "); arb_poly_printd(a, 15); flint_printf("\n\n"); flint_printf("b = "); arb_poly_printd(b, 15); flint_printf("\n\n"); flint_printf("c = "); arb_poly_printd(c, 15); flint_printf("\n\n"); flint_printf("d = "); arb_poly_printd(d, 15); flint_printf("\n\n"); abort(); } arb_poly_digamma_series(a, a, n1, rbits2); if (!arb_poly_overlaps(a, b)) { flint_printf("FAIL (aliasing)\n\n"); abort(); } arb_poly_clear(a); arb_poly_clear(b); arb_poly_clear(c); arb_poly_clear(d); } flint_randclear(state); flint_cleanup(); flint_printf("PASS\n"); return EXIT_SUCCESS; }
int main() { long iter; flint_rand_t state; printf("pow_arb_series...."); fflush(stdout); flint_randinit(state); /* compare with exp/log */ for (iter = 0; iter < 10000; iter++) { long prec, trunc; arb_poly_t f, g, h1, h2; arb_t c; prec = 2 + n_randint(state, 200); trunc = n_randint(state, 20); arb_poly_init(f); arb_poly_init(g); arb_poly_init(h1); arb_poly_init(h2); arb_init(c); /* generate binomials */ if (n_randint(state, 20) == 0) { arb_randtest(c, state, prec, 10); arb_poly_set_coeff_arb(f, 0, c); arb_randtest(c, state, prec, 10); arb_poly_set_coeff_arb(f, 1 + n_randint(state, 20), c); } else { arb_poly_randtest(f, state, 1 + n_randint(state, 20), prec, 10); } arb_poly_randtest(h1, state, 1 + n_randint(state, 20), prec, 10); arb_randtest(c, state, prec, 10); arb_poly_set_arb(g, c); /* f^c */ arb_poly_pow_arb_series(h1, f, c, trunc, prec); /* f^c = exp(c*log(f)) */ arb_poly_log_series(h2, f, trunc, prec); arb_poly_mullow(h2, h2, g, trunc, prec); arb_poly_exp_series(h2, h2, trunc, prec); if (!arb_poly_overlaps(h1, h2)) { printf("FAIL\n\n"); printf("prec = %ld\n", prec); printf("trunc = %ld\n", trunc); printf("f = "); arb_poly_printd(f, 15); printf("\n\n"); printf("c = "); arb_printd(c, 15); printf("\n\n"); printf("h1 = "); arb_poly_printd(h1, 15); printf("\n\n"); printf("h2 = "); arb_poly_printd(h2, 15); printf("\n\n"); abort(); } arb_poly_pow_arb_series(f, f, c, trunc, prec); if (!arb_poly_overlaps(f, h1)) { printf("FAIL (aliasing)\n\n"); abort(); } arb_poly_clear(f); arb_poly_clear(g); arb_poly_clear(h1); arb_poly_clear(h2); arb_clear(c); } flint_randclear(state); flint_cleanup(); printf("PASS\n"); return EXIT_SUCCESS; }
int main() { slong iter; flint_rand_t state; flint_printf("mullow_block...."); fflush(stdout); flint_randinit(state); /* compare with fmpq_poly */ for (iter = 0; iter < 10000 * arb_test_multiplier(); iter++) { slong qbits1, qbits2, rbits1, rbits2, rbits3, trunc; fmpq_poly_t A, B, C; arb_poly_t a, b, c, d; qbits1 = 2 + n_randint(state, 1000); qbits2 = 2 + n_randint(state, 1000); rbits1 = 2 + n_randint(state, 1000); rbits2 = 2 + n_randint(state, 1000); rbits3 = 2 + n_randint(state, 1000); trunc = n_randint(state, 100); fmpq_poly_init(A); fmpq_poly_init(B); fmpq_poly_init(C); arb_poly_init(a); arb_poly_init(b); arb_poly_init(c); arb_poly_init(d); fmpq_poly_randtest(A, state, 1 + n_randint(state, 100), qbits1); fmpq_poly_randtest(B, state, 1 + n_randint(state, 100), qbits2); fmpq_poly_mullow(C, A, B, trunc); arb_poly_set_fmpq_poly(a, A, rbits1); arb_poly_set_fmpq_poly(b, B, rbits2); arb_poly_mullow_block(c, a, b, trunc, rbits3); if (!arb_poly_contains_fmpq_poly(c, C)) { flint_printf("FAIL\n\n"); flint_printf("bits3 = %wd\n", rbits3); flint_printf("trunc = %wd\n", trunc); flint_printf("A = "); fmpq_poly_print(A); flint_printf("\n\n"); flint_printf("B = "); fmpq_poly_print(B); flint_printf("\n\n"); flint_printf("C = "); fmpq_poly_print(C); flint_printf("\n\n"); flint_printf("a = "); arb_poly_printd(a, 15); flint_printf("\n\n"); flint_printf("b = "); arb_poly_printd(b, 15); flint_printf("\n\n"); flint_printf("c = "); arb_poly_printd(c, 15); flint_printf("\n\n"); abort(); } arb_poly_set(d, a); arb_poly_mullow_block(d, d, b, trunc, rbits3); if (!arb_poly_equal(d, c)) { flint_printf("FAIL (aliasing 1)\n\n"); abort(); } arb_poly_set(d, b); arb_poly_mullow_block(d, a, d, trunc, rbits3); if (!arb_poly_equal(d, c)) { flint_printf("FAIL (aliasing 2)\n\n"); abort(); } /* test squaring */ arb_poly_set(b, a); arb_poly_mullow_block(c, a, b, trunc, rbits3); arb_poly_mullow_block(d, a, a, trunc, rbits3); if (!arb_poly_overlaps(c, d)) /* not guaranteed to be identical */ { flint_printf("FAIL (squaring)\n\n"); flint_printf("a = "); arb_poly_printd(a, 15); flint_printf("\n\n"); flint_printf("b = "); arb_poly_printd(b, 15); flint_printf("\n\n"); flint_printf("c = "); arb_poly_printd(c, 15); flint_printf("\n\n"); abort(); } arb_poly_mullow_block(a, a, a, trunc, rbits3); if (!arb_poly_equal(d, a)) { flint_printf("FAIL (aliasing, squaring)\n\n"); flint_printf("a = "); arb_poly_printd(a, 15); flint_printf("\n\n"); flint_printf("b = "); arb_poly_printd(b, 15); flint_printf("\n\n"); flint_printf("d = "); arb_poly_printd(d, 15); flint_printf("\n\n"); abort(); } fmpq_poly_clear(A); fmpq_poly_clear(B); fmpq_poly_clear(C); arb_poly_clear(a); arb_poly_clear(b); arb_poly_clear(c); arb_poly_clear(d); } for (iter = 0; iter < 3000 * arb_test_multiplier(); iter++) { slong rbits1, rbits2, rbits3, trunc; arb_poly_t a, b, c, ab, ac, bc, abc, abc2; rbits1 = 2 + n_randint(state, 300); rbits2 = 2 + n_randint(state, 300); rbits3 = 2 + n_randint(state, 300); trunc = n_randint(state, 100); arb_poly_init(a); arb_poly_init(b); arb_poly_init(c); arb_poly_init(ab); arb_poly_init(ac); arb_poly_init(bc); arb_poly_init(abc); arb_poly_init(abc2); arb_poly_randtest(a, state, 1 + n_randint(state, 100), rbits1, 1 + n_randint(state, 100)); arb_poly_randtest(b, state, 1 + n_randint(state, 100), rbits2, 1 + n_randint(state, 100)); arb_poly_randtest(c, state, 1 + n_randint(state, 100), rbits2, 1 + n_randint(state, 100)); /* check a*(b+c) = a*b + a*c */ arb_poly_mullow_block(ab, a, b, trunc, rbits3); arb_poly_mullow_block(ac, a, c, trunc, rbits3); arb_poly_add(abc, ab, ac, rbits3); arb_poly_add(bc, b, c, rbits3); arb_poly_mullow_block(abc2, a, bc, trunc, rbits3); if (!arb_poly_overlaps(abc, abc2)) { flint_printf("FAIL (a*(b+c) = a*b + a*c) \n\n"); flint_printf("bits3 = %wd\n", rbits3); flint_printf("trunc = %wd\n", trunc); flint_printf("a = "); arb_poly_printd(a, 15); flint_printf("\n\n"); flint_printf("b = "); arb_poly_printd(b, 15); flint_printf("\n\n"); flint_printf("c = "); arb_poly_printd(c, 15); flint_printf("\n\n"); abort(); } /* check (b+c)^2 = b^2 + 2bc + c^2 */ arb_poly_mullow_block(a, b, c, trunc, rbits3); arb_poly_scalar_mul_2exp_si(a, a, 1); arb_poly_mullow_block(abc, b, b, trunc, rbits3); arb_poly_mullow_block(abc2, c, c, trunc, rbits3); arb_poly_add(abc, abc, a, rbits3); arb_poly_add(abc, abc, abc2, rbits3); arb_poly_mullow_block(abc2, bc, bc, trunc, rbits3); if (!arb_poly_overlaps(abc, abc2)) { flint_printf("FAIL ((b+c)^2 = b^2 + 2bc + c^2) \n\n"); flint_printf("bits3 = %wd\n", rbits3); flint_printf("trunc = %wd\n", trunc); flint_printf("b = "); arb_poly_printd(b, 15); flint_printf("\n\n"); flint_printf("c = "); arb_poly_printd(c, 15); flint_printf("\n\n"); flint_printf("abc = "); arb_poly_printd(abc, 15); flint_printf("\n\n"); flint_printf("abc2 = "); arb_poly_printd(abc2, 15); flint_printf("\n\n"); abort(); } arb_poly_clear(a); arb_poly_clear(b); arb_poly_clear(c); arb_poly_clear(ab); arb_poly_clear(ac); arb_poly_clear(bc); arb_poly_clear(abc); arb_poly_clear(abc2); } flint_randclear(state); flint_cleanup(); flint_printf("PASS\n"); return EXIT_SUCCESS; }
int main() { slong iter; flint_rand_t state; flint_printf("pow_series...."); fflush(stdout); flint_randinit(state); for (iter = 0; iter < 50000 * arb_test_multiplier(); iter++) { slong rbits1, rbits2, len; arb_poly_t a, b, c, d; rbits1 = 2 + n_randint(state, 200); rbits2 = 2 + n_randint(state, 200); len = n_randint(state, 25); arb_poly_init(a); arb_poly_init(b); arb_poly_init(c); arb_poly_init(d); if (n_randint(state, 4) == 0) arb_poly_randtest(a, state, 1, rbits1, 25); else arb_poly_randtest(a, state, 1 + n_randint(state, 20), rbits1, 5); if (n_randint(state, 4) == 0) arb_poly_randtest(b, state, 1, rbits1, 25); else arb_poly_randtest(b, state, 1 + n_randint(state, 20), rbits1, 5); arb_poly_randtest(c, state, 1 + n_randint(state, 20), rbits1, 5); arb_poly_pow_series(c, a, b, len, rbits2); /* a^b = exp(b log a) */ arb_poly_log_series(d, a, len, rbits2); arb_poly_mullow(d, d, b, len, rbits2); arb_poly_exp_series(d, d, len, rbits2); if (!arb_poly_overlaps(c, d)) { flint_printf("FAIL (iter %wd)\n\n", iter); flint_printf("bits2 = %wd\n", rbits2); flint_printf("len = %wd\n", len); flint_printf("a = "); arb_poly_printd(a, 15); flint_printf("\n\n"); flint_printf("b = "); arb_poly_printd(b, 15); flint_printf("\n\n"); flint_printf("c = "); arb_poly_printd(c, 15); flint_printf("\n\n"); flint_printf("d = "); arb_poly_printd(d, 15); flint_printf("\n\n"); abort(); } /* check aliasing */ if (iter < 5000) { arb_poly_set(d, a); arb_poly_pow_series(d, d, b, len, rbits2); if (!arb_poly_overlaps(c, d)) { flint_printf("FAIL (aliasing 1)\n"); abort(); } arb_poly_set(d, b); arb_poly_pow_series(d, a, d, len, rbits2); if (!arb_poly_overlaps(c, d)) { flint_printf("FAIL (aliasing 2)\n"); abort(); } } arb_poly_clear(a); arb_poly_clear(b); arb_poly_clear(c); arb_poly_clear(d); } flint_randclear(state); flint_cleanup(); flint_printf("PASS\n"); return EXIT_SUCCESS; }
int main() { slong iter; flint_rand_t state; flint_printf("sinh_cosh_series...."); fflush(stdout); flint_randinit(state); for (iter = 0; iter < 1000 * arb_test_multiplier(); iter++) { arb_poly_t a, b, c, d, e; slong n1, n2, prec; int alg1, alg2; prec = 2 + n_randint(state, 200); if (n_randint(state, 40) == 0) { n1 = n_randint(state, 300); n2 = n_randint(state, 300); } else { n1 = n_randint(state, 30); n2 = n_randint(state, 30); } arb_poly_init(a); arb_poly_init(b); arb_poly_init(c); arb_poly_init(d); arb_poly_init(e); arb_poly_randtest(a, state, 20, prec, 10); arb_poly_randtest(b, state, 20, prec, 10); arb_poly_randtest(c, state, 20, prec, 10); arb_poly_randtest(d, state, 20, prec, 10); arb_poly_randtest(e, state, 20, prec, 10); alg1 = n_randint(state, 4); alg2 = n_randint(state, 7); switch (alg1) { case 0: arb_poly_sinh_cosh_series(b, c, a, n1, prec); break; case 1: arb_poly_sinh_cosh_series_basecase(b, c, a, n1, prec); break; case 2: arb_poly_sinh_cosh_series_exponential(b, c, a, n1, prec); break; default: arb_poly_sinh_series(b, a, n1, prec); arb_poly_cosh_series(c, a, n1, prec); break; } switch (alg2) { case 0: arb_poly_sinh_cosh_series(d, e, a, n2, prec); break; case 1: arb_poly_sinh_cosh_series_basecase(d, e, a, n2, prec); break; case 2: arb_poly_sinh_cosh_series_exponential(d, e, a, n2, prec); break; case 3: arb_poly_sinh_series(d, a, n2, prec); arb_poly_cosh_series(e, a, n2, prec); break; case 4: arb_poly_set(d, a); arb_poly_sinh_cosh_series(d, e, d, n2, prec); break; case 5: arb_poly_set(e, a); arb_poly_sinh_cosh_series(d, e, e, n2, prec); break; default: arb_poly_set(d, a); arb_poly_sinh_series(d, d, n2, prec); arb_poly_set(e, a); arb_poly_cosh_series(e, e, n2, prec); break; } arb_poly_truncate(b, FLINT_MIN(n1, n2)); arb_poly_truncate(c, FLINT_MIN(n1, n2)); arb_poly_truncate(d, FLINT_MIN(n1, n2)); arb_poly_truncate(e, FLINT_MIN(n1, n2)); if (!arb_poly_overlaps(b, d) || !arb_poly_overlaps(c, e)) { flint_printf("FAIL\n\n"); flint_printf("alg1 = %d, alg2 = %d, n1 = %wd, n2 = %wd\n\n", alg1, alg2, n1, n2); flint_printf("a = "); arb_poly_printd(a, 15); flint_printf("\n\n"); flint_printf("b = "); arb_poly_printd(b, 15); flint_printf("\n\n"); flint_printf("c = "); arb_poly_printd(c, 15); flint_printf("\n\n"); flint_printf("d = "); arb_poly_printd(d, 15); flint_printf("\n\n"); flint_printf("d = "); arb_poly_printd(e, 15); flint_printf("\n\n"); flint_abort(); } arb_poly_clear(a); arb_poly_clear(b); arb_poly_clear(c); arb_poly_clear(d); arb_poly_clear(e); } flint_randclear(state); flint_cleanup(); flint_printf("PASS\n"); return EXIT_SUCCESS; }
int main() { slong iter; flint_rand_t state; flint_printf("rgamma_series...."); fflush(stdout); flint_randinit(state); for (iter = 0; iter < 2000 * arb_test_multiplier(); iter++) { slong m, n1, n2, qbits, rbits1, rbits2, rbits3; fmpq_poly_t A; arb_poly_t a, b, c, d; qbits = 2 + n_randint(state, 200); rbits1 = 2 + n_randint(state, 400); rbits2 = 2 + n_randint(state, 400); rbits3 = 2 + n_randint(state, 400); m = 1 + n_randint(state, 30); n1 = 1 + n_randint(state, 30); n2 = 1 + n_randint(state, 30); fmpq_poly_init(A); arb_poly_init(a); arb_poly_init(b); arb_poly_init(c); arb_poly_init(d); fmpq_poly_randtest_not_zero(A, state, m, qbits); arb_poly_set_fmpq_poly(a, A, rbits1); arb_poly_rgamma_series(b, a, n1, rbits2); arb_poly_rgamma_series(c, a, n2, rbits3); arb_poly_set(d, b); arb_poly_truncate(d, FLINT_MIN(n1, n2)); arb_poly_truncate(c, FLINT_MIN(n1, n2)); if (!arb_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 = "); fmpq_poly_print(A); flint_printf("\n\n"); flint_printf("a = "); arb_poly_printd(a, 15); flint_printf("\n\n"); flint_printf("b = "); arb_poly_printd(b, 15); flint_printf("\n\n"); flint_printf("c = "); arb_poly_printd(c, 15); flint_printf("\n\n"); abort(); } /* check rgamma(a) = a gamma(a+1) */ arb_poly_add_si(d, a, 1, rbits2); arb_poly_rgamma_series(d, d, n1, rbits2); arb_poly_mullow(c, d, a, n1, rbits2); if (!arb_poly_overlaps(b, c)) { flint_printf("FAIL (functional equation, n1 = %wd)\n\n", n1); flint_printf("A = "); fmpq_poly_print(A); flint_printf("\n\n"); flint_printf("a = "); arb_poly_printd(a, 15); flint_printf("\n\n"); flint_printf("b = "); arb_poly_printd(b, 15); flint_printf("\n\n"); flint_printf("c = "); arb_poly_printd(c, 15); flint_printf("\n\n"); flint_printf("d = "); arb_poly_printd(d, 15); flint_printf("\n\n"); abort(); } arb_poly_rgamma_series(a, a, n1, rbits2); if (!arb_poly_overlaps(a, b)) { flint_printf("FAIL (aliasing)\n\n"); abort(); } fmpq_poly_clear(A); arb_poly_clear(a); arb_poly_clear(b); arb_poly_clear(c); arb_poly_clear(d); } flint_randclear(state); flint_cleanup(); flint_printf("PASS\n"); return EXIT_SUCCESS; }