#include "nmod_vec.h"
#include "nmod_poly.h"
#include "gr_poly.h"
void
_nmod_poly_exp_series(nn_ptr f, nn_srcptr h, slong hlen, slong n, nmod_t mod)
{
gr_ctx_t ctx;
_gr_ctx_init_nmod(ctx, &mod);
GR_MUST_SUCCEED(_gr_poly_exp_series(f, h, hlen, n, ctx));
}
void
_nmod_poly_exp_expinv_series(nn_ptr f, nn_ptr g, nn_srcptr h, slong hlen, slong n, nmod_t mod)
{
_nmod_poly_exp_series(f, h, hlen, n, mod);
_nmod_poly_inv_series(g, f, n, n, mod);
}
void
nmod_poly_exp_series(nmod_poly_t f, const nmod_poly_t h, slong n)
{
slong hlen = h->length;
if (hlen > 0 && h->coeffs[0] != UWORD(0))
{
flint_throw(FLINT_ERROR, "Exception (nmod_poly_exp_series). Constant term != 0.\n");
}
if (n <= 1 || hlen <= 1)
{
if (n == 0)
nmod_poly_zero(f);
else
nmod_poly_one(f);
return;
}
nmod_poly_fit_length(f, n);
_nmod_poly_exp_series(f->coeffs, h->coeffs, hlen, n, f->mod);
f->length = n;
_nmod_poly_normalise(f);
}