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

◆ make_minimal()

MonomialTable * MonomialTable::make_minimal ( int nvars,
const VECTOR(exponents_t) & exps,
const VECTOR(int) & comps,
const VECTOR(int) & vals,
VECTOR(int) & rejects )
staticprivate

Definition at line 367 of file montable.cpp.

372{
374
375 VECTOR(int) positions;
376 positions.reserve(exps.size());
377 for (unsigned int i = 0; i < exps.size(); i++) positions.push_back(i);
378
379 /* The following sorts in ascending lex order, considering the component and
380 the
381 inhomogeneous part of the exponent vector */
382 std::stable_sort(
383 positions.begin(), positions.end(), sorter(nvars, exps, comps));
384
385 T = MonomialTable::make(nvars);
386
387 VECTOR(int)::iterator first, end, last_minimal;
388 first = positions.begin();
389 end = positions.end();
390 last_minimal = first;
391 while (first != end)
392 {
393 VECTOR(int)::iterator next = first + 1;
394 exponents_t this_exp = exps[*first];
395 int comp = comps[*first];
396 while (next != end)
397 {
398 if (!exponents_equal(nvars, this_exp, exps[*next])) break;
399 if (comp != comps[*next]) break;
400 rejects.push_back(*next);
401 next++;
402 }
403 if (T->find_divisor(this_exp, comp) == -1)
404 {
405 /* We have a minimal element */
406
407 T->insert(this_exp, comp, vals[*first]);
408 *last_minimal++ = *first;
409 }
410 else
411 rejects.push_back(*first);
412
413 first = next;
414 /* At this point: [first,next) is the range of equal monomials */
415 }
416 return T;
417}
exponents::Exponents exponents_t
static MonomialTable * make(int nvars)
Definition montable.cpp:61
static bool exponents_equal(int nvars, exponents_t a, exponents_t b)
#define VECTOR(T)
Definition newdelete.hpp:78
TermIterator< Nterm > end(Nterm *)
Definition ringelem.cpp:5
#define T
Definition table.c:13

References end(), exponents_equal(), make(), MonomialTable(), T, and VECTOR.