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 "mpoly.h"
13 
14 
mpoly_monomials_shift_right_ui(ulong * Aexps,flint_bitcnt_t Abits,slong Alength,const ulong * user_exps,const mpoly_ctx_t mctx)15 void mpoly_monomials_shift_right_ui(ulong * Aexps, flint_bitcnt_t Abits,
16                 slong Alength, const ulong * user_exps, const mpoly_ctx_t mctx)
17 {
18     slong i;
19     slong N = mpoly_words_per_exp(Abits, mctx);
20     ulong * texps;
21     TMP_INIT;
22 
23     TMP_START;
24 
25     texps = (ulong *) TMP_ALLOC(N*sizeof(ulong));
26 
27     mpoly_set_monomial_ui(texps, user_exps, Abits, mctx);
28 
29     if (Abits <= FLINT_BITS)
30     {
31 #if WANT_ASSERT
32         ulong mask = mpoly_overflow_mask_sp(Abits);
33 #endif
34         for (i = 0; i < Alength; i++)
35         {
36             mpoly_monomial_sub(Aexps + N*i, Aexps + N*i, texps, N);
37             FLINT_ASSERT(!mpoly_monomial_overflows(Aexps + N*i, N, mask));
38         }
39     }
40     else
41     {
42         for (i = 0; i < Alength; i++)
43         {
44             mpoly_monomial_sub_mp(Aexps + N*i, Aexps + N*i, texps, N);
45             FLINT_ASSERT(!mpoly_monomial_overflows_mp(Aexps + N*i, N, Abits));
46         }
47     }
48 
49     TMP_END;
50 }
51 
52