Changeset 83be980 in git for kernel/kstd2.cc


Ignore:
Timestamp:
Jul 2, 2012, 7:26:50 AM (12 years ago)
Author:
Christian Eder
Branches:
(u'spielwiese', '17f1d200f27c5bd38f5dfc6e8a0879242279d1d8')
Children:
1bc7d4ac8a4fd3280459ab78ca65bd4e60dd2c93
Parents:
cffd3e2f630fbc7b0e35afee97d6fa948cfd0b3e
git-author:
Christian Eder <ederc@mathematik.uni-kl.de>2012-07-02 07:26:50+02:00
git-committer:
Christian Eder <ederc@mathematik.uni-kl.de>2012-07-05 16:12:50+02:00
Message:
adds signature-based algorithm files from master, does not build right now:
fixes kstd1.cc for compilation
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/kstd2.cc

    rcffd3e r83be980  
    3434#define PLURAL_INTERNAL_DECLARATIONS 1
    3535#endif
     36
     37#define DEBUGF50  0
     38#define DEBUGF51  0
     39
     40#ifdef DEBUGF5
     41#undef DEBUGF5
     42//#define DEBUGF5 1
     43#endif
     44
     45#define F5C       1
     46#if F5C
     47  #define F5CTAILRED 0
     48#endif
     49
    3650#include <kernel/kutil.h>
    3751#include <misc/options.h>
     
    478492        h->Clear();
    479493        return -1;
     494      }
     495    }
     496  }
     497}
     498
     499/*2
     500*  reduction procedure for signature-based standard
     501*  basis algorithms:
     502*  all reductions have to be sig-safe!
     503*
     504*  2 is returned if and only if the pair is rejected by the rewritten criterion
     505*  at exactly this point of the computations. This is the last possible point
     506*  such a check can be done => checks with the biggest set of available
     507*  signatures
     508*/
     509int redSig (LObject* h,kStrategy strat)
     510{
     511  if (strat->tl<0) return 1;
     512  //if (h->GetLmTailRing()==NULL) return 0; // HS: SHOULD NOT BE NEEDED!
     513  //printf("FDEGS: %ld -- %ld\n",h->FDeg, h->pFDeg());
     514  assume(h->FDeg == h->pFDeg());
     515//#if 1
     516#ifdef DEBUGF5
     517  Print("------- IN REDSIG -------\n");
     518  Print("p: ");
     519  pWrite(pHead(h->p));
     520  Print("p1: ");
     521  pWrite(pHead(h->p1));
     522  Print("p2: ");
     523  pWrite(pHead(h->p2));
     524  Print("---------------------------\n");
     525#endif
     526  poly h_p;
     527  int i,j,at,pass, ii;
     528  int start=0;
     529  int sigSafe;
     530  unsigned long not_sev;
     531  long reddeg,d;
     532
     533  pass = j = 0;
     534  d = reddeg = h->GetpFDeg();
     535  h->SetShortExpVector();
     536  int li;
     537  h_p = h->GetLmTailRing();
     538  not_sev = ~ h->sev;
     539  loop
     540  {
     541    j = kFindDivisibleByInT(strat->T, strat->sevT, strat->tl, h, start);
     542    if (j < 0)
     543    {
     544      return 1;
     545    }
     546
     547    li = strat->T[j].pLength;
     548    ii = j;
     549    /*
     550     * the polynomial to reduce with (up to the moment) is;
     551     * pi with length li
     552     */
     553    i = j;
     554#if 1
     555    if (TEST_OPT_LENGTH)
     556    loop
     557    {
     558      /*- search the shortest possible with respect to length -*/
     559      i++;
     560      if (i > strat->tl)
     561        break;
     562      if (li<=1)
     563        break;
     564      if ((strat->T[i].pLength < li)
     565         &&
     566          p_LmShortDivisibleBy(strat->T[i].GetLmTailRing(), strat->sevT[i],
     567                               h_p, not_sev, strat->tailRing))
     568      {
     569        /*
     570         * the polynomial to reduce with is now;
     571         */
     572        li = strat->T[i].pLength;
     573        ii = i;
     574      }
     575    }
     576    start = ii+1;
     577#endif
     578
     579    /*
     580     * end of search: have to reduce with pi
     581     */
     582#ifdef KDEBUG
     583    if (TEST_OPT_DEBUG)
     584    {
     585      PrintS("red:");
     586      h->wrp();
     587      PrintS(" with ");
     588      strat->T[ii].wrp();
     589    }
     590#endif
     591    assume(strat->fromT == FALSE);
     592//#if 1
     593#ifdef DEBUGF5
     594    Print("BEFORE REDUCTION WITH %d:\n",ii);
     595    Print("--------------------------------\n");
     596    pWrite(h->sig);
     597    pWrite(strat->T[ii].sig);
     598    pWrite(h->GetLmCurrRing());
     599    pWrite(pHead(h->p1));
     600    pWrite(pHead(h->p2));
     601    pWrite(pHead(strat->T[ii].p));
     602    Print("--------------------------------\n");
     603    printf("INDEX OF REDUCER T: %d\n",ii);
     604#endif
     605    sigSafe = ksReducePolySig(h, &(strat->T[ii]), strat->S_2_R[ii], NULL, NULL, strat);
     606    // if reduction has taken place, i.e. the reduction was sig-safe
     607    // otherwise start is already at the next position and the loop
     608    // searching reducers in T goes on from index start
     609//#if 1
     610#ifdef DEBUGF5
     611    Print("SigSAFE: %d\n",sigSafe);
     612#endif
     613    if (sigSafe != 3)
     614    {
     615      // start the next search for reducers in T from the beginning
     616      start = 0;
     617#ifdef KDEBUG
     618      if (TEST_OPT_DEBUG)
     619      {
     620        PrintS("\nto ");
     621        h->wrp();
     622        PrintLn();
     623      }
     624#endif
     625
     626      h_p = h->GetLmTailRing();
     627      if (h_p == NULL)
     628      {
     629        if (h->lcm!=NULL) pLmFree(h->lcm);
     630#ifdef KDEBUG
     631        h->lcm=NULL;
     632#endif
     633        return 0;
     634      }
     635      h->SetShortExpVector();
     636      not_sev = ~ h->sev;
     637      /*
     638      * try to reduce the s-polynomial h
     639      *test first whether h should go to the lazyset L
     640      *-if the degree jumps
     641      *-if the number of pre-defined reductions jumps
     642      */
     643      pass++;
     644      if (!TEST_OPT_REDTHROUGH && (strat->Ll >= 0) && (pass > strat->LazyPass))
     645      {
     646        h->SetLmCurrRing();
     647        at = strat->posInL(strat->L,strat->Ll,h,strat);
     648        if (at <= strat->Ll)
     649        {
     650          int dummy=strat->sl;
     651          if (kFindDivisibleByInS(strat, &dummy, h) < 0)
     652          {
     653            return 1;
     654          }
     655          enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
     656#ifdef KDEBUG
     657          if (TEST_OPT_DEBUG)
     658            Print(" lazy: -> L%d\n",at);
     659#endif
     660          h->Clear();
     661          return -1;
     662        }
    480663      }
    481664    }
     
    12941477  idTest(strat->Shdl);
    12951478
     1479  return (strat->Shdl);
     1480}
     1481ideal ssgincschreyer (ideal F, ideal Q,intvec *w,intvec *hilb,kStrategy strat)
     1482{
     1483        int
     1484                time_interred = 0, time_prepare = 0, time_reduction_search = 0, time_reduction = 0,
     1485                time_add_r = 0, time_filter_b = 0, time_add_b1_testings = 0, time_add_b1_insertion = 0,
     1486                time_add_b2 = 0;
     1487
     1488        time_from_last_call();
     1489        int current_input_idx = 0;
     1490        while (F->m[current_input_idx] == NULL && current_input_idx < IDELEMS(F))
     1491        {
     1492                ++current_input_idx;
     1493        }
     1494        ideal I0 = idInit(1);
     1495        if (current_input_idx >= IDELEMS(F))
     1496        {
     1497                return I0;
     1498        }
     1499        I0->m[0] = pCopy(F->m[current_input_idx]);
     1500        int zero_reductions = 0;
     1501        LabeledPoly::GvwLess gvw_less;
     1502  poly pEins = pOne();
     1503        for (current_input_idx +=1; current_input_idx < IDELEMS(F); ++current_input_idx)
     1504        {
     1505                if (!F->m[current_input_idx]) continue;
     1506                idDelDiv(I0);
     1507                idSkipZeroes(I0);
     1508#ifndef SSG_NO_INTERRED
     1509                std::sort(I0->m, I0->m+IDELEMS(I0), LmCompareForNonZeroPolys());
     1510               
     1511                ideal I0_tail_reduced = idInit(IDELEMS(I0));
     1512                //tail reducton
     1513                for(int n0 = IDELEMS(I0) - 1; n0 > 0; --n0)
     1514                {
     1515                        poly p_old = NULL;
     1516                        std::swap(p_old,I0->m[n0]);
     1517                        poly p_new = kNF(I0, Q, p_old);
     1518                        pDelete(&p_old);
     1519                        I0_tail_reduced->m[n0] = p_new;
     1520                }
     1521                std::swap(I0_tail_reduced->m[0], I0->m[0]);
     1522                idDelete(&I0);
     1523                I0 = I0_tail_reduced;
     1524#endif
     1525                time_interred += time_from_last_call();
     1526                LPolysByGvw R;
     1527                LPolysMuledBySig B;
     1528    //LabeledPoly* p = LabeledPoly::CreateOneSig(F->m[current_input_idx]);
     1529    LabeledPoly* p = LabeledPoly::CreateOneSig(F->m[current_input_idx],
     1530    current_input_idx);
     1531                for(int n0 = IDELEMS(I0) - 1; n0 >=0; --n0)
     1532                {
     1533                        R.push_back(LabeledPoly::CreateZeroSig(I0->m[n0]));
     1534                }
     1535                const LPolysByGvw::iterator first_zero_sig = R.begin();
     1536    /*
     1537                for(int n0 = IDELEMS(I0) - 1; n0 >=0; --n0)
     1538                {
     1539      for (int m0 = n0-1; m0>=0; --m0)
     1540      {
     1541                          R.push_front(LabeledPoly::CreateZeroPoly(I0->m[n0], n0, I0->m[m0], m0));
     1542      }
     1543                }
     1544    */
     1545                for(int n0 = IDELEMS(I0) - 1; n0 >=0; --n0)
     1546                {
     1547      //R.push_front(LabeledPoly::CreateZeroPoly(I0->m[n0]));
     1548                        R.push_front(LabeledPoly::CreateZeroPoly(I0->m[n0],current_input_idx+1,F->m[current_input_idx]));
     1549                }
     1550                                /*
     1551        printf("\nR-init = \n");
     1552                                for(LPolysByGvw::iterator ir = R.begin(); ir != R.end(); ++ir)
     1553                                {
     1554                                        printf("p = ");pWrite((*ir)->p_);
     1555                                        printf("s = ");pWrite((*ir)->s_monom_);
     1556                                }
     1557        */
     1558    LabeledPolyMuled bnew;
     1559    bnew.Init();
     1560    bnew.FillBy(pEins, *p);
     1561    LPolysByGvw::iterator known_gvw_greater_p = first_zero_sig;
     1562    /*
     1563    const LPolysByGvw::iterator p_insert_pos =
     1564      R.insert(known_gvw_greater_p, p);
     1565    */
     1566    bool rejected = false;
     1567                SigMuledMinimumFinder b_min_finder(B);
     1568    /*
     1569    for(LPolysByGvw::const_iterator ir2 = R.begin();ir2 != p_insert_pos;++ir2)
     1570    {
     1571      if ((*ir2)->sig_divides(bnew))
     1572      {
     1573        rejected = true;
     1574        break;
     1575      }
     1576    }
     1577    */
     1578    if (!rejected)
     1579    {
     1580      B.push_back(bnew);
     1581      b_min_finder.UpdateBy(B.size() - 1);
     1582      bnew.Init();
     1583      //time_add_b1_insertion += time_from_last_call();
     1584    }
     1585    bnew.Release();
     1586                time_prepare += time_from_last_call();
     1587    // first test in B
     1588                        if (b_min_finder.minimum_idx_ == SigMuledMinimumFinder::NO_ELEMENTS)
     1589                        {
     1590                                break;
     1591                        }else{
     1592                                p = LabeledPoly::ConvertFromAndRelease(B[b_min_finder.minimum_idx_]);
     1593                                B.erase_and_move_from_back(b_min_finder.minimum_idx_);
     1594                        }
     1595                while(1)
     1596                {
     1597                        bool reduced_to_zero = false;
     1598                        LPolysByGvw::iterator known_gvw_greater_p = first_zero_sig;
     1599#if 1
     1600      /*
     1601                        if (n ==  IDELEMS(F) - 1)
     1602                        {
     1603      */
     1604        /*
     1605        printf("\nR = \n");
     1606                                for(LPolysByGvw::iterator ir = R.begin(); ir != R.end(); ++ir)
     1607                                {
     1608                                        printf("p = ");pWrite((*ir)->p_);
     1609                                        printf("s = ");pWrite((*ir)->s_monom_);
     1610                                }
     1611                                printf("B = \n");
     1612                                for(LPolysMuledBySig::iterator ib = B.begin(); ib != B.end(); ++ib)
     1613                                {
     1614                                        printf("smuled = ");pWrite((*ib).smuled_monom_);
     1615          //printf("s = ");pWrite((*ib)->not_muled_.s_monom_);
     1616                                }
     1617        */
     1618                        /*
     1619      }
     1620      */
     1621#endif
     1622                        while(1)
     1623                        {
     1624        //printf("p to reduce = ");pWrite (p->p_);
     1625                                bool was_reduced = false;
     1626                                LPolysByGvw::iterator ir = --R.end();
     1627                                while(1)
     1628                                {
     1629                                        was_reduced = p->can_reduce_by(*ir);
     1630                                        if (was_reduced)
     1631                                        {
     1632                                                time_reduction_search += time_from_last_call();
     1633                                                p->reduce_by(*ir);
     1634                                                time_reduction += time_from_last_call();
     1635                                                break;
     1636                                        }
     1637                                        if (ir == known_gvw_greater_p) break;
     1638                                        --ir;
     1639                                }
     1640                                if (!was_reduced && ir != R.begin())
     1641                                {
     1642                                        --ir;
     1643                                        while(1)
     1644                                        {
     1645                                                if (!gvw_less(p, *ir))
     1646                                                {
     1647                                                        ++ir;
     1648                                                        break;
     1649                                                }
     1650                                                was_reduced = p->can_reduce_by(*ir);
     1651                                                if (was_reduced)
     1652                                                {
     1653                                                        time_reduction_search += time_from_last_call();
     1654                                                        p->reduce_by(*ir);
     1655                                                        time_reduction += time_from_last_call();
     1656                                                        break;
     1657                                                }
     1658                                                if (ir == R.begin()) break;
     1659                                                --ir;
     1660                                        }
     1661                                        known_gvw_greater_p = ir;
     1662                                }
     1663                                if (!was_reduced) break;
     1664                                reduced_to_zero = p->p_ == NULL;
     1665                                if (reduced_to_zero)
     1666                                {
     1667                                        ++zero_reductions;
     1668                                        known_gvw_greater_p = R.begin();
     1669                                        break;
     1670                                }
     1671                        }
     1672                        time_reduction_search += time_from_last_call();
     1673                        const LPolysByGvw::iterator p_insert_pos =
     1674                                R.insert(known_gvw_greater_p, p);
     1675                        time_add_r += time_from_last_call();
     1676                        SigMuledMinimumFinder b_min_finder(B);
     1677                        for(int i=0;i<B.size();)
     1678                        {
     1679                                LabeledPolyMuled& b = B[i];
     1680                                if (p->sig_divides(b) && gvw_less(p,b.not_muled_))
     1681                                {
     1682                                        b.Release();
     1683                                        B.erase_and_move_from_back(i);
     1684                                }else
     1685                                {
     1686                                        b_min_finder.UpdateBy(i);
     1687                                        ++i;
     1688                                }
     1689                        }
     1690                        time_filter_b += time_from_last_call();
     1691                        if (!reduced_to_zero)
     1692                        {
     1693                                LabeledPolyMuled bnew;
     1694                                bnew.Init();
     1695                                for(LPolysByGvw::const_iterator ir = --R.end();ir != p_insert_pos;--ir)
     1696                                {
     1697                                        bnew.FillBy((*ir)->p_, *p);
     1698                                        bool rejected = false;
     1699                                        for(LPolysByGvw::const_iterator ir2 = R.begin();ir2 != p_insert_pos;++ir2)
     1700                                        {
     1701                                                if ((*ir2)->sig_divides(bnew))
     1702                                                {
     1703                                                        rejected = true;
     1704                                                        break;
     1705                                                }
     1706                                        }
     1707                                        time_add_b1_testings += time_from_last_call();
     1708                                        if (!rejected)
     1709                                        {
     1710                                                B.push_back(bnew);
     1711                                                b_min_finder.UpdateBy(B.size() - 1);
     1712                                                bnew.Init();
     1713                                                time_add_b1_insertion += time_from_last_call();
     1714                                        }
     1715                                }
     1716                                for(LPolysByGvw::const_iterator ir = R.begin();ir != p_insert_pos;++ir)
     1717                                {
     1718                                        if (!gvw_less(*ir, p)) break;
     1719                                        if ((*ir)->p_ == NULL) continue;
     1720                                        bool rejected = false;
     1721                                        bnew.FillBy(p->p_, *(*ir));
     1722                                        for(LPolysByGvw::const_iterator ir2 = R.begin();ir2 != ir;++ir2)
     1723                                        {
     1724                                                if ((*ir2)->sig_divides(bnew))
     1725                                                {
     1726                                                        rejected = true;
     1727                                                        break;
     1728                                                }
     1729                                        }
     1730                                        if (!rejected)
     1731                                        {
     1732                                                B.push_back(bnew);
     1733                                                b_min_finder.UpdateBy(B.size() - 1);
     1734                                                bnew.Init();
     1735                                        }
     1736                                }
     1737                                bnew.Release();
     1738                                time_add_b2 += time_from_last_call();
     1739                        }
     1740      /*
     1741                                printf("B = \n");
     1742                                for(LPolysMuledBySig::iterator ib = B.begin(); ib != B.end(); ++ib)
     1743                                {
     1744                                        printf("smuled = ");pWrite((*ib).smuled_monom_);
     1745          //printf("s = ");pWrite((*ib).not_muled_.s_monom_);
     1746                                }
     1747        */
     1748                        if (b_min_finder.minimum_idx_ == SigMuledMinimumFinder::NO_ELEMENTS)
     1749                        {
     1750                                break;
     1751                        }else{
     1752                                p = LabeledPoly::ConvertFromAndRelease(B[b_min_finder.minimum_idx_]);
     1753                                B.erase_and_move_from_back(b_min_finder.minimum_idx_);
     1754                        }
     1755                }
     1756                idDelete(&I0);
     1757                I0 = idInit(R.size());
     1758                int i0_idx = 0;
     1759                for(LPolysByGvw::iterator ir = R.begin();ir != R.end();++ir,++i0_idx)
     1760                {
     1761                        std::swap(I0->m[i0_idx], (*ir)->p_);
     1762                        delete (*ir);
     1763                       
     1764                }
     1765                R.clear();
     1766        }
     1767
     1768        printf("time time_interred = %d\n", time_interred);
     1769        printf("time time_prepare = %d\n", time_prepare);
     1770        printf("time time_reduction_search = %d\n", time_reduction_search);
     1771        printf("time time_reduction = %d\n", time_reduction);
     1772        printf("time time_add_r = %d\n", time_add_r);
     1773        printf("time time_filter_b = %d\n", time_filter_b);
     1774        printf("time time_add_b1_testings = %d\n", time_add_b1_testings);
     1775        printf("time time_add_b1_insertion = %d\n", time_add_b1_insertion);
     1776        printf("time time_add_b2 = %d\n", time_add_b2);
     1777
     1778        printf("ZERO REDUCTIONS: %d\n", zero_reductions);
     1779
     1780        return I0;
     1781}
     1782ideal ssgnoninc (ideal F, ideal Q,intvec *w,intvec *hilb,kStrategy strat)
     1783{
     1784  int
     1785    time_interred = 0, time_prepare = 0, time_reduction_search = 0, time_reduction = 0,
     1786                  time_add_r = 0, time_filter_b = 0, time_add_b1_testings = 0, time_add_b1_insertion = 0,
     1787                  time_add_b2 = 0;
     1788
     1789  time_from_last_call();
     1790  int current_input_idx = 0;
     1791  while (F->m[current_input_idx] == NULL && current_input_idx < IDELEMS(F))
     1792  {
     1793    ++current_input_idx;
     1794  }
     1795  ideal I0 = idInit(1);
     1796  if (current_input_idx >= IDELEMS(F))
     1797  {
     1798    return I0;
     1799  }
     1800  I0->m[0] = pCopy(F->m[current_input_idx]);
     1801  int zero_reductions = 0;
     1802  LabeledPoly::GvwLess gvw_less;
     1803  poly pEins = pOne();
     1804  // made these global for non-incremental computation
     1805  // -------------------------------------------------
     1806  LPolysByGvw R;
     1807  LPolysMuledBySig B;
     1808  SigMuledMinimumFinder b_min_finder(B);
     1809  LabeledPoly* p;
     1810  LPolysByGvw::iterator first_zero_sig_temp = R.begin();
     1811  bool set_first_zero_sig                   = true;
     1812  // -------------------------------------------------
     1813  for (current_input_idx +=1; current_input_idx < IDELEMS(F); ++current_input_idx)
     1814  {
     1815    if (!F->m[current_input_idx]) continue;
     1816    idDelDiv(I0);
     1817    idSkipZeroes(I0);
     1818#ifndef SSG_NO_INTERRED
     1819    std::sort(I0->m, I0->m+IDELEMS(I0), LmCompareForNonZeroPolys());
     1820
     1821    ideal I0_tail_reduced = idInit(IDELEMS(I0));
     1822    //tail reducton
     1823    for(int n0 = IDELEMS(I0) - 1; n0 > 0; --n0)
     1824    {
     1825      poly p_old = NULL;
     1826      std::swap(p_old,I0->m[n0]);
     1827      poly p_new = kNF(I0, Q, p_old);
     1828      pDelete(&p_old);
     1829      I0_tail_reduced->m[n0] = p_new;
     1830    }
     1831    std::swap(I0_tail_reduced->m[0], I0->m[0]);
     1832    idDelete(&I0);
     1833    I0 = I0_tail_reduced;
     1834#endif
     1835    time_interred += time_from_last_call();
     1836    //LPolysByGvw R;
     1837    //LPolysMuledBySig B;
     1838    //LabeledPoly* p = LabeledPoly::CreateOneSig(F->m[current_input_idx]);
     1839    p = LabeledPoly::CreateOneSig(F->m[current_input_idx],
     1840        current_input_idx);
     1841    for(int n0 = IDELEMS(I0) - 1; n0 >=0; --n0)
     1842    {
     1843      R.push_back(LabeledPoly::CreateZeroSig(I0->m[n0]));
     1844    }
     1845    //const LPolysByGvw::iterator first_zero_sig = R.begin();
     1846    if (set_first_zero_sig)
     1847    {
     1848      first_zero_sig_temp = R.begin();
     1849      set_first_zero_sig  = false;
     1850    }
     1851    /*
     1852       for(int n0 = IDELEMS(I0) - 1; n0 >=0; --n0)
     1853       {
     1854       for (int m0 = n0-1; m0>=0; --m0)
     1855       {
     1856       R.push_front(LabeledPoly::CreateZeroPoly(I0->m[n0], n0, I0->m[m0], m0));
     1857       }
     1858       }
     1859       */
     1860    for(int n0 = IDELEMS(I0) - 1; n0 >=0; --n0)
     1861    {
     1862      //R.push_front(LabeledPoly::CreateZeroPoly(I0->m[n0]));
     1863      R.push_front(LabeledPoly::CreateZeroPoly(I0->m[n0],current_input_idx+1,F->m[current_input_idx]));
     1864    }
     1865    /*
     1866       printf("\nR-init = \n");
     1867       for(LPolysByGvw::iterator ir = R.begin(); ir != R.end(); ++ir)
     1868       {
     1869       printf("p = ");pWrite((*ir)->p_);
     1870       printf("s = ");pWrite((*ir)->s_monom_);
     1871       }
     1872       */
     1873    LabeledPolyMuled bnew;
     1874    bnew.Init();
     1875    bnew.FillBy(pEins, *p);
     1876    LPolysByGvw::iterator known_gvw_greater_p = first_zero_sig_temp;
     1877    /*
     1878       const LPolysByGvw::iterator p_insert_pos =
     1879       R.insert(known_gvw_greater_p, p);
     1880       */
     1881    bool rejected = false;
     1882    //SigMuledMinimumFinder b_min_finder(B);
     1883    //SigMuledMinimumFinder b_min_finder(B);
     1884    /*
     1885       for(LPolysByGvw::const_iterator ir2 = R.begin();ir2 != p_insert_pos;++ir2)
     1886       {
     1887       if ((*ir2)->sig_divides(bnew))
     1888       {
     1889       rejected = true;
     1890       break;
     1891       }
     1892       }
     1893       */
     1894    if (!rejected)
     1895    {
     1896      B.push_back(bnew);
     1897      b_min_finder.UpdateBy(B.size() - 1);
     1898      bnew.Init();
     1899      //time_add_b1_insertion += time_from_last_call();
     1900    }
     1901    bnew.Release();
     1902  }
     1903  const LPolysByGvw::iterator first_zero_sig = first_zero_sig_temp;
     1904  //SigMuledMinimumFinder b_min_finder(B);
     1905  /*
     1906  printf("B = \n");
     1907  for(LPolysMuledBySig::iterator ib = B.begin(); ib != B.end(); ++ib)
     1908  {
     1909    printf("smuled = ");pWrite((*ib).smuled_monom_);
     1910    //printf("s = ");pWrite((ib)->not_muled_.s_monom_);
     1911  }
     1912  */
     1913  time_prepare += time_from_last_call();
     1914  // first test in B
     1915  if (b_min_finder.minimum_idx_ == SigMuledMinimumFinder::NO_ELEMENTS)
     1916  {
     1917    return I0;
     1918    //break;
     1919  }else{
     1920    p = LabeledPoly::ConvertFromAndRelease(B[b_min_finder.minimum_idx_]);
     1921    B.erase_and_move_from_back(b_min_finder.minimum_idx_);
     1922  }
     1923  while(1)
     1924  {
     1925    bool reduced_to_zero = false;
     1926    LPolysByGvw::iterator known_gvw_greater_p = first_zero_sig;
     1927#if 1
     1928    /*
     1929       if (n ==  IDELEMS(F) - 1)
     1930       {
     1931       */
     1932    /*
     1933       printf("\nR = \n");
     1934       for(LPolysByGvw::iterator ir = R.begin(); ir != R.end(); ++ir)
     1935       {
     1936       printf("p = ");pWrite((*ir)->p_);
     1937       printf("s = ");pWrite((*ir)->s_monom_);
     1938       }
     1939       printf("B = \n");
     1940       for(LPolysMuledBySig::iterator ib = B.begin(); ib != B.end(); ++ib)
     1941       {
     1942       printf("smuled = ");pWrite((*ib).smuled_monom_);
     1943    //printf("s = ");pWrite((*ib)->not_muled_.s_monom_);
     1944    }
     1945    */
     1946    /*
     1947       }
     1948       */
     1949#endif
     1950    while(1)
     1951    {
     1952      //printf("p to reduce = ");pWrite (p->p_);
     1953      bool was_reduced = false;
     1954      LPolysByGvw::iterator ir = --R.end();
     1955      while(1)
     1956      {
     1957        was_reduced = p->can_reduce_by(*ir);
     1958        if (was_reduced)
     1959        {
     1960          time_reduction_search += time_from_last_call();
     1961          p->reduce_by(*ir);
     1962          time_reduction += time_from_last_call();
     1963          break;
     1964        }
     1965        if (ir == known_gvw_greater_p) break;
     1966        --ir;
     1967      }
     1968      if (!was_reduced && ir != R.begin())
     1969      {
     1970        --ir;
     1971        while(1)
     1972        {
     1973          if (!gvw_less(p, *ir))
     1974          {
     1975            ++ir;
     1976            break;
     1977          }
     1978          was_reduced = p->can_reduce_by(*ir);
     1979          if (was_reduced)
     1980          {
     1981            time_reduction_search += time_from_last_call();
     1982            p->reduce_by(*ir);
     1983            time_reduction += time_from_last_call();
     1984            break;
     1985          }
     1986          if (ir == R.begin()) break;
     1987          --ir;
     1988        }
     1989        known_gvw_greater_p = ir;
     1990      }
     1991      if (!was_reduced) break;
     1992      reduced_to_zero = p->p_ == NULL;
     1993      if (reduced_to_zero)
     1994      {
     1995        ++zero_reductions;
     1996        known_gvw_greater_p = R.begin();
     1997        break;
     1998      }
     1999    }
     2000    time_reduction_search += time_from_last_call();
     2001    const LPolysByGvw::iterator p_insert_pos =
     2002      R.insert(known_gvw_greater_p, p);
     2003    time_add_r += time_from_last_call();
     2004    SigMuledMinimumFinder b_min_finder(B);
     2005    for(int i=0;i<B.size();)
     2006    {
     2007      LabeledPolyMuled& b = B[i];
     2008      if (p->sig_divides(b) && gvw_less(p,b.not_muled_))
     2009      {
     2010        b.Release();
     2011        B.erase_and_move_from_back(i);
     2012      }else
     2013      {
     2014        b_min_finder.UpdateBy(i);
     2015        ++i;
     2016      }
     2017    }
     2018    time_filter_b += time_from_last_call();
     2019    if (!reduced_to_zero)
     2020    {
     2021      LabeledPolyMuled bnew;
     2022      bnew.Init();
     2023       /*
     2024        printf("\nR = \n");
     2025       for(LPolysByGvw::iterator ir = R.begin(); ir != R.end(); ++ir)
     2026       {
     2027       printf("p = ");pWrite((*ir)->p_);
     2028       printf("s = ");pWrite((*ir)->s_monom_);
     2029       }
     2030       */
     2031      for(LPolysByGvw::const_iterator ir = --R.end();ir != p_insert_pos;--ir)
     2032      {
     2033        //printf ("pNew = "); pWrite(p->p_);
     2034        bnew.FillBy((*ir)->p_, *p);
     2035        bool rejected = false;
     2036        for(LPolysByGvw::const_iterator ir2 = R.begin();ir2 != p_insert_pos;++ir2)
     2037        {
     2038          if ((*ir2)->sig_divides(bnew))
     2039          {
     2040            rejected = true;
     2041            break;
     2042          }
     2043        }
     2044        time_add_b1_testings += time_from_last_call();
     2045        if (!rejected)
     2046        {
     2047          B.push_back(bnew);
     2048          b_min_finder.UpdateBy(B.size() - 1);
     2049          bnew.Init();
     2050          time_add_b1_insertion += time_from_last_call();
     2051        }
     2052      }
     2053      for(LPolysByGvw::const_iterator ir = R.begin();ir != p_insert_pos;++ir)
     2054      {
     2055        if (!gvw_less(*ir, p)) break;
     2056        if ((*ir)->p_ == NULL) continue;
     2057        bool rejected = false;
     2058        bnew.FillBy(p->p_, *(*ir));
     2059        for(LPolysByGvw::const_iterator ir2 = R.begin();ir2 != ir;++ir2)
     2060        {
     2061          if ((*ir2)->sig_divides(bnew))
     2062          {
     2063            rejected = true;
     2064            break;
     2065          }
     2066        }
     2067        if (!rejected)
     2068        {
     2069          B.push_back(bnew);
     2070          b_min_finder.UpdateBy(B.size() - 1);
     2071          bnew.Init();
     2072        }
     2073      }
     2074      bnew.Release();
     2075      time_add_b2 += time_from_last_call();
     2076    }
     2077    /*
     2078       printf("B = \n");
     2079       for(LPolysMuledBySig::iterator ib = B.begin(); ib != B.end(); ++ib)
     2080       {
     2081       printf("smuled = ");pWrite((*ib).smuled_monom_);
     2082    //printf("s = ");pWrite((*ib).not_muled_.s_monom_);
     2083    }
     2084    */
     2085    if (b_min_finder.minimum_idx_ == SigMuledMinimumFinder::NO_ELEMENTS)
     2086    {
     2087      break;
     2088    }else{
     2089      p = LabeledPoly::ConvertFromAndRelease(B[b_min_finder.minimum_idx_]);
     2090      B.erase_and_move_from_back(b_min_finder.minimum_idx_);
     2091    }
     2092  }
     2093  idDelete(&I0);
     2094  I0 = idInit(R.size());
     2095  int i0_idx = 0;
     2096  for(LPolysByGvw::iterator ir = R.begin();ir != R.end();++ir,++i0_idx)
     2097  {
     2098    std::swap(I0->m[i0_idx], (*ir)->p_);
     2099    delete (*ir);
     2100
     2101  }
     2102  R.clear();
     2103
     2104  printf("time time_interred = %d\n", time_interred);
     2105  printf("time time_prepare = %d\n", time_prepare);
     2106  printf("time time_reduction_search = %d\n", time_reduction_search);
     2107  printf("time time_reduction = %d\n", time_reduction);
     2108  printf("time time_add_r = %d\n", time_add_r);
     2109  printf("time time_filter_b = %d\n", time_filter_b);
     2110  printf("time time_add_b1_testings = %d\n", time_add_b1_testings);
     2111  printf("time time_add_b1_insertion = %d\n", time_add_b1_insertion);
     2112  printf("time time_add_b2 = %d\n", time_add_b2);
     2113
     2114  printf("ZERO REDUCTIONS: %d\n", zero_reductions);
     2115
     2116  return I0;
     2117}
     2118ideal ssg (ideal F, ideal Q,intvec *w,intvec *hilb,kStrategy strat)
     2119{
     2120        int
     2121                time_interred = 0, time_prepare = 0, time_reduction_search = 0, time_reduction = 0,
     2122                time_add_r = 0, time_filter_b = 0, time_add_b1_testings = 0, time_add_b1_insertion = 0,
     2123                time_add_b2 = 0;
     2124
     2125        time_from_last_call();
     2126        int current_input_idx = 0;
     2127        while (F->m[current_input_idx] == NULL && current_input_idx < IDELEMS(F))
     2128        {
     2129                ++current_input_idx;
     2130        }
     2131        ideal I0 = idInit(1);
     2132        if (current_input_idx >= IDELEMS(F))
     2133        {
     2134                return I0;
     2135        }
     2136        I0->m[0] = pCopy(F->m[current_input_idx]);
     2137        int zero_reductions = 0;
     2138        LabeledPoly::GvwLess gvw_less;
     2139        for (current_input_idx +=1; current_input_idx < IDELEMS(F); ++current_input_idx)
     2140        {
     2141                if (!F->m[current_input_idx]) continue;
     2142                idDelDiv(I0);
     2143                idSkipZeroes(I0);
     2144#ifndef SSG_NO_INTERRED
     2145                std::sort(I0->m, I0->m+IDELEMS(I0), LmCompareForNonZeroPolys());
     2146               
     2147                ideal I0_tail_reduced = idInit(IDELEMS(I0));
     2148                //tail reducton
     2149                for(int n0 = IDELEMS(I0) - 1; n0 > 0; --n0)
     2150                {
     2151                        poly p_old = NULL;
     2152                        std::swap(p_old,I0->m[n0]);
     2153                        poly p_new = kNF(I0, Q, p_old);
     2154                        pDelete(&p_old);
     2155                        I0_tail_reduced->m[n0] = p_new;
     2156                }
     2157                std::swap(I0_tail_reduced->m[0], I0->m[0]);
     2158                idDelete(&I0);
     2159                I0 = I0_tail_reduced;
     2160#endif
     2161                time_interred += time_from_last_call();
     2162                LPolysByGvw R;
     2163                LPolysMuledBySig B;
     2164                LabeledPoly* p = LabeledPoly::CreateOneSig(F->m[current_input_idx]);
     2165                for(int n0 = IDELEMS(I0) - 1; n0 >=0; --n0)
     2166                {
     2167                        R.push_back(LabeledPoly::CreateZeroSig(I0->m[n0]));
     2168                }
     2169                const LPolysByGvw::iterator first_zero_sig = R.begin();
     2170                for(int n0 = IDELEMS(I0) - 1; n0 >=0; --n0)
     2171                {
     2172                        R.push_front(LabeledPoly::CreateZeroPoly(I0->m[n0]));
     2173                }
     2174    /*
     2175                                printf("\nR-init = \n");
     2176                                for(LPolysByGvw::iterator ir = R.begin(); ir != R.end(); ++ir)
     2177                                {
     2178                                        printf("p = ");pWrite((*ir)->p_);
     2179                                        printf("s = ");pWrite((*ir)->s_monom_);
     2180                                }
     2181    */
     2182                time_prepare += time_from_last_call();
     2183                while(1)
     2184                {
     2185                        bool reduced_to_zero = false;
     2186                        LPolysByGvw::iterator known_gvw_greater_p = first_zero_sig;
     2187#if 1
     2188      /*
     2189                        if (n ==  IDELEMS(F) - 1)
     2190                        {
     2191      */
     2192                                /*
     2193        printf("\nR = \n");
     2194                                for(LPolysByGvw::iterator ir = R.begin(); ir != R.end(); ++ir)
     2195                                {
     2196                                        printf("p = ");pWrite((*ir)->p_);
     2197                                        printf("s = ");pWrite((*ir)->s_monom_);
     2198                                }
     2199                                printf("B = \n");
     2200                                for(LPolysMuledBySig::iterator ib = B.begin(); ib != B.end(); ++ib)
     2201                                {
     2202                                        printf("smuled = ");pWrite((*ib).smuled_monom_);
     2203          //printf("s = ");pWrite((*ib)->not_muled_.s_monom_);
     2204                                }
     2205        */
     2206                        /*
     2207      }
     2208      */
     2209#endif
     2210                        while(1)
     2211                        {
     2212                                bool was_reduced = false;
     2213                                LPolysByGvw::iterator ir = --R.end();
     2214        //printf("p to reduce = ");pWrite (p->p_);
     2215                                while(1)
     2216                                {
     2217                                        was_reduced = p->can_reduce_by(*ir);
     2218                                        if (was_reduced)
     2219                                        {
     2220                                                time_reduction_search += time_from_last_call();
     2221                                                p->reduce_by(*ir);
     2222                                                time_reduction += time_from_last_call();
     2223                                                break;
     2224                                        }
     2225                                        if (ir == known_gvw_greater_p) break;
     2226                                        --ir;
     2227                                }
     2228                                if (!was_reduced && ir != R.begin())
     2229                                {
     2230                                        --ir;
     2231                                        while(1)
     2232                                        {
     2233                                                if (!gvw_less(p, *ir))
     2234                                                {
     2235                                                        ++ir;
     2236                                                        break;
     2237                                                }
     2238                                                was_reduced = p->can_reduce_by(*ir);
     2239                                                if (was_reduced)
     2240                                                {
     2241                                                        time_reduction_search += time_from_last_call();
     2242                                                        p->reduce_by(*ir);
     2243                                                        time_reduction += time_from_last_call();
     2244                                                        break;
     2245                                                }
     2246                                                if (ir == R.begin()) break;
     2247                                                --ir;
     2248                                        }
     2249                                        known_gvw_greater_p = ir;
     2250                                }
     2251                                if (!was_reduced) break;
     2252                                reduced_to_zero = p->p_ == NULL;
     2253                                if (reduced_to_zero)
     2254                                {
     2255                                        ++zero_reductions;
     2256                                        known_gvw_greater_p = R.begin();
     2257                                        break;
     2258                                }
     2259                        }
     2260                        time_reduction_search += time_from_last_call();
     2261                        const LPolysByGvw::iterator p_insert_pos =
     2262                                R.insert(known_gvw_greater_p, p);
     2263                        time_add_r += time_from_last_call();
     2264                        SigMuledMinimumFinder b_min_finder(B);
     2265                        for(int i=0;i<B.size();)
     2266                        {
     2267                                LabeledPolyMuled& b = B[i];
     2268                                if (p->sig_divides(b) && gvw_less(p,b.not_muled_))
     2269                                {
     2270                                        b.Release();
     2271                                        B.erase_and_move_from_back(i);
     2272                                }else
     2273                                {
     2274                                        b_min_finder.UpdateBy(i);
     2275                                        ++i;
     2276                                }
     2277                        }
     2278                        time_filter_b += time_from_last_call();
     2279                        if (!reduced_to_zero)
     2280                        {
     2281                                LabeledPolyMuled bnew;
     2282                                bnew.Init();
     2283                                for(LPolysByGvw::const_iterator ir = --R.end();ir != p_insert_pos;--ir)
     2284                                {
     2285                                        bnew.FillBy((*ir)->p_, *p);
     2286                                        bool rejected = false;
     2287                                        for(LPolysByGvw::const_iterator ir2 = R.begin();ir2 != p_insert_pos;++ir2)
     2288                                        {
     2289                                                if ((*ir2)->sig_divides(bnew))
     2290                                                {
     2291                                                        rejected = true;
     2292                                                        break;
     2293                                                }
     2294                                        }
     2295                                        time_add_b1_testings += time_from_last_call();
     2296                                        if (!rejected)
     2297                                        {
     2298                                                B.push_back(bnew);
     2299                                                b_min_finder.UpdateBy(B.size() - 1);
     2300                                                bnew.Init();
     2301                                                time_add_b1_insertion += time_from_last_call();
     2302                                        }
     2303                                }
     2304                                for(LPolysByGvw::const_iterator ir = R.begin();ir != p_insert_pos;++ir)
     2305                                {
     2306                                        if (!gvw_less(*ir, p)) break;
     2307                                        if ((*ir)->p_ == NULL) continue;
     2308                                        bool rejected = false;
     2309                                        bnew.FillBy(p->p_, *(*ir));
     2310                                        for(LPolysByGvw::const_iterator ir2 = R.begin();ir2 != ir;++ir2)
     2311                                        {
     2312                                                if ((*ir2)->sig_divides(bnew))
     2313                                                {
     2314                                                        rejected = true;
     2315                                                        break;
     2316                                                }
     2317                                        }
     2318                                        if (!rejected)
     2319                                        {
     2320                                                B.push_back(bnew);
     2321                                                b_min_finder.UpdateBy(B.size() - 1);
     2322                                                bnew.Init();
     2323                                        }
     2324                                }
     2325                                bnew.Release();
     2326                                time_add_b2 += time_from_last_call();
     2327                        }
     2328                                /*
     2329        printf("B = \n");
     2330                                for(LPolysMuledBySig::iterator ib = B.begin(); ib != B.end(); ++ib)
     2331                                {
     2332                                        printf("smuled = ");pWrite((*ib).smuled_monom_);
     2333          //printf("s = ");pWrite((*ib).not_muled_.s_monom_);
     2334                                }
     2335        */
     2336                        if (b_min_finder.minimum_idx_ == SigMuledMinimumFinder::NO_ELEMENTS)
     2337                        {
     2338                                break;
     2339                        }else{
     2340                                p = LabeledPoly::ConvertFromAndRelease(B[b_min_finder.minimum_idx_]);
     2341                                B.erase_and_move_from_back(b_min_finder.minimum_idx_);
     2342                        }
     2343     
     2344                }
     2345                idDelete(&I0);
     2346                I0 = idInit(R.size());
     2347                int i0_idx = 0;
     2348                for(LPolysByGvw::iterator ir = R.begin();ir != R.end();++ir,++i0_idx)
     2349                {
     2350                        std::swap(I0->m[i0_idx], (*ir)->p_);
     2351                        delete (*ir);
     2352                       
     2353                }
     2354                R.clear();
     2355        }
     2356
     2357        printf("time time_interred = %d\n", time_interred);
     2358        printf("time time_prepare = %d\n", time_prepare);
     2359        printf("time time_reduction_search = %d\n", time_reduction_search);
     2360        printf("time time_reduction = %d\n", time_reduction);
     2361        printf("time time_add_r = %d\n", time_add_r);
     2362        printf("time time_filter_b = %d\n", time_filter_b);
     2363        printf("time time_add_b1_testings = %d\n", time_add_b1_testings);
     2364        printf("time time_add_b1_insertion = %d\n", time_add_b1_insertion);
     2365        printf("time time_add_b2 = %d\n", time_add_b2);
     2366
     2367        printf("ZERO REDUCTIONS: %d\n", zero_reductions);
     2368
     2369        return I0;
     2370}
     2371ideal sba (ideal F0, ideal Q,intvec *w,intvec *hilb,kStrategy strat)
     2372{
     2373  // ring order stuff:
     2374  // in sba we have (until now) two possibilities:
     2375  // 1. an incremental computation w.r.t. (C,monomial order)
     2376  // 2. a (possibly non-incremental) computation w.r.t. the
     2377  //    induced Schreyer order.
     2378  // The corresponding orders are computed in sbaRing(), depending
     2379  // on the flag strat->incremental
     2380  ideal F = F0;
     2381  ring sRing, currRingOld;
     2382  currRingOld  = currRing;
     2383  if (strat->incremental)
     2384  {
     2385    sRing = sbaRing(strat);
     2386    if (sRing!=currRingOld)
     2387    {
     2388      rChangeCurrRing (sRing);
     2389      F = idrMoveR (F0, currRingOld);
     2390    }
     2391  }
     2392#if 0
     2393  printf("SBA COMPUTATIONS DONE IN THE FOLLOWING RING:\n");
     2394  rWrite (currRing);
     2395  printf("\n");
     2396#endif
     2397#ifdef KDEBUG
     2398  bba_count++;
     2399  int loop_count = 0;
     2400#endif /* KDEBUG */
     2401  om_Opts.MinTrack = 5;
     2402  int   srmax,lrmax, red_result = 1;
     2403  int   olddeg,reduc;
     2404  int hilbeledeg=1,hilbcount=0,minimcnt=0;
     2405  LObject L;
     2406  BOOLEAN withT     = FALSE;
     2407  BOOLEAN newrules  = FALSE;
     2408  strat->max_lower_index = 0;
     2409
     2410  //initBuchMoraCrit(strat); /*set Gebauer, honey, sugarCrit*/
     2411  initSbaCrit(strat); /*set Gebauer, honey, sugarCrit*/
     2412  initSbaPos(strat);
     2413  //initBuchMoraPos(strat);
     2414  initHilbCrit(F,Q,&hilb,strat);
     2415  initSba(F,strat);
     2416  /*set enterS, spSpolyShort, reduce, red, initEcart, initEcartPair*/
     2417  /*Shdl=*/initSbaBuchMora(F, Q,strat);
     2418  if (strat->minim>0) strat->M=idInit(IDELEMS(F),F->rank);
     2419  srmax = strat->sl;
     2420  reduc = olddeg = lrmax = 0;
     2421
     2422#ifndef NO_BUCKETS
     2423  if (!TEST_OPT_NOT_BUCKETS)
     2424    strat->use_buckets = 1;
     2425#endif
     2426
     2427  // redtailBBa against T for inhomogenous input
     2428  if (!TEST_OPT_OLDSTD)
     2429    withT = ! strat->homog;
     2430
     2431  // strat->posInT = posInT_pLength;
     2432  kTest_TS(strat);
     2433
     2434#ifdef KDEBUG
     2435#if MYTEST
     2436  if (TEST_OPT_DEBUG)
     2437  {
     2438    PrintS("bba start GB: currRing: ");
     2439    // rWrite(currRing);PrintLn();
     2440    rDebugPrint(currRing);
     2441    PrintLn();
     2442  }
     2443#endif /* MYTEST */
     2444#endif /* KDEBUG */
     2445
     2446#ifdef HAVE_TAIL_RING
     2447  if(!idIs0(F) &&(!rField_is_Ring()))  // create strong gcd poly computes with tailring and S[i] ->to be fixed
     2448    kStratInitChangeTailRing(strat);
     2449#endif
     2450  if (BVERBOSE(23))
     2451  {
     2452    if (test_PosInT!=NULL) strat->posInT=test_PosInT;
     2453    if (test_PosInL!=NULL) strat->posInL=test_PosInL;
     2454    kDebugPrint(strat);
     2455  }
     2456
     2457
     2458#ifdef KDEBUG
     2459  //kDebugPrint(strat);
     2460#endif
     2461  /* compute------------------------------------------------------- */
     2462  arriAgain:
     2463  while (strat->Ll >= 0)
     2464  {
     2465    if (strat->Ll > lrmax) lrmax =strat->Ll;/*stat.*/
     2466    #ifdef KDEBUG
     2467      loop_count++;
     2468      if (TEST_OPT_DEBUG) messageSets(strat);
     2469    #endif
     2470    if (strat->Ll== 0) strat->interpt=TRUE;
     2471    if (TEST_OPT_DEGBOUND
     2472        && ((strat->honey && (strat->L[strat->Ll].ecart+pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))
     2473            || ((!strat->honey) && (pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))))
     2474    {
     2475      /*
     2476       *stops computation if
     2477       * 24 IN test and the degree +ecart of L[strat->Ll] is bigger then
     2478       *a predefined number Kstd1_deg
     2479       */
     2480      while ((strat->Ll >= 0)
     2481        && (strat->L[strat->Ll].p1!=NULL) && (strat->L[strat->Ll].p2!=NULL)
     2482        && ((strat->honey && (strat->L[strat->Ll].ecart+pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))
     2483            || ((!strat->honey) && (pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg)))
     2484        )
     2485        deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
     2486      if (strat->Ll<0) break;
     2487      else strat->noClearS=TRUE;
     2488    }
     2489    if (strat->incremental && pGetComp(strat->L[strat->Ll].sig) != strat->currIdx)
     2490    {
     2491      strat->currIdx  = pGetComp(strat->L[strat->Ll].sig);
     2492#if F5C
     2493      // 1. interreduction of the current standard basis
     2494      // 2. generation of new principal syzygy rules for syzCriterion
     2495      f5c ( strat, olddeg, minimcnt, hilbeledeg, hilbcount, srmax,
     2496            lrmax, reduc, Q, w, hilb );
     2497#endif
     2498      // initialize new syzygy rules for the next iteration step 
     2499      initSyzRules(strat);
     2500    }
     2501    /*********************************************************************
     2502     * interrreduction step is done, we can go on with the next iteration
     2503     * step of the signature-based algorithm
     2504     ********************************************************************/
     2505    /* picks the last element from the lazyset L */
     2506    strat->P = strat->L[strat->Ll];
     2507    strat->Ll--;
     2508//#if 1
     2509#ifdef DEBUGF5
     2510    Print("SIG OF NEXT PAIR TO HANDLE IN SIG-BASED ALGORITHM\n");
     2511    Print("-------------------------------------------------\n");
     2512    pWrite(strat->P.sig);
     2513    pWrite(pHead(strat->P.p));
     2514    pWrite(pHead(strat->P.p1));
     2515    pWrite(pHead(strat->P.p2));
     2516    Print("-------------------------------------------------\n");
     2517#endif
     2518    if (pNext(strat->P.p) == strat->tail)
     2519    {
     2520      // deletes the short spoly
     2521#ifdef HAVE_RINGS
     2522      if (rField_is_Ring(currRing))
     2523        pLmDelete(strat->P.p);
     2524      else
     2525#endif
     2526        pLmFree(strat->P.p);
     2527
     2528      // TODO: needs some masking
     2529      // TODO: masking needs to vanish once the signature
     2530      //       sutff is completely implemented
     2531      strat->P.p = NULL;
     2532      poly m1 = NULL, m2 = NULL;
     2533
     2534      // check that spoly creation is ok
     2535      while (strat->tailRing != currRing &&
     2536             !kCheckSpolyCreation(&(strat->P), strat, m1, m2))
     2537      {
     2538        assume(m1 == NULL && m2 == NULL);
     2539        // if not, change to a ring where exponents are at least
     2540        // large enough
     2541        if (!kStratChangeTailRing(strat))
     2542        {
     2543          WerrorS("OVERFLOW...");
     2544          break;
     2545        }
     2546      }
     2547      // create the real one
     2548      ksCreateSpoly(&(strat->P), NULL, strat->use_buckets,
     2549                    strat->tailRing, m1, m2, strat->R);
     2550
     2551    }
     2552    else if (strat->P.p1 == NULL)
     2553    {
     2554      if (strat->minim > 0)
     2555        strat->P.p2=p_Copy(strat->P.p, currRing, strat->tailRing);
     2556      // for input polys, prepare reduction
     2557      strat->P.PrepareRed(strat->use_buckets);
     2558    }
     2559
     2560    if (strat->P.p == NULL && strat->P.t_p == NULL)
     2561    {
     2562      red_result = 0;
     2563    }
     2564    else
     2565    {
     2566      if (TEST_OPT_PROT)
     2567        message((strat->honey ? strat->P.ecart : 0) + strat->P.pFDeg(),
     2568                &olddeg,&reduc,strat, red_result);
     2569
     2570//#if 1
     2571#ifdef DEBUGF5
     2572      Print("Poly before red: ");
     2573      pWrite(strat->P.p);
     2574#endif
     2575      /* reduction of the element choosen from L */
     2576      if (!strat->rewCrit2(strat->P.sig, ~strat->P.sevSig, strat, strat->P.checked+1))
     2577        red_result = strat->red(&strat->P,strat);
     2578      else
     2579      {
     2580        if (strat->P.lcm!=NULL)
     2581          pLmFree(strat->P.lcm);
     2582        red_result = 2;
     2583      }
     2584      if (errorreported)  break;
     2585    }
     2586
     2587    if (strat->overflow)
     2588    {
     2589        if (!kStratChangeTailRing(strat)) { Werror("OVERFLOW.."); break;}
     2590    }
     2591    if (strat->incremental)
     2592    {
     2593      for (int jj = 0; jj<strat->tl+1; jj++)
     2594      {
     2595        if (pGetComp(strat->T[jj].sig) == strat->currIdx)
     2596        {
     2597          strat->T[jj].is_sigsafe = FALSE;
     2598        }
     2599      }
     2600    }
     2601    else
     2602    {
     2603      for (int jj = 0; jj<strat->tl+1; jj++)
     2604      {
     2605        strat->T[jj].is_sigsafe = FALSE;
     2606      }
     2607    }
     2608
     2609    // reduction to non-zero new poly
     2610    if (red_result == 1)
     2611    {
     2612      // get the polynomial (canonicalize bucket, make sure P.p is set)
     2613      strat->P.GetP(strat->lmBin);
     2614     
     2615      // sig-safe computations may lead to wrong FDeg computation, thus we need
     2616      // to recompute it to make sure everything is alright
     2617      (strat->P).FDeg = (strat->P).pFDeg();
     2618      // in the homogeneous case FDeg >= pFDeg (sugar/honey)
     2619      // but now, for entering S, T, we reset it
     2620      // in the inhomogeneous case: FDeg == pFDeg
     2621      if (strat->homog) strat->initEcart(&(strat->P));
     2622
     2623      /* statistic */
     2624      if (TEST_OPT_PROT) PrintS("s");
     2625
     2626      //int pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart);
     2627      // in F5E we know that the last reduced element is already the
     2628      // the one with highest signature
     2629      int pos = strat->sl+1;
     2630
     2631#ifdef KDEBUG
     2632#if MYTEST
     2633      PrintS("New S: "); pDebugPrint(strat->P.p); PrintLn();
     2634#endif /* MYTEST */
     2635#endif /* KDEBUG */
     2636
     2637      // reduce the tail and normalize poly
     2638      // in the ring case we cannot expect LC(f) = 1,
     2639      // therefore we call pContent instead of pNorm
     2640      /*
     2641      if ((TEST_OPT_INTSTRATEGY) || (rField_is_Ring(currRing)))
     2642      {
     2643        strat->P.pCleardenom();
     2644        if ((TEST_OPT_REDSB)||(TEST_OPT_REDTAIL))
     2645        {
     2646          strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT);
     2647          strat->P.pCleardenom();
     2648        }
     2649      }
     2650      else
     2651      {
     2652        strat->P.pNorm();
     2653        if ((TEST_OPT_REDSB)||(TEST_OPT_REDTAIL))
     2654          strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT);
     2655      }
     2656      */
     2657#ifdef KDEBUG
     2658      if (TEST_OPT_DEBUG){PrintS("new s:");strat->P.wrp();PrintLn();}
     2659#if MYTEST
     2660//#if 1
     2661      PrintS("New (reduced) S: "); pDebugPrint(strat->P.p); PrintLn();
     2662#endif /* MYTEST */
     2663#endif /* KDEBUG */
     2664
     2665      // min_std stuff
     2666      if ((strat->P.p1==NULL) && (strat->minim>0))
     2667      {
     2668        if (strat->minim==1)
     2669        {
     2670          strat->M->m[minimcnt]=p_Copy(strat->P.p,currRing,strat->tailRing);
     2671          p_Delete(&strat->P.p2, currRing, strat->tailRing);
     2672        }
     2673        else
     2674        {
     2675          strat->M->m[minimcnt]=strat->P.p2;
     2676          strat->P.p2=NULL;
     2677        }
     2678        if (strat->tailRing!=currRing && pNext(strat->M->m[minimcnt])!=NULL)
     2679          pNext(strat->M->m[minimcnt])
     2680            = strat->p_shallow_copy_delete(pNext(strat->M->m[minimcnt]),
     2681                                           strat->tailRing, currRing,
     2682                                           currRing->PolyBin);
     2683        minimcnt++;
     2684      }
     2685
     2686      // enter into S, L, and T
     2687      //if ((!TEST_OPT_IDLIFT) || (pGetComp(strat->P.p) <= strat->syzComp))
     2688      if(!strat->incremental)
     2689      {
     2690        BOOLEAN overwrite = TRUE;
     2691        for (int tk=0; tk<strat->sl+1; tk++)
     2692        {
     2693          if (pGetComp(strat->sig[tk]) == pGetComp(strat->P.sig))
     2694          {
     2695            //printf("TK %d / %d\n",tk,strat->sl);
     2696            overwrite = FALSE;
     2697            break;
     2698          }
     2699        }
     2700        //printf("OVERWRITE %d\n",overwrite);
     2701        if (overwrite)
     2702        {
     2703          int cmp = pGetComp(strat->P.sig);
     2704          int* vv = (int*)omAlloc((currRing->N+1)*sizeof(int));
     2705          pGetExpV (strat->P.p,vv);
     2706          pSetExpV (strat->P.sig, vv);
     2707          pSetComp (strat->P.sig,cmp);
     2708
     2709          strat->P.sevSig = pGetShortExpVector (strat->P.sig);
     2710          for(int ps=0;ps<strat->sl+1;ps++)
     2711          {
     2712            int i = strat->syzl;
     2713
     2714            strat->newt = TRUE;
     2715            if (strat->syzl == strat->syzmax)
     2716            {
     2717              pEnlargeSet(&strat->syz,strat->syzmax,setmaxTinc);
     2718              strat->sevSyz = (unsigned long*) omRealloc0Size(strat->sevSyz,
     2719                  (strat->syzmax)*sizeof(unsigned long),
     2720                  ((strat->syzmax)+setmaxTinc)
     2721                  *sizeof(unsigned long));
     2722              strat->syzmax += setmaxTinc;
     2723            }
     2724            strat->syz[i] = pCopy(strat->P.sig);
     2725            // add LM(F->m[i]) to the signature to get a Schreyer order
     2726            // without changing the underlying polynomial ring at all
     2727            p_ExpVectorAdd (strat->syz[i],strat->S[ps],currRing); 
     2728            // since p_Add_q() destroys all input
     2729            // data we need to recreate help
     2730            // each time
     2731            // ----------------------------------------------------------
     2732            // in the Schreyer order we always know that the multiplied
     2733            // module monomial strat->P.sig gives the leading monomial of
     2734            // the corresponding principal syzygy
     2735            // => we do not need to compute the "real" syzygy completely
     2736            poly help = pCopy(strat->sig[ps]);
     2737            p_ExpVectorAdd (help,strat->P.p,currRing); 
     2738            strat->syz[i] = p_Add_q(strat->syz[i],help,currRing);
     2739            //printf("%d. SYZ  ",i+1);
     2740            //pWrite(strat->syz[i]);
     2741            strat->sevSyz[i] = p_GetShortExpVector(strat->syz[i],currRing);
     2742            strat->syzl++;
     2743          }
     2744        }
     2745      }
     2746        enterT(strat->P, strat);
     2747        strat->T[strat->tl].is_sigsafe = FALSE;
     2748#ifdef HAVE_RINGS
     2749      if (rField_is_Ring(currRing))
     2750        superenterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl);
     2751      else
     2752#endif
     2753        enterpairsSig(strat->P.p,strat->P.sig,strat->sl+1,strat->sl,strat->P.ecart,pos,strat, strat->tl);
     2754      // posInS only depends on the leading term
     2755      strat->enterS(strat->P, pos, strat, strat->tl);
     2756//#if 1
     2757#if DEBUGF50
     2758    printf("---------------------------\n");
     2759    Print(" %d. ELEMENT ADDED TO GCURR:\n",strat->sl+1);
     2760    Print("LEAD POLY:  "); pWrite(pHead(strat->S[strat->sl]));
     2761    Print("SIGNATURE:  "); pWrite(strat->sig[strat->sl]);
     2762#endif
     2763      /*
     2764      if (newrules)
     2765      {
     2766        newrules  = FALSE;
     2767      }
     2768      */
     2769#if 0
     2770      int pl=pLength(strat->P.p);
     2771      if (pl==1)
     2772      {
     2773        //if (TEST_OPT_PROT)
     2774        //PrintS("<1>");
     2775      }
     2776      else if (pl==2)
     2777      {
     2778        //if (TEST_OPT_PROT)
     2779        //PrintS("<2>");
     2780      }
     2781#endif
     2782      if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat);
     2783//      Print("[%d]",hilbeledeg);
     2784      if (strat->P.lcm!=NULL)
     2785#ifdef HAVE_RINGS
     2786        pLmDelete(strat->P.lcm);
     2787#else
     2788        pLmFree(strat->P.lcm);
     2789#endif
     2790      if (strat->sl>srmax) srmax = strat->sl;
     2791    }
     2792    else
     2793    {
     2794      // adds signature of the zero reduction to
     2795      // strat->syz. This is the leading term of
     2796      // syzygy and can be used in syzCriterion()
     2797      // the signature is added if and only if the
     2798      // pair was not detected by the rewritten criterion in strat->red = redSig
     2799      if (red_result!=2) {
     2800        zeroreductions++;
     2801        enterSyz(strat->P,strat);
     2802//#if 1
     2803#ifdef DEBUGF5
     2804        Print("ADDING STUFF TO SYZ :  ");
     2805        pWrite(strat->P.p);
     2806        pWrite(strat->P.sig);
     2807#endif
     2808      }
     2809      if (strat->P.p1 == NULL && strat->minim > 0)
     2810      {
     2811        p_Delete(&strat->P.p2, currRing, strat->tailRing);
     2812      }
     2813    }
     2814
     2815#ifdef KDEBUG
     2816    memset(&(strat->P), 0, sizeof(strat->P));
     2817#endif /* KDEBUG */
     2818    kTest_TS(strat);
     2819  }
     2820#ifdef KDEBUG
     2821#if MYTEST
     2822  PrintS("bba finish GB: currRing: "); rWrite(currRing);
     2823#endif /* MYTEST */
     2824  if (TEST_OPT_DEBUG) messageSets(strat);
     2825#endif /* KDEBUG */
     2826
     2827  if (TEST_OPT_SB_1)
     2828  {
     2829    int k=1;
     2830    int j;
     2831    while(k<=strat->sl)
     2832    {
     2833      j=0;
     2834      loop
     2835      {
     2836        if (j>=k) break;
     2837        clearS(strat->S[j],strat->sevS[j],&k,&j,strat);
     2838        j++;
     2839      }
     2840      k++;
     2841    }
     2842  }
     2843
     2844  /* complete reduction of the standard basis--------- */
     2845  if (TEST_OPT_REDSB)
     2846  {
     2847    completeReduce(strat);
     2848#ifdef HAVE_TAIL_RING
     2849    if (strat->completeReduce_retry)
     2850    {
     2851      // completeReduce needed larger exponents, retry
     2852      // to reduce with S (instead of T)
     2853      // and in currRing (instead of strat->tailRing)
     2854      cleanT(strat);strat->tailRing=currRing;
     2855      int i;
     2856      for(i=strat->sl;i>=0;i--) strat->S_2_R[i]=-1;
     2857      completeReduce(strat);
     2858    }
     2859#endif
     2860  }
     2861  else if (TEST_OPT_PROT) PrintLn();
     2862
     2863  exitSba(strat);
     2864  if (TEST_OPT_WEIGHTM)
     2865  {
     2866    pRestoreDegProcs(pFDegOld, pLDegOld);
     2867    if (ecartWeights)
     2868    {
     2869      omFreeSize((ADDRESS)ecartWeights,(pVariables+1)*sizeof(short));
     2870      ecartWeights=NULL;
     2871    }
     2872  }
     2873  if (TEST_OPT_PROT) messageStat(srmax,lrmax,hilbcount,strat);
     2874  if (Q!=NULL) updateResult(strat->Shdl,Q,strat);
     2875
     2876#ifdef KDEBUG
     2877#if MYTEST
     2878  PrintS("bba_end: currRing: "); rWrite(currRing);
     2879#endif /* MYTEST */
     2880#endif /* KDEBUG */
     2881  // using F5C it is possible that there is some data stored in the last
     2882  // entries of strat->Shdl which are dirty, i.e. not correct, but also not NULL
     2883  // => we need to delete them before return the ideal
     2884#if F5C
     2885  for(int i=strat->sl+1;i<IDELEMS(strat->Shdl);i++)
     2886  {
     2887    //pDelete (&strat->Shdl->m[i]);
     2888    strat->Shdl->m[i] = NULL;
     2889  }
     2890#endif
     2891  if (strat->incremental && sRing!=currRingOld)
     2892  {
     2893    rChangeCurrRing (currRingOld);
     2894    F0          = idrMoveR (F, sRing);
     2895    strat->Shdl = idrMoveR_NoSort (strat->Shdl, sRing);
     2896    rDelete (sRing);
     2897  }
     2898  idTest(strat->Shdl);
     2899
     2900#ifdef DEBUGF5
     2901  printf("SIZE OF SHDL: %d\n",IDELEMS(strat->Shdl));
     2902  int oo = 0;
     2903  while (oo<IDELEMS(strat->Shdl))
     2904  {
     2905    printf(" %d.   ",oo+1);
     2906    pWrite(pHead(strat->Shdl->m[oo]));
     2907    oo++;
     2908  }
     2909#endif
     2910  printf("ZERO REDUCTIONS: %ld\n",zeroreductions);
     2911  zeroreductions  = 0;
    12962912  return (strat->Shdl);
    12972913}
     
    14473063  return res;
    14483064}
     3065
     3066#if F5C
     3067/*********************************************************************
     3068* interrreduction step of the signature-based algorithm:
     3069* 1. all strat->S are interpreted as new critical pairs
     3070* 2. those pairs need to be completely reduced by the usual (non sig-
     3071*    safe) reduction process (including tail reductions)
     3072* 3. strat->S and strat->T are completely new computed in these steps
     3073********************************************************************/
     3074void f5c (kStrategy strat, int& olddeg, int& minimcnt, int& hilbeledeg,
     3075          int& hilbcount, int& srmax, int& lrmax, int& reduc, ideal Q,
     3076          intvec *w,intvec *hilb )
     3077{
     3078  int Ll_old, red_result = 1;
     3079  BOOLEAN withT = FALSE;
     3080  int pos  = 0;
     3081  hilbeledeg=1;
     3082  hilbcount=0;
     3083  minimcnt=0;
     3084  srmax = 0; // strat->sl is 0 at this point
     3085  reduc = olddeg = lrmax = 0;
     3086  // we cannot use strat->T anymore
     3087  //cleanT(strat);
     3088  //strat->tl = -1;
     3089  Ll_old    = strat->Ll;
     3090  while (strat->tl >= 0)
     3091  {
     3092    if(!strat->T[strat->tl].is_redundant)
     3093    {
     3094      LObject h;
     3095      h.p = strat->T[strat->tl].p;
     3096      h.tailRing = strat->T[strat->tl].tailRing;
     3097      h.t_p = strat->T[strat->tl].t_p;
     3098      if (h.p!=NULL)
     3099      {
     3100        if (pOrdSgn==-1)
     3101        {
     3102          cancelunit(&h); 
     3103          deleteHC(&h, strat);
     3104        }
     3105        if (h.p!=NULL)
     3106        {
     3107          if (TEST_OPT_INTSTRATEGY)
     3108          {
     3109            //pContent(h.p);
     3110            h.pCleardenom(); // also does a pContent
     3111          }
     3112          else
     3113          {
     3114            h.pNorm();
     3115          }
     3116          strat->initEcart(&h);
     3117          pos = strat->Ll+1;
     3118          h.sev = pGetShortExpVector(h.p);
     3119          enterL(&strat->L,&strat->Ll,&strat->Lmax,h,pos);
     3120        }
     3121      }
     3122    }
     3123    strat->tl--;
     3124  }
     3125  strat->sl = -1;
     3126#if 0
     3127//#ifdef HAVE_TAIL_RING
     3128  if(!rField_is_Ring())  // create strong gcd poly computes with tailring and S[i] ->to be fixed
     3129    kStratInitChangeTailRing(strat);
     3130#endif
     3131  //enterpairs(pOne(),0,0,-1,strat,strat->tl);
     3132  //strat->sl = -1;
     3133  /* picks the last element from the lazyset L */
     3134  while (strat->Ll>Ll_old)
     3135  {
     3136    strat->P = strat->L[strat->Ll];
     3137    strat->Ll--;
     3138//#if 1
     3139#ifdef DEBUGF5
     3140    Print("NEXT PAIR TO HANDLE IN INTERRED ALGORITHM\n");
     3141    Print("-------------------------------------------------\n");
     3142    pWrite(pHead(strat->P.p));
     3143    pWrite(pHead(strat->P.p1));
     3144    pWrite(pHead(strat->P.p2));
     3145    printf("%d\n",strat->tl);
     3146    Print("-------------------------------------------------\n");
     3147#endif
     3148    if (pNext(strat->P.p) == strat->tail)
     3149    {
     3150      // deletes the short spoly
     3151#ifdef HAVE_RINGS
     3152      if (rField_is_Ring(currRing))
     3153        pLmDelete(strat->P.p);
     3154      else
     3155#endif
     3156        pLmFree(strat->P.p);
     3157
     3158      // TODO: needs some masking
     3159      // TODO: masking needs to vanish once the signature
     3160      //       sutff is completely implemented
     3161      strat->P.p = NULL;
     3162      poly m1 = NULL, m2 = NULL;
     3163
     3164      // check that spoly creation is ok
     3165      while (strat->tailRing != currRing &&
     3166          !kCheckSpolyCreation(&(strat->P), strat, m1, m2))
     3167      {
     3168        assume(m1 == NULL && m2 == NULL);
     3169        // if not, change to a ring where exponents are at least
     3170        // large enough
     3171        if (!kStratChangeTailRing(strat))
     3172        {
     3173          WerrorS("OVERFLOW...");
     3174          break;
     3175        }
     3176      }
     3177      // create the real one
     3178      ksCreateSpoly(&(strat->P), NULL, strat->use_buckets,
     3179          strat->tailRing, m1, m2, strat->R);
     3180    }
     3181    else if (strat->P.p1 == NULL)
     3182    {
     3183      if (strat->minim > 0)
     3184        strat->P.p2=p_Copy(strat->P.p, currRing, strat->tailRing);
     3185      // for input polys, prepare reduction
     3186      strat->P.PrepareRed(strat->use_buckets);
     3187    }
     3188
     3189    if (strat->P.p == NULL && strat->P.t_p == NULL)
     3190    {
     3191      red_result = 0;
     3192    }
     3193    else
     3194    {
     3195      if (TEST_OPT_PROT)
     3196        message((strat->honey ? strat->P.ecart : 0) + strat->P.pFDeg(),
     3197            &olddeg,&reduc,strat, red_result);
     3198
     3199#ifdef DEBUGF5
     3200      Print("Poly before red: ");
     3201      pWrite(strat->P.p);
     3202#endif
     3203      /* complete reduction of the element choosen from L */
     3204      red_result = strat->red2(&strat->P,strat);
     3205      if (errorreported)  break;
     3206    }
     3207
     3208    if (strat->overflow)
     3209    {
     3210      if (!kStratChangeTailRing(strat)) { Werror("OVERFLOW.."); break;}
     3211    }
     3212
     3213    // reduction to non-zero new poly
     3214    if (red_result == 1)
     3215    {
     3216      // get the polynomial (canonicalize bucket, make sure P.p is set)
     3217      strat->P.GetP(strat->lmBin);
     3218      // in the homogeneous case FDeg >= pFDeg (sugar/honey)
     3219      // but now, for entering S, T, we reset it
     3220      // in the inhomogeneous case: FDeg == pFDeg
     3221      if (strat->homog) strat->initEcart(&(strat->P));
     3222
     3223      /* statistic */
     3224      if (TEST_OPT_PROT) PrintS("s");
     3225
     3226      int pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart);
     3227
     3228#ifdef KDEBUG
     3229#if MYTEST
     3230      PrintS("New S: "); pDebugPrint(strat->P.p); PrintLn();
     3231#endif /* MYTEST */
     3232#endif /* KDEBUG */
     3233
     3234      // reduce the tail and normalize poly
     3235      // in the ring case we cannot expect LC(f) = 1,
     3236      // therefore we call pContent instead of pNorm
     3237#if F5CTAILRED
     3238      if ((TEST_OPT_INTSTRATEGY) || (rField_is_Ring(currRing)))
     3239      {
     3240        strat->P.pCleardenom();
     3241        if ((TEST_OPT_REDSB)||(TEST_OPT_REDTAIL))
     3242        {
     3243          strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT);
     3244          strat->P.pCleardenom();
     3245        }
     3246      }
     3247      else
     3248      {
     3249        strat->P.pNorm();
     3250        if ((TEST_OPT_REDSB)||(TEST_OPT_REDTAIL))
     3251          strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT);
     3252      }
     3253#endif
     3254#ifdef KDEBUG
     3255      if (TEST_OPT_DEBUG){PrintS("new s:");strat->P.wrp();PrintLn();}
     3256#if MYTEST
     3257//#if 1
     3258      PrintS("New (reduced) S: "); pDebugPrint(strat->P.p); PrintLn();
     3259#endif /* MYTEST */
     3260#endif /* KDEBUG */
     3261
     3262      // min_std stuff
     3263      if ((strat->P.p1==NULL) && (strat->minim>0))
     3264      {
     3265        if (strat->minim==1)
     3266        {
     3267          strat->M->m[minimcnt]=p_Copy(strat->P.p,currRing,strat->tailRing);
     3268          p_Delete(&strat->P.p2, currRing, strat->tailRing);
     3269        }
     3270        else
     3271        {
     3272          strat->M->m[minimcnt]=strat->P.p2;
     3273          strat->P.p2=NULL;
     3274        }
     3275        if (strat->tailRing!=currRing && pNext(strat->M->m[minimcnt])!=NULL)
     3276          pNext(strat->M->m[minimcnt])
     3277            = strat->p_shallow_copy_delete(pNext(strat->M->m[minimcnt]),
     3278                strat->tailRing, currRing,
     3279                currRing->PolyBin);
     3280        minimcnt++;
     3281      }
     3282
     3283      // enter into S, L, and T
     3284      // here we need to recompute new signatures, but those are trivial ones
     3285      //if ((!TEST_OPT_IDLIFT) || (pGetComp(strat->P.p) <= strat->syzComp))
     3286      enterT(strat->P, strat);
     3287      // posInS only depends on the leading term
     3288      strat->enterS(strat->P, pos, strat, strat->tl);
     3289//#if 1
     3290#ifdef DEBUGF5
     3291      Print("ELEMENT ADDED TO GCURR DURING INTERRED: ");
     3292      pWrite(pHead(strat->S[strat->sl]));
     3293      pWrite(strat->sig[strat->sl]);
     3294#endif
     3295      if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat);
     3296      //      Print("[%d]",hilbeledeg);
     3297      if (strat->P.lcm!=NULL)
     3298#ifdef HAVE_RINGS
     3299        pLmDelete(strat->P.lcm);
     3300#else
     3301      pLmFree(strat->P.lcm);
     3302#endif
     3303      if (strat->sl>srmax) srmax = strat->sl;
     3304    }
     3305    else
     3306    {
     3307      // adds signature of the zero reduction to
     3308      // strat->syz. This is the leading term of
     3309      // syzygy and can be used in syzCriterion()
     3310      // the signature is added if and only if the
     3311      // pair was not detected by the rewritten criterion in strat->red = redSig
     3312      if (strat->P.p1 == NULL && strat->minim > 0)
     3313      {
     3314        p_Delete(&strat->P.p2, currRing, strat->tailRing);
     3315      }
     3316    }
     3317
     3318#ifdef KDEBUG
     3319    memset(&(strat->P), 0, sizeof(strat->P));
     3320#endif /* KDEBUG */
     3321  }
     3322  int cc = 0;
     3323  while (cc<strat->tl+1)
     3324  {
     3325    strat->T[cc].sig        = pOne();
     3326    p_SetComp(strat->T[cc].sig,cc+1,currRing);
     3327    strat->T[cc].sevSig     = pGetShortExpVector(strat->T[cc].sig);
     3328    strat->sig[cc]          = strat->T[cc].sig;
     3329    strat->sevSig[cc]       = strat->T[cc].sevSig;
     3330    strat->T[cc].is_sigsafe = TRUE; 
     3331    cc++;
     3332  }
     3333  strat->max_lower_index = strat->tl;
     3334  // set current signature index of upcoming iteration step
     3335  // NOTE:  this needs to be set here, as otherwise initSyzRules cannot compute
     3336  //        the corresponding syzygy rules correctly
     3337  strat->currIdx = cc+1;
     3338  for (int cd=strat->Ll; cd>=0; cd--)
     3339  {
     3340    p_SetComp(strat->L[cd].sig,cc+1,currRing);
     3341    cc++;
     3342  }
     3343//#if 1
     3344#if DEBUGF5
     3345  Print("------------------- STRAT S ---------------------\n");
     3346  cc = 0;
     3347  while (cc<strat->tl+1)
     3348  {
     3349    pWrite(pHead(strat->S[cc]));
     3350    pWrite(strat->sig[cc]);
     3351    printf("- - - - - -\n");
     3352    cc++;
     3353  }
     3354  Print("-------------------------------------------------\n");
     3355  Print("------------------- STRAT T ---------------------\n");
     3356  cc = 0;
     3357  while (cc<strat->tl+1)
     3358  {
     3359    pWrite(pHead(strat->T[cc].p));
     3360    pWrite(strat->T[cc].sig);
     3361    printf("- - - - - -\n");
     3362    cc++;
     3363  }
     3364  Print("-------------------------------------------------\n");
     3365  Print("------------------- STRAT L ---------------------\n");
     3366  cc = 0;
     3367  while (cc<strat->Ll+1)
     3368  {
     3369    pWrite(pHead(strat->L[cc].p));
     3370    pWrite(pHead(strat->L[cc].p1));
     3371    pWrite(pHead(strat->L[cc].p2));
     3372    pWrite(strat->L[cc].sig);
     3373    printf("- - - - - -\n");
     3374    cc++;
     3375  }
     3376  Print("-------------------------------------------------\n");
     3377  printf("F5C DONE\nSTRAT SL: %d -- %d\n",strat->sl, strat->currIdx);
     3378#endif
     3379
     3380}
     3381#endif
    14493382
    14503383/* shiftgb stuff */
Note: See TracChangeset for help on using the changeset viewer.