Пример #1
0
void
acb_dirichlet_l(acb_t res, const acb_t s,
    const dirichlet_group_t G, const dirichlet_char_t chi, slong prec)
{
    if (!acb_is_finite(s))
    {
        acb_indeterminate(res);
    }
    else if (G == NULL || G->q == 1)
    {
        acb_dirichlet_zeta(res, s, prec);
    }
    else if (dirichlet_char_is_primitive(G, chi) &&
        (arf_cmp_d(arb_midref(acb_realref(s)), -0.5) < 0 ||
            (G->q != 1 && dirichlet_parity_char(G, chi) == 0 &&
                arf_cmpabs_d(arb_midref(acb_imagref(s)), 0.125) < 0 &&
                arf_cmp_d(arb_midref(acb_realref(s)), 0.125) < 0)))
    {
        /* use functional equation */
        acb_t t, u, v;
        int parity;
        ulong q;

        parity = dirichlet_parity_char(G, chi);
        q = G->q;

        acb_init(t);
        acb_init(u);
        acb_init(v);

        /* gamma((1-s+p)/2) / gamma((s+p)/2) */
        acb_add_ui(t, s, parity, prec);
        acb_mul_2exp_si(t, t, -1);
        acb_rgamma(t, t, prec);

        if (!acb_is_zero(t))  /* assumes q != 1 when s = 0 */
        {
            acb_neg(u, s);
            acb_add_ui(u, u, 1 + parity, prec);
            acb_mul_2exp_si(u, u, -1);
            acb_gamma(u, u, prec);
            acb_mul(t, t, u, prec);

            /* epsilon */
            acb_dirichlet_root_number(u, G, chi, prec);
            acb_mul(t, t, u, prec);

            /* (pi/q)^(s-1/2) */
            acb_const_pi(u, prec);
            acb_div_ui(u, u, q, prec);
            acb_set_d(v, -0.5);
            acb_add(v, v, s, prec);
            acb_pow(u, u, v, prec);
            acb_mul(t, t, u, prec);

            acb_sub_ui(u, s, 1, prec);
            acb_neg(u, u);
            acb_conj(u, u);
            acb_dirichlet_l_general(u, u, G, chi, prec);
            acb_conj(u, u);
            acb_mul(t, t, u, prec);

            if (dirichlet_char_is_real(G, chi) && acb_is_real(s))
                arb_zero(acb_imagref(t));
        }

        acb_set(res, t);

        acb_clear(t);
        acb_clear(u);
        acb_clear(v);
    }
    else
    {
        acb_dirichlet_l_general(res, s, G, chi, prec);
    }
}
Пример #2
0
int main()
{
    slong iter, bits;
    flint_rand_t state;

    flint_printf("properties....");
    fflush(stdout);
    flint_randinit(state);
    for (bits = 5; bits <= 30; bits += 5)
    {

        for (iter = 0; iter < 50; iter++)
        {
            dirichlet_group_t G;
            dirichlet_char_t chi, psi;
            ulong q, iter2;

            q = 2 + n_randint(state, 1 << bits);

            dirichlet_group_init(G, q);
            dirichlet_char_init(chi, G);
            dirichlet_char_init(psi, G);

            /* check number char properties */
            for (iter2 = 0; iter2 < 100; iter2++)
            {
                ulong m, n;
                ulong p1, p2, pairing, cm, cn, q2, q3;
                dirichlet_group_t G2, G3;
                dirichlet_char_t chi2, chi3;

                if (iter2 == 50)
                    dirichlet_group_dlog_precompute(G, 5);

                /* one random character */
                do
                    m = n_randint(state, q);
                while (n_gcd(q, m) > 1);

                dirichlet_char_log(chi, G, m);

                p1 = dirichlet_order_ui(G, m);
                p2 = dirichlet_order_char(G, chi);
                check_eq(p1, p2, q, m, "order m", "order chi");

                p1 = dirichlet_conductor_ui(G, m);
                p2 = dirichlet_conductor_char(G, chi);
                check_eq(p1, p2, q, m, "conductor m", "conductor chi");

                p1 = dirichlet_parity_ui(G, m);
                p2 = dirichlet_parity_char(G, chi);
                check_eq(p1, p2, q, m, "parity m", "parity chi");

                p1 = dirichlet_char_is_real(G, chi);
                p2 = (dirichlet_order_char(G, chi) <= 2);
                check_eq(p1, p2, q, m, "is_real", "(order <= 2)");

                /* check index */
                p1 = dirichlet_index_char(G, chi);
                dirichlet_char_index(psi, G, p1);

                if (!dirichlet_char_eq_deep(G, chi, psi))
                {
                    flint_printf("FAIL: index\n\n");
                    flint_printf("q = %wu\n\n", q);
                    flint_printf("m = %wu\n\n", m);
                    flint_printf("chi = "); dirichlet_char_print(G, chi);
                    flint_printf("\n\nindex(chi) = %wu\n\n", p1);
                    flint_printf("psi(index) = %wu\n\n", psi->n);
                    flint_printf("psi = "); dirichlet_char_print(G, psi);
                    flint_printf("\n\n");
                    abort();
                }

                /* lift to higher modulus */
                q2 = q * (1 + n_randint(state, 100));

                dirichlet_group_init(G2, q2);
                dirichlet_char_init(chi2, G2);
                dirichlet_char_lift(chi2, G2, chi, G);

                p1 = dirichlet_conductor_char(G, chi);
                p2 = dirichlet_conductor_char(G2, chi2);
                check_eq(p1, p2, q, m, "conductor chi", "conductor lift");

                p1 = dirichlet_order_char(G, chi);
                p2 = dirichlet_order_char(G2, chi2);
                check_eq(p1, p2, q, m, "order chi", "order lift");

                /* and lower */

                dirichlet_char_lower(psi, G, chi2, G2);
                if (!dirichlet_char_eq_deep(G, chi, psi))
                {
                    flint_printf("FAIL: lift and lower back\n\n");
                    flint_printf("q = %wu\n\nchi = ", q);
                    dirichlet_char_print(G, chi);
                    flint_printf("\n\nq2 = %wu\n\nchi2 = ", q2);
                    dirichlet_char_print(G2, chi2);
                    flint_printf("\n\nq = %wu\n\npsi = ", q);
                    dirichlet_char_print(G, psi);
                    flint_printf("\n\n");
                    abort();
                }

                q3 = dirichlet_conductor_char(G, chi) * random_divisor(state, G);
                q3 = n_gcd(q, q3);

                dirichlet_group_init(G3, q3);
                dirichlet_char_init(chi3, G3);
                dirichlet_char_lower(chi3, G3, chi2, G2);

                p1 = dirichlet_conductor_char(G, chi);
                p2 = dirichlet_conductor_char(G3, chi3);
                check_eq(p1, p2, q, m, "conductor chi", "conductor lower");

                p1 = dirichlet_order_char(G, chi);
                p2 = dirichlet_order_char(G3, chi3);
                check_eq(p1, p2, q, m, "order chi", "order lower");

                dirichlet_char_clear(chi3);
                dirichlet_group_clear(G3);
                dirichlet_char_clear(chi2);
                dirichlet_group_clear(G2);

                /* another random character */
                do
                    n = n_randint(state, q);
                while (n_gcd(q, n) > 1);

                dirichlet_char_log(psi, G, n);
                pairing = dirichlet_pairing(G, m, n);
                cn = dirichlet_chi(G, chi, n);
                cm = dirichlet_chi(G, psi, m);

                if (pairing != cn || pairing != cm)
                {
                    flint_printf("FAIL: pairing\n\n");
                    flint_printf("q = %wu\n\n", q);
                    flint_printf("m = %wu\n\n", m);
                    flint_printf("n = %wu\n\n", n);
                    flint_printf("chi(m,n) = %wu\n\n", pairing);
                    flint_printf("chi(m)(n) = %wu\n\n", cn);
                    flint_printf("chi(n)(m) = %wu\n\n", cm);
                    abort();
                }

            }

            dirichlet_group_dlog_clear(G);

            dirichlet_char_clear(chi);
            dirichlet_char_clear(psi);
            dirichlet_group_clear(G);
        }
    }

    flint_randclear(state);
    flint_cleanup();
    flint_printf("PASS\n");
    return EXIT_SUCCESS;
}