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

◆ find_divisors()

int MonomialTable::find_divisors ( int max,
exponents_t exp,
int comp,
VECTOR(mon_term *) * result = nullptr )

Definition at line 152 of file montable.cpp.

156{
157 assert(comp >= 1);
158 assert(max != 0);
159 if (comp >= static_cast<int>(_head.size())) return 0;
160 if (max == 1 && comp == _last_match_comp && _last_match != nullptr &&
162 {
163 if (result != nullptr) result->push_back(_last_match);
164 return 1;
165 }
166 mon_term *head = _head[comp];
167 int nmatches = 0;
168 unsigned long expmask = ~exponents::mask(_nvars, exp);
169 //*DEBUG*/ long nviewed = 0;
170 //*DEBUG*/ long nmasked = 0;
171 for (mon_term *t = head->_next, *tnext = t->_next; t != head;
172 t = tnext, tnext = t->_next)
173 if ((expmask & t->_mask) == 0)
174 {
175 //*DEBUG*/ nviewed++;
176 if (exponents::divides(_nvars, t->_lead, exp))
177 {
178 nmatches++; // this doesn't happen very often
179 _last_match = t;
180 _last_match_comp = comp;
181 // move_up(t,head);
182 if (result != nullptr) result->push_back(t);
183 if (max >= 0 && nmatches >= max) break;
184 }
185 }
186 //*DEBUG*/ else
187 //*DEBUG*/ nmasked++;
188 //*DEBUG*/ fprintf(stderr, "nviewed %d nmasked %ld max %d nfound %ld\n",
189 // nviewed, nmasked, max, nmatches);
190 return nmatches;
191}
static bool divides(int nvars, ConstExponents a, ConstExponents b)
mon_term * _last_match
Definition montable.hpp:156
VALGRIND_MAKE_MEM_DEFINED & result(result)
#define max(a, b)
Definition polyroots.cpp:52
Doubly-linked-list node of a MonomialTable's per-component monomial list.
Definition montable.hpp:109

References _last_match, _last_match_comp, MonomialTable::mon_term::_next, _nvars, ExponentVector< int, true >::divides(), max, and result().

Referenced by ReducedGB_Field_Local::find_good_divisor(), and gbA::minimalize_pairs_non_ZZ().