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

◆ division_algorithm() [1/2]

Nterm * PolyRing::division_algorithm ( Nterm * f,
Nterm * g ) const
protected

Definition at line 1517 of file poly.cpp.

1518{
1519 // This does standard division by one polynomial, returning the remainder.
1520 // However, it does work for Weyl algebra, skew commutative algebra,
1521 // as long as the coefficient ring is a field.
1522 ring_elem a = copy(f);
1523 Nterm *t = a;
1524 Nterm *b = g;
1525 Nterm remhead;
1526 Nterm *remt = &remhead;
1527 ring_elem c;
1528 monomial m = M_->make_one();
1529 while (t != nullptr)
1530 if (M_->divides_partial_order(b->monom, t->monom))
1531 {
1532 a = t;
1533 bool cancelled = imp_attempt_to_cancel_lead_term(a, g, c, m);
1534 t = a;
1535 if (!cancelled)
1536 {
1537 remt->next = t;
1538 remt = remt->next;
1539 t = t->next;
1540 }
1541 }
1542 else
1543 {
1544 remt->next = t;
1545 remt = remt->next;
1546 t = t->next;
1547 }
1548
1549 remt->next = nullptr;
1550 return remhead.next;
1551}
virtual ring_elem copy(const ring_elem f) const
Definition poly.cpp:653
bool imp_attempt_to_cancel_lead_term(ring_elem &f, ring_elem g, ring_elem &coeff, monomial monom) const
Definition poly.cpp:1010
const Monoid * M_
Definition polyring.hpp:124
#define monomial
Definition gb-toric.cpp:11
Nterm * next
Definition ringelem.hpp:157
int monom[1]
Definition ringelem.hpp:160

References copy(), imp_attempt_to_cancel_lead_term(), PolynomialRing::M_, Nterm::monom, monomial, and Nterm::next.