Changeset 66bff8 in git
- Timestamp:
- Dec 2, 2010, 4:53:31 PM (12 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', '0604212ebb110535022efecad887940825b97c3f')
- Children:
- 722db68fa52e40537a49b654c41d22424285d092
- Parents:
- c3005ea46d9ce4dea15139c365c248317f216023
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/polys.cc
rc3005ea r66bff8 357 357 *p2 in that of p1 358 358 */ 359 static int pGetMaxPower (poly p1,poly p2)360 {361 int i,k,res = 32000; /*a very large integer*/362 363 if (p1 == NULL) return 0;364 for (i=1; i<=pVariables; i++)365 {366 if ( pGetExp(p2,i) != 0)367 {368 k = pGetExp(p1,i) / pGetExp(p2,i);369 if (k < res) res = k;370 }371 }372 return res;373 }374 375 /*2376 *returns the leading monomial of p1 divided by the maximal power of that377 *of p2378 */379 static poly pDivByMonom (poly p1,poly p2)380 {381 int k, i;382 383 if (p1 == NULL) return NULL;384 k = pGetMaxPower(p1,p2);385 if (k == 0)386 return pHead(p1);387 else388 {389 number n;390 poly p = pInit();391 392 p->next = NULL;393 for (i=1; i<=pVariables; i++)394 {395 pSetExp(p,i, pGetExp(p1,i)-k* pGetExp(p2,i));396 }397 nPower(p2->coef,k,&n);398 pSetCoeff0(p,nDiv(p1->coef,n));399 nDelete(&n);400 pSetm(p);401 return p;402 }403 }404 // Returns as i-th entry of P the coefficient of the (i-1) power of405 // the leading monomial of p2 in p1406 //407 static void pCancelPolyByMonom (poly p1,poly p2,polyset * P,int * SizeOfSet)408 {409 int maxPow;410 poly p,qp,Coeff;411 412 if (*P == NULL)413 {414 *P = (polyset) omAlloc(5*sizeof(poly));415 *SizeOfSet = 5;416 }417 p = pCopy(p1);418 while (p != NULL)419 {420 qp = p->next;421 p->next = NULL;422 maxPow = pGetMaxPower(p,p2);423 Coeff = pDivByMonom(p,p2);424 if (maxPow > *SizeOfSet)425 {426 pEnlargeSet(P,*SizeOfSet,maxPow+1-*SizeOfSet);427 *SizeOfSet = maxPow+1;428 }429 (*P)[maxPow] = pAdd((*P)[maxPow],Coeff);430 pDelete(&p);431 p = qp;432 }433 }434 435 359 /*----------utilities for syzygies--------------*/ 436 360 poly pTakeOutComp(poly * p, int k)
Note: See TracChangeset
for help on using the changeset viewer.