File: theta_arb.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 (104 lines) | stat: -rw-r--r-- 2,902 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
/*
    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"
#include "acb_poly.h"

void
_acb_dirichlet_theta_arb_smallorder(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, const arb_t xt, slong len, slong prec)
{
    ulong order;
    ulong * a;
    int parity;
    acb_dirichlet_roots_t z;

    parity = dirichlet_parity_char(G, chi);
    order = dirichlet_order_char(G, chi);
    a = flint_malloc(len * sizeof(ulong));
    dirichlet_chi_vec_order(a, G, chi, order, len);

    acb_dirichlet_roots_init(z, order, 0, prec);
    acb_dirichlet_qseries_arb_powers_smallorder(res, xt, parity, a, z, len, prec);
    acb_dirichlet_roots_clear(z);

    flint_free(a);
}

void
_acb_dirichlet_theta_arb_series(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, const arb_t xt, slong len, slong prec)
{
    acb_ptr a;
    a = _acb_vec_init(len);
    acb_dirichlet_chi_vec(a, G, chi, len, prec);
    if (dirichlet_parity_char(G, chi))
    {
        slong k;
        for (k = 2; k < len; k++)
            acb_mul_si(a + k, a + k, k, prec);
    }
    acb_dirichlet_qseries_arb(res, a, xt, len, prec);
    _acb_vec_clear(a, len);
}

void
_acb_dirichlet_theta_arb_naive(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, const arb_t xt, slong len, slong prec)
{
    ulong order, * a;
    acb_dirichlet_roots_t z;
    int parity;

    parity = dirichlet_parity_char(G, chi);
    order = dirichlet_order_char(G, chi);
    a = flint_malloc(len * sizeof(ulong));
    dirichlet_chi_vec_order(a, G, chi, order, len);

    acb_dirichlet_roots_init(z, order, len, prec);

    acb_dirichlet_qseries_arb_powers_naive(res, xt, parity, a, z, len, prec);

    acb_dirichlet_roots_clear(z);
    flint_free(a);
}

void
acb_dirichlet_theta_arb(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, const arb_t t, slong prec)
{
    slong len;
    ulong order;
    arb_t xt;
    mag_t e;

    len = acb_dirichlet_theta_length(G->q, t, prec);

    arb_init(xt);
    _acb_dirichlet_theta_argument_at_arb(xt, G->q, t, prec);

    mag_init(e);
    mag_tail_kexpk2_arb(e, xt, len);

    arb_neg(xt, xt);
    arb_exp(xt, xt, prec);

    /* TODO: tune this limit */
    order = dirichlet_order_char(G, chi);
    if (order < 30)
        _acb_dirichlet_theta_arb_smallorder(res, G, chi, xt, len, prec);
    else
        _acb_dirichlet_theta_arb_naive(res, G, chi, xt, len, prec);

    arb_add_error_mag(acb_realref(res), e);
    arb_add_error_mag(acb_imagref(res), e);

    mag_clear(e);

    acb_mul_2exp_si(res, res, 1);
    arb_clear(xt);
}