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

◆ find_term_divisors()

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

Definition at line 145 of file montableZZ.cpp.

154{
155 assert(comp >= 1);
156 if (comp >= static_cast<int>(_head.size())) return 0;
157 mon_term *head = _head[comp];
158 mon_term *t;
159
160 int nmatches = 0;
161 unsigned long expmask = ~(monomial_mask(_nvars, exp));
162
163 for (t = head->_next; t != head; t = t->_next)
164 if ((expmask & t->_mask) == 0)
165 {
166 bool is_div = 1;
167 for (int i = 0; i < _nvars; i++)
168 if (exp[i] < t->_lead[i])
169 {
170 is_div = 0;
171 break;
172 }
173 if (is_div && mpz_divisible_p(coeff, t->_coeff))
174 {
175 nmatches++;
176 if (result != nullptr) result->push_back(t);
177 if (max >= 0 && nmatches >= max) break;
178 }
179 }
180 if (M2_gbTrace == 15 && nmatches >= 2)
181 {
182 buffer o;
183 o << "find_term_divisors called on ";
184 show_mon_term(o, coeff, exp, comp);
185 o << " #matches=" << nmatches << newline;
186 if (result != nullptr)
187 for (int i = 0; i < result->size(); i++) show_mon_term(o, (*result)[i]);
188 o << newline;
189 }
190 return nmatches;
191}
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::_coeff, MonomialTableZZ::mon_term::_lead, MonomialTableZZ::mon_term::_mask, MonomialTableZZ::mon_term::_next, _nvars, M2_gbTrace, max, monomial_mask(), newline, result(), and show_mon_term().

Referenced by is_strong_member().