Changeset a0e0258 in git


Ignore:
Timestamp:
Mar 16, 2016, 12:09:05 PM (8 years ago)
Author:
Yue <ren@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', '4bd32dfef92ec9f5ed8dceee82d14318ae147107')
Children:
536e0345b0ecea04de0317c030a9643c6a8ed988
Parents:
58399e5955b89ce4f0005174693ea0831df58d45
Message:
fix: satstd various bugs
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/dyn_modules/customstd/customstd.cc

    r58399e ra0e0258  
    4949  {
    5050    poly p=strat->P.p;
    51     if (pNext(p)==NULL)
    52     {
    53       // if a term is contained in the ideal, abort std computation
    54       // and store the whole ring in idealCache to be returned
    55       while ((strat->Ll >= 0))
    56         deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
    57       idealCache = idInit(1);
    58       idealCache->m[0] = p_One(currRing);
    59       return FALSE;
    60     }
    6151
    6252    // iterate over all terms of p and
     
    6555    int *m0=(int*)omAlloc((1+rVar(currRing))*sizeof(int));
    6656    p_GetExpV(p,mm,currRing);
    67     bool nonTrivialSaturationToBeDone=false;
     57    bool nonTrivialSaturationToBeDone=true;
    6858    for (p=pNext(p); p!=NULL; pIter(p))
    6959    {
     
    8373      // std::cout << "simplifying!" << std::endl;
    8474      p=p_Copy(strat->P.p,currRing);
     75      memset(&strat->P,0,sizeof(strat->P));
     76      strat->P.tailRing = strat->tailRing;
    8577      strat->P.p=p;
    8678      while(p!=NULL)
    8779      {
    88         for (int i=1; i<satstdSaturatingVariables.size(); i++)
     80        for (int i=0; i<satstdSaturatingVariables.size(); i++)
    8981        {
    9082          int li = satstdSaturatingVariables[i];
     
    10294  {
    10395    poly p=strat->P.t_p;
    104     if (pNext(p)==NULL)
    105     {
    106       // if a term is contained in the ideal, abort std computation
    107       // and store the output in idealCache to be returned
    108       while ((strat->Ll >= 0))
    109         deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
    110       idealCache = idInit(1);
    111       idealCache->m[0] = p_One(currRing);
    112       return FALSE;
    113     }
    11496
    11597    // iterate over all terms of p and
     
    118100    int *m0=(int*)omAlloc((1+rVar(currRing))*sizeof(int));
    119101    p_GetExpV(p,mm,strat->tailRing);
    120     bool nonTrivialSaturationToBeDone=false;
     102    bool nonTrivialSaturationToBeDone=true;
    121103    for (p = pNext(p); p!=NULL; pIter(p))
    122104    {
     
    135117    {
    136118      p=p_Copy(strat->P.t_p,strat->tailRing);
     119      memset(&strat->P,0,sizeof(strat->P));
     120      strat->P.tailRing = strat->tailRing;
    137121      strat->P.t_p=p;
    138       strat->P.p=NULL;
    139122      while(p!=NULL)
    140123      {
    141         for(int i=1;i<=rVar(currRing);i++)
    142           p_SubExp(p,i,mm[i],strat->tailRing);
     124        for(int i=0; i<satstdSaturatingVariables.size(); i++)
     125        {
     126          int li = satstdSaturatingVariables[i];
     127          p_SubExp(p,li,mm[li],strat->tailRing);
     128        }
    143129        p_Setm(p,strat->tailRing);
    144130        pIter(p);
     
    174160
    175161  // check that remaining variables have zero exponent
    176   for (i++; i<=rVar(r); i++)
     162  for (l=i+1; l<=rVar(r); l++)
    177163  {
    178     if (p_GetExp(x,i,r)>0)
     164    if (p_GetExp(x,l,r)>0)
    179165      return 0;
    180166  }
    181167
    182   return l;
    183 }
    184 
    185 //------------------------------------------------------------------------
    186 // routine that simplifies the ideal dividing each generator by the maximal monomial dividing it
    187 // in particular returns 1 if a generator is a term
    188 // to be used before starting saturation with respect to all variables
    189 static void satSimplify(ideal I, const ring r)
    190 {
    191   idSkipZeroes(I);
    192   int k = IDELEMS(I);
    193   int *mm=(int*)omAlloc((1+rVar(r))*sizeof(int));
    194   int *m0=(int*)omAlloc((1+rVar(r))*sizeof(int));
    195   for (int i=0; i<k; i++)
    196   {
    197     poly p = I->m[i];
    198     if (p != NULL)
    199     {
    200       // check whether p is a term, return 1 if true
    201       if (p->next == NULL)
    202       {
    203         p_Delete(&I->m[0],r);
    204         I->m[0] = p_One(r);
    205         for (int j=1; j<k; j++)
    206         {
    207           p_Delete(&I->m[j],r);
    208           I->m[j] = NULL;
    209         }
    210         idSkipZeroes(I);
    211         omFree(mm);
    212         omFree(m0);
    213         return;
    214       }
    215 
    216       // check whether p is divisible by a monomial
    217       // divide if true
    218       p_GetExpV(p,mm,r);
    219       bool satNecessary=false;
    220       for (; p!=NULL; pIter(p))
    221       {
    222         satNecessary=false;
    223         p_GetExpV(p,m0,r);
    224         for(int i=1;i<=rVar(r);i++)
    225         {
    226           mm[i]=si_min(mm[i],m0[i]);
    227           if (mm[i]>0)
    228             satNecessary=true;
    229         }
    230         if (satNecessary==false)
    231           break;
    232       }
    233       if (satNecessary==true)
    234       {
    235         for (p=I->m[i]; p!=NULL; pIter(p))
    236         {
    237           for (int i=1; i<=rVar(r); i++)
    238             p_SubExp(p,i,mm[i],r);
    239           p_Setm(p,r);
    240         }
    241       }
    242     }
    243   }
    244   omFree(mm);
    245   omFree(m0);
     168  return i;
    246169}
    247170
     
    289212
    290213    ideal I = (ideal) u->Data();
    291     satSimplify(I,currRing);
    292214
    293215    idealCache = NULL;
Note: See TracChangeset for help on using the changeset viewer.