2016-02-24 11:06:49 +01: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 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) 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
|
|
|
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
#include "acb_dirichlet.h"
|
|
|
|
|
|
|
|
/* TODO: use precomputations in G if present */
|
2016-03-22 11:29:21 +01:00
|
|
|
/* assume m is invertible */
|
2016-02-24 11:06:49 +01:00
|
|
|
void
|
2016-03-22 11:29:21 +01:00
|
|
|
acb_dirichlet_conrey_log(acb_dirichlet_conrey_t x, const acb_dirichlet_group_t G, ulong m)
|
2016-02-24 11:06:49 +01:00
|
|
|
{
|
|
|
|
ulong k, pk, gk;
|
|
|
|
/* 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;
|
|
|
|
if (G->dlog == NULL)
|
|
|
|
x->log[1] = n_discrete_log_bsgs(m2, 5, G->q_even);
|
|
|
|
else
|
|
|
|
x->log[1] = dlog_precomp(G->dlog[1], m2);
|
|
|
|
}
|
2016-02-24 11:06:49 +01:00
|
|
|
}
|
|
|
|
/* odd part */
|
2016-03-23 12:53:08 +01:00
|
|
|
if (G->dlog == NULL)
|
|
|
|
{
|
|
|
|
for (k = G->neven; k < G->num; k++)
|
|
|
|
{
|
|
|
|
pk = G->primepowers[k];
|
|
|
|
gk = G->generators[k] % pk;
|
|
|
|
x->log[k] = n_discrete_log_bsgs(m % pk, gk, pk);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2016-02-24 11:06:49 +01:00
|
|
|
{
|
2016-03-23 12:53:08 +01:00
|
|
|
for (k = G->neven; k < G->num; k++)
|
|
|
|
x->log[k] = dlog_precomp(G->dlog[k], m % G->primepowers[k]);
|
2016-02-24 11:06:49 +01:00
|
|
|
}
|
|
|
|
/* keep value m */
|
|
|
|
x->n = m;
|
|
|
|
}
|