File: t-jacobi.c

package info (click to toggle)
flint-arb 1%3A2.19.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 13,028 kB
  • sloc: ansic: 177,109; sh: 553; makefile: 288; python: 268
file content (88 lines) | stat: -rw-r--r-- 2,343 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
    Copyright (C) 2016 Pascal Molin

    This file is part of Arb.

    Arb is free software: you can redistribute it and/or modify it under
    the terms of the GNU Lesser General Public License (LGPL) as published
    by the Free Software Foundation; either version 2.1 of the License, or
    (at your option) any later version.  See <http://www.gnu.org/licenses/>.
*/

#include "acb_dirichlet.h"

int main()
{
    slong prec = 128;
    ulong q;

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

    /* check Jacobi sums */

    for (q = 29 * 29; q > 1; q = q%2 ? 3*q+1 : q/2)
    {
        slong m1, m2;
        dirichlet_group_t G;
        dirichlet_char_t chi1, chi2;

        acb_t s1, s2;

        dirichlet_group_init(G, q);
        dirichlet_char_init(chi1, G);
        dirichlet_char_init(chi2, G);

        acb_init(s1);
        acb_init(s2);

        dirichlet_char_one(chi1, G);

        for (m1 = 0; m1 < 50; m1++)
        {

            dirichlet_char_one(chi2, G);

            for (m2 = 0; m2 < 50; m2++)
            {

                acb_dirichlet_jacobi_sum_naive(s1, G, chi1, chi2, prec);
                acb_dirichlet_jacobi_sum(s2, G, chi1, chi2, prec);

                if (!acb_overlaps(s1, s2))
                {
                    flint_printf("FAIL: J_%wu(%wu,%wu)",
                            q, chi1->n, chi2->n);
                    flint_printf("\nnaive ");
                    acb_printd(s1, 25);
                    flint_printf("\ndefault ");
                    acb_printd(s2, 25);
                    flint_printf("\n");
                    flint_printf("cond = %wu, %wu, %wu\n",
                            dirichlet_conductor_char(G, chi1),
                            dirichlet_conductor_char(G, chi2),
                            dirichlet_conductor_ui(G, nmod_mul(chi1->n, chi2->n, G->mod))
                            );
                    flint_abort();
                }
                if (dirichlet_char_next(chi2, G) < 0)
                    break;

            }

            if (dirichlet_char_next(chi1, G) < 0)
                break;

        }

        acb_clear(s1);
        acb_clear(s2);
        dirichlet_group_clear(G);
        dirichlet_char_clear(chi1);
        dirichlet_char_clear(chi2);
    }

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