1#define MOVE_UP_JUST_ONE
17 for (
int i = 0; i < nvars; i++)
18 if (a[i] != b[i])
return false;
25 for (
int i = 0; i < nvars; i++)
27 if (a[i] < b[i])
return false;
28 if (a[i] > b[i])
return true;
38 for (
int i = 0; i < nvars; i++) fprintf(fil,
"%d ", exp[i]);
70 result->_head.push_back(
nullptr);
78 for (
unsigned int i = 1; i < _head.size(); i++)
96 if (head->
_next == y)
return;
125#ifdef MOVE_UP_JUST_ONE
126#define MOVE_UP(t, head) move_up(t, head)
128#define MOVE_UP(t, head) (remove(t), insert_before(t, head->_next))
134 if (comp >=
static_cast<int>(_head.size()))
return -1;
141 if ((expmask & t->_mask) == 0)
159 if (comp >=
static_cast<int>(_head.size()))
return 0;
172 t = tnext, tnext = t->
_next)
173 if ((expmask & t->_mask) == 0)
183 if (
max >= 0 && nmatches >=
max)
break;
196 if (comp >=
static_cast<int>(_head.size()))
return nullptr;
203 for (t = head->
_next; t != head; t = t->
_next)
204 if (expmask == t->
_mask)
207 for (i = 0; i <
_nvars; i++)
208 if (exp[i] != t->
_lead[i])
227 for (
int i =
INTSIZE(_head); i <= comp; i++)
236 newterm->
_lead = exp;
248 for (t = head; t->
_next != head; t = t->
_next)
276 const VECTOR(
int) & comps0)
277 :
nvars(nvars0), exps(exps0), comps(comps0)
284 for (
int i = 0; i <
nvars; i++)
287 else if (xx[i] > yy[i])
289 if (comps[
x] < comps[y])
291 else if (comps[
x] > comps[y])
299 const VECTOR(
int) & comps,
300 bool keep_duplicates,
301 VECTOR(
int) & result_positions)
326 positions.reserve(exps.size());
327 for (
unsigned int i = 0; i < exps.size(); i++) positions.push_back(i);
333 positions.begin(), positions.end(),
sorter(nvars, exps, comps));
338 first = positions.begin();
339 end = positions.end();
342 VECTOR(
int)::iterator next = first + 1;
344 int comp = comps[*first];
348 if (comp != comps[*next])
break;
351 if (
T->find_divisor(this_exp, comp) == -1)
355 T->insert(this_exp, comp, *first);
356 result_positions.push_back(*first);
358 while (++first != next) result_positions.push_back(*first);
369 const VECTOR(
int) & comps,
376 positions.reserve(exps.size());
377 for (
unsigned int i = 0; i < exps.size(); i++) positions.push_back(i);
383 positions.begin(), positions.end(),
sorter(nvars, exps, comps));
387 VECTOR(
int)::iterator first,
end, last_minimal;
388 first = positions.begin();
389 end = positions.end();
390 last_minimal = first;
393 VECTOR(
int)::iterator next = first + 1;
395 int comp = comps[*first];
399 if (comp != comps[*next])
break;
400 rejects.push_back(*next);
403 if (
T->find_divisor(this_exp, comp) == -1)
407 T->insert(this_exp, comp, vals[*first]);
408 *last_minimal++ = *first;
411 rejects.push_back(*first);
424 "monomial table: %d vars, %d components, %d elements\n",
426 static_cast<int>(_head.size()),
428 for (
unsigned i = 1; i < _head.size(); i++)
430 head = this->_head[i];
431 if (head->
_next == head)
continue;
432 fprintf(fil,
" -- component %d --\n", i);
433 for (t = head->
_next; t != head; t = t->
_next)
436 fprintf(fil,
" (%d)\n", t->
_val);
ExponentVector< int, true > exponents
exponents::Exponents exponents_t
Dense exponent-vector template [e_0, ..., e_{nvars-1}] for monomial operations.
static bool divides(int nvars, ConstExponents a, ConstExponents b)
static HashExponent mask(int nvars, ConstExponents a)
mon_term * make_list_head()
static void insert_before(mon_term *const y, mon_term *const z)
void insert(exponents_t exp, int comp, int id)
static MonomialTable * make_minimal(int nvars, const VECTOR(exponents_t) &exps, const VECTOR(int) &comps, const VECTOR(int) &vals, VECTOR(int) &rejects)
static MonomialTable * make(int nvars)
int find_divisor(exponents_t exp, int comp)
static void move_up(mon_term *const y, mon_term *const head)
int find_divisors(int max, exponents_t exp, int comp, VECTOR(mon_term *) *result=nullptr)
static void minimalize(int nvars, const VECTOR(exponents_t) &exps, const VECTOR(int) &comps, bool keep_duplicates, VECTOR(int) &result_positions)
static void remove(mon_term *const y)
mon_term * find_exact(exponents_t exp, int comp) const
static bool exponents_equal(int nvars, exponents_t a, exponents_t b)
VALGRIND_MAKE_MEM_DEFINED & result(result)
static bool exponents_equal(int nvars, exponents_t a, exponents_t b)
static void exponents_show(FILE *fil, exponents_t exp, int nvars)
MonomialTable — leading-monomial divisor index used by the GB reducer.
static bool exponents_greater(int nvars, exponents_t a, exponents_t b)
TermIterator< Nterm > end(Nterm *)
Doubly-linked-list node of a MonomialTable's per-component monomial list.
bool operator()(int x, int y)
const VECTOR(exponents_t) &exps
sorter(int nvars0, const VECTOR(exponents_t) &exps0, const VECTOR(int) &comps0)