source: git/libpolys/polys/monomials/p_polys.h @ 0145cb4

spielwiese
Last change on this file since 0145cb4 was 0145cb4, checked in by Hans Schoenemann <hannes@…>, 13 years ago
p_IsConstantPoly ->p_polys.h
  • Property mode set to 100644
File size: 54.6 KB
Line 
1/****************************************
2*  Computer Algebra System SINGULAR     *
3****************************************/
4/***************************************************************
5 *  File:    p_polys.h
6 *  Purpose: declaration of poly stuf which are independent of
7 *           currRing
8 *  Author:  obachman (Olaf Bachmann)
9 *  Created: 9/00
10 *  Version: $Id$
11 *******************************************************************/
12#ifndef P_POLYS_H
13#define P_POLYS_H
14
15#include <polys/monomials/ring.h>
16#include <polys/monomials/monomials.h>
17#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>
21
22/***************************************************************
23 *
24 * Primitives for accessing and setting fields of a poly
25 * poly must be != NULL
26 *
27 ***************************************************************/
28// next
29#define pNext(p)            ((p)->next)
30#define pIter(p)            ((p) = (p)->next)
31
32// coeff
33#define pGetCoeff(p)        ((p)->coef)
34// deletes old coeff before setting the new one
35#define pSetCoeff0(p,n)     (p)->coef=(n)
36#define p_GetCoeff(p,r)     pGetCoeff(p)
37#define p_SetCoeff0(p,n,r)  pSetCoeff0(p,n)
38// deletes old p->coef and sets new one
39static inline number p_SetCoeff(poly p, number n, ring r);
40
41// get Order
42static inline long p_GetOrder(poly p, ring r);
43
44// Component
45static inline unsigned long p_SetComp(poly p, unsigned long c, ring r);
46static inline unsigned long p_AddComp(poly p, unsigned long v, ring r);
47static inline unsigned long p_SubComp(poly p, unsigned long v, ring r);
48
49// Exponent
50static inline long p_GetExp(poly p, int v, ring r);
51static inline long p_SetExp(poly p, int v, long e, ring r);
52static inline long p_IncrExp(poly p, int v, ring r);
53static inline long p_DecrExp(poly p, int v, ring r);
54static inline long p_AddExp(poly p, int v, long ee, ring r);
55static inline long p_SubExp(poly p, int v, long ee, ring r);
56static inline long p_MultExp(poly p, int v, long ee, ring r);
57static inline long p_GetExpSum(poly p1, poly p2, int i, ring r);
58static inline long p_GetExpDiff(poly p1, poly p2, int i, ring r);
59
60/***************************************************************
61 *
62 * Allocation/Initalization/Deletion
63 * except for pHead, all polys must be != NULL
64 *
65 ***************************************************************/
66static inline poly p_New(ring r);
67static inline poly p_New(ring r, omBin bin);
68static inline poly p_Init(ring r);
69static inline poly p_Init(ring r, omBin bin);
70static inline poly p_LmInit(poly p, ring r);
71static inline poly p_LmInit(poly s_p, ring s_r, ring d_p);
72static inline poly p_LmInit(poly s_p, ring s_r, ring d_p, omBin d_bin);
73static inline poly p_Head(poly p, ring r);
74static inline void p_LmFree(poly p, ring r);
75static inline void p_LmFree(poly *p, ring r);
76static inline poly p_LmFreeAndNext(poly p, ring r);
77static inline void p_LmDelete(poly p, ring r);
78static inline void p_LmDelete(poly *p, ring r);
79static inline poly p_LmDeleteAndNext(poly p, ring r);
80
81/***************************************************************
82 *
83 * Operation on ExpVectors: assumes polys != NULL
84 *
85 ***************************************************************/
86// ExpVextor(d_p) = ExpVector(s_p)
87static inline void p_ExpVectorCopy(poly d_p, poly s_p, ring r);
88// adjustments for negative weights
89static inline void p_MemAdd_NegWeightAdjust(poly p, ring r);
90static inline void p_MemSub_NegWeightAdjust(poly p, ring r);
91// ExpVector(p1) += ExpVector(p2)
92static inline void p_ExpVectorAdd(poly p1, poly p2, ring r);
93// ExpVector(p1) -= ExpVector(p2)
94static inline void p_ExpVectorSub(poly p1, poly p2, ring r);
95// ExpVector(p1) += ExpVector(p2) - ExpVector(p3)
96static inline void p_ExpVectorAddSub(poly p1, poly p2, poly p3, ring r);
97// ExpVector(pr) = ExpVector(p1) + ExpVector(p2)
98static inline void p_ExpVectorSum(poly pr, poly p1, poly p2, ring r);
99/// ExpVector(pr) = ExpVector(p1) + ExpVector(p2)
100static inline void p_ExpVectorDiff(poly pr, poly p1, poly p2, ring r);
101/// returns TRUE if ExpVector(p1) == ExpVector(p2), FALSE, otherwise
102static inline BOOLEAN p_ExpVectorEqual(poly p1, poly p2, ring r);
103/// compute the degree of the leading monomial of p
104/// with respect to weigths 1
105/// the ordering may not be compatible with degree so do not use p->Order
106static inline long p_Totaldegree(poly p, ring r);
107
108static inline void p_GetExpV(poly p, int *ev, ring r);
109static inline void p_SetExpV(poly p, int *ev, ring r);
110
111
112/***************************************************************
113 *
114 * Comparisons: they are all done without regarding coeffs
115 *
116 ***************************************************************/
117static inline int p_LmCmp(poly p, poly q, ring r);
118#define p_LmCmpAction(p, q, r, actionE, actionG, actionS) \
119  _p_LmCmpAction(p, q, r, actionE, actionG, actionS)
120
121// returns 1 if ExpVector(p)==ExpVector(q): does not compare numbers !!
122#define p_LmEqual(p1, p2, r) p_ExpVectorEqual(p1, p2, r)
123
124// pCmp: args may be NULL
125// returns: (p2==NULL ? 1 : (p1 == NULL ? -1 : p_LmCmp(p1, p2)))
126static inline int p_Cmp(poly p1, poly p2, ring r);
127
128
129/***************************************************************
130 *
131 * Divisiblity tests, args must be != NULL, except for
132 * pDivisbleBy
133 *
134 ***************************************************************/
135static inline BOOLEAN p_DivisibleBy(poly a, poly b, ring r);
136static inline BOOLEAN p_LmDivisibleBy(poly a, poly b, ring r);
137static inline BOOLEAN p_LmDivisibleByNoComp(poly a, poly b, ring r);
138unsigned long p_GetShortExpVector(poly a, ring r);
139static inline BOOLEAN p_LmShortDivisibleBy(poly a, unsigned long sev_a,
140                                      poly b, unsigned long not_sev_b, ring r);
141
142static inline BOOLEAN p_DivisibleBy(poly a, ring r_a, poly b, ring r_b);
143static inline BOOLEAN p_LmDivisibleBy(poly a, ring r_a, poly b, ring r_b);
144static inline BOOLEAN p_LmShortDivisibleBy(poly a, unsigned long sev_a, ring r_a,
145                                      poly b, unsigned long not_sev_b, ring r_b);
146
147/***************************************************************
148 *
149 * Misc things on Lm
150 *
151 ***************************************************************/
152// test if the monomial is a constant as a vector component
153// i.e., test if all exponents are zero
154static inline BOOLEAN p_LmIsConstantComp(const poly p, const ring r);
155static inline BOOLEAN p_LmIsConstant(const poly p, const ring r);
156
157// return TRUE, if p_LmExpVectorAdd stays within ExpBound of ring r,
158//       FALSE, otherwise
159static inline BOOLEAN p_LmExpVectorAddIsOk(const poly p1, const poly p2, ring r);
160
161/***************************************************************
162 *
163 * Misc things on polys
164 *
165 ***************************************************************/
166// return the maximal exponent of p
167static inline unsigned long p_GetMaxExp(poly p, ring r);
168// return the maximal exponent of p in form of the maximal long var
169unsigned long p_GetMaxExpL(poly p, const ring r, unsigned long l_max = 0);
170// return monomial r such that GetExp(r,i) is maximum of all
171// monomials in p; coeff == 0, next == NULL, ord is not set
172poly p_GetMaxExpP(poly p, ring r);
173
174// suppose that l is a long var in r, return maximal exponent of l
175static inline unsigned long p_GetMaxExp(const unsigned long l, const ring r);
176
177// return the TotalDegree of the long var l
178static inline unsigned long p_GetTotalDegree(const unsigned long l, const ring r);
179// return the total degree of the long var l containing number_of_exp exponents
180static inline unsigned long p_GetTotalDegree(const unsigned long l, const ring r, const int number_of_exps);
181
182int p_MinDeg(poly p,intvec *w, const ring R);
183
184long p_DegW(poly p, const short *w, const ring R);
185
186
187// like the respective p_LmIs* routines, except that p might be empty
188static inline BOOLEAN p_IsConstantComp(const poly p, const ring r);
189static inline BOOLEAN p_IsConstant(const poly p, const ring r);
190static inline BOOLEAN p_IsConstantPoly(const poly p, const ring r)
191{
192  poly pp=p;
193  while(pp!=NULL)
194  {
195    if (! p_LmIsConstantComp(pp, r))
196      return FALSE;
197    pIter(pp);
198  }
199  return TRUE;
200}
201
202
203// return TRUE if all monoms have the same component
204BOOLEAN   p_OneComp(poly p, ring r);
205
206// return i, if head depends only on var(i)
207int       p_IsPurePower(const poly p, const ring r);
208
209// return i, if poly depends only on var(i)
210int       p_IsUnivariate(poly p, const ring r);
211
212// set entry e[i] to 1 if var(i) occurs in p, ignore var(j) if e[j]>0
213// return #(e[i]>0)
214int      p_GetVariables(poly p, int * e, const ring r);
215
216// returns the poly representing the integer i
217poly      p_ISet(int i, ring r);
218
219// returns the poly representing the number n, destroys n
220poly      p_NSet(number n, ring r);
221
222/***************************************************************
223 *
224 * Copying/Deletion of polys: args may be NULL
225 *
226 ***************************************************************/
227// returns a copy of p
228static inline poly p_Copy(poly p, const ring r);
229// returns a copy of p with Lm(p) from lmRing and Tail(p) from tailRing
230static inline poly p_Copy(poly p, const ring lmRing, const ring tailRing);
231// deletes *p, and sets *p to NULL
232static inline void p_Delete(poly *p, const ring r);
233static inline void p_Delete(poly *p, const ring lmRing, const ring tailRing);
234
235// copys monomials of p, allocates new monomials from bin,
236// deletes monomoals of p
237static inline poly p_ShallowCopyDelete(poly p, const ring r, omBin bin);
238// simial but does it only for leading monomial
239static inline poly p_LmShallowCopyDelete(poly p, const ring r, omBin bin);
240// simply deletes monomials, does not free coeffs
241void p_ShallowDelete(poly *p, const ring r);
242
243
244
245/***************************************************************
246 *
247 * Copying/Deleteion of polys: args may be NULL
248 *  - p/q as arg mean a poly
249 *  - m a monomial
250 *  - n a number
251 *  - pp (resp. qq, mm, nn) means arg is constant
252 *  - p (resp, q, m, n)     means arg is destroyed
253 *
254 ***************************************************************/
255// returns -p, p is destroyed
256static inline poly p_Neg(poly p, const ring r);
257
258// returns p*n, p is const (i.e. copied)
259static inline poly pp_Mult_nn(poly p, number n, const ring r);
260// returns p*n, destroys p
261static inline poly p_Mult_nn(poly p, number n, const ring r);
262static inline poly p_Mult_nn(poly p, number n, const ring lmRing, const ring tailRing);
263
264// returns p*m, does neither destroy p nor m
265static inline poly pp_Mult_mm(poly p, poly m, const ring r);
266// returns p*m, destroys p, const: m
267static inline poly p_Mult_mm(poly p, poly m, const ring r);
268
269/// returns p+q, destroys p and q
270static inline poly p_Add_q(poly p, poly q, const ring r);
271/// like p_Add_q, except that if lp == pLength(lp) lq == pLength(lq) then lp == pLength(p+q)
272static inline poly p_Add_q(poly p, poly q, int &lp, int lq, const ring r);
273
274poly      p_Sub(poly a, poly b, const ring r);
275
276// return p - m*q, destroys p; const: q,m
277static inline poly p_Minus_mm_Mult_qq(poly p, poly m, poly q, const ring r);
278// like p_Minus_mm_Mult_qq, except that if lp == pLength(lp) lq == pLength(lq)
279// then lp == pLength(p -m*q)
280static inline poly p_Minus_mm_Mult_qq(poly p, poly m, poly q, int &lp, int lq,
281                                 poly spNoether, const ring r);
282// returns p + m*q destroys p, const: q, m
283static inline poly p_Plus_mm_Mult_qq(poly p, poly m, poly q, const ring r);
284
285// returns p + m*q destroys p, const: q, m
286static inline poly p_Plus_mm_Mult_qq(poly p, poly m, poly q, int &lp, int lq,
287                                const ring r);
288
289// returns p*q, destroys p and q
290static inline poly p_Mult_q(poly p, poly q, const ring r);
291// returns p*q, does neither destroy p nor q
292static inline poly pp_Mult_qq(poly p, poly q, const ring r);
293
294// returns p*Coeff(m) for such monomials pm of p, for which m is divisble by pm
295static inline poly pp_Mult_Coeff_mm_DivSelect(poly p, const poly m, const ring r);
296
297// returns p*Coeff(m) for such monomials pm of p, for which m is divisble by pm
298// if lp is length of p on input then lp is length of returned poly on output
299static inline poly pp_Mult_Coeff_mm_DivSelect(poly p, int &lp, const poly m, const ring r);
300
301// returns merged p and q, assumes p and q have no monomials which are equal
302static inline poly p_Merge_q(poly p, poly c, const ring r);
303// sorts p using bucket sort: returns sorted poly
304// assumes that monomials of p are all different
305// reverses it first, if revert == TRUE, use this if input p is "almost" sorted
306// correctly
307static inline poly p_SortMerge(poly p, const ring r, BOOLEAN revert = FALSE);
308// like SortMerge, except that p may have equal monimals
309static inline poly p_SortAdd(poly p, const ring r, BOOLEAN revert = FALSE);
310
311poly      p_Power(poly p, int i, const ring r);
312/***************************************************************
313 *
314 * Misc stuff
315 *
316 ***************************************************************/
317/*2
318* returns the length of a (numbers of monomials)
319*/
320static inline int pLength(poly a)
321{
322  int l = 0;
323  while (a!=NULL)
324  {
325    pIter(a);
326    l++;
327  }
328  return l;
329}
330
331void      p_Norm(poly p1, const ring r);
332void      p_Normalize(poly p,const ring r);
333
334void      p_Content(poly p, const ring r);
335//void      p_SimpleContent(poly p, int s, const ring r);
336
337poly      p_Cleardenom(poly p, const ring r);
338void      p_Cleardenom_n(poly p, const ring r,number &c);
339number    p_GetAllDenom(poly ph, const ring r);
340
341int       pSize( poly p, const ring r );
342
343// homogenizes p by multiplying certain powers of the varnum-th variable
344poly      p_Homogen (poly p, int varnum, const ring r);
345
346BOOLEAN   p_IsHomogeneous (poly p, const ring r);
347
348static inline void p_Setm(poly p, const ring r);
349p_SetmProc p_GetSetmProc(ring r);
350
351poly      p_Subst(poly p, int n, poly e, const ring r);
352
353// TODO:
354#define p_SetmComp  p_Setm
355
356// sets component of poly a to i, returns length of p
357static inline   void p_SetCompP(poly p, int i, ring r)
358{
359  if (p != NULL)
360  {
361#ifdef PDEBUG
362    poly q = p;
363    int l = 0;
364#endif
365
366    if (rOrd_SetCompRequiresSetm(r))
367    {
368      do
369      {
370        p_SetComp(p, i, r);
371        p_SetmComp(p, r);
372#ifdef PDEBUG
373        l++;
374#endif
375        pIter(p);
376      }
377      while (p != NULL);
378    }
379    else
380    {
381      do
382      {
383        p_SetComp(p, i, r);
384#ifdef PDEBUG
385        l++;
386#endif
387        pIter(p);
388      }
389      while(p != NULL);
390    }
391#ifdef PDEBUG
392    p_Test(q, r);
393    assume(l == pLength(q));
394#endif
395  }
396}
397
398static inline   void p_SetCompP(poly p, int i, ring lmRing, ring tailRing)
399{
400  if (p != NULL)
401  {
402    p_SetComp(p, i, lmRing);
403    p_SetmComp(p, lmRing);
404    p_SetCompP(pNext(p), i, tailRing);
405  }
406}
407
408// returns maximal column number in the modul element a (or 0)
409static inline long p_MaxComp(poly p, ring lmRing, ring tailRing)
410{
411  long result,i;
412
413  if(p==NULL) return 0;
414  result = p_GetComp(p, lmRing);
415  if (result != 0)
416  {
417    loop
418    {
419      pIter(p);
420      if(p==NULL) break;
421      i = p_GetComp(p, tailRing);
422      if (i>result) result = i;
423    }
424  }
425  return result;
426}
427
428static inline long p_MaxComp(poly p,ring lmRing) {return p_MaxComp(p,lmRing,lmRing);}
429
430static inline   long p_MinComp(poly p, ring lmRing, ring tailRing)
431{
432  long result,i;
433
434  if(p==NULL) return 0;
435  result = p_GetComp(p,lmRing);
436  if (result != 0)
437  {
438    loop
439    {
440      pIter(p);
441      if(p==NULL) break;
442      i = p_GetComp(p,tailRing);
443      if (i<result) result = i;
444    }
445  }
446  return result;
447}
448
449static inline long p_MinComp(poly p,ring lmRing) {return p_MinComp(p,lmRing,lmRing);}
450
451/***************************************************************
452 *
453 * poly things which are independent of ring
454 *
455 ***************************************************************/
456static inline int       pLength(poly a);
457static inline poly      pLast(poly a, int &length);
458inline   poly      pLast(poly a) { int l; return pLast(a, l);}
459static inline poly pReverse(poly p);
460void      pEnlargeSet(poly**p, int length, int increment);
461
462
463/***************************************************************
464 *
465 * I/O
466 *
467 ***************************************************************/
468char*     p_String(poly p, ring lmRing, ring tailRing);
469char*     p_String0(poly p, ring lmRing, ring tailRing);
470void      p_Write(poly p, ring lmRing, ring tailRing);
471void      p_Write0(poly p, ring lmRing, ring tailRing);
472void      p_wrp(poly p, ring lmRing, ring tailRing);
473
474static inline char*     p_String(poly p, ring p_ring);
475static inline char*     p_String0(poly p, ring p_ring);
476static inline void      p_Write(poly p, ring p_ring);
477static inline void      p_Write0(poly p, ring p_ring);
478static inline void      p_wrp(poly p, ring p_ring);
479
480
481/***************************************************************
482 *
483 * Degree stuff -- see p_polys.cc for explainations
484 *
485 ***************************************************************/
486extern pLDegProc pLDeg;
487extern pFDegProc pFDeg;
488long p_WFirstTotalDegree(poly p, ring r);
489long p_WTotaldegree(poly p, const ring r);
490long p_WDegree(poly p,const ring r);
491long pLDeg0(poly p,int *l, ring r);
492long pLDeg0c(poly p,int *l, ring r);
493long pLDegb(poly p,int *l, ring r);
494long pLDeg1(poly p,int *l, ring r);
495long pLDeg1c(poly p,int *l, ring r);
496long pLDeg1_Deg(poly p,int *l, ring r);
497long pLDeg1c_Deg(poly p,int *l, ring r);
498long pLDeg1_Totaldegree(poly p,int *l, ring r);
499long pLDeg1c_Totaldegree(poly p,int *l, ring r);
500long pLDeg1_WFirstTotalDegree(poly p,int *l, ring r);
501long pLDeg1c_WFirstTotalDegree(poly p,int *l, ring r);
502BOOLEAN p_EqualPolys(poly p1, poly p2, const ring r);
503
504long p_Deg(poly a, const ring r);
505/***************************************************************
506 *
507 * PDEBUG stuff
508 *
509 ***************************************************************/
510#ifdef PDEBUG
511// Returns TRUE if m is monom of p, FALSE otherwise
512BOOLEAN pIsMonomOf(poly p, poly m);
513// Returns TRUE if p and q have common monoms
514BOOLEAN pHaveCommonMonoms(poly p, poly q);
515
516// p_Check* routines return TRUE if everything is ok,
517// else, they report error message and return false
518
519// check if Lm(p) is from ring r
520BOOLEAN p_LmCheckIsFromRing(poly p, ring r);
521// check if Lm(p) != NULL, r != NULL and initialized && Lm(p) is from r
522BOOLEAN p_LmCheckPolyRing(poly p, ring r);
523// check if all monoms of p are from ring r
524BOOLEAN p_CheckIsFromRing(poly p, ring r);
525// check r != NULL and initialized && all monoms of p are from r
526BOOLEAN p_CheckPolyRing(poly p, ring r);
527// check if r != NULL and initialized
528BOOLEAN p_CheckRing(ring r);
529// only do check if cond
530
531
532#define pIfThen(cond, check) do {if (cond) {check;}} while (0)
533
534BOOLEAN _p_Test(poly p, ring r, int level);
535BOOLEAN _p_LmTest(poly p, ring r, int level);
536BOOLEAN _pp_Test(poly p, ring lmRing, ring tailRing, int level);
537
538#define p_Test(p,r)     _p_Test(p, r, PDEBUG)
539#define p_LmTest(p,r)   _p_LmTest(p, r, PDEBUG)
540#define pp_Test(p, lmRing, tailRing)    _pp_Test(p, lmRing, tailRing, PDEBUG)
541
542#else // ! PDEBUG
543
544#define pIsMonomOf(p, q)        (TRUE)
545#define pHaveCommonMonoms(p, q) (TRUE)
546#define p_LmCheckIsFromRing(p,r)  ((void)0)
547#define p_LmCheckPolyRing(p,r)    ((void)0)
548#define p_CheckIsFromRing(p,r)  ((void)0)
549#define p_CheckPolyRing(p,r)    ((void)0)
550#define p_CheckRing(r)          ((void)0)
551#define P_CheckIf(cond, check)  ((void)0)
552
553#define p_Test(p,r)     (1)
554#define p_LmTest(p,r)   (1)
555#define pp_Test(p, lmRing, tailRing) (1)
556
557#endif
558
559/***************************************************************
560 *
561 * Primitives for accessing and setting fields of a poly
562 *
563 ***************************************************************/
564
565static inline number p_SetCoeff(poly p, number n, ring r)
566{
567  p_LmCheckPolyRing2(p, r);
568  n_Delete(&(p->coef), r->cf);
569  (p)->coef=n;
570  return n;
571}
572
573// order
574static inline long p_GetOrder(poly p, ring r)
575{
576  p_LmCheckPolyRing2(p, r);
577  if (r->typ==NULL) return ((p)->exp[r->pOrdIndex]);
578  int i=0;
579  loop
580  {
581    switch(r->typ[i].ord_typ)
582    {
583      case ro_wp_neg:
584        return (((long)((p)->exp[r->pOrdIndex]))-POLY_NEGWEIGHT_OFFSET);
585      case ro_syzcomp:
586      case ro_syz:
587      case ro_cp:
588        i++;
589        break;
590      //case ro_dp:
591      //case ro_wp:
592      default:
593        return ((p)->exp[r->pOrdIndex]);
594    }
595  }
596}
597
598// Setm
599static inline void p_Setm(poly p, const ring r)
600{
601  p_CheckRing2(r);
602  r->p_Setm(p, r);
603}
604
605// component
606static inline  unsigned long p_SetComp(poly p, unsigned long c, ring r)
607{
608  p_LmCheckPolyRing2(p, r);
609  pAssume2(rRing_has_Comp(r));
610  __p_GetComp(p,r) = c;
611  return c;
612}
613static inline unsigned long p_AddComp(poly p, unsigned long v, ring r)
614{
615  p_LmCheckPolyRing2(p, r);
616  pAssume2(rRing_has_Comp(r));
617  return __p_GetComp(p,r) += v;
618}
619static inline unsigned long p_SubComp(poly p, unsigned long v, ring r)
620{
621  p_LmCheckPolyRing2(p, r);
622  pAssume2(rRing_has_Comp(r));
623  _pPolyAssume2(__p_GetComp(p,r) >= v,p,r);
624  return __p_GetComp(p,r) -= v;
625}
626static inline int p_Comp_k_n(poly a, poly b, int k, ring r)
627{
628  if ((a==NULL) || (b==NULL) ) return FALSE;
629  p_LmCheckPolyRing2(a, r);
630  p_LmCheckPolyRing2(b, r);
631  pAssume2(k > 0 && k <= r->N);
632  int i=k;
633  for(;i<=r->N;i++)
634  {
635    if (p_GetExp(a,i,r) != p_GetExp(b,i,r)) return FALSE;
636    //    if (a->exp[(r->VarOffset[i] & 0xffffff)] != b->exp[(r->VarOffset[i] & 0xffffff)]) return FALSE;
637  }
638  return TRUE;
639}
640
641#ifndef HAVE_EXPSIZES
642
643/// get a single variable exponent
644/// @Note:
645/// the integer VarOffset encodes:
646/// 1. the position of a variable in the exponent vector p->exp (lower 24 bits)
647/// 2. number of bits to shift to the right in the upper 8 bits (which takes at most 6 bits for 64 bit)
648/// Thus VarOffset always has 2 zero higher bits!
649static inline long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
650{
651  pAssume2((VarOffset >> (24 + 6)) == 0);
652#if 0
653  int pos=(VarOffset & 0xffffff);
654  int bitpos=(VarOffset >> 24);
655  unsigned long exp=(p->exp[pos] >> bitmask) & iBitmask;
656  return exp;
657#else
658  return (long)
659         ((p->exp[(VarOffset & 0xffffff)] >> (VarOffset >> 24))
660          & iBitmask);
661#endif
662}
663
664
665/// set a single variable exponent
666/// @Note:
667/// VarOffset encodes the position in p->exp @see p_GetExp
668static inline unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
669{
670  pAssume2(e>=0);
671  pAssume2(e<=iBitmask);
672  pAssume2((VarOffset >> (24 + 6)) == 0);
673
674  // shift e to the left:
675  register int shift = VarOffset >> 24;
676  unsigned long ee = e << shift /*(VarOffset >> 24)*/;
677  // find the bits in the exponent vector
678  register int offset = (VarOffset & 0xffffff);
679  // clear the bits in the exponent vector:
680  p->exp[offset]  &= ~( iBitmask << shift );
681  // insert e with |
682  p->exp[ offset ] |= ee;
683  return e;
684}
685
686
687#else // #ifdef HAVE_EXPSIZES // EXPERIMENTAL!!!
688
689static inline unsigned long BitMask(unsigned long bitmask, int twobits)
690{
691  // bitmask = 00000111111111111
692  // 0 must give bitmask!
693  // 1, 2, 3 - anything like 00011..11
694  pAssume2((twobits >> 2) == 0);
695  static const unsigned long _bitmasks[4] = {-1, 0x7fff, 0x7f, 0x3};
696  return bitmask & _bitmasks[twobits];
697}
698
699
700/// @Note: we may add some more info (6 ) into VarOffset and thus encode
701static inline long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
702{
703  int pos  =(VarOffset & 0xffffff);
704  int hbyte= (VarOffset >> 24); // the highest byte
705  int bitpos = hbyte & 0x3f; // last 6 bits
706  long bitmask = BitMask(iBitmask, hbyte >> 6);
707
708  long exp=(p->exp[pos] >> bitpos) & bitmask;
709  return exp;
710
711}
712
713static inline long p_SetExp(poly p, const long e, const unsigned long iBitmask, const int VarOffset)
714{
715  pAssume2(e>=0);
716  pAssume2(e <= BitMask(iBitmask, VarOffset >> 30));
717
718  // shift e to the left:
719  register int hbyte = VarOffset >> 24;
720  int bitmask = BitMask(iBitmask, hbyte >> 6);
721  register int shift = hbyte & 0x3f;
722  long ee = e << shift;
723  // find the bits in the exponent vector
724  register int offset = (VarOffset & 0xffffff);
725  // clear the bits in the exponent vector:
726  p->exp[offset]  &= ~( bitmask << shift );
727  // insert e with |
728  p->exp[ offset ] |= ee;
729  return e;
730}
731
732#endif // #ifndef HAVE_EXPSIZES
733
734
735static inline long p_GetExp(const poly p, const ring r, const int VarOffset)
736{
737  p_LmCheckPolyRing2(p, r);
738  pAssume2(VarOffset != -1);
739  return p_GetExp(p, r->bitmask, VarOffset);
740}
741
742static inline long p_SetExp(poly p, const long e, const ring r, const int VarOffset)
743{
744  p_LmCheckPolyRing2(p, r);
745  pAssume2(VarOffset != -1);
746  return p_SetExp(p, e, r->bitmask, VarOffset);
747}
748
749
750
751/// get v^th exponent for a monomial
752static inline long p_GetExp(const poly p, const int v, const ring r)
753{
754  p_LmCheckPolyRing2(p, r);
755  pAssume2(v>0 && v <= r->N);
756  pAssume2(r->VarOffset[v] != -1);
757  return p_GetExp(p, r->bitmask, r->VarOffset[v]);
758}
759
760
761/// set v^th exponent for a monomial
762static inline long p_SetExp(poly p, const int v, const long e, const ring r)
763{
764  p_LmCheckPolyRing2(p, r);
765  pAssume2(v>0 && v <= r->N);
766  pAssume2(r->VarOffset[v] != -1);
767  return p_SetExp(p, e, r->bitmask, r->VarOffset[v]);
768}
769
770
771
772
773
774// the following should be implemented more efficiently
775static inline  long p_IncrExp(poly p, int v, ring r)
776{
777  p_LmCheckPolyRing2(p, r);
778  int e = p_GetExp(p,v,r);
779  e++;
780  return p_SetExp(p,v,e,r);
781}
782static inline  long p_DecrExp(poly p, int v, ring r)
783{
784  p_LmCheckPolyRing2(p, r);
785  int e = p_GetExp(p,v,r);
786  pAssume2(e > 0);
787  e--;
788  return p_SetExp(p,v,e,r);
789}
790static inline  long p_AddExp(poly p, int v, long ee, ring r)
791{
792  p_LmCheckPolyRing2(p, r);
793  int e = p_GetExp(p,v,r);
794  e += ee;
795  return p_SetExp(p,v,e,r);
796}
797static inline  long p_SubExp(poly p, int v, long ee, ring r)
798{
799  p_LmCheckPolyRing2(p, r);
800  long e = p_GetExp(p,v,r);
801  pAssume2(e >= ee);
802  e -= ee;
803  return p_SetExp(p,v,e,r);
804}
805static inline  long p_MultExp(poly p, int v, long ee, ring r)
806{
807  p_LmCheckPolyRing2(p, r);
808  long e = p_GetExp(p,v,r);
809  e *= ee;
810  return p_SetExp(p,v,e,r);
811}
812
813static inline long p_GetExpSum(poly p1, poly p2, int i, ring r)
814{
815  p_LmCheckPolyRing2(p1, r);
816  p_LmCheckPolyRing2(p2, r);
817  return p_GetExp(p1,i,r) + p_GetExp(p2,i,r);
818}
819static inline long p_GetExpDiff(poly p1, poly p2, int i, ring r)
820{
821  return p_GetExp(p1,i,r) - p_GetExp(p2,i,r);
822}
823
824
825/***************************************************************
826 *
827 * Allocation/Initalization/Deletion
828 *
829 ***************************************************************/
830static inline poly p_New(ring r, omBin bin)
831{
832  p_CheckRing2(r);
833  pAssume2(bin != NULL && r->PolyBin->sizeW == bin->sizeW);
834  poly p;
835  omTypeAllocBin(poly, p, bin);
836  p_SetRingOfLm(p, r);
837  return p;
838}
839
840static inline poly p_New(ring r)
841{
842  return p_New(r, r->PolyBin);
843}
844
845static inline void p_LmFree(poly p, ring r)
846{
847  p_LmCheckPolyRing2(p, r);
848  omFreeBinAddr(p);
849}
850static inline void p_LmFree(poly *p, ring r)
851{
852  p_LmCheckPolyRing2(*p, r);
853  poly h = *p;
854  *p = pNext(h);
855  omFreeBinAddr(h);
856}
857static inline poly p_LmFreeAndNext(poly p, ring r)
858{
859  p_LmCheckPolyRing2(p, r);
860  poly pnext = pNext(p);
861  omFreeBinAddr(p);
862  return pnext;
863}
864static inline void p_LmDelete(poly p, const ring r)
865{
866  p_LmCheckPolyRing2(p, r);
867  n_Delete(&pGetCoeff(p), r->cf);
868  omFreeBinAddr(p);
869}
870static inline void p_LmDelete(poly *p, const ring r)
871{
872  p_LmCheckPolyRing2(*p, r);
873  poly h = *p;
874  *p = pNext(h);
875  n_Delete(&pGetCoeff(h), r->cf);
876  omFreeBinAddr(h);
877}
878static inline poly p_LmDeleteAndNext(poly p, const ring r)
879{
880  p_LmCheckPolyRing2(p, r);
881  poly pnext = pNext(p);
882  n_Delete(&pGetCoeff(p), r->cf);
883  omFreeBinAddr(p);
884  return pnext;
885}
886
887/***************************************************************
888 *
889 * Misc routines
890 *
891 ***************************************************************/
892static inline int p_Cmp(poly p1, poly p2, ring r)
893{
894  if (p2==NULL)
895    return 1;
896  if (p1==NULL)
897    return -1;
898  return p_LmCmp(p1,p2,r);
899}
900
901static inline unsigned long p_GetMaxExp(const poly p, const ring r)
902{
903  return p_GetMaxExp(p_GetMaxExpL(p, r), r);
904}
905
906static inline unsigned long p_GetMaxExp(const unsigned long l, const ring r)
907{
908  unsigned long bitmask = r->bitmask;
909  unsigned long max = (l & bitmask);
910  unsigned long j = r->ExpPerLong - 1;
911
912  if (j > 0)
913  {
914    unsigned long i = r->BitsPerExp;
915    long e;
916    loop
917    {
918      e = ((l >> i) & bitmask);
919      if ((unsigned long) e > max)
920        max = e;
921      j--;
922      if (j==0) break;
923      i += r->BitsPerExp;
924    }
925  }
926  return max;
927}
928
929static inline unsigned long
930p_GetTotalDegree(const unsigned long l, const ring r, const int number_of_exps)
931{
932  const unsigned long bitmask = r->bitmask;
933  unsigned long sum = (l & bitmask);
934  unsigned long j = number_of_exps - 1;
935
936  if (j > 0)
937  {
938    unsigned long i = r->BitsPerExp;
939    loop
940    {
941      sum += ((l >> i) & bitmask);
942      j--;
943      if (j==0) break;
944      i += r->BitsPerExp;
945    }
946  }
947  return sum;
948}
949
950static inline unsigned long
951p_GetTotalDegree(const unsigned long l, const ring r)
952{
953  return p_GetTotalDegree(l, r, r->ExpPerLong);
954}
955
956/***************************************************************
957 *
958 * Dispatcher to r->p_Procs, they do the tests/checks
959 *
960 ***************************************************************/
961// returns a copy of p
962static inline poly p_Copy(poly p, const ring r)
963{
964#ifdef PDEBUG
965  poly pp= r->p_Procs->p_Copy(p, r);
966  p_Test(pp,r);
967  return pp;
968#else
969  return r->p_Procs->p_Copy(p, r);
970#endif
971}
972
973static inline poly p_Copy(poly p, const ring lmRing, const ring tailRing)
974{
975#ifndef PDEBUG
976  if (tailRing == lmRing)
977    return tailRing->p_Procs->p_Copy(p, tailRing);
978#endif
979  if (p != NULL)
980  {
981    poly pres = p_Head(p, lmRing);
982    pNext(pres) = tailRing->p_Procs->p_Copy(pNext(p), tailRing);
983    return pres;
984  }
985  else
986    return NULL;
987}
988
989// deletes *p, and sets *p to NULL
990static inline void p_Delete(poly *p, const ring r)
991{
992  r->p_Procs->p_Delete(p, r);
993}
994
995static inline void p_Delete(poly *p,  const ring lmRing, const ring tailRing)
996{
997#ifndef PDEBUG
998  if (tailRing == lmRing)
999  {
1000    tailRing->p_Procs->p_Delete(p, tailRing);
1001    return;
1002  }
1003#endif
1004  if (*p != NULL)
1005  {
1006    if (pNext(*p) != NULL)
1007      tailRing->p_Procs->p_Delete(&pNext(*p), tailRing);
1008    p_LmDelete(p, lmRing);
1009  }
1010}
1011
1012static inline poly p_ShallowCopyDelete(poly p, const ring r, omBin bin)
1013{
1014  p_LmCheckPolyRing2(p, r);
1015  pAssume2(r->PolyBin->sizeW == bin->sizeW);
1016  return r->p_Procs->p_ShallowCopyDelete(p, r, bin);
1017}
1018
1019// returns p+q, destroys p and q
1020static inline poly p_Add_q(poly p, poly q, const ring r)
1021{
1022  int shorter;
1023  return r->p_Procs->p_Add_q(p, q, shorter, r);
1024}
1025
1026static inline poly p_Add_q(poly p, poly q, int &lp, int lq, const ring r)
1027{
1028  int shorter;
1029  poly res = r->p_Procs->p_Add_q(p, q, shorter, r);
1030  lp = (lp + lq) - shorter;
1031  return res;
1032}
1033
1034// returns p*n, destroys p
1035static inline poly p_Mult_nn(poly p, number n, const ring r)
1036{
1037  if (n_IsOne(n, r->cf))
1038    return p;
1039  else
1040    return r->p_Procs->p_Mult_nn(p, n, r);
1041}
1042
1043static inline poly p_Mult_nn(poly p, number n, const ring lmRing,
1044                        const ring tailRing)
1045{
1046#ifndef PDEBUG
1047  if (lmRing == tailRing)
1048  {
1049    return p_Mult_nn(p, n, tailRing);
1050  }
1051#endif
1052  poly pnext = pNext(p);
1053  pNext(p) = NULL;
1054  p = lmRing->p_Procs->p_Mult_nn(p, n, lmRing);
1055  pNext(p) = tailRing->p_Procs->p_Mult_nn(pnext, n, tailRing);
1056  return p;
1057}
1058
1059// returns p*n, does not destroy p
1060static inline poly pp_Mult_nn(poly p, number n, const ring r)
1061{
1062  if (n_IsOne(n, r->cf))
1063    return p_Copy(p, r);
1064  else
1065    return r->p_Procs->pp_Mult_nn(p, n, r);
1066}
1067
1068// returns Copy(p)*m, does neither destroy p nor m
1069static inline poly pp_Mult_mm(poly p, poly m, const ring r)
1070{
1071  if (p_LmIsConstant(m, r))
1072    return pp_Mult_nn(p, pGetCoeff(m), r);
1073  else
1074  {
1075    poly last;
1076    return r->p_Procs->pp_Mult_mm(p, m, r, last);
1077  }
1078}
1079
1080// returns p*m, destroys p, const: m
1081static inline poly p_Mult_mm(poly p, poly m, const ring r)
1082{
1083  if (p_LmIsConstant(m, r))
1084    return p_Mult_nn(p, pGetCoeff(m), r);
1085  else
1086    return r->p_Procs->p_Mult_mm(p, m, r);
1087}
1088
1089// return p - m*Copy(q), destroys p; const: p,m
1090static inline poly p_Minus_mm_Mult_qq(poly p, poly m, poly q, const ring r)
1091{
1092#ifdef HAVE_PLURAL
1093  if (rIsPluralRing(r))
1094  {
1095    int lp, lq;
1096    poly spNoether;
1097    return nc_p_Minus_mm_Mult_qq(p, m, q, lp, lq, spNoether, r);
1098  }
1099#endif
1100
1101  int shorter;
1102  poly last;
1103
1104  return r->p_Procs->p_Minus_mm_Mult_qq(p, m, q, shorter, NULL, r, last); // !!!
1105}
1106
1107static inline poly p_Minus_mm_Mult_qq(poly p, poly m, poly q, int &lp, int lq,
1108                                 poly spNoether, const ring r)
1109{
1110#ifdef HAVE_PLURAL
1111  if (rIsPluralRing(r))
1112     return nc_p_Minus_mm_Mult_qq(p, m, q, lp, lq, spNoether, r);
1113#endif
1114
1115  int shorter;
1116  poly last,res;
1117  res = r->p_Procs->p_Minus_mm_Mult_qq(p, m, q, shorter, spNoether, r, last);
1118  lp = (lp + lq) - shorter;
1119  return res;
1120}
1121
1122static inline poly pp_Mult_Coeff_mm_DivSelect(poly p, const poly m, const ring r)
1123{
1124  int shorter;
1125  return r->p_Procs->pp_Mult_Coeff_mm_DivSelect(p, m, shorter, r);
1126}
1127
1128static inline poly pp_Mult_Coeff_mm_DivSelect(poly p, int &lp, const poly m, const ring r)
1129{
1130  int shorter;
1131  poly pp = r->p_Procs->pp_Mult_Coeff_mm_DivSelect(p, m, shorter, r);
1132  lp -= shorter;
1133  return pp;
1134}
1135
1136// returns -p, destroys p
1137static inline poly p_Neg(poly p, const ring r)
1138{
1139  return r->p_Procs->p_Neg(p, r);
1140}
1141
1142extern poly  _p_Mult_q(poly p, poly q, const int copy, const ring r);
1143// returns p*q, destroys p and q
1144static inline poly p_Mult_q(poly p, poly q, const ring r)
1145{
1146  if (p == NULL)
1147  {
1148    r->p_Procs->p_Delete(&q, r);
1149    return NULL;
1150  }
1151  if (q == NULL)
1152  {
1153    r->p_Procs->p_Delete(&p, r);
1154    return NULL;
1155  }
1156
1157  if (pNext(p) == NULL)
1158  {
1159#ifdef HAVE_PLURAL
1160    if (rIsPluralRing(r))
1161      q = nc_mm_Mult_p(p, q, r);
1162    else
1163#endif /* HAVE_PLURAL */
1164      q = r->p_Procs->p_Mult_mm(q, p, r);
1165
1166    r->p_Procs->p_Delete(&p, r);
1167    return q;
1168  }
1169
1170  if (pNext(q) == NULL)
1171  {
1172  // NEEDED
1173#ifdef HAVE_PLURAL
1174/*    if (rIsPluralRing(r))
1175      p = gnc_p_Mult_mm(p, q, r); // ???
1176    else*/
1177#endif /* HAVE_PLURAL */
1178      p = r->p_Procs->p_Mult_mm(p, q, r);
1179
1180    r->p_Procs->p_Delete(&q, r);
1181    return p;
1182  }
1183#ifdef HAVE_PLURAL
1184  if (rIsPluralRing(r))
1185    return _nc_p_Mult_q(p, q, r);
1186  else
1187#endif
1188  return _p_Mult_q(p, q, 0, r);
1189}
1190
1191// returns p*q, does neither destroy p nor q
1192static inline poly pp_Mult_qq(poly p, poly q, const ring r)
1193{
1194  poly last;
1195  if (p == NULL || q == NULL) return NULL;
1196
1197  if (pNext(p) == NULL)
1198  {
1199#ifdef HAVE_PLURAL
1200    if (rIsPluralRing(r))
1201      return nc_mm_Mult_pp(p, q, r);
1202#endif
1203    return r->p_Procs->pp_Mult_mm(q, p, r, last);
1204  }
1205
1206  if (pNext(q) == NULL)
1207  {
1208    return r->p_Procs->pp_Mult_mm(p, q, r, last);
1209  }
1210
1211  poly qq = q;
1212  if (p == q)
1213    qq = p_Copy(q, r);
1214
1215  poly res;
1216#ifdef HAVE_PLURAL
1217  if (rIsPluralRing(r))
1218    res = _nc_pp_Mult_qq(p, qq, r);
1219  else
1220#endif
1221    res = _p_Mult_q(p, qq, 1, r);
1222
1223  if (qq != q)
1224    p_Delete(&qq, r);
1225  return res;
1226}
1227
1228// returns p + m*q destroys p, const: q, m
1229static inline poly p_Plus_mm_Mult_qq(poly p, poly m, poly q, int &lp, int lq,
1230                                const ring r)
1231{
1232#ifdef HAVE_PLURAL
1233  if (rIsPluralRing(r))
1234    return nc_p_Plus_mm_Mult_qq(p, m, q, lp, lq, r);
1235#endif
1236
1237// this should be implemented more efficiently
1238  poly res, last;
1239  int shorter;
1240  number n_old = pGetCoeff(m);
1241  number n_neg = n_Copy(n_old, r->cf);
1242  n_neg = n_Neg(n_neg, r->cf);
1243  pSetCoeff0(m, n_neg);
1244  res = r->p_Procs->p_Minus_mm_Mult_qq(p, m, q, shorter, NULL, r, last);
1245  lp = (lp + lq) - shorter;
1246  pSetCoeff0(m, n_old);
1247  n_Delete(&n_neg, r->cf);
1248  return res;
1249}
1250
1251static inline poly p_Plus_mm_Mult_qq(poly p, poly m, poly q, const ring r)
1252{
1253  int lp = 0, lq = 0;
1254  return p_Plus_mm_Mult_qq(p, m, q, lp, lq, r);
1255}
1256
1257static inline poly p_Merge_q(poly p, poly q, const ring r)
1258{
1259  return r->p_Procs->p_Merge_q(p, q, r);
1260}
1261
1262static inline poly p_SortAdd(poly p, const ring r, BOOLEAN revert)
1263{
1264  if (revert) p = pReverse(p);
1265  return sBucketSortAdd(p, r);
1266}
1267
1268static inline poly p_SortMerge(poly p, const ring r, BOOLEAN revert)
1269{
1270  if (revert) p = pReverse(p);
1271  return sBucketSortMerge(p, r);
1272}
1273
1274/***************************************************************
1275 *
1276 * I/O
1277 *
1278 ***************************************************************/
1279static inline char*     p_String(poly p, ring p_ring)
1280{
1281  return p_String(p, p_ring, p_ring);
1282}
1283static inline char*     p_String0(poly p, ring p_ring)
1284{
1285  return p_String0(p, p_ring, p_ring);
1286}
1287static inline void      p_Write(poly p, ring p_ring)
1288{
1289  p_Write(p, p_ring, p_ring);
1290}
1291static inline void      p_Write0(poly p, ring p_ring)
1292{
1293  p_Write0(p, p_ring, p_ring);
1294}
1295static inline void      p_wrp(poly p, ring p_ring)
1296{
1297  p_wrp(p, p_ring, p_ring);
1298}
1299
1300/***************************************************************
1301 *  Purpose: implementation of poly procs which iter over ExpVector
1302 *  Author:  obachman (Olaf Bachmann)
1303 *  Created: 8/00
1304 *  Version: $Id$
1305 *******************************************************************/
1306#include <misc/mylimits.h>
1307#include <polys/templates/p_MemCmp.h>
1308// #include <polys/structs.h>
1309#include <polys/monomials/ring.h>
1310#include <coeffs/coeffs.h>
1311
1312#if PDEBUG > 0
1313
1314#define _p_LmCmpAction(p, q, r, actionE, actionG, actionS)  \
1315do                                                          \
1316{                                                           \
1317  int _cmp = p_LmCmp(p,q,r);                                \
1318  if (_cmp == 0) actionE;                                   \
1319  if (_cmp == 1) actionG;                                   \
1320  actionS;                                                  \
1321}                                                           \
1322while(0)
1323
1324#else
1325
1326#define _p_LmCmpAction(p, q, r, actionE, actionG, actionS)                      \
1327 p_MemCmp_LengthGeneral_OrdGeneral(p->exp, q->exp, r->CmpL_Size, r->ordsgn,    \
1328                                   actionE, actionG, actionS)
1329
1330#endif
1331
1332#define pDivAssume(x)   ((void)0)
1333
1334#include <omalloc/omalloc.h>
1335#include <coeffs/coeffs.h>
1336#include <polys/monomials/p_polys.h>
1337#include <polys/templates/p_MemAdd.h>
1338#include <polys/templates/p_MemCopy.h>
1339
1340/***************************************************************
1341 *
1342 * Allocation/Initalization/Deletion
1343 *
1344 ***************************************************************/
1345// adjustments for negative weights
1346static inline void p_MemAdd_NegWeightAdjust(poly p, const ring r)
1347{
1348  if (r->NegWeightL_Offset != NULL)
1349  {
1350    for (int i=r->NegWeightL_Size-1; i>=0; i--)
1351    {
1352      p->exp[r->NegWeightL_Offset[i]] -= POLY_NEGWEIGHT_OFFSET;
1353    }
1354  }
1355}
1356static inline void p_MemSub_NegWeightAdjust(poly p, const ring r)
1357{
1358  if (r->NegWeightL_Offset != NULL)
1359  {
1360    for (int i=r->NegWeightL_Size-1; i>=0; i--)
1361    {
1362      p->exp[r->NegWeightL_Offset[i]] += POLY_NEGWEIGHT_OFFSET;
1363    }
1364  }
1365}
1366// ExpVextor(d_p) = ExpVector(s_p)
1367static inline void p_ExpVectorCopy(poly d_p, poly s_p, const ring r)
1368{
1369  p_LmCheckPolyRing1(d_p, r);
1370  p_LmCheckPolyRing1(s_p, r);
1371  p_MemCopy_LengthGeneral(d_p->exp, s_p->exp, r->ExpL_Size);
1372}
1373
1374static inline poly p_Init(const ring r, omBin bin)
1375{
1376  p_CheckRing1(r);
1377  pAssume1(bin != NULL && r->PolyBin->sizeW == bin->sizeW);
1378  poly p;
1379  omTypeAlloc0Bin(poly, p, bin);
1380  p_MemAdd_NegWeightAdjust(p, r);
1381  p_SetRingOfLm(p, r);
1382  return p;
1383}
1384static inline poly p_Init(const ring r)
1385{
1386  return p_Init(r, r->PolyBin);
1387}
1388
1389static inline poly p_LmInit(poly p, const ring r)
1390{
1391  p_LmCheckPolyRing1(p, r);
1392  poly np;
1393  omTypeAllocBin(poly, np, r->PolyBin);
1394  p_SetRingOfLm(np, r);
1395  p_MemCopy_LengthGeneral(np->exp, p->exp, r->ExpL_Size);
1396  pNext(np) = NULL;
1397  pSetCoeff0(np, NULL);
1398  return np;
1399}
1400static inline poly p_LmInit(poly s_p, const ring s_r, const ring d_r, omBin d_bin)
1401{
1402  p_LmCheckPolyRing1(s_p, s_r);
1403  p_CheckRing(d_r);
1404  pAssume1(d_r->N <= s_r->N);
1405  poly d_p = p_Init(d_r, d_bin);
1406  for (int i=d_r->N; i>0; i--)
1407  {
1408    p_SetExp(d_p, i, p_GetExp(s_p, i,s_r), d_r);
1409  }
1410  if (rRing_has_Comp(d_r))
1411  {
1412    p_SetComp(d_p, p_GetComp(s_p,s_r), d_r);
1413  }
1414  p_Setm(d_p, d_r);
1415  return d_p;
1416}
1417static inline poly p_LmInit(poly s_p, const ring s_r, const ring d_r)
1418{
1419  pAssume1(d_r != NULL);
1420  return p_LmInit(s_p, s_r, d_r, d_r->PolyBin);
1421}
1422static inline poly p_Head(poly p, const ring r)
1423{
1424  if (p == NULL) return NULL;
1425  p_LmCheckPolyRing1(p, r);
1426  poly np;
1427  omTypeAllocBin(poly, np, r->PolyBin);
1428  p_SetRingOfLm(np, r);
1429  p_MemCopy_LengthGeneral(np->exp, p->exp, r->ExpL_Size);
1430  pNext(np) = NULL;
1431  pSetCoeff0(np, n_Copy(pGetCoeff(p), r->cf));
1432  return np;
1433}
1434// set all exponents l..k to 0, assume exp. k+1..n and 1..l-1 are in
1435// different blocks
1436// set coeff to 1
1437static inline poly p_GetExp_k_n(poly p, int l, int k, const ring r)
1438{
1439  if (p == NULL) return NULL;
1440  p_LmCheckPolyRing1(p, r);
1441  poly np;
1442  omTypeAllocBin(poly, np, r->PolyBin);
1443  p_SetRingOfLm(np, r);
1444  p_MemCopy_LengthGeneral(np->exp, p->exp, r->ExpL_Size);
1445  pNext(np) = NULL;
1446  pSetCoeff0(np, n_Init(1, r->cf));
1447  int i;
1448  for(i=l;i<=k;i++)
1449  {
1450    //np->exp[(r->VarOffset[i] & 0xffffff)] =0;
1451    p_SetExp(np,i,0,r);
1452  }
1453  p_Setm(np,r);
1454  return np;
1455}
1456
1457static inline poly p_LmShallowCopyDelete(poly p, const ring r, omBin bin)
1458{
1459  p_LmCheckPolyRing1(p, r);
1460  pAssume1(bin->sizeW == r->PolyBin->sizeW);
1461  poly new_p = p_New(r);
1462  p_MemCopy_LengthGeneral(new_p->exp, p->exp, r->ExpL_Size);
1463  pSetCoeff0(new_p, pGetCoeff(p));
1464  pNext(new_p) = pNext(p);
1465  omFreeBinAddr(p);
1466  return new_p;
1467}
1468
1469/***************************************************************
1470 *
1471 * Operation on ExpVectors
1472 *
1473 ***************************************************************/
1474// ExpVector(p1) += ExpVector(p2)
1475static inline void p_ExpVectorAdd(poly p1, poly p2, const ring r)
1476{
1477  p_LmCheckPolyRing1(p1, r);
1478  p_LmCheckPolyRing1(p2, r);
1479#if PDEBUG >= 1
1480  for (int i=1; i<=r->N; i++)
1481    pAssume1((unsigned long) (p_GetExp(p1, i, r) + p_GetExp(p2, i, r)) <= r->bitmask);
1482  pAssume1(p_GetComp(p1, r) == 0 || p_GetComp(p2, r) == 0);
1483#endif
1484
1485  p_MemAdd_LengthGeneral(p1->exp, p2->exp, r->ExpL_Size);
1486  p_MemAdd_NegWeightAdjust(p1, r);
1487}
1488// ExpVector(p1) -= ExpVector(p2)
1489static inline void p_ExpVectorSub(poly p1, poly p2, const ring r)
1490{
1491  p_LmCheckPolyRing1(p1, r);
1492  p_LmCheckPolyRing1(p2, r);
1493#if PDEBUG >= 1
1494  for (int i=1; i<=r->N; i++)
1495    pAssume1(p_GetExp(p1, i, r) >= p_GetExp(p2, i, r));
1496  pAssume1(p_GetComp(p1, r) == 0 || p_GetComp(p2, r) == 0 ||
1497          p_GetComp(p1, r) == p_GetComp(p2, r));
1498#endif
1499
1500  p_MemSub_LengthGeneral(p1->exp, p2->exp, r->ExpL_Size);
1501  p_MemSub_NegWeightAdjust(p1, r);
1502
1503}
1504// ExpVector(p1) += ExpVector(p2) - ExpVector(p3)
1505static inline void p_ExpVectorAddSub(poly p1, poly p2, poly p3, const ring r)
1506{
1507  p_LmCheckPolyRing1(p1, r);
1508  p_LmCheckPolyRing1(p2, r);
1509  p_LmCheckPolyRing1(p3, r);
1510#if PDEBUG >= 1
1511  for (int i=1; i<=r->N; i++)
1512    pAssume1(p_GetExp(p1, i, r) + p_GetExp(p2, i, r) >= p_GetExp(p3, i, r));
1513  pAssume1(p_GetComp(p1, r) == 0 ||
1514           (p_GetComp(p2, r) - p_GetComp(p3, r) == 0) ||
1515           (p_GetComp(p1, r) == p_GetComp(p2, r) - p_GetComp(p3, r)));
1516#endif
1517
1518  p_MemAddSub_LengthGeneral(p1->exp, p2->exp, p3->exp, r->ExpL_Size);
1519  // no need to adjust in case of NegWeights
1520}
1521
1522// ExpVector(pr) = ExpVector(p1) + ExpVector(p2)
1523static inline void p_ExpVectorSum(poly pr, poly p1, poly p2, const ring r)
1524{
1525  p_LmCheckPolyRing1(p1, r);
1526  p_LmCheckPolyRing1(p2, r);
1527  p_LmCheckPolyRing1(pr, r);
1528#if PDEBUG >= 1
1529  for (int i=1; i<=r->N; i++)
1530    pAssume1((unsigned long) (p_GetExp(p1, i, r) + p_GetExp(p2, i, r)) <= r->bitmask);
1531  pAssume1(p_GetComp(p1, r) == 0 || p_GetComp(p2, r) == 0);
1532#endif
1533
1534  p_MemSum_LengthGeneral(pr->exp, p1->exp, p2->exp, r->ExpL_Size);
1535  p_MemAdd_NegWeightAdjust(pr, r);
1536}
1537// ExpVector(pr) = ExpVector(p1) - ExpVector(p2)
1538static inline void p_ExpVectorDiff(poly pr, poly p1, poly p2, const ring r)
1539{
1540  p_LmCheckPolyRing1(p1, r);
1541  p_LmCheckPolyRing1(p2, r);
1542  p_LmCheckPolyRing1(pr, r);
1543#if PDEBUG >= 2
1544  for (int i=1; i<=r->N; i++)
1545    pAssume1(p_GetExp(p1, i, r) >= p_GetExp(p2, i, r));
1546  pAssume1(!rRing_has_Comp(r) || p_GetComp(p1, r) == p_GetComp(p2, r));
1547#endif
1548
1549  p_MemDiff_LengthGeneral(pr->exp, p1->exp, p2->exp, r->ExpL_Size);
1550  p_MemSub_NegWeightAdjust(pr, r);
1551}
1552
1553static inline BOOLEAN p_ExpVectorEqual(poly p1, poly p2, const ring r)
1554{
1555  p_LmCheckPolyRing1(p1, r);
1556  p_LmCheckPolyRing1(p2, r);
1557
1558  int i = r->ExpL_Size;
1559  unsigned long *ep = p1->exp;
1560  unsigned long *eq = p2->exp;
1561
1562  do
1563  {
1564    i--;
1565    if (ep[i] != eq[i]) return FALSE;
1566  }
1567  while (i);
1568  return TRUE;
1569}
1570
1571static inline long p_Totaldegree(poly p, const ring r)
1572{
1573  p_LmCheckPolyRing1(p, r);
1574  unsigned long s = p_GetTotalDegree(p->exp[r->VarL_Offset[0]],
1575                                     r,
1576                                     r->MinExpPerLong);
1577  for (int i=r->VarL_Size-1; i>0; i--)
1578  {
1579    s += p_GetTotalDegree(p->exp[r->VarL_Offset[i]], r);
1580  }
1581  return (long)s;
1582}
1583
1584static inline void p_GetExpV(poly p, int *ev, const ring r)
1585{
1586  p_LmCheckPolyRing1(p, r);
1587  for (int j = r->N; j; j--)
1588      ev[j] = p_GetExp(p, j, r);
1589
1590  ev[0] = p_GetComp(p, r);
1591}
1592static inline void p_SetExpV(poly p, int *ev, const ring r)
1593{
1594  p_LmCheckPolyRing1(p, r);
1595  for (int j = r->N; j; j--)
1596      p_SetExp(p, j, ev[j], r);
1597
1598  p_SetComp(p, ev[0],r);
1599  p_Setm(p, r);
1600}
1601
1602/***************************************************************
1603 *
1604 * Comparison w.r.t. monomial ordering
1605 *
1606 ***************************************************************/
1607static inline int p_LmCmp(poly p, poly q, const ring r)
1608{
1609  p_LmCheckPolyRing1(p, r);
1610  p_LmCheckPolyRing1(q, r);
1611
1612  p_MemCmp_LengthGeneral_OrdGeneral(p->exp, q->exp, r->CmpL_Size, r->ordsgn,
1613                                    return 0, return 1, return -1);
1614}
1615
1616
1617/***************************************************************
1618 *
1619 * divisibility
1620 *
1621 ***************************************************************/
1622// return: FALSE, if there exists i, such that a->exp[i] > b->exp[i]
1623//         TRUE, otherwise
1624// (1) Consider long vars, instead of single exponents
1625// (2) Clearly, if la > lb, then FALSE
1626// (3) Suppose la <= lb, and consider first bits of single exponents in l:
1627//     if TRUE, then value of these bits is la ^ lb
1628//     if FALSE, then la-lb causes an "overflow" into one of those bits, i.e.,
1629//               la ^ lb != la - lb
1630static inline BOOLEAN _p_LmDivisibleByNoComp(poly a, poly b, const ring r)
1631{
1632  int i=r->VarL_Size - 1;
1633  unsigned long divmask = r->divmask;
1634  unsigned long la, lb;
1635
1636  if (r->VarL_LowIndex >= 0)
1637  {
1638    i += r->VarL_LowIndex;
1639    do
1640    {
1641      la = a->exp[i];
1642      lb = b->exp[i];
1643      if ((la > lb) ||
1644          (((la & divmask) ^ (lb & divmask)) != ((lb - la) & divmask)))
1645      {
1646        pDivAssume(p_DebugLmDivisibleByNoComp(a, b, r) == FALSE);
1647        return FALSE;
1648      }
1649      i--;
1650    }
1651    while (i>=r->VarL_LowIndex);
1652  }
1653  else
1654  {
1655    do
1656    {
1657      la = a->exp[r->VarL_Offset[i]];
1658      lb = b->exp[r->VarL_Offset[i]];
1659      if ((la > lb) ||
1660          (((la & divmask) ^ (lb & divmask)) != ((lb - la) & divmask)))
1661      {
1662        pDivAssume(p_DebugLmDivisibleByNoComp(a, b, r) == FALSE);
1663        return FALSE;
1664      }
1665      i--;
1666    }
1667    while (i>=0);
1668  }
1669#ifdef HAVE_RINGS
1670  pDivAssume(p_DebugLmDivisibleByNoComp(a, b, r) == nDivBy(p_GetCoeff(b, r), p_GetCoeff(a, r)));
1671  return (!rField_is_Ring(r)) || n_DivBy(p_GetCoeff(b, r), p_GetCoeff(a, r), r->cf);
1672#else
1673  pDivAssume(p_DebugLmDivisibleByNoComp(a, b, r) == TRUE);
1674  return TRUE;
1675#endif
1676}
1677
1678static inline BOOLEAN _p_LmDivisibleByNoComp(poly a, const ring r_a, poly b, const ring r_b)
1679{
1680  int i=r_a->N;
1681  pAssume1(r_a->N == r_b->N);
1682
1683  do
1684  {
1685    if (p_GetExp(a,i,r_a) > p_GetExp(b,i,r_b))
1686      return FALSE;
1687    i--;
1688  }
1689  while (i);
1690#ifdef HAVE_RINGS
1691  return n_DivBy(p_GetCoeff(b, r_b), p_GetCoeff(a, r_a), r_a->cf);
1692#else
1693  return TRUE;
1694#endif
1695}
1696
1697#ifdef HAVE_RATGRING
1698static inline BOOLEAN _p_LmDivisibleByNoCompPart(poly a, const ring r_a, poly b, const ring r_b,const int start, const int end)
1699{
1700  int i=end;
1701  pAssume1(r_a->N == r_b->N);
1702
1703  do
1704  {
1705    if (p_GetExp(a,i,r_a) > p_GetExp(b,i,r_b))
1706      return FALSE;
1707    i--;
1708  }
1709  while (i>=start);
1710#ifdef HAVE_RINGS
1711  return nDivBy(p_GetCoeff(b, r), p_GetCoeff(a, r));
1712#else
1713  return TRUE;
1714#endif
1715}
1716static inline BOOLEAN _p_LmDivisibleByPart(poly a, const ring r_a, poly b, const ring r_b,const int start, const int end)
1717{
1718  if (p_GetComp(a, r_a) == 0 || p_GetComp(a,r_a) == p_GetComp(b,r_b))
1719    return _p_LmDivisibleByNoCompPart(a, r_a, b, r_b,start,end);
1720  return FALSE;
1721}
1722static inline BOOLEAN p_LmDivisibleByPart(poly a, poly b, const ring r,const int start, const int end)
1723{
1724  p_LmCheckPolyRing1(b, r);
1725  pIfThen1(a != NULL, p_LmCheckPolyRing1(b, r));
1726  if (p_GetComp(a, r) == 0 || p_GetComp(a,r) == p_GetComp(b,r))
1727    return _p_LmDivisibleByNoCompPart(a, r, b, r,start, end);
1728  return FALSE;
1729}
1730#endif
1731static inline BOOLEAN _p_LmDivisibleBy(poly a, poly b, const ring r)
1732{
1733  if (p_GetComp(a, r) == 0 || p_GetComp(a,r) == p_GetComp(b,r))
1734    return _p_LmDivisibleByNoComp(a, b, r);
1735  return FALSE;
1736}
1737static inline BOOLEAN _p_LmDivisibleBy(poly a, const ring r_a, poly b, const ring r_b)
1738{
1739  if (p_GetComp(a, r_a) == 0 || p_GetComp(a,r_a) == p_GetComp(b,r_b))
1740    return _p_LmDivisibleByNoComp(a, r_a, b, r_b);
1741  return FALSE;
1742}
1743static inline BOOLEAN p_LmDivisibleByNoComp(poly a, poly b, const ring r)
1744{
1745  p_LmCheckPolyRing1(a, r);
1746  p_LmCheckPolyRing1(b, r);
1747  return _p_LmDivisibleByNoComp(a, b, r);
1748}
1749static inline BOOLEAN p_LmDivisibleBy(poly a, poly b, const ring r)
1750{
1751  p_LmCheckPolyRing1(b, r);
1752  pIfThen1(a != NULL, p_LmCheckPolyRing1(b, r));
1753  if (p_GetComp(a, r) == 0 || p_GetComp(a,r) == p_GetComp(b,r))
1754    return _p_LmDivisibleByNoComp(a, b, r);
1755  return FALSE;
1756}
1757
1758static inline BOOLEAN p_DivisibleBy(poly a, poly b, const ring r)
1759{
1760  pIfThen1(b!=NULL, p_LmCheckPolyRing1(b, r));
1761  pIfThen1(a!=NULL, p_LmCheckPolyRing1(a, r));
1762
1763  if (a != NULL && (p_GetComp(a, r) == 0 || p_GetComp(a,r) == p_GetComp(b,r)))
1764      return _p_LmDivisibleByNoComp(a,b,r);
1765  return FALSE;
1766}
1767static inline BOOLEAN p_DivisibleBy(poly a, const ring r_a, poly b, const ring r_b)
1768{
1769  pIfThen1(b!=NULL, p_LmCheckPolyRing1(b, r_b));
1770  pIfThen1(a!=NULL, p_LmCheckPolyRing1(a, r_a));
1771  if (a != NULL) {
1772      return _p_LmDivisibleBy(a, r_a, b, r_b);
1773  }
1774  return FALSE;
1775}
1776static inline BOOLEAN p_LmDivisibleBy(poly a, const ring r_a, poly b, const ring r_b)
1777{
1778  p_LmCheckPolyRing(a, r_a);
1779  p_LmCheckPolyRing(b, r_b);
1780  return _p_LmDivisibleBy(a, r_a, b, r_b);
1781}
1782static inline BOOLEAN p_LmShortDivisibleBy(poly a, unsigned long sev_a,
1783                                    poly b, unsigned long not_sev_b, const ring r)
1784{
1785  p_LmCheckPolyRing1(a, r);
1786  p_LmCheckPolyRing1(b, r);
1787#ifndef PDIV_DEBUG
1788  _pPolyAssume2(p_GetShortExpVector(a, r) == sev_a, a, r);
1789  _pPolyAssume2(p_GetShortExpVector(b, r) == ~ not_sev_b, b, r);
1790
1791  if (sev_a & not_sev_b)
1792  {
1793    pAssume1(p_LmDivisibleByNoComp(a, b, r) == FALSE);
1794    return FALSE;
1795  }
1796  return p_LmDivisibleBy(a, b, r);
1797#else
1798  return pDebugLmShortDivisibleBy(a, sev_a, r, b, not_sev_b, r);
1799#endif
1800}
1801
1802static inline BOOLEAN p_LmShortDivisibleBy(poly a, unsigned long sev_a, const ring r_a,
1803                                      poly b, unsigned long not_sev_b, const ring r_b)
1804{
1805  p_LmCheckPolyRing1(a, r_a);
1806  p_LmCheckPolyRing1(b, r_b);
1807#ifndef PDIV_DEBUG
1808  _pPolyAssume2(p_GetShortExpVector(a, r_a) == sev_a, a, r_a);
1809  _pPolyAssume2(p_GetShortExpVector(b, r_b) == ~ not_sev_b, b, r_b);
1810
1811  if (sev_a & not_sev_b)
1812  {
1813    pAssume1(_p_LmDivisibleByNoComp(a, r_a, b, r_b) == FALSE);
1814    return FALSE;
1815  }
1816  return _p_LmDivisibleBy(a, r_a, b, r_b);
1817#else
1818  return pDebugLmShortDivisibleBy(a, sev_a, r_a, b, not_sev_b, r_b);
1819#endif
1820}
1821
1822/***************************************************************
1823 *
1824 * Misc things on Lm
1825 *
1826 ***************************************************************/
1827// test if the monomial is a constant as a vector component
1828// i.e., test if all exponents are zero
1829static inline BOOLEAN p_LmIsConstantComp(const poly p, const ring r)
1830{
1831  //p_LmCheckPolyRing(p, r);
1832  int i = r->VarL_Size - 1;
1833
1834  do
1835  {
1836    if (p->exp[r->VarL_Offset[i]] != 0)
1837      return FALSE;
1838    i--;
1839  }
1840  while (i >= 0);
1841  return TRUE;
1842}
1843// test if monomial is a constant, i.e. if all exponents and the component
1844// is zero
1845static inline BOOLEAN p_LmIsConstant(const poly p, const ring r)
1846{
1847  if (p_LmIsConstantComp(p, r))
1848    return (p_GetComp(p, r) == 0);
1849  return FALSE;
1850}
1851
1852// like the respective p_LmIs* routines, except that p might be empty
1853static inline BOOLEAN p_IsConstantComp(const poly p, const ring r)
1854{
1855  if (p == NULL) return TRUE;
1856  return (pNext(p)==NULL) && p_LmIsConstantComp(p, r);
1857}
1858
1859static inline BOOLEAN p_IsConstant(const poly p, const ring r)
1860{
1861  if (p == NULL) return TRUE;
1862  return (pNext(p)==NULL) && p_LmIsConstant(p, r);
1863}
1864
1865static inline BOOLEAN p_IsUnit(const poly p, const ring r)
1866{
1867  if (p == NULL) return FALSE;
1868#ifdef HAVE_RINGS
1869  if (rField_is_Ring(r))
1870    return (p_LmIsConstant(p, r) && nIsUnit(pGetCoeff(p),r->cf));
1871#endif
1872  return p_LmIsConstant(p, r);
1873}
1874
1875static inline BOOLEAN p_LmExpVectorAddIsOk(const poly p1, const poly p2,
1876                                      const ring r)
1877{
1878  p_LmCheckPolyRing(p1, r);
1879  p_LmCheckPolyRing(p2, r);
1880  unsigned long l1, l2, divmask = r->divmask;
1881  int i;
1882
1883  for (i=0; i<r->VarL_Size; i++)
1884  {
1885    l1 = p1->exp[r->VarL_Offset[i]];
1886    l2 = p2->exp[r->VarL_Offset[i]];
1887    // do the divisiblity trick
1888    if ( (l1 > ULONG_MAX - l2) ||
1889         (((l1 & divmask) ^ (l2 & divmask)) != ((l1 + l2) & divmask)))
1890      return FALSE;
1891  }
1892  return TRUE;
1893}
1894void      p_Split(poly p, poly * r);   /*p => IN(p), r => REST(p) */
1895BOOLEAN p_HasNotCF(poly p1, poly p2, const ring r);
1896poly      p_mInit(const char *s, BOOLEAN &ok, const ring r); /* monom s -> poly, interpreter */
1897const char *    p_Read(const char *s, poly &p,const ring r); /* monom -> poly */
1898poly      p_Divide(poly a, poly b, const ring r);
1899poly      p_DivideM(poly a, poly b, const ring r);
1900void      p_Lcm(poly a, poly b, poly m, const ring r);
1901poly      p_Diff(poly a, int k, const ring r);
1902poly      p_DiffOp(poly a, poly b,BOOLEAN multiply, const ring r);
1903int       p_Weight(int c, const ring r);
1904
1905/* syszygy stuff */
1906BOOLEAN   p_VectorHasUnitB(poly p, int * k, const ring r);
1907void      p_VectorHasUnit(poly p, int * k, int * len, const ring r);
1908poly      p_TakeOutComp1(poly * p, int k, const ring r);
1909// Splits *p into two polys: *q which consists of all monoms with
1910// component == comp and *p of all other monoms *lq == pLength(*q)
1911// On return all components pf *q == 0
1912void p_TakeOutComp(poly *p, long comp, poly *q, int *lq, const ring r);
1913
1914// This is something weird -- Don't use it, unless you know what you are doing
1915poly      p_TakeOutComp(poly * p, int k);
1916
1917void      p_DeleteComp(poly * p,int k, const ring r);
1918
1919/*-------------ring management:----------------------*/
1920void p_SetGlobals(const ring r, BOOLEAN complete = TRUE);
1921
1922// resets the pFDeg and pLDeg: if pLDeg is not given, it is
1923// set to currRing->pLDegOrig, i.e. to the respective LDegProc which
1924// only uses pFDeg (and not pDeg, or pTotalDegree, etc).
1925// If you use this, make sure your procs does not make any assumptions
1926// on ordering and/or OrdIndex -- otherwise they might return wrong results
1927// on strat->tailRing
1928void pSetDegProcs(ring r, pFDegProc new_FDeg, pLDegProc new_lDeg = NULL);
1929// restores pFDeg and pLDeg:
1930void pRestoreDegProcs(ring r, pFDegProc old_FDeg, pLDegProc old_lDeg);
1931
1932/*-------------pComp for syzygies:-------------------*/
1933void p_SetModDeg(intvec *w, ring r);
1934
1935/*------------ Jet ----------------------------------*/
1936poly pp_Jet(poly p, int m, const ring R);
1937poly p_Jet(poly p, int m,const ring R);
1938poly pp_JetW(poly p, int m, short *w, const ring R);
1939poly p_JetW(poly p, int m, short *w, const ring R);
1940
1941
1942poly      p_PermPoly (poly p, int * perm,const ring OldRing, const ring dst,
1943                     nMapFunc nMap, int *par_perm=NULL, int OldPar=0);
1944
1945/*----------------------------------------------------*/
1946poly p_Series(int n,poly p,poly u, intvec *w, const ring R);
1947poly p_Invers(int n,poly u,intvec *w, const ring R);
1948
1949
1950#endif // P_POLYS_H
1951
Note: See TracBrowser for help on using the repository browser.