1 /*
2     Copyright (C) 2019 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 "fq_nmod_mpoly.h"
13 
_fq_nmod_mpoly_neg(fq_nmod_struct * Acoeff,ulong * Aexp,const fq_nmod_struct * Bcoeff,const ulong * Bexp,slong Blen,slong N,const fq_nmod_ctx_t fqctx)14 void _fq_nmod_mpoly_neg(fq_nmod_struct * Acoeff, ulong * Aexp,
15                   const fq_nmod_struct * Bcoeff, const ulong * Bexp, slong Blen,
16                                             slong N, const fq_nmod_ctx_t fqctx)
17 {
18     slong i;
19 
20     for (i = 0; i < Blen; i++)
21         fq_nmod_neg(Acoeff + i, Bcoeff + i, fqctx);
22 
23     if (Aexp != Bexp)
24     {
25         mpoly_copy_monomials(Aexp, Bexp, Blen, N);
26     }
27 }
28 
fq_nmod_mpoly_neg(fq_nmod_mpoly_t A,const fq_nmod_mpoly_t B,const fq_nmod_mpoly_ctx_t ctx)29 void fq_nmod_mpoly_neg(fq_nmod_mpoly_t A, const fq_nmod_mpoly_t B,
30                                                  const fq_nmod_mpoly_ctx_t ctx)
31 {
32     slong N;
33 
34     fq_nmod_mpoly_fit_length(A, B->length, ctx);
35     fq_nmod_mpoly_fit_bits(A, B->bits, ctx);
36     A->bits = B->bits;
37 
38     N = mpoly_words_per_exp(B->bits, ctx->minfo);
39     _fq_nmod_mpoly_neg(A->coeffs, A->exps, B->coeffs, B->exps, B->length,
40                                                                 N, ctx->fqctx);
41     _fq_nmod_mpoly_set_length(A, B->length, ctx);
42 }
43