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

◆ extract_divisible_by_x()

Nterm * extract_divisible_by_x ( Nterm *& ff,
int i )

Definition at line 191 of file NAG.cpp.

192{
193 /* Extracts into fx the terms divisible by the (n-1-i)-th variable "x"
194 and divides them by x. (exponent vectors are assumed to be reversed)
195 Note: terms in fx may not be in monomial order. */
196 Nterm* fx = nullptr;
197 Nterm* f = ff;
198 Nterm* prev_f = nullptr;
199 while (f != nullptr)
200 {
201 if (f->monom[i] == 0)
202 {
203 prev_f = f;
204 f = f->next;
205 }
206 else
207 {
208 f->monom[i]--; // divide by x
209 if (prev_f != nullptr)
210 {
211 prev_f->next = f->next; // extract
212 }
213 else
214 {
215 ff = f->next; // ... or cut
216 }
217 f->next = fx; // prepend to fx
218 fx = f;
219 f = (prev_f == nullptr) ? ff : prev_f->next;
220 }
221 }
222 return fx;
223}
Nterm * next
Definition ringelem.hpp:157
int monom[1]
Definition ringelem.hpp:160
Singly linked-list node carrying one term of a polynomial-ring element.
Definition ringelem.hpp:156

References Nterm::monom, and Nterm::next.

Referenced by SLP< Field >::poly_to_horner_slp().