Changeset a0350e9 in git
- Timestamp:
- Jan 15, 2009, 6:44:24 PM (14 years ago)
- Branches:
- (u'spielwiese', '0d6b7fcd9813a1ca1ed4220cfa2b104b97a0a003')
- Children:
- 2653d3c2809f0b96d6da699e54066fdb07623b92
- Parents:
- 5ec4a8bc9c1e8e23c5f5f95235a4e4839659b682
- Location:
- kernel
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/f5gb.cc
r5ec4a8 ra0350e9 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: f5gb.cc,v 1.1 5 2008-12-27 13:50:05ederc Exp $ */4 /* $Id: f5gb.cc,v 1.16 2009-01-15 17:44:23 ederc Exp $ */ 5 5 /* 6 6 * ABSTRACT: f5gb interface … … 24 24 #include "lpolynomial.h" 25 25 #include "lists.h" 26 27 28 /*29 ================================================30 computation of ONE polynomial as global variable31 ================================================32 */33 poly one_poly() {34 poly one = pInit();35 pSetCoeff(one,nInit(1));36 return one;37 }38 39 26 40 27 … … 80 67 ================================================== 81 68 */ 82 LList* F5inc(long* i, poly* f_i, LList* g_prev) { 83 poly one = pInit(); 84 pSetCoeff(one, nInit(1)); 85 static poly ONE = one; 86 //poly ONE = pOne(); 69 LList* F5inc(int* i, poly* f_i, LList* g_prev, poly* ONE) { 87 70 LList* g_curr = g_prev; 88 LNode* prev_last = g_prev->getLast(); //tags the end of g_prev->only 1 list for g_prev & g_curr 89 g_curr->append(&ONE,i,f_i); 71 g_curr->insert(ONE,i,f_i); 90 72 91 73 return g_curr; … … 98 80 */ 99 81 ideal F5main(ideal id, ring r) { 100 101 static poly ONE = pOne(); 102 long i,j; 103 82 int i,j; 83 const int idElems = IDELEMS(id); 84 // 1 polynomial for defining initial labels & further tests 85 static poly ONE = pOne(); 86 87 104 88 // definition of one-polynomial as global constant ONE 105 89 //poly one = pInit(); … … 122 106 idShow(id); 123 107 i = 1; 124 //lp->setIndex(&i);125 //lp->setTerm(&ONE);126 //lp->setPoly(&id->m[0]);127 LPoly* lp = new LPoly(&ONE,&i,&ONE);128 129 108 // only for debugging 130 long k = 2; 131 LList* g_prev = new LList(&ONE,&k,&id->m[2]); 132 LNode* current; 133 LPoly* lp2 = new LPoly(&ONE,&k,&ONE); 109 //LNode* current; 134 110 //LList* g_curr = new LList(lp); 135 k = 134; 136 g_prev->append(&ONE,&k,&id->m[3]); 137 g_prev->append(&ONE,&k,&id->m[3]); 138 g_prev->append(lp2); 139 g_prev->append(lp2); 140 g_prev->append(lp); 141 g_prev->append(&ONE,&k,&id->m[1]); 142 g_prev->append(&ONE,&k,&id->m[3]); 143 g_prev->append(lp2); 144 i = g_prev->getLength(); 145 Print("%ld\n\n",i); 146 current = g_prev->getFirst(); 147 while(NULL != current) { 148 Print("Index: %ld\n",*(current->getLPoly()->getIndex())); 149 Print("Pointer comparison: %p , %p\n\n",g_prev->getFirst(),current); 150 current = current->getNext(); 151 } 111 //} 152 112 //for(i=2; i<IDELEMS(id); i++) { 153 113 //g_curr = F5inc(&i,&id->m[i],g_prev); -
kernel/f5gb.h
r5ec4a8 ra0350e9 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: f5gb.h,v 1.1 4 2008-12-27 13:50:05ederc Exp $ */4 /* $Id: f5gb.h,v 1.15 2009-01-15 17:44:23 ederc Exp $ */ 5 5 /* 6 6 * ABSTRACT: f5gb interface … … 12 12 #include "lpolynomial.h" 13 13 #include "lists.h" 14 15 16 /*17 ================================================18 computation of ONE polynomial as global variable19 ================================================20 */21 poly one_poly();22 14 23 15 … … 45 37 ================================================== 46 38 */ 47 LList* F5inc(const longi, LList* g_prev);39 LList* F5inc(const int i, LList* g_prev); 48 40 49 41 -
kernel/lists.cc
r5ec4a8 ra0350e9 25 25 */ 26 26 27 // generating new list elements in the labeled / classical polynomial / LNode view27 // generating new list elements (labeled / classical polynomial / LNode view) 28 28 LNode::LNode(LPoly* lp) { 29 29 data = lp; … … 31 31 } 32 32 33 LNode::LNode(poly* t, long* i, poly* p) {33 LNode::LNode(poly* t, int* i, poly* p) { 34 34 LPoly* lp = new LPoly(t,i,p); 35 35 data = lp; 36 Print("Index angelegt? % ld\n",*(data->getIndex()));36 Print("Index angelegt? %d\n",*(data->getIndex())); 37 37 next = NULL; 38 38 } … … 48 48 } 49 49 50 // append new elements to the list from the labeled / classical polynomial view51 LNode* LNode:: append(LPoly* lp) {52 LNode* new _element = new LNode(lp);53 ne xt = new_element;54 return new _element;50 // insert new elements to the list always in front (labeled / classical polynomial view) 51 LNode* LNode::insert(LPoly* lp) { 52 LNode* newElement = new LNode(lp); 53 newElement->next = this; 54 return newElement; 55 55 } 56 56 57 LNode* LNode:: append(poly* t, long* i, poly* p) {58 LNode* new _element = new LNode(t,i,p);59 ne xt = new_element;60 return new _element;57 LNode* LNode::insert(poly* t, int* i, poly* p) { 58 LNode* newElement = new LNode(t,i,p); 59 newElement->next = this; 60 return newElement; 61 61 } 62 62 … … 77 77 78 78 // test if for any list element the polynomial part of the data is equal to *p 79 bool LNode: polyTest(poly* p) {79 bool LNode::polyTest(poly* p) { 80 80 LNode* temp = new LNode(this); 81 81 while(NULL != temp) { … … 88 88 } 89 89 90 LNode* LNode::operator++() {91 LNode* temp= new LNode(this);92 return temp->getNext();93 }94 95 96 90 97 91 /* … … 103 97 LList::LList(LPoly* lp) { 104 98 first = new LNode(lp); 105 last = first;106 99 length = 1; 107 100 } 108 101 109 LList::LList(poly* t, long* i,poly* p) {102 LList::LList(poly* t,int* i,poly* p) { 110 103 first = new LNode(t,i,p); 111 last = first;112 104 length = 1; 113 105 } … … 117 109 } 118 110 119 void LList::append(LPoly* lp) { 120 last = last->append(lp); 111 // insertion in front of the list 112 void LList::insert(LPoly* lp) { 113 first = first->insert(lp); 121 114 length++; 122 115 } 123 116 124 void LList:: append(poly* t,long* i, poly* p) {125 last = last->append(t,i,p);117 void LList::insert(poly* t,int* i, poly* p) { 118 first = first->insert(t,i,p); 126 119 length++; 127 120 } … … 131 124 } 132 125 133 longLList::getLength() const {126 int LList::getLength() const { 134 127 return length; 135 128 } … … 139 132 } 140 133 141 LNode* LList::getLast() { 142 return last; 134 135 /* 136 ======================================= 137 functions working on the class PrevNode 138 ======================================= 139 */ 140 141 PrevNode::PrevNode(LNode* l) { 142 data = l; 143 next = NULL; 144 } 145 146 PrevNode::~PrevNode() { 147 delete next; 148 delete data; 149 } 150 151 PrevNode* PrevNode::append(LNode* l) { 152 PrevNode* new_element = new PrevNode(l); 153 next = new_element; 154 return new_element; 155 } 156 157 LNode* PrevNode::getLNode() { 158 return this->data; 159 } 160 161 LNode* PrevNode::getPrevLast(int i) { 162 int j; 163 PrevNode* temp = this; 164 for(j=1;j<=i-1;j++) { 165 temp = temp->next; 166 } 167 return temp->data; 168 } 169 170 /* 171 ======================================= 172 functions working on the class PrevList 173 ======================================= 174 */ 175 176 PrevList::PrevList(LNode* l) { 177 PrevNode* first = new PrevNode(l); 178 last = first; 179 } 180 181 void PrevList::append(LNode* l) { 182 last = last->append(l); 183 } 184 185 LNode* PrevList::getPrevLast(int i) { 186 switch(i) { 187 case 0: return NULL; 188 case 1: return first->getLNode(); 189 default: first->getPrevLast(i); 190 } 191 } 192 193 /* 194 ==================================== 195 functions working on the class CNode 196 ==================================== 197 */ 198 199 CNode::CNode(CPair* c) { 200 data = c; 201 next = NULL; 202 } 203 204 CNode::~CNode() { 205 delete next; 206 delete data; 207 } 208 209 // insert sorts the critical pairs firstly by increasing total degree, secondly by increasing label 210 // note: as all critical pairs have the same index here, the second sort is done on the terms of the labels 211 // working only with linked, but not doubly linked lists due to memory usage we have to check the 212 // insertion around the first element separately from the insertion around all other elements in the list 213 CNode* CNode::insert(CPair* c) { 214 if( c->getDeg() < this->data->getDeg() ) { // lower degree than the first list element 215 CNode* newElement = new CNode(c); 216 newElement->next = this; 217 return newElement; 218 } 219 if( c->getDeg() == this->data->getDeg() ) { // same degree than the first list element 220 if( c->getT1() <= this->data->getT1() ) { 221 CNode* newElement = new CNode(c); 222 newElement->next = this; 223 return newElement; 224 } 225 else { 226 CNode* temp = this; 227 while( temp->next != NULL ) { 228 if( temp->next->data->getDeg() == c->getDeg() ) { 229 if( c->getT1() <= temp->next->data->getT1() ) { 230 temp = temp->next; 231 } 232 else { 233 CNode* newElement = new CNode(c); 234 newElement->next = temp->next; 235 temp->next = newElement; 236 return this; 237 } 238 } 239 else { 240 CNode* newElement = new CNode(c); 241 newElement->next = temp->next; 242 temp->next = newElement; 243 return this; 244 } 245 } 246 CNode* newElement = new CNode(c); 247 newElement->next = NULL; 248 temp->next = newElement; 249 return this; 250 } 251 } // outer if-clause 252 if( c->getDeg() > this->data->getDeg() ) { // greater degree than the first list element 253 CNode* temp = this; 254 while( temp->next != NULL) { 255 if( c->getDeg() < temp->next->data->getDeg() ) { 256 CNode* newElement = new CNode(c); 257 newElement->next = temp->next; 258 temp->next = newElement; 259 return this; 260 } 261 if( c->getDeg() == temp->next->data->getDeg() ) { 262 if( c->getT1() <= temp->next->data->getT1() ) { 263 CNode* newElement = new CNode(c); 264 newElement->next = temp->next; 265 temp->next = newElement; 266 return this; 267 } 268 else { 269 temp = temp->next; 270 while( temp->next != NULL ) { 271 if( temp->next->data->getDeg() == c->getDeg() ) { 272 if( c->getT1() <= temp->next->data->getT1() ) { 273 temp = temp->next; 274 } 275 else { 276 CNode* newElement = new CNode(c); 277 newElement->next = temp->next; 278 temp->next = newElement; 279 return this; 280 } 281 } 282 else { 283 CNode* newElement = new CNode(c); 284 newElement->next = temp->next; 285 temp->next = newElement; 286 return this; 287 } 288 } 289 CNode* newElement = new CNode(c); 290 newElement->next = NULL; 291 temp->next = newElement; 292 return this; 293 } 294 } 295 if( c->getDeg() > temp->next->data->getDeg() ) { 296 temp = temp->next; 297 } 298 } 299 CNode* newElement = new CNode(c); 300 newElement->next = NULL; 301 temp->next = newElement; 302 return this; 303 } 304 } 305 306 /* 307 ==================================== 308 functions working on the class CList 309 ==================================== 310 */ 311 312 CList::CList(CPair* c) { 313 first = new CNode(c); 314 } 315 316 CList::~CList() { 317 delete first; 318 } 319 320 // insert sorts the critical pairs firstly by increasing total degree, secondly by increasing label 321 // note: as all critical pairs have the same index here, the second sort is done on the terms of the labels 322 void CList::insert(CPair* c) { 323 first = first->insert(c); 143 324 } 144 325 #endif -
kernel/lists.h
r5ec4a8 ra0350e9 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: lists.h,v 1. 2 2008-12-27 13:50:05ederc Exp $ */4 /* $Id: lists.h,v 1.3 2009-01-15 17:44:24 ederc Exp $ */ 5 5 /* 6 6 * ABSTRACT: list interface … … 11 11 12 12 #ifdef HAVE_F5 13 14 15 13 /* 16 ======================= 17 ======================= 18 linked lists for LPolys 19 ======================= 20 ======================= 21 */ 22 23 24 /* 25 =========================== 26 classes for lists of LPolys 27 =========================== 14 ============================ 15 ============================ 16 classes for lists used in F5 17 ============================ 18 ============================ 28 19 */ 29 20 class LNode; 30 21 class LList; 22 class PrevNode; 23 class PrevList; 24 class CNode; 25 class CList; 31 26 32 27 … … 43 38 // generating new list elements from the labeled / classical polynomial view 44 39 LNode(LPoly* lp); 45 LNode(poly* t, long* i, poly* p);40 LNode(poly* t, int* i, poly* p); 46 41 LNode(LNode* ln); 47 42 ~LNode(); 48 43 // append new elements to the list from the labeled / classical polynomial view 49 LNode* append(LPoly* lp);50 LNode* append(poly* t, long* i, poly* p);44 LNode* insert(LPoly* lp); 45 LNode* insert(poly* t, int* i, poly* p); 51 46 // get next from current LNode 52 47 LNode* getNext(); … … 58 53 // test if for any list element the polynomial part of the data is equal to *p 59 54 bool polyTest(poly* p); 60 LNode* operator++();61 55 }; 62 56 … … 70 64 private: 71 65 LNode* first; 72 LNode* last; 73 long length; 66 int length; 74 67 public: 75 68 LList(LPoly* lp); 76 LList(poly* t, long* i,poly* p);69 LList(poly* t,int* i,poly* p); 77 70 ~LList(); 78 void append(LPoly* lp); 79 void append(poly* t,long* i, poly* p); 71 void insert(LPoly* lp); 72 // insertion in front of the list 73 void insert(poly* t,int* i, poly* p); 80 74 bool polyTest(poly* p); 81 longgetLength() const;75 int getLength() const; 82 76 LNode* getFirst(); 83 LNode* getLast();84 77 }; 85 78 86 79 87 80 /* 88 ======================= 89 ======================= 90 linked lists for CPairs 91 ======================= 92 ======================= 81 ============================================= 82 PrevNode class (nodes for lists of gPrevLast) 83 ============================================= 93 84 */ 85 class PrevNode { 86 private: 87 LNode* data; 88 PrevNode* next; 89 public: 90 PrevNode(LNode* l); 91 ~PrevNode(); 92 PrevNode* append(LNode* l); 93 LNode* getLNode(); 94 LNode* getPrevLast(int i); 95 }; 94 96 95 97 96 98 /* 97 =========================== 98 class es for lists of CPairs99 =========================== 99 ==================================================== 100 class PrevList(lists of last node elements in gPrev) 101 ==================================================== 100 102 */ 101 class CNode; 102 class CList; 103 class PrevList { 104 private: 105 PrevNode* first; 106 PrevNode* last; 107 public: 108 PrevList(LNode* l); 109 ~PrevList(); 110 void append(LNode* l); 111 LNode* getPrevLast(int i); 112 }; 103 113 104 114 … … 110 120 class CNode { 111 121 private: 112 LPoly* data;122 CPair* data; 113 123 CNode* next; 114 124 public: 115 CNode(LPoly* lp, CNode* n) { 116 data = lp; 117 next = n; 118 } 119 ~CNode() { 120 delete next; 121 delete data; 122 } 123 CNode* append(LPoly* lp) { 124 CNode* new_element = new CNode(lp,NULL); 125 next = new_element; 126 return new_element; 127 } 128 LPoly* getLPoly() const { 129 return data; 130 } 125 CNode(CPair* c); 126 ~CNode(); 127 CNode* insert(CPair* c); 128 CNode* getLPoly() const; 131 129 }; 132 130 … … 140 138 private: 141 139 CNode* first; 142 CNode* last;143 long length;144 140 public: 145 CList(LPoly* lp) { 146 first = new CNode(lp,NULL); 147 last = first; 148 length = 1; 149 } 150 ~CList() { 151 delete first; 152 } 153 void append(LPoly* lp) { 154 last = last->append(lp); 155 length++; 156 } 157 long getLength() const { 158 return length; 159 } 160 CNode* getFirst() const { 161 return first; 162 } 163 CNode* getLast() const { 164 return last; 165 } 141 CList(CPair* c); 142 ~CList(); 143 void insert(CPair* c); 166 144 }; 167 145 #endif -
kernel/lpolynomial.cc
r5ec4a8 ra0350e9 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: lpolynomial.cc,v 1. 4 2008-12-27 13:50:06ederc Exp $ */4 /* $Id: lpolynomial.cc,v 1.5 2009-01-15 17:44:24 ederc Exp $ */ 5 5 /* 6 6 * ABSTRACT: lpolynomial definition … … 30 30 ================================================================ 31 31 */ 32 LPoly::LPoly(poly* t, long* i,poly* p) {32 LPoly::LPoly(poly* t,int* i,poly* p) { 33 33 set(t,i,p); 34 34 } 35 35 36 void LPoly::setPoly(poly* p) { 36 37 polynomial = *p; … … 41 42 } 42 43 43 void LPoly::setIndex( long* i) {44 void LPoly::setIndex(int* i) { 44 45 index = *i; 45 46 } 46 47 47 48 48 void LPoly::setDel(bool b) { … … 58 58 } 59 59 60 long* LPoly::getIndex() {60 int* LPoly::getIndex() { 61 61 return &index; 62 62 } … … 66 66 } 67 67 68 void LPoly::set(poly* t, long* i, poly* p) {68 void LPoly::set(poly* t, int* i, poly* p) { 69 69 this->setTerm(t); 70 70 this->setIndex(i); … … 75 75 return this; 76 76 } 77 78 /* 79 ==================================== 80 functions working on the class CPair 81 ==================================== 82 */ 83 CPair::CPair(int degree, poly term1, LPoly* lpoly1, poly term2, LPoly* lpoly2) { 84 deg = degree; 85 t1 = term1; 86 lp1 = lpoly1; 87 t2 = term2; 88 lp2 = lpoly2; 89 } 90 91 int CPair::getDeg() { 92 return deg; 93 } 94 95 poly CPair::getT1() { 96 return t1; 97 } 98 99 poly CPair::getT2() { 100 return t2; 101 } 102 103 poly CPair::getLp1Poly() { 104 return *(lp1->getPoly()); 105 } 106 107 poly CPair::getLp2Poly() { 108 return *(lp2->getPoly()); 109 } 110 111 poly CPair::getLp1Term() { 112 return *(lp1->getTerm()); 113 } 114 115 poly CPair::getLp2Term() { 116 return *(lp2->getTerm()); 117 } 118 119 int CPair::getLp1Index() { 120 return *(lp1->getIndex()); 121 } 122 123 124 int CPair::getLp2Index() { 125 return *(lp2->getIndex()); 126 } 127 128 77 129 #endif -
kernel/lpolynomial.h
r5ec4a8 ra0350e9 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: lpolynomial.h,v 1. 4 2008-12-27 13:50:06ederc Exp $ */4 /* $Id: lpolynomial.h,v 1.5 2009-01-15 17:44:24 ederc Exp $ */ 5 5 /* 6 6 * ABSTRACT: labeled polynomial interface … … 10 10 11 11 #ifdef HAVE_F5 12 /* 13 ========================================================= 14 ========================================================= 15 classes for labeled polynomials/pairs/S-polynomials in F5 16 ========================================================= 17 ========================================================= 18 */ 19 class LPoly; 20 class CPair; 12 21 13 22 … … 20 29 private: 21 30 poly term; //term of signature 22 longindex; //index of signature31 int index; //index of signature 23 32 poly polynomial; //standard polynomial data 24 33 bool del; //for deletion in TopReduction Subalgorithm 25 34 public: 26 LPoly(poly*t, long* i,poly* p);35 LPoly(poly*t,int* i,poly* p); 27 36 void setPoly(poly* p); 28 37 poly* getPoly(); 29 38 void setTerm(poly* t); 30 39 poly* getTerm(); 31 void setIndex( long* i);32 long*getIndex();40 void setIndex(int* i); 41 int* getIndex(); 33 42 void setDel(bool b); 34 43 bool getDel() const; 35 void set(poly* t, long* i, poly* p);44 void set(poly* t, int* i, poly* p); 36 45 LPoly* get(); 37 46 }; … … 43 52 =============================== 44 53 */ 45 struct CPair { 46 LPoly* cp1; // first component 47 LPoly* cp2; // second component 54 class CPair { 55 private: 56 int deg; // total degree of the critical pair 57 poly t1; // first term for label 58 LPoly* lp1; // first labeled poly 59 poly t2; // second term for label 60 LPoly* lp2; // second labeled poly 61 public: 62 CPair(int degree, poly term1, LPoly* lpoly1, poly term2, LPoly* lpoly2); 63 int getDeg(); 64 poly getT1(); 65 poly getLp1Poly(); 66 poly getLp1Term(); 67 int getLp1Index(); 68 poly getT2(); 69 poly getLp2Poly(); 70 poly getLp2Term(); 71 int getLp2Index(); 48 72 }; 49 73
Note: See TracChangeset
for help on using the changeset viewer.