Changeset 2b3caae in git
 Timestamp:
 Dec 18, 2009, 5:09:26 PM (13 years ago)
 Branches:
 (u'spielwiese', 'f6c3dc58b0df4bd712574325fe76d0626174ad97')
 Children:
 9821ca7eb7f00bcded47abfce2ebbf6fee5c0e6d
 Parents:
 1c35568d7e5a5987077ae991beaea0a846eec9ce
 Location:
 kernel
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

kernel/ideals.cc
r1c35568 r2b3caae 191 191 IDELEMS(ide) = j+1; 192 192 } 193 } 194 195 /*2 196 * copies the first k (>= 1) entries of the given ideal 197 * and returns these as a new ideal 198 * (Note that the copied polynomials may be zero.) 199 */ 200 ideal idCopyFirstK (const ideal ide, const int k) 201 { 202 ideal newI = idInit(k, 0); 203 for (int i = 0; i < k; i++) 204 newI>m[i] = pCopy(ide>m[i]); 205 return newI; 193 206 } 194 207 … … 560 573 561 574 /*2 562 * insert h2 into h1 (if h2 is neither the zero polynomial 563 * nor a generator in h1) 575 * insert h2 into h1 depending on the two boolean parameters: 576 *  if zeroOk is true, then h2 will also be inserted when it is zero 577 *  if duplicateOk is true, then h2 will also be inserted when it is 578 * already present in h1 564 579 * return TRUE iff h2 was indeed inserted 565 580 */ 566 BOOLEAN idInsertPolyNoDuplicates (ideal h1, poly h2) 567 { 568 bool h2FoundInH1 = false; 569 int i = 0; 570 while ((i < IDELEMS(h1)) && (!h2FoundInH1)) 571 { 572 h2FoundInH1 = pEqualPolys(h1>m[i], h2); 573 i++; 574 } 575 if (!h2FoundInH1) return idInsertPoly(h1, h2); 576 else return FALSE; 581 BOOLEAN idInsertPolyWithTests (ideal h1, const int validEntries, 582 const poly h2, const bool zeroOk, const bool duplicateOk) 583 { 584 if ((!zeroOk) && (h2 == NULL)) return FALSE; 585 if (!duplicateOk) 586 { 587 bool h2FoundInH1 = false; 588 int i = 0; 589 while ((i < validEntries) && (!h2FoundInH1)) 590 { 591 h2FoundInH1 = pEqualPolys(h1>m[i], h2); 592 i++; 593 } 594 if (h2FoundInH1) return FALSE; 595 } 596 if (validEntries == IDELEMS(h1)) 597 { 598 pEnlargeSet(&(h1>m), IDELEMS(h1), 16); 599 IDELEMS(h1) += 16; 600 } 601 h1>m[validEntries] = h2; 602 return TRUE; 577 603 } 578 604 
kernel/ideals.h
r1c35568 r2b3caae 12 12 #ifdef PDEBUG 13 13 ideal idDBInit (int size, int rank, const char *f, int l); 14 ideal idCopyFirstK (const ideal ide, const int k); 14 15 #define idInit(A,B) idDBInit(A,B,__FILE__,__LINE__) 15 16 #else 16 17 /* creates an ideal */ 17 18 ideal idInit (int size, int rank=1); 19 ideal idCopyFirstK (const ideal ide, const int k); 18 20 #endif 19 21 /* deletes an ideal */ … … 56 58 BOOLEAN idInsertPoly (ideal h1,poly h2); 57 59 /* h1 + h2 */ 58 BOOLEAN idInsertPolyNoDuplicates (ideal h1,poly h2); 60 BOOLEAN idInsertPolyWithTests (ideal h1, const int validEntries, 61 const poly h2, const bool zeroOk, const bool duplicateOk); 59 62 /* h1 + h2 */ 60 63 ideal idMult (ideal h1,ideal h2);
Note: See TracChangeset
for help on using the changeset viewer.