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

◆ minimalize()

void MonomialTable::minimalize ( int nvars,
const VECTOR(exponents_t) & exps,
const VECTOR(int) & comps,
bool keep_duplicates,
VECTOR(int) & result_positions )
staticprivate

Definition at line 297 of file montable.cpp.

302{
303 /* Step 1: Sort an intarray into ascending order.
304 In this order, if e divides f, then e should appear
305 before f. Don't actually change 'exp'. Need a special compare routine. */
306
307 /* Step 2: Make a monomial table. */
308
309 /* Step 3: Loop through each element in the intarray. If the exponent is not
310 in the
311 monomial ideal, put that index into the result, and insert into the
312 monomial ideal.
313 If it is in the monomial ideal, go on. */
314
315 /* Step alternate3: If ALL minimal elements are to be taken. (e.g. if [1,1,0]
316 is
317 minimal, but occurs more than once, then keep all occurrences of [1,1,0].
318 */
319
320 /* Step 4: Remove the monomial table. Note that the exp vectors should not
321 be recreated. */
322
324
325 VECTOR(int) positions;
326 positions.reserve(exps.size());
327 for (unsigned int i = 0; i < exps.size(); i++) positions.push_back(i);
328
329 /* The following sorts in ascending lex order, considering the component and
330 the
331 inhomogeneous part of the exponent vector */
332 std::stable_sort(
333 positions.begin(), positions.end(), sorter(nvars, exps, comps));
334
335 T = MonomialTable::make(nvars);
336
337 VECTOR(int)::iterator first, end;
338 first = positions.begin();
339 end = positions.end();
340 while (first != end)
341 {
342 VECTOR(int)::iterator next = first + 1;
343 exponents_t this_exp = exps[*first];
344 int comp = comps[*first];
345 while (next != end)
346 {
347 if (!exponents_equal(nvars, this_exp, exps[*next])) break;
348 if (comp != comps[*next]) break;
349 next++;
350 }
351 if (T->find_divisor(this_exp, comp) == -1)
352 {
353 /* We have a minimal element */
354
355 T->insert(this_exp, comp, *first);
356 result_positions.push_back(*first);
357 if (keep_duplicates)
358 while (++first != next) result_positions.push_back(*first);
359 }
360
361 first = next;
362 /* At this point: [first,next) is the range of equal monomials */
363 }
364 freemem(T);
365}
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)
void freemem(void *s)
Definition m2-mem.cpp:103
#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(), freemem(), make(), MonomialTable(), T, and VECTOR.