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

◆ remove_lead_term()

Nterm * polyheap::remove_lead_term ( )
inline

Definition at line 112 of file geopoly.hpp.

113{
114 int lead_so_far = -1;
115 for (int i = 0; i <= top_of_heap; i++)
116 {
117 if (heap[i] == NULL) continue;
118 if (lead_so_far < 0)
119 {
120 lead_so_far = i;
121 continue;
122 }
123 int cmp = EQ; // F->compare(heap[lead_so_far], heap[i]);
124 if (cmp == GT) continue;
125 if (cmp == LT)
126 {
127 lead_so_far = i;
128 continue;
129 }
130 // At this point we have equality
131 K->add_to(heap[lead_so_far]->coeff, heap[i]->coeff);
132 Nterm *tmp = heap[i];
133 heap[i] = tmp->next;
134 tmp->next = NULL;
135 F->remove(reinterpret_cast<ring_elem &>(tmp));
136
137 if (K->is_zero(heap[lead_so_far]->coeff))
138 {
139 // Remove, and start over
140 tmp = heap[lead_so_far];
141 heap[lead_so_far] = tmp->next;
142 tmp->next = NULL;
143 F->remove(reinterpret_cast<ring_elem &>(tmp));
144 lead_so_far = -1;
145 i = -1;
146 }
147 }
148 if (lead_so_far < 0) return NULL;
149 Nterm *result = heap[lead_so_far];
150 heap[lead_so_far] = result->next;
151 result->next = NULL;
152 return result;
153}
const PolynomialRing * F
Definition geopoly.hpp:49
Nterm * heap[GEOHEAP_SIZE]
Definition geopoly.hpp:51
int top_of_heap
Definition geopoly.hpp:52
const Ring * K
Definition geopoly.hpp:50
VALGRIND_MAKE_MEM_DEFINED & result(result)
Nterm * next
Definition ringelem.hpp:157
const int EQ
Definition style.hpp:40
const int GT
Definition style.hpp:41
const int LT
Definition style.hpp:39

References EQ, F, GT, heap, K, LT, Nterm::next, result(), and top_of_heap.