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

◆ sort()

void res2_poly::sort ( res2term *& f) const
private

Definition at line 342 of file res-a0-poly.cpp.

343{
344 // Divide f into two lists of equal length, sort each,
345 // then add them together. This allows the same monomial
346 // to appear more than once in 'f'.
347
348 if (f == nullptr || f->next == nullptr) return;
349 res2term *f1 = nullptr;
350 res2term *f2 = nullptr;
351 while (f != nullptr)
352 {
353 res2term *t = f;
354 f = f->next;
355 t->next = f1;
356 f1 = t;
357
358 if (f == nullptr) break;
359 t = f;
360 f = f->next;
361 t->next = f2;
362 f2 = t;
363 }
364
365 sort(f1);
366 sort(f2);
367 add_to(f1, f2);
368 f = f1;
369}
void sort(res2term *&f) const
void add_to(res2term *&f, res2term *&g) const
res2term * next

References add_to(), res2term::next, and sort().

Referenced by from_vector(), and sort().