59{
60 mpz_t result_coeff;
61 mpz_t mn_half;
62 mpz_init(result_coeff);
63 mpz_init(mn_half);
64 Nterm *f = ff;
65 Nterm *g = gg;
66 Nterm head;
68
69 mpz_tdiv_q_2exp(mn_half, mn, 1);
70
73
74 while (1)
75 {
76 if (g == nullptr)
77 {
78
79 for (; f !=
nullptr; f = f->
next)
80 {
86 mpz_mod(result_coeff, result_coeff, mn);
87 if (mpz_cmp(result_coeff, mn_half) > 0)
88 {
89 mpz_sub(result_coeff, result_coeff, mn);
90 }
92 }
93 break;
94 }
95 if (f == nullptr)
96 {
97
98 for (; g !=
nullptr; g = g->
next)
99 {
105 mpz_mod(result_coeff, result_coeff, mn);
106 if (mpz_cmp(result_coeff, mn_half) > 0)
107 {
108 mpz_sub(result_coeff, result_coeff, mn);
109 }
111 }
112 break;
113 }
115 {
116 case -1:
124 break;
125 case 1:
133 break;
134 case 0:
135 Nterm *tmf = f;
136 Nterm *tmg = g;
141 um,
142 vn,
143 mn,
144 result_coeff);
151 break;
152 }
153 }
154
155 mpz_clear(result_coeff);
156 mpz_clear(mn_half);
159}
static void CRA0(mpz_srcptr a, mpz_srcptr b, mpz_srcptr um, mpz_srcptr vn, mpz_srcptr mn, mpz_t result)
int compare(int nslots, const_monomial m, const_monomial n) const
void copy(const_monomial m, monomial result) const
const Ring * getCoefficientRing() const
virtual const Monoid * getMonoid() const
virtual ring_elem from_int(mpz_srcptr n) const =0
VALGRIND_MAKE_MEM_DEFINED & result(result)
mpz_srcptr get_mpz() const