1 /*
2     Copyright (C) 2016 William Hart
3     Copyright (C) 2018 Daniel Schultz
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 <http://www.gnu.org/licenses/>.
11 */
12 
13 #include "fmpz_mpoly.h"
14 
fmpz_mpoly_gen(fmpz_mpoly_t A,slong var,const fmpz_mpoly_ctx_t ctx)15 void fmpz_mpoly_gen(fmpz_mpoly_t A, slong var, const fmpz_mpoly_ctx_t ctx)
16 {
17     flint_bitcnt_t bits;
18 
19     bits = mpoly_gen_bits_required(var, ctx->minfo);
20     bits = mpoly_fix_bits(bits, ctx->minfo);
21 
22     fmpz_mpoly_fit_length(A, WORD(1), ctx);
23     fmpz_mpoly_fit_bits(A, bits, ctx);
24     A->bits = bits;
25 
26     fmpz_one(A->coeffs);
27     if (bits <= FLINT_BITS)
28         mpoly_gen_monomial_sp(A->exps, var, bits, ctx->minfo);
29     else
30         mpoly_gen_monomial_offset_mp(A->exps, var, bits, ctx->minfo);
31 
32     _fmpz_mpoly_set_length(A, WORD(1), ctx);
33 }
34