File: t-euler_product_real_ui.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 (133 lines) | stat: -rw-r--r-- 3,874 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/*
    Copyright (C) 2016 Fredrik Johansson

    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"

const signed char chi[8][6] = {
  {1, 1},
  {2, 0, 1},
  {3, 0, 1, 1},
  {3, 0, 1, -1},
  {4, 0, 1, 0, 1},
  {4, 0, 1, 0, -1},
  {5, 0, 1, 1, 1, 1},
  {5, 0, 1, -1, -1, 1},
};

const double L10[8] = {
  1.0009945751278180853371459589,
  1.0000170413630448254881839023,
  1.00097762319679253337038382667,
  0.999024291448866695201196896346,
  1.0000170413630448254881839023,
  0.999983164026196877405540729958,
  1.00099447262597359224857402038,
  0.999007468458940084215357132419
};

int main()
{
    slong iter;
    flint_rand_t state;

    flint_printf("euler_product_real_ui....");
    fflush(stdout);
    flint_randinit(state);

    for (iter = 0; iter < 3000 * arb_test_multiplier(); iter++)
    {
        arb_t res1, res2;
        ulong s;
        slong prec1, prec2, accuracy;
        int choice, reciprocal1, reciprocal2;

        if (iter % 10 == 0)
        {
            s = n_randtest(state);
            prec1 = 2 + n_randint(state, 300);
            prec2 = 2 + n_randint(state, 300);
        }
        else
        {
            s = 6 + n_randint(state, 1 << n_randint(state, 12));
            prec1 = 2 + n_randint(state, 12 * s);
            prec2 = 2 + n_randint(state, 12 * s);
        }

        if (n_randint(state, 30)  == 0)
            prec1 = 2 + n_randint(state, 4000);

        choice = n_randint(state, 7);
        reciprocal1 = n_randint(state, 2);
        reciprocal2 = n_randint(state, 2);

        arb_init(res1);
        arb_init(res2);
        arb_randtest(res1, state, 200, 100);

        _acb_dirichlet_euler_product_real_ui(res1, s, chi[choice] + 1,
            chi[choice][0], reciprocal1, prec1);
        _acb_dirichlet_euler_product_real_ui(res2, s, chi[choice] + 1,
            chi[choice][0], reciprocal2, prec2);

        if (reciprocal1 != reciprocal2)
            arb_inv(res2, res2, prec2);

        if (!arb_overlaps(res1, res2))
        {
            flint_printf("FAIL: overlap\n\n");
            flint_printf("s = %wu\n\n", s);
            flint_printf("chi: %d\n", choice);
            flint_printf("res1 = "); arb_printd(res1, prec1 / 3.33); flint_printf("\n\n");
            flint_printf("res2 = "); arb_printd(res2, prec2 / 3.33); flint_printf("\n\n");
            flint_abort();
        }

        if (s >= 6 && prec1 < 2 * s * log(s))
        {
            accuracy = arb_rel_accuracy_bits(res1);

            if (accuracy < prec1 - 4)
            {
                flint_printf("FAIL: accuracy = %wd, prec = %wd\n\n", accuracy, prec1);
                flint_printf("res1 = "); arb_printd(res1, prec1 / 3.33); flint_printf("\n\n");
                flint_abort();
            }
        }

        if (s == 10)
        {
            arf_set_d(arb_midref(res2), L10[choice]);
            mag_set_d(arb_radref(res2), 1e-15);
            if (reciprocal1)
                arb_inv(res2, res2, 53);

            if (!arb_overlaps(res1, res2))
            {
                flint_printf("FAIL: overlap (2)\n\n");
                flint_printf("s = %wu\n\n", s);
                flint_printf("chi: %d\n", choice);
                flint_printf("res1 = "); arb_printd(res1, prec1 / 3.33); flint_printf("\n\n");
                flint_printf("res2 = "); arb_printd(res2, prec2 / 3.33); flint_printf("\n\n");
                flint_abort();
            }
        }

        arb_clear(res1);
        arb_clear(res2);
    }

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