Changeset cce6ed3 in git
- Timestamp:
- Jan 25, 2009, 6:13:06 PM (14 years ago)
- Branches:
- (u'spielwiese', '0d6b7fcd9813a1ca1ed4220cfa2b104b97a0a003')
- Children:
- f4e338f564fc725c8dac99c44cbf3f5ec5ceacb2
- Parents:
- 0883ed62762dee5f6c5fa37f064d3883b99dc21f
- Location:
- kernel
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/f5gb.cc
r0883ed rcce6ed3 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: f5gb.cc,v 1.1 6 2009-01-15 17:44:23ederc Exp $ */4 /* $Id: f5gb.cc,v 1.17 2009-01-25 17:13:05 ederc Exp $ */ 5 5 /* 6 6 * ABSTRACT: f5gb interface … … 67 67 ================================================== 68 68 */ 69 LList* F5inc(int* i, poly* f_i, LList* g_prev, poly* ONE) { 70 LList* g_curr = g_prev; 71 g_curr->insert(ONE,i,f_i); 72 73 return g_curr; 69 LList* F5inc(int* i, poly* f_i, LList* gPrev, poly* ONE) { 70 gPrev->insert(ONE,i,f_i); 71 CList* critPairs = criticalPair(gPrev); 72 73 return gPrev; 74 } 75 76 77 /* 78 ================================================================ 79 computes a list of critical pairs for the next reduction process 80 first element in gPrev is always the newest element which must 81 build critical pairs with all other elements in gPrev 82 ================================================================ 83 */ 84 CList* criticalPair(LList* gPrev) { 85 poly lcm = pInit(); 86 number n = nInit(2); 87 nWrite(n); 88 pWrite(lcm); 89 // initialization for usage in pLcm() 90 LNode* first = gPrev->getFirst(); 91 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; 97 // computation of critical pairs 98 while( NULL != l) { 99 //pWrite( *(gPrev->getFirst()->getPoly()) ); 100 //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)); 109 // 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)); 128 // 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"); 142 l = l->getNext(); 143 } 144 return NULL; 145 } 146 147 /* 148 ======================================== 149 Criterion 1, i.e. Faugere's F5 Criterion 150 ======================================== 151 */ 152 bool criterion1(LNode* l, LList* gPrev) { 153 LNode* testNode = l->getNext(); 154 while(NULL != testNode) { 155 while(*testNode->getIndex() == *l->getIndex()) { 156 testNode = testNode->getNext(); 157 } 158 } 159 160 161 return true; 74 162 } 75 163 … … 81 169 ideal F5main(ideal id, ring r) { 82 170 int i,j; 83 const int idElems = IDELEMS(id);84 171 // 1 polynomial for defining initial labels & further tests 85 172 static poly ONE = pOne(); 86 87 173 i = 1; 174 LList* gPrev = new LList( &ONE, &i, &id->m[0]); 175 poly* lcm = new poly; 176 // initialization for usage in pLcm() 177 *lcm = pOne(); 178 pWrite(*lcm); 88 179 // definition of one-polynomial as global constant ONE 89 180 //poly one = pInit(); … … 95 186 if(pComparePolys(id->m[j],ONE)) { 96 187 Print("One Polynomial in Input => Computations stopped\n"); 97 ideal id _new = idInit(1,1);98 id _new->m[0] = ONE;99 return(id _new);188 ideal idNew = idInit(1,1); 189 idNew->m[0] = ONE; 190 return(idNew); 100 191 } 101 192 } 102 193 } 103 194 pLcm( id->m[0], id->m[1], *lcm); 195 Print("LCM NEU\n"); 196 //*lcm = pHead(*lcm); 197 //pWrite(*lcm); 198 Print("\n\n"); 104 199 id = kInterRed(id,0); 105 200 qsortDegree(&id->m[0],&id->m[IDELEMS(id)-1]); 106 201 idShow(id); 107 i = 1; 202 poly p = pHead(id->m[0]); 203 pWrite(p); 204 poly q = pHead(id->m[2]); 205 pWrite(q); 206 for(i=2; i<=IDELEMS(id); i++) { 207 gPrev = F5inc( &i, &id->m[i-1], gPrev, &ONE ); 208 } 108 209 // only for debugging 109 210 //LNode* current; -
kernel/f5gb.h
r0883ed rcce6ed3 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: f5gb.h,v 1.1 5 2009-01-15 17:44:23ederc Exp $ */4 /* $Id: f5gb.h,v 1.16 2009-01-25 17:13:06 ederc Exp $ */ 5 5 /* 6 6 * ABSTRACT: f5gb interface … … 21 21 void qsort_degree(poly* left, poly* right); 22 22 23 24 23 /* 25 24 ============================================== … … 30 29 void generate_input_list(LPoly* lp, ideal id, poly one); 31 30 32 33 31 /* 34 32 ================================================== … … 37 35 ================================================== 38 36 */ 39 LList* F5inc( const int i, LList* g_prev);37 LList* F5inc(int* i, poly* f_i, LList* gPrev, poly* ONE); 40 38 39 /* 40 ================================================================ 41 computes a list of critical pairs for the next reduction process 42 first element in gPrev is always the newest element which must 43 build critical pairs with all other elements in gPrev 44 ================================================================ 45 */ 46 CList* criticalPair(LList* gPrev); 41 47 48 /* 49 ======================================== 50 Criterion 1, i.e. Faugere's F5 Criterion 51 ======================================== 52 */ 53 bool criterion1(LNode* l, LList* gPrev); 42 54 /* 43 55 ====================================== -
kernel/lists.cc
r0883ed rcce6ed3 34 34 LPoly* lp = new LPoly(t,i,p); 35 35 data = lp; 36 Print("Index angelegt? %d\n",*(data->getIndex()));37 36 next = NULL; 38 37 } … … 61 60 } 62 61 62 // insert new elemets to the list w.r.t. increasing labels 63 // only used for the S-polys to be reduced (TopReduction building new S-polys with higher label) 64 LNode* LNode::insertByLabel(LPoly* lp) { 65 if( lp->getTerm() <= this->data->getTerm() ) { 66 LNode* newElement = new LNode(lp); 67 newElement->next = this; 68 return newElement; 69 } 70 else { 71 LNode* temp = this; 72 while( NULL != temp->next ) { 73 if( lp->getTerm() <= temp->next->data->getTerm() ) { 74 LNode* newElement = new LNode(lp); 75 newElement->next = temp->next; 76 temp->next = newElement; 77 return this; 78 } 79 else { 80 temp = temp->next; 81 } 82 } 83 LNode* newElement = new LNode(lp); 84 temp->next = newElement; 85 newElement->next = NULL; 86 return this; 87 } 88 } 89 90 // deletes the first elements of the list with the same degree 91 // only used for the S-polys, which are already sorted by increasing degree by CList 92 LNode* LNode::deleteByDeg() { 93 return this; 94 } 95 63 96 // get next from current LNode 64 97 LNode* LNode::getNext() { … … 71 104 } 72 105 73 // get the address of the polynomial part of LPoly* of LNode*106 // get the data from the LPoly saved in LNode 74 107 poly* LNode::getPoly() { 75 108 return data->getPoly(); 109 } 110 111 poly* LNode::getTerm() { 112 return data->getTerm(); 113 } 114 115 int* LNode::getIndex() { 116 return data->getIndex(); 76 117 } 77 118 … … 88 129 } 89 130 131 LNode* LNode::getNext(LNode* l) { 132 return l->next; 133 } 90 134 91 135 /* … … 97 141 LList::LList(LPoly* lp) { 98 142 first = new LNode(lp); 99 length = 1;100 143 } 101 144 102 145 LList::LList(poly* t,int* i,poly* p) { 103 146 first = new LNode(t,i,p); 104 length = 1;105 147 } 106 148 … … 112 154 void LList::insert(LPoly* lp) { 113 155 first = first->insert(lp); 114 length++;115 156 } 116 157 117 158 void LList::insert(poly* t,int* i, poly* p) { 118 159 first = first->insert(t,i,p); 119 length++; 160 } 161 162 void LList::insertByLabel(LPoly* lp) { 163 first = first->insertByLabel(lp); 164 } 165 166 void LList::deleteByDeg() { 167 first = first->deleteByDeg(); 120 168 } 121 169 … … 124 172 } 125 173 126 int LList::getLength() const {127 return length;128 }129 130 174 LNode* LList::getFirst() { 131 175 return first; 132 176 } 133 177 178 LNode* LList::getNext(LNode* l) { 179 return l->getNext(); 180 } 134 181 135 182 /* … … 225 272 else { 226 273 CNode* temp = this; 227 while( temp->next != NULL) {274 while( NULL != temp->next ) { 228 275 if( temp->next->data->getDeg() == c->getDeg() ) { 229 276 if( c->getT1() <= temp->next->data->getT1() ) { … … 252 299 if( c->getDeg() > this->data->getDeg() ) { // greater degree than the first list element 253 300 CNode* temp = this; 254 while( temp->next != NULL) {301 while( NULL != temp->next ) { 255 302 if( c->getDeg() < temp->next->data->getDeg() ) { 256 303 CNode* newElement = new CNode(c); … … 268 315 else { 269 316 temp = temp->next; 270 while( temp->next != NULL) {317 while( NULL != temp->next ) { 271 318 if( temp->next->data->getDeg() == c->getDeg() ) { 272 319 if( c->getT1() <= temp->next->data->getT1() ) { … … 304 351 } 305 352 353 // get the first elements from CList which by the above sorting have minimal degree 354 CNode* CNode::getMinDeg() { 355 CNode* temp = this; 356 while( NULL != temp ) { 357 if( temp->next->data->getDeg() == this->data->getDeg() ) { 358 temp = temp->next; 359 } 360 CNode* returnCNode = temp->next; 361 temp->next = NULL; 362 return returnCNode; 363 } 364 return NULL; 365 } 366 367 306 368 /* 307 369 ==================================== … … 309 371 ==================================== 310 372 */ 311 312 373 CList::CList(CPair* c) { 313 374 first = new CNode(c); … … 323 384 first = first->insert(c); 324 385 } 386 387 // get the first elements from CList which by the above sorting have minimal degree 388 // returns the pointer on the first element of those 389 CNode* CList::getMinDeg() { 390 CNode* temp = first; 391 first = first->getMinDeg(); 392 return temp; 393 } 394 395 396 /* 397 ==================================== 398 functions working on the class RNode 399 ==================================== 400 */ 401 RNode::RNode(Rule* r) { 402 data = r; 403 next = NULL; 404 } 405 406 RNode::~RNode() { 407 delete next; 408 delete data; 409 } 410 411 RNode* RNode::insert(Rule* r) { 412 RNode* newElement = new RNode(r); 413 newElement->next = this; 414 return newElement; 415 } 416 417 /* 418 ==================================== 419 functions working on the class RList 420 ==================================== 421 */ 422 RList::RList(Rule* r) { 423 first = new RNode(r); 424 } 425 426 void RList::insert(Rule* r) { 427 first = first->insert(r); 428 } 325 429 #endif -
kernel/lists.h
r0883ed rcce6ed3 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: lists.h,v 1. 3 2009-01-15 17:44:24ederc Exp $ */4 /* $Id: lists.h,v 1.4 2009-01-25 17:13:06 ederc Exp $ */ 5 5 /* 6 6 * ABSTRACT: list interface … … 24 24 class CNode; 25 25 class CList; 26 26 class RList; 27 class RNode; 27 28 28 29 /* … … 41 42 LNode(LNode* ln); 42 43 ~LNode(); 43 // append new elements to the listfrom the labeled / classical polynomial view44 // insert new elements to the list in first place from the labeled / classical polynomial view 44 45 LNode* insert(LPoly* lp); 45 46 LNode* insert(poly* t, int* i, poly* p); 47 // insert new elements to the list with resp. to increasing labels 48 // only used for the S-polys to be reduced (TopReduction building new S-polys with higher label) 49 LNode* insertByLabel(LPoly* lp); 50 // deletes the first elements of the list with the same degree 46 51 // get next from current LNode 47 52 LNode* getNext(); 48 53 // only used for the S-polys, which are already sorted by increasing degree by CList 54 LNode* deleteByDeg(); 49 55 // get the LPoly* out of LNode* 50 56 LPoly* getLPoly(); 51 // get the address of the polynomial part of LPoly* of LNode*57 // get the data from the LPoly saved in LNode 52 58 poly* getPoly(); 59 poly* getTerm(); 60 int* getIndex(); 53 61 // test if for any list element the polynomial part of the data is equal to *p 54 62 bool polyTest(poly* p); 63 LNode* getNext(LNode* l); 55 64 }; 56 65 … … 64 73 private: 65 74 LNode* first; 66 int length;67 75 public: 68 76 LList(LPoly* lp); … … 72 80 // insertion in front of the list 73 81 void insert(poly* t,int* i, poly* p); 82 void insertByLabel(LPoly* lp); 83 void deleteByDeg(); 74 84 bool polyTest(poly* p); 75 int getLength() const;76 LNode* get First();85 LNode* getFirst(); 86 LNode* getNext(LNode* l); 77 87 }; 78 88 … … 115 125 /* 116 126 ======================================= 117 CNode class(nodes for lists of CPairs)127 class CNode (nodes for lists of CPairs) 118 128 ======================================= 119 129 */ … … 126 136 ~CNode(); 127 137 CNode* insert(CPair* c); 128 CNode* getLPoly() const; 138 CNode* getMinDeg(); 139 //CNode* getLPoly() const; 129 140 }; 130 141 131 142 132 143 /* 133 ============================ =134 class C PList(lists of CPairs)135 ============================ =144 ============================ 145 class CList(lists of CPairs) 146 ============================ 136 147 */ 137 148 class CList { … … 141 152 CList(CPair* c); 142 153 ~CList(); 143 void insert(CPair* c); 154 void insert(CPair* c); 155 CNode* getMinDeg(); 156 157 }; 158 159 160 /* 161 ====================================== 162 class RNode (nodes for lists of Rules) 163 ====================================== 164 */ 165 class RNode { 166 private: 167 Rule* data; 168 RNode* next; 169 public: 170 RNode(Rule* r); 171 ~RNode(); 172 RNode* insert(Rule* r); 173 }; 174 175 /* 176 ============================ 177 class RList (lists of Rules) 178 ============================ 179 */ 180 class RList { 181 private: 182 RNode* first; 183 public: 184 RList(Rule* r); 185 ~RList(); 186 void insert(Rule* r); 144 187 }; 145 188 #endif -
kernel/lpolynomial.cc
r0883ed rcce6ed3 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: lpolynomial.cc,v 1. 5 2009-01-15 17:44:24ederc Exp $ */4 /* $Id: lpolynomial.cc,v 1.6 2009-01-25 17:13:06 ederc Exp $ */ 5 5 /* 6 6 * ABSTRACT: lpolynomial definition … … 81 81 ==================================== 82 82 */ 83 CPair::CPair( intdegree, poly term1, LPoly* lpoly1, poly term2, LPoly* lpoly2) {83 CPair::CPair(long degree, poly term1, LPoly* lpoly1, poly term2, LPoly* lpoly2) { 84 84 deg = degree; 85 85 t1 = term1; … … 89 89 } 90 90 91 intCPair::getDeg() {91 long CPair::getDeg() { 92 92 return deg; 93 93 } … … 127 127 128 128 129 /* 130 =================================== 131 functions working on the class Rule 132 =================================== 133 */ 134 Rule::Rule(int* i, poly* t) { 135 index = i; 136 term = t; 137 } 138 139 int Rule::getIndex() { 140 return *index; 141 } 142 143 poly Rule::getTerm() { 144 return *term; 145 } 129 146 #endif -
kernel/lpolynomial.h
r0883ed rcce6ed3 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: lpolynomial.h,v 1. 5 2009-01-15 17:44:24ederc Exp $ */4 /* $Id: lpolynomial.h,v 1.6 2009-01-25 17:13:06 ederc Exp $ */ 5 5 /* 6 6 * ABSTRACT: labeled polynomial interface … … 19 19 class LPoly; 20 20 class CPair; 21 class Rule; 21 22 22 23 23 24 /* 24 ============================ =25 class of a labeled polynomial26 ============================ =25 ============================ 26 class of labeled polynomials 27 ============================ 27 28 */ 28 29 class LPoly { … … 48 49 49 50 /* 50 =============================== 51 structure of thecritical pairs52 =============================== 51 =================================== 52 structure of labeled critical pairs 53 =================================== 53 54 */ 54 55 class CPair { 55 56 private: 56 intdeg; // total degree of the critical pair57 long deg; // total degree of the critical pair 57 58 poly t1; // first term for label 58 59 LPoly* lp1; // first labeled poly … … 60 61 LPoly* lp2; // second labeled poly 61 62 public: 62 CPair( intdegree, poly term1, LPoly* lpoly1, poly term2, LPoly* lpoly2);63 intgetDeg();63 CPair(long degree, poly term1, LPoly* lpoly1, poly term2, LPoly* lpoly2); 64 long getDeg(); 64 65 poly getT1(); 65 66 poly getLp1Poly(); … … 73 74 74 75 76 /* 77 ======================================================== 78 structure of rules(i.e. already computed / known labels) 79 ======================================================== 80 */ 81 class Rule { 82 private: 83 int* index; // index of the labeled polynomial the rule comes from 84 poly* term; // term of the labeled polynomial the rule comes from 85 public: 86 Rule(int* i, poly* term); 87 int getIndex(); 88 poly getTerm(); 89 }; 75 90 #endif 76 91 #endif
Note: See TracChangeset
for help on using the changeset viewer.