1 /*
2     Copyright (C) 2018 Daniel Schultz
3 
4     This file is part of FLINT.
5 
6     FLINT is free software: you can redistribute it and/or modify it under
7     the terms of the GNU Lesser General Public License (LGPL) as published
8     by the Free Software Foundation; either version 2.1 of the License, or
9     (at your option) any later version.  See <http://www.gnu.org/licenses/>.
10 */
11 
12 #include "fmpz_mpoly.h"
13 
fmpz_mpoly_get_coeff_fmpz_monomial(fmpz_t c,const fmpz_mpoly_t A,const fmpz_mpoly_t M,const fmpz_mpoly_ctx_t ctx)14 void fmpz_mpoly_get_coeff_fmpz_monomial(fmpz_t c, const fmpz_mpoly_t A,
15                          const fmpz_mpoly_t M, const fmpz_mpoly_ctx_t ctx)
16 {
17     slong index;
18 
19     if (M->length != WORD(1))
20     {
21         flint_throw(FLINT_ERROR, "M not monomial in fmpz_mpoly_get_coeff_fmpz_monomial");
22     }
23 
24     index = mpoly_monomial_index_monomial(A->exps, A->bits, A->length,
25                                                  M->exps, M->bits, ctx->minfo);
26     if (index < 0)
27     {
28         fmpz_zero(c);
29     }
30     else
31     {
32         FLINT_ASSERT(index < A->length);
33         fmpz_set(c, A->coeffs + index);
34     }
35 }
36