Changeset 81306a in git
- Timestamp:
- May 9, 2005, 12:03:25 PM (18 years ago)
- Branches:
- (u'spielwiese', '0d6b7fcd9813a1ca1ed4220cfa2b104b97a0a003')
- Children:
- bafa5b4ac634fe7bcc5d99004b65bffd70c587ad
- Parents:
- b055de970998dfcbcea96c80ca2368175890afb4
- Location:
- kernel
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/tgb.cc
rb055de9 r81306a 1664 1664 return -pLmCmp(((int_poly_pair*) a)->p,((int_poly_pair*) b)->p ); 1665 1665 } 1666 mac_poly mac_p_add_ff_qq(mac_poly a, number f,mac_poly b){ 1667 mac_poly erg; 1668 mac_poly* set_this; 1669 set_this=&erg; 1670 while((a!=NULL) &&(b!=NULL)){ 1671 if (a->exp<b->exp){ 1672 (*set_this)=a; 1673 a=a->next; 1674 set_this= &((*set_this)->next); 1675 } 1676 else{ 1677 if (a->exp>b->exp){ 1678 mac_poly in =new mac_poly_r(); 1679 in->exp=b->exp; 1680 in->coef=nMult(b->coef,f); 1681 (*set_this)=in; 1682 b=b->next; 1683 set_this= &((*set_this)->next); 1684 } 1685 else { 1686 //a->exp==b->ecp 1687 number n=nMult(b->coef,f); 1688 number n2=nAdd(a->coef,n); 1689 nDelete(&n); 1690 nDelete(&(a->coef)); 1691 if (nIsZero(n2)){ 1692 nDelete(&n2); 1693 mac_poly ao=a; 1694 a=a->next; 1695 delete ao; 1696 b=b->next; 1697 1698 } else { 1699 a->coef=n2; 1700 b=b->next; 1701 (*set_this)=a; 1702 a=a->next; 1703 set_this= &((*set_this)->next); 1704 } 1705 1706 } 1707 1708 } 1709 } 1710 if((a==NULL)&&(b==NULL)){ 1711 (*set_this)=NULL; 1712 return erg; 1713 } 1714 if (b==NULL) { 1715 (*set_this=a); 1716 return erg; 1717 } 1718 1719 //a==NULL 1720 while(b!=NULL){ 1721 mac_poly mp= new mac_poly_r(); 1722 mp->exp=b->exp; 1723 mp->coef=nMult(f,b->coef); 1724 (*set_this)=mp; 1725 set_this=&(mp->next); 1726 b=b->next; 1727 } 1728 (*set_this)=NULL; 1729 return erg; 1730 1731 } 1732 void mac_mult_cons(mac_poly p,number c){ 1733 while(p){ 1734 number m=nMult(p->coef,c); 1735 nDelete(&(p->coef)); 1736 p->coef=m; 1737 p=p->next; 1738 } 1739 1740 } 1741 int mac_length(mac_poly p){ 1742 int l=0; 1743 while(p){ 1744 l++; 1745 p=p->next; 1746 } 1747 return l; 1748 } 1749 //contrary to delete on the mac_poly_r, the coefficients are also destroyed here 1750 void mac_destroy(mac_poly p){ 1751 mac_poly iter=p; 1752 while(iter) 1753 { 1754 mac_poly next=iter->next; 1755 nDelete(&iter->coef); 1756 delete iter; 1757 iter=next; 1758 } 1759 } 1666 1760 1667 BOOLEAN is_valid_ro(red_object & ro){ 1761 1668 red_object r2=ro; -
kernel/tgb_internal.h
rb055de9 r81306a 103 103 }; 104 104 105 class mac_poly_r{106 public:107 number coef;108 mac_poly_r* next;109 int exp;110 mac_poly_r():next(NULL){}111 };112 //mac_polys exp are smaller iff they are greater by monomial ordering113 //corresponding to solving linear equations notation114 115 typedef mac_poly_r* mac_poly;116 105 117 106 struct poly_array_list{ … … 284 273 285 274 286 287 288 mac_poly mac_p_add_ff_qq(mac_poly a, number f,mac_poly b);289 290 void mac_mult_cons(mac_poly p,number c);291 int mac_length(mac_poly p);292 293 //contrary to delete on the mac_poly_r, the coefficients are also destroyed here294 void mac_destroy(mac_poly p);295 296 297 298 275 #endif -
kernel/tgbgauss.cc
rb055de9 r81306a 3 3 4 4 static const int bundle_size=100; 5 6 mac_poly mac_p_add_ff_qq(mac_poly a, number f,mac_poly b){ 7 mac_poly erg; 8 mac_poly* set_this; 9 set_this=&erg; 10 while((a!=NULL) &&(b!=NULL)){ 11 if (a->exp<b->exp){ 12 (*set_this)=a; 13 a=a->next; 14 set_this= &((*set_this)->next); 15 } 16 else{ 17 if (a->exp>b->exp){ 18 mac_poly in =new mac_poly_r(); 19 in->exp=b->exp; 20 in->coef=nMult(b->coef,f); 21 (*set_this)=in; 22 b=b->next; 23 set_this= &((*set_this)->next); 24 } 25 else { 26 //a->exp==b->ecp 27 number n=nMult(b->coef,f); 28 number n2=nAdd(a->coef,n); 29 nDelete(&n); 30 nDelete(&(a->coef)); 31 if (nIsZero(n2)){ 32 nDelete(&n2); 33 mac_poly ao=a; 34 a=a->next; 35 delete ao; 36 b=b->next; 37 38 } else { 39 a->coef=n2; 40 b=b->next; 41 (*set_this)=a; 42 a=a->next; 43 set_this= &((*set_this)->next); 44 } 45 46 } 47 48 } 49 } 50 if((a==NULL)&&(b==NULL)){ 51 (*set_this)=NULL; 52 return erg; 53 } 54 if (b==NULL) { 55 (*set_this=a); 56 return erg; 57 } 58 59 //a==NULL 60 while(b!=NULL){ 61 mac_poly mp= new mac_poly_r(); 62 mp->exp=b->exp; 63 mp->coef=nMult(f,b->coef); 64 (*set_this)=mp; 65 set_this=&(mp->next); 66 b=b->next; 67 } 68 (*set_this)=NULL; 69 return erg; 70 71 } 72 void mac_mult_cons(mac_poly p,number c){ 73 while(p){ 74 number m=nMult(p->coef,c); 75 nDelete(&(p->coef)); 76 p->coef=m; 77 p=p->next; 78 } 79 80 } 81 int mac_length(mac_poly p){ 82 int l=0; 83 while(p){ 84 l++; 85 p=p->next; 86 } 87 return l; 88 } 89 //contrary to delete on the mac_poly_r, the coefficients are also destroyed here 90 void mac_destroy(mac_poly p){ 91 mac_poly iter=p; 92 while(iter) 93 { 94 mac_poly next=iter->next; 95 nDelete(&iter->coef); 96 delete iter; 97 iter=next; 98 } 99 } 100 5 101 void simple_gauss(tgb_sparse_matrix* mat, calc_dat* c){ 6 102 int col, row; -
kernel/tgbgauss.h
rb055de9 r81306a 4 4 #include "numbers.h" 5 5 #include "tgb_internal.h" 6 6 7 class tgb_matrix{ 7 8 private: … … 28 29 int non_zero_entries(int row); 29 30 }; 31 32 class mac_poly_r{ 33 public: 34 number coef; 35 mac_poly_r* next; 36 int exp; 37 mac_poly_r():next(NULL){} 38 }; 39 //mac_polys exp are smaller iff they are greater by monomial ordering 40 //corresponding to solving linear equations notation 41 42 typedef mac_poly_r* mac_poly; 43 30 44 class tgb_sparse_matrix{ 31 45 private: … … 66 80 void simple_gauss(tgb_sparse_matrix* mat, calc_dat* c); 67 81 void simple_gauss2(tgb_matrix* mat); 82 83 84 85 mac_poly mac_p_add_ff_qq(mac_poly a, number f,mac_poly b); 86 87 void mac_mult_cons(mac_poly p,number c); 88 int mac_length(mac_poly p); 89 90 //contrary to delete on the mac_poly_r, the coefficients are also destroyed here 91 void mac_destroy(mac_poly p); 92 68 93 #endif
Note: See TracChangeset
for help on using the changeset viewer.