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

◆ sort()

void res_poly::sort ( resterm *& f) const
private

Definition at line 324 of file res-a1-poly.cpp.

325{
326 // Divide f into two lists of equal length, sort each,
327 // then add them together. This allows the same monomial
328 // to appear more than once in 'f'.
329
330 if (f == nullptr || f->next == nullptr) return;
331 resterm *f1 = nullptr;
332 resterm *f2 = nullptr;
333 while (f != nullptr)
334 {
335 resterm *t = f;
336 f = f->next;
337 t->next = f1;
338 f1 = t;
339
340 if (f == nullptr) break;
341 t = f;
342 f = f->next;
343 t->next = f2;
344 f2 = t;
345 }
346
347 sort(f1);
348 sort(f2);
349 add_to(f1, f2);
350 f = f1;
351}
void sort(resterm *&f) const
void add_to(resterm *&f, resterm *&g) const
resterm * next

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

Referenced by from_vector(), and sort().