2016-04-26 17:20:05 +02:00
|
|
|
/*
|
2016-02-21 23:23:51 +01:00
|
|
|
Copyright (C) 2015 Jonathan Bober
|
|
|
|
Copyright (C) 2016 Fredrik Johansson
|
|
|
|
|
2016-04-26 17:20:05 +02:00
|
|
|
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/>.
|
|
|
|
*/
|
2016-02-21 23:23:51 +01:00
|
|
|
|
|
|
|
#include "acb_dirichlet.h"
|
|
|
|
|
|
|
|
/* todo: modular arithmetic */
|
|
|
|
|
2016-02-24 11:06:49 +01:00
|
|
|
long
|
|
|
|
n_dirichlet_chi_conrey(const acb_dirichlet_group_t G, const acb_conrey_t a, const acb_conrey_t b)
|
2016-02-21 23:23:51 +01:00
|
|
|
{
|
2016-02-24 11:06:49 +01:00
|
|
|
ulong x, k;
|
|
|
|
x = 0;
|
|
|
|
for (k = 0; k < G->num; k++)
|
|
|
|
x = (x + G->PHI[k] * a->log[k] * b->log[k]) % G->expo;
|
|
|
|
return x;
|
2016-02-21 23:23:51 +01:00
|
|
|
}
|
|
|
|
|
2016-02-24 11:06:49 +01:00
|
|
|
long
|
|
|
|
n_dirichlet_chi(const acb_dirichlet_group_t G, ulong m, ulong n)
|
2016-02-21 23:23:51 +01:00
|
|
|
{
|
2016-02-24 11:06:49 +01:00
|
|
|
ulong x;
|
|
|
|
acb_conrey_t a, b;
|
|
|
|
acb_conrey_init(a, G);
|
|
|
|
acb_conrey_init(b, G);
|
2016-02-21 23:23:51 +01:00
|
|
|
|
2016-02-24 11:06:49 +01:00
|
|
|
acb_conrey_log(a, G, m);
|
|
|
|
acb_conrey_log(b, G, n);
|
|
|
|
x = n_dirichlet_chi_conrey(G, a, b);
|
2016-02-21 23:23:51 +01:00
|
|
|
|
2016-02-24 11:06:49 +01:00
|
|
|
acb_conrey_clear(a);
|
|
|
|
acb_conrey_clear(b);
|
2016-02-21 23:23:51 +01:00
|
|
|
|
2016-02-24 11:06:49 +01:00
|
|
|
return x;
|
|
|
|
}
|
2016-02-21 23:23:51 +01:00
|
|
|
|
2016-02-24 11:06:49 +01:00
|
|
|
void
|
|
|
|
acb_dirichlet_chi_conrey(acb_t res, const acb_dirichlet_group_t G, const acb_conrey_t a, const acb_conrey_t b, slong prec)
|
|
|
|
{
|
|
|
|
fmpq_t t;
|
|
|
|
fmpq_init(t);
|
|
|
|
fmpq_set_si(t, n_dirichlet_chi_conrey(G, a, b), G->expo);
|
|
|
|
arb_sin_cos_pi_fmpq(acb_imagref(res), acb_realref(res), t, prec);
|
|
|
|
fmpq_clear(t);
|
2016-02-21 23:23:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-02-22 11:47:12 +01:00
|
|
|
acb_dirichlet_chi(acb_t res, const acb_dirichlet_group_t G, ulong m, ulong n, slong prec)
|
2016-02-21 23:23:51 +01:00
|
|
|
{
|
2016-02-24 11:06:49 +01:00
|
|
|
fmpq_t t;
|
|
|
|
fmpq_init(t);
|
|
|
|
fmpq_set_si(t, n_dirichlet_chi(G, m, n), G->expo);
|
|
|
|
arb_sin_cos_pi_fmpq(acb_imagref(res), acb_realref(res), t, prec);
|
|
|
|
fmpq_clear(t);
|
2016-02-21 23:23:51 +01:00
|
|
|
}
|