Changeset 58399e in git


Ignore:
Timestamp:
Mar 15, 2016, 4:14:24 PM (8 years ago)
Author:
Yue <ren@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', '4bd32dfef92ec9f5ed8dceee82d14318ae147107')
Children:
a0e02588881623134f70bb2c9041a27f6cbab5c4
Parents:
ad425214a13a6d1b4a9295cb343e8b528e070b00
Message:
chg: slimmed down customstd
File:
1 edited

Legend:

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

    rad42521 r58399e  
    8181    if (nonTrivialSaturationToBeDone==true)
    8282    {
    83       std::cout << "simplifying!" << std::endl;
     83      // std::cout << "simplifying!" << std::endl;
    8484      p=p_Copy(strat->P.p,currRing);
    8585      strat->P.p=p;
    8686      while(p!=NULL)
    8787      {
    88         for (int i=1; i<=rVar(currRing); i++)
    89           p_SubExp(p,i,mm[i],currRing);
     88        for (int i=1; i<satstdSaturatingVariables.size(); i++)
     89        {
     90          int li = satstdSaturatingVariables[i];
     91          p_SubExp(p,li,mm[li],currRing);
     92        }
    9093        p_Setm(p,currRing);
    9194        pIter(p);
     
    131134    if (nonTrivialSaturationToBeDone==true)
    132135    {
    133       std::cout << "simplifying!" << std::endl;
    134136      p=p_Copy(strat->P.t_p,strat->tailRing);
    135137      strat->P.t_p=p;
     
    151153}
    152154
    153 int extractVariableIndex(poly x, ring r)
     155// returns 1<=i<=rVar(r) if x is the i-th variable,
     156// return 0 otherwise
     157static int getVariableIndex(const poly x, const ring r)
    154158{
    155   if ((x->next == NULL) && (n_IsOne(p_GetCoeff(x,r),r->cf)))
     159  // return 0 if x is not a monomial
     160  if ((x->next!=NULL) || (!n_IsOne(p_GetCoeff(x,r),r->cf)))
     161    return 0;
     162
     163  // find the first variable index with non-zero exponent
     164  int i=1;
     165  int l=0;
     166  for (; i<=rVar(r); i++)
    156167  {
    157     int l0=0;
    158     for (int i=1; i<=rVar(r); i++)
    159     {
    160       int l1 = p_GetExp(x,i,r);
    161       if (l1>0)
    162       {
    163         if (l0>0)
    164           return 0;
    165         l0 = l1;
    166       }
    167     }
     168    l = p_GetExp(x,i,r);
     169    if (l>0) break;
    168170  }
    169   return (0);
     171  // return 0 if no such l exist or l is bigger than one
     172  if (l!=1)
     173    return 0;
     174
     175  // check that remaining variables have zero exponent
     176  for (i++; i<=rVar(r); i++)
     177  {
     178    if (p_GetExp(x,i,r)>0)
     179      return 0;
     180  }
     181
     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
     189static 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);
    170246}
    171247
     
    179255    if (v==NULL)
    180256    {
    181       ideal I = (ideal) u->Data();
    182257      int n = rVar(currRing);
    183258      satstdSaturatingVariables = std::vector<int>(n);
    184259      for (int i=0; i<n; i++)
    185260        satstdSaturatingVariables[i] = i+1;
    186 
     261    }
     262    else
     263    {
     264      if (v->Typ()==IDEAL_CMD)
     265      {
     266        ideal J = (ideal) v->Data();
     267
     268        int k = idSize(J);
     269        satstdSaturatingVariables = std::vector<int>(k);
     270        for (int i=0; i<k; i++)
     271        {
     272          poly x = J->m[i];
     273          int li = getVariableIndex(x,currRing);
     274          if (li>0)
     275            satstdSaturatingVariables[i]=li;
     276          else
     277          {
     278            WerrorS("satstd: second argument only ideals generated by variables supported for now");
     279            return FALSE;
     280          }
     281        }
     282      }
     283      else
     284      {
     285        WerrorS("satstd: unexpected parameters");
     286        return TRUE;
     287      }
     288    }
     289
     290    ideal I = (ideal) u->Data();
     291    satSimplify(I,currRing);
     292
     293    idealCache = NULL;
     294    I=kStd(I,currRing->qideal,testHomog,NULL,NULL,0,0,NULL,sat_vars_sp);
     295    satstdSaturatingVariables = std::vector<int>();
     296
     297    res->rtyp=IDEAL_CMD;
     298    if (idealCache)
     299    {
     300      id_Delete(&I,currRing);
     301      res->data = (char*) idealCache;
    187302      idealCache = NULL;
    188       I=kStd(I,currRing->qideal,testHomog,NULL,NULL,0,0,NULL,sat_vars_sp);
    189       satstdSaturatingVariables = std::vector<int>();
    190 
    191       res->rtyp=IDEAL_CMD;
    192       if (idealCache)
    193       {
    194         id_Delete(&I,currRing);
    195         res->data = (char*) idealCache;
    196         idealCache = NULL;
    197       }
    198       else
    199       {
    200         idSkipZeroes(I);
    201         res->data=(char*)I;
    202       }
    203       return FALSE;
    204     }
    205 
    206     if ((v!=NULL) && (v->Typ()==IDEAL_CMD))
    207     {
    208       ideal I = (ideal) u->Data();
    209       ideal J = (ideal) v->Data();
    210 
    211       int k = idSize(J);
    212       satstdSaturatingVariables = std::vector<int>(k);
    213       for (int i=0; i<k; i++)
    214       {
    215         poly x = I->m[i];
    216         int li = extractVariableIndex(x,currRing);
    217         if (li>0)
    218           satstdSaturatingVariables[i]=li;
    219         else
    220         {
    221           WerrorS("satstd: only ideals generated by variables supported for now");
    222           return FALSE;
    223         }
    224       }
    225 
    226       idealCache = NULL;
    227       I=kStd(I,currRing->qideal,testHomog,NULL,NULL,0,0,NULL,sat_vars_sp);
    228       res->rtyp=IDEAL_CMD;
    229       if (idealCache)
    230       {
    231         id_Delete(&I,currRing);
    232         res->data=(char*)idealCache;
    233       }
    234       else
    235       {
    236         idSkipZeroes(I);
    237         res->data=(char*)I;
    238       }
    239       return FALSE;
    240     }
     303    }
     304    else
     305    {
     306      idSkipZeroes(I);
     307      res->data=(char*)I;
     308    }
     309    return FALSE;
    241310  }
    242311  WerrorS("satstd: unexpected parameters");
     
    244313}
    245314
    246 static BOOLEAN abortIfMonomial_sp(kStrategy strat)
    247 {
    248   BOOLEAN b = FALSE; // set b to TRUE, if spoly was changed,
    249                      // let it remain FALSE otherwise
    250   if (strat->P.t_p==NULL)
    251   {
    252     poly p=strat->P.p;
    253     if (pNext(p)==NULL)
    254     {
    255       // if a term is contained in the ideal, abort std computation
    256       // and store the output in idealCache to be returned
    257       while ((strat->Ll >= 0))
    258         deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
    259       std::cout << "aborting!" << std::endl;
    260       return FALSE;
    261     }
    262   }
    263   else
    264   {
    265     poly p=strat->P.t_p;
    266     if (pNext(p)==NULL)
    267     {
    268       // if a term is contained in the ideal, abort std computation
    269       // and store the output in idealCache to be returned
    270       while ((strat->Ll >= 0))
    271         deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
    272       std::cout << "aborting!" << std::endl;
    273       return FALSE;
    274     }
    275   }
    276   return b; // return TRUE if sp was changed, FALSE if not
    277 }
    278 static BOOLEAN abortifmonomialstd(leftv res, leftv args)
    279 {
    280   if (args!=NULL)
    281   {
    282     if ((args->Typ()==IDEAL_CMD) && (args->next==NULL))
    283     {
    284       ideal I=(ideal)args->Data();
    285       idealCache = NULL;
    286       I=kStd(I,currRing->qideal,testHomog,NULL,NULL,0,0,NULL,abortIfMonomial_sp);
    287       res->rtyp=IDEAL_CMD;
    288       if (idealCache)
    289         res->data=(char*)idealCache;
    290       else
    291       {
    292         idSkipZeroes(I);
    293         res->data=(char*)I;
    294       }
    295       return FALSE;
    296     }
    297   }
    298   WerrorS("abortifmonomialstd: unexpected parameters");
    299   return TRUE;
    300 }
    301 
    302 
    303 //------------------------------------------------------------------------
    304 // routine that simplifies the ideal dividing each generator by the maximal monomial dividing it
    305 // in particular returns 1 if a generator is a term
    306 // to be used before starting saturation with respect to all variables
    307 static BOOLEAN simplifySat(leftv res, leftv args)
    308 {
    309   if (args!=NULL)
    310   {
    311     if ((args->Typ()==IDEAL_CMD) && (args->next==NULL))
    312     {
    313       ideal I=(ideal)args->CopyD();
    314       idSkipZeroes(I);
    315       int k = IDELEMS(I);
    316       int *mm=(int*)omAlloc((1+rVar(currRing))*sizeof(int));
    317       int *m0=(int*)omAlloc((1+rVar(currRing))*sizeof(int));
    318       for (int i=0; i<k; i++)
    319       {
    320         poly p = I->m[i];
    321         // check whether p is a term, return 1 if true
    322         if (p != NULL)
    323         {
    324           if (p->next == NULL)
    325           {
    326             id_Delete(&I,currRing);
    327             ideal oneIdeal = idInit(1);
    328             oneIdeal->m[0] = p_One(currRing);
    329             res->rtyp=IDEAL_CMD;
    330             res->data=(char*) oneIdeal;
    331             omFree(mm);
    332             omFree(m0);
    333             return FALSE;
    334           }
    335 
    336           // check whether p is divisible by a monomial
    337           // divide if true
    338           p_GetExpV(p,mm,currRing);
    339           bool satNecessary=false;
    340           for (; p!=NULL; pIter(p))
    341           {
    342             satNecessary=false;
    343             p_GetExpV(p,m0,currRing);
    344             for(int i=1;i<=rVar(currRing);i++)
    345             {
    346               mm[i]=si_min(mm[i],m0[i]);
    347               if (mm[i]>0)
    348                 satNecessary=true;
    349             }
    350             if (satNecessary==false)
    351               break;
    352           }
    353           if (satNecessary==true)
    354           {
    355             for (p=I->m[i]; p!=NULL; pIter(p))
    356             {
    357               for (int i=1; i<=rVar(currRing); i++)
    358                 p_SubExp(p,i,mm[i],currRing);
    359               p_Setm(p,currRing);
    360             }
    361           }
    362         }
    363       }
    364       omFree(mm);
    365       omFree(m0);
    366       res->rtyp=IDEAL_CMD;
    367       res->data=(char*)I;
    368       return FALSE;
    369     }
    370   }
    371   WerrorS("simplifySat: unexpected parameters");
    372   return TRUE;
    373 }
    374 
    375 
    376 static long wDeg(const poly p, const ring r)
    377 {
    378   if (r->order[0] == ringorder_lp)
    379     return p_GetExp(p,1,currRing);
    380   if (r->order[0] == ringorder_ls)
    381     return -p_GetExp(p,1,currRing);
    382 
    383   if (r->order[0] == ringorder_dp)
    384   {
    385     long d = 0;
    386     for (int i=1; i<=rVar(r); i++)
    387       d = d + p_GetExp(p,i,r);
    388     return d;
    389   }
    390   if (r->order[0] == ringorder_wp || r->order[0] == ringorder_a)
    391   {
    392     long d = 0;
    393     for (int i=r->block0[0]; i<=r->block1[0]; i++)
    394       d = d + p_GetExp(p,i,r)*r->wvhdl[0][i-1];
    395     return d;
    396   }
    397   if (r->order[0] == ringorder_ws)
    398   {
    399     long d = 0;
    400     for (int i=r->block0[0]; i<=r->block1[0]; i++)
    401       d = d - p_GetExp(p,i,r)*r->wvhdl[0][i-1];
    402     return d;
    403   }
    404 }
    405 
    406 static bool isInitialFormMonomial(const poly g, const ring r)
    407 {
    408   if (g->next==NULL)
    409     return true;
    410   return wDeg(g,r)!=wDeg(g->next,r);
    411 }
    412 
    413 //------------------------------------------------------------------------
    414 // routine that checks whether the initial form is a monomial,
    415 // breaks computation if it finds one, writing the element into idealCache
    416 static BOOLEAN sat_sp_initial(kStrategy strat)
    417 {
    418   BOOLEAN b = FALSE; // set b to TRUE, if spoly was changed,
    419                      // let it remain FALSE otherwise
    420   if (strat->P.t_p==NULL)
    421   {
    422     poly p=strat->P.p;
    423     if (pNext(p)==NULL)
    424     {
    425       // if a term is contained in the ideal, abort std computation
    426       // and store the output in idealCache to be returned
    427       while ((strat->Ll >= 0))
    428         deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
    429       idealCache = idInit(1);
    430       idealCache->m[0] = p_One(currRing);
    431       return FALSE;
    432     }
    433     if (isInitialFormMonomial(p,currRing))
    434     {
    435       while ((strat->Ll >= 0))
    436         deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
    437       idealCache = idInit(1);
    438       idealCache->m[0] = p_Copy(p,currRing);
    439     }
    440     int *mm=(int*)omAlloc((1+rVar(currRing))*sizeof(int));
    441     int *m0=(int*)omAlloc((1+rVar(currRing))*sizeof(int));
    442     p_GetExpV(p,mm,currRing);
    443     int m_null=0;
    444     while(p!=NULL)
    445     {
    446       m_null=0;
    447       p_GetExpV(p,m0,currRing);
    448       for(int i=1;i<=rVar(currRing);i++)
    449       {
    450         mm[i]=si_min(mm[i],m0[i]);
    451         if (mm[i]>0) m_null++;
    452       }
    453       if (m_null==0) break;
    454       pIter(p);
    455     }
    456     if (m_null>0)
    457     {
    458       std::cout << "simplifying!" << std::endl;
    459       p=p_Copy(strat->P.p,currRing);
    460       strat->P.p=p;
    461       while(p!=NULL)
    462       {
    463         for(int i=1;i<=rVar(currRing);i++)
    464           p_SubExp(p,i,mm[i],currRing);
    465         p_Setm(p,currRing);
    466         pIter(p);
    467       }
    468       b = TRUE;
    469     }
    470     omFree(mm);
    471     omFree(m0);
    472   }
    473   else
    474   {
    475     poly p=strat->P.t_p;
    476     if (pNext(p)==NULL)
    477     {
    478       // if a term is contained in the ideal, abort std computation
    479       // and store the output in idealCache to be returned
    480       while ((strat->Ll >= 0))
    481         deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
    482       idealCache = idInit(1);
    483       idealCache->m[0] = p_One(currRing);
    484       return FALSE;
    485     }
    486     if (isInitialFormMonomial(p,strat->tailRing))
    487     {
    488       while ((strat->Ll >= 0))
    489         deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
    490       nMapFunc identity = n_SetMap(strat->tailRing,currRing);
    491       idealCache = idInit(1);
    492       idealCache->m[0] = p_PermPoly(p,NULL,strat->tailRing,currRing,identity,NULL,0);
    493     }
    494     int *mm=(int*)omAlloc((1+rVar(currRing))*sizeof(int));
    495     int *m0=(int*)omAlloc((1+rVar(currRing))*sizeof(int));
    496     p_GetExpV(p,mm,strat->tailRing);
    497     int m_null=0;
    498     while(p!=NULL)
    499     {
    500       m_null=0;
    501       p_GetExpV(p,m0,strat->tailRing);
    502       for(int i=1;i<=rVar(currRing);i++)
    503       {
    504         mm[i]=si_min(mm[i],m0[i]);
    505         if (mm[i]>0) m_null++;
    506       }
    507       if (m_null==0) break;
    508       pIter(p);
    509     }
    510     if (m_null>0)
    511     {
    512       std::cout << "simplifying!" << std::endl;
    513       p=p_Copy(strat->P.t_p,strat->tailRing);
    514       strat->P.t_p=p;
    515       strat->P.p=NULL;
    516       while(p!=NULL)
    517       {
    518         for(int i=1;i<=rVar(currRing);i++)
    519           p_SubExp(p,i,mm[i],strat->tailRing);
    520         p_Setm(p,strat->tailRing);
    521         pIter(p);
    522       }
    523       strat->P.GetP();
    524       b = TRUE;
    525     }
    526     omFree(mm);
    527     omFree(m0);
    528   }
    529   return b; // return TRUE if sp was changed, FALSE if not
    530 }
    531 static BOOLEAN satstdWithInitialCheck(leftv res, leftv args)
    532 {
    533   if (args!=NULL)
    534   {
    535     if ((args->Typ()==IDEAL_CMD) && (args->next==NULL))
    536     {
    537       ideal I=(ideal)args->Data();
    538       idealCache = NULL;
    539       I=kStd(I,currRing->qideal,testHomog,NULL,NULL,0,0,NULL,sat_sp_initial);
    540       res->rtyp=IDEAL_CMD;
    541       if (idealCache)
    542         res->data=(char*)idealCache;
    543       else
    544         res->data=(char*)I;
    545       return FALSE;
    546     }
    547   }
    548   WerrorS("satstdWithInitialCheck: unexpected parameters");
    549   return TRUE;
    550 }
     315// static BOOLEAN abortIfMonomial_sp(kStrategy strat)
     316// {
     317//   BOOLEAN b = FALSE; // set b to TRUE, if spoly was changed,
     318//                      // let it remain FALSE otherwise
     319//   if (strat->P.t_p==NULL)
     320//   {
     321//     poly p=strat->P.p;
     322//     if (pNext(p)==NULL)
     323//     {
     324//       // if a term is contained in the ideal, abort std computation
     325//       // and store the output in idealCache to be returned
     326//       while ((strat->Ll >= 0))
     327//         deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
     328//       std::cout << "aborting!" << std::endl;
     329//       return FALSE;
     330//     }
     331//   }
     332//   else
     333//   {
     334//     poly p=strat->P.t_p;
     335//     if (pNext(p)==NULL)
     336//     {
     337//       // if a term is contained in the ideal, abort std computation
     338//       // and store the output in idealCache to be returned
     339//       while ((strat->Ll >= 0))
     340//         deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
     341//       std::cout << "aborting!" << std::endl;
     342//       return FALSE;
     343//     }
     344//   }
     345//   return b; // return TRUE if sp was changed, FALSE if not
     346// }
     347// static BOOLEAN abortifmonomialstd(leftv res, leftv args)
     348// {
     349//   if (args!=NULL)
     350//   {
     351//     if ((args->Typ()==IDEAL_CMD) && (args->next==NULL))
     352//     {
     353//       ideal I=(ideal)args->Data();
     354//       idealCache = NULL;
     355//       I=kStd(I,currRing->qideal,testHomog,NULL,NULL,0,0,NULL,abortIfMonomial_sp);
     356//       res->rtyp=IDEAL_CMD;
     357//       if (idealCache)
     358//         res->data=(char*)idealCache;
     359//       else
     360//       {
     361//         idSkipZeroes(I);
     362//         res->data=(char*)I;
     363//       }
     364//       return FALSE;
     365//     }
     366//   }
     367//   WerrorS("abortifmonomialstd: unexpected parameters");
     368//   return TRUE;
     369// }
     370
     371
     372// static long wDeg(const poly p, const ring r)
     373// {
     374//   if (r->order[0] == ringorder_lp)
     375//     return p_GetExp(p,1,currRing);
     376//   if (r->order[0] == ringorder_ls)
     377//     return -p_GetExp(p,1,currRing);
     378
     379//   if (r->order[0] == ringorder_dp)
     380//   {
     381//     long d = 0;
     382//     for (int i=1; i<=rVar(r); i++)
     383//       d = d + p_GetExp(p,i,r);
     384//     return d;
     385//   }
     386//   if (r->order[0] == ringorder_wp || r->order[0] == ringorder_a)
     387//   {
     388//     long d = 0;
     389//     for (int i=r->block0[0]; i<=r->block1[0]; i++)
     390//       d = d + p_GetExp(p,i,r)*r->wvhdl[0][i-1];
     391//     return d;
     392//   }
     393//   if (r->order[0] == ringorder_ws)
     394//   {
     395//     long d = 0;
     396//     for (int i=r->block0[0]; i<=r->block1[0]; i++)
     397//       d = d - p_GetExp(p,i,r)*r->wvhdl[0][i-1];
     398//     return d;
     399//   }
     400// }
     401
     402// static bool isInitialFormMonomial(const poly g, const ring r)
     403// {
     404//   if (g->next==NULL)
     405//     return true;
     406//   return wDeg(g,r)!=wDeg(g->next,r);
     407// }
     408
     409// //------------------------------------------------------------------------
     410// // routine that checks whether the initial form is a monomial,
     411// // breaks computation if it finds one, writing the element into idealCache
     412// static BOOLEAN sat_sp_initial(kStrategy strat)
     413// {
     414//   BOOLEAN b = FALSE; // set b to TRUE, if spoly was changed,
     415//                      // let it remain FALSE otherwise
     416//   if (strat->P.t_p==NULL)
     417//   {
     418//     poly p=strat->P.p;
     419//     if (pNext(p)==NULL)
     420//     {
     421//       // if a term is contained in the ideal, abort std computation
     422//       // and store the output in idealCache to be returned
     423//       while ((strat->Ll >= 0))
     424//         deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
     425//       idealCache = idInit(1);
     426//       idealCache->m[0] = p_One(currRing);
     427//       return FALSE;
     428//     }
     429//     if (isInitialFormMonomial(p,currRing))
     430//     {
     431//       while ((strat->Ll >= 0))
     432//         deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
     433//       idealCache = idInit(1);
     434//       idealCache->m[0] = p_Copy(p,currRing);
     435//     }
     436//     int *mm=(int*)omAlloc((1+rVar(currRing))*sizeof(int));
     437//     int *m0=(int*)omAlloc((1+rVar(currRing))*sizeof(int));
     438//     p_GetExpV(p,mm,currRing);
     439//     int m_null=0;
     440//     while(p!=NULL)
     441//     {
     442//       m_null=0;
     443//       p_GetExpV(p,m0,currRing);
     444//       for(int i=1;i<=rVar(currRing);i++)
     445//       {
     446//         mm[i]=si_min(mm[i],m0[i]);
     447//         if (mm[i]>0) m_null++;
     448//       }
     449//       if (m_null==0) break;
     450//       pIter(p);
     451//     }
     452//     if (m_null>0)
     453//     {
     454//       std::cout << "simplifying!" << std::endl;
     455//       p=p_Copy(strat->P.p,currRing);
     456//       strat->P.p=p;
     457//       while(p!=NULL)
     458//       {
     459//         for(int i=1;i<=rVar(currRing);i++)
     460//           p_SubExp(p,i,mm[i],currRing);
     461//         p_Setm(p,currRing);
     462//         pIter(p);
     463//       }
     464//       b = TRUE;
     465//     }
     466//     omFree(mm);
     467//     omFree(m0);
     468//   }
     469//   else
     470//   {
     471//     poly p=strat->P.t_p;
     472//     if (pNext(p)==NULL)
     473//     {
     474//       // if a term is contained in the ideal, abort std computation
     475//       // and store the output in idealCache to be returned
     476//       while ((strat->Ll >= 0))
     477//         deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
     478//       idealCache = idInit(1);
     479//       idealCache->m[0] = p_One(currRing);
     480//       return FALSE;
     481//     }
     482//     if (isInitialFormMonomial(p,strat->tailRing))
     483//     {
     484//       while ((strat->Ll >= 0))
     485//         deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
     486//       nMapFunc identity = n_SetMap(strat->tailRing,currRing);
     487//       idealCache = idInit(1);
     488//       idealCache->m[0] = p_PermPoly(p,NULL,strat->tailRing,currRing,identity,NULL,0);
     489//     }
     490//     int *mm=(int*)omAlloc((1+rVar(currRing))*sizeof(int));
     491//     int *m0=(int*)omAlloc((1+rVar(currRing))*sizeof(int));
     492//     p_GetExpV(p,mm,strat->tailRing);
     493//     int m_null=0;
     494//     while(p!=NULL)
     495//     {
     496//       m_null=0;
     497//       p_GetExpV(p,m0,strat->tailRing);
     498//       for(int i=1;i<=rVar(currRing);i++)
     499//       {
     500//         mm[i]=si_min(mm[i],m0[i]);
     501//         if (mm[i]>0) m_null++;
     502//       }
     503//       if (m_null==0) break;
     504//       pIter(p);
     505//     }
     506//     if (m_null>0)
     507//     {
     508//       std::cout << "simplifying!" << std::endl;
     509//       p=p_Copy(strat->P.t_p,strat->tailRing);
     510//       strat->P.t_p=p;
     511//       strat->P.p=NULL;
     512//       while(p!=NULL)
     513//       {
     514//         for(int i=1;i<=rVar(currRing);i++)
     515//           p_SubExp(p,i,mm[i],strat->tailRing);
     516//         p_Setm(p,strat->tailRing);
     517//         pIter(p);
     518//       }
     519//       strat->P.GetP();
     520//       b = TRUE;
     521//     }
     522//     omFree(mm);
     523//     omFree(m0);
     524//   }
     525//   return b; // return TRUE if sp was changed, FALSE if not
     526// }
     527// static BOOLEAN satstdWithInitialCheck(leftv res, leftv args)
     528// {
     529//   if (args!=NULL)
     530//   {
     531//     if ((args->Typ()==IDEAL_CMD) && (args->next==NULL))
     532//     {
     533//       ideal I=(ideal)args->Data();
     534//       idealCache = NULL;
     535//       I=kStd(I,currRing->qideal,testHomog,NULL,NULL,0,0,NULL,sat_sp_initial);
     536//       res->rtyp=IDEAL_CMD;
     537//       if (idealCache)
     538//         res->data=(char*)idealCache;
     539//       else
     540//         res->data=(char*)I;
     541//       return FALSE;
     542//     }
     543//   }
     544//   WerrorS("satstdWithInitialCheck: unexpected parameters");
     545//   return TRUE;
     546// }
    551547
    552548
     
    557553{
    558554  // p->iiAddCproc("std_demo","std_with_display",FALSE,std_with_display);
    559   p->iiAddCproc("std_demo","satstd",FALSE,satstd);
    560   p->iiAddCproc("std_demo","simplifySat",FALSE,simplifySat);
     555  p->iiAddCproc("customstd","satstd",FALSE,satstd);
    561556  // p->iiAddCproc("std_demo","satstdWithInitialCheck",FALSE,satstdWithInitialCheck);
    562557  // p->iiAddCproc("std_demo","abortifmonomialstd",FALSE,abortifmonomialstd);
    563   PrintS("init of std_demo - type `listvar(Std_demo);` to its contents\n");
     558  // PrintS("init of std_demo - type `listvar(Std_demo);` to its contents\n");
    564559  return (MAX_TOK);
    565560}
Note: See TracChangeset for help on using the changeset viewer.