Changeset 5162db in git for polys


Ignore:
Timestamp:
Nov 8, 2010, 6:10:18 PM (13 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', '4a9821a93ffdc22a6696668bd4f6b8c9de3e6c5f')
Children:
041dfe18affe0cfc2ab3f798958a8e596f6bad6f
Parents:
ac0bd60e1d213f4d9b7e9b2c6e9dd526c82bac2d
git-author:
Hans Schoenemann <hannes@mathematik.uni-kl.de>2010-11-08 18:10:18+01:00
git-committer:
Mohamed Barakat <mohamed.barakat@rwth-aachen.de>2011-11-09 11:55:36+01:00
Message:
moved pDiffOp to p_polys p_DiffOp
Location:
polys
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • polys/monomials/p_polys.cc

    rac0bd6 r5162db  
    14051405  return res;
    14061406}
     1407
     1408static poly pDiffOpM(poly a, poly b,BOOLEAN multiply, const ring r)
     1409{
     1410  int i,j,s;
     1411  number n,h,hh;
     1412  poly p=p_One(r);
     1413  n=n_Mult(pGetCoeff(a),pGetCoeff(b),r->cf);
     1414  for(i=rVar(r);i>0;i--)
     1415  {
     1416    s=p_GetExp(b,i,r);
     1417    if (s<p_GetExp(a,i,r))
     1418    {
     1419      n_Delete(&n,r->cf);
     1420      p_LmDelete(&p,r);
     1421      return NULL;
     1422    }
     1423    if (multiply)
     1424    {
     1425      for(j=p_GetExp(a,i,r); j>0;j--)
     1426      {
     1427        h = n_Init(s,r->cf);
     1428        hh=n_Mult(n,h,r->cf);
     1429        n_Delete(&h,r->cf);
     1430        n_Delete(&n,r->cf);
     1431        n=hh;
     1432        s--;
     1433      }
     1434      p_SetExp(p,i,s,r);
     1435    }
     1436    else
     1437    {
     1438      p_SetExp(p,i,s-p_GetExp(a,i,r),r);
     1439    }
     1440  }
     1441  p_Setm(p,r);
     1442  /*if (multiply)*/ p_SetCoeff(p,n,r);
     1443  if (n_IsZero(n,r->cf))  p=p_LmDeleteAndNext(p,r); // return NULL as p is a monomial
     1444  return p;
     1445}
     1446
     1447poly p_DiffOp(poly a, poly b,BOOLEAN multiply, const ring r)
     1448{
     1449  poly result=NULL;
     1450  poly h;
     1451  for(;a!=NULL;pIter(a))
     1452  {
     1453    for(h=b;h!=NULL;pIter(h))
     1454    {
     1455      result=p_Add_q(result,p_DiffOpM(a,h,multiply,r),r);
     1456    }
     1457  }
     1458  return result;
     1459}
    14071460/***************************************************************
    14081461 *
  • polys/monomials/p_polys.h

    rac0bd6 r5162db  
    17591759void      p_Lcm(poly a, poly b, poly m, const ring r);
    17601760poly      p_Diff(poly a, int k, const ring r);
     1761poly      p_DiffOp(poly a, poly b,BOOLEAN multiply, const ring r);
    17611762#endif // P_POLYS_H
    17621763
  • polys/polys.h

    rac0bd6 r5162db  
    292292#define pLcm(a,b,m) p_Lcm(a,b,m,currRing)
    293293#define pDiff(a,b)  p_Diff(a,b,currRing)
    294 poly      pDiffOp(poly a, poly b,BOOLEAN multiply);
     294#define pDiffOp(a,b,m) p_DiffOp(a,b,m,currRing)
    295295
    296296#define   pMaxComp(p)   p_MaxComp(p, currRing)
  • polys/polys1.cc

    rac0bd6 r5162db  
    352352  }
    353353  return rc;
    354 }
    355 
    356 static poly pDiffOpM(poly a, poly b,BOOLEAN multiply)
    357 {
    358   int i,j,s;
    359   number n,h,hh;
    360   poly p=pOne();
    361   n=nMult(pGetCoeff(a),pGetCoeff(b));
    362   for(i=pVariables;i>0;i--)
    363   {
    364     s=pGetExp(b,i);
    365     if (s<pGetExp(a,i))
    366     {
    367       nDelete(&n);
    368       pLmDelete(&p);
    369       return NULL;
    370     }
    371     if (multiply)
    372     {
    373       for(j=pGetExp(a,i); j>0;j--)
    374       {
    375         h = nInit(s);
    376         hh=nMult(n,h);
    377         nDelete(&h);
    378         nDelete(&n);
    379         n=hh;
    380         s--;
    381       }
    382       pSetExp(p,i,s);
    383     }
    384     else
    385     {
    386       pSetExp(p,i,s-pGetExp(a,i));
    387     }
    388   }
    389   pSetm(p);
    390   /*if (multiply)*/ pSetCoeff(p,n);
    391   if (nIsZero(n))  p=pLmDeleteAndNext(p); // return NULL as p is a monomial
    392   return p;
    393 }
    394 
    395 poly pDiffOp(poly a, poly b,BOOLEAN multiply)
    396 {
    397   poly result=NULL;
    398   poly h;
    399   for(;a!=NULL;pIter(a))
    400   {
    401     for(h=b;h!=NULL;pIter(h))
    402     {
    403       result=pAdd(result,pDiffOpM(a,h,multiply));
    404     }
    405   }
    406   return result;
    407354}
    408355
Note: See TracChangeset for help on using the changeset viewer.