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

◆ find_monomial_divisors()

int MonomialTableZZ::find_monomial_divisors ( int max,
exponents_t exp,
int comp,
VECTOR(mon_term *) * result = nullptr ) const

Definition at line 281 of file montableZZ.cpp.

285{
286 assert(comp >= 1);
287 if (comp >= static_cast<int>(_head.size())) return 0;
288 mon_term *head = _head[comp];
289 mon_term *t;
290
291 int nmatches = 0;
292 unsigned long expmask = ~(monomial_mask(_nvars, exp));
293
294 for (t = head->_next; t != head; t = t->_next)
295 if ((expmask & t->_mask) == 0)
296 {
297 bool is_div = 1;
298 for (int i = 0; i < _nvars; i++)
299 if (exp[i] < t->_lead[i])
300 {
301 is_div = 0;
302 break;
303 }
304 if (is_div)
305 {
306 nmatches++;
307 if (result != nullptr) result->push_back(t);
308 if (max >= 0 && nmatches >= max) break;
309 }
310 }
311
312 if (M2_gbTrace == 15 && nmatches >= 2)
313 {
314 buffer o;
315 o << "find_monomial_divisors called on ";
316 show_mon_term(o, nullptr, exp, comp);
317 o << " #matches=" << nmatches << newline;
318 if (result != nullptr)
319 for (int i = 0; i < result->size(); i++) show_mon_term(o, (*result)[i]);
320 o << newline;
321 }
322 return nmatches;
323}
void show_mon_term(FILE *fil, mon_term *t) const
VALGRIND_MAKE_MEM_DEFINED & result(result)
char newline[]
Definition m2-types.cpp:49
int M2_gbTrace
Definition m2-types.cpp:52
static unsigned long monomial_mask(int nvars, exponents_t exp)
#define max(a, b)
Definition polyroots.cpp:52
MonomialTable::mon_term plus an _coeff slot pointing at the entry's leading ZZ coefficient (or nullpt...

References MonomialTableZZ::mon_term::_lead, MonomialTableZZ::mon_term::_mask, MonomialTableZZ::mon_term::_next, _nvars, M2_gbTrace, max, monomial_mask(), newline, result(), and show_mon_term().