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