Changeset 66e7b5 in git for kernel/f5gb.cc
- Timestamp:
- Jan 29, 2009, 6:59:30 PM (15 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- 5d0556d9643aab314fbe86e3ef4cbcd69d864661
- Parents:
- 5376a6afb7e0e9c5e8ba37a9e7964552e94edc3b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/f5gb.cc
r5376a6 r66e7b5 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: f5gb.cc,v 1.1 8 2009-01-28 17:20:49 SingularExp $ */4 /* $Id: f5gb.cc,v 1.19 2009-01-29 17:59:30 ederc Exp $ */ 5 5 /* 6 6 * ABSTRACT: f5gb interface … … 67 67 ================================================== 68 68 */ 69 LList* F5inc(int* i, poly* f_i, LList* gPrev, poly* ONE ) {69 LList* F5inc(int* i, poly* f_i, LList* gPrev, poly* ONE, RList* rules, LTagList* lTag) { 70 70 gPrev->insert(ONE,i,f_i); 71 CList* critPairs = criticalPair(gPrev); 72 71 CList* critPairs = new CList(); 72 critPairs = criticalPair(gPrev, critPairs, rules, lTag); 73 73 74 return gPrev; 74 75 } … … 82 83 ================================================================ 83 84 */ 84 CList* criticalPair(LList* gPrev) { 85 poly lcm = pInit(); 86 number n = nInit(2); 87 nWrite(n); 88 pWrite(lcm); 85 CList* criticalPair(LList* gPrev, CList* critPairs, RList* rules, LTagList* lTag) { 89 86 // initialization for usage in pLcm() 87 number nOne = nInit(1); 90 88 LNode* first = gPrev->getFirst(); 91 89 LNode* l = gPrev->getFirst()->getNext(); 92 poly t1, t2 = pInit(); 93 t1 = pHead(*first->getPoly()); 94 poly u1 = pOne(); 95 poly u2 = pOne(); 96 CList* critpairs = NULL; 90 poly* u1 = new poly(pInit()); 91 poly* u2 = new poly(pInit()); 92 poly* lcm = new poly(pInit()); 97 93 // computation of critical pairs 98 94 while( NULL != l) { 99 95 //pWrite( *(gPrev->getFirst()->getPoly()) ); 100 96 //pWrite( *(l->getPoly()) ); 101 pLcm(*first->getPoly(), *l->getPoly(), t1); 102 pWrite(t1); 103 pWrite(u1); 104 pWrite(u2); 105 pSetCoeff0(lcm,n); 106 poly p = lcm; 107 pWrite(p); 108 Print("%ld\n",pDeg(t1)); 97 pLcm(first->getPoly(), l->getPoly(), *lcm); 98 pSetCoeff(*lcm,nOne); 109 99 // computing factors u1 & u2 for new labels 110 u1 = pDivide(lcm, t1); 111 pWrite(u1); 112 pWrite(t1); 113 Print("%ld\n",pDeg(t1)); 114 //pSetCoeff(u1,pGetCoeff(pOne())); 115 pWrite(u1); 116 t2 = pHead(*l->getPoly()); 117 pWrite(t2); 118 // testing stuff 119 u1 = ppMult_qq(t1,t2); 120 pWrite(u1); 121 pWrite(t2); 122 Print("%ld\n",pDeg(u1)); 123 Print("%ld\n",pDeg(t2)); 124 u2 = pDivide(lcm, t2); 125 pSetCoeff(u2, pGetCoeff(pOne())); 126 pWrite(u2); 127 Print("%ld\n",pDeg(u2)); 100 *u1 = pDivide(*lcm,pHead(first->getPoly())); 101 pSetCoeff(*u1,nOne); 102 *u2 = pDivide(*lcm, pHead(l->getPoly())); 103 pSetCoeff(*u2,nOne); 104 pWrite(*u2); 128 105 // testing both new labels by the F5 Criterion 129 if(!criterion1(first, gPrev) && 130 !criterion1(l, gPrev)) { 131 if(*first->getIndex() == *l->getIndex()) { 132 if(pMult(u1, *first->getTerm()) < pMult(u2, *l->getTerm())) { 133 //if(!critPairs) { 134 CPair* cp = new CPair(pDeg(lcm), u1, first->getLPoly(), u2, 135 l->getLPoly()); 136 //} 137 } 138 } 139 } 140 141 Print("\n"); 106 if(!criterion1(u1, first, lTag) && !criterion1(u2, l, lTag) && 107 !criterion2(u1, first, rules) && !criterion2(u2, l, rules)) { 108 Print("Criteria passed\n"); 109 // if they pass the test, add them to CList critPairs, having the LPoly with greater 110 // label as first element in the CPair 111 if(first->getIndex() == l->getIndex() && 112 pMult(*u1, first->getTerm()) < pMult(*u2, l->getTerm())) { 113 CPair* cp = new CPair(pDeg(ppMult_qq(*u2,pHead(l->getPoly()))), *u2, 114 l->getLPoly(), *u1, first->getLPoly()); 115 critPairs->insert(cp); 116 } 117 else { 118 CPair* cp = new CPair(pDeg(ppMult_qq(*u2,pHead(l->getPoly()))), *u1, 119 first->getLPoly(), *u2, l->getLPoly()); 120 critPairs->insert(cp); 121 } 122 } 123 else { 124 Print("Criteria not passed\n"); 125 } 126 127 // for debugging 128 if(NULL != critPairs) { 129 critPairs->print(); 130 } 142 131 l = l->getNext(); 143 132 } 144 return NULL; 133 Print("ENDE CRITPAIRS\n"); 134 return critPairs; 145 135 } 146 136 … … 150 140 ======================================== 151 141 */ 152 bool criterion1(LNode* l, LList* gPrev) { 153 LNode* testNode = l->getNext(); 142 bool criterion1(poly* t, LNode* l, LTagList* lTag) { 143 // start at the previously added element to gPrev, as all other elements will have the same index for sure 144 LNode* testNode = lTag->get(l->getIndex()); 145 // save the monom t1*label_term(l) as it is tested various times in the following 146 poly u1 = ppMult_qq(*t,l->getTerm()); 154 147 while(NULL != testNode) { 155 while(*testNode->getIndex() == *l->getIndex()) { 148 //while(NULL != testNode && testNode->getIndex() == l->getIndex()) { 149 // testNode = testNode->getNext(); 150 //} 151 Print("%d\n", pLmDivisibleByNoComp(pHead(testNode->getPoly()),u1)); 152 if(NULL != testNode && pLmDivisibleByNoComp(pHead(testNode->getPoly()),u1)) { 153 return true; 154 } 155 testNode = testNode->getNext(); 156 157 } 158 // 25/01/2009: TO DO -> change return value, until now no element is added to CList! 159 return false; 160 } 161 162 /* 163 ===================================== 164 Criterion 2, i.e. Rewritten Criterion 165 ===================================== 166 */ 167 bool criterion2(poly* t, LNode* l, RList* rules) { 168 // start at the previously added element to gPrev, as all other elements will have the same index for sure 169 RNode* testNode = rules->getFirst(); 170 while(NULL != testNode->getRule()) { 171 while(NULL != testNode->getRule() && testNode->getRuleIndex() == l->getIndex()) { 156 172 testNode = testNode->getNext(); 157 173 } 158 } 174 if(NULL != testNode->getRule() && 175 pLmDivisibleByNoComp(ppMult_qq(*t,l->getTerm()),testNode->getRuleTerm())) { 176 return true; 177 } 178 testNode = testNode->getNext(); 159 179 160 161 return true; 162 } 180 } 181 // 25/01/2009: TO DO -> change return value, until now no element is added to CList! 182 183 return false; 184 } 185 163 186 164 187 /* 165 188 ========================================================================== 166 MAIN:computes a gb of the ideal i in the ring r with our f5 implementation189 MAIN:computes a gb of the ideal i in the ring r with our F5 implementation 167 190 ========================================================================== 168 191 */ … … 170 193 int i,j; 171 194 // 1 polynomial for defining initial labels & further tests 172 static poly ONE = pOne(); 195 poly ONE = pOne(); 196 // list of rules 197 RList* rules = new RList(); 173 198 i = 1; 174 LList* gPrev = new LList( &ONE, &i, &id->m[0]); 199 LList* gPrev = new LList( &ONE, &i, &id->m[0]); 200 LTagList* lTag = new LTagList(gPrev->getFirst()); 175 201 poly* lcm = new poly; 176 202 // initialization for usage in pLcm() … … 205 231 pWrite(q); 206 232 for(i=2; i<=IDELEMS(id); i++) { 207 gPrev = F5inc( &i, &id->m[i-1], gPrev, &ONE ); 233 gPrev = F5inc(&i, &id->m[i-1], gPrev, &ONE, rules, lTag); 234 lTag->insert(gPrev->getFirst()); 235 Print("JA\n"); 208 236 } 209 237 // only for debugging
Note: See TracChangeset
for help on using the changeset viewer.