Macaulay2 Engine
Loading...
Searching...
No Matches

◆ find_smallest_coeff_divisor()

int MonomialTableZZ::find_smallest_coeff_divisor ( exponents_t exp,
int comp ) const

Definition at line 247 of file montableZZ.cpp.

248{
249 assert(comp >= 1);
250 if (comp >= static_cast<int>(_head.size())) return -1;
251 mon_term *head = _head[comp];
252 mon_term *t;
253
254 int smallest_val = -1;
255 mpz_srcptr smallest = nullptr;
256
257 unsigned long expmask = ~(monomial_mask(_nvars, exp));
258
259 for (t = head->_next; t != head; t = t->_next)
260 if ((expmask & t->_mask) == 0)
261 {
262 bool is_div = 1;
263 for (int i = 0; i < _nvars; i++)
264 if (exp[i] < t->_lead[i])
265 {
266 is_div = 0;
267 break;
268 }
269 if (is_div)
270 {
271 if (smallest_val < 0 || (mpz_cmpabs(smallest, t->_coeff) > 0))
272 {
273 smallest_val = t->_val;
274 smallest = t->_coeff;
275 }
276 }
277 }
278 return smallest_val;
279}
static unsigned long monomial_mask(int nvars, exponents_t exp)
MonomialTable::mon_term plus an _coeff slot pointing at the entry's leading ZZ coefficient (or nullpt...

References MonomialTableZZ::mon_term::_coeff, MonomialTableZZ::mon_term::_lead, MonomialTableZZ::mon_term::_mask, MonomialTableZZ::mon_term::_next, _nvars, MonomialTableZZ::mon_term::_val, and monomial_mask().