Changeset 311499 in git for Singular/polys.inc
- Timestamp:
- May 28, 1998, 6:50:55 PM (26 years ago)
- Branches:
- (u'spielwiese', '2a584933abf2a2d3082034c7586d38bb6de1a30a')
- Children:
- 3939bce4295208a7c089668825e3a510f02ca7a7
- Parents:
- 27b7998492f70ad316fe2f33dee8479b2b99a977
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/polys.inc
r27b799 r311499 19 19 /* pVariables=pdN*2+1+pdK */ 20 20 21 void pdSetDFlag (poly p, int i)21 void pdSetDFlagP(poly p, int i) 22 22 { 23 23 while (p!=NULL) 24 24 { 25 pd DFlag(p)=1;25 pdSetDFlag(p,1); 26 26 pSetm(p); 27 27 pIter(p); … … 39 39 poly e2=pOne(); 40 40 41 pd DFlag(e1)=1;42 pd DFlag(e2)=1;41 pdSetDFlag(e1,1); 42 pdSetDFlag(e2,1); 43 43 number t; 44 44 45 45 if (x==1) 46 46 { 47 e1->exp[pdX(n)]=1;48 e1->exp[pdDX(n)]=d;47 pSetExp(e1,pdX(n),1); 48 pSetExp(e1,pdDX(n),d); 49 49 pSetm(e1); 50 50 pNext(e1)=e2; 51 e2->exp[pdDX(n)]=d-1;51 pSetExp(e2,pdDX(n),d-1); 52 52 t = nInit(d); 53 53 pSetCoeff(e2,t); … … 56 56 else if (d==1) 57 57 { 58 e1->exp[pdX(n)]=x;59 e1->exp[pdDX(n)]=1;58 pSetExp(e1,pdX(n),x); 59 pSetExp(e1,pdDX(n),1); 60 60 pSetm(e1); 61 61 pNext(e1)=e2; 62 e2->exp[n]=x-1;62 pSetExp(e2,n,x-1); 63 63 t = nInit(x); 64 64 pSetCoeff(e2,t); … … 72 72 poly h=NULL; 73 73 74 e1->exp[pdX(n)]=x;75 e1->exp[pdDX(n)]=d;74 pSetExp(e1,pdX(n),x); 75 pSetExp(e1,pdDX(n),d); 76 76 pSetm(e1); 77 77 for (j=1;j<=min(x,d);j++) … … 82 82 p *= (d-k); 83 83 } 84 e2->exp[pdX(n)]=x-j;85 e2->exp[pdDX(n)]=d-j;84 pSetExp(e2,pdX(n),x-j); 85 pSetExp(e2,pdDX(n),d-j); 86 86 pSetm(e2); 87 87 tp=0; … … 114 114 short c; /* the component number of the result*/ 115 115 116 if( c=pGetComp(a))116 if((c=pGetComp(a))!=0) 117 117 { 118 118 #ifdef TEST 119 if (pGetComp(b) )119 if (pGetComp(b)!=0) 120 120 { 121 121 Werror("mult vector * vector"); … … 127 127 c=pGetComp(b); 128 128 129 pd DFlag(resl)=1;130 pd DFlag(resr)=1;129 pdSetDFlag(resl,1); 130 pdSetDFlag(resr,1); 131 131 pSetCoeff(resl,nCopy(pGetCoeff(a))); 132 132 // put all x from a to the left result resl, … … 134 134 for (i=1;i<=pdN;i++) 135 135 { 136 resl->exp[pdX(i)]=a->exp[pdX(i)];137 resr->exp[pdDX(i)]=b->exp[pdDX(i)];136 pSetExp(resl,pdX(i),pGetExp(a,pdX(i))); 137 pSetExp(resr,pdDX(i),pGetExp(b,pdDX(i))); 138 138 } 139 139 // put all commutative vars y to the right result resr 140 140 for (i=1;i<=pdK;i++) 141 141 { 142 resr->exp[pdY(i)]=a->exp[pdY(i)]+b->exp[pdY(i)];142 pSetExp(resr,pdY(i),pGetExp(a,pdY(i))+pGetExp(b,pdY(i))); 143 143 } 144 144 // set the component number … … 147 147 { 148 148 if ((a->exp[pdDX(i)] !=0) && (b->exp[pdX(i)] !=0)) 149 if ((pGetExp(a,pdDX(i)) !=0) && (pGetExp(b,pdX(i)) !=0)) 149 150 { 150 151 if (multiply!=NULL) 151 152 { 152 multiply=pMult(multiply,comm(i, a->exp[pdDX(i)],b->exp[pdX(i)]));153 multiply=pMult(multiply,comm(i,pGetExp(a,pdDX(i)),pGetExp(b,pdX(i)))); 153 154 } 154 155 else 155 156 { 156 multiply=comm(i, a->exp[pdDX(i)],b->exp[pdX(i)]);157 multiply=comm(i,pGetExp(a,pdDX(i)),pGetExp(b,pdX(i))); 157 158 } 158 159 } 159 160 else 160 161 { 161 resl->exp[pdX(i)] += b->exp[pdX(i)];162 resr->exp[pdDX(i)] += a->exp[pdDX(i)];162 pSetExp(resl,pdX(i),pGetExp(resl,pdX(i))+pGetExp(b,pdX(i))); 163 pSetExp(resr,pdDX(i),pGetExp(resr,pdDX(i))+pGetExp(a,pdDX(i))); 163 164 } 164 165 } … … 174 175 // now resl has only powers of x(i) and y(i), resr has only powers of d(i): 175 176 for (i=1;i<=pdN;i++) 176 resl->exp[pdDX(i)]=resr->exp[pdDX(i)]; 177 { 178 pSetExp(resl,pdDX(i),pGetExp(resr,pdDX(i))); 179 } 177 180 pSetm(resl); 178 181 pFree1(resr); … … 190 193 short c; /* the component number of the result*/ 191 194 192 if( c=pGetComp(a))195 if((c=pGetComp(a))!=0) 193 196 { 194 197 #ifdef TEST 195 if (pGetComp(b) )198 if (pGetComp(b)!=0) 196 199 { 197 200 Werror("mult vector * vector"); … … 206 209 for (i=1;i<=pdN;i++) 207 210 { 208 if (( a->exp[pdDX(i)] > b->exp[pdX(i)])209 && ( b->exp[pdIX(i)]==0))211 if ((pGetExp(a,pdDX(i)) > pGetExp(b,pdX(i))) 212 && (pGetExp(b,pdIX(i))==0)) 210 213 return NULL; 211 214 } 212 215 poly resl=pOne(); 213 pd DFlag(resl)=0;216 pdSetDFlag(resl,0); 214 217 pSetCoeff(resl,nCopy(pGetCoeff(a))); 215 218 // put all x from a to the left result resl 216 219 for (i=1;i<=pdN;i++) 217 220 { 218 resl->exp[pdX(i)]=a->exp[pdX(i)];221 pSetExp(resl,pdX(i),pGetExp(a,pdX(i))); 219 222 } 220 223 // put all commutative vars y to the left result resl 221 224 for (i=1;i<=pdK;i++) 222 225 { 223 resl->exp[pdY(i)]=a->exp[pdY(i)]+b->exp[pdY(i)];226 pSetExp(resl,pdY(i),pGetExp(a,pdY(i))+pGetExp(b,pdY(i))); 224 227 } 225 228 // set the component number … … 229 232 for (i=1;i<=pdN;i++) 230 233 { 231 if (((p= a->exp[pdDX(i)]) !=0) && ((q=b->exp[pdX(i)]) !=0))234 if (((p=pGetExp(a,pdDX(i))) !=0) && ((q=pGetExp(b,pdX(i))) !=0)) 232 235 { 233 236 // d^p(x^q): q*(q-1)*...*(q-p+1)* x^(q-p) 234 resl->exp[pdX(i)]+=q-p;237 pSetExp(resl,pdX(i),pGetExp(resl,pdX(i))+q-p); 235 238 n=nInit(q); 236 239 q--;p--; … … 250 253 } 251 254 else 252 if (((p= a->exp[pdDX(i)]) !=0) && ((q=b->exp[pdIX(i)]) !=0))255 if (((p=pGetExp(a,pdDX(i))) !=0) && ((q=pGetExp(b,pdIX(i))) !=0)) 253 256 { 254 257 // d^p(x^(-q)): (-1)^p*q*(q+1)*...*(q+p-1)* x^(-(q+p)) 255 resl->exp[pdIX(i)]+=q+p;258 pSetExp(resl,pdIX(i),pGetExp(resl,pdIX(i))+q+p); 256 259 if (p & 1) n=nInit(-q); 257 260 else n=nInit(q); … … 273 276 else 274 277 { 275 resl->exp[pdX(i)]+=b->exp[pdX(i)];276 resl->exp[pdIX(i)]+=b->exp[pdIX(i)];278 pSetExp(resl,pdX(i),pGetExp(resl,pdX(i))+pGetExp(b,pdX(i))); 279 pSetExp(resl,pdIX(i),pGetExp(resl,pdIX(i))+pGetExp(b,pdIX(i))); 277 280 } 278 281 } 279 282 for(i=1;i<=pdN;i++) 280 283 { 281 if ( resl->exp[pdX(i)]>=resl->exp[pdIX(i)])282 { 283 resl->exp[pdX(i)]-=resl->exp[pdIX(i)];284 resl->exp[pdIX(i)]=0;284 if (pGetExp(resl,pdX(i))>=pGetExp(resl,pdIX(i))) 285 { 286 pSetExp(resl,pdX(i),pGetExp(resl,pdX(i))-pGetExp(resl,pdIX(i))); 287 pSetExp(resl,pdIX(i),0); 285 288 } 286 289 else 287 290 { 288 resl->exp[pdIX(i)]-=resl->exp[pdX(i)];289 resl->exp[pdX(i)]=0;291 pSetExp(resl,pdIX(i),pGetExp(resl,pdIX(i))-pGetExp(resl,pdX(i))); 292 pSetExp(resl,pdX(i),0); 290 293 } 291 294 } … … 303 306 short c; /* the component number of the result*/ 304 307 305 if( c=pGetComp(a))308 if((c=pGetComp(a))!=0) 306 309 { 307 310 #ifdef TEST 308 if (pGetComp(b) )311 if (pGetComp(b)!=0) 309 312 { 310 313 Werror("mult vector * vector"); … … 318 321 poly resl=pOne(); 319 322 int t; 320 pd DFlag(resl)=0;323 pdSetDFlag(resl,0); 321 324 pSetCoeff(resl,nCopy(pGetCoeff(a))); 322 325 for (i=1;i<=pdN;i++) 323 326 { 324 t= a->exp[pdX(i)]+b->exp[pdX(i)]-a->exp[pdIX(i)]-b->exp[pdIX(i)];325 if (t>=0) resl->exp[pdX(i)]=t;326 else resl->exp[pdIX(i)]=-t;327 t=pGetExp(a,pdX(i))+pGetExp(b,pdX(i))-pGetExp(a,pdIX(i))-pGetExp(b,pdIX(i)); 328 if (t>=0) pSetExp(resl,pdX(i),t); 329 else pSetExp(resl,pdIX(i),-t); 327 330 } 328 331 // put all commutative vars y to the result resl 329 332 for (i=1;i<=pdK;i++) 330 333 { 331 resl->exp[pdY(i)]=a->exp[pdY(i)]+b->exp[pdY(i)];334 pSetExp(resl,pdY(i),pGetExp(a,pdY(i))+pGetExp(b,pdY(i))); 332 335 } 333 336 // set the component number … … 544 547 q=pOne(); 545 548 pSetExp(q,pdDX(an),pGetExp(p,pdX(an))+1); 546 pd DFlag(q)=1;549 pdSetDFlag(q,1); 547 550 pSetm(q); 548 551 //Print("1: q ");wrp(q); Print("\n"); … … 570 573 pSetExp(q,pdX(an),pGetExp(p,pdIX(an))); 571 574 pSetExp(dif,pdDX(an),1); 572 pd DFlag(q)=1;573 pd DFlag(dif)=1;575 pdSetDFlag(q,1); 576 pdSetDFlag(dif,1); 574 577 pSetm(q); 575 578 //Print("2: q ");wrp(q); Print("\n"); … … 604 607 for (i=2*pdN; i>=0; i--) 605 608 { 606 m->exp[i] = min(a->exp[i],b->exp[i]);609 pSetExp(m,i, min(pGetExp(a,i),pGetExp(b,i))); 607 610 } 608 611 for (i=pdY(1); i<=pdK; i++) 609 612 { 610 m->exp[i] = max(a->exp[i],b->exp[i]);613 pSetExp(m,i, max(pGetExp(a,i),pGetExp(b,i))); 611 614 } 612 615 }
Note: See TracChangeset
for help on using the changeset viewer.