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_neg(fmpz_mpoly_t A,const fmpz_mpoly_t B,const fmpz_mpoly_ctx_t ctx)15 void fmpz_mpoly_neg(fmpz_mpoly_t A, const fmpz_mpoly_t B,
16                                                     const fmpz_mpoly_ctx_t ctx)
17 {
18     slong N;
19 
20     if (A != B)
21     {
22         N = mpoly_words_per_exp(B->bits, ctx->minfo);
23         fmpz_mpoly_fit_length(A, B->length, ctx);
24         fmpz_mpoly_fit_bits(A, B->bits, ctx);
25         A->bits = B->bits;
26         mpn_copyi(A->exps, B->exps, N*B->length);
27     }
28     _fmpz_vec_neg(A->coeffs, B->coeffs, B->length);
29     _fmpz_mpoly_set_length(A, B->length, ctx);
30 }
31