Changeset 5038cd in git


Ignore:
Timestamp:
Nov 23, 2000, 6:34:13 PM (23 years ago)
Author:
Olaf Bachmann <obachman@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
85342036e5a4c81e1cace3f56c0dc8c1c1c655e0
Parents:
3d3d161d5697190f14e10031ef2c3cbb81a36c9f
Message:
* buckets in local case


git-svn-id: file:///usr/local/Singular/svn/trunk@4763 2c84dea3-7e68-4137-9b89-c4e89433aadc
Location:
Singular
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • Singular/kInline.cc

    r3d3d16 r5038cd  
    77 *  Author:  obachman (Olaf Bachmann)
    88 *  Created: 8/00
    9  *  Version: $Id: kInline.cc,v 1.16 2000-11-16 09:54:49 obachman Exp $
     9 *  Version: $Id: kInline.cc,v 1.17 2000-11-23 17:34:07 obachman Exp $
    1010 *******************************************************************/
    1111#ifndef KINLINE_CC
     
    3737  tailBin = omGetStickyBinOfBin(currRing->PolyBin);
    3838#endif
     39  pOrigFDeg = pFDeg;
     40  pOrigLDeg = pLDeg;
    3941}
    4042
     
    4951  if (currRing != tailRing)
    5052    rKillModifiedRing(tailRing);
     53  pLDeg = pOrigLDeg;
     54  pFDeg = pOrigFDeg;
    5155}
    5256
     
    284288    p = p_LmDeleteAndNext(p, currRing);
    285289  }
     290  is_normalized = FALSE;
    286291}
    287292
     
    436441}
    437442
    438 KINLINE void sLObject::SetLmTail(poly lm, poly p_tail, int p_Length, int use_bucket, ring tailRing)
    439 {
     443KINLINE void sLObject::PrepareRed(BOOLEAN use_bucket)
     444{
     445  if (bucket == NULL)
     446  {
     447    int l = GetpLength();
     448    if (use_bucket && l > 1)
     449    {
     450      poly tp = GetLmTailRing();
     451      bucket = kBucketCreate(tailRing);
     452      kBucketInit(bucket, pNext(tp), l-1);
     453      pNext(tp) = NULL;
     454      if (p != NULL) pNext(p) = NULL;
     455      pLength = 0;
     456    }
     457  }
     458}
     459
     460KINLINE void sLObject::SetLmTail(poly lm, poly p_tail, int p_Length, int use_bucket, ring tailRing, poly _last)
     461{
     462 
    440463  Set(lm, tailRing);
    441464  if (use_bucket)
     
    449472  {
    450473    pNext(lm) = p_tail;
    451     pLength = p_Length;
    452   }
     474    pLength = p_Length + 1;
     475    last = _last;
     476  }
     477 
    453478}
    454479
     
    478503    poly _p = (t_p != NULL ? t_p : p);
    479504    assume(_p != NULL);
    480     int dummy;
     505    int shorter;
    481506    pNext(_p) = tailRing->p_Procs->p_Minus_mm_Mult_qq(pNext(_p), m, q,
    482                                                       dummy,spNoether,tailRing);
     507                                                      shorter,spNoether,
     508                                                      tailRing, last);
     509    pLength += lq - shorter;
    483510  }
    484511}
     
    493520    {
    494521      kBucketDestroy(&bucket);
     522      p = t_p = NULL;
    495523      return;
    496524    }
    497525    Set(_p, tailRing);
    498526  }
    499 }
    500 
    501 KINLINE void sLObject::CanonicalizeP()
     527  else
     528  {
     529    pLength--;
     530  }
     531}
     532
     533KINLINE poly sLObject::CanonicalizeP()
    502534{
    503535  kTest_L(this);
     536  int i = -1;
    504537
    505538  if (bucket != NULL)
    506     kBucketCanonicalize(bucket);
     539    i = kBucketCanonicalize(bucket);
    507540
    508541  if (p == NULL)
    509542    p = k_LmInit_tailRing_2_currRing(t_p, tailRing);
     543
     544  if (i >= 0) pNext(p) = bucket->buckets[i];
     545  return p;
    510546}
    511547
     
    554590}
    555591
     592KINLINE void sLObject::Copy()
     593{
     594  if (bucket != NULL)
     595  {
     596    int i = kBucketCanonicalize(bucket);
     597    kBucket_pt new_bucket = kBucketCreate(tailRing);
     598    kBucketInit(new_bucket,
     599                p_Copy(bucket->buckets[i], tailRing),
     600                bucket->buckets_length[i]);
     601    bucket = new_bucket;
     602    if (t_p != NULL) pNext(t_p) = NULL;
     603    if (p != NULL) pNext(p) = NULL;
     604  }
     605  TObject::Copy();
     606  last = NULL;
     607}
     608
     609KINLINE poly sLObject::CopyGetP()
     610{
     611  last = NULL;
     612  if (bucket != NULL)
     613  {
     614    int i = kBucketCanonicalize(bucket);
     615    poly bp = p_Copy(bucket->buckets[i], tailRing);
     616    pLength = bucket->buckets_length[i] + 1;
     617    if (bp != NULL)
     618    {
     619      assume(t_p != NULL || p != NULL);
     620      if (t_p != NULL) pNext(t_p) = bp;
     621      else pNext(p) = bp;
     622    }
     623    bucket = NULL;
     624  }
     625  return sLObject::GetP();
     626}
     627
     628
    556629KINLINE long sLObject::pLDeg()
    557630{
     
    569642    return ::pLDeg(tp, &length, tailRing);
    570643}
     644KINLINE long sLObject::pLDeg(BOOLEAN deg_last)
     645{
     646  if (! deg_last || bucket != NULL) return sLObject::pLDeg();
     647 
     648  if (last == NULL || pLength == 0)
     649    last = pLast((t_p != NULL ? t_p : p), pLength);
     650#ifdef HAVE_ASSUME
     651  long fdeg;
     652  fdeg = ::pLDeg(GetLmTailRing(), &length, tailRing);
     653  assume (pLength == length && fdeg == ::pFDeg(last, tailRing));
     654  return fdeg;
     655#else
     656  length = pLength;
     657  return ::pFDeg(last, tailRing);
     658#endif
     659}
     660
    571661KINLINE long sLObject::SetDegStuffReturnLDeg()
    572662{
     
    576666  return d;
    577667}
    578 KINLINE long sLObject::SetLength()
    579 {
    580   // this can be improved
    581   this->pLDeg();
     668KINLINE long sLObject::SetDegStuffReturnLDeg(BOOLEAN use_last)
     669{
     670  FDeg = this->pFDeg();
     671  long d = this->pLDeg(use_last);
     672  ecart = d - FDeg;
     673  return d;
     674}
     675KINLINE int sLObject::GetpLength()
     676{
     677  if (bucket == NULL)
     678    return sTObject::GetpLength();
     679  int i = kBucketCanonicalize(bucket);
     680  return bucket->buckets_length[i] + 1;
     681}
     682KINLINE int sLObject::SetLength(BOOLEAN length_pLength)
     683{
     684  if (length_pLength)
     685    length = this->GetpLength();
     686  else
     687    this->pLDeg();
    582688  return length;
    583689}
  • Singular/kbuckets.cc

    r3d3d16 r5038cd  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: kbuckets.cc,v 1.19 2000-10-26 06:39:26 obachman Exp $ */
     4/* $Id: kbuckets.cc,v 1.20 2000-11-23 17:34:08 obachman Exp $ */
    55
    66#include "mod2.h"
     
    445445  int i, l1;
    446446  poly p1 = p;
     447  poly last;
    447448
    448449  if (*l <= 0)
     
    482483  else
    483484  {
     485    int shorter = 0;
    484486    pSetCoeff0(m, nNeg(pGetCoeff(m)));
    485     p1 = bucket->bucket_ring->p_Procs->pp_Mult_mm(p1, m, spNoether, bucket->bucket_ring);
     487    p1 = bucket->bucket_ring->p_Procs->pp_Mult_mm(p1, m, shorter, spNoether, bucket->bucket_ring, last);
    486488    pSetCoeff0(m, nNeg(pGetCoeff(m)));
     489    l1 -= shorter;
    487490  }
    488491
  • Singular/kspoly.cc

    r3d3d16 r5038cd  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: kspoly.cc,v 1.19 2000-11-14 16:04:53 obachman Exp $ */
     4/* $Id: kspoly.cc,v 1.20 2000-11-23 17:34:08 obachman Exp $ */
    55/*
    66*  ABSTRACT -  Routines for Spoly creation and reductions
     
    101101 
    102102  // and finally,
    103   PR->Tail_Minus_mm_Mult_qq(lm, t2,
    104                             (PR->bucket != NULL ? PW->GetpLength() - 1 : 0),
    105                             spNoether);
     103  PR->Tail_Minus_mm_Mult_qq(lm, t2, PW->GetpLength() - 1, spNoether);
    106104  PR->LmDeleteAndIter();
    107105  return ret;
     
    121119  poly p1 = Pair->p1;
    122120  poly p2 = Pair->p2;
     121  poly last;
    123122  Pair->tailRing = tailRing;
    124123 
     
    131130  int co=0, ct = ksCheckCoeff(&lc1, &lc2);
    132131
    133   int l1=0, l2=0;
     132  int l1=0, l2=0, shorter=0;
    134133 
    135134  if (p_GetComp(p1, currRing)!=p_GetComp(p2, currRing))
     
    155154  pSetCoeff0(m2, lc1);  // and now, m1 * LT(p1) == m2 * LT(p2)
    156155
    157   if (use_buckets && R != NULL)
    158   {
    159     l1 = (R[Pair->i_r1])->pLength - 1;
    160     l2 = (R[Pair->i_r2])->pLength - 1;
     156  if (R != NULL)
     157  {
     158    l1 = (R[Pair->i_r1])->GetpLength() - 1;
     159    l2 = (R[Pair->i_r2])->GetpLength() - 1;
    161160  }
    162161 
    163162  // get m2 * a2
    164   a2 = tailRing->p_Procs->pp_Mult_mm(a2, m2, spNoether, tailRing);
    165   Pair->SetLmTail(m2, a2, l2, use_buckets, tailRing);
     163  a2 = tailRing->p_Procs->pp_Mult_mm(a2, m2, shorter,spNoether,tailRing,last);
     164  Pair->SetLmTail(m2, a2, l2-shorter, use_buckets, tailRing, last);
    166165
    167166  // get m2*a2 - m1*a1
     
    208207  number coef;
    209208
     209  pAssume(!pHaveCommonMonoms(Red.p, With.p));
    210210  ret = ksReducePoly(&Red, &With, spNoether, &coef);
    211211 
  • Singular/kstd1.cc

    r3d3d16 r5038cd  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: kstd1.cc,v 1.65 2000-11-22 17:35:33 Singular Exp $ */
     4/* $Id: kstd1.cc,v 1.66 2000-11-23 17:34:08 obachman Exp $ */
    55/*
    66* ABSTRACT:
     
    7777//static BOOLEAN posInLOldFlag;
    7878           /*FALSE, if posInL == posInL10*/
    79 
    80 /*0 implementation*/
    81 
    82 /*2
    83 *p is a polynomial in the set s;
    84 *recompute p and its ecart e with respect to the new noether
    85 *(cut every monomial of pNext(p) above noether)
    86 */
    87 void deleteHCs (TObject* p,kStrategy strat)
    88 {
    89   poly p1;
    90   int o;
    91 
    92   if (strat->kHEdgeFound)
    93   {
    94     p1 = (*p).p;
    95     o = pFDeg(p1);
    96     while (pNext(p1) != NULL)
    97     {
    98       if (pLmCmp(pNext(p1),strat->kNoether) == -1)
    99       {
    100         pDelete(&(pNext(p1)));
    101         (*p).ecart = pLDeg((*p).p,&((*p).length))-o;
    102         p->pLength = 0;
    103       }
    104       else
    105       {
    106         pIter(p1);
    107       }
    108     }
    109   }
    110 }
    111 
    112 
     79// returns TRUE if mora should use buckets, false otherwise
     80static BOOLEAN kMoraUseBucket(kStrategy strat);
     81
     82static void kOptimizeLDeg(pFDegProc fdeg, pLDegProc ldeg, kStrategy strat)
     83{
     84  if (fdeg == pDeg)
     85  {
     86    if (ldeg == pLDeg1)
     87      pLDeg = pLDeg1_Deg;
     88    if (ldeg == pLDeg1c)
     89      pLDeg = pLDeg1c_Deg;
     90  }
     91  else if (fdeg == pTotaldegree)
     92  {
     93    if (ldeg == pLDeg1)
     94      pLDeg = pLDeg1_Totaldegree;
     95    if (ldeg == pLDeg1c)
     96      pLDeg = pLDeg1c_Totaldegree;
     97  }
     98
     99  if (strat->ak == 0 && !rIsSyzIndexRing(currRing))
     100    strat->length_pLength = TRUE;
     101   
     102  if ((ldeg == pLDeg0c && !rIsSyzIndexRing(currRing)) ||
     103      (ldeg == pLDeg0 && strat->ak == 0))
     104  {
     105    strat->LDegLast = TRUE;
     106  }
     107  else
     108  {
     109    strat->LDegLast = FALSE;
     110  }
     111}
     112
     113 
    113114static int doRed (LObject* h, TObject* with,BOOLEAN intoT,kStrategy strat)
    114115{
     
    135136    L.Copy();
    136137    h->GetP();
     138    h->SetLength(strat->length_pLength);
    137139    ret = ksReducePoly(&L, with, strat->kNoether, NULL, strat);
    138140    if (ret)
     
    158160}
    159161
    160 #if 0
    161 /*2
    162 * reduces h with elements from T choosing first possible
    163 * element in T with respect to the given ecart
    164 */
    165162int redEcart (LObject* h,kStrategy strat)
    166163{
     
    169166  int j = 0;
    170167  int pass = 0;
    171   unsigned long not_sev;
    172 
    173   d = pFDeg((*h).p)+(*h).ecart;
    174   reddeg = strat->LazyDegree+d;
    175   h->sev = pGetShortExpVector(h->p);
    176   not_sev = ~ h->sev;
    177   loop
    178   {
    179     if (j > strat->tl)
    180     {
    181       if (strat->honey) pLDeg((*h).p,&((*h).length));
    182       return 1;
    183     }
    184     if (pLmShortDivisibleBy(strat->T[j].p, strat->sevT[j], (*h).p, not_sev))
    185     {
    186       //if (strat->interpt) test_int_std(strat->kIdeal);
    187       /*- compute the s-polynomial -*/
    188       pi = strat->T[j].p;
    189       ei = strat->T[j].ecart;
    190       li = strat->T[j].length;
    191       ii = j;
    192       /*
    193       * the polynomial to reduce with (up to the moment) is;
    194       * pi with ecart ei and length li
    195       */
    196       i = j;
    197       loop
    198       {
    199       /*- takes the first possible with respect to ecart -*/
    200         if (ei <= (*h).ecart) break;
    201         i++;
    202         if (i > strat->tl) break;
    203         if ((((strat->T[i]).ecart < ei)
    204           || (((strat->T[i]).ecart == ei)
    205           && ((strat->T[i]).length < li)))
    206           && pLmShortDivisibleBy(strat->T[i].p, strat->sevT[i],
    207                                (*h).p, not_sev))
    208         {
    209           /*
    210            * the polynomial to reduce with is now;
    211            */
    212           pi = strat->T[i].p;
    213           ei = strat->T[i].ecart;
    214           li = strat->T[i].length;
    215           ii = i;
    216         }
    217       }
    218       /*
    219       * end of search: have to reduce with pi
    220       */
    221       if (ei > (*h).ecart)
    222       {
    223         /*
    224         * It is not possible to reduce h with smaller ecart;
    225         * if possible h goes to the lazy-set L,i.e
    226         * if its position in L would be not the last one
    227         */
    228         strat->fromT = TRUE;
    229         if (strat->Ll >= 0) /*- L is not empty -*/
    230         {
    231           if (strat->honey) pLDeg((*h).p,&((*h).length));
    232           at = strat->posInL(strat->L,strat->Ll,(*h),strat);
    233           if (at <= strat->Ll)
    234           {
    235             /*- h will not become the next element to reduce -*/
    236             enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
    237             if (TEST_OPT_DEBUG) Print(" ecart too big; -> L%d\n",at);
    238             (*h).p = NULL;
    239             strat->fromT = FALSE;
    240             return -1;
    241           }
    242         }
    243       }
    244       doRed(h,&(strat->T[ii]),strat->fromT,strat);
    245       strat->fromT=FALSE;
    246       if ((*h).p == NULL)
    247       {
    248         if (h->lcm!=NULL) pLmFree((*h).lcm);
    249         return 0;
    250       }
    251       h->sev = pGetShortExpVector(h->p);
    252       not_sev = ~ h->sev;
    253       /*computes the ecart*/
    254       if (strat->honey)
    255       {
    256         if (ei <= (*h).ecart)
    257           (*h).ecart = d-pFDeg((*h).p);
    258         else
    259           (*h).ecart = d-pFDeg((*h).p)+ei-(*h).ecart;
    260         // pLDeg((*h).p,&((*h).length));
    261         //(*h).length = pLength((*h).p);
    262       }
    263       else
    264         (*h).ecart = pLDeg((*h).p,&((*h).length))-pFDeg((*h).p);
    265       if (strat->syzComp!=0)
    266       {
    267         if ((strat->syzComp>0) && (pMinComp((*h).p) > strat->syzComp))
    268         {
    269           if (TEST_OPT_DEBUG) PrintS(" > syzComp\n");
    270           return -2;
    271         }
    272 
    273       }
    274       /*- try to reduce the s-polynomial -*/
    275       pass++;
    276       d = pFDeg((*h).p)+(*h).ecart;
    277       /*
    278       *test whether the polynomial should go to the lazyset L
    279       *-if the degree jumps
    280       *-if the number of pre-defined reductions jumps
    281       */
    282       if ((strat->Ll >= 0)
    283       && ((d >= reddeg) || (pass > strat->LazyPass)))
    284       {
    285         if (strat->honey) pLDeg((*h).p,&((*h).length));
    286         at = strat->posInL(strat->L,strat->Ll,*h,strat);
    287         if (at <= strat->Ll)
    288         {
    289           i=strat->sl+1;
    290           do
    291           {
    292             i--;
    293             if (i<0) return 1;
    294           } while (!pLmShortDivisibleBy(strat->S[i], strat->sevS[i],
    295                                       (*h).p, not_sev));
    296           enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
    297           if (TEST_OPT_DEBUG) Print(" degree jumped; ->L%d\n",at);
    298           (*h).p = NULL;
    299           return -1;
    300         }
    301       }
    302       else if ((TEST_OPT_PROT) && (strat->Ll < 0) && (d >= reddeg))
    303       {
    304         Print(".%d",d);mflush();
    305         reddeg = d+1;
    306       }
    307       j = 0;
    308     }
    309     else
    310     {
    311       j++;
    312     }
    313   }
    314 }
    315 #else
    316 int redEcart (LObject* h,kStrategy strat)
    317 {
    318   poly pi;
    319   int i,at,reddeg,d,ei,li,ii;
    320   int j = 0;
    321   int pass = 0;
    322168
    323169  d = h->GetpFDeg()+ h->ecart;
     
    329175    if (j < 0)
    330176    {
    331       if (strat->honey) h->SetLength();
     177      if (strat->honey) h->SetLength(strat->length_pLength);
    332178      return 1;
    333179    }
     
    347193        /*- takes the first possible with respect to ecart -*/
    348194        i++;
    349 //        i = kFindDivisibleByInT(strat->T, strat->sevT, strat->tl, h, i);
     195#if 1
    350196        if (i > strat->tl) break;
    351197        if ((strat->T[i].ecart < ei || (strat->T[i].ecart == ei &&
     
    353199            &&
    354200            pLmShortDivisibleBy(strat->T[i].p, strat->sevT[i], h->p, ~h->sev))
     201#else
     202          j = kFindDivisibleByInT(strat->T, strat->sevT, strat->tl, h, i);
     203        if (j < 0) break;
     204        i = j;
     205        if (strat->T[i].ecart < ei || (strat->T[i].ecart == ei &&
     206                                        strat->T[i].length < li))
     207#endif
    355208        {
    356209          // the polynomial to reduce with is now
     
    373226      {
    374227        h->SetLmCurrRing();
    375         if (strat->honey) h->SetLength();
     228        if (strat->honey && strat->posInLDependsOnLength)
     229          h->SetLength(strat->length_pLength);
    376230        assume(h->FDeg == h->pFDeg());
    377         at = strat->posInL(strat->L,strat->Ll,(*h),strat);
     231        at = strat->posInL(strat->L,strat->Ll,h,strat);
    378232        if (at <= strat->Ll)
    379233        {
     234          h->CanonicalizeP();
    380235          /*- h will not become the next element to reduce -*/
    381           h->CanonicalizeP();
    382236          enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
    383237#ifdef KDEBUG
     
    415269    else
    416270      // this has the side effect of setting h->length
    417       h->ecart = h->pLDeg() - h->GetpFDeg();
     271      h->ecart = h->pLDeg(strat->LDegLast) - h->GetpFDeg();
    418272
    419273    if (strat->syzComp!=0)
     
    440294    {
    441295      h->SetLmCurrRing();
    442       if (strat->honey) h->SetLength();
     296      if (strat->honey && strat->posInLDependsOnLength)
     297        h->SetLength(strat->length_pLength);
    443298      assume(h->FDeg == h->pFDeg());
    444       at = strat->posInL(strat->L,strat->Ll,*h,strat);
     299      at = strat->posInL(strat->L,strat->Ll,h,strat);
    445300      if (at <= strat->Ll)
    446301      {
    447302        if (kFindDivisibleByInS(strat->S, strat->sevS, strat->sl, h) < 0)
     303        {
     304          if (strat->honey && !strat->posInLDependsOnLength)
     305            h->SetLength(strat->length_pLength);
    448306          return 1;
     307        }
    449308        h->CanonicalizeP();
    450309        enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
     
    463322  }
    464323}
    465 #endif
    466324
    467325/*2
     
    488346    if (j < 0)
    489347    {
    490       if (! strat->homog)
    491         h->SetDegStuffReturnLDeg();
     348      if (strat->homog)
     349        h->SetDegStuffReturnLDeg(strat->LDegLast);
    492350      return 1;
    493351    }
     
    529387        if (TEST_OPT_DEBUG) PrintS(" > syzComp\n");
    530388#endif
     389        if (strat->homog)
     390          h->SetDegStuffReturnLDeg(strat->LDegLast);
    531391        return -2;
    532392      }
     
    534394    if (!strat->homog)
    535395    {
    536       d = h->SetDegStuffReturnLDeg();
     396      d = h->SetDegStuffReturnLDeg(strat->LDegLast);
    537397      /*- try to reduce the s-polynomial -*/
    538398      pass++;
     
    546406      {
    547407        h->SetLmCurrRing();
    548         at = strat->posInL(strat->L,strat->Ll,*h,strat);
     408        at = strat->posInL(strat->L,strat->Ll,h,strat);
    549409        if (at <= strat->Ll)
    550410        {
     
    579439  int j = 0;
    580440  int z = 10;
    581   int o = pFDeg(h);
     441  int o = H.SetpFDeg();
    582442  H.ecart = pLDeg(H.p,&H.length)-o;
    583443  if (flag==0) cancelunit(&H);
     
    657517      }
    658518      /*- try to reduce the s-polynomial -*/
    659       o = pFDeg(H.p);
     519      o = H.SetpFDeg();
    660520      cancelunit(&H);
    661521      H.ecart = pLDeg(H.p,&(H.length))-o;
     
    681541  for (i=1; i<=strat->Ll; i++)
    682542  {
    683     at = strat->posInL(strat->L,i-1,strat->L[i],strat);
     543    at = strat->posInL(strat->L,i-1,&(strat->L[i]),strat);
    684544    if (at != i)
    685545    {
     
    762622*(should be minimal)
    763623*/
    764 BOOLEAN hasPurePower (poly p,int last, int *length,kStrategy strat)
     624BOOLEAN hasPurePower (const poly p,int last, int *length,kStrategy strat)
    765625{
    766626  poly h;
     
    769629  if (pNext(p) == strat->tail)
    770630    return FALSE;
    771   if (pMinComp(p) == strat->ak)
    772   {
    773     *length = 0;
    774     h = p;
     631  pp_Test(p, currRing, strat->tailRing);
     632  if (p_MinComp(p, currRing, strat->tailRing) == strat->ak)
     633  {
     634    i = p_IsPurePower(p, currRing);
     635    if (i == last)
     636    {
     637      *length = 0;
     638      return TRUE;
     639    }
     640    *length = 1;
     641    h = pNext(p);
    775642    while (h != NULL)
    776643    {
    777       i = pIsPurePower(h);
     644      i = p_IsPurePower(h, strat->tailRing);
    778645      if (i==last) return TRUE;
    779646      (*length)++;
     
    782649  }
    783650  return FALSE;
     651}
     652
     653BOOLEAN hasPurePower (LObject *L,int last, int *length,kStrategy strat)
     654{
     655  if (L->bucket != NULL)
     656  {
     657    poly p = L->CanonicalizeP();
     658    BOOLEAN ret = hasPurePower(p, last, length, strat);
     659    pNext(p) = NULL;
     660    return ret;
     661  }
     662  else
     663  {
     664    return hasPurePower(L->p, last, length, strat);
     665  }
    784666}
    785667
     
    788670* in the case of looking for the pure powers
    789671*/
    790 int posInL10 (LSet const set, int length, const LObject &p,kStrategy const strat)
     672int posInL10 (LSet const set, int length, LObject* p,kStrategy const strat)
    791673{
    792674  int j,dp,dL;
    793675
    794676  if (length<0) return 0;
    795   if (hasPurePower(p.p,strat->lastAxis,&dp,strat))
    796   {
    797     int op= pFDeg(p.p)+p.ecart;
     677  if (hasPurePower(p,strat->lastAxis,&dp,strat))
     678  {
     679    int op= p->GetpFDeg() +p->ecart;
    798680    for (j=length; j>=0; j--)
    799681    {
    800       if (!hasPurePower(set[j].p,strat->lastAxis,&dL,strat))
     682      if (!hasPurePower(&(set[j]),strat->lastAxis,&dL,strat))
    801683        return j+1;
    802684      if (dp < dL)
    803685        return j+1;
    804686      if ((dp == dL)
    805       && (pFDeg(set[j].p)+set[j].ecart >= op))
     687          && (set[j].GetpFDeg()+set[j].ecart >= op))
    806688        return j+1;
    807689    }
     
    811693  {
    812694    if (j<0) break;
    813     if (!hasPurePower(set[j].p,strat->lastAxis,&dL,strat)) break;
     695    if (!hasPurePower(&(set[j]),strat->lastAxis,&dL,strat)) break;
    814696    j--;
    815697  }
    816698  return strat->posInLOld(set,j,p,strat);
    817699}
     700
    818701
    819702/*2
     
    828711  {
    829712    if (j<0) break;
    830     if (hasPurePower(strat->L[j].p,strat->lastAxis,&dL,strat))
     713    if (hasPurePower(&(strat->L[j]),strat->lastAxis,&dL,strat))
    831714    {
    832715      p=strat->L[strat->Ll];
     
    846729      {
    847730        pLmFree(strat->L[j].p);    /*deletes the short spoly and computes*/
    848         strat->L[j].p=ksOldCreateSpoly(strat->L[j].p1,
    849                                     strat->L[j].p2,
    850                                     strat->kNoether);   /*the real one*/
     731        poly m1 = NULL, m2 = NULL;
     732        // check that spoly creation is ok
     733        while (strat->tailRing != currRing &&
     734               !kCheckSpolyCreation(&(strat->L[j]), strat, m1, m2))
     735        {
     736          assume(m1 == NULL && m2 == NULL);
     737          // if not, change to a ring where exponents are at least
     738          // large enough
     739          kStratChangeTailRing(strat);
     740        }
     741        /* create the real one */
     742        ksCreateSpoly(&(strat->L[j]), strat->kNoether, FALSE,
     743                      strat->tailRing, m1, m2, strat->R);
     744
    851745        if (!strat->honey)
    852746          strat->initEcart(&strat->L[j]);
    853747        else
    854           strat->L[j].length = pLength(strat->L[j].p);
    855         if (hasPurePower(strat->L[j].p,strat->lastAxis,&dL,strat))
     748          strat->L[j].SetLength(strat->length_pLength);
     749       
     750        BOOLEAN pp = hasPurePower(&(strat->L[j]),strat->lastAxis,&dL,strat);
     751       
     752        if (strat->use_buckets) strat->L[j].PrepareRed(TRUE);
     753       
     754        if (pp)
    856755        {
    857756          p=strat->L[strat->Ll];
     
    873772{
    874773  int i = 0;
     774  kTest_TS(strat);
    875775  while (i <= strat->Ll)
    876776  {
     
    886786      {
    887787        pLmFree(strat->L[i].p);
    888         strat->L[i].p = ksOldCreateSpoly(strat->L[i].p1,
    889                                          strat->L[i].p2,
    890                                          strat->kNoether);
     788        poly m1 = NULL, m2 = NULL;
     789        // check that spoly creation is ok
     790        while (strat->tailRing != currRing &&
     791               !kCheckSpolyCreation(&(strat->L[i]), strat, m1, m2))
     792        {
     793          assume(m1 == NULL && m2 == NULL);
     794          // if not, change to a ring where exponents are at least
     795          // large enough
     796          kStratChangeTailRing(strat);
     797        }
     798        /* create the real one */
     799        ksCreateSpoly(&(strat->L[i]), strat->kNoether, FALSE,
     800                      strat->tailRing, m1, m2, strat->R);
    891801        strat->L[i].SetpFDeg();
    892         strat->L[i].ecart = pLDeg(strat->L[i].p,&strat->L[i].length)
    893                            -strat->L[i].GetpFDeg();
     802        strat->L[i].ecart
     803          = strat->L[i].pLDeg(strat->LDegLast) - strat->L[i].GetpFDeg();
     804        if (strat->use_buckets) strat->L[i].PrepareRed(TRUE);
    894805      }
    895806    }
    896807    else
    897       deleteHC(&strat->L[i].p,&strat->L[i].ecart,&strat->L[i].length,strat);
    898    if (strat->L[i].p == NULL)
     808      deleteHC(&(strat->L[i]), strat);
     809   if (strat->L[i].IsNull())
    899810      deleteInL(strat->L,&strat->Ll,i,strat);
    900811    else
     812    {
     813#ifdef KDEBUG
     814      kTest_L(&(strat->L[i]), strat->tailRing, TRUE, i, strat->T, strat->tl);
     815#endif
    901816      i++;
    902   }
     817    }
     818  }
     819  kTest_TS(strat);
    903820}
    904821
     
    914831  {
    915832    p = strat->T[i];
    916     deleteHCs(&p,strat);
     833    deleteHC(&p,strat, TRUE);
    917834    /*- tries to cancel a unit: -*/
    918835    cancelunit(&p);
     
    934851  if (strat->update)
    935852  {
     853    kTest_TS(strat);
    936854    strat->update = (strat->tl == -1);
    937855    if (TEST_OPT_WEIGHTM)
     
    951869      }
    952870      pLDeg=pLDegOld;
     871      kOptimizeLDeg(pFDeg, pLDeg, strat);
    953872      if (ecartWeights)
    954873      {
     
    965884      return;
    966885    if (!BTEST1(20))        /*- take the first possible -*/
     886    {
    967887      strat->red = redFirst;
     888      strat->use_buckets = kMoraUseBucket(strat);
     889    }
    968890    updateT(strat);
    969891    strat->posInT = posInT2;
    970892    reorderT(strat);
    971893  }
     894  kTest_TS(strat);
    972895}
    973896
     
    1022945        strat->posInLOldFlag = FALSE;
    1023946        strat->posInL = posInL10;
     947        strat->posInLDependsOnLength = TRUE;
    1024948        updateL(strat);
    1025949        reorderL(strat);
     
    11041028    mflush();
    11051029  }
    1106 }
     1030  kOptimizeLDeg(pFDeg, pLDeg, strat);
     1031}
     1032
     1033#ifdef HAVE_ASSUME
     1034static int mora_count = 0;
     1035static int mora_loop_count;
     1036#endif
    11071037
    11081038ideal mora (ideal F, ideal Q,intvec *w,intvec *hilb,kStrategy strat)
    11091039{
     1040#ifdef HAVE_ASSUME
     1041  mora_count++;
     1042  mora_loop_count = 0;
     1043#endif
     1044#ifdef KDEBUG
     1045  om_Opts.MinTrack = 5;
     1046#endif
    11101047  int srmax;
    11111048  int lrmax = 0;
     
    11431080  }
    11441081  srmax = strat->sl;
     1082  kTest_TS(strat);
     1083  strat->use_buckets = kMoraUseBucket(strat);
    11451084  /*- compute-------------------------------------------*/
    11461085  while (strat->Ll >= 0)
    11471086  {
    1148     kTest_TS(strat);
     1087#ifdef HAVE_ASSUME
     1088    mora_loop_count++;
     1089#endif
    11491090    if (lrmax< strat->Ll) lrmax=strat->Ll; /*stat*/
    11501091    //test_int_std(strat->kIdeal);
    11511092    if (TEST_OPT_DEBUG) messageSets(strat);
    11521093    if (TEST_OPT_DEGBOUND
    1153     && (strat->L[strat->Ll].ecart+pFDeg(strat->L[strat->Ll].p)> Kstd1_deg))
     1094    && (strat->L[strat->Ll].ecart+strat->L[strat->Ll].GetpFDeg()> Kstd1_deg))
    11541095    {
    11551096      /*
     
    11591100      */
    11601101      while ((strat->Ll >= 0)
    1161         && (strat->L[strat->Ll].ecart+pFDeg(strat->L[strat->Ll].p)> Kstd1_deg)
     1102        && (strat->L[strat->Ll].ecart+strat->L[strat->Ll].GetpFDeg()> Kstd1_deg)
    11621103        && (strat->L[strat->Ll].p1!=NULL) && (strat->L[strat->Ll].p2!=NULL))
    11631104      {
     
    11731114    if (strat->Ll==0) strat->interpt=TRUE;
    11741115    strat->Ll--;
     1116
     1117    // create the real Spoly
    11751118    if (pNext(strat->P.p) == strat->tail)
    11761119    {
    1177       pLmFree(strat->P.p);/*- deletes the short spoly and computes -*/
    1178       strat->P.p = ksOldCreateSpoly(strat->P.p1,
    1179                                     strat->P.p2,
    1180                                     strat->kNoether);/*- the real one -*/
    1181       if (!strat->honey)
     1120      /*- deletes the short spoly and computes -*/
     1121      pLmFree(strat->P.p);
     1122      strat->P.p = NULL;
     1123      poly m1 = NULL, m2 = NULL;
     1124      // check that spoly creation is ok
     1125      while (strat->tailRing != currRing &&
     1126             !kCheckSpolyCreation(&(strat->P), strat, m1, m2))
     1127      {
     1128        assume(m1 == NULL && m2 == NULL);
     1129        // if not, change to a ring where exponents are large enough
     1130        kStratChangeTailRing(strat);
     1131      }
     1132      /* create the real one */
     1133      ksCreateSpoly(&(strat->P), strat->kNoether, strat->use_buckets,
     1134                    strat->tailRing, m1, m2, strat->R);
     1135      if (!strat->use_buckets)
     1136        strat->P.SetLength(strat->length_pLength);
     1137    }
     1138    else if (strat->P.p1 == NULL)
     1139    {
     1140      // for input polys, prepare reduction
     1141      strat->P.SetLength(strat->length_pLength);
     1142      strat->P.PrepareRed(strat->use_buckets);
     1143    }
     1144   
     1145
     1146    if (TEST_OPT_PROT)
     1147      message(strat->P.ecart+strat->P.GetpFDeg(),&olddeg,&reduc,strat);
     1148
     1149    strat->red(&strat->P,strat);/*- reduction of the element choosen from L -*/
     1150
     1151    if (strat->P.p != NULL)
     1152    {
     1153      strat->P.GetP();
     1154      assume(strat->P.sev == 0 || strat->P.sev == pGetShortExpVector(strat->P.p));
     1155      if (TEST_OPT_PROT) PrintS("s");/*- statistic -*/
     1156      /*- enter P.p into s and b: -*/
     1157      if (!TEST_OPT_INTSTRATEGY)
     1158        strat->P.pNorm();
     1159
     1160      strat->P.p = redtail(strat->P.p,strat->sl,strat);
     1161      if (strat->redTailChange)
     1162      {
     1163        strat->P.pLength = 0;
     1164        strat->P.last = NULL;
     1165      }
     1166     
     1167      if ((!strat->noTailReduction) && (!strat->honey))
     1168      {
    11821169        strat->initEcart(&strat->P);
    1183       else
    1184         strat->P.length = pLength(strat->P.p);
    1185     }
    1186     {
    1187       if (TEST_OPT_PROT) message(strat->P.ecart+(strat->P.p == NULL ? 0 : pFDeg(strat->P.p)),&olddeg,&reduc,strat);
    1188       strat->red(&strat->P,strat);/*- reduction of the element choosen from L -*/
    1189     }
    1190     if (strat->P.p != NULL)
    1191     {
    1192       assume(strat->P.sev == 0 || strat->P.sev == pGetShortExpVector(strat->P.p));
    1193           if (TEST_OPT_PROT) PrintS("s");/*- statistic -*/
    1194           /*- enter P.p into s and b: -*/
    1195           if (!TEST_OPT_INTSTRATEGY)
    1196           {
    1197             pNorm(strat->P.p);
    1198           }
    1199           strat->P.p = redtail(strat->P.p,strat->sl,strat);
    1200           if ((!strat->noTailReduction) && (!strat->honey))
    1201           {
    1202             strat->initEcart(&strat->P);
    1203           }
    1204           if (TEST_OPT_INTSTRATEGY)
    1205           {
    1206             //pContent(strat->P.p);
    1207             pCleardenom(strat->P.p);// also does a pContent
    1208           }
    1209           cancelunit(&strat->P);/*- tries to cancel a unit -*/
    1210           enterT(strat->P,strat);
    1211           {
    1212             int pos;
    1213             {
    1214               enterpairs(strat->P.p,strat->sl,strat->P.ecart,0,strat);
    1215               if (strat->sl==-1)
    1216               {
    1217                 pos=0;
    1218               }
    1219               else
    1220               {
    1221                 pos = posInS(strat->S,strat->sl,strat->P.p);
    1222               }
    1223               strat->enterS(strat->P,pos,strat, strat->tl);
    1224             }
    1225             if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat);
    1226           }
    1227           kTest_TS(strat);
    1228           if (strat->P.lcm!=NULL) pLmFree(strat->P.lcm);
    1229           strat->P.lcm=NULL;
     1170      }
     1171      if (TEST_OPT_INTSTRATEGY)
     1172        strat->P.pCleardenom();
     1173      cancelunit(&strat->P);/*- tries to cancel a unit -*/
     1174      enterT(strat->P,strat);
     1175      int pos;
     1176      {
     1177        enterpairs(strat->P.p,strat->sl,strat->P.ecart,0,strat, strat->tl);
     1178        if (strat->sl==-1)
     1179        {
     1180          pos=0;
     1181        }
     1182        else
     1183        {
     1184          pos = posInS(strat->S,strat->sl,strat->P.p);
     1185        }
     1186        strat->enterS(strat->P,pos,strat, strat->tl);
     1187      }
     1188      if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat);
     1189      if (strat->P.lcm!=NULL) pLmFree(strat->P.lcm);
     1190      strat->P.lcm=NULL;
    12301191#ifdef KDEBUG
    12311192      memset(&strat->P,0,sizeof(strat->P));
     
    12501211      }
    12511212    }
     1213    kTest_TS(strat);
    12521214  }
    12531215  /*- complete reduction of the standard basis------------------------ -*/
     
    13561318    h.length = pLength(h.p);
    13571319    h.sev = strat->sevS[i];
     1320    h.SetpFDeg();
    13581321    enterT(h,strat);
    13591322  }
     
    14801443          h.p = strat->S[j];
    14811444          h.ecart = strat->ecartS[j];
    1482           h.length = pLength(h.p);
     1445          h.pLength = h.length = pLength(h.p);
    14831446          if (strat->sevS[j] == 0) strat->sevS[j] = pGetShortExpVector(h.p);
    14841447          else assume(strat->sevS[j] == pGetShortExpVector(h.p));
    14851448          h.sev = strat->sevS[j];
    1486           h.length = pLength(h.p);
     1449          h.SetpFDeg();
    14871450          enterT(h,strat);
    14881451        }
     
    18731836  return shdl;
    18741837}
     1838
     1839// returns TRUE if mora should use buckets, false otherwise
     1840static BOOLEAN kMoraUseBucket(kStrategy strat)
     1841{
     1842  if (TEST_OPT_NOT_BUCKETS)
     1843    return FALSE;
     1844  if (strat->red == redFirst)
     1845  {
     1846    if (strat->homog && !strat->syzComp)
     1847      return TRUE;
     1848    else
     1849      return FALSE;
     1850  }
     1851  else
     1852  {
     1853    assume(strat->red == redEcart);
     1854    if (strat->honey && !strat->syzComp)
     1855      return TRUE;
     1856    else
     1857      return FALSE;
     1858  }
     1859}
  • Singular/kstd2.cc

    r3d3d16 r5038cd  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: kstd2.cc,v 1.61 2000-11-16 09:54:50 obachman Exp $ */
     4/* $Id: kstd2.cc,v 1.62 2000-11-23 17:34:09 obachman Exp $ */
    55/*
    66*  ABSTRACT -  Kernel: alg. of Buchberger
     
    3131//        number of first divisor, otherwise
    3232int kFindDivisibleByInT(const TSet &T, const unsigned long* sevT,
    33                         const int tl, const LObject* L)
     33                        const int tl, const LObject* L, int start)
    3434{
    3535  unsigned long not_sev = ~L->sev;
    36   int j = 0;
     36  int j = start;
    3737  poly p;
    3838  ring r;
     
    7575    }
    7676  }
    77   return -1;
    7877}
    7978
     
    108107static int redHomog (LObject* h,kStrategy strat)
    109108{
    110   if (strat->tl<0) return 1;
     109//  if (strat->tl<0) return 1;
    111110#ifdef KDEBUG
    112111  if (TEST_OPT_DEBUG)
     
    123122    h->SetShortExpVector();
    124123    j = kFindDivisibleByInT(strat->T, strat->sevT, strat->tl, h);
    125     if (j < 0) return 1;
     124    if (j < 0)
     125    {
     126      h->SetpFDeg();
     127      return 1;
     128    }
    126129   
    127130    // now we found one which is divisible -- reduce it
     
    131134    if (TEST_OPT_DEBUG)
    132135    {
    133       Print("\n%pto ", h->t_p);
     136      Print("\nto ", h->t_p);
    134137      h->wrp();
    135138      PrintLn();
     
    159162  int pass = 0;
    160163  assume(h->pFDeg() == h->FDeg);
    161   int reddeg = h->FDeg;
     164  long reddeg = h->GetpFDeg();
    162165
    163166  h->SetShortExpVector();
     
    203206    {
    204207      h->SetLmCurrRing();
    205       at = posInL11(strat->L,strat->Ll,*h,strat);
     208      at = posInL11(strat->L,strat->Ll,h,strat);
    206209      if (at <= strat->Ll)
    207210      {
     
    236239
    237240  poly h_p;
    238   int i,j,at,reddeg,d,pass,ei, ii, h_d;
     241  int i,j,at,pass,ei, ii, h_d;
    239242  unsigned long not_sev;
    240 
     243  long reddeg,d;
     244 
    241245  pass = j = 0;
    242   d = reddeg = h->FDeg + h->ecart;
     246  d = reddeg = h->GetpFDeg() + h->ecart;
    243247  h->SetShortExpVector();
    244248  h_p = h->GetLmTailRing();
     
    289293      if (strat->Ll >= 0) /* L is not empty */
    290294      {
    291         at = strat->posInL(strat->L,strat->Ll,*h,strat);
     295        at = strat->posInL(strat->L,strat->Ll,h,strat);
    292296
    293297        if(at <= strat->Ll)
     
    354358    {
    355359      h->SetLmCurrRing();
    356       at = strat->posInL(strat->L,strat->Ll,*h,strat);
     360      at = strat->posInL(strat->L,strat->Ll,h,strat);
    357361      if (at <= strat->Ll)
    358362      {
     
    483487}
    484488
     489#ifdef KDEBUG
     490static int bba_count = 0;
     491#endif
     492
    485493ideal bba (ideal F, ideal Q,intvec *w,intvec *hilb,kStrategy strat)
    486494{
     495#ifdef KDEBUG
     496  bba_count++;
     497  int loop_count = 0;
     498#endif
    487499  om_Opts.MinTrack = 5;
    488500  int   srmax,lrmax, red_result;
     
    500512  reduc = olddeg = lrmax = 0;
    501513
    502   if (!TEST_OPT_NOT_BUCKETS &&
    503       (strat->red == redHomog || strat->red == redHoney))
     514  if (!TEST_OPT_NOT_BUCKETS)
    504515    strat->use_buckets = 1;
    505516
     
    515526    if (strat->Ll > lrmax) lrmax =strat->Ll;/*stat.*/
    516527#ifdef KDEBUG
     528    loop_count++;
    517529    if (TEST_OPT_DEBUG) messageSets(strat);
    518530#endif
     
    536548    if (pNext(strat->P.p) == strat->tail)
    537549    {
     550      // deletes the short spoly
     551      pLmFree(strat->P.p);
     552      strat->P.p = NULL;
    538553      poly m1 = NULL, m2 = NULL;
    539       /* check that spoly creation is ok */
     554
     555      // check that spoly creation is ok
    540556      while (strat->tailRing != currRing &&
    541              !kCheckSpolyCreation(strat, m1, m2))
     557             !kCheckSpolyCreation(&(strat->P), strat, m1, m2))
    542558      {
    543559        assume(m1 == NULL && m2 == NULL);
     
    546562        kStratChangeTailRing(strat);
    547563      }
    548       /* deletes the short spoly and computes */
    549       pLmFree(strat->P.p);
    550       strat->P.p=NULL;
    551       /* create the real one */
     564      // create the real one
    552565      ksCreateSpoly(&(strat->P), strat->kNoether, strat->use_buckets,
    553566                    strat->tailRing, m1, m2, strat->R);
    554567    }
    555 
    556     if  ((strat->P.p1==NULL) && (strat->minim>0))
    557       strat->P.p2=p_Copy(strat->P.p, currRing, strat->tailRing);
    558 
     568    else if (strat->P.p1 == NULL)
     569    {
     570      if (strat->minim > 0)
     571        strat->P.p2=p_Copy(strat->P.p, currRing, strat->tailRing);
     572      // for input polys, prepare reduction
     573      strat->P.PrepareRed(strat->use_buckets);
     574    }
     575   
    559576    if (TEST_OPT_PROT)
    560577      message((strat->honey ? strat->P.ecart : 0) + strat->P.pFDeg(),
     
    569586      /* statistic */
    570587      if (TEST_OPT_PROT) PrintS("s");
     588
     589      // get the polynomial (canonicalize bucket, make sure P.p is set)
    571590      strat->P.GetP(strat->lmBin);
    572       /* enter P.p into s and L */
    573       {
    574         int pos=posInS(strat->S,strat->sl,strat->P.p);
    575         if (TEST_OPT_INTSTRATEGY)
     591
     592      int pos=posInS(strat->S,strat->sl,strat->P.p);
     593
     594      // reduce the tail and normailze poly
     595      if (TEST_OPT_INTSTRATEGY)
     596      {
     597        strat->P.pCleardenom();
     598        if ((TEST_OPT_REDSB)||(TEST_OPT_REDTAIL))
    576599        {
     600          strat->P.p = redtailBba(&(strat->P),pos-1,strat);
     601          if (strat->redTailChange)  strat->P.pLength = 0;
    577602          strat->P.pCleardenom();
    578           if ((TEST_OPT_REDSB)||(TEST_OPT_REDTAIL))
    579           {
    580             strat->P.p = redtailBba(&(strat->P),pos-1,strat);
    581             if (strat->redTailChange)  strat->P.pLength = 0;
    582             strat->P.pCleardenom();
    583           }
     603        }
     604      }
     605      else
     606      {
     607        strat->P.pNorm();
     608        if ((TEST_OPT_REDSB)||(TEST_OPT_REDTAIL))
     609        {
     610          strat->P.p = redtailBba(&(strat->P),pos-1,strat);
     611          if (strat->redTailChange)  strat->P.pLength = 0;
     612        }
     613      }
     614
     615#ifdef KDEBUG
     616      if (TEST_OPT_DEBUG){PrintS("new s:");strat->P.wrp();PrintLn();}
     617#endif
     618
     619      // min_std stuff
     620      if ((strat->P.p1==NULL) && (strat->minim>0))
     621      {
     622        if (strat->minim==1)
     623        {
     624          strat->M->m[minimcnt]=p_Copy(strat->P.p,currRing,strat->tailRing);
     625          p_Delete(&strat->P.p2, currRing, strat->tailRing);
    584626        }
    585627        else
    586628        {
    587           strat->P.pNorm();
    588           if ((TEST_OPT_REDSB)||(TEST_OPT_REDTAIL))
    589           {
    590             strat->P.p = redtailBba(&(strat->P),pos-1,strat);
    591             if (strat->redTailChange)  strat->P.pLength = 0;
    592           }
     629          strat->M->m[minimcnt]=strat->P.p2;
     630          strat->P.p2=NULL;
    593631        }
    594 #ifdef KDEBUG
    595         if (TEST_OPT_DEBUG){PrintS("new s:");strat->P.wrp();PrintLn();}
    596 #endif
    597         if ((strat->P.p1==NULL) && (strat->minim>0))
    598         {
    599           if (strat->minim==1)
    600           {
    601             strat->M->m[minimcnt]=p_Copy(strat->P.p,currRing,strat->tailRing);
    602             p_Delete(&strat->P.p2, currRing, strat->tailRing);
    603           }
    604           else
    605           {
    606             strat->M->m[minimcnt]=strat->P.p2;
    607             strat->P.p2=NULL;
    608           }
    609           if (strat->tailRing!=currRing && pNext(strat->M->m[minimcnt])!=NULL)
    610             pNext(strat->M->m[minimcnt])
    611               = strat->p_shallow_copy_delete(pNext(strat->M->m[minimcnt]),
    612                                              strat->tailRing, currRing,
    613                                              currRing->PolyBin);
    614           minimcnt++;
    615         }
    616 
    617         // put stuff into T-Set
    618         enterT(strat->P, strat);
    619         enterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl);
    620         // posInS only depends on the leading term
    621         strat->enterS(strat->P, pos, strat, strat->tl);
    622         if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat);
    623       }
     632        if (strat->tailRing!=currRing && pNext(strat->M->m[minimcnt])!=NULL)
     633          pNext(strat->M->m[minimcnt])
     634            = strat->p_shallow_copy_delete(pNext(strat->M->m[minimcnt]),
     635                                           strat->tailRing, currRing,
     636                                           currRing->PolyBin);
     637        minimcnt++;
     638      }
     639
     640      // enter into S, L, and T
     641      enterT(strat->P, strat);
     642      enterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl);
     643      // posInS only depends on the leading term
     644      strat->enterS(strat->P, pos, strat, strat->tl);
     645      if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat);
    624646      if (strat->P.lcm!=NULL) pLmFree(strat->P.lcm);
    625647      if (strat->sl>srmax) srmax = strat->sl;
  • Singular/kutil.cc

    r3d3d16 r5038cd  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: kutil.cc,v 1.78 2000-11-16 09:54:51 obachman Exp $ */
     4/* $Id: kutil.cc,v 1.79 2000-11-23 17:34:09 obachman Exp $ */
    55/*
    66* ABSTRACT: kernel: utils for kStd
     
    1212// #define PDEBUG 2
    1313// #define PDIV_DEBUG
    14 
     14#include <limits.h>
    1515#include <stdlib.h>
    1616#include <string.h>
     
    2020#define KDEBUG 2
    2121#endif
     22// define if enterL, enterT should use memmove instead of doing it manually
     23// on topgun, this is slightly faster (see monodromy_l.tst)
     24#define ENTER_USE_MEMMOVE
     25
    2226#include "tok.h"
    2327#include "kutil.h"
     
    9094*works only for orderings with ecart =pFDeg(end)-pFDeg(start)
    9195*/
     96void deleteHC(LObject *L, kStrategy strat, BOOLEAN fromNext)
     97{
     98  if (strat->kHEdgeFound)
     99  {
     100    kTest_L(L);
     101    poly p1;
     102    poly p = L->GetLmTailRing();
     103    int l = 1;
     104    if (L->bucket != NULL)
     105    {
     106      kBucketClear(L->bucket, &pNext(p), &L->pLength);
     107      L->pLength++;
     108    }
     109
     110    if (!fromNext && p_Cmp(p,strat->kNoether, L->tailRing) == -1)
     111    {
     112      L->Delete();
     113      L->Clear();
     114      L->ecart = -1;
     115      return;
     116    }
     117    p1 = p;
     118    while (pNext(p1)!=NULL)
     119    {
     120      if (p_LmCmp(pNext(p1), strat->kNoether, L->tailRing) == -1)
     121      {
     122        if (L->last != NULL)
     123          L->last = p1;
     124        p_Delete(&pNext(p1), L->tailRing);
     125        if (p1 == p)
     126        {
     127          if (L->t_p != NULL)
     128          {
     129            assume(L->p != NULL && p == L->t_p);
     130            pNext(L->p) = NULL;
     131          }
     132        }
     133        if (L->pLength != 0) L->pLength = l;
     134        // Hmmm when called from updateT, then only
     135        // reset ecart when cut
     136        if (fromNext)
     137          L->ecart = L->pLDeg() - L->GetpFDeg();
     138        break;
     139      }
     140      l++;
     141      pIter(p1);
     142    }
     143    if (L->bucket != NULL)
     144    {
     145      if (L->pLength > 1)
     146      {
     147        kBucketInit(L->bucket, pNext(p), L->pLength - 1);
     148        pNext(p) = NULL;
     149        if (L->t_p != NULL) pNext(L->t_p) = NULL;
     150        L->pLength = 0;
     151      }
     152      else
     153        kBucketDestroy(&L->bucket);
     154    }
     155    if (! fromNext)
     156    {
     157      L->SetpFDeg();
     158      L->ecart = L->pLDeg() - L->GetpFDeg();
     159    }
     160    kTest_L(L);
     161  }
     162}
     163
    92164void deleteHC(poly* p, int* e, int* l,kStrategy strat)
    93165{
    94   poly p1;
    95 
    96   if (strat->kHEdgeFound)
    97   {
    98     if (pCmp(*p,strat->kNoether) == -1)
    99     {
    100       pDelete(p);
    101       *l = 0;
    102       *e = -1;
    103       return;
    104     }
    105     p1 = *p;
    106     while (pNext(p1)!=NULL)
    107     {
    108       if (pLmCmp(pNext(p1), strat->kNoether) == -1)
    109         pDelete(&pNext(p1));
    110       else
    111         pIter(p1);
    112     }
    113     *e = pLDeg(*p,l)-pFDeg(*p);
    114   }
     166  LObject L(*p, currRing, strat->tailRing);
     167
     168  deleteHC(&L, strat);
     169  *p = L.p;
     170  *e = L.ecart;
     171  *l = L.length;
     172  if (L.t_p != NULL) p_LmFree(L.t_p, strat->tailRing);
    115173}
    116174
     
    141199        L->ecart = 0;
    142200        L->length = 1;
    143         L->pLength = 1; // let pLength be determined dynamically
     201        if (L->pLength > 0) L->pLength = 1;
     202        if (L->last != NULL) L->last = p;
     203
    144204        if (L->t_p != NULL && pNext(L->t_p) != NULL)
    145205          pNext(L->t_p) = NULL;
     
    460520  }
    461521
    462   if (T->pLength != 0 &&
    463       T->pLength != pLength(p))
     522  if (i >= 0 && T->pLength != 0 && T->pLength != pLength(p))
    464523  {
    465524    return dReportError("%c[%d] pLength error: has %d, specified to have %d",
     
    491550  if (testp)
    492551  {
     552    poly pn = NULL;
    493553    if (L->bucket != NULL)
    494554    {
    495555      kFalseReturn(kbTest(L->bucket));
    496556      r_assume(L->bucket->bucket_ring == L->tailRing);
     557      if (L->p != NULL && pNext(L->p) != NULL)
     558      {
     559        pn = pNext(L->p);
     560        pNext(L->p) = NULL;
     561      }
    497562    }
    498563    kFalseReturn(kTest_T(L, strat_tailRing, lpos, 'L'));
     564    if (pn != NULL)
     565      pNext(L->p) = pn;
     566
    499567    ring r;
    500568    poly p;
     
    504572      return dReportError("L[%d] wrong sev: has %o, specified to have %o",
    505573                          lpos, p_GetShortExpVector(p, r), L->sev);
     574    }
     575    if (lpos > 0 && L->last != NULL && pLast(p) != L->last)
     576    {
     577      return dReportError("L[%d] last wrong: has %p specified to have %p",
     578                          lpos, pLast(p), L->last);
    506579    }
    507580  }
     
    618691  for (i=0; i<=strat->Ll; i++)
    619692  {
    620     if (strat->L[i].i_r1 >= 0 &&
    621         (strat->L[i].i_r1 > strat->tl ||
    622          strat->L[i].T_1(strat)->p != strat->L[i].p1))
    623       return dReportError("L[%d].i_r1 out of sync", i);
    624     if (strat->L[i].i_r2 >= 0 &&
    625         (strat->L[i].i_r2 > strat->tl ||
    626          strat->L[i].T_2(strat)->p != strat->L[i].p2))
    627       return dReportError("L[%d].i_r2 out of sync", i);
     693    if (strat->L[i].p1 != NULL && strat->L[i].p2)
     694    {
     695      if (strat->L[i].i_r1 < 0 ||
     696          strat->L[i].i_r1 > strat->tl ||
     697          strat->L[i].T_1(strat)->p != strat->L[i].p1)
     698        return dReportError("L[%d].i_r1 out of sync", i);
     699      if (strat->L[i].i_r2 < 0 ||
     700          strat->L[i].i_r2 > strat->tl ||
     701          strat->L[i].T_2(strat)->p != strat->L[i].p2);
     702    }
     703    else
     704    {
     705      if (strat->L[i].i_r1 != -1)
     706        return dReportError("L[%d].i_r1 out of sync", i);
     707      if (strat->L[i].i_r2 != -1)
     708        return dReportError("L[%d].i_r2 out of sync", i);
     709    }
    628710  }
    629711  return TRUE;
     
    691773          {
    692774            /* not found : */
     775            if (set[j].bucket != NULL)
     776            {
     777              kBucketDeleteAndDestroy(&set[j].bucket);
     778              pNext(p) = NULL;
     779              if (set[j].t_p != NULL) pNext(set[j].t_p) = NULL;
     780            }
    693781            if (set[j].t_p != NULL)
    694782            {
     
    700788              pDelete(&p);
    701789            }
    702             if (set[j].bucket != NULL)
    703               kBucketDeleteAndDestroy(&set[j].bucket);
    704790            break;
    705791          }
     
    751837  int i;
    752838  // this should be corrected
    753   p.FDeg = p.pFDeg();
     839  assume(p.FDeg == p.pFDeg());
    754840  if ((*length)>=0)
    755841  {
    756842    if ((*length) == (*LSetmax)-1) enlargeL(set,LSetmax,setmax);
     843    if (at <= (*length))
     844#ifdef ENTER_USE_MEMMOVE
     845      memmove(&((*set)[at+1]), &((*set)[at]), ((*length)-at+1)*sizeof(LObject));
     846#else
    757847    for (i=(*length)+1; i>=at+1; i--) (*set)[i] = (*set)[i-1];
     848#endif
    758849  }
    759850  else at = 0;
     
    9901081      nDelete(&(Lp.p->coef));
    9911082    }
    992     l = strat->posInL(strat->B,strat->Bl,Lp,strat);
     1083    l = strat->posInL(strat->B,strat->Bl,&Lp,strat);
    9931084    enterL(&strat->B,&strat->Bl,&strat->Bmax,Lp,l);
    9941085  }
     
    10521143      nDelete(&(Lp.p->coef));
    10531144    }
    1054     l = strat->posInL(strat->L,strat->Ll,Lp,strat);
     1145    l = strat->posInL(strat->L,strat->Ll,&Lp,strat);
    10551146    enterL(&strat->L,&strat->Ll,&strat->Lmax,Lp,l);
    10561147  }
     
    11941285    for (i=strat->Bl; i>=0; i--)
    11951286    {
    1196       j = strat->posInL(strat->L,j-1,strat->B[i],strat);
     1287      j = strat->posInL(strat->L,j-1,&(strat->B[i]),strat);
    11971288      enterL(&strat->L,&strat->Ll,&strat->Lmax,strat->B[i],j);
    11981289    }
     
    12281319    for (i=strat->Bl; i>=0; i--)
    12291320    {
    1230       j = strat->posInL(strat->L,j,strat->B[i],strat);
     1321      j = strat->posInL(strat->L,j,&(strat->B[i]),strat);
    12311322      enterL(&strat->L,&strat->Ll,&strat->Lmax,strat->B[i],j);
    12321323    }
     
    16351726 * int o;
    16361727 *
    1637  * o = pFDeg(p.p);
     1728 * o = p.GetpFDeg();
    16381729 * loop
    16391730 * {
     
    16511742  if (length==-1) return 0;
    16521743
    1653   int o = pFDeg(p.p);
     1744  int o = p.GetpFDeg();
    16541745  int op = set[length].GetpFDeg();
    16551746
     
    16911782  if (length==-1) return 0;
    16921783
    1693   int o = pFDeg(p.p);
     1784  int o = p.GetpFDeg();
    16941785  int op = set[length].GetpFDeg();
    16951786
     
    17361827  if (length==-1) return 0;
    17371828
    1738   int o = pFDeg(p.p);
     1829  int o = p.GetpFDeg();
    17391830
    17401831  if (set[length].GetpFDeg() <= o)
     
    17701861 * int o;
    17711862 *
    1772  * o = pFDeg(p.p)+p.ecart;
     1863 * o = p.GetpFDeg()+p.ecart;
    17731864 * loop
    17741865 * {
     
    17871878  if (length==-1) return 0;
    17881879
    1789   int o = pFDeg(p.p) + p.ecart;
     1880  int o = p.GetpFDeg() + p.ecart;
    17901881  int op = set[length].GetpFDeg()+set[length].ecart;
    17911882
     
    18291920* int  o;
    18301921*
    1831 *  o = pFDeg(p.p)+p.ecart;
     1922*  o = p.GetpFDeg()+p.ecart;
    18321923*  loop
    18331924*  {
     
    18471938  if (length==-1) return 0;
    18481939
    1849   int o = pFDeg(p.p) + p.ecart;
     1940  int o = p.GetpFDeg() + p.ecart;
    18501941  int op = set[length].GetpFDeg()+set[length].ecart;
    18511942
     
    18931984  int cc = (-1+2*currRing->order[0]==ringorder_c);
    18941985  /* cc==1 for (c,..), cc==-1 for (C,..) */
    1895   int o = pFDeg(p.p) + p.ecart;
     1986  int o = p.GetpFDeg() + p.ecart;
    18961987  int c = pGetComp(p.p)*cc;
    18971988
     
    19572048
    19582049  int o = p.ecart;
    1959   int op=pFDeg(p.p);
     2050  int op=p.GetpFDeg();
    19602051
    19612052  if (set[length].ecart < o)
     
    20092100*/
    20102101int posInLSpecial (const LSet set, const int length,
    2011                    const LObject &p,const kStrategy strat)
     2102                   LObject *p,const kStrategy strat)
    20122103{
    20132104  if (length<0) return 0;
    20142105
    2015   int d=pFDeg(p.p);
     2106  int d=p->GetpFDeg();
    20162107  int op=set[length].GetpFDeg();
    20172108
    20182109  if ((op > d)
    2019   || ((op == d) && (p.p1!=NULL)&&(set[length].p1==NULL))
    2020   || (pLmCmp(set[length].p,p.p)== pOrdSgn))
     2110  || ((op == d) && (p->p1!=NULL)&&(set[length].p1==NULL))
     2111  || (pLmCmp(set[length].p,p->p)== pOrdSgn))
    20212112     return length+1;
    20222113
     
    20302121      op=set[an].GetpFDeg();
    20312122      if ((op > d)
    2032       || ((op == d) && (p.p1!=NULL) && (set[an].p1==NULL))
    2033       || (pLmCmp(set[an].p,p.p)== pOrdSgn))
     2123      || ((op == d) && (p->p1!=NULL) && (set[an].p1==NULL))
     2124      || (pLmCmp(set[an].p,p->p)== pOrdSgn))
    20342125         return en;
    20352126      return an;
     
    20382129    op=set[i].GetpFDeg();
    20392130    if ((op>d)
    2040     || ((op==d) && (p.p1!=NULL) && (set[i].p1==NULL))
    2041     || (pLmCmp(set[i].p,p.p) == pOrdSgn))
     2131    || ((op==d) && (p->p1!=NULL) && (set[i].p1==NULL))
     2132    || (pLmCmp(set[i].p,p->p) == pOrdSgn))
    20422133      an=i;
    20432134    else
     
    20522143*/
    20532144int posInL0 (const LSet set, const int length,
    2054              const LObject &p,const kStrategy strat)
     2145             LObject* p,const kStrategy strat)
    20552146{
    20562147  if (length<0) return 0;
    20572148
    2058   if (pLmCmp(set[length].p,p.p)== pOrdSgn)
     2149  if (pLmCmp(set[length].p,p->p)== pOrdSgn)
    20592150    return length+1;
    20602151
     
    20662157    if (an >= en-1)
    20672158    {
    2068       if (pLmCmp(set[an].p,p.p) == pOrdSgn) return en;
     2159      if (pLmCmp(set[an].p,p->p) == pOrdSgn) return en;
    20692160      return an;
    20702161    }
    20712162    i=(an+en) / 2;
    2072     if (pLmCmp(set[i].p,p.p) == pOrdSgn) an=i;
     2163    if (pLmCmp(set[i].p,p->p) == pOrdSgn) an=i;
    20732164    else                                 en=i;
    20742165    /*aend. fuer lazy == in !=- machen */
     
    20832174*/
    20842175int posInL11 (const LSet set, const int length,
    2085               const LObject &p,const kStrategy strat)
     2176              LObject* p,const kStrategy strat)
    20862177/*{
    20872178 * int j=0;
    20882179 * int o;
    20892180 *
    2090  * o = pFDeg(p.p);
     2181 * o = p->GetpFDeg();
    20912182 * loop
    20922183 * {
    20932184 *   if (j > length)            return j;
    20942185 *   if ((set[j].GetpFDeg() < o)) return j;
    2095  *   if ((set[j].GetpFDeg() == o) && (pLmCmp(set[j].p,p.p) == -pOrdSgn))
     2186 *   if ((set[j].GetpFDeg() == o) && (pLmCmp(set[j].p,p->p) == -pOrdSgn))
    20962187 *   {
    20972188 *     return j;
     
    21042195  if (length<0) return 0;
    21052196
    2106   int o = pFDeg(p.p);
     2197  int o = p->GetpFDeg();
    21072198  int op = set[length].GetpFDeg();
    21082199
    21092200  if ((op > o)
    2110   || ((op == o) && (pLmCmp(set[length].p,p.p) != -pOrdSgn)))
     2201  || ((op == o) && (pLmCmp(set[length].p,p->p) != -pOrdSgn)))
    21112202    return length+1;
    21122203  int i;
     
    21192210      op = set[an].GetpFDeg();
    21202211      if ((op > o)
    2121       || ((op == o) && (pLmCmp(set[an].p,p.p) != -pOrdSgn)))
     2212      || ((op == o) && (pLmCmp(set[an].p,p->p) != -pOrdSgn)))
    21222213        return en;
    21232214      return an;
     
    21262217    op = set[i].GetpFDeg();
    21272218    if ((op > o)
    2128     || ((op == o) && (pLmCmp(set[i].p,p.p) != -pOrdSgn)))
     2219    || ((op == o) && (pLmCmp(set[i].p,p->p) != -pOrdSgn)))
    21292220      an=i;
    21302221    else
     
    21392230*/
    21402231int posInL110 (const LSet set, const int length,
    2141                const LObject &p,const kStrategy strat)
     2232               LObject* p,const kStrategy strat)
    21422233{
    21432234  if (length<0) return 0;
    21442235
    2145   int o = pFDeg(p.p);
     2236  int o = p->GetpFDeg();
    21462237  int op = set[length].GetpFDeg();
    21472238
    21482239  if ((op > o)
    2149   || ((op == o) && (set[length].length >2*p.length))
    2150   || ((op == o) && (set[length].length <= 2*p.length)
    2151      && (pLmCmp(set[length].p,p.p) != -pOrdSgn)))
     2240  || ((op == o) && (set[length].length >2*p->length))
     2241  || ((op == o) && (set[length].length <= 2*p->length)
     2242     && (pLmCmp(set[length].p,p->p) != -pOrdSgn)))
    21522243    return length+1;
    21532244  int i;
     
    21602251      op = set[an].GetpFDeg();
    21612252      if ((op > o)
    2162       || ((op == o) && (set[an].length >2*p.length))
    2163       || ((op == o) && (set[an].length <=2*p.length)
    2164          && (pLmCmp(set[an].p,p.p) != -pOrdSgn)))
     2253      || ((op == o) && (set[an].length >2*p->length))
     2254      || ((op == o) && (set[an].length <=2*p->length)
     2255         && (pLmCmp(set[an].p,p->p) != -pOrdSgn)))
    21652256        return en;
    21662257      return an;
     
    21692260    op = set[i].GetpFDeg();
    21702261    if ((op > o)
    2171     || ((op == o) && (set[i].length > 2*p.length))
    2172     || ((op == o) && (set[i].length <= 2*p.length)
    2173        && (pLmCmp(set[i].p,p.p) != -pOrdSgn)))
     2262    || ((op == o) && (set[i].length > 2*p->length))
     2263    || ((op == o) && (set[i].length <= 2*p->length)
     2264       && (pLmCmp(set[i].p,p->p) != -pOrdSgn)))
    21742265      an=i;
    21752266    else
     
    21852276*/
    21862277int posInL13 (const LSet set, const int length,
    2187               const LObject &p,const kStrategy strat)
     2278              LObject* p,const kStrategy strat)
    21882279{
    21892280  if (length<0) return 0;
    21902281
    2191   int o = pFDeg(p.p);
     2282  int o = p->GetpFDeg();
    21922283
    21932284  if (set[length].GetpFDeg() > o)
     
    22202311*/
    22212312int posInL15 (const LSet set, const int length,
    2222               const LObject &p,const kStrategy strat)
     2313              LObject* p,const kStrategy strat)
    22232314/*{
    22242315 * int j=0;
    22252316 * int o;
    22262317 *
    2227  * o = p.ecart+pFDeg(p.p);
     2318 * o = p->ecart+p->GetpFDeg();
    22282319 * loop
    22292320 * {
     
    22312322 *   if (set[j].GetpFDeg()+set[j].ecart < o) return j;
    22322323 *   if ((set[j].GetpFDeg()+set[j].ecart == o)
    2233  *   && (pLmCmp(set[j].p,p.p) == -pOrdSgn))
     2324 *   && (pLmCmp(set[j].p,p->p) == -pOrdSgn))
    22342325 *   {
    22352326 *     return j;
     
    22422333  if (length<0) return 0;
    22432334
    2244   int o = pFDeg(p.p) + p.ecart;
     2335  int o = p->GetpFDeg() + p->ecart;
    22452336  int op = set[length].GetpFDeg() + set[length].ecart;
    22462337
    22472338  if ((op > o)
    2248   || ((op == o) && (pLmCmp(set[length].p,p.p) != -pOrdSgn)))
     2339  || ((op == o) && (pLmCmp(set[length].p,p->p) != -pOrdSgn)))
    22492340    return length+1;
    22502341  int i;
     
    22572348      op = set[an].GetpFDeg() + set[an].ecart;
    22582349      if ((op > o)
    2259       || ((op == o) && (pLmCmp(set[an].p,p.p) != -pOrdSgn)))
     2350      || ((op == o) && (pLmCmp(set[an].p,p->p) != -pOrdSgn)))
    22602351        return en;
    22612352      return an;
     
    22642355    op = set[i].GetpFDeg() + set[i].ecart;
    22652356    if ((op > o)
    2266     || ((op == o) && (pLmCmp(set[i].p,p.p) != -pOrdSgn)))
     2357    || ((op == o) && (pLmCmp(set[i].p,p->p) != -pOrdSgn)))
    22672358      an=i;
    22682359    else
     
    22792370*/
    22802371int posInL17 (const LSet set, const int length,
    2281               const LObject &p,const kStrategy strat)
     2372              LObject* p,const kStrategy strat)
    22822373{
    22832374  if (length<0) return 0;
    22842375
    2285   int o = pFDeg(p.p) + p.ecart;
     2376  int o = p->GetpFDeg() + p->ecart;
    22862377
    22872378  if ((set[length].GetpFDeg() + set[length].ecart > o)
    22882379  || ((set[length].GetpFDeg() + set[length].ecart == o)
    2289      && (set[length].ecart > p.ecart))
     2380     && (set[length].ecart > p->ecart))
    22902381  || ((set[length].GetpFDeg() + set[length].ecart == o)
    2291      && (set[length].ecart == p.ecart)
    2292      && (pLmCmp(set[length].p,p.p) != -pOrdSgn)))
     2382     && (set[length].ecart == p->ecart)
     2383     && (pLmCmp(set[length].p,p->p) != -pOrdSgn)))
    22932384    return length+1;
    22942385  int i;
     
    23012392      if ((set[an].GetpFDeg() + set[an].ecart > o)
    23022393      || ((set[an].GetpFDeg() + set[an].ecart == o)
    2303          && (set[an].ecart > p.ecart))
     2394         && (set[an].ecart > p->ecart))
    23042395      || ((set[an].GetpFDeg() + set[an].ecart == o)
    2305          && (set[an].ecart == p.ecart)
    2306          && (pLmCmp(set[an].p,p.p) != -pOrdSgn)))
     2396         && (set[an].ecart == p->ecart)
     2397         && (pLmCmp(set[an].p,p->p) != -pOrdSgn)))
    23072398        return en;
    23082399      return an;
     
    23112402    if ((set[i].GetpFDeg() + set[i].ecart > o)
    23122403    || ((set[i].GetpFDeg() + set[i].ecart == o)
    2313        && (set[i].ecart > p.ecart))
     2404       && (set[i].ecart > p->ecart))
    23142405    || ((set[i].GetpFDeg() +set[i].ecart == o)
    2315        && (set[i].ecart == p.ecart)
    2316        && (pLmCmp(set[i].p,p.p) != -pOrdSgn)))
     2406       && (set[i].ecart == p->ecart)
     2407       && (pLmCmp(set[i].p,p->p) != -pOrdSgn)))
    23172408      an=i;
    23182409    else
     
    23272418*/
    23282419int posInL17_c (const LSet set, const int length,
    2329                 const LObject &p,const kStrategy strat)
     2420                LObject* p,const kStrategy strat)
    23302421{
    23312422  if (length<0) return 0;
     
    23332424  int cc = (-1+2*currRing->order[0]==ringorder_c);
    23342425  /* cc==1 for (c,..), cc==-1 for (C,..) */
    2335   int c = pGetComp(p.p)*cc;
    2336   int o = pFDeg(p.p) + p.ecart;
     2426  int c = pGetComp(p->p)*cc;
     2427  int o = p->GetpFDeg() + p->ecart;
    23372428
    23382429  if (pGetComp(set[length].p)*cc > c)
     
    23422433    if ((set[length].GetpFDeg() + set[length].ecart > o)
    23432434    || ((set[length].GetpFDeg() + set[length].ecart == o)
    2344        && (set[length].ecart > p.ecart))
     2435       && (set[length].ecart > p->ecart))
    23452436    || ((set[length].GetpFDeg() + set[length].ecart == o)
    2346        && (set[length].ecart == p.ecart)
    2347        && (pLmCmp(set[length].p,p.p) != -pOrdSgn)))
     2437       && (set[length].ecart == p->ecart)
     2438       && (pLmCmp(set[length].p,p->p) != -pOrdSgn)))
    23482439      return length+1;
    23492440  }
     
    23612452        if ((set[an].GetpFDeg() + set[an].ecart > o)
    23622453        || ((set[an].GetpFDeg() + set[an].ecart == o)
    2363            && (set[an].ecart > p.ecart))
     2454           && (set[an].ecart > p->ecart))
    23642455        || ((set[an].GetpFDeg() + set[an].ecart == o)
    2365            && (set[an].ecart == p.ecart)
    2366            && (pLmCmp(set[an].p,p.p) != -pOrdSgn)))
     2456           && (set[an].ecart == p->ecart)
     2457           && (pLmCmp(set[an].p,p->p) != -pOrdSgn)))
    23672458          return en;
    23682459      }
     
    23762467      if ((set[i].GetpFDeg() + set[i].ecart > o)
    23772468      || ((set[i].GetpFDeg() + set[i].ecart == o)
    2378          && (set[i].ecart > p.ecart))
     2469         && (set[i].ecart > p->ecart))
    23792470      || ((set[i].GetpFDeg() +set[i].ecart == o)
    2380          && (set[i].ecart == p.ecart)
    2381          && (pLmCmp(set[i].p,p.p) != -pOrdSgn)))
     2471         && (set[i].ecart == p->ecart)
     2472         && (pLmCmp(set[i].p,p->p) != -pOrdSgn)))
    23822473        an=i;
    23832474      else
     
    23882479  }
    23892480}
     2481
     2482/***************************************************************
     2483 *
     2484 * Tail reductions
     2485 *
     2486 ***************************************************************/
     2487static TObject*
     2488kFindDivisibleByInS(kStrategy strat, int pos, LObject* L, TObject *T,
     2489                    long ecart = LONG_MAX)
     2490{
     2491  int j = 0;
     2492  const unsigned long not_sev = ~L->sev;
     2493  const unsigned long* sev = strat->sevS;
     2494  poly p;
     2495  ring r;
     2496  L->GetLm(p, r);
     2497 
     2498  assume(~not_sev == p_GetShortExpVector(p, r));
     2499
     2500  if (r == currRing)
     2501  {
     2502    while (1)
     2503    {
     2504      if (j > pos) return NULL;
     2505#if defined(PDEBUG) || defined(PDIV_DEBUG)
     2506      if (p_LmShortDivisibleBy(strat->S[j], sev[j], p, not_sev, r) &&
     2507          (ecart== LONG_MAX || ecart>= strat->ecartS[j]))
     2508        break;
     2509#else
     2510      if (!(sev[j] & not_sev) &&
     2511          (ecart== LONG_MAX || ecart>= strat->ecartS[j]) &&
     2512          p_LmDivisibleBy(strat->S[j], p, r))
     2513        break;
     2514     
     2515#endif
     2516      j++;
     2517    }
     2518    // if called from NF, T objects do not exist:
     2519    if (strat->tl < 0)
     2520    {
     2521      T->Set(strat->S[j], r);
     2522      return T;
     2523    }
     2524    else
     2525    {
     2526      assume (j >= 0 && j <= strat->tl && strat->S_2_T(j) != NULL);
     2527      return strat->S_2_T(j);
     2528    }
     2529  }
     2530  else
     2531  {
     2532    TObject* t;
     2533    while (1)
     2534    {
     2535      if (j > pos) return NULL;
     2536#if defined(PDEBUG) || defined(PDIV_DEBUG)
     2537      t = strat->S_2_T(j);
     2538      assume(t != NULL && t->t_p != NULL && t->tailRing == r);
     2539      if (p_LmShortDivisibleBy(t->t_p, sev[j], p, not_sev, r) &&
     2540          (ecart== LONG_MAX || ecart>= strat->ecartS[j]))
     2541        return t;
     2542#else     
     2543      if (! (sev[j] & not_sev) && (ecart== LONG_MAX || ecart>= strat->ecartS[j]))
     2544      {
     2545        t = strat->S_2_T(j);
     2546        assume(t != NULL && t->t_p != NULL && t->tailRing == r);
     2547        if (p_LmDivisibleBy(t->t_p, p, r)) return t;
     2548      }
     2549#endif
     2550      j++;
     2551    }
     2552  }
     2553}
     2554
     2555
     2556poly redtail (LObject* L, int pos, kStrategy strat)
     2557{
     2558  poly h, hn;
     2559  int j;
     2560  unsigned long not_sev;
     2561  strat->redTailChange=FALSE;
     2562  poly p = L->p;
     2563  if (strat->noTailReduction || pNext(p) == NULL)
     2564    return p;
     2565
     2566  LObject Ln(strat->tailRing);
     2567  TObject* With;
     2568  // placeholder in case strat->tl < 0
     2569  TObject  With_s(strat->tailRing);
     2570  h = p;
     2571  hn = pNext(h);
     2572  long op = pFDeg(hn, strat->tailRing);
     2573  long e;
     2574  int l;
     2575  BOOLEAN save_HE=strat->kHEdgeFound;
     2576  strat->kHEdgeFound |=
     2577    ((Kstd1_deg>0) && (op<=Kstd1_deg)) || TEST_OPT_INFREDTAIL;
     2578
     2579  while(hn != NULL)
     2580  {
     2581    e = pLDeg(hn, &l, strat->tailRing) - op;
     2582    while (1)
     2583    {
     2584      kTest_TS(strat);
     2585      Ln.Set(hn, strat->tailRing);
     2586      Ln.sev = p_GetShortExpVector(hn, strat->tailRing);
     2587      if (strat->kHEdgeFound)
     2588        With = kFindDivisibleByInS(strat, pos, &Ln, &With_s);
     2589      else
     2590        With = kFindDivisibleByInS(strat, pos, &Ln, &With_s, e);
     2591      if (With == NULL) break;
     2592      strat->redTailChange=TRUE;
     2593      if (ksReducePolyTail(L, With, h, strat->kNoether))
     2594      {
     2595        // reducing the tail would violate the exp bound
     2596        if (kStratChangeTailRing(strat, L))
     2597        {
     2598          strat->kHEdgeFound = save_HE;
     2599          return redtail(L, pos, strat);
     2600        }
     2601        else
     2602          return NULL;
     2603      }
     2604      hn = pNext(h);
     2605      if (hn == NULL) goto all_done;
     2606      op = pFDeg(hn, strat->tailRing);
     2607      e = pLDeg(hn, &l) - op;
     2608      kTest_TS(strat);
     2609    }
     2610    h = hn;
     2611    hn = pNext(h);
     2612  }
     2613
     2614  all_done:
     2615  strat->kHEdgeFound = save_HE;
     2616  return p;
     2617}
     2618
     2619#define OLD_RED_TAIL
     2620#ifdef OLD_RED_TAIL
    23902621/*2
    23912622* reduces h using the set S
     
    23982629poly redtail (poly p, int pos, kStrategy strat)
    23992630{
    2400   if ((!strat->noTailReduction)
    2401   && (pNext(p)!=NULL))
     2631  if ((!strat->noTailReduction) && (pNext(p)!=NULL))
    24022632  {
    24032633    int j, e, l;
     
    24182648      {
    24192649        if (pLmShortDivisibleBy(strat->S[j], strat->sevS[j], hn, not_sev)
    2420         && ((e >= strat->ecartS[j])
    2421           || strat->kHEdgeFound)
    2422         )
     2650            &&
     2651            ((e >= strat->ecartS[j]) || strat->kHEdgeFound))
    24232652        {
    24242653          strat->redTailChange=TRUE;
     
    24482677  return p;
    24492678}
    2450 
    2451 /*2
    2452 *compute the normalform of the tail p->next of p
    2453 *with respect to S
    2454 */
    2455 TObject* kFindDivisibleByInS(kStrategy strat, int pos, LObject* L, TObject *T)
    2456 {
    2457   int j = 0;
    2458   const unsigned long not_sev = ~L->sev;
    2459   const unsigned long* sev = strat->sevS;
    2460   poly p;
    2461   ring r;
    2462   L->GetLm(p, r);
    2463  
    2464   assume(~not_sev == p_GetShortExpVector(p, r));
    2465 
    2466   if (r == currRing)
    2467   {
    2468     while (1)
    2469     {
    2470       if (j > pos) return NULL;
    2471 #if defined(PDEBUG) || defined(PDIV_DEBUG)
    2472       if (p_LmShortDivisibleBy(strat->S[j], sev[j], p, not_sev, r))
    2473         break;
    24742679#else
    2475       if (!(sev[j] & not_sev) &&
    2476           p_LmDivisibleBy(strat->S[j], p, r))
    2477         break;
    2478      
     2680poly redtail (poly p, int pos, kStrategy strat)
     2681{
     2682  LObject L(p, currRing);
     2683  return redtail(&L, pos, strat);
     2684}
    24792685#endif
    2480       j++;
    2481     }
    2482     // if called from NF, T objects do not exist:
    2483     if (strat->tl < 0)
    2484     {
    2485       T->Set(strat->S[j], r);
    2486       return T;
    2487     }
    2488     else
    2489     {
    2490       assume (j >= 0 && j <= strat->tl && strat->S_2_T(j) != NULL);
    2491       return strat->S_2_T(j);
    2492     }
    2493   }
    2494   else
    2495   {
    2496     TObject* t;
    2497     while (1)
    2498     {
    2499       if (j > pos) return NULL;
    2500 #if defined(PDEBUG) || defined(PDIV_DEBUG)
    2501       t = strat->S_2_T(j);
    2502       assume(t != NULL && t->t_p != NULL && t->tailRing == r);
    2503       if (p_LmShortDivisibleBy(t->t_p, sev[j], p, not_sev, r))
    2504         return t;
    2505 #else     
    2506       if (! (sev[j] & not_sev))
    2507       {
    2508         t = strat->S_2_T(j);
    2509         assume(t != NULL && t->t_p != NULL && t->tailRing == r);
    2510         if (p_LmDivisibleBy(t->t_p, p, r)) return t;
    2511       }
    2512 #endif
    2513       j++;
    2514     }
    2515   }
    2516 }
    25172686
    25182687poly redtailBba (LObject* L, int pos, kStrategy strat)
     
    26412810
    26422811#endif
     2812
    26432813
    26442814/*2
     
    26722842        {
    26732843          //pContent(h.p);
    2674           pCleardenom(h.p); // also does a pContent
     2844          h.pCleardenom(); // also does a pContent
    26752845        }
    26762846        else
    26772847        {
    2678           pNorm(h.p);
     2848          h.pNorm();
    26792849        }
    26802850        strat->initEcart(&h);
    26812851        if (pOrdSgn==-1)
    26822852        {
    2683           deleteHC(&h.p, &h.ecart, &h.length,strat);
     2853          deleteHC(&h, strat);
    26842854        }
    26852855        if (h.p!=NULL)
     
    27072877      {
    27082878        //pContent(h.p);
    2709         pCleardenom(h.p); // also does a pContent
     2879        h.pCleardenom(); // also does a pContent
    27102880      }
    27112881      else
    27122882      {
    2713         pNorm(h.p);
     2883        h.pNorm();
    27142884      }
    27152885      strat->initEcart(&h);
     
    27172887      {
    27182888        cancelunit(&h);  /*- tries to cancel a unit -*/
    2719         deleteHC(&h.p, &h.ecart, &h.length,strat);
     2889        deleteHC(&h, strat);
    27202890      }
    27212891      if (TEST_OPT_DEGBOUND
     
    27712941        {
    27722942          //pContent(h.p);
    2773           pCleardenom(h.p); // also does a pContent
     2943          h.pCleardenom(); // also does a pContent
    27742944        }
    27752945        else
    27762946        {
    2777           pNorm(h.p);
     2947          h.pNorm();
    27782948        }
    27792949        strat->initEcart(&h);
    27802950        if (pOrdSgn==-1)
    27812951        {
    2782           deleteHC(&h.p, &h.ecart, &h.length,strat);
     2952          deleteHC(&h,strat);
    27832953        }
    27842954        if (h.p!=NULL)
     
    28062976      {
    28072977        //pContent(h.p);
    2808         pCleardenom(h.p); // also does a pContent
     2978        h.pCleardenom(); // also does a pContent
    28092979      }
    28102980      else
    28112981      {
    2812         pNorm(h.p);
     2982        h.pNorm();
    28132983      }
    28142984      strat->initEcart(&h);
     
    28162986      {
    28172987        cancelunit(&h);  /*- tries to cancel a unit -*/
    2818         deleteHC(&h.p, &h.ecart, &h.length,strat);
     2988        deleteHC(&h, strat);
    28192989      }
    28202990      if (TEST_OPT_DEGBOUND
     
    28292999          else
    28303000          {
    2831             pos = strat->posInL(strat->L,strat->Ll,h,strat);
     3001            pos = strat->posInL(strat->L,strat->Ll,&h,strat);
    28323002          }
    28333003          h.sev = pGetShortExpVector(h.p);
     
    28753045        //{
    28763046        //  //pContent(h.p);
    2877         //  pCleardenom(h.p); // also does a pContent
     3047        //  h.pCleardenom(); // also does a pContent
    28783048        //}
    28793049        //else
    28803050        //{
    2881         //  pNorm(h.p);
     3051        //  h.pNorm();
    28823052        //}
    28833053        strat->initEcart(&h);
    28843054        if (pOrdSgn==-1)
    28853055        {
    2886           deleteHC(&h.p, &h.ecart, &h.length,strat);
     3056          deleteHC(&h,strat);
    28873057        }
    28883058        if (h.p!=NULL)
     
    28953065          }
    28963066          h.sev = pGetShortExpVector(h.p);
     3067          h.SetpFDeg();
    28973068          strat->enterS(h,pos,strat, strat->tl+1);
    28983069          enterT(h, strat);
     
    29163087      if (pOrdSgn==-1)
    29173088      {
    2918           deleteHC(&h.p, &h.ecart, &h.length,strat);
     3089        deleteHC(&h,strat);
    29193090      }
    29203091      if (TEST_OPT_DEGBOUND
     
    29343105        strat->enterS(h,pos,strat, strat->tl+1);
    29353106        h.length = pLength(h.p);
     3107        h.SetpFDeg();
    29363108        enterT(h,strat);
    29373109      }
     
    29483120      if (TEST_OPT_INTSTRATEGY)
    29493121      {
    2950         pCleardenom(h.p);
     3122        h.pCleardenom();
    29513123      }
    29523124      else
    29533125      {
    2954         pNorm(h.p);
     3126        h.pNorm();
    29553127      }
    29563128      if(strat->sl>=0)
     
    29713143          if (TEST_OPT_INTSTRATEGY)
    29723144          {
    2973             pCleardenom(h.p);
     3145            h.pCleardenom();
    29743146          }
    29753147          else
    29763148          {
    2977             pNorm(h.p);
     3149            h.is_normalized = 0;
     3150            h.pNorm();
    29783151          }
    29793152          h.sev = pGetShortExpVector(h.p);
     3153          h.SetpFDeg();
    29803154          pos = posInS(strat->S,strat->sl,h.p);
    29813155          enterpairsSpecial(h.p,strat->sl,h.ecart,pos,strat,strat->tl+1);
     
    29873161      {
    29883162        h.sev = pGetShortExpVector(h.p);
     3163        h.SetpFDeg();
    29893164        strat->enterS(h,0,strat, strat->tl+1);
    29903165        enterT(h,strat);
     
    31193294  int  j=0;
    31203295  int  e,l;
    3121   poly h1;
    31223296  unsigned long not_sev = ~ pGetShortExpVector(h);
    31233297
     
    31303304      && ((e >= strat->ecartS[j]) || strat->kHEdgeFound))
    31313305      {
    3132         h1 = ksOldSpolyRedNew(strat->S[j],h,strat->kNoether);
     3306#ifdef KDEBUG
     3307        if (TEST_OPT_DEBUG)
     3308          PrintS("reduce "); wrp(h); Print(" with S[%d] (",j);wrp(strat->S[j]);
     3309#endif         
     3310        h = ksOldSpolyRed(strat->S[j],h,strat->kNoether);
     3311#ifdef KDEBUG
    31333312        if(TEST_OPT_DEBUG)
    3134         {
    3135           PrintS("reduce "); wrp(h); Print(" with S[%d] (",j);wrp(strat->S[j]);
    3136           PrintS(")\nto "); wrp(h1); PrintLn();
    3137         }
    3138         pDelete(&h);
    3139         if (h1 == NULL) return NULL;
    3140         h = h1;
     3313          PrintS(")\nto "); wrp(h); PrintLn();
     3314#endif
     3315        // pDelete(&h);
     3316        if (h == NULL) return NULL;
    31413317        e = pLDeg(h,&l)-pFDeg(h);
    31423318        j = 0;
     
    32393415        else assume(strat->sevS[i] == pGetShortExpVector(h.p));
    32403416        h.sev = strat->sevS[i];
     3417        h.SetpFDeg();
    32413418        /*puts the elements of S also to T*/
    32423419        enterT(h,strat);
     
    33223499        cancelunit1(&h,strat->sl,strat);
    33233500      h.length = pLength(h.p);
     3501      h.SetpFDeg();
    33243502      /*puts the elements of S also to T*/
    33253503      enterT(h,strat);
     
    33663544    strat->Shdl->m=strat->S;
    33673545  }
    3368   for (i=strat->sl+1; i>=atS+1; i--)
    3369   {
    3370     strat->S[i] = strat->S[i-1];
    3371     strat->ecartS[i] = strat->ecartS[i-1];
    3372     strat->sevS[i] = strat->sevS[i-1];
    3373     strat->S_2_R[i] = strat->S_2_R[i-1];
     3546  if (atS <= strat->sl)
     3547  {
     3548#ifdef ENTER_USE_MEMMOVE
     3549// #if 0
     3550    memmove(&(strat->S[atS+1]), &(strat->S[atS]),
     3551            (strat->sl - atS + 1)*sizeof(poly));
     3552    memmove(&(strat->ecartS[atS+1]), &(strat->ecartS[atS]),
     3553            (strat->sl - atS + 1)*sizeof(int));
     3554    memmove(&(strat->sevS[atS+1]), &(strat->sevS[atS]),
     3555            (strat->sl - atS + 1)*sizeof(unsigned long));
     3556    memmove(&(strat->S_2_R[atS+1]), &(strat->S_2_R[atS]),
     3557            (strat->sl - atS + 1)*sizeof(int));
     3558#else   
     3559    for (i=strat->sl+1; i>=atS+1; i--)
     3560    {
     3561      strat->S[i] = strat->S[i-1];
     3562      strat->ecartS[i] = strat->ecartS[i-1];
     3563      strat->sevS[i] = strat->sevS[i-1];
     3564      strat->S_2_R[i] = strat->S_2_R[i-1];
     3565    }
     3566#endif
    33743567  }
    33753568  if (strat->fromQ!=NULL)
     
    34053598  assume(strat->tailRing == p.tailRing);
    34063599  assume(p.pLength == 0 || pLength(p.p) == p.pLength);
     3600  assume(p.FDeg == p.pFDeg());
     3601  assume(!p.is_normalized || nIsOne(pGetCoeff(p.p)));
    34073602
    34083603  strat->newt = TRUE;
     
    34113606  if (strat->tl == strat->tmax-1)
    34123607    enlargeT(strat->T,strat->R,strat->sevT,strat->tmax,setmax);
    3413   for (i=strat->tl+1; i>=atT+1; i--)
    3414   {
    3415     strat->T[i] = strat->T[i-1];
    3416     strat->sevT[i] = strat->sevT[i-1];
    3417     strat->R[strat->T[i].i_r] = &(strat->T[i]);
     3608  if (atT <= strat->tl)
     3609  {
     3610#ifdef ENTER_USE_MEMMOVE
     3611    memmove(&(strat->T[atT+1]), &(strat->T[atT]),
     3612            (strat->tl-atT+1)*sizeof(TObject));
     3613    memmove(&(strat->sevT[atT+1]), &(strat->sevT[atT]),
     3614            (strat->tl-atT+1)*sizeof(unsigned long));
     3615#endif
     3616    for (i=strat->tl+1; i>=atT+1; i--)
     3617    {
     3618#ifndef ENTER_USE_MEMMOVE
     3619      strat->T[i] = strat->T[i-1];
     3620      strat->sevT[i] = strat->sevT[i-1];
     3621#endif
     3622      strat->R[strat->T[i].i_r] = &(strat->T[i]);
     3623    }
    34183624  }
    34193625
     
    34333639    strat->T[atT].max = NULL;
    34343640
    3435   strat->T[atT].FDeg = p.pFDeg();
    34363641  strat->tl++;
    34373642  strat->R[strat->tl] = &(strat->T[atT]);
     
    34673672    else              PrintS("ideal/module is not homogeneous\n");
    34683673  }
     3674}
     3675
     3676BOOLEAN kPosInLDependsOnLength(int (*pos_in_l)
     3677                               (const LSet set, const int length,
     3678                                LObject* L,const kStrategy strat))
     3679{
     3680  if (pos_in_l == posInL110 ||
     3681      pos_in_l == posInL10)
     3682    return TRUE;
     3683
     3684  return FALSE;
    34693685}
    34703686
     
    35393755  else if (BTEST1(12) || BTEST1(14) || BTEST1(16) || BTEST1(18))
    35403756    strat->posInT = posInT1;
     3757  strat->posInLDependsOnLength = kPosInLDependsOnLength(strat->posInL);
    35413758}
    35423759
     
    37803997 *
    37813998 ***************************************************************/
    3782 BOOLEAN kCheckSpolyCreation(kStrategy strat,
    3783                             poly &m1, poly &m2)
    3784 {
    3785   assume(pNext(strat->P.p) == strat->tail);
    3786   assume(strat->P.p1 != NULL && strat->P.p2 != NULL);
    3787   assume(strat->P.i_r1 >= 0 && strat->P.i_r1 <= strat->tl);
    3788   assume(strat->P.i_r2 >= 0 && strat->P.i_r2 <= strat->tl);
     3999BOOLEAN kCheckSpolyCreation(LObject *L, kStrategy strat, poly &m1, poly &m2)
     4000{
     4001  assume(L->p1 != NULL && L->p2 != NULL);
     4002  assume(L->i_r1 >= 0 && L->i_r1 <= strat->tl);
     4003  assume(L->i_r2 >= 0 && L->i_r2 <= strat->tl);
    37894004  assume(strat->tailRing != currRing);
    37904005 
    3791   if (! k_GetLeadTerms(strat->P.p1, strat->P.p2, currRing,
    3792                        m1, m2, strat->tailRing))
     4006  if (! k_GetLeadTerms(L->p1, L->p2, currRing, m1, m2, strat->tailRing))
    37934007    return FALSE;
    3794   poly p1_max = (strat->R[strat->P.i_r1])->max;
    3795   poly p2_max = (strat->R[strat->P.i_r2])->max;
     4008  poly p1_max = (strat->R[L->i_r1])->max;
     4009  poly p2_max = (strat->R[L->i_r2])->max;
    37964010 
    37974011  if ((p1_max != NULL && !p_LmExpVectorAddIsOk(m1, p1_max, strat->tailRing)) ||
  • Singular/kutil.h

    r3d3d16 r5038cd  
    44*  Computer Algebra System SINGULAR     *
    55****************************************/
    6 /* $Id: kutil.h,v 1.44 2000-11-16 09:54:52 obachman Exp $ */
     6/* $Id: kutil.h,v 1.45 2000-11-23 17:34:10 obachman Exp $ */
    77/*
    88* ABSTRACT: kernel: utils for kStd
     
    119119 
    120120  poly  lcm;   /*- the lcm of p1,p2 -*/
     121  poly last;   // pLast(p) during reductions
    121122  kBucket_pt bucket;
    122123  int   i_r1, i_r2;
     
    134135
    135136  // spoly related things
     137  // preparation for reduction if not spoly
     138  KINLINE void PrepareRed(BOOLEAN use_bucket);
    136139  KINLINE void SetLmTail(poly lm, poly new_p, int length,
    137                          int use_bucket, ring r);
     140                         int use_bucket, ring r, poly last);
    138141  KINLINE void Tail_Minus_mm_Mult_qq(poly m, poly qq, int lq, poly spNoether);
    139142  KINLINE void Tail_Mult_nn(number n);
     143  // deletes bucket, makes sure that p and t_p exists
    140144  KINLINE poly GetP(omBin lmBin = NULL);
    141   KINLINE void CanonicalizeP();
    142  
     145  // does not delete bucket, just canonicalizes it
     146  // returned poly is such that Lm(p) \in currRing, Tail(p) \in tailRing
     147  KINLINE poly CanonicalizeP();
     148 
     149  // makes a copy of the poly of L
     150  KINLINE void Copy();
     151  // gets the poly and makes a copy of it
     152  KINLINE poly CopyGetP();
     153
     154  KINLINE int GetpLength();
     155  KINLINE long pLDeg(BOOLEAN use_last);
    143156  KINLINE long pLDeg();
    144   KINLINE long SetLength();
     157  KINLINE int SetLength(BOOLEAN lengt_pLength = FALSE);
    145158  KINLINE long SetDegStuffReturnLDeg();
     159  KINLINE long SetDegStuffReturnLDeg(BOOLEAN use_last);
    146160
    147161  KINLINE long MinComp();
     
    176190  int (*posInT)(const TSet T,const int tl,const LObject &h);
    177191  int (*posInL)(const LSet set, const int length,
    178                 const LObject &L,const kStrategy strat);
     192                LObject* L,const kStrategy strat);
    179193  void (*enterS)(LObject h, int pos,kStrategy strat, int atR = -1);
    180194  void (*initEcartPair)(LObject * h, poly f, poly g, int ecartF, int ecartG);
    181195  int (*posInLOld)(const LSet Ls,const int Ll,
    182                    const LObject &Lo,const kStrategy strat);
     196                   LObject* Lo,const kStrategy strat);
     197  pFDegProc pOrigFDeg;
     198  pLDegProc pOrigLDeg;
    183199  pFDegProc pOldFDeg;
    184200  ideal Shdl;
     
    204220  pShallowCopyDeleteProc p_shallow_copy_delete;
    205221  BOOLEAN *pairtest;/*used for enterOnePair*/
     222  // if set, pLDeg(p, l) == (pFDeg(pLast(p), pLength)
     223  BOOLEAN LDegLast;
     224  // if set, then L.length == L.pLength
     225  BOOLEAN length_pLength;
     226  // if set, then posInL does not depend on L.length
     227  BOOLEAN posInLDependsOnLength;
    206228  int cp,c3;
    207229  int sl,mu;
     
    246268
    247269void deleteHC(poly *p, int *e, int *l, kStrategy strat);
     270void deleteHC(LObject* L, kStrategy strat, BOOLEAN fromNext = FALSE);
    248271void deleteInS (int i,kStrategy strat);
    249272void cleanT (kStrategy strat);
     
    265288void reorderS (int* suc,kStrategy strat);
    266289int posInL0 (const LSet set, const int length,
    267              const LObject &L,const kStrategy strat);
     290             LObject* L,const kStrategy strat);
    268291int posInL11 (const LSet set, const int length,
    269              const LObject &L,const kStrategy strat);
     292             LObject* L,const kStrategy strat);
    270293int posInL13 (const LSet set, const int length,
    271              const LObject &L,const kStrategy strat);
     294             LObject* L,const kStrategy strat);
    272295int posInL15 (const LSet set, const int length,
    273              const LObject &L,const kStrategy strat);
     296             LObject* L,const kStrategy strat);
    274297int posInL17 (const LSet set, const int length,
    275              const LObject &L,const kStrategy strat);
     298             LObject* L,const kStrategy strat);
     299int posInL10 (const LSet set, const int length,
     300             LObject* L,const kStrategy strat);
    276301KINLINE poly redtailBba (poly p,int pos,kStrategy strat);
    277302poly redtailBba (LObject *L, int pos,kStrategy strat);
    278303poly redtail (poly p,int pos,kStrategy strat);
     304poly redtail (LObject *L,int pos,kStrategy strat);
    279305void enterpairs (poly h, int k, int ec, int pos,kStrategy strat, int atR = -1);
    280306void entersets (LObject h);
     
    296322void cancelunit (LObject* p);
    297323void HEckeTest (poly pp,kStrategy strat);
    298 void redtailS (poly* h,int maxIndex);
    299 void redtailMora (poly* h,int maxIndex);
    300324void initBuchMoraCrit(kStrategy strat);
    301325void initHilbCrit(ideal F, ideal Q, intvec **hilb,kStrategy strat);
     
    314338//        number of first divisor, otherwise
    315339int kFindDivisibleByInT(const TSet &T, const unsigned long* sevT,
    316                         const int tl, const LObject* L);
     340                        const int tl, const LObject* L, const int start=0);
    317341// same with S
    318342int kFindDivisibleByInS(const polyset &S, const unsigned long* sev,
     
    460484//             exponent bound of strat->tailRing
    461485//      FALSE, otherwise
    462 BOOLEAN kCheckSpolyCreation(kStrategy strat, poly &m1, poly &m2);
     486BOOLEAN kCheckSpolyCreation(LObject* L, kStrategy strat, poly &m1, poly &m2);
    463487// change strat->tailRing and adjust all data in strat, L, and T:
    464488// new tailRing has larger exponent bound
  • Singular/pInline0.h

    r3d3d16 r5038cd  
    77 *  Author:  obachman (Olaf Bachmann)
    88 *  Created: 8/00
    9  *  Version: $Id: pInline0.h,v 1.4 2000-11-08 15:34:59 obachman Exp $
     9 *  Version: $Id: pInline0.h,v 1.5 2000-11-23 17:34:11 obachman Exp $
    1010 *******************************************************************/
    1111#ifndef PINLINE0_H
     
    4141}
    4242
    43 
    4443// returns minimal column number in the modul element a (or 0)
    45 PINLINE0 int p_MinComp(poly p, ring r)
     44PINLINE0 long p_MinComp(poly p, ring lmRing, ring tailRing)
    4645{
    47   int result,i;
     46  long result,i;
    4847
    4948  if(p==NULL) return 0;
    50   result = p_GetComp(p,r);
    51   while (pNext(p)!=NULL)
     49  result = p_GetComp(p,lmRing);
     50  if (result != 0)
    5251  {
    53     pIter(p);
    54     i = p_GetComp(p,r);
    55     if (i<result) result = i;
     52    while (pNext(p)!=NULL)
     53    {
     54      pIter(p);
     55      i = p_GetComp(p,tailRing);
     56      if (i<result) result = i;
     57    }
    5658  }
    5759  return result;
     
    6163PINLINE0 long p_MaxComp(poly p, ring lmRing, ring tailRing)
    6264{
    63   int result,i;
     65  long result,i;
    6466
    6567  if(p==NULL) return 0;
    6668  result = p_GetComp(p, lmRing);
    67   while (pNext(p)!=NULL)
     69  if (result != 0)
    6870  {
    69     pIter(p);
    70     i = p_GetComp(p, tailRing);
    71     if (i>result) result = i;
     71    while (pNext(p)!=NULL)
     72    {
     73      pIter(p);
     74      i = p_GetComp(p, tailRing);
     75      if (i>result) result = i;
     76    }
    7277  }
    7378  return result;
     
    113118}
    114119
     120/*2
     121* returns the length of a (numbers of monomials)
     122*/
     123PINLINE0 poly pLast(poly a, int &l)
     124{
     125  if (a == NULL)
     126  {
     127    l = 0;
     128    return NULL;
     129  }
     130  l = 1;
     131  while (pNext(a)!=NULL)
     132  {
     133    pIter(a);
     134    l++;
     135  }
     136  return a;
     137}
     138
    115139#endif // PINLINE_CC
    116140
  • Singular/pInline2.h

    r3d3d16 r5038cd  
    77 *  Author:  obachman (Olaf Bachmann)
    88 *  Created: 8/00
    9  *  Version: $Id: pInline2.h,v 1.17 2000-11-13 14:50:24 levandov Exp $
     9 *  Version: $Id: pInline2.h,v 1.18 2000-11-23 17:34:11 obachman Exp $
    1010 *******************************************************************/
    1111#ifndef PINLINE2_H
     
    465465PINLINE2 poly pp_Mult_mm(poly p, poly m, const ring r)
    466466{
    467   return r->p_Procs->pp_Mult_mm(p, m, NULL, r);
     467  poly last;
     468  int shorter;
     469  return r->p_Procs->pp_Mult_mm(p, m, shorter, NULL, r, last);
    468470}
    469471
     
    478480{
    479481  int shorter;
    480   return r->p_Procs->p_Minus_mm_Mult_qq(p, m, q, shorter, NULL, r);
     482  poly last;
     483  return r->p_Procs->p_Minus_mm_Mult_qq(p, m, q, shorter, NULL, r, last);
    481484}
    482485PINLINE2 poly p_Minus_mm_Mult_qq(poly p, poly m, poly q, int &lp, int lq,
     
    484487{
    485488  int shorter;
    486   poly res = r->p_Procs->p_Minus_mm_Mult_qq(p, m, q, shorter, spNoether, r);
     489  poly last;
     490  poly res = r->p_Procs->p_Minus_mm_Mult_qq(p, m, q, shorter, spNoether, r, last);
    487491  lp = (lp + lq) - shorter;
    488492  return res;
     
    538542PINLINE2 poly pp_Mult_qq(poly p, poly q, const ring r)
    539543{
     544  poly last;
     545  int shorter;
    540546  if (p == NULL || q == NULL) return NULL;
    541547
    542548  if (pNext(p) == NULL)
    543     return r->p_Procs->pp_Mult_mm(q, p, NULL, r);
     549    return r->p_Procs->pp_Mult_mm(q, p, shorter, NULL, r, last);
    544550
    545551  if (pNext(q) == NULL)
    546     return r->p_Procs->pp_Mult_mm(p, q, NULL, r);
     552    return r->p_Procs->pp_Mult_mm(p, q, shorter, NULL, r, last);
    547553
    548554  poly qq = q;
     
    560566PINLINE2 poly p_Plus_mm_Mult_qq(poly p, poly m, poly q, const ring r)
    561567{
    562   poly res;
     568  poly res, last;
    563569  int shorter;
    564570  number n_old = pGetCoeff(m);
     
    567573  pSetCoeff0(m, n_neg);
    568574
    569   res = r->p_Procs->p_Minus_mm_Mult_qq(p, m, q, shorter, NULL, r);
     575  res = r->p_Procs->p_Minus_mm_Mult_qq(p, m, q, shorter, NULL, r, last);
    570576  pSetCoeff0(m, n_old);
    571577  n_Delete(&n_neg, r);
  • Singular/p_Minus_mm_Mult_qq__Template.cc

    r3d3d16 r5038cd  
    77 *  Author:  obachman (Olaf Bachmann)
    88 *  Created: 8/00
    9  *  Version: $Id: p_Minus_mm_Mult_qq__Template.cc,v 1.6 2000-11-03 14:50:21 obachman Exp $
     9 *  Version: $Id: p_Minus_mm_Mult_qq__Template.cc,v 1.7 2000-11-23 17:34:11 obachman Exp $
    1010 *******************************************************************/
    1111
     
    1818 *
    1919 ***************************************************************/
    20 poly p_Minus_mm_Mult_qq(poly p, poly m, poly q, int& Shorter, const poly spNoether, const ring r)
     20poly p_Minus_mm_Mult_qq(poly p, poly m, poly q, int& Shorter, const poly spNoether, const ring r, poly &last)
    2121{
    2222  p_Test(p, r);
     
    105105  a = pNext(a) = p;// append p to result and advance p
    106106  pIter(p);
    107   if (p == NULL) goto Finish;;
     107  if (p == NULL) goto Finish;
    108108  goto CmpTop;
    109109 
     
    111111  Finish: // q or p is NULL: Clean-up time
    112112  if (q == NULL) // append rest of p to result
     113  {
    113114    pNext(a) = p;
     115    if (p == NULL) last = a;
     116  }
    114117  else  // append (- m*q) to result
    115118  {
    116119    pSetCoeff0(m, tneg);
    117     pNext(a) = r->p_Procs->pp_Mult_mm(q, m, spNoether, r);
     120    last = a;
     121    pNext(a) = r->p_Procs->pp_Mult_mm(q, m, shorter, spNoether, r, last);
    118122    pSetCoeff0(m, tm);
    119123  }
  • Singular/p_Mult_q.cc

    r3d3d16 r5038cd  
    77 *  Author:  obachman (Olaf Bachmann)
    88 *  Created: 8/00
    9  *  Version: $Id: p_Mult_q.cc,v 1.5 2000-09-18 09:19:26 obachman Exp $
     9 *  Version: $Id: p_Mult_q.cc,v 1.6 2000-11-23 17:34:11 obachman Exp $
    1010 *******************************************************************/
    1111#include "mod2.h"
     
    9595}
    9696
    97 #if 0
    98 poly _p_Mult_q(poly p, poly q, const int copy, const ring r)
    99 {
    100   pAssume (p != NULL && pNext(p) != NULL && q != NULL && pNext(q) != NULL);
    101  
    102   // to minimize the number of polynomial comparisons
    103   // we reverse p and should arrange p and q such that
    104   // pLast(p)*pHead(q) > pHead(p)*pLast(q)
    105   // as a first approximation, we just compare the head terms
    106 #if 0 
    107   if (p_LmCmp(p, q, r) == -1)
    108   {
    109     poly tmp = q;
    110     q = p;
    111     p = tmp;
    112   }
    113   p = r->p_Procs->p_ReverseNeg(p, r);
    114 #endif
    115 
    116   poly pp = p;
    117   int shorter;
    118   p_Minus_mm_Mult_qq_Proc_Ptr p_minus_mm_mult_qq
    119     =  r->p_Procs->p_Minus_mm_Mult_qq;
    120   poly pr = NULL;
    121 
    122   while (pp != NULL)
    123   {
    124     pr = p_minus_mm_mult_qq(pr, pp, q, shorter, NULL, r);
    125     pIter(pp);
    126   }
    127  
    128   if (copy)
    129   {
    130     r->p_Procs->p_ReverseNeg(p, r);
    131   }
    132   else
    133   {
    134     r->p_Procs->p_Delete(&q, r);
    135     r->p_Procs->p_Delete(&p, r);
    136   }
    137   return pr;
    138 }
    139 
    140  
    141  
    142 #endif
  • Singular/p_Procs.h

    r3d3d16 r5038cd  
    88 *  Author:  obachman (Olaf Bachmann)
    99 *  Created: 8/00
    10  *  Version: $Id: p_Procs.h,v 1.7 2000-11-03 14:50:22 obachman Exp $
     10 *  Version: $Id: p_Procs.h,v 1.8 2000-11-23 17:34:12 obachman Exp $
    1111 *******************************************************************/
    1212#ifndef P_PROCS_H
     
    2222typedef poly (*p_Mult_mm_Proc_Ptr)(poly p, poly m, const ring r);
    2323typedef poly (*pp_Mult_mm_Proc_Ptr)(poly p, poly m,
    24                                    poly spNoether, const ring r);
     24                                    int &shorter, poly spNoether,
     25                                    const ring r,
     26                                    poly &last);
    2527typedef poly (*p_Add_q_Proc_Ptr)(poly p, poly q, int & shorter, const ring r);
    2628typedef poly (*p_Minus_mm_Mult_qq_Proc_Ptr)(poly p, poly m, poly q,
    27                                                 int &shorter, poly spNoether,
    28                                                 const ring r);
     29                                            int &shorter, poly spNoether,
     30                                            const ring r, poly &last);
    2931typedef poly (*p_Neg_Proc_Ptr)(poly p, const ring r);
    3032typedef poly (*pp_Mult_Coeff_mm_DivSelect_Proc_Ptr)(poly p, const poly m, const ring r);
  • Singular/p_polys.cc

    r3d3d16 r5038cd  
    77 *  Author:  obachman (Olaf Bachmann)
    88 *  Created: 8/00
    9  *  Version: $Id: p_polys.cc,v 1.9 2000-11-14 16:04:59 obachman Exp $
     9 *  Version: $Id: p_polys.cc,v 1.10 2000-11-23 17:34:12 obachman Exp $
    1010 *******************************************************************/
    1111
     
    169169* the ordering is compatible with degree, use a->order
    170170*/
    171 long pDeg(poly a, ring r)
     171inline long _pDeg(poly a, ring r)
    172172{
    173173  p_LmCheckPolyRing(a, r);
    174174  assume(p_GetOrder(a, r) == pWTotaldegree(a, r));
    175175  return p_GetOrder(a, r);
     176}
     177
     178long pDeg(poly a, ring r)
     179{
     180  return _pDeg(a, r);
    176181}
    177182
     
    182187* the ordering is not compatible with degree so do not use p->Order
    183188*/
    184 long pTotaldegree(poly p, ring r)
     189inline long _pTotaldegree(poly p, ring r)
    185190{
    186191  p_LmCheckPolyRing(p, r);
    187192  return (long) p_ExpVectorQuerSum(p, r);
     193}
     194long pTotaldegree(poly p, ring r)
     195{
     196  return (long) _pTotaldegree(p, r);
    188197}
    189198
     
    295304  int ll=1;
    296305
    297   while ((pNext(p)!=NULL) && (p_GetComp(pNext(p), r)==k))
    298   {
    299     pIter(p);
    300     ll++;
     306  if (k > 0)
     307  {
     308    while ((pNext(p)!=NULL) && (p_GetComp(pNext(p), r)==k))
     309    {
     310      pIter(p);
     311      ll++;
     312    }
     313  }
     314  else
     315  {
     316     while (pNext(p)!=NULL)
     317     {
     318       pIter(p);
     319       ll++;
     320     }
    301321  }
    302322  *l=ll;
     
    354374  int ll=1;
    355375
    356   while (((p=pNext(p))!=NULL) && (p_GetComp(p, r)==k))
    357   {
    358     ll++;
     376  if (k != 0)
     377  {
     378    while (((p=pNext(p))!=NULL) && (p_GetComp(p, r)==k))
     379    {
     380      ll++;
     381    }
     382  }
     383  else
     384  {
     385    while ((p=pNext(p)) !=NULL)
     386    {
     387      ll++;
     388    }
    359389  }
    360390  *l=ll;
     
    374404  long  t,max;
    375405
    376   max=pFDeg(p);
    377   while (((p=pNext(p))!=NULL) && (p_GetComp(p, r)==k))
    378   {
    379     t=pFDeg(p, r);
    380     if (t>max) max=t;
    381     ll++;
     406  max=pFDeg(p, r);
     407  if (k > 0)
     408  {
     409    while (((p=pNext(p))!=NULL) && (p_GetComp(p, r)==k))
     410    {
     411      t=pFDeg(p, r);
     412      if (t>max) max=t;
     413      ll++;
     414    }
     415  }
     416  else
     417  {
     418    while ((p=pNext(p))!=NULL)
     419    {
     420      t=pFDeg(p, r);
     421      if (t>max) max=t;
     422      ll++;
     423    }
    382424  }
    383425  *l=ll;
     
    398440
    399441  max=pFDeg(p, r);
    400   while ((p=pNext(p))!=NULL)
    401   {
    402     if (! rIsSyzIndexRing(r) ||
    403         (p_GetComp(p, r)<=rGetCurrSyzLimit(r)))
    404     {
    405        if ((t=pFDeg(p, r))>max) max=t;
    406        ll++;
    407     }
    408     else break;
     442  if (rIsSyzIndexRing(r))
     443  {
     444    long limit = rGetCurrSyzLimit(r);
     445    while ((p=pNext(p))!=NULL)
     446    {
     447      if (p_GetComp(p, r)<=limit)
     448      {
     449        if ((t=pFDeg(p, r))>max) max=t;
     450        ll++;
     451      }
     452      else break;
     453    }
     454  }
     455  else
     456  {
     457    while ((p=pNext(p))!=NULL)
     458    {
     459      if ((t=pFDeg(p, r))>max) max=t;
     460      ll++;
     461    }
     462  }
     463  *l=ll;
     464  return max;
     465}
     466
     467// like pLDeg1, only pFDeg == Deg
     468long pLDeg1_Deg(poly p,int *l, ring r)
     469{
     470  p_CheckPolyRing(p, r);
     471  Exponent_t k= p_GetComp(p, r);
     472  int ll=1;
     473  long  t,max;
     474
     475  max=_pDeg(p, r);
     476  if (k > 0)
     477  {
     478    while (((p=pNext(p))!=NULL) && (p_GetComp(p, r)==k))
     479    {
     480      t=_pDeg(p, r);
     481      if (t>max) max=t;
     482      ll++;
     483    }
     484  }
     485  else
     486  {
     487    while ((p=pNext(p))!=NULL)
     488    {
     489      t=_pDeg(p, r);
     490      if (t>max) max=t;
     491      ll++;
     492    }
     493  }
     494  *l=ll;
     495  return max;
     496}
     497
     498long pLDeg1c_Deg(poly p,int *l, ring r)
     499{
     500  p_CheckPolyRing(p, r);
     501  int ll=1;
     502  long  t,max;
     503
     504  max=_pDeg(p, r);
     505  if (rIsSyzIndexRing(r))
     506  {
     507    long limit = rGetCurrSyzLimit(r);
     508    while ((p=pNext(p))!=NULL)
     509    {
     510      if (p_GetComp(p, r)<=limit)
     511      {
     512        if ((t=_pDeg(p, r))>max) max=t;
     513        ll++;
     514      }
     515      else break;
     516    }
     517  }
     518  else
     519  {
     520    while ((p=pNext(p))!=NULL)
     521    {
     522      if ((t=_pDeg(p, r))>max) max=t;
     523      ll++;
     524    }
     525  }
     526  *l=ll;
     527  return max;
     528}
     529
     530// like pLDeg1, only pFDeg == pTotoalDegree
     531long pLDeg1_Totaldegree(poly p,int *l, ring r)
     532{
     533  p_CheckPolyRing(p, r);
     534  Exponent_t k= p_GetComp(p, r);
     535  int ll=1;
     536  long  t,max;
     537
     538  max=_pTotaldegree(p, r);
     539  if (k > 0)
     540  {
     541    while (((p=pNext(p))!=NULL) && (p_GetComp(p, r)==k))
     542    {
     543      t=_pTotaldegree(p, r);
     544      if (t>max) max=t;
     545      ll++;
     546    }
     547  }
     548  else
     549  {
     550    while ((p=pNext(p))!=NULL)
     551    {
     552      t=_pTotaldegree(p, r);
     553      if (t>max) max=t;
     554      ll++;
     555    }
     556  }
     557  *l=ll;
     558  return max;
     559}
     560
     561long pLDeg1c_Totaldegree(poly p,int *l, ring r)
     562{
     563  p_CheckPolyRing(p, r);
     564  int ll=1;
     565  long  t,max;
     566
     567  max=_pTotaldegree(p, r);
     568  if (rIsSyzIndexRing(r))
     569  {
     570    long limit = rGetCurrSyzLimit(r);
     571    while ((p=pNext(p))!=NULL)
     572    {
     573      if (p_GetComp(p, r)<=limit)
     574      {
     575        if ((t=_pTotaldegree(p, r))>max) max=t;
     576        ll++;
     577      }
     578      else break;
     579    }
     580  }
     581  else
     582  {
     583    while ((p=pNext(p))!=NULL)
     584    {
     585      if ((t=_pTotaldegree(p, r))>max) max=t;
     586      ll++;
     587    }
    409588  }
    410589  *l=ll;
     
    533712  return TRUE;
    534713}
     714
     715/*2
     716*test if a monomial /head term is a pure power
     717*/
     718int p_IsPurePower(const poly p, const ring r)
     719{
     720  int i,k=0;
     721
     722  for (i=r->N;i;i--)
     723  {
     724    if (p_GetExp(p,i, r)!=0)
     725    {
     726      if(k!=0) return 0;
     727      k=i;
     728    }
     729  }
     730  return k;
     731}
  • Singular/p_polys.h

    r3d3d16 r5038cd  
    88 *  Author:  obachman (Olaf Bachmann)
    99 *  Created: 9/00
    10  *  Version: $Id: p_polys.h,v 1.14 2000-11-14 16:05:00 obachman Exp $
     10 *  Version: $Id: p_polys.h,v 1.15 2000-11-23 17:34:12 obachman Exp $
    1111 *******************************************************************/
    1212#ifndef P_POLYS_H
     
    214214// return TRUE if all monoms have the same component
    215215BOOLEAN   p_OneComp(poly p, ring r);
     216int       p_IsPurePower(const poly p, const ring r);
     217
    216218/***************************************************************
    217219 *
     
    299301PINLINE0   long p_MaxComp(poly p, ring lmRing, ring tailRing);
    300302inline long p_MaxComp(poly p,ring lmRing) {return p_MaxComp(p,lmRing,lmRing);}
    301 PINLINE0   int  p_MinComp(poly p, ring r);
     303PINLINE0   long p_MinComp(poly p, ring lmRing, ring tailRing);
     304inline long p_MinComp(poly p,ring lmRing) {return p_MinComp(p,lmRing,lmRing);}
    302305
    303306/***************************************************************
     
    307310 ***************************************************************/
    308311PINLINE0 int       pLength(poly a);
     312PINLINE0 poly      pLast(poly a, int &length);
     313inline   poly      pLast(poly a) { int l; return pLast(a, l);}
    309314PINLINE0 poly pReverse(poly p);
    310315
     
    346351long pLDeg1(poly p,int *l, ring r);
    347352long pLDeg1c(poly p,int *l, ring r);
     353long pLDeg1_Deg(poly p,int *l, ring r);
     354long pLDeg1c_Deg(poly p,int *l, ring r);
     355long pLDeg1_Totaldegree(poly p,int *l, ring r);
     356long pLDeg1c_Totaldegree(poly p,int *l, ring r);
    348357
    349358/***************************************************************
  • Singular/polys.h

    r3d3d16 r5038cd  
    44*  Computer Algebra System SINGULAR     *
    55****************************************/
    6 /* $Id: polys.h,v 1.45 2000-11-14 16:05:00 obachman Exp $ */
     6/* $Id: polys.h,v 1.46 2000-11-23 17:34:12 obachman Exp $ */
    77/*
    88* ABSTRACT - all basic methods to manipulate polynomials of the
     
    237237BOOLEAN   pIsConstant(const poly p);
    238238BOOLEAN   pIsConstantPoly(poly p);
    239 int       pIsPurePower(const poly p);
     239#define   pIsPurePower(p)   p_IsPurePower(p, currRing)
    240240#define   pIsVector(p)     (pGetComp(p)!=0)
    241241BOOLEAN   pHasNotCF(poly p1, poly p2);   /*has no common factor ?*/
     
    270270long pLDeg1(poly p,int *l, ring r = currRing);
    271271long pLDeg1c(poly p,int *l, ring r = currRing);
     272long pLDeg1_Deg(poly p,int *l, ring r = currRing);
     273long pLDeg1c_Deg(poly p,int *l, ring r = currRing);
     274long pLDeg1_Totaldegree(poly p,int *l, ring r = currRing);
     275long pLDeg1c_Totaldegree(poly p,int *l, ring r = currRing);
    272276
    273277/*-------------pComp for syzygies:-------------------*/
  • Singular/polys1.cc

    r3d3d16 r5038cd  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: polys1.cc,v 1.53 2000-11-14 16:05:00 obachman Exp $ */
     4/* $Id: polys1.cc,v 1.54 2000-11-23 17:34:13 obachman Exp $ */
    55
    66/*
     
    6262}
    6363
    64 /*2
    65 *test if a monomial /head term is a pure power
    66 */
    67 int pIsPurePower(const poly p)
    68 {
    69   int i,k=0;
    70 
    71   for (i=pVariables;i;i--)
    72   {
    73     if (pGetExp(p,i)!=0)
    74     {
    75       if(k!=0) return 0;
    76       k=i;
    77     }
    78   }
    79   return k;
    80 }
    8164
    8265
  • Singular/pp_Mult_mm__Template.cc

    r3d3d16 r5038cd  
    77 *  Author:  obachman (Olaf Bachmann)
    88 *  Created: 8/00
    9  *  Version: $Id: pp_Mult_mm__Template.cc,v 1.6 2000-10-30 16:54:56 obachman Exp $
     9 *  Version: $Id: pp_Mult_mm__Template.cc,v 1.7 2000-11-23 17:34:13 obachman Exp $
    1010 *******************************************************************/
    1111
     
    1818 *
    1919 ***************************************************************/
    20 poly pp_Mult_mm(poly p, const poly m, const poly spNoether, const ring ri)
     20poly pp_Mult_mm(poly p, const poly m, int& Shorter, const poly spNoether, const ring ri, poly &last)
    2121{
    2222  p_Test(p, ri);
    2323  p_LmTest(m, ri);
    24   if (p == NULL) return NULL;
     24  if (p == NULL)
     25  {
     26    last = NULL;
     27    return NULL;
     28  }
    2529  spolyrec rp;
    2630  poly q = &rp, r;
     
    4549    }
    4650    while (p != NULL);
     51    last = q;
    4752  }
    4853  else
     
    5661      if (p_LmCmp(r, spNoether, ri) == -1)
    5762      {
     63        Shorter += pLength(p);
    5864        p_FreeBinAddr(r, ri);
    5965        break;
     
    6369      pIter(p);
    6470    }
     71    if (q  != &rp) last = q;
    6572  }
    6673  pNext(q) = NULL;
    67  
     74
    6875  p_Test(pNext(&rp), ri);
    6976  return pNext(&rp);
  • Singular/ring.cc

    r3d3d16 r5038cd  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: ring.cc,v 1.144 2000-11-23 14:06:50 Singular Exp $ */
     4/* $Id: ring.cc,v 1.145 2000-11-23 17:34:13 obachman Exp $ */
    55
    66/*
     
    26312631    {
    26322632      // Hmm... sometimes (e.g., from maGetPreimage) new variables
    2633       // are intorduced, but their name is never set
    2634       // hence, do the following awkward trick
     2633      // are intorduced, but their names are never set
     2634      // hence, we do the following awkward trick
    26352635      int N = omSizeWOfAddr(r->names);
    26362636      if (r->N < N) N = r->N;
     
    27072707  r->ComponentOrder = 1;
    27082708  r->pFDeg = pTotaldegree;
    2709   r->pLDeg = (r->OrdSgn == 1 ? r->pLDeg = pLDegb : pLDeg0);
     2709  r->pLDeg = (r->OrdSgn == 1 ? pLDegb : pLDeg0);
    27102710
    27112711  /*======== ordering type is (_,c) =========================*/
     
    27432743  &&  (order[2]==0))
    27442744  {
    2745     /* pLDeg = ldeg0; is standard*/
    27462745    if ((order[0]==ringorder_C)||(order[0]==ringorder_S)||
    27472746        order[0]==ringorder_s)
Note: See TracChangeset for help on using the changeset viewer.