Changeset daab57 in git


Ignore:
Timestamp:
Oct 12, 2017, 12:05:19 PM (6 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', '60097d763e0b541617a3b864b5310c523edaf81d')
Children:
99d5efaced04eeb5351af0f291ee1a53f0ad8114
Parents:
721195144d1556e36c2c84272425dd4d09faa226
Message:
chg: use id_Stastd in customstd.so
Files:
2 edited

Legend:

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

    r721195 rdaab57  
    44
    55// global variable potentially storing output
    6 ideal idealCache=NULL;
    7 
    8 std::vector<int> customstd_satstdSaturatingVariables;
     6//ideal idealCache=NULL;
    97
    108// //------------------------------------------------------------------------
     
    3937// }
    4038
    41 //------------------------------------------------------------------------
    42 // routine that simplifies the new element by dividing it with the maximal possible
    43 // partially saturating the ideal with respect to all variables doing so
    44 static BOOLEAN sat_vars_sp(kStrategy strat)
    45 {
    46   BOOLEAN b = FALSE; // set b to TRUE, if spoly was changed,
    47                      // let it remain FALSE otherwise
    48   if (strat->P.t_p==NULL)
    49   {
    50     poly p=strat->P.p;
    51 
    52     // iterate over all terms of p and
    53     // compute the minimum mm of all exponent vectors
    54     int *mm=(int*)omAlloc((1+rVar(currRing))*sizeof(int));
    55     int *m0=(int*)omAlloc((1+rVar(currRing))*sizeof(int));
    56     p_GetExpV(p,mm,currRing);
    57     bool nonTrivialSaturationToBeDone=true;
    58     for (p=pNext(p); p!=NULL; pIter(p))
    59     {
    60       nonTrivialSaturationToBeDone=false;
    61       p_GetExpV(p,m0,currRing);
    62       for (int i=customstd_satstdSaturatingVariables.size()-1; i>=0; i--)
    63       {
    64         int li = customstd_satstdSaturatingVariables[i];
    65         mm[li]=si_min(mm[li],m0[li]);
    66         if (mm[li]>0) nonTrivialSaturationToBeDone=true;
    67       }
    68       // abort if the minimum is zero in each component
    69       if (nonTrivialSaturationToBeDone==false) break;
    70     }
    71     if (nonTrivialSaturationToBeDone)
    72     {
    73       // std::cout << "simplifying!" << std::endl;
    74       if (TEST_OPT_PROT) { PrintS("S"); mflush(); }
    75       p=p_Copy(strat->P.p,currRing);
    76       memset(&strat->P,0,sizeof(strat->P));
    77       strat->P.tailRing = strat->tailRing;
    78       strat->P.p=p;
    79       while(p!=NULL)
    80       {
    81         for (int i=customstd_satstdSaturatingVariables.size()-1; i>=0; i--)
    82         {
    83           int li = customstd_satstdSaturatingVariables[i];
    84           p_SubExp(p,li,mm[li],currRing);
    85         }
    86         p_Setm(p,currRing);
    87         pIter(p);
    88       }
    89       b = TRUE;
    90     }
    91     omFree(mm);
    92     omFree(m0);
    93   }
    94   else
    95   {
    96     poly p=strat->P.t_p;
    97 
    98     // iterate over all terms of p and
    99     // compute the minimum mm of all exponent vectors
    100     int *mm=(int*)omAlloc((1+rVar(currRing))*sizeof(int));
    101     int *m0=(int*)omAlloc((1+rVar(currRing))*sizeof(int));
    102     p_GetExpV(p,mm,strat->tailRing);
    103     bool nonTrivialSaturationToBeDone=true;
    104     for (p = pNext(p); p!=NULL; pIter(p))
    105     {
    106       nonTrivialSaturationToBeDone=false;
    107       p_GetExpV(p,m0,strat->tailRing);
    108       for(int i=customstd_satstdSaturatingVariables.size()-1; i>=0; i--)
    109       {
    110         int li = customstd_satstdSaturatingVariables[i];
    111         mm[li]=si_min(mm[li],m0[li]);
    112         if (mm[li]>0) nonTrivialSaturationToBeDone = true;
    113       }
    114       // abort if the minimum is zero in each component
    115       if (!nonTrivialSaturationToBeDone) break;
    116     }
    117     if (nonTrivialSaturationToBeDone)
    118     {
    119       if (TEST_OPT_PROT) { PrintS("S"); mflush(); }
    120       p=p_Copy(strat->P.t_p,strat->tailRing);
    121       memset(&strat->P,0,sizeof(strat->P));
    122       strat->P.tailRing = strat->tailRing;
    123       strat->P.t_p=p;
    124       while(p!=NULL)
    125       {
    126         for(int i=customstd_satstdSaturatingVariables.size()-1; i>=0; i--)
    127         {
    128           int li = customstd_satstdSaturatingVariables[i];
    129           p_SubExp(p,li,mm[li],strat->tailRing);
    130         }
    131         p_Setm(p,strat->tailRing);
    132         pIter(p);
    133       }
    134       strat->P.GetP();
    135       b = TRUE;
    136     }
    137     omFree(mm);
    138     omFree(m0);
    139   }
    140   return b; // return TRUE if sp was changed, FALSE if not
    141 }
    142 
    14339static BOOLEAN satstd(leftv res, leftv args)
    14440{
     
    14743  && ((u->Typ()==IDEAL_CMD)||(u->Typ()==MODUL_CMD)))
    14844  {
     45    ideal I=(ideal)u->Data();
    14946    leftv v = u->next;
    15047
     48    res->rtyp=IDEAL_CMD;
     49    ideal J;
    15150    if (v==NULL)
    15251    {
    153       int n = rVar(currRing);
    154       customstd_satstdSaturatingVariables = std::vector<int>(n);
    155       for (int i=n-1; i>=0; i--)
    156         customstd_satstdSaturatingVariables[i] = i+1;
     52      J=id_MaxIdeal(1,currRing);
    15753    }
    15854    else
     
    16056      if (v->Typ()==IDEAL_CMD)
    16157      {
    162         ideal J = (ideal) v->Data();
    163 
    164         int k = IDELEMS(J);
    165         customstd_satstdSaturatingVariables = std::vector<int>(k);
    166         for (int i=0; i<k; i++)
    167         {
    168           poly x = J->m[i];
    169           int li = p_Var(x,currRing);
    170           if (li>0)
    171             customstd_satstdSaturatingVariables[i]=li;
    172           else
    173           {
    174             WerrorS("satstd: second argument only ideals generated by variables supported for now");
    175             return TRUE;
    176           }
    177         }
     58        J = (ideal) v->Data();
    17859      }
    17960      else
    18061      {
     62        args->CleanUp();
    18163        WerrorS("satstd: unexpected parameters");
    18264        return TRUE;
    18365      }
    18466    }
    185 
    186     idealCache = NULL;
    187     ideal I=kStd(I,currRing->qideal,testHomog,NULL,NULL,0,0,NULL,sat_vars_sp);
    188     customstd_satstdSaturatingVariables = std::vector<int>();
    189 
    190     res->rtyp=IDEAL_CMD;
     67    I=id_Satstd(I,J,currRing);
     68
     69#if 0 /* unused */
    19170    if (idealCache)
    19271    {
     
    19675    }
    19776    else
     77#endif
    19878    {
    19979      idSkipZeroes(I);
    20080      res->data=(char*)I;
    20181    }
    202     return FALSE;
     82    if (v==NULL) id_Delete(&J,currRing);
     83    args->CleanUp();
     84    setFlag(res,FLAG_STD);
     85    return (res->data==NULL);
    20386  }
    20487  WerrorS("satstd: unexpected parameters");
  • kernel/ideals.cc

    r721195 rdaab57  
    28522852      {
    28532853        if (id_satstdSaturatingVariables[i]!=0)
    2854         {
     2854        {
    28552855          mm[i]=si_min(mm[i],m0[i]);
    28562856          if (mm[i]>0) nonTrivialSaturationToBeDone=true;
    2857         }
     2857        }
     2858        else mm[i]=0;
    28582859      }
    28592860      // abort if the minimum is zero in each component
     
    28652866      if (TEST_OPT_PROT) { PrintS("S"); mflush(); }
    28662867      p=p_Copy(strat->P.p,currRing);
     2868      //pWrite(p);
     2869      //  for (int i=rVar(currRing); i>0; i--)
     2870      //    if (mm[i]!=0) Print("x_%d:%d ",i,mm[i]);
     2871      //PrintLn();
    28672872      memset(&strat->P,0,sizeof(strat->P));
    28682873      strat->P.tailRing = strat->tailRing;
     
    28722877        for (int i=rVar(currRing); i>0; i--)
    28732878        {
    2874           if(id_satstdSaturatingVariables[i]!=0)
    2875           {
    2876             p_SubExp(p,i,mm[i],currRing);
    2877           }
     2879          p_SubExp(p,i,mm[i],currRing);
    28782880        }
    28792881        p_Setm(p,currRing);
     
    29022904      {
    29032905        if(id_satstdSaturatingVariables[i]!=0)
    2904         {
     2906        {
    29052907          mm[i]=si_min(mm[i],m0[i]);
    29062908          if (mm[i]>0) nonTrivialSaturationToBeDone = true;
    2907         }
     2909        }
     2910        else mm[i]=0;
    29082911      }
    29092912      // abort if the minimum is zero in each component
     
    29142917      if (TEST_OPT_PROT) { PrintS("S"); mflush(); }
    29152918      p=p_Copy(strat->P.t_p,strat->tailRing);
     2919      //p_Write(p,strat->tailRing);
     2920      //  for (int i=rVar(currRing); i>0; i--)
     2921      //    if (mm[i]!=0) Print("x_%d:%d ",i,mm[i]);
     2922      //PrintLn();
    29162923      memset(&strat->P,0,sizeof(strat->P));
    29172924      strat->P.tailRing = strat->tailRing;
     
    29212928        for(int i=rVar(currRing); i>0; i--)
    29222929        {
    2923           if(id_satstdSaturatingVariables[i]!=0)
    2924           {
    2925             p_SubExp(p,i,mm[i],strat->tailRing);
    2926           }
     2930          p_SubExp(p,i,mm[i],strat->tailRing);
    29272931        }
    29282932        p_Setm(p,strat->tailRing);
Note: See TracChangeset for help on using the changeset viewer.