Changeset a9a7be in git for Singular/polys-impl.h


Ignore:
Timestamp:
Sep 27, 1999, 5:05:35 PM (25 years ago)
Author:
Olaf Bachmann <obachman@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'b4f17ed1d25f93d46dbe29e4b499baecc2fd51bb')
Children:
7c19609b3106a80912e66f6ac4fa0fa446532b1f
Parents:
7d423ecfe560c226d3e99aed883841c463e884ec
Message:
* walk stuff


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

Legend:

Unmodified
Added
Removed
  • Singular/polys-impl.h

    r7d423e ra9a7be  
    44*  Computer Algebra System SINGULAR     *
    55****************************************/
    6 /* $Id: polys-impl.h,v 1.31 1999-08-23 13:15:58 Singular Exp $ */
     6/* $Id: polys-impl.h,v 1.32 1999-09-27 15:05:29 obachman Exp $ */
    77
    88/***************************************************************
     
    3131#define VARS (0)
    3232#endif
    33 
    34 typedef Exponent_t  monomial[VARS + 1];
     33union s_exp
     34{
     35   Exponent_t e[VARS +1];
     36   long       l[(VARS +1)/2];
     37};
     38
     39//typedef Exponent_t  monomial[VARS + 1];
     40typedef s_exp  monomial;
    3541typedef Exponent_t* Exponent_pt;
    3642
     
    4046  poly      next; // next needs to be the first field
    4147  number    coef; // and coef the second --- do not change this !!!
    42   Order_t   Order;
    4348  monomial  exp; // make sure that exp is aligned
    4449};
     
    5055 ***************************************************************/
    5156
    52 #define POLYSIZE (sizeof(poly) + sizeof(number) + sizeof(Order_t))
     57#define POLYSIZE (sizeof(poly) + sizeof(number))
    5358#define POLYSIZEW (POLYSIZE / sizeof(long))
    5459#define MAX_EXPONENT_NUMBER ((MAX_BLOCK_SIZE - POLYSIZE) / SIZEOF_EXPONENT)
     
    6166extern int pMonomSizeW;
    6267// Ceiling((pVariables+1) / sizeof(void*)) == length of exp-vector in words
    63 extern int pVariables1W;
     68// extern int pVariables1W;
    6469// Ceiling((pVariables) / sizeof(void*))
    65 extern int pVariablesW;
     70// extern int pVariablesW;
    6671extern int *pVarOffset;
    67 extern int pVarLowIndex;
    68 extern int pVarHighIndex;
    69 extern int pVarCompIndex;
     72// extern int pVarLowIndex;
     73// extern int pVarHighIndex;
     74// extern int pVarCompIndex;
    7075
    7176/***************************************************************
     
    7479 *
    7580 ***************************************************************/
    76 #define _pExpIndex(i) pVarOffset[(i)]
     81#define _pExpIndex(i) (currRing->VarOffset[(i)])
    7782#define _pRingExpIndex(r, i)  (r)->VarOffset[(i)]
    7883
    79 #define _pCompIndex        pVarOffset[0]
    80 #define _pRingCompIndex(r)  ((r)->VarOffset[0])
    81 
    82 // for simple, lex orderings
    83 extern void pGetVarIndicies_Lex(int nvars, int* VarOffset, int &VarCompIndex,
    84                                 int &VarLowIndex, int &VarHighIndex);
    85 // for simple, revlex orderings
    86 extern void pGetVarIndicies_RevLex(int nvars,int *VarOffset,int &VarCompIndex,
    87                                    int &VarLowIndex, int &VarHighIndex);
    88 // for all non-simple orderings
    89 extern void pGetVarIndicies(int nvars, int *VarOffset, int &VarCompIndex,
    90                             int &VarLowIndex, int &VarHighIndex);
    91 // gets var indicies w.r.t. the ring r --
    92 // determines which one of three pGetVarIndicies((int nvars, ...) to use
    93 // based on properties of r
    94 extern void pGetVarIndicies(ring r, int *VarOffset, int &VarCompIndex,
    95                             int &VarLowIndex, int &VarHighIndex);
     84#define _pCompIndex        (currRing->pCompIndex)
     85#define _pRingCompIndex(r)  ((r)->pCompIndex)
    9686
    9787/***************************************************************
     
    10797#define _pSetCoeff0(p,n)    (p)->coef=n
    10898
    109 #define _pGetOrder(p)       ((p)->Order)
     99#define _pGetOrder(p)       ((p)->exp.l[currRing->pOrdIndex])
    110100
    111101#if defined(PDEBUG) && PDEBUG != 0
     
    121111extern Exponent_t pPDRingGetExp(ring r,poly p, int v, char* f, int l);
    122112
     113extern Exponent_t pDBSetComp(poly p, Exponent_t k, int l, char* f, int l);
     114extern Exponent_t pDBDecrComp(poly p, char* f, int l);
     115extern Exponent_t pDBAddComp(poly p, Exponent_t k, int l, char* f, int l);
     116extern Exponent_t pDBSubComp(poly p, Exponent_t k, char* f, int l);
     117extern Exponent_t pDBRingSetComp(ring r, poly p, Exponent_t k, char* f, int l);
     118
     119
    123120#define _pSetExp(p,v,e)     pPDSetExp(p,v,e,__FILE__,__LINE__)
    124121#define _pGetExp(p,v)       pPDGetExp(p,v,__FILE__,__LINE__)
     
    132129#define _pRingGetExp(r,p,v)       pPDRingGetExp(r,p,v,__FILE__,__LINE__)
    133130
     131#define _pSetComp(p,k)      pDBSetComp(p, k, 0, __FILE__, __LINE__)
     132#define _pDecrComp(p)       pDBDecrComp(p, __FILE__, __LINE__)
     133#define _pAddComp(p,v)      pDBAddComp(p,v, 0, __FILE__, __LINE__)
     134#define _pSubComp(p,v)      pDBSubComp(p,v, __FILE__, __LINE__)
     135#define _pRingSetComp(r,p,k)  pDBRingSetComp(r, p, k, __FILE__, __LINE__)
     136
     137#define pSetCompS(p, k, l) pDBSetComp(p, k, l, __FILE__, __LINE__)
     138
    134139#else  // ! (defined(PDEBUG) && PDEBUG != 0)
    135140
    136 #define _pSetExp(p,v,e)     (p)->exp[_pExpIndex(v)]=(e)
    137 #define _pGetExp(p,v)       (p)->exp[_pExpIndex(v)]
    138 #define _pIncrExp(p,v)      ((p)->exp[_pExpIndex(v)])++
    139 #define _pDecrExp(p,v)      ((p)->exp[_pExpIndex(v)])--
    140 #define _pAddExp(p,i,v)     ((p)->exp[_pExpIndex(i)]) += (v)
    141 #define _pSubExp(p,i,v)     ((p)->exp[_pExpIndex(i)]) -= (v)
    142 #define _pMultExp(p,i,v)    ((p)->exp[_pExpIndex(i)]) *= (v)
    143 
    144 #define _pRingSetExp(r,p,v,e)     (p)->exp[_pRingExpIndex(r,v)]=(e)
    145 #define _pRingGetExp(r,p,v)       (p)->exp[_pRingExpIndex(r,v)]
    146 
    147 #endif // defined(PDEBUG) && PDEBUG != 0
    148 
    149 inline Exponent_t _pGetExpSum(poly p1, poly p2, int i)
    150 {
    151   int index = _pExpIndex(i);
    152   return p1->exp[index] + p2->exp[index];
    153 }
    154 inline Exponent_t _pGetExpDiff(poly p1, poly p2, int i)
    155 {
    156   int index = _pExpIndex(i);
    157   return p1->exp[index] - p2->exp[index];
    158 }
    159 
    160 #define _pGetComp(p)        ((p)->exp[_pCompIndex])
     141#define _pSetExp(p,v,E)     (p)->exp.e[_pExpIndex(v)]=(E)
     142#define _pGetExp(p,v)       (p)->exp.e[_pExpIndex(v)]
     143#define _pIncrExp(p,v)      ((p)->exp.e[_pExpIndex(v)])++
     144#define _pDecrExp(p,v)      ((p)->exp.e[_pExpIndex(v)])--
     145#define _pAddExp(p,i,v)     ((p)->exp.e[_pExpIndex(i)]) += (v)
     146#define _pSubExp(p,i,v)     ((p)->exp.e[_pExpIndex(i)]) -= (v)
     147#define _pMultExp(p,i,v)    ((p)->exp.e[_pExpIndex(i)]) *= (v)
     148
     149#define _pRingSetExp(r,p,v,e)     (p)->exp.e[_pRingExpIndex(r,v)]=(e)
     150#define _pRingGetExp(r,p,v)       (p)->exp.e[_pRingExpIndex(r,v)]
     151
    161152#define _pSetComp(p,k)      _pGetComp(p) = (k)
    162 #define _pIncrComp(p)       _pGetComp(p)++
    163153#define _pDecrComp(p)       _pGetComp(p)--
    164154#define _pAddComp(p,v)      _pGetComp(p) += (v)
    165155#define _pSubComp(p,v)      _pGetComp(p) -= (v)
    166 
    167 #define _pRingGetComp(r,p)        ((p)->exp[_pRingCompIndex(r)])
    168 #define _pRingSetComp(r,p,k)      (_pRingGetComp(p) = (k))
     156#define _pRingSetComp(r,p,k)      (_pRingGetComp(r, p) = (k))
     157#define pSetCompS(p, k,l)     _pSetComp(p, k)
     158
     159#endif // defined(PDEBUG) && PDEBUG != 0
     160
     161#define _pGetComp(p)        ((p)->exp.e[_pCompIndex])
     162#define _pIncrComp(p)       _pGetComp(p)++
     163#define _pRingGetComp(r,p)        ((p)->exp.e[_pRingCompIndex(r)])
     164
     165inline Exponent_t _pGetExpSum(poly p1, poly p2, int i)
     166{
     167  int index = _pExpIndex(i);
     168  return p1->exp.e[index] + p2->exp.e[index];
     169}
     170inline Exponent_t _pGetExpDiff(poly p1, poly p2, int i)
     171{
     172  int index = _pExpIndex(i);
     173  return p1->exp.e[index] - p2->exp.e[index];
     174}
     175
    169176
    170177inline void _pGetExpV(poly p, Exponent_t *ev)
     
    193200#ifdef MDEBUG
    194201
    195 poly    pDBInit(char *f, int l);
     202poly    pDBInit(memHeap h, char *f, int l);
    196203poly    pDBCopy(poly a, char *f, int l);
     204poly    pDBCopy(memHeap h, poly a, char *f, int l);
    197205poly    pDBCopy1(poly a, char *f, int l);
    198 poly    pDBHead(poly a, char *f, int l);
     206poly    pDBHead(memHeap h, poly a, char *f, int l);
    199207poly    pDBHead0(poly a, char *f, int l);
    200208poly    pDBFetchCopy(ring r, poly a, char *f, int l);
    201 
    202 void    pDBDelete(poly * a, char * f, int l);
    203 void    pDBDelete1(poly * a, char * f, int l);
    204 
    205 #define pDBNew(f,l)  (poly) mmDBAllocHeap(mm_specHeap, f,l)
    206 #define _pNew()      (poly) mmDBAllocHeap(mm_specHeap, __FILE__, __LINE__)
    207 #define _pInit()     (poly) pDBInit(__FILE__,__LINE__)
    208 
    209 #define pDBFree1(a,f,l) mmDBFreeHeap((void*)a, mm_specHeap, f, l)
    210 
    211 #define _pDelete(a)     pDBDelete((a),__FILE__,__LINE__)
    212 #define _pDelete1(a)    pDBDelete1((a),__FILE__,__LINE__)
    213 
    214 #define _pCopy(A)       pDBCopy(A,__FILE__,__LINE__)
     209poly    pDBFetchCopyDelete(ring r, poly a, char *f, int l);
     210poly    pDBFetchHead(ring r, poly a, char *f, int l);
     211poly    pDBFetchHeadDelete(ring r, poly a, char *f, int l);
     212poly    pDBShallowCopyDeleteHead(memHeap d_h,poly *s_p,memHeap s_h,
     213                                 char *f,int l);
     214poly    pDBShallowCopyDelete(memHeap d_h,poly *s_p,memHeap s_h, char *f,int l);
     215
     216
     217void    pDBDelete(poly * a, memHeap h, char * f, int l);
     218void    pDBDelete1(poly * a, memHeap h, char * f, int l);
     219
     220#define pDBNew(h, f,l)  (poly) mmDBAllocHeap(h, f,l)
     221#define _pNew(h)        (poly) mmDBAllocHeap(h, __FILE__, __LINE__)
     222#define _pInit(h)       (poly) pDBInit(h, __FILE__,__LINE__)
     223
     224#define pDBFree1(a,h,f,l)   mmDBFreeHeap((void*)a, h, f, l)
     225#define _pFree1(a, h)       mmDBFreeHeap((void*)a, h, __FILE__, __LINE__)
     226
     227#define _pDelete(a, h)     pDBDelete((a),h, __FILE__,__LINE__)
     228#define _pDelete1(a, h)    pDBDelete1((a),h, __FILE__,__LINE__)
     229
     230#define _pCopy(h, A)    pDBCopy(h,A,__FILE__,__LINE__)
    215231#define _pCopy1(A)      pDBCopy1(A, __FILE__,__LINE__)
    216 #define _pHead(A)       pDBHead(A,__FILE__,__LINE__)
     232#define _pHead(h, A)    pDBHead(h, A,__FILE__,__LINE__)
    217233#define _pHead0(A)      pDBHead0(A, __FILE__,__LINE__)
    218 #define _pFetchCopy(r,A)    pDBFetchCopy(r, A,__FILE__,__LINE__)
     234
     235#define _pShallowCopyDeleteHead(dest_heap, source_p, source_heap) \
     236  pDBShallowCopyDeleteHead(dest_heap, source_p, source_heap,__FILE__,__LINE__)
     237#define _pShallowCopyDelete(dest_heap, source_p, source_heap) \
     238  pDBShallowCopyDelete(dest_heap, source_p, source_heap,__FILE__,__LINE__)
     239
     240#define _pFetchCopy(r,A)        pDBFetchCopy(r, A,__FILE__,__LINE__)
     241#define _pFetchCopyDelete(r,A)  pDBFetchCopyDelete(r, A,__FILE__,__LINE__)
     242#define _pFetchHead(r,A)        pDBFetchHead(r, A,__FILE__,__LINE__)
     243#define _pFetchHeadDelete(r,A)  pDBFetchHeadDelete(r, A,__FILE__,__LINE__)
     244
     245#define _pRingFree1(r, A)      pDBFreeHeap(A,r->mm_specHeap,__FILE__,__LINE__)
     246#define _pRingDelete1(r, A)     pDBDelete1(A,r->mm_specHeap,__FILE__,__LINE__)
     247#define _pRingDelete(r, A)      pDBDelete(A,r->mm_specHeap,__FILE__, __LINE__)
    219248
    220249#else // ! MDEBUG
    221250
    222 inline poly _pNew()
    223 {
    224   void * p;
    225   AllocHeap(p, mm_specHeap);
    226   return (poly)p;
    227 }
    228 
    229 inline poly    _pInit(void)
    230 {
    231   poly p = _pNew();
    232   memsetW((long*)p,0, pMonomSizeW);
     251inline poly _pNew(memHeap h)
     252{
     253  poly p;
     254  AllocHeap(p, h);
    233255  return p;
    234256}
    235257
    236 extern void    _pDelete(poly * a);
    237 extern void    _pDelete1(poly * a);
     258inline poly    _pInit(memHeap h)
     259{
     260  poly p;
     261  AllocHeap(p, h);
     262  memsetW((long *)p,0, pMonomSizeW);
     263  return p;
     264}
     265
     266#define _pFree1(a, h)       FreeHeap(a, h)
     267#define _pRingFree1(r, a)   FreeHeap(a, r->mm_specHeap)
     268#define _pRingDelete1(r, A) _pDelete1(A, r->mm_specHeap)
     269#define _pRingDelete(r, A)  _pDelete(A, r->mm_specHeap)
     270
     271extern void    _pDelete(poly * a, memHeap h);
     272extern void    _pDelete1(poly * a, memHeap h);
    238273
    239274extern poly    _pCopy(poly a);
     275extern poly    _pCopy(memHeap h, poly a);
    240276extern poly    _pCopy1(poly a);
    241 extern poly    _pHead(poly a);
     277extern poly    _pHead(memHeap h, poly a);
    242278extern poly    _pHead0(poly a);
     279extern poly    _pShallowCopyDeleteHead(memHeap d_h, poly *s_p, memHeap s_h);
     280extern poly    _pShallowCopyDelete(memHeap d_h, poly *s_p, memHeap s_h);
     281
    243282extern poly    _pFetchCopy(ring r,poly a);
     283extern poly    _pFetchCopyDelete(ring r,poly a);
     284extern poly    _pFetchHead(ring r,poly a);
     285extern poly    _pFetchHeadDelete(ring r,poly a);
     286
    244287#endif // MDEBUG
    245288
    246289#define _pCopy2(p1, p2)     memcpyW(p1, p2, pMonomSizeW)
    247 #define _pFree1(a)          FreeHeap(a, mm_specHeap)
     290
    248291
    249292/***************************************************************
     
    280323#endif // defined(PDEBUG) && PDEBUG == 1
    281324{
    282   // OK -- this might be the only place where we are kind of quick and
    283   // dirty: the following only works correctly if all exponents are
    284   // positive and the sum of two exponents does not exceed
    285   // EXPONENT_MAX
    286   Exponent_t c2 = _pGetComp(p2);
    287   int i = pVariables1W;
    288   unsigned long* s1 = (unsigned long*) &(p1->exp[0]);
    289   const unsigned long* s2 = (unsigned long*) &(p2->exp[0]);
    290   // set comp of p2 temporarily to 0, so that nothing is added to comp of p1
    291   _pSetComp(p2, 0);
    292 
     325  int i = currRing->ExpLSize;
     326  long* s1 = &(p1->exp.l[0]);
     327  const long* s2 = &(p2->exp.l[0]);
    293328  for (;;)
    294329  {
     
    299334    s2++;
    300335  }
    301   // reset comp of p2
    302   _pSetComp(p2, c2);
    303   _pGetOrder(p1) += _pGetOrder(p2);
    304 }
    305 
    306 // Makes p1 a copy of p2 and adds on exponets of p3
     336}
     337
     338#if defined(PDEBUG) && PDEBUG == 1
     339#define _pMonSubFast(p1, p2)  pDBMonSubFast(p1, p2, __FILE__, __LINE__)
     340extern  void pDBMonSubFast(poly p1, poly p2, char* f, int l);
     341inline void __pMonSubFast(poly p1, poly p2)
     342#else
     343  DECLARE(void, _pMonSubFast(poly p1, poly p2))
     344#endif // defined(PDEBUG) && PDEBUG == 1
     345{
     346  int i = currRing->ExpLSize;
     347  long* s1 = &(p1->exp.l[0]);
     348  const long* s2 = &(p2->exp.l[0]);
     349
     350  for (;;)
     351  {
     352    *s1 -= *s2;
     353    i--;
     354    if (i==0) break;
     355    s1++;
     356    s2++;
     357  }
     358}
     359
     360// Makes p1 a copy of p2 and adds on exponents of p3
    307361#if defined(PDEBUG) && PDEBUG == 1
    308362#define _pCopyAddFast(p1, p2, p3)  pDBCopyAddFast(p1, p2, p3, __FILE__, __LINE__)
     
    313367#endif // defined(PDEBUG) && PDEBUG == 1
    314368{
    315   unsigned long* s1 = (unsigned long*) &(p1->exp[0]);
    316   const unsigned long* s2 = (unsigned long*) &(p2->exp[0]);
    317   const unsigned long* s3 = (unsigned long*) &(p3->exp[0]);
    318   const unsigned long* const ub = s3 + pVariables1W;
     369  long* s1 = &(p1->exp.l[0]);
     370  const long* s2 = &(p2->exp.l[0]);
     371  const long* s3 = &(p3->exp.l[0]);
     372  const long* const ub = s3 + currRing->ExpLSize;
    319373
    320374  p1->next = p2->next;
     
    331385  // we first are supposed to do a copy from p2 to p1 -- therefore,
    332386  // component of p1 is set to comp of p2
    333   _pSetComp(p1, _pGetComp(p2));
    334   _pGetOrder(p1) = _pGetOrder(p2) + _pGetOrder(p3);
     387  // _pSetComp(p1, _pGetComp(p2));
    335388}
    336389
     
    344397#endif // defined(PDEBUG) && PDEBUG == 1
    345398{
    346   unsigned long* s1 = (unsigned long*) &(p1->exp[0]);
    347   const unsigned long* s2 = (unsigned long*) &(p2->exp[0]);
    348   const unsigned long* s3 = (unsigned long*) &(p3->exp[0]);
    349   const unsigned long* const ub = s3 + pVariables1W;
     399  long* s1 = &(p1->exp.l[0]);
     400  const long* s2 = &(p2->exp.l[0]);
     401  const long* s3 = &(p3->exp.l[0]);
     402  const long* const ub = s3 + currRing->ExpLSize;
    350403
    351404  p1->coef = p2->coef;
     
    359412    s2++;
    360413  }
    361   _pSetComp(p1, _pGetComp(p2));
    362   _pGetOrder(p1) = _pGetOrder(p2) + _pGetOrder(p3);
    363 }
    364 
    365 // Similar to pCopyAddFast0, except that we do not recompute the Order,
    366 // but assume that it is the sum of the Order of p2 and p3
    367 #if defined(PDEBUG) && PDEBUG == 1
    368 #define _pCopyAddFastHomog(p1, p2, p3, Order)  \
    369    pDBCopyAddFastHomog(p1, p2, p3, Order, __FILE__, __LINE__)
    370 extern  void pDBCopyAddFastHomog(poly p1, poly p2, poly p3, Order_t Order,
    371                                  char* f, int l);
    372 inline void __pCopyAddFastHomog(poly p1, poly p2, poly p3, Order_t Order)
    373 #else
    374   DECLARE(void, _pCopyAddFastHomog(poly p1, poly p2, poly p3, Order_t Order))
    375 #endif // defined(PDEBUG) && PDEBUG == 1
    376 {
    377   unsigned long* s1 = (unsigned long*) &(p1->exp[0]);
    378   const unsigned long* s2 = (unsigned long*) &(p2->exp[0]);
    379   const unsigned long* s3 = (unsigned long*) &(p3->exp[0]);
    380   const unsigned long* const ub = s3 + pVariables1W;
    381 
    382   p1->coef = p2->coef;
    383   p1->Order = Order;
    384 
    385   for (;;)
    386   {
    387     *s1 = *s2 + *s3;
    388     s3++;
    389     if (s3 == ub) break;
    390     s1++;
    391     s2++;
    392   }
    393   _pSetComp(p1, _pGetComp(p2));
     414  // _pSetComp(p1, _pGetComp(p2));
    394415}
    395416
     
    419440#endif
    420441
     442// #define LONG_MONOMS
     443
     444#ifdef LONG_MONOMS
    421445DECLARE(BOOLEAN, __pDivisibleBy(poly a, poly b))
    422446{
    423 #ifdef WORDS_BIGENDIAN
    424   const unsigned long* const lb = (unsigned long*) &(a->exp[0]);;
    425   const unsigned long* s1 = ((unsigned long*) a) + pMonomSizeW -1;
    426   const unsigned long* s2 = ((unsigned long*) b) + pMonomSizeW -1;
    427 #else
    428   const unsigned long* const lb = ((unsigned long*) a) + pMonomSizeW;
    429   const unsigned long* s1 = (unsigned long*) &(a->exp[0]);
    430   const unsigned long* s2 = (unsigned long*) &(b->exp[0]);
    431 #endif
     447  const unsigned long* const lb = (unsigned long*) &(a->exp.l[currRing->pDivLow]);
     448  const unsigned long* s1 = (unsigned long*) &(a->exp.l[currRing->pDivHigh]);
     449  const unsigned long* s2 = (unsigned long*) &(b->exp.l[currRing->pDivHigh]);
    432450
    433451  for (;;)
     
    436454    // not have their first bit set
    437455    if ((*s2 - *s1) & P_DIV_MASK) return FALSE;
    438 #ifdef WORDS_BIGENDIAN
    439456    if (s1 == lb) return TRUE;
    440457    s1--;
    441458    s2--;
    442 #else
    443     s1++;
    444     if (s1 == lb) return TRUE;
    445     s2++;
    446 #endif
    447   }
    448 }
     459  }
     460}
     461#else
     462DECLARE(BOOLEAN, __pDivisibleBy(poly a, poly b))
     463{
     464  int i=pVariables; // assume i>0
     465
     466  for (;;)
     467  {
     468    if (_pGetExp(a,i) > _pGetExp(b,i))
     469      return FALSE;
     470    i--;
     471    if (i==0)
     472      return TRUE;
     473  }
     474}
     475#endif
    449476
    450477#if defined(PDEBUG) && PDEBUG == 1
     
    486513DECLARE(BOOLEAN, _pEqual(poly p1, poly p2))
    487514{
    488   const long *s1 = (long*) &(p1->exp[0]);
    489   const long *s2 = (long*) &(p2->exp[0]);
    490   const long* const lb = s1 + pVariables1W;
     515  const long *s1 = (long*) &(p1->exp.l[0]);
     516  const long *s2 = (long*) &(p2->exp.l[0]);
     517  const long* const lb = s1 + currRing->ExpLSize;
    491518
    492519  for(;;)
     
    498525  }
    499526}
     527/***************************************************************
     528 *
     529 * Misc. things
     530 *
     531 *
     532 ***************************************************************/
     533// Divisiblity tests based on Short Exponent Vectors
     534#ifdef PDEBUG
     535#define _pShortDivisibleBy(a, sev_a, b, not_sev_b) \
     536  pDBShortDivisibleBy(a, sev_a, b, not_sev_b, __FILE__, __LINE__)
     537BOOLEAN pDBShortDivisibleBy(poly p1, unsigned long sev_1,
     538                            poly p2, unsigned long not_sev_2,
     539                            char* f, int l);
     540#else
     541#define _pShortDivisibleBy(a, sev_a, b, not_sev_b) \
     542  ( ! (sev_a & not_sev_b) && pDivisibleBy(a, b))
     543#endif
     544
    500545
    501546/***************************************************************
     
    506551 ***************************************************************/
    507552
     553#ifdef LONG_MONOMS
    508554DECLARE(int, __pExpQuerSum2(poly p, int from, int to))
    509555{
    510   int j = p->exp[from];
    511   int i = from + 1;
     556  int j = 0;
     557  int i = from ;
    512558
    513559  for(;;)
    514560  {
    515     if (i > to) return j;
    516     j += p->exp[i];
     561    if (i > to) break;
     562    j += p->exp.e[i];
    517563    i++;
    518564  }
    519 }
    520 
    521 #define _pExpQuerSum(p)  __pExpQuerSum2(p, pVarLowIndex, pVarHighIndex)
    522 
    523 inline int _pExpQuerSum1(poly p, int to)
    524 {
    525   int ei_to = _pExpIndex(to);
    526   int ei_1 = _pExpIndex(1);
    527 
    528   if (ei_1 > ei_to)
    529     return __pExpQuerSum2(p, ei_to, ei_1);
    530   else
    531     return __pExpQuerSum2(p, ei_1, ei_to);
    532 }
    533 
     565  if (from <= _pCompIndex && to >= _pCompIndex)
     566    return j - _pGetComp(p);
     567  return j;
     568}
     569
     570#define _pExpQuerSum(p)  __pExpQuerSum2(p, currRing->pVarLowIndex, currRing->pVarHighIndex)
    534571
    535572inline int _pExpQuerSum2(poly p,int from,int to)
     
    544581}
    545582
     583#else
     584DECLARE(int, _pExpQuerSum(poly p))
     585{
     586  int s = 0;
     587  int i = pVariables;
     588  for (;;)
     589  {
     590    s += _pGetExp(p, i);
     591    i--;
     592    if (i==0) return s;
     593  }
     594}
     595#endif
     596
    546597#endif // POLYS_IMPL_H
Note: See TracChangeset for help on using the changeset viewer.