1 /*
2     Copyright (C) 2011 Sebastian Pancratz
3     Copyright (C) 2008, 2009 William Hart
4 
5     This file is part of FLINT.
6 
7     FLINT is free software: you can redistribute it and/or modify it under
8     the terms of the GNU Lesser General Public License (LGPL) as published
9     by the Free Software Foundation; either version 2.1 of the License, or
10     (at your option) any later version.  See <https://www.gnu.org/licenses/>.
11 */
12 
13 #include <gmp.h>
14 #include <stdlib.h>
15 #include "flint.h"
16 #include "fmpz.h"
17 #include "fmpz_mod_poly.h"
18 
fmpz_mod_poly_set_coeff_si(fmpz_mod_poly_t poly,slong n,slong x,const fmpz_mod_ctx_t ctx)19 void fmpz_mod_poly_set_coeff_si(fmpz_mod_poly_t poly, slong n, slong x,
20                                                       const fmpz_mod_ctx_t ctx)
21 {
22     fmpz_mod_poly_fit_length(poly, n + 1, ctx);
23 
24     if (n + 1 > poly->length)
25     {
26         flint_mpn_zero((mp_ptr) (poly->coeffs + poly->length), n - poly->length);
27         poly->length = n + 1;
28     }
29 
30     fmpz_set_si(poly->coeffs + n, x);
31     fmpz_mod(poly->coeffs + n, poly->coeffs + n, fmpz_mod_ctx_modulus(ctx));
32     _fmpz_mod_poly_normalise(poly);
33 }
34 
35