Changeset 66e7b5 in git
- Timestamp:
- Jan 29, 2009, 6:59:30 PM (14 years ago)
- Branches:
- (u'spielwiese', '0d6b7fcd9813a1ca1ed4220cfa2b104b97a0a003')
- Children:
- 5d0556d9643aab314fbe86e3ef4cbcd69d864661
- Parents:
- 5376a6afb7e0e9c5e8ba37a9e7964552e94edc3b
- Location:
- kernel
- Files:
-
- 6 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 -
kernel/f5gb.h
r5376a6 r66e7b5 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: f5gb.h,v 1.1 7 2009-01-28 17:20:53 SingularExp $ */4 /* $Id: f5gb.h,v 1.18 2009-01-29 17:59:30 ederc Exp $ */ 5 5 /* 6 6 * ABSTRACT: f5gb interface … … 35 35 ================================================== 36 36 */ 37 LList* F5inc(int* i, poly* f_i, LList* gPrev, poly* ONE );37 LList* F5inc(int* i, poly* f_i, LList* gPrev, poly* ONE, RList* rules, LTagList* lTag); 38 38 39 39 /* … … 44 44 ================================================================ 45 45 */ 46 CList* criticalPair(LList* gPrev );46 CList* criticalPair(LList* gPrev, CList* critPairs, RList* rules, LTagList* lTag); 47 47 48 48 /* … … 51 51 ======================================== 52 52 */ 53 bool criterion1(LNode* l, LList* gPrev); 53 bool criterion1(poly* t, LNode* l, LTagList* lTag); 54 55 /* 56 ===================================== 57 Criterion 2, i.e. Rewritten Criterion 58 ===================================== 59 */ 60 bool criterion2(poly* t, LNode* l, RList* rules); 61 54 62 /* 55 63 ====================================== -
kernel/f5lists.cc
r5376a6 r66e7b5 31 31 } 32 32 33 LNode::LNode(LPoly* lp, LNode* l) { 34 data = lp; 35 next = l; 36 } 33 37 LNode::LNode(poly* t, int* i, poly* p) { 34 38 LPoly* lp = new LPoly(t,i,p); … … 37 41 } 38 42 39 LNode::LNode(LNode* ln) { 43 LNode::LNode(poly* t, int* i, poly* p, LNode* l) { 44 LPoly* lp = new LPoly(t,i,p); 45 data = lp; 46 next = l; 47 } 48 49 LNode::LNode(LNode* ln) { 40 50 data = ln->getLPoly(); 41 51 next = ln->getNext(); … … 49 59 // insert new elements to the list always in front (labeled / classical polynomial view) 50 60 LNode* LNode::insert(LPoly* lp) { 51 LNode* newElement = new LNode(lp); 52 newElement->next = this; 61 LNode* newElement = new LNode(lp, this); 53 62 return newElement; 54 63 } 55 64 56 65 LNode* LNode::insert(poly* t, int* i, poly* p) { 57 LNode* newElement = new LNode(t,i,p); 58 newElement->next = this; 66 LNode* newElement = new LNode(t, i, p, this); 59 67 return newElement; 60 68 } … … 64 72 LNode* LNode::insertByLabel(LPoly* lp) { 65 73 if( lp->getTerm() <= this->data->getTerm() ) { 66 LNode* newElement = new LNode(lp); 67 newElement->next = this; 74 LNode* newElement = new LNode(lp, this); 68 75 return newElement; 69 76 } … … 72 79 while( NULL != temp->next ) { 73 80 if( lp->getTerm() <= temp->next->data->getTerm() ) { 74 LNode* newElement = new LNode(lp); 75 newElement->next = temp->next; 81 LNode* newElement = new LNode(lp, temp->next); 76 82 temp->next = newElement; 77 83 return this; … … 81 87 } 82 88 } 83 LNode* newElement = new LNode(lp );89 LNode* newElement = new LNode(lp, NULL); 84 90 temp->next = newElement; 85 newElement->next = NULL;86 91 return this; 87 92 } … … 105 110 106 111 // get the data from the LPoly saved in LNode 107 poly *LNode::getPoly() {112 poly LNode::getPoly() { 108 113 return data->getPoly(); 109 114 } 110 115 111 poly *LNode::getTerm() {116 poly LNode::getTerm() { 112 117 return data->getTerm(); 113 118 } 114 119 115 int *LNode::getIndex() {120 int LNode::getIndex() { 116 121 return data->getIndex(); 117 122 } … … 121 126 LNode* temp = new LNode(this); 122 127 while(NULL != temp) { 123 if(pComparePolys( *(temp->getPoly()),*p)) {128 if(pComparePolys(temp->getPoly(),*p)) { 124 129 return 1; 125 130 } … … 182 187 /* 183 188 ======================================= 184 functions working on the class PrevNode185 ======================================= 186 */ 187 188 PrevNode::PrevNode(LNode* l) {189 functions working on the class LTagNode 190 ======================================= 191 */ 192 193 LTagNode::LTagNode(LNode* l) { 189 194 data = l; 190 195 next = NULL; 191 196 } 192 197 193 PrevNode::~PrevNode() { 198 LTagNode::LTagNode(LNode* l, LTagNode* n) { 199 data = l; 200 next = n; 201 } 202 203 LTagNode::~LTagNode() { 194 204 delete next; 195 205 delete data; 196 206 } 197 207 198 PrevNode* PrevNode::append(LNode* l) { 199 PrevNode* new_element = new PrevNode(l); 200 next = new_element;201 return new _element;202 } 203 204 LNode* PrevNode::getLNode() {208 // declaration with first as parameter due to sorting of LTagList 209 LTagNode* LTagNode::insert(LNode* l) { 210 LTagNode* newElement = new LTagNode(l, this); 211 return newElement; 212 } 213 214 LNode* LTagNode::getLNode() { 205 215 return this->data; 206 216 } 207 217 208 LNode* PrevNode::getPrevLast(int i) { 209 int j; 210 PrevNode* temp = this; 211 for(j=1;j<=i-1;j++) { 212 temp = temp->next; 213 } 214 return temp->data; 215 } 216 217 /* 218 ======================================= 219 functions working on the class PrevList 220 ======================================= 221 */ 222 223 PrevList::PrevList(LNode* l) { 224 PrevNode* first = new PrevNode(l); 225 last = first; 226 } 227 228 void PrevList::append(LNode* l) { 229 last = last->append(l); 230 } 231 232 LNode* PrevList::getPrevLast(int i) { 233 switch(i) { 234 case 0: return NULL; 235 case 1: return first->getLNode(); 236 default: first->getPrevLast(i); 237 } 218 // NOTE: We insert at the beginning of the list and length = i-1, where i is the actual index. 219 // Thus given actual index i and idx being the index of the LPoly under investigation 220 // the element on position length-idx is the right one 221 LNode* LTagNode::get(int idx, int length) { 222 if(idx == 1) { 223 return NULL; 224 } 225 else { 226 int j; 227 LTagNode* temp = this; // last 228 for(j=1;j<=length-idx+1;j++) { 229 temp = temp->next; 230 } 231 return temp->data; 232 } 233 } 234 235 236 /* 237 ======================================= 238 functions working on the class LTagList 239 ======================================= 240 */ 241 242 LTagList::LTagList(LNode* l) { 243 LTagNode* first = new LTagNode(l); 244 length = 1; 245 } 246 247 // declaration with first as parameter in LTagNode due to sorting of LTagList 248 void LTagList::insert(LNode* l) { 249 first = first->insert(l); 250 length++; 251 } 252 253 LNode* LTagList::get(int idx) { 254 return first->get(idx, length); 238 255 } 239 256 … … 243 260 ==================================== 244 261 */ 262 263 CNode::CNode() { 264 data = NULL; 265 next = NULL; 266 } 245 267 246 268 CNode::CNode(CPair* c) { 247 269 data = c; 248 270 next = NULL; 271 } 272 273 CNode::CNode(CPair* c, CNode* n) { 274 data = c; 275 next = n; 249 276 } 250 277 … … 258 285 // working only with linked, but not doubly linked lists due to memory usage we have to check the 259 286 // insertion around the first element separately from the insertion around all other elements in the list 260 CNode* CNode::insert(CPair* c) { 261 if( c->getDeg() < this->data->getDeg() ) { // lower degree than the first list element 262 CNode* newElement = new CNode(c); 263 newElement->next = this; 287 CNode* CNode::insert(CPair* c, CNode* last) { 288 if(NULL == this->data) { 289 CNode* newElement = new CNode(c, this); 264 290 return newElement; 265 291 } 266 if( c->getDeg() == this->data->getDeg() ) { // same degree than the first list element267 if( c->getT1() <= this->data->getT1() ) {268 CNode* newElement = new CNode(c);269 newElement->next = this;292 else { 293 poly u1 = ppMult_qq(c->getT1(),c->getLp1Term()); 294 if( c->getDeg() < this->data->getDeg() ) { // lower degree than the first list element 295 CNode* newElement = new CNode(c, this); 270 296 return newElement; 271 297 } 272 else { 273 CNode* temp = this; 274 while( NULL != temp->next ) { 275 if( temp->next->data->getDeg() == c->getDeg() ) { 276 if( c->getT1() <= temp->next->data->getT1() ) { 277 temp = temp->next; 298 if( c->getDeg() == this->data->getDeg() ) { // same degree than the first list element 299 if(0 == pLmCmp(u1,ppMult_qq(this->data->getT1(), this->data->getLp1Term())) || 300 -1 == pLmCmp(u1,ppMult_qq(this->data->getT1(), this->data->getLp1Term()))) { 301 Print("Leck mich am Arsch: "); 302 pWrite(u1); 303 Print("Multi-Term in CritPairs Sortierung altes Element: "); 304 pWrite(ppMult_qq(this->data->getT1(),this->data->getLp1Term())); 305 CNode* newElement = new CNode(c, this); 306 return newElement; 307 } 308 else { 309 Print("Insert Deg\n"); 310 CNode* temp = this; 311 while( NULL != temp->next->data ) { 312 if(temp->next->data->getDeg() == c->getDeg() ) { 313 if(1 == pLmCmp(u1,ppMult_qq(temp->next->data->getT1(),temp->next->data->getLp1Term()))) { 314 temp = temp->next; 315 } 316 else { 317 CNode* newElement = new CNode(c, temp->next); 318 temp->next = newElement; 319 return this; 320 } 278 321 } 279 322 else { 280 CNode* newElement = new CNode(c); 281 newElement->next = temp->next; 323 CNode* newElement = new CNode(c, temp->next); 282 324 temp->next = newElement; 283 325 return this; 284 } 326 } 285 327 } 286 else { 287 CNode* newElement = new CNode(c); 288 newElement->next = temp->next; 328 CNode* newElement = new CNode(c, last); 329 temp->next = newElement; 330 return this; 331 } 332 } // outer if-clause 333 if( c->getDeg() > this->data->getDeg() ) { // greater degree than the first list element 334 CNode* temp = this; 335 while( NULL != temp->next->data ) { 336 if( c->getDeg() < temp->next->data->getDeg() ) { 337 CNode* newElement = new CNode(c, temp->next); 289 338 temp->next = newElement; 290 339 return this; 291 340 } 341 if( c->getDeg() == temp->next->data->getDeg() ) { 342 if(0 == pLmCmp(u1,ppMult_qq(temp->next->data->getT1(),temp->next->data->getLp1Term())) || 343 -1 == pLmCmp(u1,ppMult_qq(temp->next->data->getT1(),temp->next->data->getLp1Term()))) { 344 CNode* newElement = new CNode(c, temp->next); 345 temp->next = newElement; 346 return this; 347 } 348 else { 349 temp = temp->next; 350 while( NULL != temp->next->data ) { 351 if( temp->next->data->getDeg() == c->getDeg() ) { 352 if(1 == pLmCmp(u1,ppMult_qq(temp->next->data->getT1(), 353 temp->next->data->getLp1Term()))) { 354 temp = temp->next; 355 } 356 else { 357 CNode* newElement = new CNode(c, temp->next); 358 temp->next = newElement; 359 return this; 360 } 361 } 362 else { 363 CNode* newElement = new CNode(c, temp->next); 364 temp->next = newElement; 365 return this; 366 } 367 } 368 CNode* newElement = new CNode(c, last); 369 temp->next = newElement; 370 return this; 371 } 372 } 373 if( c->getDeg() > temp->next->data->getDeg() ) { 374 temp = temp->next; 375 } 292 376 } 293 CNode* newElement = new CNode(c); 294 newElement->next = NULL; 377 CNode* newElement = new CNode(c, last); 295 378 temp->next = newElement; 296 379 return this; 297 380 } 298 } // outer if-clause299 if( c->getDeg() > this->data->getDeg() ) { // greater degree than the first list element300 CNode* temp = this;301 while( NULL != temp->next ) {302 if( c->getDeg() < temp->next->data->getDeg() ) {303 CNode* newElement = new CNode(c);304 newElement->next = temp->next;305 temp->next = newElement;306 return this;307 }308 if( c->getDeg() == temp->next->data->getDeg() ) {309 if( c->getT1() <= temp->next->data->getT1() ) {310 CNode* newElement = new CNode(c);311 newElement->next = temp->next;312 temp->next = newElement;313 return this;314 }315 else {316 temp = temp->next;317 while( NULL != temp->next ) {318 if( temp->next->data->getDeg() == c->getDeg() ) {319 if( c->getT1() <= temp->next->data->getT1() ) {320 temp = temp->next;321 }322 else {323 CNode* newElement = new CNode(c);324 newElement->next = temp->next;325 temp->next = newElement;326 return this;327 }328 }329 else {330 CNode* newElement = new CNode(c);331 newElement->next = temp->next;332 temp->next = newElement;333 return this;334 }335 }336 CNode* newElement = new CNode(c);337 newElement->next = NULL;338 temp->next = newElement;339 return this;340 }341 }342 if( c->getDeg() > temp->next->data->getDeg() ) {343 temp = temp->next;344 }345 }346 CNode* newElement = new CNode(c);347 newElement->next = NULL;348 temp->next = newElement;349 return this;350 381 } 351 382 } … … 354 385 CNode* CNode::getMinDeg() { 355 386 CNode* temp = this; 356 while( NULL != temp ) {357 if( temp->next->data->getDeg() == this->data->getDeg() ) {387 while( NULL != temp->data ) { 388 while( temp->next->data->getDeg() == this->data->getDeg() ) { 358 389 temp = temp->next; 359 390 } … … 365 396 } 366 397 398 poly CNode::getLp1Poly() { 399 return this->data->getLp1Poly(); 400 } 401 402 poly CNode::getLp2Poly() { 403 return this->data->getLp2Poly(); 404 } 405 406 poly CNode::getLp1Term() { 407 return this->data->getLp1Term(); 408 } 409 410 poly CNode::getLp2Term() { 411 return this->data->getLp2Term(); 412 } 413 414 int CNode::getLp1Index() { 415 return this->data->getLp1Index(); 416 } 417 418 int CNode::getLp2Index() { 419 return this->data->getLp2Index(); 420 } 421 422 poly CNode::getT1() { 423 return this->data->getT1(); 424 } 425 426 poly CNode::getT2() { 427 return this->data->getT2(); 428 } 429 430 // for debugging 431 void CNode::print() { 432 CNode* temp = this; 433 Print("List of critical pairs:\n"); 434 while(NULL != temp->data) { 435 Print("Leck mich am Arsch: "); 436 Print("Index: %d\n",temp->getLp1Index()); 437 Print("T1: "); 438 pWrite(temp->getT1()); 439 Print("Lp1 Term: "); 440 pWrite(temp->getLp1Term()); 441 Print("%d\n",temp->getLp2Index()); 442 pWrite(temp->getT2()); 443 pWrite(temp->getLp2Term()); 444 Print("\n"); 445 temp = temp->next; 446 } 447 } 367 448 368 449 /* … … 371 452 ==================================== 372 453 */ 454 // for initialization of CLists, last element alwas has data=NULL and next=NULL 455 CList::CList() { 456 first = new CNode(); 457 last = first; 458 } 459 373 460 CList::CList(CPair* c) { 374 first = new CNode(c); 461 first = new CNode(c); 462 last = first; 375 463 } 376 464 … … 382 470 // note: as all critical pairs have the same index here, the second sort is done on the terms of the labels 383 471 void CList::insert(CPair* c) { 384 first = first->insert(c );472 first = first->insert(c, last); 385 473 } 386 474 … … 393 481 } 394 482 483 void CList::print() { 484 first->print(); 485 } 395 486 396 487 /* … … 399 490 ==================================== 400 491 */ 492 RNode::RNode() { 493 data = NULL; 494 next = NULL; 495 } 496 401 497 RNode::RNode(Rule* r) { 402 498 data = r; … … 415 511 } 416 512 513 RNode* RNode::getNext() { 514 return next; 515 } 516 517 Rule* RNode::getRule() { 518 return data; 519 } 520 521 int RNode::getRuleIndex() { 522 return data->getIndex(); 523 } 524 525 poly RNode::getRuleTerm() { 526 return data->getTerm(); 527 } 528 417 529 /* 418 530 ==================================== … … 420 532 ==================================== 421 533 */ 534 RList::RList() { 535 first = new RNode(); 536 } 537 422 538 RList::RList(Rule* r) { 423 539 first = new RNode(r); … … 427 543 first = first->insert(r); 428 544 } 545 546 RNode* RList::getFirst() { 547 return first; 548 } 549 550 Rule* RList::getRule() { 551 return this->getRule(); 552 } 553 554 /* 555 ======================================= 556 functions working on the class RTagNode 557 ======================================= 558 */ 559 560 RTagNode::RTagNode(RNode* r) { 561 data = r; 562 next = NULL; 563 } 564 565 RTagNode::RTagNode(RNode* r, RTagNode* n) { 566 data = r; 567 next = n; 568 } 569 570 RTagNode::~RTagNode() { 571 delete next; 572 delete data; 573 } 574 575 // declaration with first as parameter due to sorting of LTagList 576 RTagNode* RTagNode::insert(RNode* r) { 577 Print("Hier1\n"); 578 RTagNode* newElement = new RTagNode(r, this); 579 Print("Hier2\n"); 580 return newElement; 581 } 582 583 RNode* RTagNode::getRNode() { 584 return this->data; 585 } 586 587 // NOTE: We insert at the beginning of the list and length = i-1, where i is the actual index. 588 // Thus given actual index i and idx being the index of the LPoly under investigation 589 // the element on position length-idx+1 is the right one 590 RNode* RTagNode::get(int idx, int length) { 591 if(idx == 1) { 592 return NULL; 593 } 594 else { 595 int j; 596 RTagNode* temp = this; 597 for(j=1;j<=length-idx+1;j++) { 598 temp = temp->next; 599 } 600 return temp->data; 601 } 602 } 603 604 605 /* 606 ======================================= 607 functions working on the class LTagList 608 ======================================= 609 */ 610 611 RTagList::RTagList(RNode* r) { 612 RTagNode* first = new RTagNode(r); 613 length = 1; 614 } 615 616 // declaration with first as parameter in LTagNode due to sorting of LTagList 617 void RTagList::insert(RNode* r) { 618 first = first->insert(r); 619 length++; 620 } 621 622 RNode* RTagList::get(int idx) { 623 return first->get(idx, length); 624 } 429 625 #endif -
kernel/f5lists.h
r5376a6 r66e7b5 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: f5lists.h,v 1. 1 2009-01-27 10:38:08 SingularExp $ */4 /* $Id: f5lists.h,v 1.2 2009-01-29 17:59:30 ederc Exp $ */ 5 5 /* 6 6 * ABSTRACT: list interface … … 20 20 class LNode; 21 21 class LList; 22 class PrevNode;23 class PrevList;22 class LTagNode; 23 class LTagList; 24 24 class CNode; 25 25 class CList; 26 26 class RList; 27 27 class RNode; 28 29 /* 30 ======================================= 31 LNode class (nodes for lists of LPolys) 28 class RTagNode; 29 class RTagList; 30 31 32 /* 33 ======================================= 34 class LNode (nodes for lists of LPolys) 32 35 ======================================= 33 36 */ … … 39 42 // generating new list elements from the labeled / classical polynomial view 40 43 LNode(LPoly* lp); 44 LNode(LPoly* lp, LNode* l); 41 45 LNode(poly* t, int* i, poly* p); 46 LNode(poly* t, int* i, poly* p, LNode* l); 42 47 LNode(LNode* ln); 43 48 ~LNode(); … … 56 61 LPoly* getLPoly(); 57 62 // get the data from the LPoly saved in LNode 58 poly *getPoly();59 poly *getTerm();60 int *getIndex();63 poly getPoly(); 64 poly getTerm(); 65 int getIndex(); 61 66 // test if for any list element the polynomial part of the data is equal to *p 62 67 bool polyTest(poly* p); … … 89 94 90 95 /* 91 ============================================= 92 PrevNode class (nodes for lists of gPrevLast)93 ============================================= 94 */ 95 class PrevNode {96 ============================================== 97 class LtagNode (nodes for lists of LPoly tags) 98 ============================================== 99 */ 100 class LTagNode { 96 101 private: 97 102 LNode* data; 98 PrevNode* next; 99 public: 100 PrevNode(LNode* l); 101 ~PrevNode(); 102 PrevNode* append(LNode* l); 103 LTagNode* next; 104 public: 105 LTagNode(LNode* l); 106 LTagNode(LNode* l, LTagNode* n); 107 ~LTagNode(); 108 // declaration with first as parameter due to sorting of LTagList 109 LTagNode* insert(LNode* l); 103 110 LNode* getLNode(); 104 LNode* getPrevLast(int i); 105 }; 106 107 108 /* 109 ==================================================== 110 class PrevList(lists of last node elements in gPrev) 111 ==================================================== 112 */ 113 class PrevList { 114 private: 115 PrevNode* first; 116 PrevNode* last; 117 public: 118 PrevList(LNode* l); 119 ~PrevList(); 120 void append(LNode* l); 121 LNode* getPrevLast(int i); 111 LNode* get(int i, int length); 112 }; 113 114 115 /* 116 ========================================================================= 117 class LTagList(lists of LPoly tags, i.e. first elements of a given index) 118 ========================================================================= 119 */ 120 class LTagList { 121 private: 122 LTagNode* first; 123 int length; 124 public: 125 LTagList(LNode* l); 126 ~LTagList(); 127 // declaration with first as parameter in LTagNode due to sorting of LTagList 128 void insert(LNode* l); 129 LNode* get(int idx); 122 130 }; 123 131 … … 133 141 CNode* next; 134 142 public: 143 CNode(); 135 144 CNode(CPair* c); 145 CNode(CPair* c, CNode* n); 136 146 ~CNode(); 137 CNode* insert(CPair* c );147 CNode* insert(CPair* c, CNode* last); 138 148 CNode* getMinDeg(); 139 //CNode* getLPoly() const; 149 poly getLp1Poly(); 150 poly getLp2Poly(); 151 poly getLp1Term(); 152 poly getLp2Term(); 153 poly getT1(); 154 poly getT2(); 155 int getLp1Index(); 156 int getLp2Index(); 157 void print(); 140 158 }; 141 159 … … 149 167 private: 150 168 CNode* first; 151 public: 169 // last alway has data=NULL and next=NULL, for initialization purposes used 170 CNode* last; 171 public: 172 // for initialization of CLists, last element alwas has data=NULL and next=NULL 173 CList(); 152 174 CList(CPair* c); 153 175 ~CList(); 154 176 void insert(CPair* c); 155 177 CNode* getMinDeg(); 156 178 void print(); 157 179 }; 158 180 … … 168 190 RNode* next; 169 191 public: 192 RNode(); 170 193 RNode(Rule* r); 171 194 ~RNode(); 172 195 RNode* insert(Rule* r); 196 RNode* getNext(); 197 Rule* getRule(); 198 int getRuleIndex(); 199 poly getRuleTerm(); 173 200 }; 174 201 … … 181 208 private: 182 209 RNode* first; 183 public: 210 // last alway has data=NULL and next=NULL, for initialization purposes used 211 RNode* last; 212 public: 213 RList(); 184 214 RList(Rule* r); 185 215 ~RList(); 186 216 void insert(Rule* r); 217 RNode* getFirst(); 218 Rule* getRule(); 219 }; 220 221 222 223 /* 224 ============================================= 225 class RtagNode (nodes for lists of Rule tags) 226 ============================================= 227 */ 228 class RTagNode { 229 private: 230 RNode* data; 231 RTagNode* next; 232 public: 233 RTagNode(RNode* r); 234 RTagNode(RNode* r, RTagNode* n); 235 ~RTagNode(); 236 // declaration with first as parameter due to sorting of LTagList 237 RTagNode* insert(RNode* r); 238 RNode* getRNode(); 239 RNode* get(int idx, int length); 240 }; 241 242 243 /* 244 ======================================================================== 245 class RTagList(lists of Rule tags, i.e. first elements of a given index) 246 ======================================================================== 247 */ 248 class RTagList { 249 private: 250 RTagNode* first; 251 int length; 252 public: 253 RTagList(RNode* r); 254 ~RTagList(); 255 // declaration with first as parameter in LTagNode due to sorting of LTagList 256 void insert(RNode* r); 257 RNode* get(int idx); 187 258 }; 188 259 #endif -
kernel/lpolynomial.cc
r5376a6 r66e7b5 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: lpolynomial.cc,v 1. 7 2009-01-28 17:21:07 SingularExp $ */4 /* $Id: lpolynomial.cc,v 1.8 2009-01-29 17:59:30 ederc Exp $ */ 5 5 /* 6 6 * ABSTRACT: lpolynomial definition … … 50 50 } 51 51 52 poly *LPoly::getPoly() {53 return &polynomial;52 poly LPoly::getPoly() { 53 return polynomial; 54 54 } 55 55 56 poly *LPoly::getTerm() {57 return &term;56 poly LPoly::getTerm() { 57 return term; 58 58 } 59 59 60 int *LPoly::getIndex() {61 return &index;60 int LPoly::getIndex() { 61 return index; 62 62 } 63 63 … … 82 82 */ 83 83 CPair::CPair(long degree, poly term1, LPoly* lpoly1, poly term2, LPoly* lpoly2) { 84 deg = degree; 85 t1 = term1; 86 lp1 = lpoly1; 87 t2 = term2; 88 lp2 = lpoly2; 84 deg = degree; 85 t1 = term1; 86 lp1 = lpoly1; 87 t2 = term2; 88 lp2 = lpoly2; 89 lastRuleTested = NULL; 89 90 } 90 91 … … 102 103 103 104 poly CPair::getLp1Poly() { 104 return *(lp1->getPoly());105 return lp1->getPoly(); 105 106 } 106 107 107 108 poly CPair::getLp2Poly() { 108 return *(lp2->getPoly());109 return lp2->getPoly(); 109 110 } 110 111 111 112 poly CPair::getLp1Term() { 112 return *(lp1->getTerm());113 return lp1->getTerm(); 113 114 } 114 115 115 116 poly CPair::getLp2Term() { 116 return *(lp2->getTerm());117 return lp2->getTerm(); 117 118 } 118 119 119 120 int CPair::getLp1Index() { 120 return *(lp1->getIndex());121 return lp1->getIndex(); 121 122 } 122 123 123 124 124 int CPair::getLp2Index() { 125 return *(lp2->getIndex());125 return lp2->getIndex(); 126 126 } 127 127 128 Rule* CPair::getLastRuleTested() { 129 return lastRuleTested; 130 } 128 131 129 132 /* -
kernel/lpolynomial.h
r5376a6 r66e7b5 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: lpolynomial.h,v 1. 6 2009-01-25 17:13:06ederc Exp $ */4 /* $Id: lpolynomial.h,v 1.7 2009-01-29 17:59:30 ederc Exp $ */ 5 5 /* 6 6 * ABSTRACT: labeled polynomial interface … … 8 8 #ifndef LPOLYNOMIAL_HEADER 9 9 #define LPOLYNOMIAL_HEADER 10 11 10 #ifdef HAVE_F5 12 11 /* … … 36 35 LPoly(poly*t,int* i,poly* p); 37 36 void setPoly(poly* p); 38 poly *getPoly();37 poly getPoly(); 39 38 void setTerm(poly* t); 40 poly *getTerm();39 poly getTerm(); 41 40 void setIndex(int* i); 42 int *getIndex();41 int getIndex(); 43 42 void setDel(bool b); 44 43 bool getDel() const; … … 46 45 LPoly* get(); 47 46 }; 48 49 50 /*51 ===================================52 structure of labeled critical pairs53 ===================================54 */55 class CPair {56 private:57 long deg; // total degree of the critical pair58 poly t1; // first term for label59 LPoly* lp1; // first labeled poly60 poly t2; // second term for label61 LPoly* lp2; // second labeled poly62 public:63 CPair(long degree, poly term1, LPoly* lpoly1, poly term2, LPoly* lpoly2);64 long getDeg();65 poly getT1();66 poly getLp1Poly();67 poly getLp1Term();68 int getLp1Index();69 poly getT2();70 poly getLp2Poly();71 poly getLp2Term();72 int getLp2Index();73 };74 75 47 76 48 /* … … 88 60 poly getTerm(); 89 61 }; 62 63 64 /* 65 =================================== 66 structure of labeled critical pairs 67 =================================== 68 */ 69 class CPair { 70 private: 71 long deg; // total degree of the critical pair 72 poly t1; // first term for label 73 LPoly* lp1; // first labeled poly 74 poly t2; // second term for label 75 LPoly* lp2; // second labeled poly 76 Rule* lastRuleTested; // already tested by rules up to lastRuleTested 77 public: 78 CPair(long degree, poly term1, LPoly* lpoly1, poly term2, LPoly* lpoly2); 79 long getDeg(); 80 poly getT1(); 81 poly getLp1Poly(); 82 poly getLp1Term(); 83 int getLp1Index(); 84 poly getT2(); 85 poly getLp2Poly(); 86 poly getLp2Term(); 87 int getLp2Index(); 88 Rule* getLastRuleTested(); 89 }; 90 90 91 #endif 91 92 #endif
Note: See TracChangeset
for help on using the changeset viewer.