Exemplo n.º 1
0
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;
}
Exemplo n.º 2
0
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;
}
Exemplo n.º 3
0
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;
}