Changeset ded085 in git
- Timestamp:
- Dec 11, 2009, 4:40:02 PM (13 years ago)
- Branches:
- (u'spielwiese', '0d6b7fcd9813a1ca1ed4220cfa2b104b97a0a003')
- Children:
- 867e1a39616ddc1692d837af059565a1320e8cc7
- Parents:
- b54a393fcb8e823c662951c5a6219096fb8a6800
- Location:
- kernel
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/ideals.cc
rb54a393 rded085 541 541 542 542 /*2 543 * concat h1 and h2 544 */ 545 void idInsertPoly (ideal h1,poly h2) 546 { 547 if (h2==NULL) return; 543 * insert h2 into h1 (if h2 is not the zero polynomial) 544 * return TRUE iff h2 was indeed inserted 545 */ 546 BOOLEAN idInsertPoly (ideal h1, poly h2) 547 { 548 if (h2==NULL) return FALSE; 548 549 int j = IDELEMS(h1)-1; 549 550 while ((j >= 0) && (h1->m[j] == NULL)) j--; … … 555 556 } 556 557 h1->m[j]=h2; 557 } 558 559 /*2 560 * concat h1 and h2 (if h2 is neither zero nor a generator of h1) 561 */ 562 void idInsertPolyNoDuplicates (ideal h1,poly h2) 558 return TRUE; 559 } 560 561 /*2 562 * insert h2 into h1 (if h2 is neither the zero polynomial 563 * nor a generator in h1) 564 * return TRUE iff h2 was indeed inserted 565 */ 566 BOOLEAN idInsertPolyNoDuplicates (ideal h1, poly h2) 563 567 { 564 568 bool h2FoundInH1 = false; … … 569 573 i++; 570 574 } 571 if (!h2FoundInH1) idInsertPoly(h1, h2); 575 if (!h2FoundInH1) return idInsertPoly(h1, h2); 576 else return FALSE; 572 577 } 573 578 -
kernel/ideals.h
rb54a393 rded085 54 54 ideal idAdd (ideal h1,ideal h2); 55 55 /* h1 + h2 */ 56 voididInsertPoly (ideal h1,poly h2);56 BOOLEAN idInsertPoly (ideal h1,poly h2); 57 57 /* h1 + h2 */ 58 voididInsertPolyNoDuplicates (ideal h1,poly h2);58 BOOLEAN idInsertPolyNoDuplicates (ideal h1,poly h2); 59 59 /* h1 + h2 */ 60 60 ideal idMult (ideal h1,ideal h2); -
kernel/ring.cc
rb54a393 rded085 766 766 } 767 767 768 int binaryPower (const int a, const int b) 769 { 770 /* computes a^b according to the binary representation of b, 771 i.e., a^7 = a^4 * a^2 * a^1. This saves some multiplications. */ 772 int result = 1; 773 int factor = a; 774 int bb = b; 775 while (bb != 0) 776 { 777 if (bb % 2 != 0) result = result * factor; 778 bb = bb / 2; 779 factor = factor * factor; 780 } 781 return result; 782 } 783 768 784 int rChar(ring r) 769 785 { 786 if (rField_is_Ring_2toM(r)) 787 return binaryPower(2, (int)(unsigned long)r->ringflagb); 788 if (rField_is_Ring_ModN(r)) 789 return (int)mpz_get_ui(r->ringflaga); 790 if (rField_is_Ring_PtoM(r)) 791 return binaryPower((int)mpz_get_ui(r->ringflaga), 792 (int)(unsigned long)r->ringflagb); 770 793 if (rField_is_numeric(r)) 771 794 return 0;
Note: See TracChangeset
for help on using the changeset viewer.