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

◆ sort()

void PolyRing::sort ( Nterm *& f) const

Definition at line 2077 of file poly.cpp.

2078{
2079 // Divide f into two lists of equal length, sort each,
2080 // then add them together. This allows the same monomial
2081 // to appear more than once in 'f'.
2082
2083 if (f == nullptr || f->next == nullptr) return;
2084 Nterm *f1 = nullptr;
2085 Nterm *f2 = nullptr;
2086 while (f != nullptr)
2087 {
2088 Nterm *t = f;
2089 f = f->next;
2090 t->next = f1;
2091 f1 = t;
2092
2093 if (f == nullptr) break;
2094 t = f;
2095 f = f->next;
2096 t->next = f2;
2097 f2 = t;
2098 }
2099
2100 sort(f1);
2101 sort(f2);
2102 ring_elem g = f1;
2103 ring_elem h = f2;
2104 add_to(g, h);
2105 f = g;
2106}
void sort(Nterm *&f) const
Definition poly.cpp:2077
void add_to(ring_elem &f, const ring_elem &g) const
Definition ring.cpp:205
Nterm * next
Definition ringelem.hpp:157

References Ring::add_to(), Nterm::next, and sort().

Referenced by divide_by_expvector(), homogenize(), SchurRing::mult_by_term(), and sort().