Changeset bba835 in git
- Timestamp:
- May 3, 2007, 3:27:45 PM (16 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', '0604212ebb110535022efecad887940825b97c3f')
- Children:
- 75ae36afc86628e8325b039c42ab23fe91876b39
- Parents:
- 52e38fce6d01c11b7934d7b1830db574af0f6983
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/iparith.cc
r52e38fc rbba835 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: iparith.cc,v 1.44 4 2007-03-22 13:34:52 Singular Exp $ */4 /* $Id: iparith.cc,v 1.445 2007-05-03 13:27:42 Singular Exp $ */ 5 5 6 6 /* … … 1684 1684 return FALSE; 1685 1685 } 1686 #if 0 1686 1687 static BOOLEAN jjCHINREM_P(leftv res, leftv u, leftv v) 1687 1688 { 1688 #if 0 1689 ideal c=(ideal)u->CopyD(); 1689 lists c=(lists)u->CopyD(); // list of poly 1690 1690 intvec* p=(intvec*)v->Data(); 1691 1691 int rl=p->length(); 1692 poly r=NULL,h ;1692 poly r=NULL,h, result=NULL; 1693 1693 number *x=(number *)omAlloc(rl*sizeof(number)); 1694 1694 number *q=(number *)omAlloc(rl*sizeof(number)); … … 1698 1698 q[i]=nlInit((*p)[i]); 1699 1699 } 1700 // for each monom 1701 //number n=nlChineseRemainder(x,q,rl); 1700 loop 1701 { 1702 for(i=rl-1;i>=0;i--) 1703 { 1704 if (c->m[i].Typ()!=POLY_CMD) 1705 { 1706 Werror("poly expected at pos %d",i+1); 1707 for(i=rl-1;i>=0;i--) 1708 { 1709 nlDelete(&(q[i]),currRing); 1710 } 1711 omFree(x); omFree(q); // delete c 1712 return TRUE; 1713 } 1714 h=((poly)c->m[i].Data()); 1715 if (r==NULL) r=h; 1716 else if (pLmCmp(r,h)==-1) r=h; 1717 } 1718 if (r==NULL) break; 1719 for(i=rl-1;i>=0;i--) 1720 { 1721 h=((poly)c->m[i].Data()); 1722 if (pLmCmp(r,h)==0) 1723 { 1724 x[i]=pGetCoeff(h); 1725 h=pLmFreeAndNext(h); 1726 c->m[i].data=(char*)h; 1727 } 1728 else 1729 x[i]=nlInit(0); 1730 } 1731 number n=nlChineseRemainder(x,q,rl); 1732 for(i=rl-1;i>=0;i--) 1733 { 1734 nlDelete(&(x[i]),currRing); 1735 } 1736 h=pHead(r); 1737 pSetCoeff(h,n); 1738 result=pAdd(result,h); 1739 } 1702 1740 for(i=rl-1;i>=0;i--) 1703 1741 { … … 1705 1743 } 1706 1744 omFree(x); omFree(q); 1707 res->data=(char *)r; 1708 return FALSE; 1709 #else 1710 return TRUE; // not yet implemented 1745 res->data=(char *)result; 1746 return FALSE; 1747 } 1711 1748 #endif 1749 static BOOLEAN jjCHINREM_ID(leftv res, leftv u, leftv v) 1750 { 1751 lists c=(lists)u->CopyD(); // list of ideal 1752 intvec* p=(intvec*)v->Data(); 1753 int rl=p->length(); 1754 poly r=NULL,h; 1755 ideal result; 1756 ideal *x=(ideal *)omAlloc(rl*sizeof(ideal)); 1757 int i; 1758 for(i=rl-1;i>=0;i--) 1759 { 1760 if (c->m[i].Typ()!=IDEAL_CMD) 1761 { 1762 Werror("ideal expected at pos %d",i+1); 1763 omFree(x); // delete c 1764 return TRUE; 1765 } 1766 x[i]=((ideal)c->m[i].Data()); 1767 } 1768 number *q=(number *)omAlloc(rl*sizeof(number)); 1769 for(i=rl-1;i>=0;i--) 1770 { 1771 q[i]=nlInit((*p)[i]); 1772 } 1773 result=idChineseRemainder(x,q,rl); 1774 for(i=rl-1;i>=0;i--) 1775 { 1776 nlDelete(&(q[i]),currRing); 1777 } 1778 omFree(q); 1779 res->data=(char *)result; 1780 return FALSE; 1712 1781 } 1713 1782 static BOOLEAN jjCOEF(leftv res, leftv u, leftv v) … … 3107 3176 #endif 3108 3177 ,{jjCHINREM_BI,CHINREM_CMD, BIGINT_CMD, INTVEC_CMD, INTVEC_CMD ALLOW_PLURAL} 3109 ,{jjCHINREM_P, CHINREM_CMD, POLY_CMD, IDEAL_CMD, IDEAL_CMD ALLOW_PLURAL} 3178 //,{jjCHINREM_P, CHINREM_CMD, POLY_CMD, LIST_CMD, INTVEC_CMD ALLOW_PLURAL} 3179 ,{jjCHINREM_ID,CHINREM_CMD, IDEAL_CMD, LIST_CMD, INTVEC_CMD ALLOW_PLURAL} 3110 3180 ,{jjCOEF, COEF_CMD, MATRIX_CMD, POLY_CMD, POLY_CMD ALLOW_PLURAL} 3111 3181 ,{jjCOEFFS_Id, COEFFS_CMD, MATRIX_CMD, IDEAL_CMD, POLY_CMD ALLOW_PLURAL} -
kernel/clapconv.cc
r52e38fc rbba835 3 3 * Computer Algebra System SINGULAR * 4 4 ****************************************/ 5 // $Id: clapconv.cc,v 1. 8 2007-03-15 14:24:03Singular Exp $5 // $Id: clapconv.cc,v 1.9 2007-05-03 13:27:45 Singular Exp $ 6 6 /* 7 7 * ABSTRACT: convert data between Singular and factory … … 730 730 chineseRemainder(X,Q,xnew,qnew); 731 731 number n=convClapNSingN(xnew); 732 number p=convClapNSingN(qnew); 733 number p2=nlIntDiv(p,nlInit(2)); 734 if (nlGreater(n,p2)) 735 { 736 number n2=nlSub(n,p); 737 nlDelete(&n,currRing); 738 n=n2; 739 } 740 nlDelete(&p,currRing); 741 nlDelete(&p2,currRing); 732 742 return n; 733 743 #else -
kernel/ideals.cc
r52e38fc rbba835 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: ideals.cc,v 1.4 1 2007-04-03 15:16:39Singular Exp $ */4 /* $Id: ideals.cc,v 1.42 2007-05-03 13:27:44 Singular Exp $ */ 5 5 /* 6 6 * ABSTRACT - all basic methods to manipulate ideals … … 13 13 #include "febase.h" 14 14 #include "numbers.h" 15 #include "longrat.h" 15 16 #include "polys.h" 16 17 #include "ring.h" … … 3694 3695 return gcd_p; 3695 3696 } 3697 3698 /*2 3699 * xx,q: arrays of length 0..rl-1 3700 * xx[i]: SB mod q[i] 3701 * assume: char=0 3702 * assume: q[i]!=0 3703 * destroys xx 3704 */ 3705 ideal idChineseRemainder(ideal *xx, number *q, int rl) 3706 { 3707 ideal result=idInit(IDELEMS(xx[0]),1); 3708 int i,j; 3709 poly r,h,res_p; 3710 number *x=(number *)omAlloc(rl*sizeof(number)); 3711 for(i=IDELEMS(result)-1;i>=0;i--) 3712 { 3713 res_p=NULL; 3714 loop 3715 { 3716 r=NULL; 3717 for(j=rl-1;j>=0;j--) 3718 { 3719 h=xx[j]->m[i]; 3720 if ((r==NULL)||(pLmCmp(r,h)==-1)) r=h; 3721 } 3722 if (r==NULL) break; 3723 for(j=rl-1;j>=0;j--) 3724 { 3725 h=xx[j]->m[i]; 3726 if (pLmCmp(r,h)==0) 3727 { 3728 x[j]=pGetCoeff(h); 3729 h=pLmFreeAndNext(h); 3730 xx[j]->m[i]=h; 3731 } 3732 else 3733 x[j]=nlInit(0); 3734 } 3735 number n=nlChineseRemainder(x,q,rl); 3736 for(j=rl-1;j>=0;j--) 3737 { 3738 nlDelete(&(x[j]),currRing); 3739 } 3740 h=pHead(r); 3741 pSetCoeff(h,n); 3742 res_p=pAdd(res_p,h); 3743 } 3744 result->m[i]=res_p; 3745 } 3746 omFree(x); 3747 for(i=rl-1;i>=0;i--) idDelete(&(xx[i])); 3748 omFree(xx); 3749 return result; 3750 } -
kernel/ideals.h
r52e38fc rbba835 4 4 * Computer Algebra System SINGULAR * 5 5 ****************************************/ 6 /* $Id: ideals.h,v 1. 7 2007-01-10 17:17:27Singular Exp $ */6 /* $Id: ideals.h,v 1.8 2007-05-03 13:27:44 Singular Exp $ */ 7 7 /* 8 8 * ABSTRACT - all basic methods to manipulate ideals … … 155 155 156 156 poly id_GCD(poly f, poly g, const ring r); 157 158 ideal idChineseRemainder(ideal *x, number *q, int rl); 157 159 #endif
Note: See TracChangeset
for help on using the changeset viewer.