Changeset a6a239 in git for Singular/polys.cc
- Timestamp:
- Sep 12, 2000, 6:01:23 PM (24 years ago)
- Branches:
- (u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', '38dfc5131670d387a89455159ed1e071997eec94')
- Children:
- fe7bd4983d0c4322efb17bf36dbf3b28109b9608
- Parents:
- 47e83c37a0601dd5b7dadba83e9c5b04d7efeaf1
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/polys.cc
r47e83c3 ra6a239 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: polys.cc,v 1. 59 2000-09-07 10:02:54 sulandraExp $ */4 /* $Id: polys.cc,v 1.60 2000-09-12 16:01:10 obachman Exp $ */ 5 5 6 6 /* … … 20 20 #include "ring.h" 21 21 #include "binom.h" 22 #include "polys-comp.h"23 22 24 23 /* ----------- global variables, set by pSetGlobals --------------------- */ … … 78 77 /*-------- the several possibilities for pSetm:-----------------------*/ 79 78 80 void rSetm(poly p)79 void p_Setm(poly p, ring r) 81 80 { 82 81 int pos=0; 83 if ( currRing->typ!=NULL)82 if (r->typ!=NULL) 84 83 { 85 84 loop 86 85 { 87 sro_ord* o=&( currRing->typ[pos]);86 sro_ord* o=&(r->typ[pos]); 88 87 switch(o->ord_typ) 89 88 { … … 94 93 e=o->data.dp.end; 95 94 long ord=0; //0x40000000; 96 for(int i=a;i<=e;i++) ord+=p GetExp(p,i);97 p->exp .l[o->data.dp.place]=ord;95 for(int i=a;i<=e;i++) ord+=p_GetExp(p,i,r); 96 p->exp[o->data.dp.place]=ord; 98 97 break; 99 98 } … … 105 104 int *w=o->data.wp.weights; 106 105 long ord=0; //0x40000000; 107 for(int i=a;i<=e;i++) ord+=p GetExp(p,i)*w[i-a];108 p->exp .l[o->data.wp.place]=ord;106 for(int i=a;i<=e;i++) ord+=p_GetExp(p,i,r)*w[i-a]; 107 p->exp[o->data.wp.place]=ord; 109 108 break; 110 109 } … … 115 114 e=o->data.cp.end; 116 115 int pl=o->data.cp.place; 117 118 for(int i=a;i<=e;i++) { p->exp .l[pl]=pGetExp(p,i); pl++; }119 120 for(int i=a;i<=e;i++) { p->exp.e[pl]=p GetExp(p,i); pl++; }121 116 #ifdef HAVE_SHIFTED_EXPONENTS 117 for(int i=a;i<=e;i++) { p->exp[pl]=p_GetExp(p,i,r); pl++; } 118 #else 119 for(int i=a;i<=e;i++) { p->exp.e[pl]=p_GetExp(p,i,r); pl++; } 120 #endif 122 121 break; 123 122 } 124 123 case ro_syzcomp: 125 124 { 126 int c=p GetComp(p);125 int c=p_GetComp(p,r); 127 126 long sc = c; 128 127 if (o->data.syzcomp.ShiftedComponents != NULL) … … 134 133 assume(c == 0 || sc != 0); 135 134 } 136 p->exp .l[o->data.syzcomp.place]=sc;135 p->exp[o->data.syzcomp.place]=sc; 137 136 break; 138 137 } … … 141 140 int c=pGetComp(p); 142 141 if (c > o->data.syz.limit) 143 p->exp .l[o->data.syz.place] = o->data.syz.curr_index;142 p->exp[o->data.syz.place] = o->data.syz.curr_index; 144 143 else if (c > 0) 145 p->exp .l[o->data.syz.place]= o->data.syz.syz_index[c];144 p->exp[o->data.syz.place]= o->data.syz.syz_index[c]; 146 145 else 147 146 { 148 147 assume(c == 0); 149 p->exp .l[o->data.syz.place]= 0;148 p->exp[o->data.syz.place]= 0; 150 149 } 151 150 break; … … 179 178 long ord=0; 180 179 for(int i=a;i<=e;i++) ord+=pGetExp(p,i); 181 p->exp .l[o->data.dp.place]=ord;180 p->exp[o->data.dp.place]=ord; 182 181 break; 183 182 } … … 190 189 long ord=0; 191 190 for(int i=a;i<=e;i++) ord+=pGetExp(p,i)*w[i-a]; 192 p->exp .l[o->data.wp.place]=ord;191 p->exp[o->data.wp.place]=ord; 193 192 break; 194 193 } … … 200 199 int pl=o->data.cp.place; 201 200 #ifdef HAVE_SHIFTED_EXPONENTS 202 for(int i=a;i<=e;i++) { p->exp .l[pl]=pGetExp(p,i); pl++; }201 for(int i=a;i<=e;i++) { p->exp[pl]=pGetExp(p,i); pl++; } 203 202 #else 204 203 for(int i=a;i<=e;i++) { p->exp.e[pl]=pGetExp(p,i); pl++; } … … 208 207 case ro_syzcomp: 209 208 { 210 #if 1211 209 int c=pGetComp(p); 212 210 long sc = ShiftedComponents[Components[c]]; 213 211 assume(c == 0 || Components[c] != 0); 214 212 assume(c == 0 || sc != 0); 215 p->exp.l[o->data.syzcomp.place]=sc; 216 #endif 213 p->exp[o->data.syzcomp.place]=sc; 217 214 break; 218 215 } … … 249 246 250 247 251 /*---------------------------------------------------*/252 253 int pComp(poly p1, poly p2)254 {255 if (p2==NULL)256 return 1;257 if (p1==NULL)258 return -1;259 return pComp0(p1,p2);260 }261 248 262 249 … … 293 280 294 281 //if (CompP1==CompP2) return pCompOld(p1,p2); 295 if (CompP1==CompP2) return p Comp0(p1,p2);282 if (CompP1==CompP2) return pLmCmp(p1,p2); 296 283 pSetComp(p1,cP1); 297 284 pSetComp(p2,cP2); 298 285 //result = pCompOld(p1,p2); 299 result = p Comp0(p1,p2);286 result = pLmCmp(p1,p2); 300 287 pSetComp(p1,CompP1); 301 288 pSetComp(p2,CompP2); … … 382 369 for (i=indexShift;i<maxSchreyer;i++) 383 370 SchreyerOrd[i] = pGetComp(nextOrder[i-indexShift]); 384 //pCompOld = p Comp0;385 //p Comp0= mcompSchrM;371 //pCompOld = pLmCmp; 372 //pLmCmp = mcompSchrM; 386 373 pLDegOld = pLDeg; 387 374 pLDeg = ldegSchrM; … … 395 382 maxSchreyer = 0; 396 383 indexShift = 0; 397 //p Comp0= pCompOld;384 //pLmCmp = pCompOld; 398 385 pLDeg = pLDegOld; 399 386 } … … 428 415 int pTotaldegree(poly p) 429 416 { 430 return pExpQuerSum(p);417 return (int) pExpVectorQuerSum(p); 431 418 } 432 419 … … 801 788 test &= ~Sy_bit(OPT_REDTAIL); /* noredTail */ 802 789 } 803 pSetm=rSetm;804 790 } 805 791 if (pFDeg!=pWTotaldegree) pFDeg=pTotaldegree; 806 }807 808 809 static Exponent_t pMultT_nok = 0;810 811 #ifndef HAVE_P_PROCS812 /* -------------------------------------------------------- */813 /*2814 * update the polynomial a by multipying it by815 * the (number) coefficient816 * and the exponent vector (of) exp (a well initialized polynomial)817 */818 poly pMultT(poly a, poly exp )819 {820 int i;821 number t,x,y=pGetCoeff(exp);822 poly aa=a;823 poly prev=NULL;824 825 pMultT_nok = pGetComp(exp);826 #ifdef PDEBUG827 pTest(a);828 pTest(exp);829 #endif830 while (a !=NULL)831 {832 x=pGetCoeff(a);833 t=nMult(x/*pGetCoeff(a)*/,y/*pGetCoeff(exp)*/);834 nDelete(&x/*pGetCoeff(a)*/);835 pSetCoeff0(a,t);836 if (nIsZero(t))837 {838 if (prev==NULL) { pDelete1(&a); aa=a; }839 else { pDelete1(&prev->next); a=prev->next;}840 }841 else842 {843 {844 if (pMultT_nok) /* comp of exp != 0 */845 {846 if (pGetComp(a) != 0)847 {848 return NULL /*FALSE*/;849 }850 }851 pMonAddOn(a,exp);852 }853 prev=a;854 pIter(a);855 }856 }857 pMultT_nok=0;858 pTest(aa);859 return aa; /*TRUE*/860 }861 862 863 /*2864 * update a by multiplying it with c (c will not be destroyed)865 */866 void pMultN(poly a, number c)867 {868 number t;869 870 while (a!=NULL)871 {872 t=nMult(pGetCoeff(a), c);873 //nNormalize(t);874 pSetCoeff(a,t);875 pIter(a);876 }877 }878 879 /*2880 * return a copy of the poly a times the number c (a,c will not be destroyed)881 */882 poly pMultCopyN(poly a, number c)883 {884 poly result=NULL,hp;885 886 if (a != NULL)887 {888 result=pNew();889 pCopy2(result,a);890 pNext(result)=NULL;891 pGetCoeff(result)=nMult(pGetCoeff(a),c);892 pIter(a);893 hp=result;894 while (a!=NULL)895 {896 hp=pNext(hp)=pNew();897 pCopy2(hp,a);898 pSetCoeff0(hp,nMult(pGetCoeff(a), c));899 pIter(a);900 }901 pNext(hp)=NULL;902 }903 return result;904 }905 906 /*2907 * multiply p1 with p2, p1 and p2 are destroyed908 * do not put attention on speed: the procedure is only used in the interpreter909 */910 911 #endif912 913 #ifdef HAVE_P_PROCS914 poly pMult_Old(poly p1, poly p2)915 #else916 poly pMult(poly p1, poly p2)917 #endif918 {919 poly res, r, rn, a;920 BOOLEAN cont;921 922 if ((p1!=NULL) && (p2!=NULL))923 {924 #ifdef PDEBUG925 pTest(p1);926 pTest(p2);927 #endif928 cont = TRUE;929 a = p1;930 if (pNext(p2)!=NULL)931 a = pCopy(a);932 else933 cont = FALSE;934 res = pMultT(a, p2);935 if (pMultT_nok)936 {937 if (cont) pDelete(&p1);938 pDelete(&res);939 pDelete(&p2);940 return NULL;941 }942 pTest(res);943 pDelete1(&p2);944 r = res;945 if (r!=NULL) rn = pNext(r);946 else rn=NULL;947 while (cont)948 {949 if (pNext(p2)==NULL)950 {951 a = p1;952 cont = FALSE;953 }954 else955 {956 a = pCopy(p1);957 }958 a=pMultT(a, p2); //sets pMultT_nok959 pTest(a);960 if (pMultT_nok)961 {962 if (cont) pDelete(&p1);963 pDelete(&a);964 pDelete(&res);965 pDelete(&p2);966 return NULL;967 }968 while ((rn!=NULL) && (pComp0(rn,a)>0))969 {970 r = rn;971 pIter(rn);972 }973 if (r!=NULL) pNext(r) = rn = pAdd(a, rn);974 else res=r=a;975 pDelete1(&p2);976 }977 pTest(res);978 return res;979 }980 pDelete(&p1);981 pDelete(&p2);982 return NULL;983 792 } 984 793 … … 991 800 { 992 801 int i; 993 poly result =pInit();802 poly result = pInit(); 994 803 995 804 for(i=(int)pVariables; i; i--) … … 1037 846 } 1038 847 } 1039 pMult N(result,inv);848 pMult_nn(result,inv); 1040 849 nDelete(&inv); 1041 850 pDelete(&b); … … 1176 985 { 1177 986 nPower(n,i,&nn); 1178 pMult N(P[i],nn);987 pMult_nn(P[i],nn); 1179 988 p = pAdd(p,P[i]); 1180 989 //P[i] =NULL; // for safety, may be removed later
Note: See TracChangeset
for help on using the changeset viewer.