tail reduction for SBA
| 1740 | |
| 1741 | // tail reduction for SBA |
| 1742 | poly redtailSba (LObject* L, int pos, kStrategy strat, BOOLEAN withT, BOOLEAN normalize) |
| 1743 | { |
| 1744 | strat->redTailChange=FALSE; |
| 1745 | if (strat->noTailReduction) return L->GetLmCurrRing(); |
| 1746 | poly h, p; |
| 1747 | p = h = L->GetLmTailRing(); |
| 1748 | if ((h==NULL) || (pNext(h)==NULL)) |
| 1749 | return L->GetLmCurrRing(); |
| 1750 | |
| 1751 | TObject* With; |
| 1752 | // placeholder in case strat->tl < 0 |
| 1753 | TObject With_s(strat->tailRing); |
| 1754 | |
| 1755 | LObject Ln(pNext(h), strat->tailRing); |
| 1756 | Ln.sig = L->sig; |
| 1757 | Ln.sevSig = L->sevSig; |
| 1758 | Ln.pLength = L->GetpLength() - 1; |
| 1759 | |
| 1760 | pNext(h) = NULL; |
| 1761 | if (L->p != NULL) pNext(L->p) = NULL; |
| 1762 | L->pLength = 1; |
| 1763 | |
| 1764 | Ln.PrepareRed(strat->use_buckets); |
| 1765 | |
| 1766 | int cnt=REDTAIL_CANONICALIZE; |
| 1767 | while(!Ln.IsNull()) |
| 1768 | { |
| 1769 | loop |
| 1770 | { |
| 1771 | if(rField_is_Ring(currRing) && strat->sigdrop) |
| 1772 | break; |
| 1773 | Ln.SetShortExpVector(); |
| 1774 | if (withT) |
| 1775 | { |
| 1776 | int j; |
| 1777 | j = kFindDivisibleByInT(strat, &Ln); |
| 1778 | if (j < 0) break; |
| 1779 | With = &(strat->T[j]); |
| 1780 | } |
| 1781 | else |
| 1782 | { |
| 1783 | With = kFindDivisibleByInS_T(strat, pos, &Ln, &With_s); |
| 1784 | if (With == NULL) break; |
| 1785 | } |
| 1786 | cnt--; |
| 1787 | if (cnt==0) |
| 1788 | { |
| 1789 | cnt=REDTAIL_CANONICALIZE; |
| 1790 | /*poly tmp=*/Ln.CanonicalizeP(); |
| 1791 | if (normalize && !rField_is_Ring(currRing)) |
| 1792 | { |
| 1793 | Ln.Normalize(); |
| 1794 | //pNormalize(tmp); |
| 1795 | //if (TEST_OPT_PROT) { PrintS("n"); mflush(); } |
| 1796 | } |
| 1797 | } |
| 1798 | if (normalize && (!TEST_OPT_INTSTRATEGY) && !rField_is_Ring(currRing) && (!nIsOne(pGetCoeff(With->p)))) |
| 1799 | { |
no test coverage detected