Changeset a9c298 in git for kernel/f5gb.cc
- Timestamp:
- Nov 20, 2013, 4:54:25 PM (10 years ago)
- Branches:
- (u'spielwiese', '17f1d200f27c5bd38f5dfc6e8a0879242279d1d8')
- Children:
- 0de0509972719531e2a4b51ec9fd0e44a66fd2fd
- Parents:
- e4014563a82388c4b39dfa37db24cbe159b24a35
- git-author:
- Hans Schoenemann <hannes@mathematik.uni-kl.de>2013-11-20 16:54:25+01:00
- git-committer:
- Hans Schoenemann <hannes@mathematik.uni-kl.de>2013-11-20 16:54:42+01:00
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/f5gb.cc
re40145 ra9c298 47 47 /* 48 48 ==================================================================== 49 sorting ideals by decreasing total degree "left" and "right" are the 49 sorting ideals by decreasing total degree "left" and "right" are the 50 50 pointer of the first and last polynomial in the considered ideal 51 51 ==================================================================== … … 59 59 while(pTotaldegree(*ptr1, currRing) < pTotaldegree(p2, currRing)) { 60 60 ptr1++; 61 } 61 } 62 62 while(pTotaldegree(*ptr2, currRing) > pTotaldegree(p2,currRing)) { 63 63 ptr2--; … … 111 111 return true; 112 112 } 113 } 113 } 114 114 } 115 115 } … … 119 119 /* 120 120 ================================================== 121 computes incrementally gbs of subsets of the input 121 computes incrementally gbs of subsets of the input 122 122 gb{f_m} -> gb{f_m,f_(m-1)} -> gb{f_m,...,f_1} 123 123 ================================================== 124 124 */ 125 125 LList* F5inc(int i, poly f_i, LList* gPrev, LList* reducers, ideal gbPrev, poly ONE, LTagList* lTag, RList* rules, RTagList* rTag, int plus, int termination) { 126 //Print("in f5inc\n"); 126 //Print("in f5inc\n"); 127 127 //pWrite(rules->getFirst()->getRuleTerm()); 128 128 int iterationstep = i; … … 140 140 //Print("2nd gPrev: "); 141 141 //pWrite(gPrev->getFirst()->getNext()->getPoly()); 142 //pWrite(gPrev->getFirst()->getNext()->getPoly()); 142 //pWrite(gPrev->getFirst()->getNext()->getPoly()); 143 143 CListOld* critPairs = new CListOld(); 144 CNode* critPairsMinDeg = new CNode(); 144 CNode* critPairsMinDeg = new CNode(); 145 145 PList* rejectedGBList = new PList(); 146 146 // computation of critical pairs with checking of criterion 1 and criterion 2 and saving them … … 154 154 static LList* reducedLPolys = new LList(); 155 155 // while there are critical pairs to be further checked and deleted/computed 156 while(NULL != critPairs->getFirst()) { 156 while(NULL != critPairs->getFirst()) { 157 157 // critPairs->getMinDeg() deletes the first elements of minimal degree from 158 158 // critPairs, thus the while loop is not infinite. 159 // adds all to be reduced S-polynomials in the list sPolyList and adds 159 // adds all to be reduced S-polynomials in the list sPolyList and adds 160 160 // the corresponding rules to the list rules 161 // NOTE: inside there is a second check of criterion 2 if new rules are 161 // NOTE: inside there is a second check of criterion 2 if new rules are 162 162 // added 163 163 //int timer4 = initTimer(); … … 180 180 //Print("number of useful pairs: %d\n",numberUsefulPairs); 181 181 //Print("number of useless pairs: %d\n\n",numberUselessPairs); 182 //Print("Degree of following reduction: %d\n",critPairsMinDeg->getData()->getDeg()); 183 long degreecheck = critPairsMinDeg->getData()->getDeg(); 184 182 //Print("Degree of following reduction: %d\n",critPairsMinDeg->getData()->getDeg()); 183 long degreecheck = critPairsMinDeg->getData()->getDeg(); 184 185 185 computeSPols(critPairsMinDeg,rTag,rules,sPolyList, rejectedGBList); 186 186 //} … … 216 216 // return gPrev; 217 217 //} 218 //Print("ARRIS DEG: %ld\n",arrideg); 218 //Print("ARRIS DEG: %ld\n",arrideg); 219 219 // Arris idea stated by John in an email 220 220 //if(arrisCheck(critPairs->getFirst(),gPrev->getFirst(),arrideg)) { … … 222 222 // return gPrev; 223 223 //} 224 225 226 //bool aha = checkDGB(gPrev); 227 224 225 226 //bool aha = checkDGB(gPrev); 227 228 228 229 229 //timer3 = getTimer(); 230 230 //reductionTime = reductionTime + timer3; 231 //Print("REDUCTION TIMER: %d\n",timer3); 231 //Print("REDUCTION TIMER: %d\n",timer3); 232 232 // DEBUG STUFF FOR GPREV 233 233 //temp = gPrev->getFirst(); … … 242 242 //} 243 243 //sleep(5); 244 244 245 245 } 246 246 //Print("REDUCTION DONE\n"); … … 333 333 ppMult_qq(u2,temp2->getPoly())); 334 334 pNorm(sp); 335 335 336 336 poly reducer = pOne(); 337 337 //reducer = gb->m[0]; 338 338 int i = 0; 339 339 pWrite(pHead(sp)); 340 340 341 341 while(i<IDELEMS(gb)) { 342 342 reducer = gb->m[i]; … … 356 356 } 357 357 } 358 358 359 359 pWrite(pHead(sp)); 360 360 } … … 371 371 * Checks all remaining critical pairs, i.e. those of higher degree, 372 372 * by the two Buchberger criteria. 373 * return value: 0, if all remaining critical pairs are deleted by 373 * return value: 0, if all remaining critical pairs are deleted by 374 374 * Buchberger's criteria 375 375 * 1, otherwise … … 377 377 bool arrisCheck(CNode* first, LNode* firstGCurr, long arrideg) { 378 378 CNode* temp = first; 379 379 380 380 //product criterion check 381 381 while(NULL != temp) { … … 422 422 } 423 423 424 425 424 425 426 426 /* 427 427 ================================================================ 428 428 computes a list of critical pairs for the next reduction process 429 the first element is always "useful" thus the critical pair 430 computed is either "useful" or "useless" depending on the second 429 the first element is always "useful" thus the critical pair 430 computed is either "useful" or "useless" depending on the second 431 431 element which generates the critical pair. 432 432 first element in gPrev is always the newest element which must … … 466 466 u2 = pDivide(lcm,pHead(temp->getPoly())); 467 467 pSetCoeff(u2,nOne); 468 int degree = pDeg(ppMult_qq(u2,pHead(temp->getPoly()))); 468 int degree = pDeg(ppMult_qq(u2,pHead(temp->getPoly()))); 469 469 // testing both new labels by the F5 Criterion 470 470 if(!temp->getDel()) { … … 473 473 } 474 474 if(!criterion2(gPrev->getFirst()->getIndex(), u2, temp, rules, rTag) 475 && !criterion2(gPrev->getFirst()->getIndex(), u1, newElement, rules, rTag) 475 && !criterion2(gPrev->getFirst()->getIndex(), u1, newElement, rules, rTag) 476 476 && !criterion1(gPrev,u1,newElement,lTag) && !criterion1(gPrev,u2,temp,lTag)) { 477 477 // if they pass the test, add them to CListOld critPairs, having the LPolyOld with greater 478 478 // label as first element in the CPairOld 479 if(newElement->getIndex() == temp->getIndex() && 479 if(newElement->getIndex() == temp->getIndex() && 480 480 -1 == pLmCmp(ppMult_qq(u1, newElement->getTerm()),ppMult_qq(u2, temp->getTerm()))) { 481 CPairOld* cp = new CPairOld(pDeg(ppMult_qq(u2,pHead(temp->getPoly()))), u2, 482 temp->getLPolyOld(), u1, newElement->getLPolyOld(), 0 , testedRuleOld); 481 CPairOld* cp = new CPairOld(pDeg(ppMult_qq(u2,pHead(temp->getPoly()))), u2, 482 temp->getLPolyOld(), u1, newElement->getLPolyOld(), 0 , testedRuleOld); 483 483 critPairs->insert(cp); 484 484 // counting the number of useful pairs … … 486 486 } 487 487 else { 488 CPairOld* cp = new CPairOld(pDeg(ppMult_qq(u2,pHead(temp->getPoly()))), u1, 489 newElement->getLPolyOld(), u2, temp->getLPolyOld(), 0, testedRuleOld); 488 CPairOld* cp = new CPairOld(pDeg(ppMult_qq(u2,pHead(temp->getPoly()))), u1, 489 newElement->getLPolyOld(), u2, temp->getLPolyOld(), 0, testedRuleOld); 490 490 critPairs->insert(cp); 491 491 // counting the number of useful pairs … … 511 511 //if(rejectedGBList->check(lcm)) { // if there is equality of lcms then we need the F5 critical pair 512 512 if(!criterion2(gPrev->getFirst()->getIndex(), u2, temp, rules, rTag) 513 && !criterion2(gPrev->getFirst()->getIndex(), u1, newElement, rules, rTag) 513 && !criterion2(gPrev->getFirst()->getIndex(), u1, newElement, rules, rTag) 514 514 && !criterion1(gPrev,u1,newElement,lTag) && !criterion1(gPrev,u2,temp,lTag)) { 515 515 // if they pass the test, add them to CListOld critPairs, having the LPolyOld with greater 516 516 // label as first element in the CPairOld 517 if(newElement->getIndex() == temp->getIndex() && 517 if(newElement->getIndex() == temp->getIndex() && 518 518 -1 == pLmCmp(ppMult_qq(u1, newElement->getTerm()),ppMult_qq(u2, temp->getTerm()))) { 519 CPairOld* cp = new CPairOld(pDeg(ppMult_qq(u2,pHead(temp->getPoly()))), u2, 520 temp->getLPolyOld(), u1, newElement->getLPolyOld(), 1 , testedRuleOld); 519 CPairOld* cp = new CPairOld(pDeg(ppMult_qq(u2,pHead(temp->getPoly()))), u2, 520 temp->getLPolyOld(), u1, newElement->getLPolyOld(), 1 , testedRuleOld); 521 521 critPairs->insert(cp); 522 522 numberUselessPairs++; 523 523 } 524 524 else { 525 CPairOld* cp = new CPairOld(pDeg(ppMult_qq(u2,pHead(temp->getPoly()))), u1, 526 newElement->getLPolyOld(), u2, temp->getLPolyOld(), 1, testedRuleOld); 525 CPairOld* cp = new CPairOld(pDeg(ppMult_qq(u2,pHead(temp->getPoly()))), u1, 526 newElement->getLPolyOld(), u2, temp->getLPolyOld(), 1, testedRuleOld); 527 527 critPairs->insert(cp); 528 528 numberUselessPairs++; … … 540 540 ================================================================ 541 541 computes a list of critical pairs for the next reduction process 542 the first element is always "useless" thus the critical pair 542 the first element is always "useless" thus the critical pair 543 543 computed is "useless". 544 544 first element in gPrev is always the newest element which must … … 577 577 //if(rejectedGBList->check(lcm)) { // if there is equality of lcms then we need the F5 critical pair 578 578 if(!criterion2(gPrev->getFirst()->getIndex(), u2, temp, rules, rTag) 579 && !criterion2(gPrev->getFirst()->getIndex(), u1, newElement, rules, rTag) 579 && !criterion2(gPrev->getFirst()->getIndex(), u1, newElement, rules, rTag) 580 580 && !criterion1(gPrev,u1,newElement,lTag) && !criterion1(gPrev,u2,temp,lTag)) { 581 581 // if they pass the test, add them to CListOld critPairs, having the LPolyOld with greater 582 582 // label as first element in the CPairOld 583 if(newElement->getIndex() == temp->getIndex() && 583 if(newElement->getIndex() == temp->getIndex() && 584 584 -1 == pLmCmp(ppMult_qq(u1, newElement->getTerm()),ppMult_qq(u2, temp->getTerm()))) { 585 CPairOld* cp = new CPairOld(pDeg(ppMult_qq(u2,pHead(temp->getPoly()))), u2, 586 temp->getLPolyOld(), u1, newElement->getLPolyOld(), 1 , testedRuleOld); 585 CPairOld* cp = new CPairOld(pDeg(ppMult_qq(u2,pHead(temp->getPoly()))), u2, 586 temp->getLPolyOld(), u1, newElement->getLPolyOld(), 1 , testedRuleOld); 587 587 critPairs->insert(cp); 588 588 numberUselessPairs++; 589 589 } 590 590 else { 591 CPairOld* cp = new CPairOld(pDeg(ppMult_qq(u2,pHead(temp->getPoly()))), u1, 592 newElement->getLPolyOld(), u2, temp->getLPolyOld(), 1, testedRuleOld); 591 CPairOld* cp = new CPairOld(pDeg(ppMult_qq(u2,pHead(temp->getPoly()))), u1, 592 newElement->getLPolyOld(), u2, temp->getLPolyOld(), 1, testedRuleOld); 593 593 critPairs->insert(cp); 594 594 numberUselessPairs++; 595 595 } 596 596 } 597 //} 597 //} 598 598 temp = temp->getNext(); 599 599 } … … 609 609 inline bool criterion1(LList* gPrev, poly t, LNode* l, LTagList* lTag) { 610 610 // starts at the first element in gPrev with index = (index of l)-1, these tags are saved in lTag 611 611 int idx = l->getIndex(); 612 612 int i; 613 613 if(idx == 1) { … … 670 670 inline bool criterion2(int idx, poly t, LNode* l, RList* rules, RTagList* rTag) { 671 671 //Print("------------------------------IN CRITERION 2/1-----------------------------------------\n"); 672 /* 672 /* 673 673 Print("RULES: \n"); 674 674 RNode* tempR = rules->getFirst(); … … 694 694 return false; 695 695 } 696 696 697 697 RNode* testNode; // = new RNode(); 698 698 testNode = rules->getFirst(); … … 706 706 } 707 707 } 708 708 709 709 else { 710 710 … … 713 713 } 714 714 else { 715 //Print("HIER\n"); 715 //Print("HIER\n"); 716 716 //Print("DEBUG\n"); 717 717 //Print("L INDEX: %d\n",l->getIndex()); … … 731 731 */ 732 732 //testNode = rules->getFirst(); 733 733 // save the monom t1*label_term(l) as it is tested various times in the following 734 734 poly u1 = ppMult_qq(t,l->getTerm()); 735 735 // first element added to rTag was NULL, check for this … … 738 738 //Print("TESTNODE: %p\n",testNode); 739 739 //pWrite(testNode->getRuleTerm()); 740 if(NULL != testNode ) { 740 if(NULL != testNode ) { 741 741 //pWrite(testNode->getRuleTerm()); 742 742 } … … 750 750 } 751 751 } 752 while(NULL != testNode && testNode->getRuleOld() != l->getRuleOld() 752 while(NULL != testNode && testNode->getRuleOld() != l->getRuleOld() 753 753 && l->getIndex() == testNode->getRuleOldIndex()) { 754 754 //Print("%p\n",testNode); … … 765 765 return true; 766 766 } 767 767 testNode = testNode->getNext(); 768 768 } 769 769 //delete testNode; … … 798 798 */ 799 799 // start at the previously added element to gPrev, as all other elements will have the same index for sure 800 800 RNode* testNode = rules->getFirst(); 801 801 // save the monom t1*label_term(l) as it is tested various times in the following 802 802 poly u1 = ppMult_qq(t,l->getTerm()); 803 804 803 // first element added to rTag was NULL, check for this 804 while(NULL != testNode && testNode->getRuleOld() != testedRuleOld) { 805 805 //pWrite(testNode->getRuleTerm()); 806 806 if(pLmDivisibleByNoComp(testNode->getRuleOldTerm(),u1)) { … … 811 811 return true; 812 812 } 813 813 testNode = testNode->getNext(); 814 814 } 815 815 pDelete(&u1); … … 837 837 ================================== 838 838 */ 839 void computeSPols(CNode* first, RTagList* rTag, RList* rules, LList* sPolyList, PList* rejectedGBList) { 839 void computeSPols(CNode* first, RTagList* rTag, RList* rules, LList* sPolyList, PList* rejectedGBList) { 840 840 CNode* temp = first; 841 841 //Print("\nDegree: %d\n",temp->getData()->getDeg()); … … 850 850 CListOld* f5pairs = new CListOld(); 851 851 poly sp = pInit(); 852 number sign = nInit(-1); 852 number sign = nInit(-1); 853 853 //Print("###############################IN SPOLS##############################\n"); 854 854 //first->print(); … … 898 898 } 899 899 rejectedGBList->insert(pHead(ppMult_qq(temp->getT1(),temp->getLp1Poly()))); 900 //Print("rejected!\n"); 900 //Print("rejected!\n"); 901 901 902 902 //Print("CRITERION 2 in SPOLS 2nd generator\n"); 903 903 } 904 904 } 905 else { 905 else { 906 906 sp = ksOldSpolyRedNew(ppMult_qq(temp->getT1(),temp->getLp1Poly()), 907 907 ppMult_qq(temp->getT2(),temp->getLp2Poly())); … … 925 925 } 926 926 } 927 /* 927 /* 928 928 if(temp->getDel() == 0 && criterion2(temp->getT1(),temp->getAdLp1(),rules,temp->getTestedRuleOld())) { 929 //Print("rejected!\n"); 929 //Print("rejected!\n"); 930 930 rejectedGBList->insert(pHead(ppMult_qq(temp->getT1(),temp->getLp1Poly()))); 931 931 } 932 933 932 933 934 934 if(temp->getDel() == 1 && !criterion2(temp->getT1(),temp->getAdLp1(),rules,temp->getTestedRuleOld())) { 935 if(highestDegree < pDeg(ppMult_qq(temp->getT1(),temp->getLp1Poly()))) { 935 if(highestDegree < pDeg(ppMult_qq(temp->getT1(),temp->getLp1Poly()))) { 936 936 highestDegree = pDeg(ppMult_qq(temp->getT1(),temp->getLp1Poly())); 937 } 937 } 938 938 if(temp->getLp2Index() == temp->getLp1Index()) { 939 939 if(!criterion2(temp->getT2(),temp->getAdLp2(),rules,temp->getTestedRuleOld())) { … … 956 956 957 957 f5rules->insert(rules->getFirst()->getRuleOld()); 958 f5pairs->insertWithoutSort(temp->getData()); 958 f5pairs->insertWithoutSort(temp->getData()); 959 959 /////////////////////////////////////// 960 960 … … 963 963 } 964 964 } 965 else { 965 else { 966 966 sp = ksOldSpolyRedNew(ppMult_qq(temp->getT1(),temp->getLp1Poly()), 967 967 ppMult_qq(temp->getT2(),temp->getLp2Poly())); … … 983 983 984 984 f5rules->insert(rules->getFirst()->getRuleOld()); 985 f5pairs->insertWithoutSort(temp->getData()); 985 f5pairs->insertWithoutSort(temp->getData()); 986 986 /////////////////////////////////////// 987 987 //sPolyList->insertByLabel(ppMult_qq(temp->getT1(),temp->getLp1Term()),temp->getLp1Index(),sp,rules->getFirst()->getRuleOld()); … … 1004 1004 1005 1005 } 1006 1007 /* 1006 1007 /* 1008 1008 temp = f5pairs->getFirst(); 1009 1009 RNode* tempRule = f5rules->getFirst(); … … 1026 1026 numberRejectedF5CriticalPairs++; 1027 1027 howmany++; 1028 if(numberRejectedF5CriticalPairs < -1) { // || 1028 if(numberRejectedF5CriticalPairs < -1) { // || 1029 1029 } 1030 1030 else { … … 1050 1050 //if(temp->getLp1Index() < 7) { 1051 1051 sPolyList->insertByLabel(ppMult_qq(temp->getT1(),temp->getLp1Term()),temp->getLp1Index(),sp,tempRule->getRuleOld()); 1052 1052 1053 1053 //} 1054 1054 //numberOfSpolys++; 1055 1055 } 1056 //pSetExp(tempRule->getRuleOld()->getTerm(),1,1000); 1056 //pSetExp(tempRule->getRuleOld()->getTerm(),1,1000); 1057 1057 } 1058 1058 temp = temp->getNext(); … … 1060 1060 1061 1061 } 1062 */ 1063 // these critical pairs can be deleted now as they are either useless for further computations or 1062 */ 1063 // these critical pairs can be deleted now as they are either useless for further computations or 1064 1064 // already saved as an S-polynomial to be reduced in the following 1065 delete first; 1065 delete first; 1066 1066 //Print("NUMBER SPOLYS: %d\n", numberOfSpolys); 1067 1067 //Print("SPOLY LIST: \n"); … … 1082 1082 ======================================================================== 1083 1083 */ 1084 void reduction(LList* sPolyList, CListOld* critPairs, LList* gPrev, RList* rules, LTagList* lTag, RTagList* rTag, 1085 ideal gbPrev, PList* rejectedGBList, int plus) { 1084 void reduction(LList* sPolyList, CListOld* critPairs, LList* gPrev, RList* rules, LTagList* lTag, RTagList* rTag, 1085 ideal gbPrev, PList* rejectedGBList, int plus) { 1086 1086 //Print("##########################################In REDUCTION!########################################\n"); 1087 1087 // check if sPolyList has any elements … … 1090 1090 while(NULL != temp) { 1091 1091 // temp is the first element in the sPolyList which should be reduced 1092 // due to earlier sorting this is the element of minimal degree AND 1092 // due to earlier sorting this is the element of minimal degree AND 1093 1093 // minimal label 1094 1094 // delete the above first element from sPolyList, temp will be either reduced to … … 1103 1103 temp->setPoly(tempNF); 1104 1104 // try further reductions of temp with polynomials in gPrev 1105 // with label index = current label index: this is done such that there 1105 // with label index = current label index: this is done such that there 1106 1106 // is no label corruption during the reduction process 1107 1107 //Print("lower label reduction: "); 1108 1108 //pWrite(tempNF); 1109 1109 topReduction(temp,sPolyList,gPrev,critPairs,rules,lTag,rTag,gbPrev, rejectedGBList,plus); 1110 1110 1111 1111 } 1112 1112 else { … … 1121 1121 //sPolyList->print(); 1122 1122 //delete sPolyList; 1123 } 1123 } 1124 1124 1125 1125 /* … … 1128 1128 ======================================================================== 1129 1129 */ 1130 void newReduction(LList* sPolyList, CListOld* critPairs, LList* gPrev, LList* reducers, RList* rules, LTagList* lTag, RTagList* rTag, 1131 ideal gbPrev, int termination, PList* rejectedGBList, int plus) { 1130 void newReduction(LList* sPolyList, CListOld* critPairs, LList* gPrev, LList* reducers, RList* rules, LTagList* lTag, RTagList* rTag, 1131 ideal gbPrev, int termination, PList* rejectedGBList, int plus) { 1132 1132 //Print("##########################################In REDUCTION!########################################\n"); 1133 1133 // check if sPolyList has any elements … … 1139 1139 numberOfReductions++; 1140 1140 // temp is the first element in the sPolyList which should be reduced 1141 // due to earlier sorting this is the element of minimal degree AND 1141 // due to earlier sorting this is the element of minimal degree AND 1142 1142 // minimal label 1143 1143 // delete the above first element from sPolyList, temp will be either reduced to … … 1159 1159 //pWrite(tempNF); 1160 1160 // try further reductions of temp with polynomials in gPrev 1161 // with label index = current label index: this is done such that there 1161 // with label index = current label index: this is done such that there 1162 1162 // is no label corruption during the reduction process 1163 findReducers(temp,sPolyList,gbPrev,gPrev,reducers,critPairs,rules,lTag,rTag, termination, rejectedGBList,plus); 1163 findReducers(temp,sPolyList,gbPrev,gPrev,reducers,critPairs,rules,lTag,rTag, termination, rejectedGBList,plus); 1164 1164 //} 1165 1165 //else { … … 1180 1180 //delete sPolyList; 1181 1181 //Print("REDUCTION FERTIG\n"); 1182 } 1182 } 1183 1183 1184 1184 1185 1185 /*! 1186 1186 * ================================================================================ 1187 * searches for reducers of temp similar to the symbolic preprocessing of F4 and 1187 * searches for reducers of temp similar to the symbolic preprocessing of F4 and 1188 1188 * divides them into a "good" and "bad" part: 1189 * 1189 * 1190 1190 * the "good" ones are the reducers which do not corrupt the label of temp, with 1191 1191 * these the normal form of temp is computed 1192 1192 * 1193 * the "bad" ones are the reducers which corrupt the label of temp, they are tested 1193 * the "bad" ones are the reducers which corrupt the label of temp, they are tested 1194 1194 * later on for possible new rules and S-polynomials to be added to the algorithm 1195 1195 * ================================================================================ … … 1259 1259 break; 1260 1260 } 1261 } 1262 1261 } 1262 1263 1263 } 1264 1264 else { … … 1267 1267 //pWrite(u); 1268 1268 //pWrite(tempRed->getTerm()); 1269 //pWrite(pHead(tempRed->getPoly())); 1269 //pWrite(pHead(tempRed->getPoly())); 1270 1270 addToG = 0; 1271 1271 } … … 1312 1312 } 1313 1313 } 1314 } 1314 } 1315 1315 } 1316 1316 else { 1317 1317 //Print("CRIT 1 "); 1318 1318 1319 1319 if(pLmCmp(ppMult_qq(u,tempRed->getTerm()),l->getTerm()) == 1 ) { 1320 1320 //Print("NOT ALLOWED REDUCER, CRIT 1:\n"); … … 1369 1369 break; 1370 1370 } 1371 1371 1372 1372 } 1373 1373 } … … 1381 1381 //Print("TEMPREDPOLY: "); 1382 1382 //pWrite(tempRed->getPoly()); 1383 //pWrite(tempPoly); 1383 //pWrite(tempPoly); 1384 1384 if(pLmDivisibleByNoComp(tempRed->getPoly(),tempPoly)) { 1385 1385 //Print("A\n"); … … 1412 1412 break; 1413 1413 } 1414 } 1415 1414 } 1415 1416 1416 } 1417 1417 else { … … 1420 1420 //pWrite(u); 1421 1421 //pWrite(tempRed->getTerm()); 1422 //pWrite(pHead(tempRed->getPoly())); 1422 //pWrite(pHead(tempRed->getPoly())); 1423 1423 //addToG = 0; 1424 1424 } … … 1465 1465 } 1466 1466 } 1467 } 1467 } 1468 1468 } 1469 1469 else { 1470 1470 //Print("CRIT 1 "); 1471 1471 1472 1472 if(pLmCmp(ppMult_qq(u,tempRed->getTerm()),l->getTerm()) == 1 ) { 1473 1473 //Print("NOT ALLOWED REDUCER, CRIT 1:\n"); … … 1498 1498 } 1499 1499 } 1500 1500 1501 1501 } 1502 1502 tempRed = tempRed->getNext(); … … 1515 1515 // end for top-reduction only 1516 1516 tempPoly = kBucketGetLm(bucket); 1517 1517 1518 1518 } 1519 1519 } … … 1525 1525 Print("\nELEMENT ADDED TO GPREV: "); 1526 1526 pNorm(redPoly); 1527 if(highestDegree < pDeg(redPoly)) { 1527 if(highestDegree < pDeg(redPoly)) { 1528 1528 highestDegree = pDeg(redPoly); 1529 } 1529 } 1530 1530 pWrite(pHead(redPoly)); 1531 1531 //pWrite(l->getTerm()); … … 1567 1567 } 1568 1568 } 1569 1569 1570 1570 // if there are "bad" reducers than try to compute new S-polynomials and rules 1571 1571 1572 1572 if(NULL != bad->getFirst()) { 1573 1573 //Print("BAD STUFF LIST:\n"); … … 1608 1608 //tempRed->getLPoly()->setRule(rules->getFirst()->getRule()); 1609 1609 tempBadNew->setDel(1); 1610 1610 1611 1611 sPolyList->insertByLabel(tempBadNew); 1612 1612 //Print("BAD SPOLYLIST: \n"); … … 1625 1625 //Print("HIER AUCH\n"); 1626 1626 //Print("SPOLYLIST IN BAD: \n"); 1627 //sPolyList->print(); 1627 //sPolyList->print(); 1628 1628 //Print("END FIND REDUCERS\n"); 1629 1629 } … … 1713 1713 // if label of reductor is greater than the label of l we have to built a new element 1714 1714 // and add it to sPolyList 1715 1715 1716 1716 if(pLmCmp(tempRed->getTerm(),l->getTerm()) == 1) { 1717 1717 // needed sinc pSub destroys the arguments! … … 1743 1743 } 1744 1744 } 1745 1746 // label of reductor is smaller than the label of l, subtract reductor from l and delete the 1747 // gPrevRedCheck pointer added to l during findReductor() as the head term of l changes 1748 // after subtraction 1745 1746 // label of reductor is smaller than the label of l, subtract reductor from l and delete the 1747 // gPrevRedCheck pointer added to l during findReductor() as the head term of l changes 1748 // after subtraction 1749 1749 else { 1750 1750 1751 1751 //poly temp_poly_l = pInit(); 1752 1752 //temp_poly_l = pCopy(l->getPoly()); … … 1760 1760 pNorm(temp); 1761 1761 //pWrite(temp); 1762 poly tempNF = kNF(gbPrev,currQuotient,temp); 1762 poly tempNF = kNF(gbPrev,currQuotient,temp); 1763 1763 pNorm(tempNF); 1764 1764 if(NULL == tempNF) { … … 1769 1769 } 1770 1770 l->setPoly(tempNF); 1771 1771 1772 1772 gPrevRedCheck = lTag->getFirstCurrentIdx(); 1773 1773 } … … 1778 1778 break; 1779 1779 } 1780 } 1780 } 1781 1781 } 1782 1782 else { … … 1816 1816 poly t = pHead(l->getPoly()); 1817 1817 // if l was already checked use the information in gPrevRedCheck such 1818 // that we can start searching for new reducers from this point and 1818 // that we can start searching for new reducers from this point and 1819 1819 // not from the first element of gPrev with the current index 1820 1820 temp = gPrevRedCheck; … … 1867 1867 temp = temp->getNext(); 1868 1868 } 1869 1869 1870 1870 // delete temp; 1871 1871 return NULL; … … 1881 1881 */ 1882 1882 ideal F5main(ideal id, ring r, int opt, int plus, int termination) { 1883 switch(opt) { 1883 switch(opt) { 1884 1884 case 0: 1885 1885 Print("\nComputations are done by the standard F5 Algorithm"); … … 1895 1895 return id; 1896 1896 } 1897 1897 1898 1898 int timer = initTimer(); 1899 1899 startTimer(); … … 1904 1904 poly pOne = pOne(); 1905 1905 number nOne = nInit(1); 1906 // tag the first element of index i-1 for criterion 1 1906 // tag the first element of index i-1 for criterion 1 1907 1907 //Print("LTAG BEGINNING: %p\n",lTag); 1908 1908 1909 1909 // DEBUGGING STUFF START 1910 1910 //Print("NUMBER: %d\n",r->N); 1911 /* 1911 /* 1912 1912 int* ev = new int[r->N +1]; 1913 1913 for(i=0;i<IDELEMS(id);i++) { … … 1923 1923 */ 1924 1924 /*DEBUGGING STUFF END */ 1925 1926 // first element in rTag is first element of rules which is NULL RNode, 1925 1926 // first element in rTag is first element of rules which is NULL RNode, 1927 1927 // this must be done due to possible later improvements 1928 1928 RList* rules = new RList(); … … 1933 1933 i = 1; 1934 1934 /*for(j=0; j<IDELEMS(id); j++) { 1935 if(NULL != id->m[j]) { 1935 if(NULL != id->m[j]) { 1936 1936 if(pComparePolys(id->m[j],ONE)) { 1937 1937 Print("One Polynomial in Input => Computations stopped\n"); … … 1939 1939 idNew->m[0] = ONE; 1940 1940 return(idNew); 1941 } 1942 } 1943 }*/ 1944 ideal idNew = kInterRed(id); 1941 } 1942 } 1943 }*/ 1944 ideal idNew = kInterRed(id); 1945 1945 id = idNew; 1946 1946 //qsortDegree(&id->m[0],&id->m[IDELEMS(id)-1]); … … 1948 1948 LList* gPrev = new LList(ONE, i, id->m[0]); 1949 1949 LList* reducers = new LList(); 1950 //idShow(id); 1950 //idShow(id); 1951 1951 //Print("%p\n",id->m[0]); 1952 1952 //pWrite(id->m[0]); … … 1968 1968 LNode* gPrevTag = gPrev->getLast(); 1969 1969 //Print("Last POlynomial in GPREV: "); 1970 //Print("%p\n",gPrevTag); 1970 //Print("%p\n",gPrevTag); 1971 1971 //pWrite(gPrevTag->getPoly()); 1972 1972 Print("Iteration: %d\n\n",i); … … 1975 1975 //Print("%d\n",gPrev->getLength()); 1976 1976 //Print("____________________________________ITERATION STEP DONE________________________________________\n"); 1977 1977 1978 1978 // DEBUGGING STUFF 1979 1979 LNode* temp = gPrev->getFirst(); 1980 1980 1981 1981 1982 1982 ///////////////////////////////////////////////////////////////////////////////// 1983 // // 1983 // // 1984 1984 // one needs to choose one of the following 3 implementations of the algorithm // 1985 // F5,F5R or F5C // 1985 // F5,F5R or F5C // 1986 1986 // // 1987 ///////////////////////////////////////////////////////////////////////////////// 1988 1989 1990 // 1987 ///////////////////////////////////////////////////////////////////////////////// 1988 1989 1990 // 1991 1991 // standard "F5" 1992 1992 // 1993 if(0 == opt) { 1993 if(0 == opt) { 1994 1994 if(gPrev->getLength() > gbLength) { 1995 1995 if(i < IDELEMS(id)) { … … 2022 2022 gbLength = gPrev->getLength(); 2023 2023 } 2024 2025 2026 // 2024 2025 2026 // 2027 2027 // "F5R" 2028 2028 // … … 2060 2060 gbLength = gPrev->getLength(); 2061 2061 } 2062 2063 2064 // 2062 2063 2064 // 2065 2065 // "F5C" 2066 2066 // 2067 if(2 == opt) { 2067 if(2 == opt) { 2068 2068 if(gPrev->getLength() > gbLength) { 2069 2069 if(i < IDELEMS(id)) { … … 2103 2103 } 2104 2104 } 2105 gbLength = gPrev->getLength(); 2106 } 2105 gbLength = gPrev->getLength(); 2106 } 2107 2107 } 2108 2108 … … 2112 2112 //Print("\n\nADDING TIME IN REDUCTION: %d\n\n",reductionTime); 2113 2113 Print("\n\nNumber of zero-reductions: %d\n",reductionsToZero); 2114 Print("Number of rules: %d\n",numberOfRules); 2115 Print("Number of rejected F5-critical pairs:%d\n",numberRejectedF5CriticalPairs); 2116 Print("Number of reductions: %d\n",numberOfReductions); 2117 Print("Elements not added to G: %d\n",notInG); 2114 Print("Number of rules: %d\n",numberOfRules); 2115 Print("Number of rejected F5-critical pairs:%d\n",numberRejectedF5CriticalPairs); 2116 Print("Number of reductions: %d\n",numberOfReductions); 2117 Print("Elements not added to G: %d\n",notInG); 2118 2118 Print("Highest Degree during computations: %d\n",highestDegree); 2119 2119 Print("Degree d_0 in F5+: %d\n",highestDegreeGBCriticalPair); … … 2134 2134 highestDegree = 0; 2135 2135 highestDegreeGBCriticalPair = 0; 2136 reductionTime = 0; 2136 reductionTime = 0; 2137 2137 spolsTime = 0; 2138 2138 numberUselessPairs = 0;
Note: See TracChangeset
for help on using the changeset viewer.