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
14
mpoly_monomials_deflate(ulong * Aexps,flint_bitcnt_t Abits,const ulong * Bexps,flint_bitcnt_t Bbits,slong Blength,const fmpz * shift,const fmpz * stride,const mpoly_ctx_t mctx)15 void mpoly_monomials_deflate(ulong * Aexps, flint_bitcnt_t Abits,
16 const ulong * Bexps, flint_bitcnt_t Bbits, slong Blength,
17 const fmpz * shift, const fmpz * stride, const mpoly_ctx_t mctx)
18 {
19 slong i, j;
20 slong NA, NB;
21 slong nvars = mctx->nvars;
22 fmpz * exps;
23 TMP_INIT;
24
25 TMP_START;
26 exps = (fmpz *) TMP_ALLOC(nvars*sizeof(fmpz));
27 for (j = 0; j < nvars; j++)
28 fmpz_init(exps + j);
29
30 NA = mpoly_words_per_exp(Abits, mctx);
31 NB = mpoly_words_per_exp(Bbits, mctx);
32
33 for (i = 0; i < Blength; i++)
34 {
35 mpoly_get_monomial_ffmpz(exps, Bexps + NB*i, Bbits, mctx);
36 for (j = 0; j < nvars; j++)
37 {
38 fmpz_sub(exps + j, exps + j, shift + j);
39 /* stride + j is allowed to be zero */
40 if (!fmpz_is_zero(exps + j))
41 {
42 FLINT_ASSERT(fmpz_divisible(exps + j, stride + j));
43 fmpz_divexact(exps + j, exps + j, stride + j);
44 }
45 }
46 FLINT_ASSERT(Abits >= mpoly_exp_bits_required_ffmpz(exps, mctx));
47 mpoly_set_monomial_ffmpz(Aexps + NA*i, exps, Abits, mctx);
48 }
49
50 for (j = 0; j < nvars; j++)
51 fmpz_clear(exps + j);
52
53 TMP_END;
54 }
55
56