arb/acb_dirichlet/ui_chi_vec_primeloop.c

85 lines
2.4 KiB
C
Raw Normal View History

/*=============================================================================
This file is part of ARB.
ARB is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
ARB is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with ARB; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
=============================================================================*/
/******************************************************************************
Copyright (C) 2016 Pascal Molin
******************************************************************************/
#include "acb_dirichlet.h"
static void
2016-04-05 11:55:04 +02:00
chi_vec_evenpart(ulong *v, const acb_dirichlet_group_t G, const acb_dirichlet_char_t chi, slong nv)
{
ulong c3, c4, x;
if (G->neven >= 1 && (c3 = chi->expo[0]))
{
for (x = 3; x < nv; x += 4)
v[x] = c3;
}
if (G->neven == 2 && (c4 = chi->expo[1]))
{
ulong g, pe, vx, xp;
vx = c4;
pe = G->P[1].pe.n;
g = G->P[1].g;
2016-04-05 11:55:04 +02:00
for (x = g; x > 1;)
{
for (xp = x; xp < nv; xp += pe)
v[xp] = (v[xp] + vx) % chi->order;
for (xp = pe - x; xp < nv; xp += pe)
v[xp] = (v[xp] + vx) % chi->order;
x = (x * g) % pe;
vx = (vx + c4) % chi->order;
}
}
}
/* loop over primary components */
void
acb_dirichlet_ui_chi_vec_primeloop(ulong *v, const acb_dirichlet_group_t G, const acb_dirichlet_char_t chi, slong nv)
{
2016-03-29 14:37:21 +01:00
slong k, l;
2016-07-14 15:51:25 +02:00
nmod_t order;
2016-03-29 14:04:08 +01:00
for (k = 1; k < nv; k++)
v[k] = 0;
2016-04-05 11:55:04 +02:00
if (G->neven)
chi_vec_evenpart(v, G, chi, nv);
2016-07-14 15:51:25 +02:00
nmod_init(&order, chi->order);
2016-04-05 11:55:04 +02:00
for (l = G->neven; l < G->num; l++)
{
2016-07-14 15:51:25 +02:00
acb_dirichlet_prime_group_struct P = G->P[l];
2016-04-05 11:55:04 +02:00
2016-07-14 15:51:25 +02:00
/* FIXME: there may be some precomputed dlog in P if needed */
dlog_vec_add(v, nv, P.g, chi->expo[l], P.pe, P.phi, order);
2016-03-29 14:04:08 +01:00
}
acb_dirichlet_ui_vec_set_null(v, G, nv);
}