File: t-platt_ws_interpolation.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 (101 lines) | stat: -rw-r--r-- 3,174 bytes parent folder | download | duplicates (2)
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
/*
    Copyright (C) 2019 D.H.J. Polymath

    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 iter;
    flint_rand_t state;

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

    for (iter = 0; iter < 5 * arb_test_multiplier(); iter++)
    {
        ulong A, B, iter2;
        int Tbits;
        fmpz_t T;
        arb_ptr vec;
        slong vprec;

        A = 1 + n_randint(state, 10);
        B = 1 + n_randint(state, 10);
        if (n_randint(state, 2))
            A *= 2;
        else
            B *= 2;
        fmpz_init(T);
        Tbits = 5 + n_randint(state, 20);
        fmpz_set_ui(T, n_randtest_bits(state, Tbits));
        vprec = 2 + n_randint(state, 300);

        vec = _arb_vec_init(A*B);
        acb_dirichlet_platt_scaled_lambda_vec(vec, T, A, B, vprec);

        for (iter2 = 0; iter2 < 50; iter2++)
        {
            ulong Ns_max, sigma;
            arb_t expected, observed;
            arb_t t0, H;
            slong prec;

            arb_init(t0);
            arb_init(H);
            arb_init(expected);
            arb_init(observed);

            prec = 2 + n_randint(state, 300);
            Ns_max = 1 + n_randint(state, 100);
            sigma = 1 + 2*(1 + n_randint(state, 100));
            arb_set_si(t0, A*B*500 - n_randint(state, A*B*1000) - 1);
            arb_div_ui(t0, t0, A*1000, prec);
            arb_add_fmpz(t0, t0, T, prec);
            arb_set_ui(H, 1 + n_randint(state, 10000));
            arb_div_ui(H, H, 1000, prec);
            arb_abs(H, H);

            acb_dirichlet_platt_scaled_lambda(expected, t0, prec);
            acb_dirichlet_platt_ws_interpolation(observed, NULL, t0, vec,
                    T, A, B, Ns_max, H, sigma, prec);

            if (!arb_overlaps(expected, observed))
            {
                flint_printf("FAIL: overlap\n\n");
                flint_printf("iter = %wd\n\n", iter);
                flint_printf("iter2 = %wd\n\n", iter2);
                flint_printf("A = %wu\n\n", A);
                flint_printf("B = %wu\n\n", B);
                flint_printf("T = "); fmpz_print(T); flint_printf("\n\n");
                flint_printf("vprec = %wd\n\n", vprec);
                flint_printf("Ns_max = %wu\n\n", Ns_max);
                flint_printf("sigma = %wu\n\n", sigma);
                flint_printf("prec = %wd\n\n", prec);
                flint_printf("t0 = "); arb_printd(t0, 15); flint_printf("\n\n");
                flint_printf("H = "); arb_printd(H, 15); flint_printf("\n\n");
            }

            arb_clear(t0);
            arb_clear(H);
            arb_clear(expected);
            arb_clear(observed);
        }

        fmpz_clear(T);
        _arb_vec_clear(vec, A*B);
    }

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