Changeset 9bb97e in git
- Timestamp:
- Feb 6, 2009, 9:12:35 PM (14 years ago)
- Branches:
- (u'spielwiese', '0d6b7fcd9813a1ca1ed4220cfa2b104b97a0a003')
- Children:
- fcb80223d452f79f3b3e1a62b71d291a5fc64943
- Parents:
- b3e45f80f34104e744829011d4460dcee8e1e365
- Location:
- kernel
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/f5data.cc
rb3e45f r9bb97e 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: f5data.cc,v 1. 2 2009-02-03 20:55:43ederc Exp $ */4 /* $Id: f5data.cc,v 1.3 2009-02-06 20:12:35 ederc Exp $ */ 5 5 /* 6 6 * ABSTRACT: lpolynomial definition … … 30 30 ================================================================ 31 31 */ 32 LPoly::LPoly(poly * t,int* i,poly* p) {33 set(t,i,p );32 LPoly::LPoly(poly t,int i,poly p,bool d) { 33 set(t,i,p,d); 34 34 } 35 35 36 void LPoly::setPoly(poly *p) {37 polynomial = *p;36 void LPoly::setPoly(poly p) { 37 polynomial = p; 38 38 } 39 39 40 void LPoly::setTerm(poly *t) {41 term = *t;40 void LPoly::setTerm(poly t) { 41 term = t; 42 42 } 43 43 44 void LPoly::setIndex(int *i) {45 index = *i;44 void LPoly::setIndex(int i) { 45 index = i; 46 46 } 47 47 … … 66 66 } 67 67 68 void LPoly::set(poly * t, int* i, poly* p) {68 void LPoly::set(poly t, int i, poly p, bool d) { 69 69 this->setTerm(t); 70 70 this->setIndex(i); 71 71 this->setPoly(p); 72 this->setDel(d); 72 73 } 73 74 … … 98 99 } 99 100 101 poly* CPair::getAdT1() { 102 return &t1; 103 } 104 105 poly* CPair::getAdT2() { 106 return &t2; 107 } 108 100 109 poly CPair::getT2() { 101 110 return t2; 111 } 112 113 LPoly* CPair::getAdLp1() { 114 return lp1; 115 } 116 117 LPoly* CPair::getAdLp2() { 118 return lp2; 102 119 } 103 120 … … 135 152 =================================== 136 153 */ 137 Rule::Rule(int * i, poly* t) {154 Rule::Rule(int i, poly t, LPoly* l) { 138 155 index = i; 139 156 term = t; 157 origin = l; 140 158 } 141 159 142 160 int Rule::getIndex() { 143 return *index;161 return index; 144 162 } 145 163 146 164 poly Rule::getTerm() { 147 return *term;165 return term; 148 166 } 149 167 -
kernel/f5data.h
rb3e45f r9bb97e 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: f5data.h,v 1. 2 2009-02-03 20:55:43ederc Exp $ */4 /* $Id: f5data.h,v 1.3 2009-02-06 20:12:35 ederc Exp $ */ 5 5 /* 6 6 * ABSTRACT: labeled polynomial interface … … 33 33 bool del; //for deletion in TopReduction Subalgorithm 34 34 public: 35 LPoly(poly *t,int* i,poly* p);36 void setPoly(poly *p);35 LPoly(poly t, int i, poly p, bool d = false); 36 void setPoly(poly p); 37 37 poly getPoly(); 38 void setTerm(poly *t);38 void setTerm(poly t); 39 39 poly getTerm(); 40 void setIndex(int *i);40 void setIndex(int i); 41 41 int getIndex(); 42 42 void setDel(bool b); 43 43 bool getDel() const; 44 void set(poly * t, int* i, poly* p);44 void set(poly t, int i, poly p, bool d); 45 45 LPoly* get(); 46 46 }; … … 63 63 long getDeg(); 64 64 poly getT1(); 65 poly* getAdT1(); 66 LPoly* getAdLp1(); 65 67 poly getLp1Poly(); 66 68 poly getLp1Term(); 67 69 int getLp1Index(); 68 70 poly getT2(); 71 poly* getAdT2(); 72 LPoly* getAdLp2(); 69 73 poly getLp2Poly(); 70 74 poly getLp2Term(); … … 81 85 class Rule { 82 86 private: 83 int *index; // index of the labeled polynomial the rule comes from84 poly *term; // term of the labeled polynomial the rule comes from87 int index; // index of the labeled polynomial the rule comes from 88 poly term; // term of the labeled polynomial the rule comes from 85 89 LPoly* origin; // pointer of the LPoly which generated this rule (needed in criterion2()) 86 90 public: 87 Rule(int * i, poly* term);91 Rule(int i, poly term, LPoly* l); 88 92 int getIndex(); 89 93 poly getTerm(); -
kernel/f5gb.cc
rb3e45f r9bb97e 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: f5gb.cc,v 1.2 2 2009-02-04 19:27:11ederc Exp $ */4 /* $Id: f5gb.cc,v 1.23 2009-02-06 20:12:35 ederc Exp $ */ 5 5 /* 6 6 * ABSTRACT: f5gb interface … … 26 26 27 27 28 28 29 /* 29 30 ==================================================================== … … 61 62 62 63 64 63 65 /* 64 66 ================================================== … … 67 69 ================================================== 68 70 */ 69 LList* F5inc(int* i, poly* f_i, LList* gPrev, poly* ONE) { 71 LList* F5inc(int i, poly f_i, LList* gPrev, ideal gbPrev, poly ONE, int* reductionsToZero) { 72 int j; 70 73 // tag the first element of index i-1 for criterion 1 71 74 LTagList* lTag = new LTagList(gPrev->getFirst()); … … 73 76 RTagList* rTag = new RTagList(); 74 77 gPrev->insert(ONE,i,f_i); 75 CList* critPairs = new CList(); 76 critPairs = criticalPair(gPrev, critPairs, lTag, rTag); 77 78 Print("1st gPrev: "); 79 pWrite(gPrev->getFirst()->getPoly()); 80 Print("2nd gPrev: "); 81 pWrite(gPrev->getFirst()->getNext()->getPoly()); 82 CList* critPairs = new CList(); 83 RList* rules = new RList(); 84 CNode* critPairsMinDeg = new CNode(); 85 LNode* sPolys = new LNode(); 86 // computation of critical pairs with checking of criterion 1 and criterion 2 87 critPairs = criticalPair(gPrev, critPairs, lTag, rTag); 88 LList* sPolyList = new LList(); 89 // labeled polynomials which have passed reduction() and have to be added to list gPrev 90 LList* completed = new LList(); 91 // the reduced labeled polynomials which are returned from subalgorithm reduction() 92 LNode* reducedLPolys = new LNode(); 93 // while there are critical pairs to be further checked and deleted/computed 94 while(NULL != critPairs->getFirst()->getData()) { 95 // critPairs->getMinDeg() deletes the first elements of minimal degree from 96 // critPairs, thus the while loop is not infinite. 97 critPairsMinDeg = critPairs->getMinDeg(); 98 // adds all to be reduced S-polynomials in the list sPolyList and adds 99 // the corresponding rules to the list rules 100 // NOTE: inside there is a second check of criterion 2 if new rules are 101 // added 102 computeSPols(critPairsMinDeg,rTag,rules,sPolyList,reductionsToZero); 103 104 reducedLPolys = reduction(sPolyList, completed, gbPrev, reductionsToZero); 105 } 78 106 return gPrev; 79 107 } 108 80 109 81 110 … … 91 120 number nOne = nInit(1); 92 121 LNode* first = gPrev->getFirst(); 93 LNode* l = gPrev->getFirst()->getNext();122 LNode* l = first->getNext(); 94 123 poly* u1 = new poly(pInit()); 95 124 poly* u2 = new poly(pInit()); … … 110 139 if(!criterion1(u1, first, lTag) && !criterion1(u2, l, lTag) && 111 140 !criterion2(u1, first, rTag) && !criterion2(u2, l, rTag)) { 112 Print("Criteria passed\n");113 141 // if they pass the test, add them to CList critPairs, having the LPoly with greater 114 142 // label as first element in the CPair … … 126 154 } 127 155 else { 128 Print("Criteria not passed\n");129 156 } 130 157 … … 135 162 l = l->getNext(); 136 163 } 137 Print("ENDE CRITPAIRS\n");138 164 return critPairs; 139 165 } 166 167 140 168 141 169 /* … … 151 179 while(NULL != testNode) { 152 180 if(pLmDivisibleByNoComp(pHead(testNode->getPoly()),u1)) { 181 Print("Criterion 1 NOT passed!\n"); 153 182 return true; 154 183 } … … 157 186 return false; 158 187 } 188 189 159 190 160 191 /* … … 169 200 poly u1 = ppMult_qq(*t,l->getTerm()); 170 201 // first element added to rTag was NULL, check for this 171 Print("Hier1\n");172 202 while(NULL != testNode && testNode->getRule()->getOrigin() != l->getLPoly()) { 173 Print("Hier2\n");174 203 if(pLmDivisibleByNoComp(ppMult_qq(*t,l->getTerm()),testNode->getRuleTerm())) { 204 Print("Criterion 2 NOT passed!\n"); 175 205 return true; 176 206 } … … 180 210 } 181 211 182 /* 183 ========================================================================================================== 184 Criterion 2, i.e. Rewritten Criterion, for its second call in sPols(), with added lastRuleTested parameter 185 ========================================================================================================== 186 */ 187 bool criterion2(poly* t, LNode* l, RTagList* rTag, Rule* lastRuleTested) { 212 213 214 /* 215 ================================================================================================================= 216 Criterion 2, i.e. Rewritten Criterion, for its second call in computeSPols(), with added lastRuleTested parameter 217 ================================================================================================================= 218 */ 219 bool criterion2(poly* t, LPoly* l, RTagList* rTag, Rule* lastRuleTested) { 188 220 // start at the previously added element to gPrev, as all other elements will have the same index for sure 189 221 RNode* testNode = rTag->getFirst(); … … 191 223 poly u1 = ppMult_qq(*t,l->getTerm()); 192 224 // first element added to rTag was NULL, check for this 193 Print("Hier1\n"); 194 while(NULL != testNode && testNode->getRule()->getOrigin() != l->getLPoly()) { 195 Print("Hier2\n"); 225 while(NULL != testNode && testNode->getRule() != lastRuleTested) { 196 226 if(pLmDivisibleByNoComp(ppMult_qq(*t,l->getTerm()),testNode->getRuleTerm())) { 227 Print("Criterion 2 NOT passed!\n"); 197 228 return true; 198 229 } … … 201 232 return false; 202 233 } 234 235 236 237 /* 238 ================================== 239 Computation of S-Polynomials in F5 240 ================================== 241 */ 242 void computeSPols(CNode* first, RTagList* rTag, RList* rules, LList* sPolyList, int* reductionsToZero) { 243 CNode* temp = first; 244 poly zero = pInit(); 245 while(NULL != temp->getData()) { 246 // only if a new rule was added since the last test in subalgorithm criticalPair() 247 if(rules->getFirst() != rTag->getFirst()) { 248 Print("IN SPOLS => NEW RULES AVAILABLE\n"); 249 if(!criterion2(temp->getAdT1(),temp->getAdLp1(),rTag,temp->getLastRuleTested())) { 250 // the second component is tested only when it has the actual index, otherwise there is 251 // no new rule to test since the last test in subalgorithm criticalPair() 252 if(temp->getLp2Index() == temp->getLp1Index()) { 253 if(!criterion2(temp->getAdT2(),temp->getAdLp2(),rTag,temp->getLastRuleTested())) { 254 // computation of S-polynomial 255 poly sp = pInit(); 256 sp = pSub(ppMult_qq(temp->getT1(),temp->getLp1Poly()), 257 ppMult_qq(temp->getT2(),temp->getLp2Poly())); 258 Print("BEGIN SPOLY\n====================\n"); 259 pWrite(sp); 260 Print("END SPOLY\n====================\n"); 261 if(!pCmp(sp,zero)) { 262 // as rules consist only of pointers we need to save the labeled 263 // S-polynomial also of a zero S-polynomial 264 //zeroList->insert(temp->getAdT1(),temp->getLp1Index(),&sp); 265 // origin of rule can be set NULL as the labeled polynomial 266 // will never be used again as it is zero => no problems with 267 // further criterion2() tests and termination conditions 268 *reductionsToZero++; 269 rules->insert(temp->getLp1Index(),temp->getT1(),NULL); 270 } 271 else { 272 sPolyList->insert(temp->getT1(),temp->getLp1Index(),sp); 273 rules->insert(temp->getLp1Index(),temp->getT1(),sPolyList->getFirst()->getLPoly()); 274 } 275 // data is saved in sPolyList or zero => delete sp 276 pDelete(&sp); 277 } 278 } 279 else { // temp->getLp2Index() < temp->getLp1Index() 280 // computation of S-polynomial 281 poly sp = pInit(); 282 sp = pSub(ppMult_qq(temp->getT1(),temp->getLp1Poly()), 283 ppMult_qq(temp->getT2(),temp->getLp2Poly())); 284 Print("BEGIN SPOLY\n====================\n"); 285 pWrite(sp); 286 Print("END SPOLY\n====================\n"); 287 if(!pCmp(sp,zero)) { 288 // zeroList->insert(temp->getAdT1(),temp->getLp1Index(),&sp); 289 // origin of rule can be set NULL as the labeled polynomial 290 // will never be used again as it is zero => no problems with 291 // further criterion2() tests and termination conditions 292 *reductionsToZero++; 293 rules->insert(temp->getLp1Index(),temp->getT1(),NULL); 294 } 295 else { 296 sPolyList->insert(temp->getT1(),temp->getLp1Index(),sp); 297 rules->insert(temp->getLp1Index(),temp->getT1(),sPolyList->getFirst()->getLPoly()); 298 } 299 // data is saved in sPolyList or zero => delete sp 300 pDelete(&sp); 301 } 302 } 303 } 304 temp = temp->getNext(); 305 } 306 // these critical pairs can be deleted now as they are either useless for further computations or 307 // already saved as an S-polynomial to be reduced in the following 308 delete first; 309 } 310 311 312 313 /* 314 ======================================================================== 315 reduction including subalgorithm topReduction() using Faugere's criteria 316 ======================================================================== 317 */ 318 LNode* reduction(LList* sPolyList, LList* completed, ideal gbPrev, int* reductionsToZero) { 319 poly zero = pInit(); 320 // compute only if there are any S-polynomials to be reduced 321 if(NULL != sPolyList->getFirst()->getLPoly()) { 322 LNode* temp = sPolyList->getFirst(); 323 while(NULL != temp->getLPoly()) { 324 temp->setPoly(kNF(gbPrev,currQuotient,temp->getPoly())); 325 Print("Nach NORMAL FORM: "); 326 pWrite(temp->getPoly()); 327 // test if temp->getPoly() is zero polynomial 328 if(!pCmp(temp->getPoly(),zero)) { 329 *reductionsToZero++; 330 // TODO: sPolyList -> delete first element of list as it is zero and done 331 } 332 //completed = topReduction(); 333 // in topReduction() the investigated first element of sPolyList will be deleted after its 334 // reduction has finished => the next to be investigated element is the newly first element 335 // in sPolyList => the while loop is finite 336 // first possible after implementation of topReduction(): temp = sPolyList->getFirst(); 337 temp = temp->getNext(); 338 } 339 } 340 return NULL; 341 } 342 343 344 345 /* 346 ===================================================================================== 347 top reduction in F5, i.e. reduction of a given S-polynomial by labeled polynomials of 348 the same index whereas the labels are taken into account 349 ===================================================================================== 350 */ 351 LNode* topReduction(LNode* l, LList* gPrev, LList* completed) { 352 LPoly* red = findReductor(l, gPrev, completed); 353 return NULL; 354 } 355 356 357 358 /* 359 ===================================================================== 360 subalgorithm to find a possible reductor for the labeled polynomial l 361 ===================================================================== 362 */ 363 LPoly* findReductor(LNode* l, LList* gPrev, LList* completed) { 364 return NULL; 365 } 366 367 203 368 204 369 /* … … 209 374 ideal F5main(ideal id, ring r) { 210 375 int i,j; 376 int* reductionsToZero = new int; 377 *reductionsToZero = 0; 211 378 // 1 polynomial for defining initial labels & further tests 212 379 poly ONE = pOne(); 213 // list of rules214 RList* rules = new RList();215 380 i = 1; 216 LList* gPrev = new LList( &ONE, &i, &id->m[0]); 217 poly* lcm = new poly; 381 poly* lcm = new poly; 218 382 // initialization for usage in pLcm() 219 383 *lcm = pOne(); … … 242 406 qsortDegree(&id->m[0],&id->m[IDELEMS(id)-1]); 243 407 idShow(id); 408 LList* gPrev = new LList(ONE, i, id->m[0]); 409 pWrite(id->m[0]); 244 410 poly p = pHead(id->m[0]); 245 411 pWrite(p); 246 412 poly q = pHead(id->m[2]); 247 413 pWrite(q); 414 415 // computing the groebner basis of the elements of index < actual index 416 Print("Laenge der bisherigen Groebner Basis: %d\n",gPrev->getLength()); 417 ideal gbPrev = idInit(gPrev->getLength(),1); 418 // initializing the groebner basis of elements of index < actual index 419 gbPrev->m[0] = gPrev->getFirst()->getPoly(); 420 idShow(gbPrev); 421 idShow(currQuotient); 422 248 423 for(i=2; i<=IDELEMS(id); i++) { 249 gPrev = F5inc( &i, &id->m[i-1], gPrev, &ONE);424 gPrev = F5inc(i, id->m[i-1], gPrev, gbPrev, ONE, reductionsToZero); 250 425 Print("JA\n"); 426 //TODO: idAdd for computing gbPrev with the actual index! 251 427 } 252 428 // only for debugging … … 263 439 //} 264 440 //} 441 Print("\n\nNumber of zero-reductions: %d\n",*reductionsToZero); 265 442 return(id); 266 443 -
kernel/f5gb.h
rb3e45f r9bb97e 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: f5gb.h,v 1.2 1 2009-02-04 19:27:12ederc Exp $ */4 /* $Id: f5gb.h,v 1.22 2009-02-06 20:12:35 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, ideal gbPrev, poly ONE, int* reductionToZero); 38 38 39 39 /* … … 65 65 ========================================================================================================== 66 66 */ 67 bool criterion2(poly* t, LNode* l, RTagList* rTag, Rule* lastRuleTested); 68 67 bool criterion2(poly* t, LPoly* l, RTagList* rTag, Rule* lastRuleTested); 68 69 /* 70 ================================== 71 Computation of S-Polynomials in F5 72 ================================== 73 */ 74 void computeSPols(CNode* first, RTagList* rTag, RList* rules, LList* sPolyList, int* reductionsToZero); 75 76 /* 77 ======================================================================== 78 reduction including subalgorithm topReduction() using Faugere's criteria 79 ======================================================================== 80 */ 81 LNode* reduction(LList* sPolyList, LList* completed, ideal gbPrev, int* reductionsToZero); 82 83 /* 84 ===================================================================================== 85 top reduction in F5, i.e. reduction of a given S-polynomial by labeled polynomials of 86 the same index whereas the labels are taken into account 87 ===================================================================================== 88 */ 89 LNode* topReduction(LNode* l, LList* gPrev, LList* completed); 90 91 /* 92 ===================================================================== 93 subalgorithm to find a possible reductor for the labeled polynomial l 94 ===================================================================== 95 */ 96 LPoly* findReductor(LNode* l, LList* gPrev, LList* completed); 97 69 98 /* 70 99 ====================================== -
kernel/f5lists.cc
rb3e45f r9bb97e 26 26 27 27 // generating new list elements (labeled / classical polynomial / LNode view) 28 LNode::LNode(LPoly* lp) { 28 LNode::LNode() { 29 data = NULL; 30 next = NULL; 31 } 32 LNode::LNode(LPoly* lp) { 29 33 data = lp; 30 34 next = NULL; … … 35 39 next = l; 36 40 } 37 LNode::LNode(poly * t, int* i, poly*p) {41 LNode::LNode(poly t, int i, poly p) { 38 42 LPoly* lp = new LPoly(t,i,p); 39 43 data = lp; … … 41 45 } 42 46 43 LNode::LNode(poly * t, int* i, poly*p, LNode* l) {47 LNode::LNode(poly t, int i, poly p, LNode* l) { 44 48 LPoly* lp = new LPoly(t,i,p); 45 49 data = lp; … … 63 67 } 64 68 65 LNode* LNode::insert(poly * t, int* i, poly*p) {69 LNode* LNode::insert(poly t, int i, poly p) { 66 70 LNode* newElement = new LNode(t, i, p, this); 67 71 return newElement; … … 70 74 // insert new elemets to the list w.r.t. increasing labels 71 75 // only used for the S-polys to be reduced (TopReduction building new S-polys with higher label) 72 LNode* LNode::insertByLabel( LPoly* lp) {73 if( lp->getTerm() <= this->data->getTerm()) {74 LNode* newElement = new LNode( lp, this);76 LNode* LNode::insertByLabel(poly t, int i, poly p) { 77 if(0 == pLmCmp(t,this->getTerm()) || -1 == pLmCmp(t,this->getTerm())) { 78 LNode* newElement = new LNode(t, i, p, this); 75 79 return newElement; 76 80 } 77 81 else { 78 82 LNode* temp = this; 79 while( NULL != temp->next ) {80 if( lp->getTerm() <= temp->next->data->getTerm()) {81 LNode* newElement = new LNode( lp, temp->next);83 while( NULL != temp->next->data ) { 84 if( 0 == pLmCmp(t,temp->next->getTerm()) || -1 == pLmCmp(t,temp->next->getTerm())) { 85 LNode* newElement = new LNode(t, i, p, temp->next); 82 86 temp->next = newElement; 83 87 return this; … … 87 91 } 88 92 } 89 LNode* newElement = new LNode( lp, NULL);93 LNode* newElement = new LNode(t, i, p, NULL); 90 94 temp->next = newElement; 91 95 return this; … … 120 124 int LNode::getIndex() { 121 125 return data->getIndex(); 126 } 127 128 bool LNode::getDel() { 129 return data->getDel(); 130 } 131 132 // set the data from the LPoly saved in LNode 133 void LNode::setPoly(poly p) { 134 data->setPoly(p); 135 } 136 137 void LNode::setTerm(poly t) { 138 data->setTerm(t); 139 } 140 141 void LNode::setIndex(int i) { 142 data->setIndex(i); 143 } 144 145 void LNode::setDel(bool d) { 146 data->setDel(d); 122 147 } 123 148 … … 144 169 */ 145 170 171 LList::LList() { 172 first = new LNode(); 173 length = 0; 174 } 175 146 176 LList::LList(LPoly* lp) { 147 first = new LNode(lp); 148 } 149 150 LList::LList(poly* t,int* i,poly* p) { 151 first = new LNode(t,i,p); 177 first = new LNode(lp); 178 length = 1; 179 } 180 181 LList::LList(poly t,int i,poly p) { 182 first = new LNode(t,i,p); 183 length = 1; 152 184 } 153 185 … … 159 191 void LList::insert(LPoly* lp) { 160 192 first = first->insert(lp); 161 } 162 163 void LList::insert(poly* t,int* i, poly* p) { 193 length++; 194 } 195 196 void LList::insert(poly t,int i, poly p) { 164 197 first = first->insert(t,i,p); 165 } 166 167 void LList::insertByLabel(LPoly* lp) { 168 first = first->insertByLabel(lp); 198 length++; 199 } 200 201 void LList::insertByLabel(poly t, int i, poly p) { 202 first = first->insertByLabel(t,i,p); 203 length++; 169 204 } 170 205 … … 183 218 LNode* LList::getNext(LNode* l) { 184 219 return l->getNext(); 220 } 221 222 int LList::getLength() { 223 return length; 185 224 } 186 225 … … 299 338 if(0 == pLmCmp(u1,ppMult_qq(this->data->getT1(), this->data->getLp1Term())) || 300 339 -1 == pLmCmp(u1,ppMult_qq(this->data->getT1(), this->data->getLp1Term()))) { 301 Print("Leck mich am Arsch: ");302 340 pWrite(u1); 303 341 Print("Multi-Term in CritPairs Sortierung altes Element: "); … … 386 424 CNode* temp = this; 387 425 while( NULL != temp->data ) { 388 while( temp->next->data->getDeg() == this->data->getDeg()) {426 while(NULL != temp->next->data && temp->next->data->getDeg() == this->data->getDeg()) { 389 427 temp = temp->next; 390 428 } 391 429 CNode* returnCNode = temp->next; 392 temp->next = NULL; 430 // every CList should end with a (NULL,NULL) element for a similar behaviour 431 // using termination conditions throughout the algorithm 432 temp->next = new CNode(); 393 433 return returnCNode; 394 434 } 395 435 return NULL; 436 } 437 438 CPair* CNode::getData() { 439 return data; 440 } 441 442 CNode* CNode::getNext() { 443 return next; 444 } 445 446 LPoly* CNode::getAdLp1() { 447 return this->data->getAdLp1(); 448 } 449 450 LPoly* CNode::getAdLp2() { 451 return this->data->getAdLp2(); 396 452 } 397 453 … … 424 480 } 425 481 482 poly* CNode::getAdT1() { 483 return this->data->getAdT1(); 484 } 485 426 486 poly CNode::getT2() { 427 487 return this->data->getT2(); 488 } 489 490 poly* CNode::getAdT2() { 491 return this->data->getAdT2(); 492 } 493 494 Rule* CNode::getLastRuleTested() { 495 return this->data->getLastRuleTested(); 428 496 } 429 497 … … 472 540 } 473 541 542 CNode* CList::getFirst() { 543 return first; 544 } 545 474 546 // get the first elements from CList which by the above sorting have minimal degree 475 547 // returns the pointer on the first element of those … … 510 582 } 511 583 584 RNode* RNode::insert(int i, poly t, LPoly* l) { 585 Rule* r = new Rule(i,t,l); 586 RNode* newElement = new RNode(r); 587 newElement->next = this; 588 return newElement; 589 } 590 512 591 RNode* RNode::getNext() { 513 592 return next; … … 537 616 RList::RList(Rule* r) { 538 617 first = new RNode(r); 618 } 619 620 void RList::insert(int i, poly t, LPoly* l) { 621 first = first->insert(i,t,l); 539 622 } 540 623 -
kernel/f5lists.h
rb3e45f r9bb97e 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: f5lists.h,v 1. 5 2009-02-04 19:27:12ederc Exp $ */4 /* $Id: f5lists.h,v 1.6 2009-02-06 20:12:35 ederc Exp $ */ 5 5 /* 6 6 * ABSTRACT: list interface … … 41 41 public: 42 42 // generating new list elements from the labeled / classical polynomial view 43 LNode(); 43 44 LNode(LPoly* lp); 44 45 LNode(LPoly* lp, LNode* l); 45 LNode(poly * t, int* i, poly*p);46 LNode(poly * t, int* i, poly*p, LNode* l);46 LNode(poly t, int i, poly p); 47 LNode(poly t, int i, poly p, LNode* l); 47 48 LNode(LNode* ln); 48 49 ~LNode(); 49 50 // insert new elements to the list in first place from the labeled / classical polynomial view 50 51 LNode* insert(LPoly* lp); 51 LNode* insert(poly * t, int* i, poly*p);52 LNode* insert(poly t, int i, poly p); 52 53 // insert new elements to the list with resp. to increasing labels 53 54 // only used for the S-polys to be reduced (TopReduction building new S-polys with higher label) 54 LNode* insertByLabel( LPoly* lp);55 LNode* insertByLabel(poly t, int i, poly p); 55 56 // deletes the first elements of the list with the same degree 56 57 // get next from current LNode … … 63 64 poly getPoly(); 64 65 poly getTerm(); 65 int getIndex(); 66 int getIndex(); 67 bool getDel(); 68 // set the data from the LPoly saved in LNode 69 void setPoly(poly p); 70 void setTerm(poly t); 71 void setIndex(int i); 72 void setDel(bool d); 66 73 // test if for any list element the polynomial part of the data is equal to *p 67 74 bool polyTest(poly* p); … … 78 85 private: 79 86 LNode* first; 80 public: 87 int length; 88 public: 89 LList(); 81 90 LList(LPoly* lp); 82 LList(poly * t,int* i,poly*p);91 LList(poly t,int i,poly p); 83 92 ~LList(); 84 93 void insert(LPoly* lp); 85 94 // insertion in front of the list 86 void insert(poly * t,int* i, poly*p);87 void insertByLabel( LPoly* lp);95 void insert(poly t,int i, poly p); 96 void insertByLabel(poly t, int i, poly p); 88 97 void deleteByDeg(); 89 98 bool polyTest(poly* p); 90 99 LNode* getFirst(); 91 100 LNode* getNext(LNode* l); 101 int getLength(); 92 102 }; 93 103 … … 147 157 CNode* insert(CPair* c, CNode* last); 148 158 CNode* getMinDeg(); 159 CPair* getData(); 160 CNode* getNext(); 161 LPoly* getAdLp1(); 162 LPoly* getAdLp2(); 149 163 poly getLp1Poly(); 150 164 poly getLp2Poly(); 151 165 poly getLp1Term(); 152 166 poly getLp2Term(); 153 poly getT1(); 167 poly getT1(); 168 poly* getAdT1(); 154 169 poly getT2(); 170 poly* getAdT2(); 155 171 int getLp1Index(); 156 172 int getLp2Index(); 173 Rule* getLastRuleTested(); 157 174 void print(); 158 175 }; … … 174 191 CList(CPair* c); 175 192 ~CList(); 193 CNode* getFirst(); 176 194 void insert(CPair* c); 177 195 CNode* getMinDeg(); … … 194 212 ~RNode(); 195 213 RNode* insert(Rule* r); 214 RNode* insert(int i, poly t, LPoly* l); 196 215 RNode* getNext(); 197 216 Rule* getRule(); … … 215 234 ~RList(); 216 235 void insert(Rule* r); 236 void insert(int i, poly t, LPoly* l); 217 237 RNode* getFirst(); 218 238 Rule* getRule(); … … 257 277 // declaration with first as parameter in LTagNode due to sorting of LTagList 258 278 void insert(RNode* r); 279 void insert(int i, poly* t, LPoly* l); 259 280 RNode* getFirst(); 260 281 RNode* get(int idx);
Note: See TracChangeset
for help on using the changeset viewer.