2016-09-06 15:32:23 +02:00
|
|
|
/*
|
2016-03-22 11:29:21 +01:00
|
|
|
Copyright (C) 2016 Pascal Molin
|
2016-02-24 11:06:49 +01:00
|
|
|
|
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-02-24 11:06:49 +01:00
|
|
|
|
2016-10-06 14:19:39 +02:00
|
|
|
#include "dirichlet.h"
|
2016-02-24 11:06:49 +01:00
|
|
|
|
2016-10-08 17:22:19 +02:00
|
|
|
static void
|
|
|
|
dirichlet_exponents_char(ulong * expo, const dirichlet_group_t G, const dirichlet_char_t chi, ulong order)
|
|
|
|
{
|
|
|
|
slong k;
|
|
|
|
ulong factor = G->expo / order;
|
|
|
|
for (k = 0; k < G->num; k++)
|
|
|
|
/* no overflow: log[k] < phi[k] and G->expo = phi[k] * PHI[k] */
|
|
|
|
expo[k] = (chi->log[k] * G->PHI[k]) / factor;
|
|
|
|
}
|
|
|
|
|
2016-03-22 11:29:21 +01:00
|
|
|
/* loop over whole group */
|
2016-02-24 11:06:49 +01:00
|
|
|
void
|
2016-10-08 17:22:19 +02:00
|
|
|
dirichlet_chi_vec_loop_order(ulong * v, const dirichlet_group_t G, const dirichlet_char_t chi, ulong order, slong nv)
|
2016-02-24 11:06:49 +01:00
|
|
|
{
|
2016-03-23 12:53:08 +01:00
|
|
|
int j;
|
2016-03-29 14:37:21 +01:00
|
|
|
ulong t;
|
|
|
|
slong k;
|
2016-10-08 17:22:19 +02:00
|
|
|
ulong expo[MAX_FACTORS];
|
2016-10-07 13:06:05 +02:00
|
|
|
dirichlet_char_t x;
|
2016-10-08 17:22:19 +02:00
|
|
|
nmod_t o;
|
|
|
|
|
2016-10-07 13:06:05 +02:00
|
|
|
dirichlet_char_init(x, G);
|
|
|
|
dirichlet_char_one(x, G);
|
2016-03-23 12:53:08 +01:00
|
|
|
|
2016-10-08 17:22:19 +02:00
|
|
|
dirichlet_exponents_char(expo, G, chi, order);
|
|
|
|
nmod_init(&o, order);
|
|
|
|
|
2016-03-23 12:53:08 +01:00
|
|
|
for (k = 0; k < nv; k++)
|
2016-10-06 14:19:39 +02:00
|
|
|
v[k] = DIRICHLET_CHI_NULL;
|
2016-03-23 12:53:08 +01:00
|
|
|
|
|
|
|
t = v[1] = 0;
|
2016-03-29 14:04:08 +01:00
|
|
|
|
2016-10-07 13:06:05 +02:00
|
|
|
while ( (j = dirichlet_char_next(x, G)) >= 0 )
|
2016-03-23 12:53:08 +01:00
|
|
|
{
|
|
|
|
/* exponents were modified up to j */
|
2016-08-04 15:35:33 +02:00
|
|
|
for (k = G->num - 1; k >= j; k--)
|
2016-10-08 17:22:19 +02:00
|
|
|
t = nmod_add(t, expo[k], o);
|
2016-03-29 14:04:08 +01:00
|
|
|
|
2016-03-23 12:53:08 +01:00
|
|
|
if (x->n < nv)
|
|
|
|
v[x->n] = t;
|
|
|
|
}
|
2016-03-29 14:04:08 +01:00
|
|
|
|
2016-03-23 12:53:08 +01:00
|
|
|
/* fix result outside primes */
|
2016-10-06 14:19:39 +02:00
|
|
|
/* dirichlet_vec_set_null(v, G, nv);*/
|
2016-03-23 12:53:08 +01:00
|
|
|
/* copy outside modulus */
|
2016-03-29 14:04:08 +01:00
|
|
|
|
2016-03-23 12:53:08 +01:00
|
|
|
for (k = G->q; k < nv ; k++ )
|
|
|
|
v[k] = v[k - G->q];
|
2016-03-29 14:04:08 +01:00
|
|
|
|
2016-10-07 13:06:05 +02:00
|
|
|
dirichlet_char_clear(x);
|
2016-02-24 11:06:49 +01:00
|
|
|
}
|
2016-10-08 17:22:19 +02:00
|
|
|
|
|
|
|
void
|
|
|
|
dirichlet_chi_vec_loop(ulong * v, const dirichlet_group_t G, const dirichlet_char_t chi, slong nv)
|
|
|
|
{
|
|
|
|
dirichlet_chi_vec_loop_order(v, G, chi, G->expo, nv);
|
|
|
|
}
|