2016-09-06 15:43:12 +02:00
|
|
|
/*
|
2016-03-07 09:55:19 +01:00
|
|
|
Copyright (C) 2016 Pascal Molin
|
|
|
|
|
2016-09-06 15:43:12 +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-03-07 09:55:19 +01:00
|
|
|
|
|
|
|
#include "dlog.h"
|
|
|
|
|
|
|
|
ulong
|
|
|
|
dlog_crt(const dlog_crt_t t, ulong b)
|
|
|
|
{
|
|
|
|
int k;
|
|
|
|
ulong r = 0;
|
|
|
|
for (k = 0; k < t->num; k++)
|
|
|
|
{
|
|
|
|
ulong bk, rk;
|
2016-03-11 16:59:49 +01:00
|
|
|
bk = nmod_pow_ui(b, t->expo[k], t->mod);
|
2016-03-23 22:10:58 +01:00
|
|
|
rk = dlog_precomp(t->pre + k, bk);
|
2016-03-07 09:55:19 +01:00
|
|
|
#if 0
|
|
|
|
flint_printf("##[crt-%d]: log(%wu)=log(%wu^%wu) = %wu [size %wu mod %wu]\n",
|
|
|
|
k, bk, b, t->expo[k], rk, t->n/t->expo[k], t->mod);
|
|
|
|
#endif
|
2016-03-11 16:59:49 +01:00
|
|
|
r = nmod_add(r, nmod_mul(t->crt_coeffs[k], rk, t->n), t->n);
|
2016-03-07 09:55:19 +01:00
|
|
|
}
|
|
|
|
return r;
|
|
|
|
}
|