Changeset 5d4fa4 in git for kernel/GBEngine/kutil.cc
 Timestamp:
 Oct 21, 2015, 11:58:18 AM (8 years ago)
 Branches:
 (u'spielwiese', 'ec94ef7a30b928574c0c3daf41f6804dff5f6b69')
 Children:
 ef1a968e317a12b42f88e04cd7f9483e47fba2f7
 Parents:
 d5a14976ed24bbe1ef7d62031b04ec3dbfa74e0e
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

kernel/GBEngine/kutil.cc
rd5a149 r5d4fa4 1181 1181 void enterOnePairRing (int i,poly p,int ecart, int isFromQ,kStrategy strat, int atR = 1) 1182 1182 { 1183 #if 01184 assume(i<=strat>sl);1185 int l,j,compare,compareCoeff;1186 LObject Lp;1187 if (strat>interred_flag) return;1188 #ifdef KDEBUG1189 Lp.ecart=0; Lp.length=0;1190 #endif1191 /* 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 == 01196 if (nIsZero(pGetCoeff(Lp.lcm)))1197 {1198 #ifdef KDEBUG1199 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 #endif1209 strat>cp++;1210 pLmDelete(Lp.lcm);1211 return;1212 }1213 // basic product criterion1214 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 KDEBUG1222 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 #endif1232 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 canceled1241 *if the leading term of r devides lcm(s,p) then (s,p) will not enter B1242 */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 KDEBUG1253 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 #endif1263 if ((strat>fromQ==NULL)  (isFromQ==0)  (strat>fromQ[i]==0))1264 {1265 pLmDelete(Lp.lcm);1266 return;1267 }1268 break;1269 }1270 else1271 if (compare == 1)1272 {1273 #ifdef KDEBUG1274 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 #endif1284 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 KDEBUG1293 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 #endif1303 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 else1312 // Add hint for same LM and LC (later) (TODO Oliver)1313 // if (compareCoeff == pDivComp_GREATER)1314 {1315 #ifdef KDEBUG1316 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 #endif1326 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 != 01333 */1334 /* compute the short spolynomial */1335 if ((strat>S[i]==NULL)  (p==NULL))1336 {1337 #ifdef KDEBUG1338 if (TEST_OPT_DEBUG)1339 {1340 PrintS(" spoly = NULL\n");1341 }1342 #endif1343 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 will1349 // reduce to zero. Oliver.1350 WarnS("Could we come here? 8738947389");1351 Lp.p=NULL;1352 }1353 else1354 {1355 Lp.p = ksCreateShortSpoly(strat>S[i], p, strat>tailRing);1356 }1357 if (Lp.p == NULL)1358 {1359 #ifdef KDEBUG1360 if (TEST_OPT_DEBUG)1361 {1362 PrintS(" spoly = NULL\n");1363 }1364 #endif1365 /* the case that the spoly 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) is1372 *still in B (i.e. lcm(r,p) == lcm(s,p) or the leading term of s does not1373 *devide lcm(r,p)). In the last case (s,r) can be canceled if the leading1374 *term of p devides the lcm(s,r)1375 *(this canceling should be done here because1376 *the case lcm(s,p) == lcm(s,r) is not covered in chainCrit)1377 *the first case is handeled in chainCrit1378 */1379 pLmDelete(Lp.lcm);1380 }1381 else1382 {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 #else1399 1183 assume(atR >= 0); 1400 1184 assume(i<=strat>sl); … … 1415 1199 return; 1416 1200 } 1417 #if 11418 1201 // basic chain criterion 1419 1202 pLcm(p,strat>S[i],h.lcm); … … 1426 1209 */ 1427 1210 1428 //#if ADIDEBUG1429 #if 01430 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 #endif1436 1437 1211 for(j = strat>Bl;j>=0;j) 1438 1212 { 1439 1213 compare=pDivCompRing(strat>B[j].lcm,h.lcm); 1440 1214 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)) 1512 1235 { 1513 1236 #if ADIDEBUG … … 1520 1243 break; 1521 1244 } 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 { 1541 1247 #if ADIDEBUG 1542 printf("\nGelÃ¶scht B[j]\n");1248 printf("\nGelÃ¶scht: B[j]\n"); 1543 1249 #endif 1544 1250 deleteInL(strat>B,&strat>Bl,j,strat); 1545 1251 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 } 1551 1292 number s, t; 1552 1293 poly m1, m2, gcd = NULL; … … 1649 1390 enterL(&strat>B,&strat>Bl,&strat>Bmax,h,posx); 1650 1391 kTest_TS(strat); 1651 #endif1652 1392 } 1653 1393 … … 5395 5135 LObject* p,const kStrategy strat) 5396 5136 { 5397 #if 05398 if (length < 0) return 0;5399 if(pIsConstant(p>p)) return length+1;5400 int i,an,en;5401 #if 15402 if(pIsConstant(set[length].p) && length > 0)5403 {5404 if (set[length1].FDeg > p>FDeg)5405 return length;5406 }5407 else5408 {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 = length1;5428 else5429 i = length;5430 while(i>=0 && set[i].FDeg < p>FDeg)5431 i;5432 en = i+1;5433 }5434 else5435 {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 = length1;5442 else5443 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 #else5452 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 #endif5460 loop5461 {5462 if(an > length)5463 return length+1;5464 if (an >= en1)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 else5477 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 else5490 en = i;5491 }5492 }5493 #else5494 5137 if (length < 0) return 0; 5495 5138 int an,en,i; … … 5514 5157 if (pLmCmp(set[an].p, p>p) == 0) 5515 5158 { 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); 5517 5170 return en; 5171 } 5518 5172 else 5173 { 5174 nDelete(&lcset); 5175 nDelete(&lcp); 5519 5176 return an; 5177 } 5520 5178 } 5521 5179 } … … 5527 5185 if (pLmCmp(set[i].p, p>p) == 0) 5528 5186 { 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); 5530 5198 an = i; 5199 } 5531 5200 else 5201 { 5202 nDelete(&lcset); 5203 nDelete(&lcp); 5532 5204 en = i; 5533 }5534 }5535 #endif5205 } 5206 } 5207 } 5536 5208 } 5537 5209 … … 5561 5233 if (set[an].FDeg == p>FDeg) 5562 5234 { 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); 5564 5246 return en; 5247 } 5565 5248 else 5249 { 5250 nDelete(&lcset); 5251 nDelete(&lcp); 5566 5252 return an; 5253 } 5567 5254 } 5568 5255 } … … 5574 5261 if (set[i].FDeg == p>FDeg) 5575 5262 { 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); 5577 5274 an = i; 5275 } 5578 5276 else 5277 { 5278 nDelete(&lcset); 5279 nDelete(&lcp); 5579 5280 en = i; 5281 } 5580 5282 } 5581 5283 }
Note: See TracChangeset
for help on using the changeset viewer.