1556{
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597 ring_elem a =
copy(f);
1598 Nterm *t = a;
1599 Nterm *b = g;
1600
1601 if (!
M_->weight_value_exists())
1602 {
1603 throw exc::engine_error("no method for division in this ring");
1604 }
1605
1606 Nterm divhead;
1607 Nterm remhead;
1608 Nterm *divt = &divhead;
1609 Nterm *remt = &remhead;
1611 long gval = 0, flast = 0;
1612
1613 if (t != nullptr)
1614 {
1615 Nterm *z = t;
1616 for (; z->
next !=
nullptr; z = z->
next)
1617 ;
1618
1619 flast =
M_->first_weight_value(z->
monom);
1620 }
1621
1622 if (b != nullptr)
1623 {
1624 long gfirst, glast;
1625 Nterm *z = b;
1626
1627 if (z->
next ==
nullptr)
1628 gval = 0;
1629 else
1630 {
1631 gfirst =
M_->first_weight_value(z->
monom);
1632 long gsecond =
M_->first_weight_value(z->
next->
monom);
1633 if (gfirst == gsecond)
1634 {
1635
1636 throw exc::internal_error("division algorithm for this element is not implemented");
1637 }
1638 for (; z->
next !=
nullptr; z = z->
next)
1639 ;
1640 glast =
M_->first_weight_value(z->
monom);
1641 gval = gfirst - glast;
1642 }
1643 }
1644
1645
1646 while (t != nullptr)
1647 {
1648 long ffirst;
1649
1650 ffirst =
M_->first_weight_value(t->
monom);
1651 long fval = ffirst - flast;
1652
1653
1654
1656
1657 {
1658
1659 a = t;
1662 t = a;
1663
1664
1665
1666
1667
1668
1669 if (!
K_->is_zero(nextterm->
coeff))
1670 {
1671 divt->
next = nextterm;
1674 }
1675 if (!cancelled)
1676 {
1680 }
1681 }
1682 else
1683 {
1687 }
1688 }
1689
1690 nextterm = nullptr;
1691 remt->
next =
nullptr;
1692 divt->
next =
nullptr;
1693 quot = divhead.
next;
1694 return remhead.
next;
1695}
virtual ring_elem copy(const ring_elem f) const
bool imp_attempt_to_cancel_lead_term(ring_elem &f, ring_elem g, ring_elem &coeff, monomial monom) const