Changeset 5d4fa4 in git for kernel/GBEngine/kutil.cc


Ignore:
Timestamp:
Oct 21, 2015, 11:58:18 AM (8 years ago)
Author:
Adi Popescu <adi_popescum@…>
Branches:
(u'spielwiese', 'ec94ef7a30b928574c0c3daf41f6804dff5f6b69')
Children:
ef1a968e317a12b42f88e04cd7f9483e47fba2f7
Parents:
d5a14976ed24bbe1ef7d62031b04ec3dbfa74e0e
Message:
found problem: in posInL11Ring (and ls) i tested coeff not in abs value!!!
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/GBEngine/kutil.cc

    rd5a149 r5d4fa4  
    11811181void enterOnePairRing (int i,poly p,int ecart, int isFromQ,kStrategy strat, int atR = -1)
    11821182{
    1183   #if 0
    1184   assume(i<=strat->sl);
    1185     int      l,j,compare,compareCoeff;
    1186     LObject  Lp;
    1187     if (strat->interred_flag) return;
    1188   #ifdef KDEBUG
    1189     Lp.ecart=0; Lp.length=0;
    1190   #endif
    1191     /*- computes the lcm(s[i],p) -*/
    1192     Lp.lcm = pInit();
    1193     pSetCoeff0(Lp.lcm, n_Lcm(pGetCoeff(p), pGetCoeff(strat->S[i]), currRing->cf));
    1194  
    1195     // Lp.lcm == 0
    1196     if (nIsZero(pGetCoeff(Lp.lcm)))
    1197     {
    1198   #ifdef KDEBUG
    1199         if (TEST_OPT_DEBUG)
    1200         {
    1201           PrintS("--- Lp.lcm == 0\n");
    1202           PrintS("p:");
    1203           wrp(p);
    1204           Print("  strat->S[%d]:", i);
    1205           wrp(strat->S[i]);
    1206           PrintLn();
    1207         }
    1208   #endif
    1209         strat->cp++;
    1210         pLmDelete(Lp.lcm);
    1211         return;
    1212     }
    1213     // basic product criterion
    1214     pLcm(p,strat->S[i],Lp.lcm);
    1215  
    1216     pSetm(Lp.lcm);
    1217     assume(!strat->sugarCrit);
    1218     if (pHasNotCF(p,strat->S[i]) && n_IsUnit(pGetCoeff(p),currRing->cf)
    1219         && n_IsUnit(pGetCoeff(strat->S[i]),currRing->cf))
    1220     {
    1221   #ifdef KDEBUG
    1222         if (TEST_OPT_DEBUG)
    1223         {
    1224           PrintS("--- product criterion func enterOnePairRing type 1\n");
    1225           PrintS("p:");
    1226           wrp(p);
    1227           Print("  strat->S[%d]:", i);
    1228           wrp(strat->S[i]);
    1229           PrintLn();
    1230         }
    1231   #endif
    1232         strat->cp++;
    1233         pLmDelete(Lp.lcm);
    1234         return;
    1235     }
    1236     assume(!strat->fromT);
    1237     /*
    1238     *the set B collects the pairs of type (S[j],p)
    1239     *suppose (r,p) is in B and (s,p) is the new pair and lcm(s,p) != lcm(r,p)
    1240     *if the leading term of s devides lcm(r,p) then (r,p) will be canceled
    1241     *if the leading term of r devides lcm(s,p) then (s,p) will not enter B
    1242     */
    1243     for(j = strat->Bl;j>=0;j--)
    1244     {
    1245       compare=pDivCompRing(strat->B[j].lcm,Lp.lcm);
    1246       compareCoeff = n_DivComp(pGetCoeff(strat->B[j].lcm), pGetCoeff(Lp.lcm), currRing->cf);
    1247       if ((compareCoeff == pDivComp_EQUAL) || (compare == compareCoeff))
    1248       {
    1249         if (compare == 1)
    1250         {
    1251           strat->c3++;
    1252   #ifdef KDEBUG
    1253           if (TEST_OPT_DEBUG)
    1254           {
    1255             PrintS("--- chain criterion type 1\n");
    1256             PrintS("strat->B[j]:");
    1257             wrp(strat->B[j].lcm);
    1258             PrintS("  Lp.lcm:");
    1259             wrp(Lp.lcm);
    1260             PrintLn();
    1261           }
    1262   #endif
    1263           if ((strat->fromQ==NULL) || (isFromQ==0) || (strat->fromQ[i]==0))
    1264           {
    1265             pLmDelete(Lp.lcm);
    1266             return;
    1267           }
    1268           break;
    1269         }
    1270         else
    1271         if (compare == -1)
    1272         {
    1273   #ifdef KDEBUG
    1274           if (TEST_OPT_DEBUG)
    1275           {
    1276             PrintS("--- chain criterion type 2\n");
    1277             Print("strat->B[%d].lcm:",j);
    1278             wrp(strat->B[j].lcm);
    1279             PrintS("  Lp.lcm:");
    1280             wrp(Lp.lcm);
    1281             PrintLn();
    1282           }
    1283   #endif
    1284           deleteInL(strat->B,&strat->Bl,j,strat);
    1285           strat->c3++;
    1286         }
    1287       }
    1288       if ((compare == pDivComp_EQUAL) && (compareCoeff != 2))
    1289       {
    1290         if (compareCoeff == pDivComp_LESS)
    1291         {
    1292   #ifdef KDEBUG
    1293           if (TEST_OPT_DEBUG)
    1294           {
    1295             PrintS("--- chain criterion type 3\n");
    1296             Print("strat->B[%d].lcm:", j);
    1297             wrp(strat->B[j].lcm);
    1298             PrintS("  Lp.lcm:");
    1299             wrp(Lp.lcm);
    1300             PrintLn();
    1301           }
    1302   #endif
    1303           strat->c3++;
    1304           if ((strat->fromQ==NULL) || (isFromQ==0) || (strat->fromQ[i]==0))
    1305           {
    1306             pLmDelete(Lp.lcm);
    1307             return;
    1308           }
    1309           break;
    1310         }
    1311         else
    1312         // Add hint for same LM and LC (later) (TODO Oliver)
    1313         // if (compareCoeff == pDivComp_GREATER)
    1314         {
    1315   #ifdef KDEBUG
    1316           if (TEST_OPT_DEBUG)
    1317           {
    1318             PrintS("--- chain criterion type 4\n");
    1319             Print("strat->B[%d].lcm:", j);
    1320             wrp(strat->B[j].lcm);
    1321             PrintS("  Lp.lcm:");
    1322             wrp(Lp.lcm);
    1323             PrintLn();
    1324           }
    1325   #endif
    1326           deleteInL(strat->B,&strat->Bl,j,strat);
    1327           strat->c3++;
    1328         }
    1329       }
    1330     }
    1331     /*
    1332     *the pair (S[i],p) enters B if the spoly != 0
    1333     */
    1334     /*-  compute the short s-polynomial -*/
    1335     if ((strat->S[i]==NULL) || (p==NULL))
    1336     {
    1337   #ifdef KDEBUG
    1338       if (TEST_OPT_DEBUG)
    1339       {
    1340         PrintS("--- spoly = NULL\n");
    1341       }
    1342   #endif
    1343       pLmDelete(Lp.lcm);
    1344       return;
    1345     }
    1346     if ((strat->fromQ!=NULL) && (isFromQ!=0) && (strat->fromQ[i]!=0))
    1347     {
    1348       // Is from a previous computed GB, therefore we know that spoly will
    1349       // reduce to zero. Oliver.
    1350       WarnS("Could we come here? 8738947389");
    1351       Lp.p=NULL;
    1352     }
    1353     else
    1354     {
    1355       Lp.p = ksCreateShortSpoly(strat->S[i], p, strat->tailRing);
    1356     }
    1357     if (Lp.p == NULL)
    1358     {
    1359   #ifdef KDEBUG
    1360       if (TEST_OPT_DEBUG)
    1361       {
    1362         PrintS("--- spoly = NULL\n");
    1363       }
    1364   #endif
    1365       /*- the case that the s-poly is 0 -*/
    1366       if (strat->pairtest==NULL) initPairtest(strat);
    1367       strat->pairtest[i] = TRUE;/*- hint for spoly(S^[i],p)=0 -*/
    1368       strat->pairtest[strat->sl+1] = TRUE;
    1369       /*hint for spoly(S[i],p) == 0 for some i,0 <= i <= sl*/
    1370       /*
    1371       *suppose we have (s,r),(r,p),(s,p) and spoly(s,p) == 0 and (r,p) is
    1372       *still in B (i.e. lcm(r,p) == lcm(s,p) or the leading term of s does not
    1373       *devide lcm(r,p)). In the last case (s,r) can be canceled if the leading
    1374       *term of p devides the lcm(s,r)
    1375       *(this canceling should be done here because
    1376       *the case lcm(s,p) == lcm(s,r) is not covered in chainCrit)
    1377       *the first case is handeled in chainCrit
    1378       */
    1379       pLmDelete(Lp.lcm);
    1380     }
    1381     else
    1382     {
    1383       /*- the pair (S[i],p) enters B -*/
    1384       Lp.p1 = strat->S[i];
    1385       Lp.p2 = p;
    1386  
    1387       pNext(Lp.p) = strat->tail;
    1388  
    1389       if (atR >= 0)
    1390       {
    1391         Lp.i_r2 = atR;
    1392         Lp.i_r1 = strat->S_2_R[i];
    1393       }
    1394       strat->initEcartPair(&Lp,strat->S[i],p,strat->ecartS[i],ecart);
    1395       l = strat->posInL(strat->B,strat->Bl,&Lp,strat);
    1396       enterL(&strat->B,&strat->Bl,&strat->Bmax,Lp,l);
    1397     }
    1398   #else
    13991183  assume(atR >= 0);
    14001184  assume(i<=strat->sl);
     
    14151199      return;
    14161200  }
    1417   #if 1
    14181201  // basic chain criterion
    14191202  pLcm(p,strat->S[i],h.lcm);
     
    14261209  */
    14271210 
    1428   //#if ADIDEBUG
    1429   #if 0
    1430   idPrint(strat->Shdl);
    1431   for(int ii=0; ii<=strat->Ll; ii++)
    1432   {printf("\nL[%i]\n",ii);pWrite(strat->L[ii].p);pWrite(strat->L[ii].p1);pWrite(strat->L[ii].p2);pWrite(strat->L[ii].lcm);}
    1433   for(int ii=0; ii<=strat->Bl; ii++)
    1434   {printf("\nB[%i]\n",ii);pWrite(strat->B[ii].p);pWrite(strat->B[ii].p1);pWrite(strat->B[ii].p2);pWrite(strat->B[ii].lcm);}
    1435   #endif
    1436  
    14371211  for(j = strat->Bl;j>=0;j--)
    14381212  {
    14391213    compare=pDivCompRing(strat->B[j].lcm,h.lcm);
    14401214    compareCoeff = n_DivComp(pGetCoeff(strat->B[j].lcm), pGetCoeff(h.lcm), currRing->cf);
    1441     if ((compareCoeff == pDivComp_EQUAL) || (compare == compareCoeff))
    1442     {
    1443       if (compare == 1)
    1444       {
    1445 #if ADIDEBUG
    1446               printf("\nChainCrit1 in enteronepairring\n");
    1447               printf("\nB[j]\n");
    1448               pWrite(strat->B[j].p);
    1449               pWrite(strat->B[j].p1);
    1450               pWrite(strat->B[j].p2);
    1451               pWrite(strat->B[j].lcm);
    1452               printf("\nh - neue Paar\n");
    1453               pWrite(h.p);
    1454               pWrite(p);
    1455               pWrite(strat->S[i]);
    1456               pWrite(h.lcm);
    1457               #endif
    1458         if ((n_DivBy(h.lcm->coef, strat->B[j].lcm->coef,  currRing->cf)) && ((strat->fromQ==NULL) || (isFromQ==0) || (strat->fromQ[i]==0)))
    1459         {
    1460           #if ADIDEBUG
    1461           printf("\nGelöscht neue h\n");
    1462           #endif
    1463           strat->c3++;
    1464           pLmDelete(h.lcm);
    1465           return;
    1466         }
    1467         break;
    1468       }
    1469       else if (compare == -1)
    1470       {
    1471 #if ADIDEBUG
    1472               printf("\nChainCrit2 in enteronepairring\n");
    1473               printf("\nB[j]\n");
    1474               pWrite(strat->B[j].p);
    1475               pWrite(strat->B[j].p1);
    1476               pWrite(strat->B[j].p2);
    1477               pWrite(strat->B[j].lcm);
    1478               printf("\nh - neue Paar\n");
    1479               pWrite(h.p);
    1480               pWrite(p);
    1481               pWrite(strat->S[i]);
    1482               pWrite(h.lcm);
    1483               #endif
    1484           //Ist schon im coeffCompare
    1485           //if(n_DivBy( h.lcm->coef, strat->B[j].lcm->coef, currRing->cf))
    1486           //{
    1487           #if ADIDEBUG
    1488                         printf("\nGelöscht: B[j]\n");
    1489           #endif
    1490             deleteInL(strat->B,&strat->Bl,j,strat);
    1491             strat->c3++;
    1492           //}
    1493       }
    1494     }
    1495     if ((compare == pDivComp_EQUAL) && (compareCoeff != 2))
    1496     {
    1497       if (compareCoeff == pDivComp_LESS)
    1498       {
    1499 #if ADIDEBUG
    1500               printf("\nChainCrit3 in enteronepairring\n");
    1501               printf("\nB[j]\n");
    1502               pWrite(strat->B[j].p);
    1503               pWrite(strat->B[j].p1);
    1504               pWrite(strat->B[j].p2);
    1505               pWrite(strat->B[j].lcm);
    1506               printf("\nh - neue Paar\n");
    1507               pWrite(h.p);
    1508               pWrite(p);
    1509               pWrite(strat->S[i]);
    1510               #endif
    1511         if ((n_DivBy(strat->B[j].lcm->coef, h.lcm->coef, currRing->cf)) && (strat->fromQ==NULL) || (isFromQ==0) || (strat->fromQ[i]==0))
     1215    #if ADIDEBUG
     1216    printf("\nChainCrit in enteronepairring\n");
     1217    printf("\nB[j]\n");
     1218    pWrite(strat->B[j].p);
     1219    pWrite(strat->B[j].p1);
     1220    pWrite(strat->B[j].p2);
     1221    pWrite(strat->B[j].lcm);
     1222    printf("\nh - neue Paar\n");
     1223    pWrite(h.p);
     1224    pWrite(p);
     1225    pWrite(strat->S[i]);
     1226    pWrite(h.lcm);
     1227    printf("\ncompare = %i\ncompareCoeff = %i\n",compare,compareCoeff);
     1228    #endif
     1229    if(compare == pDivComp_EQUAL)
     1230    {
     1231      //They have the same LM
     1232      if(compareCoeff == pDivComp_LESS)
     1233      {
     1234        if ((strat->fromQ==NULL) || (isFromQ==0) || (strat->fromQ[i]==0))
    15121235        {
    15131236          #if ADIDEBUG
     
    15201243        break;
    15211244      }
    1522       else
    1523       // Add hint for same LM and LC (later) (TODO Oliver)
    1524       if (compareCoeff == pDivComp_GREATER)
    1525       {
    1526         #if ADIDEBUG
    1527               printf("\nChainCrit4 in enteronepairring\n");
    1528               printf("\nB[j]\n");
    1529               pWrite(strat->B[j].p);
    1530               pWrite(strat->B[j].p1);
    1531               pWrite(strat->B[j].p2);
    1532               pWrite(strat->B[j].lcm);
    1533               printf("\nh - neue Paar\n");
    1534               pWrite(h.p);
    1535               pWrite(p);
    1536               pWrite(strat->S[i]);
    1537               pWrite(h.lcm);
    1538               #endif
    1539         //if(n_DivBy( h.lcm->coef, strat->B[j].lcm->coef,currRing->cf))
    1540         {
     1245      if(compareCoeff == pDivComp_GREATER)
     1246      {
    15411247          #if ADIDEBUG
    1542           printf("\nGelöscht B[j]\n");
     1248          printf("\nGelöscht: B[j]\n");
    15431249          #endif
    15441250          deleteInL(strat->B,&strat->Bl,j,strat);
    15451251          strat->c3++;
    1546         }
    1547       }
    1548     }
    1549   }
    1550   #endif
     1252      }
     1253      if(compareCoeff == pDivComp_EQUAL)
     1254      {
     1255        if ((strat->fromQ==NULL) || (isFromQ==0) || (strat->fromQ[i]==0))
     1256        {
     1257          #if ADIDEBUG
     1258          printf("\nGelöscht h\n");
     1259          #endif
     1260          strat->c3++;
     1261          pLmDelete(h.lcm);
     1262          return;
     1263        }
     1264        break;
     1265      }
     1266    }
     1267    if(compareCoeff == compare || compareCoeff == pDivComp_EQUAL)
     1268    {
     1269      if(compare == pDivComp_LESS)
     1270      {
     1271        if ((strat->fromQ==NULL) || (isFromQ==0) || (strat->fromQ[i]==0))
     1272        {
     1273          #if ADIDEBUG
     1274          printf("\nGelöscht h\n");
     1275          #endif
     1276          strat->c3++;
     1277          pLmDelete(h.lcm);
     1278          return;
     1279        }
     1280        break;
     1281      }
     1282      if(compare == pDivComp_GREATER)
     1283      {
     1284          #if ADIDEBUG
     1285          printf("\nGelöscht: B[j]\n");
     1286          #endif
     1287          deleteInL(strat->B,&strat->Bl,j,strat);
     1288          strat->c3++;
     1289      }
     1290    }
     1291  }
    15511292  number s, t;
    15521293  poly m1, m2, gcd = NULL;
     
    16491390  enterL(&strat->B,&strat->Bl,&strat->Bmax,h,posx);
    16501391  kTest_TS(strat);
    1651   #endif
    16521392}
    16531393
     
    53955135              LObject* p,const kStrategy strat)
    53965136{
    5397   #if 0
    5398   if (length < 0) return 0;
    5399   if(pIsConstant(p->p)) return length+1;
    5400   int i,an,en;
    5401   #if 1
    5402   if(pIsConstant(set[length].p) && length > 0)
    5403   {   
    5404     if (set[length-1].FDeg > p->FDeg)
    5405       return length;
    5406   }
    5407   else
    5408   {
    5409     if (set[length].FDeg > p->FDeg)
    5410       return length+1;
    5411   }
    5412   if (set[0].FDeg < p->FDeg)
    5413   return 0;
    5414 
    5415   bool isFromF = (p->p1 == NULL) && (p->p2 == NULL);
    5416 
    5417   if(isFromF)
    5418   {
    5419     i = 0;
    5420     while(i<= length && set[i].FDeg > p->FDeg && !pIsConstant(set[i].p))
    5421       i++;
    5422     while(i<= length && ((set[i].p1 != NULL) || (set[i].p2 != NULL)) &&
    5423          (set[i].FDeg == p->FDeg) && !pIsConstant(set[i].p))
    5424       i++;
    5425     an = i;
    5426     if(pIsConstant(set[length].p))
    5427       i = length-1;
    5428     else
    5429       i = length;
    5430     while(i>=0 && set[i].FDeg < p->FDeg)
    5431       i--;
    5432     en = i+1;
    5433   }
    5434   else
    5435   {
    5436     i = 0;
    5437     while(i<= length && set[i].FDeg > p->FDeg && !pIsConstant(set[i].p))
    5438       i++;
    5439     an = i;
    5440     if(pIsConstant(set[length].p))
    5441       i = length-1;
    5442     else
    5443       i = length;
    5444     while(i>= 0 && set[i].FDeg < p->FDeg)
    5445       i--;
    5446     while(i>=0 && ((set[i].p1 == NULL) && (set[i].p2 == NULL)) &&
    5447          (set[i].FDeg == p->FDeg) && (i > an))
    5448       i--;
    5449     en = i+1;
    5450   }
    5451   #else
    5452   an = 0;
    5453   en = length;
    5454   while(en>=an && (set[en].p == NULL || pIsConstant(set[en].p)))
    5455     en--;
    5456   if(en == 0)
    5457     return 0;
    5458   en++;
    5459   #endif
    5460   loop
    5461   {
    5462     if(an > length)
    5463       return length+1;
    5464     if (an >= en-1)
    5465     {
    5466       if(an == en)
    5467         return en;
    5468       if (pLmCmp(set[an].p, p->p) == 1)
    5469         return en;
    5470       if (pLmCmp(set[an].p, p->p) == -1)
    5471         return an;
    5472       if (pLmCmp(set[i].p, p->p) == 0)
    5473       {
    5474         if(nGreater(set[an].p->coef, p->p->coef))
    5475           return en;
    5476         else
    5477           return an;
    5478       }
    5479     }
    5480     i=(an+en) / 2;
    5481     if (pLmCmp(set[i].p, p->p) == 1)
    5482       an=i;
    5483     if (pLmCmp(set[i].p, p->p) == -1)
    5484       en=i;
    5485     if (pLmCmp(set[i].p, p->p) == 0)
    5486     {
    5487       if(nGreater(set[i].p->coef, p->p->coef))
    5488         an = i;
    5489       else
    5490         en = i;
    5491     }
    5492   }
    5493   #else
    54945137  if (length < 0) return 0;
    54955138  int an,en,i;
     
    55145157      if (pLmCmp(set[an].p, p->p) == 0)
    55155158      {
    5516         if(nGreater(set[an].p->coef, p->p->coef))
     5159        number lcset,lcp;
     5160        lcset = nCopy(set[an].p->coef);
     5161        lcp = nCopy(p->p->coef);
     5162        if(!nGreaterZero(lcset))
     5163          lcset = nInpNeg(lcset);
     5164        if(!nGreaterZero(lcp))
     5165          lcp = nInpNeg(lcp);
     5166        if(nGreater(lcset, lcp))
     5167        {
     5168          nDelete(&lcset);
     5169          nDelete(&lcp);
    55175170          return en;
     5171        }
    55185172        else
     5173        {
     5174          nDelete(&lcset);
     5175          nDelete(&lcp);
    55195176          return an;
     5177        }
    55205178      }
    55215179    }
     
    55275185    if (pLmCmp(set[i].p, p->p) == 0)
    55285186    {
    5529       if(nGreater(set[i].p->coef, p->p->coef))
     5187      number lcset,lcp;
     5188      lcset = nCopy(set[i].p->coef);
     5189      lcp = nCopy(p->p->coef);
     5190      if(!nGreaterZero(lcset))
     5191        lcset = nInpNeg(lcset);
     5192      if(!nGreaterZero(lcp))
     5193        lcp = nInpNeg(lcp);
     5194      if(nGreater(lcset, lcp))
     5195      {
     5196        nDelete(&lcset);
     5197        nDelete(&lcp);
    55305198        an = i;
     5199      }
    55315200      else
     5201      {
     5202        nDelete(&lcset);
     5203        nDelete(&lcp);
    55325204        en = i;
    5533     }
    5534   }
    5535   #endif
     5205      }
     5206    }
     5207  }
    55365208}
    55375209
     
    55615233      if (set[an].FDeg == p->FDeg)
    55625234      {
    5563         if(nGreater(set[an].p->coef, p->p->coef))
     5235        number lcset,lcp;
     5236        lcset = nCopy(set[an].p->coef);
     5237        lcp = nCopy(p->p->coef);
     5238        if(!nGreaterZero(lcset))
     5239          lcset = nInpNeg(lcset);
     5240        if(!nGreaterZero(lcp))
     5241          lcp = nInpNeg(lcp);
     5242        if(nGreater(lcset, lcp))
     5243        {
     5244          nDelete(&lcset);
     5245          nDelete(&lcp);
    55645246          return en;
     5247        }
    55655248        else
     5249        {
     5250          nDelete(&lcset);
     5251          nDelete(&lcp);
    55665252          return an;
     5253        }
    55675254      }
    55685255    }
     
    55745261    if (set[i].FDeg == p->FDeg)
    55755262    {
    5576       if(nGreater(set[i].p->coef, p->p->coef))
     5263      number lcset,lcp;
     5264      lcset = nCopy(set[an].p->coef);
     5265      lcp = nCopy(p->p->coef);
     5266      if(!nGreaterZero(lcset))
     5267        lcset = nInpNeg(lcset);
     5268      if(!nGreaterZero(lcp))
     5269        lcp = nInpNeg(lcp);
     5270      if(nGreater(lcset, lcp))
     5271      {
     5272        nDelete(&lcset);
     5273        nDelete(&lcp);
    55775274        an = i;
     5275      }
    55785276      else
     5277      {
     5278        nDelete(&lcset);
     5279        nDelete(&lcp);
    55795280        en = i;
     5281      }
    55805282    }
    55815283  }
Note: See TracChangeset for help on using the changeset viewer.