Пример #1
0
void
arb_hypgeom_u(arb_t res, const arb_t a, const arb_t b, const arb_t z, slong prec)
{
    acb_t t, u, v;
    acb_init(t);
    acb_init(u);
    acb_init(v);
    arb_set(acb_realref(t), a);
    arb_set(acb_realref(u), b);
    arb_set(acb_realref(v), z);
    acb_hypgeom_u(t, t, u, v, prec);
    if (acb_is_finite(t) && acb_is_real(t))
        arb_swap(res, acb_realref(t));
    else
        arb_indeterminate(res);
    acb_clear(t);
    acb_clear(u);
    acb_clear(v);
}
Пример #2
0
int main()
{
    long iter;
    flint_rand_t state;

    printf("u....");
    fflush(stdout);

    flint_randinit(state);

    for (iter = 0; iter < 2000; iter++)
    {
        acb_t a0, a1, a2, b, z, w0, w1, w2, t, u;
        long prec0, prec1, prec2;

        acb_init(a0);
        acb_init(a1);
        acb_init(a2);
        acb_init(b);
        acb_init(z);
        acb_init(w0);
        acb_init(w1);
        acb_init(w2);
        acb_init(t);
        acb_init(u);

        prec0 = 2 + n_randint(state, 700);
        prec1 = 2 + n_randint(state, 700);
        prec2 = 2 + n_randint(state, 700);

        acb_randtest_maybe_half_int(a0, state, 1 + n_randint(state, 1000), 1 + n_randint(state, 100));
        acb_randtest_maybe_half_int(b, state, 1 + n_randint(state, 1000), 1 + n_randint(state, 100));
        acb_randtest(z, state, 1 + n_randint(state, 1000), 1 + n_randint(state, 100));
        acb_randtest(w0, state, 1 + n_randint(state, 1000), 1 + n_randint(state, 100));
        acb_randtest(w1, state, 1 + n_randint(state, 1000), 1 + n_randint(state, 100));
        acb_randtest(w2, state, 1 + n_randint(state, 1000), 1 + n_randint(state, 100));

        acb_add_ui(a1, a0, 1, prec0);
        acb_add_ui(a2, a0, 2, prec0);

        switch (n_randint(state, 3))
        {
            case 0:
                acb_hypgeom_u_asymp_proper(w0, a0, b, z, prec0);
                break;
            case 1:
                acb_hypgeom_u_1f1(w0, a0, b, z, prec0);
                break;
            default:
                acb_hypgeom_u(w0, a0, b, z, prec0);
        }

        switch (n_randint(state, 3))
        {
            case 0:
                acb_hypgeom_u_asymp_proper(w1, a0, b, z, prec1);
                break;
            case 1:
                acb_hypgeom_u_1f1(w1, a0, b, z, prec1);
                break;
            default:
                acb_hypgeom_u(w1, a0, b, z, prec1);
        }

        if (!acb_overlaps(w0, w1))
        {
            printf("FAIL: consistency\n\n");
            printf("a = "); acb_printd(a0, 30); printf("\n\n");
            printf("b = "); acb_printd(b, 30); printf("\n\n");
            printf("z = "); acb_printd(z, 30); printf("\n\n");
            printf("w0 = "); acb_printd(w0, 30); printf("\n\n");
            printf("w1 = "); acb_printd(w1, 30); printf("\n\n");
            abort();
        }

        switch (n_randint(state, 3))
        {
            case 0:
                acb_hypgeom_u_asymp_proper(w1, a1, b, z, prec1);
                break;
            case 1:
                acb_hypgeom_u_1f1(w1, a1, b, z, prec1);
                break;
            default:
                acb_hypgeom_u(w1, a1, b, z, prec1);
        }

        switch (n_randint(state, 3))
        {
            case 0:
                acb_hypgeom_u_asymp_proper(w2, a2, b, z, prec2);
                break;
            case 1:
                acb_hypgeom_u_1f1(w2, a2, b, z, prec2);
                break;
            default:
                acb_hypgeom_u(w2, a2, b, z, prec2);
        }

        acb_set(t, w0);

        acb_mul_2exp_si(u, a0, 1);
        acb_sub(u, u, b, prec0);
        acb_add(u, u, z, prec0);
        acb_add_ui(u, u, 2, prec0);

        acb_submul(t, w1, u, prec0);

        acb_sub(u, a2, b, prec0);
        acb_mul(u, u, a1, prec0);
        acb_addmul(t, w2, u, prec0);

        if (!acb_contains_zero(t))
        {
            printf("FAIL: contiguous relation\n\n");
            printf("a = "); acb_printd(a0, 30); printf("\n\n");
            printf("b = "); acb_printd(b, 30); printf("\n\n");
            printf("z = ");  acb_printd(z, 30); printf("\n\n");
            printf("w0 = "); acb_printd(w0, 30); printf("\n\n");
            printf("w1 = "); acb_printd(w1, 30); printf("\n\n");
            printf("w2 = "); acb_printd(w2, 30); printf("\n\n");
            printf("t = "); acb_printd(t, 30); printf("\n\n");
            abort();
        }

        acb_clear(a0);
        acb_clear(a1);
        acb_clear(a2);
        acb_clear(b);
        acb_clear(z);
        acb_clear(w0);
        acb_clear(w1);
        acb_clear(w2);
        acb_clear(t);
        acb_clear(u);
    }

    flint_randclear(state);
    flint_cleanup();
    printf("PASS\n");
    return EXIT_SUCCESS;
}
Пример #3
0
int main(int argc, char *argv[])
{
    int function, i, numtests;
    slong prec, goal;
    double t, total, logtotal;

    acb_t a, b, c, z, r, s;

    acb_init(a);
    acb_init(b);
    acb_init(c);
    acb_init(z);
    acb_init(r);
    acb_init(s);

    /*    J(0,pi x)   I(0,pi x)   K(0,pi x)          */

    for (function = 0; function < 3; function++)
    {
        total = 0.0;
        logtotal = 0.0;

        if (function < 2)
            numtests = 40;
        else
            numtests = 30;

        for (i = 0; i < numtests; i++)
        {
//            printf("%2d ", i + 1); fflush(stdout);

            TIMEIT_START
            prec = 96;

            for (;;)
            {
                if (function == 0)
                {
                    acb_set_d_d(a, input_1f1[i][0], input_1f1[i][1]);
                    acb_set_d_d(b, input_1f1[i][2], input_1f1[i][3]);
                    acb_set_d_d(z, input_1f1[i][4], input_1f1[i][5]);
                    acb_hypgeom_m(r, a, b, z, 0, prec);
                }
                else if (function == 1)
                {
                    acb_set_d_d(a, input_1f1[i][0], input_1f1[i][1]);
                    acb_set_d_d(b, input_1f1[i][2], input_1f1[i][3]);
                    acb_set_d_d(z, input_1f1[i][4], input_1f1[i][5]);
                    acb_hypgeom_u(r, a, b, z, prec);
                }
                else if (function == 2)
                {
                    acb_set_d_d(a, input_2f1[i][0], input_2f1[i][1]);
                    acb_set_d_d(b, input_2f1[i][2], input_2f1[i][3]);
                    acb_set_d_d(c, input_2f1[i][4], input_2f1[i][5]);
                    acb_set_d_d(z, input_2f1[i][6], input_2f1[i][7]);
                    acb_hypgeom_2f1(r, a, b, c, z, 0, prec);
                }
                else
                {
                    acb_set_d_d(a, input_2f1[i][0], input_2f1[i][1]);
                    acb_set_d_d(b, input_2f1[i][2], input_2f1[i][3]);
                    acb_set_d_d(c, input_2f1[i][4], input_2f1[i][5]);
                    acb_set_d_d(z, input_2f1[i][6], input_2f1[i][7]);
                    acb_mul_2exp_si(z, z, 1);
                    acb_sub_ui(z, z, 1, prec);
                    acb_neg(z, z);
                    acb_hypgeom_legendre_q(r, a, c, z, 0, prec);
                }

                if (function == 3)
                {
                    if (acb_rel_accuracy_bits(r) >= goal)
                        break;
                }
                else
                {
                    if (arb_can_round_arf(acb_realref(r), goal, ARF_RND_NEAR) &&
                        arb_can_round_arf(acb_imagref(r), goal, ARF_RND_NEAR))
                        break;
                }

                prec *= 2;
            }

            TIMEIT_STOP_VAL(t)

            total += t;
            logtotal += log(t);

#if 1
            printf("%8g, ", t);
#else
            printf("%8ld    %8g    ", prec, t);
            _acb_print(r, 25);
            printf("\n");
#endif
        }

        printf("---------------------------------------------------------------\n");
        printf("Mean %g s; geometric mean %g\n", total, exp(logtotal / numtests));
        printf("---------------------------------------------------------------\n");
    }

    acb_clear(a);
    acb_clear(b);
    acb_clear(c);
    acb_clear(z);
    acb_clear(r);
    acb_clear(s);
}