int main()
{
    slong iter;
    flint_rand_t state;

    flint_printf("backlund_s_bound....");
    fflush(stdout);

    flint_randinit(state);

    for (iter = 0; iter < 500 * arb_test_multiplier(); iter++)
    {
        arb_t a, b;
        mag_t u, v;
        slong aprec, bprec;
        slong abits, bbits;

        aprec = 2 + n_randint(state, 1000);
        bprec = 2 + n_randint(state, 1000);
        abits = 2 + n_randint(state, 100);
        bbits = 2 + n_randint(state, 100);

        arb_init(a);
        arb_init(b);
        mag_init(u);
        mag_init(v);

        arb_randtest(a, state, aprec, abits);
        arb_randtest(b, state, bprec, bbits);

        if (arb_is_nonnegative(a) && arb_is_nonnegative(b))
        {
            acb_dirichlet_backlund_s_bound(u, a);
            acb_dirichlet_backlund_s_bound(v, b);

            if ((arb_lt(a, b) && mag_cmp(u, v) > 0) ||
                (arb_gt(a, b) && mag_cmp(u, v) < 0))
            {
                flint_printf("FAIL: increasing on t >= 0\n\n");
                flint_printf("a = "); arb_print(a); flint_printf("\n\n");
                flint_printf("b = "); arb_print(b); flint_printf("\n\n");
                flint_printf("u = "); mag_print(u); flint_printf("\n\n");
                flint_printf("v = "); mag_print(v); flint_printf("\n\n");
                flint_abort();
            }
        }

        arb_clear(a);
        arb_clear(b);
        mag_clear(u);
        mag_clear(v);
    }

    flint_randclear(state);
    flint_cleanup();
    flint_printf("PASS\n");
    return EXIT_SUCCESS;
}
int
arb_richcmp(const arb_t x, const arb_t y, int op)
{
    switch (op)
    {
        case 0: return arb_eq(x, y);
        case 1: return arb_ne(x, y);
        case 2: return arb_le(x, y);
        case 3: return arb_lt(x, y);
        case 4: return arb_ge(x, y);
        default: return arb_gt(x, y);
    }
}
Beispiel #3
0
/* invalid in (-1,0) */
int
_acb_hypgeom_legendre_q_single_valid(const acb_t z)
{
    arb_t t;
    int ok;

    if (!arb_contains_zero(acb_imagref(z)))
        return 1;

    if (arb_is_positive(acb_imagref(z)))
        return 1;

    arb_init(t);
    arb_one(t);
    arb_neg(t, t);
    ok = arb_lt(acb_realref(z), t);
    arb_clear(t);
    return ok;
}
Beispiel #4
0
void
acb_acosh(acb_t res, const acb_t z, slong prec)
{
    if (acb_is_one(z))
    {
        acb_zero(res);
    }
    else
    {
        acb_t t, u;
        acb_init(t);
        acb_init(u);

        acb_add_ui(t, z, 1, prec);
        acb_sub_ui(u, z, 1, prec);
        acb_sqrt(t, t, prec);
        acb_sqrt(u, u, prec);
        acb_mul(t, t, u, prec);
        acb_add(t, t, z, prec);

        if (!arb_is_zero(acb_imagref(z)))
        {
            acb_log(res, t, prec);
        }
        else
        {
            /* pure imaginary on (-1,1) */
            arb_abs(acb_realref(u), acb_realref(z));
            arb_one(acb_imagref(u));
            acb_log(res, t, prec);
            if (arb_lt(acb_realref(u), acb_imagref(u)))
                arb_zero(acb_realref(res));
        }

        acb_clear(t);
        acb_clear(u);
    }
}
Beispiel #5
0
int
_acb_poly_validate_real_roots(acb_srcptr roots, acb_srcptr poly, long len, long prec)
{
    long i, deg, num_real;
    arb_ptr real;
    int result;

    deg = len - 1;
    num_real = 0;
    result = 1;

    if (deg <= 1)
        return 1;

    real = _arb_vec_init(deg);

    /* pick out the candidate real roots */
    for (i = 0; i < deg; i++)
    {
        if (arb_contains_zero(acb_imagref(roots + i)))
        {
            arb_set(real + num_real, acb_realref(roots + i));
            num_real++;
        }
    }

    /* number of real roots must be even if the polynomial is even,
       and odd if the polynomial is odd (unless there are repeated roots...
       in which case the input is invalid) */
    if ((num_real % 2) != (deg % 2))
    {
        result = 0;
    }
    else if (num_real > 0)
    {
        int sign_neg_inf, sign_pos_inf, prev_sign;

        acb_t t;
        acb_init(t);

        /* by assumption that the roots are real and isolated, the lead
           coefficient really must be known to be either positive or negative */
        sign_pos_inf = arb_is_positive(acb_realref(poly + deg)) ? 1 : -1;
        sign_neg_inf = (deg % 2) ? -sign_pos_inf : sign_pos_inf;

        /* now we check that there's a sign change between each root */
        _arb_vec_sort_mid(real, num_real);

        prev_sign = sign_neg_inf;

        for (i = 0; i < num_real - 1; i++)
        {
            /* set t to the midpoint between the midpoints */
            arb_zero(acb_imagref(t));
            arf_add(arb_midref(acb_realref(t)),
                arb_midref(real + i), arb_midref(real + i + 1), prec, ARF_RND_DOWN);
            arf_mul_2exp_si(arb_midref(acb_realref(t)), arb_midref(acb_realref(t)), -1);
            mag_zero(arb_radref(acb_realref(t)));

            /* check that this point really is between both intervals (one interval
               could be much wider than the other */
            if (arb_lt(real + i, acb_realref(t)) && arb_lt(acb_realref(t), real + i + 1))
            {
                /* check sign change */
                _acb_poly_evaluate(t, poly, len, t, prec);

                if (prev_sign == 1)
                    result = arb_is_negative(acb_realref(t));
                else
                    result = arb_is_positive(acb_realref(t));

                if (!result)
                    break;

                prev_sign = -prev_sign;
            }
            else
            {
                result = 0;
                break;
            }
        }

        acb_clear(t);
    }

    _arb_vec_clear(real, deg);

    return result;
}