Changeset 66bff8 in git


Ignore:
Timestamp:
Dec 2, 2010, 4:53:31 PM (13 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
722db68fa52e40537a49b654c41d22424285d092
Parents:
c3005ea46d9ce4dea15139c365c248317f216023
Message:
code cleanup: pGetMaxPower, pDivByMonom, pCancelPolyByMonom

git-svn-id: file:///usr/local/Singular/svn/trunk@13701 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/polys.cc

    rc3005ea r66bff8  
    357357*p2 in that of p1
    358358*/
    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 /*2
    376 *returns the leading monomial of p1 divided by the maximal power of that
    377 *of p2
    378 */
    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   else
    388   {
    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 of
    405 // the leading monomial of p2 in p1
    406 //
    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 
    435359/*----------utilities for syzygies--------------*/
    436360poly pTakeOutComp(poly * p, int k)
Note: See TracChangeset for help on using the changeset viewer.