Changeset 8a8c9e in git for libpolys


Ignore:
Timestamp:
Jan 12, 2011, 7:17:19 PM (13 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'fc741b6502fd8a97288eaa3eba6e5220f3c3df87')
Children:
56790491568061b8fda62ac136d56bb3bca12583
Parents:
ce2120e7219cf5bd8e6ce5db355bc0cd410f02f6
git-author:
Hans Schoenemann <hannes@mathematik.uni-kl.de>2011-01-12 19:17:19+01:00
git-committer:
Mohamed Barakat <mohamed.barakat@rwth-aachen.de>2011-11-09 11:59:24+01:00
Message:
syntax fixes for libpoly, part 1
Location:
libpolys
Files:
7 edited
2 moved

Legend:

Unmodified
Added
Removed
  • libpolys/coeffs/coeffs.h

    rce2120e r8a8c9e  
    159159           (*cfIsMOne)(number a, const coeffs r),
    160160           (*cfGreaterZero)(number a, const coeffs r);
    161    
     161
    162162   void    (*cfPower)(number a, int i, number * result, const coeffs r);
    163163   number  (*cfGetDenom)(number &n, const coeffs r);
     
    219219  short      float_len2; /* additional char-flags, rInit */
    220220
    221   BOOLEAN   ShortOut; /// ffields need this. 
     221  BOOLEAN   ShortOut; /// ffields need this.
    222222
    223223// ---------------------------------------------------
     
    265265
    266266/// return a copy of a
    267 static inline number n_Copy(number n,    const coeffs r){ return (r)->cfCopy(n, r); }
    268 static inline void   n_Delete(number* p, const coeffs r){ return (r)->cfDelete(p, r); }
    269 
    270 static inline BOOLEAN n_Equal(number a, number b, const coeffs r){ return (r)->cfEqual(a, b, r); }
    271 static inline BOOLEAN n_IsZero(number n, const coeffs r){ return (r)->cfIsZero(n,r); }
    272 static inline BOOLEAN n_IsOne(number n,  const coeffs r){ return (r)->cfIsOne(n,r); }
    273 static inline BOOLEAN n_IsMOne(number n, const coeffs r){ return (r)->cfIsMOne(n,r); }
    274 static inline BOOLEAN n_GreaterZero(number n, const coeffs r){ return (r)->cfGreaterZero(n,r); }
     267static inline number n_Copy(number n,    const coeffs r)
     268{ return (r)->cfCopy(n, r); }
     269static inline void   n_Delete(number* p, const coeffs r)
     270{ return (r)->cfDelete(p, r); }
     271
     272static inline BOOLEAN n_Equal(number a, number b, const coeffs r)
     273{ return (r)->cfEqual(a, b, r); }
     274static inline BOOLEAN n_IsZero(number n, const coeffs r)
     275{ return (r)->cfIsZero(n,r); }
     276static inline BOOLEAN n_IsOne(number n,  const coeffs r)
     277{ return (r)->cfIsOne(n,r); }
     278static inline BOOLEAN n_IsMOne(number n, const coeffs r)
     279{ return (r)->cfIsMOne(n,r); }
     280static inline BOOLEAN n_GreaterZero(number n, const coeffs r)
     281{ return (r)->cfGreaterZero(n,r); }
    275282// cfGreater?
    276283#ifdef HAVE_RINGS
    277 static inline BOOLEAN n_IsUnit(number n, const coeffs r) { return r->cfIsUnit(n,r); }
     284static inline BOOLEAN n_IsUnit(number n, const coeffs r)
     285{ return r->cfIsUnit(n,r); }
     286static inline BOOLEAN n_DivBy(number a, number b, const coeffs r)
     287{ return r->cfDivBy(a,b,r); }
    278288#endif
    279289
    280290/// init with an integer
    281 static inline number n_Init(int i,       const coeffs r){ return (r)->cfInit(i,r); }
     291static inline number n_Init(int i,       const coeffs r)
     292{ return (r)->cfInit(i,r); }
    282293
    283294/// changes argument  inline: a:= -a
    284 static inline number n_Neg(number n,     const coeffs r){ return (r)->cfNeg(n,r); }
     295static inline number n_Neg(number n,     const coeffs r)
     296{ return (r)->cfNeg(n,r); }
    285297
    286298/// return 1/a
    287 static inline number n_Invers(number a,  const coeffs r){ return (r)->cfInvers(a,r); }
     299static inline number n_Invers(number a,  const coeffs r)
     300{ return (r)->cfInvers(a,r); }
    288301
    289302/// use for pivot strategies, (0) => 0, otherwise positive
    290 static inline int    n_Size(number n,    const coeffs r){ return (r)->cfSize(n,r); }
     303static inline int    n_Size(number n,    const coeffs r)
     304{ return (r)->cfSize(n,r); }
    291305
    292306/// normalize the number. i.e. go to some canonnical representation (inplace)
    293 static inline void   n_Normalize(number& n, const coeffs r){ return (r)->cfNormalize(n,r); }
     307static inline void   n_Normalize(number& n, const coeffs r)
     308{ return (r)->cfNormalize(n,r); }
    294309
    295310/// Normalize and Write to the output buffer of reporter
    296 static inline void   n_Write(number& n,  const coeffs r){ return (r)->cfWrite(n,r); }
     311static inline void   n_Write(number& n,  const coeffs r)
     312{ return (r)->cfWrite(n,r); }
    297313
    298314/// Normalize and get denomerator
    299 static inline number n_GetDenom(number& n, const coeffs r){ return (r)->cfGetDenom(n, r); }
     315static inline number n_GetDenom(number& n, const coeffs r)
     316{ return (r)->cfGetDenom(n, r); }
    300317
    301318/// Normalize and get numerator
    302 static inline number n_GetNumerator(number& n, const coeffs r){ return (r)->cfGetNumerator(n, r); }
    303 
    304 static inline void   n_Power(number a, int b, number *res, const coeffs r){ return (r)->cfPower(a,b,res,r); }
    305 
    306 
    307 static inline number n_Mult(number a, number b, const coeffs r){ return (r)->cfMult(a, b, r); }
     319static inline number n_GetNumerator(number& n, const coeffs r)
     320{ return (r)->cfGetNumerator(n, r); }
     321
     322static inline void   n_Power(number a, int b, number *res, const coeffs r)
     323{ return (r)->cfPower(a,b,res,r); }
     324
     325static inline number n_Mult(number a, number b, const coeffs r)
     326{ return (r)->cfMult(a, b, r); }
    308327
    309328/// Inplace multiplication: a := a * b
    310 static inline void n_InpMult(number &a, number b, const coeffs r){ return (r)->cfInpMult(a,b,r); }
    311 
    312 static inline number n_Sub(number a, number b, const coeffs r){ return (r)->cfSub(a, b, r); }
    313 static inline number n_Add(number a, number b, const coeffs r){ return (r)->cfAdd(a, b, r); }
    314 
    315 static inline number n_Div(number a, number b, const coeffs r){ return (r)->cfDiv(a,b,r); }
    316 static inline number n_IntDiv(number a, number b, const coeffs r){ return (r)->cfIntDiv(a,b,r); }
    317 static inline number n_ExactDiv(number a, number b, const coeffs r){ return (r)->cfExactDiv(a,b,r); }
    318 
    319 static inline number n_Gcd(number a, number b, const coeffs r){ return (r)->cfGcd(a,b,r); }
     329static inline void n_InpMult(number &a, number b, const coeffs r)
     330{ return (r)->cfInpMult(a,b,r); }
     331
     332static inline number n_Sub(number a, number b, const coeffs r)
     333{ return (r)->cfSub(a, b, r); }
     334
     335static inline number n_Add(number a, number b, const coeffs r)
     336{ return (r)->cfAdd(a, b, r); }
     337
     338static inline number n_Div(number a, number b, const coeffs r)
     339{ return (r)->cfDiv(a,b,r); }
     340
     341static inline number n_IntDiv(number a, number b, const coeffs r)
     342{ return (r)->cfIntDiv(a,b,r); }
     343
     344static inline number n_ExactDiv(number a, number b, const coeffs r)
     345{ return (r)->cfExactDiv(a,b,r); }
     346
     347static inline number n_Gcd(number a, number b, const coeffs r)
     348{ return (r)->cfGcd(a,b,r); }
    320349
    321350/// Tests whether n is a correct number: only used if LDEBUG is defined
    322351static inline BOOLEAN n_DBTest(number n, const char *filename, const int linenumber, const coeffs r)
    323352{
    324 #ifdef LDEBUG 
     353#ifdef LDEBUG
    325354  return (r)->cfDBTest(n, filename, linenumber, r);
    326355#else
    327356  return TRUE;
    328357#endif
    329 
    330358}
    331359
     
    339367
    340368// Deprecated:
    341 static inline int n_GetChar(const coeffs r){ return nInternalChar(r); }
    342 
    343 #endif
    344 
     369static inline int n_GetChar(const coeffs r)
     370{ return nInternalChar(r); }
     371
     372#endif
     373
  • libpolys/polys/Makefile.am

    rce2120e r8a8c9e  
    1313        operations/pShallowCopyDelete.cc operations/p_Mult_q.cc \
    1414        p_Procs_Lib.cc polys-impl.cc polys.cc \
    15         polys0.cc polys1.cc prCopy.cc prCopyTemplate.cc
     15        polys0.cc polys1.cc prCopy.cc prCopyTemplate.cc \
     16        sbucktes.cc
    1617
    1718noinst_HEADERS =
     
    2223        p_MemAdd.h p_MemCmp.h p_MemCopy.h operations/p_Mult_q.h p_Numbers.h p_Procs.h \
    2324        p_Procs_Dynamic.h p_Procs_Impl.h p_Procs_Set.h p_Procs_Static.h \
    24         monomials/p_polys.h monomials/polys-impl.h monomials/polys.h prCopy.h prCopyMacros.h
     25        monomials/p_polys.h monomials/polys-impl.h monomials/polys.h prCopy.h prCopyMacros.h \
     26        sbuckets.h
    2527
    2628lib_LIBRARIES=libpolys.a libpolys_g.a
  • libpolys/polys/monomials/monomials.cc

    rce2120e r8a8c9e  
    3131#include <reporter/reporter.h>
    3232#include <coeffs/numbers.h>
    33 #include <polys/polys.h>
    3433#include <polys/monomials/ring.h>
     34#include <polys/monomials/p_polys.h>
    3535#include <polys/templates/p_Procs.h>
    3636#include <reporter/reporter.h>
  • libpolys/polys/monomials/p_polys.cc

    rce2120e r8a8c9e  
    1010 *******************************************************************/
    1111
     12#include <ctype.h>
    1213
    1314#include <misc/auxiliary.h>
     
    1617#include <polys/monomials/p_polys.h>
    1718#include <polys/monomials/ring.h>
     19#include <coeffs/longrat.h>
    1820// #include <???/ideals.h>
    1921// #include <???/int64vec.h>
     
    536538
    537539  for (;i<=r->N;i++)
    538     j+=p_GetExp(p,i, r)*pWeight(i, r);
     540    j+=p_GetExp(p,i, r)*p_Weight(i, r);
    539541
    540542  return j;
     
    11171119  {
    11181120    rc = p_Init(r);
    1119     pSetCoeff0(rc,n_Init(i,r));
    1120     if (r->cf->nIsZero(p_GetCoeff(rc,r)))
     1121    pSetCoeff0(rc,n_Init(i,r->cf));
     1122    if (n_IsZero(pGetCoeff(rc),r->cf))
    11211123      p_LmDelete(&rc,r);
    11221124  }
     
    11301132{
    11311133  poly rc = p_Init(r);
    1132   pSetCoeff0(rc,n_Init(1,r));
     1134  pSetCoeff0(rc,n_Init(1,r->cf));
    11331135  return rc;
    11341136}
     
    11671169  int i,j;
    11681170  rc = p_Init(r);
    1169   const char *s = r->cf->nRead(st,&(rc->coef));
     1171  const char *s = r->cf->cfRead(st,&(rc->coef),r->cf);
    11701172  if (s==st)
    11711173  /* i.e. it does not start with a coeff: test if it is a ringvar*/
     
    12061208  }
    12071209done:
    1208   if (r->cf->nIsZero(pGetCoeff(rc))) p_LmDelete(&rc,r);
     1210  if (n_IsZero(pGetCoeff(rc),r->cf)) p_LmDelete(&rc,r);
    12091211  else
    12101212  {
     
    12601262poly p_NSet(number n, const ring r)
    12611263{
    1262   if (r->cf->nIsZero(n))
    1263   {
    1264     r->cf->cfDelete(&n, r);
     1264  if (n_IsZero(n,r->cf))
     1265  {
     1266    n_Delete(&n, r->cf);
    12651267    return NULL;
    12661268  }
     
    12831285  assume((p_GetComp(a,r)==p_GetComp(b,r)) || (p_GetComp(b,r)==0));
    12841286  int i;
    1285   poly result = pInit();
     1287  poly result = p_Init(r);
    12861288
    12871289  for(i=(int)r->N; i; i--)
     
    12911293  return result;
    12921294}
     1295
     1296#ifdef HAVE_RINGS   //TODO Oliver
     1297
     1298poly p_Div_nn(poly p, const number n, const ring r)
     1299{
     1300  pAssume(!n_IsZero(n,r));
     1301  p_Test(p, r);
     1302
     1303  poly q = p;
     1304  while (p != NULL)
     1305  {
     1306    number nc = pGetCoeff(p);
     1307    pSetCoeff0(p, n_Div(nc, n, r->cf));
     1308    n_Delete(&nc, r->cf);
     1309    pIter(p);
     1310  }
     1311  p_Test(q, r);
     1312  return q;
     1313}
     1314#endif
    12931315
    12941316/*2
     
    13231345      if (prev==NULL)
    13241346      {
    1325         p_DeleteLm(&result,r);
     1347        p_LmDelete(&result,r);
    13261348        a=result;
    13271349      }
    13281350      else
    13291351      {
    1330         p_DeleteLm(&pNext(prev),r);
     1352        p_LmDelete(&pNext(prev),r);
    13311353        a=pNext(prev);
    13321354      }
     
    14061428}
    14071429
    1408 static poly pDiffOpM(poly a, poly b,BOOLEAN multiply, const ring r)
     1430static poly p_DiffOpM(poly a, poly b,BOOLEAN multiply, const ring r)
    14091431{
    14101432  int i,j,s;
     
    14761498  int i;
    14771499
    1478   if(!n_IsOne(pGetCoeff(p),r))
     1500  if(!n_IsOne(pGetCoeff(p),r->cf))
    14791501  {
    14801502    number x, y;
    14811503    y = pGetCoeff(p);
    1482     n_Power(y,exp,&x,r);
    1483     n_Delete(&y,r);
     1504    n_Power(y,exp,&x,r->cf);
     1505    n_Delete(&y,r->cf);
    14841506    pSetCoeff0(p,x);
    14851507  }
     
    15021524
    15031525  y = pGetCoeff(p);
    1504   x = n_Mult(y,pGetCoeff(q),r);
    1505   n_Delete(&y,r);
     1526  x = n_Mult(y,pGetCoeff(q),r->cf);
     1527  n_Delete(&y,r->cf);
    15061528  pSetCoeff0(p,x);
    15071529  //for (i=pVariables; i!=0; i--)
     
    15231545  poly r = p_Init(rr);
    15241546
    1525   x = n_Mult(pGetCoeff(p),pGetCoeff(q),rr);
     1547  x = n_Mult(pGetCoeff(p),pGetCoeff(q),rr->cf);
    15261548  pSetCoeff0(r,x);
    15271549  p_ExpVectorSum(r,p, q, rr);
     
    15661588  {
    15671589    h = a[e];
    1568     x = n_Mult(bin[exp-e],pGetCoeff(h),r);
     1590    x = n_Mult(bin[exp-e],pGetCoeff(h),r->cf);
    15691591    p_SetCoeff(h,x,r);
    15701592    p_MonMult(h,b,r);
     
    15751597  {
    15761598    h = a[e];
    1577     x = n_Mult(bin[e],pGetCoeff(h),r);
     1599    x = n_Mult(bin[e],pGetCoeff(h),r->cf);
    15781600    p_SetCoeff(h,x,r);
    15791601    p_MonMult(h,b,r);
     
    17101732    if ((ph!=NULL) && rField_has_Units(r))
    17111733    {
    1712       number k = nGetUnit(pGetCoeff(ph));
     1734      number k = n_GetUnit(pGetCoeff(ph),r->cf);
    17131735      if (!n_IsOne(k,r->cf))
    17141736      {
     
    17351757  if(pNext(ph)==NULL)
    17361758  {
    1737     p_SetCoeff(ph,n_Init(1,r),r->cf);
     1759    p_SetCoeff(ph,n_Init(1,r->cf),r);
    17381760  }
    17391761  else
     
    17411763    n_Normalize(pGetCoeff(ph),r->cf);
    17421764    if(!n_GreaterZero(pGetCoeff(ph),r->cf)) ph = p_Neg(ph,r);
    1743     if (rField_is_Q())
     1765    if (rField_is_Q(r))
    17441766    {
    17451767      h=p_InitContent(ph,r);
     
    18051827      { // each monom: coeff in Q_a
    18061828        lnumber c_n_n=(lnumber)pGetCoeff(p);
    1807         napoly c_n=c_n_n->z;
     1829        poly c_n=c_n_n->z;
    18081830        while (c_n!=NULL)
    18091831        { // each monom: coeff in Q
     
    18431865        { // each monom: coeff in Q_a
    18441866          lnumber c_n_n=(lnumber)pGetCoeff(p);
    1845           napoly c_n=c_n_n->z;
     1867          poly c_n=c_n_n->z;
    18461868          while (c_n!=NULL)
    18471869          { // each monom: coeff in Q
     
    22012223    while (p!=NULL)
    22022224    {
    2203       n_Normalize(pGetCoeff(p,r->cf));
     2225      n_Normalize(pGetCoeff(p),r->cf);
    22042226      d=n_Lcm(h,pGetCoeff(p),r->cf);
    22052227      n_Delete(&h,r->cf);
     
    24802502  else
    24812503    d=pFDeg;
    2482   o = d(p,currRing);
     2504  o = d(p,r);
    24832505  do
    24842506  {
     
    27832805static BOOLEAN pOldLexOrder;
    27842806
    2785 static long pModDeg(poly p, ring r = currRing)
     2807static long pModDeg(poly p, ring r)
    27862808{
    27872809  long d=pOldFDeg(p, r);
     
    28812903              number c=pGetCoeff(qq);
    28822904              number ee=nfPar(1);
    2883               number eee;nfPower(ee,e,&eee); //nfDelete(ee,currRing);
     2905              number eee;nfPower(ee,e,&eee); //nfDelete(ee,dst);
    28842906              ee=nfMult(c,eee);
    2885               //nfDelete(c,currRing);nfDelete(eee,currRing);
     2907              //nfDelete(c,dst);nfDelete(eee,dst);
    28862908              pSetCoeff0(qq,ee);
    28872909            }
     
    28932915              else /* more difficult: we have really to multiply: */
    28942916              {
    2895                 lnumber mmc=(lnumber)naInit(1,currRing);
     2917                lnumber mmc=(lnumber)naInit(1,dst);
    28962918                napSetExp(mmc->z,-perm[i],e/*p_GetExp( p,i,oldRing)*/);
    28972919                napSetm(mmc->z);
  • libpolys/polys/monomials/p_polys.h

    rce2120e r8a8c9e  
    1414
    1515#include <polys/monomials/ring.h>
     16#include <polys/monomials/monomials.h>
    1617#include <polys/monomials/polys-impl.h>
     18#include <polys/templates/p_Procs.h>
     19#include <polys/templates/p_Procs.h>
     20#include <polys/sbuckets.h>
    1721
    1822/***************************************************************
     
    3943
    4044// Component
    41 #define p_GetComp(p, r)     _p_GetComp(p, r)
    4245static inline unsigned long p_SetComp(poly p, unsigned long c, ring r);
    4346static inline unsigned long p_AddComp(poly p, unsigned long v, ring r);
     
    181184static inline BOOLEAN p_IsConstantComp(const poly p, const ring r);
    182185static inline BOOLEAN p_IsConstant(const poly p, const ring r);
    183 PINLINE0 BOOLEAN p_IsConstantPoly(const poly p, const ring r);
     186static inline BOOLEAN p_IsConstantPoly(const poly p, const ring r);
    184187
    185188// return TRUE if all monoms have the same component
     
    320323
    321324// sets component of poly a to i, returns length of a
    322 PINLINE0   void p_SetCompP(poly a, int i, ring r);
    323 PINLINE0   void p_SetCompP(poly a, int i, ring lmRing, ring tailRing);
    324 PINLINE0   long p_MaxComp(poly p, ring lmRing, ring tailRing);
     325static inline   void p_SetCompP(poly a, int i, ring r);
     326static inline   void p_SetCompP(poly a, int i, ring lmRing, ring tailRing);
     327static inline   long p_MaxComp(poly p, ring lmRing, ring tailRing);
    325328inline long p_MaxComp(poly p,ring lmRing) {return p_MaxComp(p,lmRing,lmRing);}
    326 PINLINE0   long p_MinComp(poly p, ring lmRing, ring tailRing);
     329static inline   long p_MinComp(poly p, ring lmRing, ring tailRing);
    327330inline long p_MinComp(poly p,ring lmRing) {return p_MinComp(p,lmRing,lmRing);}
    328331
     
    332335 *
    333336 ***************************************************************/
    334 PINLINE0 int       pLength(poly a);
    335 PINLINE0 poly      pLast(poly a, int &length);
     337static inline int       pLength(poly a);
     338static inline poly      pLast(poly a, int &length);
    336339inline   poly      pLast(poly a) { int l; return pLast(a, l);}
    337 PINLINE0 poly pReverse(poly p);
     340static inline poly pReverse(poly p);
    338341
    339342
     
    441444{
    442445  p_LmCheckPolyRing2(p, r);
    443   n_Delete(&(p->coef), r);
     446  n_Delete(&(p->coef), r->cf);
    444447  (p)->coef=n;
    445448  return n;
     
    496499  p_LmCheckPolyRing2(p, r);
    497500  pAssume2(rRing_has_Comp(r));
    498   pPolyAssume2(__p_GetComp(p,r) >= v,p,r);
     501  _pPolyAssume2(__p_GetComp(p,r) >= v,p,r);
    499502  return __p_GetComp(p,r) -= v;
    500503}
     
    737740  return pnext;
    738741}
    739 static inline void p_LmDelete(poly p, ring r)
     742static inline void p_LmDelete(poly p, const ring r)
    740743{
    741744  p_LmCheckPolyRing2(p, r);
    742   n_Delete(&pGetCoeff(p), r);
     745  n_Delete(&pGetCoeff(p), r->cf);
    743746  omFreeBinAddr(p);
    744747}
    745 static inline void p_LmDelete(poly *p, ring r)
     748static inline void p_LmDelete(poly *p, const ring r)
    746749{
    747750  p_LmCheckPolyRing2(*p, r);
    748751  poly h = *p;
    749752  *p = pNext(h);
    750   n_Delete(&pGetCoeff(h), r);
     753  n_Delete(&pGetCoeff(h), r->cf);
    751754  omFreeBinAddr(h);
    752755}
    753 static inline poly p_LmDeleteAndNext(poly p, ring r)
     756static inline poly p_LmDeleteAndNext(poly p, const ring r)
    754757{
    755758  p_LmCheckPolyRing2(p, r);
    756759  poly pnext = pNext(p);
    757   n_Delete(&pGetCoeff(p), r);
     760  n_Delete(&pGetCoeff(p), r->cf);
    758761  omFreeBinAddr(p);
    759762  return pnext;
     
    910913static inline poly p_Mult_nn(poly p, number n, const ring r)
    911914{
    912   if (n_IsOne(n, r))
     915  if (n_IsOne(n, r->cf))
    913916    return p;
    914917  else
     
    935938static inline poly pp_Mult_nn(poly p, number n, const ring r)
    936939{
    937   if (n_IsOne(n, r))
     940  if (n_IsOne(n, r->cf))
    938941    return p_Copy(p, r);
    939942  else
     
    11141117  int shorter;
    11151118  number n_old = pGetCoeff(m);
    1116   number n_neg = n_Copy(n_old, r);
    1117   n_neg = n_Neg(n_neg, r);
     1119  number n_neg = n_Copy(n_old, r->cf);
     1120  n_neg = n_Neg(n_neg, r->cf);
    11181121  pSetCoeff0(m, n_neg);
    11191122  res = r->p_Procs->p_Minus_mm_Mult_qq(p, m, q, shorter, NULL, r, last);
    11201123  lp = (lp + lq) - shorter;
    11211124  pSetCoeff0(m, n_old);
    1122   n_Delete(&n_neg, r);
     1125  n_Delete(&n_neg, r->cf);
    11231126  return res;
    11241127}
     
    13041307  p_MemCopy_LengthGeneral(np->exp, p->exp, r->ExpL_Size);
    13051308  pNext(np) = NULL;
    1306   pSetCoeff0(np, n_Copy(pGetCoeff(p), r));
     1309  pSetCoeff0(np, n_Copy(pGetCoeff(p), r->cf));
    13071310  return np;
    13081311}
     
    13191322  p_MemCopy_LengthGeneral(np->exp, p->exp, r->ExpL_Size);
    13201323  pNext(np) = NULL;
    1321   pSetCoeff0(np, n_Init(1, r));
     1324  pSetCoeff0(np, n_Init(1, r->cf));
    13221325  int i;
    13231326  for(i=l;i<=k;i++)
     
    15441547#ifdef HAVE_RINGS
    15451548  pDivAssume(p_DebugLmDivisibleByNoComp(a, b, r) == nDivBy(p_GetCoeff(b, r), p_GetCoeff(a, r)));
    1546   return (!rField_is_Ring(r)) || nDivBy(p_GetCoeff(b, r), p_GetCoeff(a, r));
     1549  return (!rField_is_Ring(r)) || n_DivBy(p_GetCoeff(b, r), p_GetCoeff(a, r), r->cf);
    15471550#else
    15481551  pDivAssume(p_DebugLmDivisibleByNoComp(a, b, r) == TRUE);
     
    15641567  while (i);
    15651568#ifdef HAVE_RINGS
    1566   return nDivBy(p_GetCoeff(b, r), p_GetCoeff(a, r));
     1569  return n_DivBy(p_GetCoeff(b, r_b), p_GetCoeff(a, r_a), r_a->cf);
    15671570#else
    15681571  return TRUE;
     
    16611664  p_LmCheckPolyRing1(b, r);
    16621665#ifndef PDIV_DEBUG
    1663   pPolyAssume2(p_GetShortExpVector(a, r) == sev_a, a, r);
    1664   pPolyAssume2(p_GetShortExpVector(b, r) == ~ not_sev_b, b, r);
     1666  _pPolyAssume2(p_GetShortExpVector(a, r) == sev_a, a, r);
     1667  _pPolyAssume2(p_GetShortExpVector(b, r) == ~ not_sev_b, b, r);
    16651668
    16661669  if (sev_a & not_sev_b)
     
    16811684  p_LmCheckPolyRing1(b, r_b);
    16821685#ifndef PDIV_DEBUG
    1683   pPolyAssume2(p_GetShortExpVector(a, r_a) == sev_a, a, r_a);
    1684   pPolyAssume2(p_GetShortExpVector(b, r_b) == ~ not_sev_b, b, r_b);
     1686  _pPolyAssume2(p_GetShortExpVector(a, r_a) == sev_a, a, r_a);
     1687  _pPolyAssume2(p_GetShortExpVector(b, r_b) == ~ not_sev_b, b, r_b);
    16851688
    16861689  if (sev_a & not_sev_b)
     
    17771780poly      p_DiffOp(poly a, poly b,BOOLEAN multiply, const ring r);
    17781781int       p_Weight(int c, const ring r);
    1779 static inline long pTotaldegree(poly p) { return p_Totaldegree(p,currRing); }
    17801782
    17811783/* syszygy stuff */
     
    18021804// on ordering and/or OrdIndex -- otherwise they might return wrong results
    18031805// on strat->tailRing
    1804 void pSetDegProcs(ring r. pFDegProc new_FDeg, pLDegProc new_lDeg = NULL);
     1806void pSetDegProcs(ring r, pFDegProc new_FDeg, pLDegProc new_lDeg = NULL);
    18051807// restores pFDeg and pLDeg:
    1806 void pRestoreDegProcs(ring r. pFDegProc old_FDeg, pLDegProc old_lDeg);
     1808void pRestoreDegProcs(ring r, pFDegProc old_FDeg, pLDegProc old_lDeg);
    18071809
    18081810/*-------------pComp for syzygies:-------------------*/
  • libpolys/polys/monomials/ring.h

    rce2120e r8a8c9e  
    1111/* includes */
    1212#include <coeffs/coeffs.h>
     13#include <omalloc/omalloc.h>
    1314//#include <polys/monomials/polys-impl.h>
     15//
     16
     17/* constants */
     18#define SHORT_REAL_LENGTH 6 // use short reals for real <= 6 digits
     19
     20/* forward declaration of types */
     21class idrec;
     22typedef idrec *   idhdl;
     23struct sip_sideal;
     24typedef struct sip_sideal *       ideal;
     25struct ip_sring;
     26typedef struct ip_sring *         ring;
     27struct  spolyrec;
     28typedef struct spolyrec    polyrec;
     29typedef polyrec *          poly;
     30class intvec;
     31struct p_Procs_s;
     32typedef struct p_Procs_s p_Procs_s;
     33class slists;
     34typedef slists *           lists;
     35class kBucket;
     36typedef kBucket*           kBucket_pt;
     37
     38#if SIZEOF_LONG == 4
     39typedef long long int64;
     40#elif SIZEOF_LONG == 8
     41typedef long int64;
     42#else
     43#error int64 undefined
     44#endif
     45
     46/* the function pointer types */
     47
     48typedef long     (*pLDegProc)(poly p, int *length, ring r);
     49typedef long     (*pFDegProc)(poly p, ring r);
     50typedef void     (*p_SetmProc)(poly p, const ring r);
     51
     52typedef enum
     53{
     54  ro_dp, // ordering is a degree ordering
     55  ro_wp, // ordering is a weighted degree ordering
     56  ro_wp64, // ordering is a weighted64 degree ordering
     57  ro_wp_neg, // ordering is a weighted degree ordering
     58             // with possibly negative weights
     59  ro_cp,    // ordering duplicates variables
     60  ro_syzcomp, // ordering indicates "subset" of component number (ringorder_S)
     61  ro_syz, // ordering  with component number >syzcomp is lower (ringorder_s)
     62  ro_isTemp, ro_is, // Induced Syzygy (Schreyer) ordering (and prefix data placeholder dummy) (ringorder_IS)
     63  ro_none
     64}
     65ro_typ;
     66
     67// ordering is a degree ordering
     68struct sro_dp
     69{
     70  short place;  // where degree is stored (in L):
     71  short start;  // bounds of ordering (in E):
     72  short end;
     73};
     74typedef struct sro_dp sro_dp;
     75
     76// ordering is a weighted degree ordering
     77struct sro_wp
     78{
     79  short place;  // where weighted degree is stored (in L)
     80  short start;  // bounds of ordering (in E)
     81  short end;
     82  int *weights; // pointers into wvhdl field
     83};
     84typedef struct sro_wp sro_wp;
     85
     86// ordering is a weighted degree ordering
     87struct sro_wp64
     88{
     89    short place;  // where weighted degree is stored (in L)
     90    short start;  // bounds of ordering (in E)
     91    short end;
     92    int64 *weights64; // pointers into wvhdl field
     93};
     94typedef struct sro_wp64 sro_wp64;
     95
     96// ordering duplicates variables
     97struct sro_cp
     98{
     99  short place;  // where start is copied to (in E)
     100  short start;  // bounds of sources of copied variables (in E)
     101  short end;
     102};
     103typedef struct sro_cp sro_cp;
     104
     105// ordering indicates "subset" of component number
     106struct sro_syzcomp
     107{
     108  short place;  // where the index is stored (in L)
     109  long *ShiftedComponents; // pointer into index field
     110  int* Components;
     111#ifdef PDEBUG
     112  long length;
     113#endif
     114};
     115typedef struct sro_syzcomp sro_syzcomp;
     116
     117// ordering  with component number >syzcomp is lower
     118struct sro_syz
     119{
     120  short place;       // where the index is stored (in L)
     121  int limit;         // syzcomp
     122  int* syz_index;    // mapping Component -> SyzIndex for Comp <= limit
     123  int  curr_index;   // SyzIndex for Component > limit
     124};
     125
     126typedef struct sro_syz sro_syz;
     127// Induced Syzygy (Schreyer) ordering is built inductively as follows:
     128// we look for changes made by ordering blocks which are between prefix/suffix markers:
     129// that is: which variables where placed by them and where (judging by v)
     130
     131// due to prefix/suffix nature we need some placeholder:
     132// prefix stores here initial state
     133// suffix cleares this up
     134struct sro_ISTemp
     135{
     136  short start; // 1st member SHOULD be short "place"
     137  int   suffixpos;
     138  int*  pVarOffset; // copy!
     139};
     140
     141// So this is the actuall thing!
     142// suffix uses last sro_ISTemp (cleares it up afterwards) and
     143// creates this block
     144struct sro_IS
     145{
     146  short start, end;  // which part of L we want to want to update...
     147  int*  pVarOffset; // same as prefix!
     148
     149  int limit; // first referenced component
     150
     151  // reference poly set?? // Should it be owned by ring?!!!
     152  ideal F; // reference leading (module)-monomials set. owned by ring...
     153  const intvec* componentWeights; // component weights! owned by ring...
     154};
     155
     156typedef struct sro_IS sro_IS;
     157typedef struct sro_ISTemp sro_ISTemp;
     158
     159struct sro_ord
     160{
     161  ro_typ  ord_typ;
     162  int     order_index; // comes from r->order[order_index]
     163  union
     164  {
     165     sro_dp dp;
     166     sro_wp wp;
     167     sro_wp64 wp64;
     168     sro_cp cp;
     169     sro_syzcomp syzcomp;
     170     sro_syz syz;
     171     sro_IS is;
     172     sro_ISTemp isTemp;
     173  } data;
     174};
     175struct ip_sring
     176{
     177// each entry must have a description and a procedure defining it,
     178// general ordering: pointer/structs, long, int, short, BOOLEAN/char/enum
     179// general defining procedures: rInit, rComplete, interpreter, ??
     180  idhdl      idroot; /* local objects , interpreter*/
     181  int*       order;  /* array of orderings, rInit/rSleftvOrdering2Ordering */
     182  int*       block0; /* starting pos., rInit/rSleftvOrdering2Ordering*/
     183  int*       block1; /* ending pos., rInit/rSleftvOrdering2Ordering*/
     184  char**     parameter; /* names of parameters, rInit */
     185  number     minpoly;  /* for Q_a/Zp_a, rInit */
     186  ideal      minideal;
     187  int**      wvhdl;  /* array of weight vectors, rInit/rSleftvOrdering2Ordering */
     188  char **    names;  /* array of variable names, rInit */
     189
     190  // what follows below here should be set by rComplete, _only_
     191  long      *ordsgn;  /* array of +/- 1 (or 0) for comparing monomials */
     192                       /*  ExpL_Size entries*/
     193
     194  // is NULL for lp or N == 1, otherwise non-NULL (with OrdSize > 0 entries) */
     195  sro_ord*   typ;   /* array of orderings + sizes, OrdSize entries */
     196  /* if NegWeightL_Size > 0, then NegWeightL_Offset[0..size_1] is index of longs
     197  in ExpVector whose values need an offset due to negative weights */
     198  /* array of NegWeigtL_Size indicies */
     199  int*      NegWeightL_Offset;
     200
     201  int*     VarOffset;
     202
     203  ideal      qideal; /* extension to the ring structure: qring, rInit */
     204
     205  int*     firstwv;
     206
     207  omBin    PolyBin; /* Bin from where monoms are allocated */
     208#ifdef HAVE_RINGS
     209  unsigned int  ringtype;  /* cring = 0 => coefficient field, cring = 1 => coeffs from Z/2^m */
     210  int_number    ringflaga; /* Z/(ringflag^ringflagb)=Z/nrnModul*/
     211  unsigned long ringflagb;
     212  unsigned long nr2mModul;  /* Z/nr2mModul */
     213  int_number    nrnModul;
     214#endif
     215  unsigned long options; /* ring dependent options */
     216
     217  int        ch;  /* characteristic, rInit */
     218  int        ref; /* reference counter to the ring, interpreter */
     219
     220  short      float_len; /* additional char-flags, rInit */
     221  short      float_len2; /* additional char-flags, rInit */
     222
     223  short      N;      /* number of vars, rInit */
     224
     225  short      P;      /* number of pars, rInit */
     226  short      OrdSgn; /* 1 for polynomial rings, -1 otherwise, rInit */
     227
     228  short     firstBlockEnds;
     229#ifdef HAVE_PLURAL
     230  short     real_var_start, real_var_end;
     231#endif
     232
     233#ifdef HAVE_SHIFTBBA
     234  short          isLPring; /* 0 for non-letterplace rings, otherwise the number of LP blocks, at least 1, known also as lV */
     235#endif
     236
     237  BOOLEAN   VectorOut;
     238  BOOLEAN   ShortOut;
     239  BOOLEAN   CanShortOut;
     240  BOOLEAN   LexOrder; // TRUE if the monomial ordering has polynomial and power series blocks
     241  BOOLEAN   MixedOrder; // TRUE for global/local mixed orderings, FALSE otherwise
     242
     243  BOOLEAN   ComponentOrder; // ???
     244
     245  // what follows below here should be set by rComplete, _only_
     246  // contains component, but no weight fields in E */
     247  short      ExpL_Size; // size of exponent vector in long
     248  short      CmpL_Size; // portions which need to be compared
     249  /* number of long vars in exp vector:
     250     long vars are those longs in the exponent vector which are
     251     occupied by variables, only */
     252  short      VarL_Size;
     253  short      BitsPerExp; /* number of bits per exponent */
     254  short      ExpPerLong; /* maximal number of Exponents per long */
     255  short      pCompIndex; /* p->exp.e[pCompIndex] is the component */
     256  short      pOrdIndex; /* p->exp[pOrdIndex] is pGetOrd(p) */
     257  short      OrdSize; /* size of ord vector (in sro_ord) */
     258
     259  /* if >= 0, long vars in exp vector are consecutive and start there
     260     if <  0, long vars in exp vector are not consecutive */
     261  short     VarL_LowIndex;
     262  // number of exponents in r->VarL_Offset[0]
     263  // is minimal number of exponents in a long var
     264  short     MinExpPerLong;
     265
     266  short     NegWeightL_Size;
     267  /* array of size VarL_Size,
     268     VarL_Offset[i] gets i-th long var in exp vector */
     269  int*      VarL_Offset;
     270
     271  /* mask for getting single exponents */
     272  unsigned long bitmask;
     273  /* mask used for divisiblity tests */
     274  unsigned long divmask; // rComplete
     275
     276  p_Procs_s*    p_Procs; // rComplete/p_ProcsSet
     277
     278  /* FDeg and LDeg */
     279  pFDegProc     pFDeg; // rComplete/rSetDegStuff
     280  pLDegProc     pLDeg; // rComplete/rSetDegStuff
     281
     282  /* as it was determined by rComplete */
     283  pFDegProc     pFDegOrig;
     284  /* and as it was determined before rOptimizeLDeg */
     285  pLDegProc     pLDegOrig;
     286
     287  p_SetmProc    p_Setm;
     288  n_Procs_s*    cf;
     289  ring          algring;
     290#ifdef HAVE_PLURAL
     291  private:
     292    nc_struct*    _nc; // private
     293  public:
     294    inline const nc_struct* GetNC() const { return _nc; }; // public!!!
     295    inline nc_struct*& GetNC() { return _nc; }; // public!!!
     296#endif
     297};
    14298
    15299enum tHomog
     
    42326#ifdef HAVE_PLURAL
    43327  nc_struct *n;
    44   return (r != NULL) && ((n=r->GetNC()) != NULL) /*&& (n->type != nc_error)*/; 
     328  return (r != NULL) && ((n=r->GetNC()) != NULL) /*&& (n->type != nc_error)*/;
    45329#else
    46330  return false;
     
    53337  /* nc_struct *n; */
    54338  return (r != NULL) /* && ((n=r->GetNC()) != NULL) */
    55           && (r->real_var_start>1);
     339          && (r->real_var_start>1);
    56340#else
    57341  return false;
     
    69353                     long* currShiftedComponents,
    70354                     int length,
    71                      ring r = currRing);
     355                     ring r);
    72356void rDBGetSComps(int** currComponents,
    73357                  long** currShiftedComponents,
    74358                  int *length,
    75                   ring r = currRing);
     359                  ring r);
    76360#else
    77361#define rChangeSComps(c,s,l) rNChangeSComps(c,s)
     
    79363#endif
    80364
    81 void rNChangeSComps(int* currComponents, long* currShiftedComponents, ring r = currRing);
    82 void rNGetSComps(int** currComponents, long** currShiftedComponents, ring r = currRing);
     365void rNChangeSComps(int* currComponents, long* currShiftedComponents, ring r);
     366void rNGetSComps(int** currComponents, long** currShiftedComponents, ring r);
    83367
    84368//idhdl  rFindHdl(ring r, idhdl n, idhdl w);
     
    94378#define rVar(r) (r->N)
    95379char * rParStr(ring r);
    96 int    rIsExtension(const ring r=currRing);
     380int    rIsExtension(const ring r);
    97381int    rSum(ring r1, ring r2, ring &sum);
    98382int rSumInternal(ring r1, ring r2, ring &sum, BOOLEAN vartest, BOOLEAN dp_dp);
     
    271555
    272556// misc things
    273 static inline char* rRingVar(short i)
    274 {
    275   return currRing->names[i];
    276 }
    277 static inline char* rRingVar(short i, ring r)
     557static inline char* rRingVar(short i, const ring r)
    278558{
    279559  return r->names[i];
    280560}
    281 static inline BOOLEAN rShortOut(ring r)
     561static inline BOOLEAN rShortOut(const ring r)
    282562{
    283563  return (r->ShortOut);
     
    332612{ return r->order[0] == ringorder_s;}
    333613
    334 static inline int rGetCurrSyzLimit(const ring r = currRing)
     614static inline int rGetCurrSyzLimit(const ring r)
    335615{ return (rIsSyzIndexRing(r)? r->typ[0].data.syz.limit : 0);}
    336616
     
    375655
    376656/// returns TRUE if var(i) belongs to p-block
    377 BOOLEAN rIsPolyVar(int i, ring r = currRing);
     657BOOLEAN rIsPolyVar(int i, ring r);
    378658
    379659static inline BOOLEAN rOrd_is_Comp_dp(ring r)
  • libpolys/polys/polys.cc

    rce2120e r8a8c9e  
    3535poly      ppNoether = NULL;
    3636
    37 #ifdef HAVE_RINGS   //TODO Oliver
    38 #define pDiv_nn(p, n)              p_Div_nn(p, n, currRing)
    39 
    40 poly p_Div_nn(poly p, const number n, const ring r)
    41 {
    42   pAssume(!n_IsZero(n,r));
    43   p_Test(p, r);
    44 
    45   poly q = p;
    46   while (p != NULL)
    47   {
    48     number nc = pGetCoeff(p);
    49     pSetCoeff0(p, n_Div(nc, n, r));
    50     n_Delete(&nc, r);
    51     pIter(p);
    52   }
    53   p_Test(q, r);
    54   return q;
    55 }
    56 #endif
    57 
    5837#ifdef HAVE_RINGS
    5938/* TRUE iff LT(f) | LT(g) */
  • libpolys/polys/sbuckets.h

    rce2120e r8a8c9e  
    1515#define S_BUCKETS_H
    1616
    17 #include <kernel/structs.h>
    18 #include <kernel/ring.h>
     17#include <polys/monomials/ring.h>
    1918
    2019
    21 
     20class sBucket;
     21typedef sBucket*           sBucket_pt;
    2222//////////////////////////////////////////////////////////////////////////
    2323// Creation/Destruction of buckets
    2424//
    25 sBucket_pt    sBucketCreate(ring r = currRing);
     25sBucket_pt    sBucketCreate(ring r);
    2626void          sBucketDestroy(sBucket_pt *bucket);
    2727
Note: See TracChangeset for help on using the changeset viewer.