Changeset 8eab868 in git


Ignore:
Timestamp:
Nov 6, 2002, 6:47:13 PM (21 years ago)
Author:
Michael Brickenstein <bricken@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', '0604212ebb110535022efecad887940825b97c3f')
Children:
2713491c6c06aabef211b682ac1f5dda2749e54c
Parents:
030fcb083622316619951241eba12a84c7c3cd28
Message:
+ updated reductions


git-svn-id: file:///usr/local/Singular/svn/trunk@6312 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/tgb.cc

    r030fcb0 r8eab868  
    3131  int b;
    3232};
     33BOOLEAN lenS_correct(kStrategy strat){
     34  int i;
     35  for(i=0;i<=strat->sl;i++){
     36    if (strat->lenS[i]!=pLength(strat->S[i]))
     37        return FALSE;
     38  }
     39  return TRUE;
     40   
     41}
    3342int bucket_guess(kBucket* bucket){
    3443  int sum=0;
     
    203212void move_forward_in_S(int old_pos, int new_pos,kStrategy strat)
    204213{
     214  assume(old_pos>=new_pos);
    205215  poly p=strat->S[old_pos];
    206216  int ecart=strat->ecartS[old_pos];
     
    225235  strat->S_2_R[new_pos]=s_2_r;
    226236  strat->lenS[new_pos]=length;
     237  //assume(lenS_correct(strat));
    227238}
    228239void replace_pair(int & i, int & j, calc_dat* c)
     
    685696  (*at)--;
    686697  (*k)--;
     698//  assume(lenS_correct(strat));
    687699}
    688700void add_to_basis(poly h, int i_pos, int j_pos,calc_dat* c)
    689701{
     702//  BOOLEAN corr=lenS_correct(c->strat);
    690703  BOOLEAN R_found=FALSE;
    691704  void* hp;
     
    749762        c->rep[j]=i;
    750763        PrintS("R"); R_found=TRUE;
    751 
     764        if((i_pos>=0) && (j_pos>=0)){
    752765        c->misses[i_pos]--;
    753766        c->misses[j_pos]--;
     767        }
    754768        for(int z=0;z<j;z++){
    755769          if (c->states[j][z]==UNCALCULATED){
     
    804818    if (c->lengths[c->n-1]==1)
    805819      shorten_tails(c,c->S->m[c->n-1]);
     820    // if (corr){
     821   
     822//     corr=lenS_correct(c->strat);
     823//     if(!corr){
     824//       PrintS("korupted in shorten tails");
     825//     }
     826//     }
    806827    //you should really update c->lengths, c->strat->lenS, and the oder of polys in strat if you sort after lengths
    807828
     
    881902  P.SetShortExpVector();
    882903  P.bucket = kBucketCreate(currRing);
     904  // BOOLEAN corr=lenS_correct(strat);
    883905  kBucketInit(P.bucket,P.p,len /*pLength(P.p)*/);
    884906  //int max_pos=simple_posInS(strat,P.p);
    885907  loop
    886908    {
     909//       if (corr){
     910       
     911//      corr=lenS_correct(strat);
     912//      if(!corr){
     913//        PrintS("korupt");
     914//      }
     915//       }
    887916      int compare_bound;
    888917      compare_bound=bucket_guess(P.bucket);
     
    893922          poly sec_copy=NULL;
    894923          //pseudo code
    895           BOOLEAN must_replace_in_basis=(len_upper_bound<=strat->lenS[j]);//first test
     924          BOOLEAN must_expand=FALSE;
     925          BOOLEAN must_replace_in_basis=(len_upper_bound<strat->lenS[j]);//first test
    896926          if (must_replace_in_basis)
    897927            {
     
    906936                {
    907937                  must_replace_in_basis=FALSE;
     938                  if ((len_upper_bound==1)
     939                      ||(len_upper_bound==2)
     940                      ||(len_upper_bound<strat->lenS[j]/2))
     941                  {
     942                    PrintS("e");
     943                    sec_copy=kBucketClear(P.bucket);
     944                    kBucketInit(P.bucket,pCopy(sec_copy),pLength(sec_copy));
     945                    must_expand=TRUE;
     946                  }
    908947                }
    909948            }
     949//        must_expand=FALSE;
     950//        must_replace_in_basis=FALSE;
    910951          nNormalize(pGetCoeff(P.p));
    911952#ifdef KDEBUG
     
    924965          nDelete(&coef);
    925966          h = kBucketGetLm(P.bucket);
    926           //pseudo code
     967       
    927968          if (must_replace_in_basis){
    928             int old_pos_in_c=-1;
     969            int pos_in_c=-1;
    929970            poly p=strat->S[j];
    930971            int z;
    931    
     972            
    932973            int new_length=pLength(sec_copy);
    933974            Print("%i",strat->lenS[j]-new_length);
    934975            len_upper_bound=new_length +strat->lenS[j]-2;//old entries length
    935976            int new_pos=simple_posInS(c->strat,strat->S[j],new_length);//hack
    936    strat->S[j]=sec_copy;
    937    c->strat->lenS[j]=new_length;
    938    
    939    for (z=c->n;z;z--)
    940      {
    941        if(p==c->S->m[z-1])
    942          {
    943            c->S->m[z-1]=sec_copy;
    944            old_pos_in_c=z-1;
    945            c->lengths[z-1]=new_length;
    946            if (new_length==1)
    947              {
    948                int i;
    949                for ( i=0;i<z-1;i++)
    950                  {
    951                    if (c->lengths[i]==1)
    952                      c->states[z-1][i]=HASTREP;
    953                  }
    954                for ( i=z;i<c->n;i++){
    955                  if (c->lengths[i]==1)
    956                    c->states[i][z-1]=HASTREP;
    957                }
    958                shorten_tails(c,sec_copy);
    959              }
    960            break;
    961          }
    962      }
    963    pDelete(&p);
    964 
    965    //   replace_quietly(c,j,sec_copy);
    966    // have to do many additional things for consistency
    967    {
    968      
    969      
    970      
    971 
    972      int old_pos=j;
    973      new_pos=min(old_pos, new_pos);
    974      assume(new_pos<=old_pos);
    975  
    976 
    977      c->strat->lenS[old_pos]=new_length;
    978      int i=0;
    979      for(i=new_pos;i<old_pos;i++){
    980        if (strat->lenS[i]<=new_length)
    981          new_pos++;
    982        else
    983          break;
    984      }
    985      if (new_pos<old_pos)
    986        move_forward_in_S(old_pos,new_pos,c->strat);
    987    
    988 
    989    }
    990  }
    991  if (h==NULL) return NULL;
    992  P.p=h;
    993  P.t_p=NULL;
    994  P.SetShortExpVector();
     977           
     978//          p=NULL;
     979            for (z=c->n;z;z--)
     980            {
     981              if(p==c->S->m[z-1])
     982              {
     983               
     984               
     985                pos_in_c=z-1;
     986
     987                break;
     988              }
     989            }
     990            if (z<=0){
     991              //not in c->S
     992              //LEAVE
     993              deleteInS(j,c->strat);
     994              //ENTER
     995               int mlength=pLength(sec_copy);
     996            int mi=simple_posInS(c->strat,sec_copy,mlength);
     997           
     998            LObject mP; memset(&mP,0,sizeof(mP));
     999            mP.tailRing=c->r;
     1000            mP.p=sec_copy; /*p_Copy(h,c->r);*/
     1001            mP.FDeg=pFDeg(mP.p,c->r);
     1002            if (!rField_is_Zp(c->r)) pCleardenom(mP.p);
     1003            //enterT(P,c->strat,-1);
     1004            c->strat->enterS(mP,mi,c->strat);
     1005            c->strat->lenS[mi]=mlength;
     1006            pNorm(c->strat->S[mi]);
     1007            }
     1008            else {
     1009//shorten_tails may alter position (not the length, even not by recursion in GLOBAL case)
     1010
     1011              strat->S[j]=sec_copy;
     1012              c->strat->lenS[j]=new_length;
     1013              pDelete(&p);
     1014             
     1015              //        replace_quietly(c,j,sec_copy);
     1016              // have to do many additional things for consistency
     1017              {
     1018               
     1019               
     1020               
     1021
     1022                int old_pos=j;
     1023                new_pos=min(old_pos, new_pos);
     1024                assume(new_pos<=old_pos);
     1025               
     1026               
     1027                c->strat->lenS[old_pos]=new_length;
     1028                int i=0;
     1029                for(i=new_pos;i<old_pos;i++){
     1030                  if (strat->lenS[i]<=new_length)
     1031                    new_pos++;
     1032                  else
     1033                    break;
     1034                }
     1035                if (new_pos<old_pos)
     1036                  move_forward_in_S(old_pos,new_pos,c->strat);
     1037               
     1038                c->S->m[pos_in_c]=sec_copy;
     1039                               
     1040                c->lengths[pos_in_c]=new_length;
     1041                if (new_length==1)
     1042                {
     1043                  int i;
     1044                  for ( i=0;i<pos_in_c;i++)
     1045                  {
     1046                    if (c->lengths[i]==1)
     1047                      c->states[pos_in_c][i]=HASTREP;
     1048                  }
     1049                  for ( i=z;i<c->n;i++){
     1050                    if (c->lengths[i]==1)
     1051                      c->states[i][pos_in_c]=HASTREP;
     1052                  }
     1053                          shorten_tails(c,sec_copy);
     1054                }
     1055              }
     1056            }
     1057          }
     1058          if(must_expand){
     1059            //i=posInS(c->strat,c->strat->sl,h,0 /*ecart*/);
     1060            int mlength=pLength(sec_copy);
     1061            int mi=simple_posInS(c->strat,sec_copy,mlength);
     1062           
     1063            LObject mP; memset(&mP,0,sizeof(mP));
     1064            mP.tailRing=c->r;
     1065            mP.p=sec_copy; /*p_Copy(h,c->r);*/
     1066            mP.FDeg=pFDeg(mP.p,c->r);
     1067            if (!rField_is_Zp(c->r)) pCleardenom(mP.p);
     1068            //enterT(P,c->strat,-1);
     1069            c->strat->enterS(mP,mi,c->strat);
     1070            c->strat->lenS[mi]=mlength;
     1071            pNorm(c->strat->S[mi]);
     1072       
     1073          }
     1074          if (h==NULL) return NULL;
     1075          P.p=h;
     1076          P.t_p=NULL;
     1077          P.SetShortExpVector();
    9951078#ifdef KDEBUG
    996  if (TEST_OPT_DEBUG)
    997    {
    998      PrintS("\nto:");
    999      wrp(h);
     1079          if (TEST_OPT_DEBUG)
     1080          {
     1081            PrintS("\nto:");
     1082            wrp(h);
    10001083     PrintLn();
    1001    }
     1084          }
    10021085#endif
    10031086        }
    1004     else
     1087      else
    10051088      {
    10061089        kBucketClear(P.bucket,&(P.p),&len);
     
    11811264
    11821265      hr=redNF2(h,c,len);
    1183 #ifdef HALFREDUCTIONS
    1184       int real_sl=c->strat->sl;
    1185       int l;
    1186       for(l=0;l<c->n;l++){
    1187         if (c->strat->lenS[l]>4)
    1188           break;
    1189       }
    1190       c->strat->sl=l;
    1191 #endif
     1266//      hr=redNF(h,c->strat,len);
     1267
    11921268      if (hr!=NULL)
    11931269#ifdef REDTAIL_S
     
    11961272      hr = redtailBba(hr,c->strat->sl,c->strat);
    11971273#endif
    1198 #ifdef HALFREDUCTIONS
    1199       c->strat->sl=real_sl;
    1200 #endif
     1274
    12011275    }
    12021276#else
     
    13551429void shorten_tails(calc_dat* c, poly monom)
    13561430{
    1357 
     1431// BOOLEAN corr=lenS_correct(c->strat);
    13581432  for(int i=0;i<c->n;i++)
    13591433    {
     
    13841458          int old_pos=-1;
    13851459          //assume new_pos<old_pos
    1386           for (int z=new_pos;z<=c->strat->sl;z++)
     1460          for (int z=0;z<=c->strat->sl;z++)
    13871461            {
    13881462              if (c->strat->S[z]==c->S->m[i])
     
    14221496            }
    14231497        }
    1424     }
    1425 }
     1498     
     1499    }
     1500//   if (corr){
     1501   
     1502//     corr=lenS_correct(c->strat);
     1503//     if(!corr){
     1504//       PrintS("korupted in shorten tails");
     1505//     }
     1506//   }
     1507}
Note: See TracChangeset for help on using the changeset viewer.