Changeset 5dad8b3 in git


Ignore:
Timestamp:
Nov 10, 2010, 3:16:13 PM (13 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', '00e2e9c41af3fde1273eb3633f4c0c7c3db2579d')
Children:
1446e7f6b858dd03816a2e1b9a0c6022428f8b67
Parents:
40157303341732339fd6bc4f53baf18c09715ae0
Message:
more static routines

git-svn-id: file:///usr/local/Singular/svn/trunk@13626 2c84dea3-7e68-4137-9b89-c4e89433aadc
Location:
kernel
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • kernel/polys.cc

    r4015730 r5dad8b3  
    275275    }
    276276#endif
    277    
    278277    p_Setm(rc,r);
    279278  }
    280 finish: 
     279finish:
    281280  return s;
    282281}
     
    354353}
    355354
     355/*4
     356*Returns the exponent of the maximal power of the leading monomial of
     357*p2 in that of p1
     358*/
     359static 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*/
     379static 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//
     407static 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}
    356434/*2
    357435*replaces the maximal powers of the leading monomial of p2 in p1 by
     
    389467}
    390468
    391 /*4
    392 *Returns the exponent of the maximal power of the leading monomial of
    393 *p2 in that of p1
    394 */
    395 static int pGetMaxPower (poly p1,poly p2)
    396 {
    397   int     i,k,res = 32000; /*a very large integer*/
    398 
    399   if (p1 == NULL) return 0;
    400   for (i=1; i<=pVariables; i++)
    401   {
    402     if ( pGetExp(p2,i) != 0)
    403     {
    404       k =  pGetExp(p1,i) /  pGetExp(p2,i);
    405       if (k < res) res = k;
    406     }
    407   }
    408   return res;
    409 }
    410 
    411 /*2
    412 *Returns as i-th entry of P the coefficient of the (i-1) power of
    413 *the leading monomial of p2 in p1
    414 */
    415 void pCancelPolyByMonom (poly p1,poly p2,polyset * P,int * SizeOfSet)
    416 {
    417   int   maxPow;
    418   poly  p,qp,Coeff;
    419 
    420   if (*P == NULL)
    421   {
    422     *P = (polyset) omAlloc(5*sizeof(poly));
    423     *SizeOfSet = 5;
    424   }
    425   p = pCopy(p1);
    426   while (p != NULL)
    427   {
    428     qp = p->next;
    429     p->next = NULL;
    430     maxPow = pGetMaxPower(p,p2);
    431     Coeff = pDivByMonom(p,p2);
    432     if (maxPow > *SizeOfSet)
    433     {
    434       pEnlargeSet(P,*SizeOfSet,maxPow+1-*SizeOfSet);
    435       *SizeOfSet = maxPow+1;
    436     }
    437     (*P)[maxPow] = pAdd((*P)[maxPow],Coeff);
    438     pDelete(&p);
    439     p = qp;
    440   }
    441 }
    442 
    443 /*2
    444 *returns the leading monomial of p1 divided by the maximal power of that
    445 *of p2
    446 */
    447 poly pDivByMonom (poly p1,poly p2)
    448 {
    449   int     k, i;
    450 
    451   if (p1 == NULL) return NULL;
    452   k = pGetMaxPower(p1,p2);
    453   if (k == 0)
    454     return pHead(p1);
    455   else
    456   {
    457     number n;
    458     poly p = pInit();
    459 
    460     p->next = NULL;
    461     for (i=1; i<=pVariables; i++)
    462     {
    463        pSetExp(p,i, pGetExp(p1,i)-k* pGetExp(p2,i));
    464     }
    465     nPower(p2->coef,k,&n);
    466     pSetCoeff0(p,nDiv(p1->coef,n));
    467     nDelete(&n);
    468     pSetm(p);
    469     return p;
    470   }
    471 }
     469
    472470/*----------utilities for syzygies--------------*/
    473471poly pTakeOutComp(poly * p, int k)
  • kernel/polys.h

    r4015730 r5dad8b3  
    365365poly      pDehomogen (poly p1,poly p2,number n);
    366366BOOLEAN   pIsHomogeneous (poly p);
    367 
    368 // returns the leading monomial of p1 divided by the maximal power of
    369 // that of p2
    370 poly      pDivByMonom (poly p1,poly p2);
    371 
    372 // Returns as i-th entry of P the coefficient of the (i-1) power of
    373 // the leading monomial of p2 in p1
    374 void      pCancelPolyByMonom (poly p1,poly p2,polyset * P,int * SizeOfSet);
    375367
    376368poly      pPermPoly (poly p, int * perm,const ring OldRing, nMapFunc nMap,
Note: See TracChangeset for help on using the changeset viewer.