2016-09-06 15:32:23 +02:00
|
|
|
/*
|
2016-02-24 11:06:49 +01:00
|
|
|
Copyright (C) 2015 Jonathan Bober
|
|
|
|
Copyright (C) 2016 Fredrik Johansson
|
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-09-09 11:13:20 +02:00
|
|
|
#include "dlog.h"
|
2016-10-06 14:19:39 +02:00
|
|
|
#include "dirichlet.h"
|
2016-02-24 11:06:49 +01:00
|
|
|
|
2016-03-22 11:29:21 +01:00
|
|
|
/* assume m is invertible */
|
2016-02-24 11:06:49 +01:00
|
|
|
void
|
2016-10-07 13:06:05 +02:00
|
|
|
dirichlet_char_log(dirichlet_char_t x, const dirichlet_group_t G, ulong m)
|
2016-02-24 11:06:49 +01:00
|
|
|
{
|
2016-09-09 12:38:22 +02:00
|
|
|
slong k;
|
2016-02-24 11:06:49 +01:00
|
|
|
/* even part */
|
|
|
|
if (G->neven >= 1)
|
|
|
|
{
|
2016-03-23 12:53:08 +01:00
|
|
|
x->log[0] = (m % 4 == 3);
|
|
|
|
if (G->neven == 2)
|
|
|
|
{
|
|
|
|
ulong m2 = (x->log[0]) ? -m % G->q_even : m % G->q_even;
|
2016-07-06 18:39:29 +02:00
|
|
|
if (G->P[1].dlog == NULL)
|
2016-09-09 11:13:20 +02:00
|
|
|
x->log[1] = dlog_mod2e_1mod4(m2, G->P[1].e,
|
|
|
|
nmod_inv(5, G->P[1].pe), G->P[1].pe);
|
2016-03-23 12:53:08 +01:00
|
|
|
else
|
2016-07-06 18:39:29 +02:00
|
|
|
x->log[1] = dlog_precomp(G->P[1].dlog, m2);
|
2016-03-23 12:53:08 +01:00
|
|
|
}
|
2016-02-24 11:06:49 +01:00
|
|
|
}
|
|
|
|
/* odd part */
|
2016-07-06 18:39:29 +02:00
|
|
|
for (k = G->neven; k < G->num; k++)
|
2016-03-23 12:53:08 +01:00
|
|
|
{
|
2016-10-06 14:19:39 +02:00
|
|
|
dirichlet_prime_group_struct P = G->P[k];
|
2016-09-09 12:38:22 +02:00
|
|
|
if (P.dlog == NULL)
|
2016-03-23 12:53:08 +01:00
|
|
|
{
|
2016-10-08 17:22:19 +02:00
|
|
|
x->log[k] = dlog_once(m % P.pe.n, P.g, P.pe, P.phi.n);
|
2016-03-23 12:53:08 +01:00
|
|
|
}
|
2016-07-06 18:39:29 +02:00
|
|
|
else
|
|
|
|
{
|
2016-09-09 12:38:22 +02:00
|
|
|
x->log[k] = dlog_precomp(P.dlog, m % P.pe.n);
|
2016-07-06 18:39:29 +02:00
|
|
|
}
|
2016-02-24 11:06:49 +01:00
|
|
|
}
|
|
|
|
/* keep value m */
|
|
|
|
x->n = m;
|
|
|
|
}
|