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

◆ is_weak_member()

bool MonomialTableZZ::is_weak_member ( mpz_srcptr c,
exponents_t exp,
int comp ) const

Definition at line 193 of file montableZZ.cpp.

196{
197 // Loop through the elements of component 'comp'
198 // If that exponent vector is <= 'exp', then set g (eventual gcd) (if not
199 // set).
200 // else mpz(g,g,...);
201 // if mpz_divisible_p(c,g): return true
202 // At the end, return false
203
204 assert(comp >= 1);
205 if (comp >= static_cast<int>(_head.size())) return 0;
206 mon_term *head = _head[comp];
207 mon_term *t;
208 int i;
209
210 unsigned long expmask = ~(monomial_mask(_nvars, exp));
211 mpz_t g;
212 bool g_is_set = false;
213 for (t = head->_next; t != head; t = t->_next)
214 if ((expmask & t->_mask) == 0)
215 {
216 bool is_div = true;
217 for (i = 0; i < _nvars; i++)
218 if (exp[i] < t->_lead[i])
219 {
220 is_div = false;
221 break;
222 }
223 if (!is_div) continue;
224 if (!g_is_set)
225 {
226 mpz_init_set(g, t->_coeff);
227 g_is_set = true;
228 }
229 else
230 mpz_gcd(g, g, t->_coeff);
231 /* g is set */
232 if (mpz_divisible_p(c, g))
233 {
234 mpz_clear(g);
235 return true;
236 }
237 }
238 if (g_is_set) mpz_clear(g);
239 return false;
240}
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, and monomial_mask().