arb/acb_dirichlet/theta_arb.c

105 lines
2.8 KiB
C
Raw Normal View History

/*
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
2016-10-06 14:19:39 +02:00
_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)
{
2016-10-08 17:22:19 +02:00
ulong order;
ulong * a;
2016-10-08 17:22:19 +02:00
int parity;
acb_dirichlet_roots_t z;
2016-10-08 17:22:19 +02:00
parity = dirichlet_parity_char(G, chi);
order = dirichlet_order_char(G, chi);
a = flint_malloc(len * sizeof(ulong));
2016-10-08 17:22:19 +02:00
dirichlet_chi_vec_order(a, G, chi, order, len);
acb_dirichlet_roots_init(z, order, 0, prec);
2016-10-08 17:22:19 +02:00
acb_dirichlet_qseries_arb_powers_smallorder(res, xt, parity, a, z, len, prec);
acb_dirichlet_roots_clear(z);
flint_free(a);
}
void
2016-10-06 14:19:39 +02:00
_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);
2016-10-08 17:22:19 +02:00
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
2016-10-06 14:19:39 +02:00
_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)
{
2016-10-08 17:22:19 +02:00
ulong order, * a;
acb_dirichlet_roots_t z;
2016-10-08 17:22:19 +02:00
int parity;
2016-10-08 17:22:19 +02:00
parity = dirichlet_parity_char(G, chi);
order = dirichlet_order_char(G, chi);
a = flint_malloc(len * sizeof(ulong));
2016-10-08 17:22:19 +02:00
dirichlet_chi_vec_order(a, G, chi, order, len);
acb_dirichlet_roots_init(z, order, len, prec);
2016-10-08 17:22:19 +02:00
acb_dirichlet_qseries_arb_powers_naive(res, xt, parity, a, z, len, prec);
acb_dirichlet_roots_clear(z);
flint_free(a);
}
void
2016-10-06 14:19:39 +02:00
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;
2016-10-08 17:22:19 +02:00
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 */
2016-10-08 17:22:19 +02:00
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);
2016-09-21 15:04:25 +02:00
acb_mul_2exp_si(res, res, 1);
arb_clear(xt);
}