arb/acb_dirichlet/gauss_sum_factor.c

71 lines
1.7 KiB
C
Raw Permalink Normal View History

2016-09-06 15:32:23 +02:00
/*
2016-07-13 15:54:45 +02:00
Copyright (C) 2016 Pascal Molin
2016-09-06 15:32:23 +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-07-13 15:54:45 +02:00
#include "acb_dirichlet.h"
void
2016-10-06 14:19:39 +02:00
acb_dirichlet_gauss_sum_factor(acb_t res, const dirichlet_group_t G, const dirichlet_char_t chi, slong prec)
2016-07-13 15:54:45 +02:00
{
slong k;
acb_t tmp;
2016-08-31 10:11:50 +02:00
2016-09-20 14:58:51 +02:00
/* early check */
2016-07-13 15:54:45 +02:00
for (k = (G->neven == 2); k < G->num; k++)
{
/* if e > 1 and not primitive, 0 */
2016-10-08 17:22:19 +02:00
if (chi->log[k] % G->P[k].p == 0 && G->P[k].e > 1)
2016-07-13 15:54:45 +02:00
{
acb_zero(res);
return;
}
}
/* factor */
acb_one(res);
acb_init(tmp);
for (k = (G->neven == 2); k < G->num; k++)
{
ulong pe = G->P[k].pe.n;
2016-10-06 14:19:39 +02:00
dirichlet_group_t Gp;
dirichlet_char_t chip;
2016-07-13 15:54:45 +02:00
2016-10-06 14:19:39 +02:00
dirichlet_subgroup_init(Gp, G, pe);
dirichlet_char_init(chip, Gp);
2016-07-13 15:54:45 +02:00
2016-10-08 17:22:19 +02:00
chip->n = chi->n % pe;
2016-07-13 15:54:45 +02:00
if (k == 1 && G->neven == 2)
{
2016-10-08 17:22:19 +02:00
chip->log[0] = chi->log[0];
chip->log[1] = chi->log[1];
2016-07-13 15:54:45 +02:00
}
else
2016-10-08 17:22:19 +02:00
chip->log[0] = chi->log[k];
2016-07-13 15:54:45 +02:00
2016-09-20 14:58:51 +02:00
/* chi_pe(a, q/pe) * G_pe(a) */
2016-07-13 15:54:45 +02:00
acb_dirichlet_gauss_sum(tmp, Gp, chip, prec);
acb_mul(res, res, tmp, prec);
acb_dirichlet_chi(tmp, Gp, chip, (G->q / pe) % pe, prec);
acb_mul(res, res, tmp, prec);
2016-10-06 14:19:39 +02:00
dirichlet_char_clear(chip);
dirichlet_group_clear(Gp);
2016-07-13 15:54:45 +02:00
}
if (G->q_even == 2)
acb_neg(res, res);
acb_clear(tmp);
}