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