My Project
Loading...
Searching...
No Matches
Macros | Functions
p_polys.h File Reference
#include "misc/mylimits.h"
#include "misc/intvec.h"
#include "coeffs/coeffs.h"
#include "polys/monomials/monomials.h"
#include "polys/monomials/ring.h"
#include "polys/templates/p_MemAdd.h"
#include "polys/templates/p_MemCmp.h"
#include "polys/templates/p_Procs.h"
#include "polys/sbuckets.h"
#include "polys/nc/nc.h"

Go to the source code of this file.

Macros

#define pIfThen(cond, check)   do {if (cond) {check;}} while (0)
 
#define p_Test(p, r)   _p_Test(p, r, PDEBUG)
 
#define p_LmTest(p, r)   _p_LmTest(p, r, PDEBUG)
 
#define pp_Test(p, lmRing, tailRing)   _pp_Test(p, lmRing, tailRing, PDEBUG)
 
#define p_SetmComp   p_Setm
 
#define __p_Mult_nn(p, n, r)   r->p_Procs->p_Mult_nn(p, n, r)
 
#define __pp_Mult_nn(p, n, r)   r->p_Procs->pp_Mult_nn(p, n, r)
 
#define _p_LmCmpAction(p, q, r, actionE, actionG, actionS)
 
#define pDivAssume(x)   do {} while (0)
 
#define p_LmCmpAction(p, q, r, actionE, actionG, actionS)    _p_LmCmpAction(p, q, r, actionE, actionG, actionS)
 
#define p_LmEqual(p1, p2, r)   p_ExpVectorEqual(p1, p2, r)
 

Functions

poly p_Farey (poly p, number N, const ring r)
 
poly p_ChineseRemainder (poly *xx, number *x, number *q, int rl, CFArray &inv_cache, const ring R)
 
unsigned long p_GetShortExpVector (const poly a, const ring r)
 
unsigned long p_GetShortExpVector0 (const poly a, const ring r)
 
unsigned long p_GetShortExpVector1 (const poly a, const ring r)
 
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), i.e., LT(f)*c*m = LT(g), for some coefficient c and some monomial m; does not take components into account
 
poly p_One (const ring r)
 
int p_MinDeg (poly p, intvec *w, const ring R)
 
long p_DegW (poly p, const int *w, const ring R)
 
BOOLEAN p_OneComp (poly p, const ring r)
 return TRUE if all monoms have the same component
 
int p_IsPurePower (const poly p, const ring r)
 return i, if head depends only on var(i)
 
int p_IsUnivariate (poly p, const ring r)
 return i, if poly depends only on var(i)
 
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)
 
poly p_ISet (long i, const ring r)
 returns the poly representing the integer i
 
poly p_NSet (number n, const ring r)
 returns the poly representing the number n, destroys n
 
void p_Vec2Polys (poly v, poly **p, int *len, const ring r)
 
poly p_Vec2Poly (poly v, int k, const ring r)
 
void p_Vec2Array (poly v, poly *p, int len, const ring r)
 julia: vector to already allocated array (len=p_MaxComp(v,r))
 
void p_ShallowDelete (poly *p, const ring r)
 
poly p_Sub (poly a, poly b, const ring r)
 
poly p_Power (poly p, int i, const ring r)
 
BOOLEAN pIsMonomOf (poly p, poly m)
 
BOOLEAN pHaveCommonMonoms (poly p, poly q)
 
BOOLEAN p_LmCheckIsFromRing (poly p, ring r)
 
BOOLEAN p_LmCheckPolyRing (poly p, ring r)
 
BOOLEAN p_CheckIsFromRing (poly p, ring r)
 
BOOLEAN p_CheckPolyRing (poly p, ring r)
 
BOOLEAN p_CheckRing (ring r)
 
BOOLEAN _p_Test (poly p, ring r, int level)
 
BOOLEAN _p_LmTest (poly p, ring r, int level)
 
BOOLEAN _pp_Test (poly p, ring lmRing, ring tailRing, int level)
 
static int pLength (poly a)
 
poly p_Last (const poly a, int &l, const ring r)
 
void p_Norm (poly p1, const ring r)
 
void p_Normalize (poly p, const ring r)
 
void p_ProjectiveUnique (poly p, const ring r)
 
void p_ContentForGB (poly p, const ring r)
 
void p_Content (poly p, const ring r)
 
void p_SimpleContent (poly p, int s, const ring r)
 
number p_InitContent (poly ph, const ring r)
 
poly p_Cleardenom (poly p, const ring r)
 
void p_Cleardenom_n (poly p, const ring r, number &c)
 
int p_Size (poly p, const ring r)
 
poly p_Homogen (poly p, int varnum, const ring r)
 
BOOLEAN p_IsHomogeneous (poly p, const ring r)
 
BOOLEAN p_IsHomogeneousW (poly p, const intvec *w, const ring r)
 
BOOLEAN p_IsHomogeneousW (poly p, const intvec *w, const intvec *module_w, const ring r)
 
static void p_Setm (poly p, const ring r)
 
p_SetmProc p_GetSetmProc (const ring r)
 
poly p_Subst (poly p, int n, poly e, const ring r)
 
static unsigned long p_SetComp (poly p, unsigned long c, ring r)
 
static void p_SetCompP (poly p, int i, ring r)
 
static void p_SetCompP (poly p, int i, ring lmRing, ring tailRing)
 
static long p_MaxComp (poly p, ring lmRing, ring tailRing)
 
static long p_MaxComp (poly p, ring lmRing)
 
static long p_MinComp (poly p, ring lmRing, ring tailRing)
 
static long p_MinComp (poly p, ring lmRing)
 
static poly pReverse (poly p)
 
void pEnlargeSet (poly **p, int length, int increment)
 
void p_String0 (poly p, ring lmRing, ring tailRing)
 print p according to ShortOut in lmRing & tailRing
 
charp_String (poly p, ring lmRing, ring tailRing)
 
void p_Write (poly p, ring lmRing, ring tailRing)
 
void p_Write0 (poly p, ring lmRing, ring tailRing)
 
void p_wrp (poly p, ring lmRing, ring tailRing)
 
void p_String0Short (const poly p, ring lmRing, ring tailRing)
 print p in a short way, if possible
 
void p_String0Long (const poly p, ring lmRing, ring tailRing)
 print p in a long way
 
static long p_FDeg (const poly p, const ring r)
 
static long p_LDeg (const poly p, int *l, const ring r)
 
long p_WFirstTotalDegree (poly p, ring r)
 
long p_WTotaldegree (poly p, const ring r)
 
long p_WDegree (poly p, const ring r)
 
long pLDeg0 (poly p, int *l, ring r)
 
long pLDeg0c (poly p, int *l, ring r)
 
long pLDegb (poly p, int *l, ring r)
 
long pLDeg1 (poly p, int *l, ring r)
 
long pLDeg1c (poly p, int *l, ring r)
 
long pLDeg1_Deg (poly p, int *l, ring r)
 
long pLDeg1c_Deg (poly p, int *l, ring r)
 
long pLDeg1_Totaldegree (poly p, int *l, ring r)
 
long pLDeg1c_Totaldegree (poly p, int *l, ring r)
 
long pLDeg1_WFirstTotalDegree (poly p, int *l, ring r)
 
long pLDeg1c_WFirstTotalDegree (poly p, int *l, ring r)
 
BOOLEAN p_EqualPolys (poly p1, poly p2, const ring r)
 
BOOLEAN p_EqualPolys (poly p1, poly p2, const ring r1, const ring r2)
 same as the usual p_EqualPolys for polys belonging to equal rings
 
long p_Deg (poly a, const ring r)
 
static number p_SetCoeff (poly p, number n, ring r)
 
static long p_GetOrder (poly p, ring r)
 
static unsigned long p_AddComp (poly p, unsigned long v, ring r)
 
static unsigned long p_SubComp (poly p, unsigned long v, ring r)
 
static long p_GetExp (const poly p, const unsigned long iBitmask, const int VarOffset)
 get a single variable exponent @Note: the integer VarOffset encodes:
 
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
 
static long p_GetExp (const poly p, const ring r, const int VarOffset)
 
static long p_SetExp (poly p, const long e, const ring r, const int VarOffset)
 
static long p_GetExp (const poly p, const int v, const ring r)
 get v^th exponent for a monomial
 
static long p_SetExp (poly p, const int v, const long e, const ring r)
 set v^th exponent for a monomial
 
static long p_IncrExp (poly p, int v, ring r)
 
static long p_DecrExp (poly p, int v, ring r)
 
static long p_AddExp (poly p, int v, long ee, ring r)
 
static long p_SubExp (poly p, int v, long ee, ring r)
 
static long p_MultExp (poly p, int v, long ee, ring r)
 
static long p_GetExpSum (poly p1, poly p2, int i, ring r)
 
static long p_GetExpDiff (poly p1, poly p2, int i, ring r)
 
static int p_Comp_k_n (poly a, poly b, int k, ring r)
 
static poly p_New (const ring, omBin bin)
 
static poly p_New (ring r)
 
static void p_LmFree (poly p, ring)
 
static void p_LmFree (poly *p, ring)
 
static poly p_LmFreeAndNext (poly p, ring)
 
static void p_LmDelete (poly p, const ring r)
 
static void p_LmDelete0 (poly p, const ring r)
 
static void p_LmDelete (poly *p, const ring r)
 
static poly p_LmDeleteAndNext (poly p, const ring r)
 
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
 
poly p_GetMaxExpP (poly p, ring r)
 return monomial r such that GetExp(r,i) is maximum of all monomials in p; coeff == 0, next == NULL, ord is not set
 
static unsigned long p_GetMaxExp (const unsigned long l, const ring r)
 
static unsigned long p_GetMaxExp (const poly p, const ring r)
 
static unsigned long p_GetTotalDegree (const unsigned long l, const ring r, const int number_of_exps)
 
static poly p_Copy_noCheck (poly p, const ring r)
 returns a copy of p (without any additional testing)
 
static poly p_Copy (poly p, const ring r)
 returns a copy of p
 
static poly p_Head (const poly p, const ring r)
 copy the (leading) term of p
 
poly p_Head0 (const poly p, const ring r)
 like p_Head, but allow NULL coeff
 
poly p_CopyPowerProduct (const poly p, const ring r)
 like p_Head, but with coefficient 1
 
poly p_CopyPowerProduct0 (const poly p, const number n, const ring r)
 like p_Head, but with coefficient n
 
static poly p_Copy (poly p, const ring lmRing, const ring tailRing)
 returns a copy of p with Lm(p) from lmRing and Tail(p) from tailRing
 
static void p_Delete (poly *p, const ring r)
 
static void p_Delete (poly *p, const ring lmRing, const ring tailRing)
 
static poly p_ShallowCopyDelete (poly p, const ring r, omBin bin)
 
static poly p_Add_q (poly p, poly q, const ring r)
 
static poly p_Add_q (poly p, poly q, int &lp, int lq, const ring r)
 like p_Add_q, except that if lp == pLength(lp) lq == pLength(lq) then lp == pLength(p+q)
 
static poly p_Mult_nn (poly p, number n, const ring r)
 
static poly p_Mult_nn (poly p, number n, const ring lmRing, const ring tailRing)
 
static poly pp_Mult_nn (poly p, number n, const ring r)
 
static BOOLEAN p_LmIsConstantComp (const poly p, const ring r)
 
static BOOLEAN p_LmIsConstant (const poly p, const ring r)
 
static poly pp_Mult_mm (poly p, poly m, const ring r)
 
static poly pp_mm_Mult (poly p, poly m, const ring r)
 
static poly p_Mult_mm (poly p, poly m, const ring r)
 
static poly p_mm_Mult (poly p, poly m, const ring r)
 
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)
 
static poly p_Minus_mm_Mult_qq (poly p, const poly m, const poly q, const ring r)
 
static poly pp_Mult_Coeff_mm_DivSelect (poly p, const poly m, const ring r)
 
static poly pp_Mult_Coeff_mm_DivSelect (poly p, int &lp, const poly m, const ring r)
 
static poly p_Neg (poly p, const ring r)
 
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, !rIsPluralRing(r)
 
static poly p_Mult_q (poly p, poly q, const ring r)
 
static poly pp_Mult_qq (poly p, poly q, const ring r)
 
static poly p_Plus_mm_Mult_qq (poly p, poly m, poly q, int &lp, int lq, const ring r)
 
static poly p_Plus_mm_Mult_qq (poly p, poly m, poly q, const ring r)
 
static poly p_Merge_q (poly p, poly q, const ring r)
 
static poly p_SortAdd (poly p, const ring r, BOOLEAN revert=FALSE)
 
static poly p_SortMerge (poly p, const ring r, BOOLEAN revert=FALSE)
 
static charp_String (poly p, ring p_ring)
 
static void p_String0 (poly p, ring p_ring)
 
static void p_Write (poly p, ring p_ring)
 
static void p_Write0 (poly p, ring p_ring)
 
static void p_wrp (poly p, ring p_ring)
 
static void p_MemAdd_NegWeightAdjust (poly p, const ring r)
 
static void p_MemSub_NegWeightAdjust (poly p, const ring r)
 
static void p_ExpVectorCopy (poly d_p, poly s_p, const ring r)
 
static poly p_Init (const ring r, omBin bin)
 
static poly p_Init (const ring r)
 
static poly p_LmInit (poly p, const ring r)
 
static poly p_LmInit (poly s_p, const ring s_r, const ring d_r, omBin d_bin)
 
static poly p_LmInit (poly s_p, const ring s_r, const ring d_r)
 
static poly p_GetExp_k_n (poly p, int l, int k, const ring r)
 
static poly p_LmShallowCopyDelete (poly p, const ring r)
 
static void p_ExpVectorAdd (poly p1, poly p2, const ring r)
 
static void p_ExpVectorSum (poly pr, poly p1, poly p2, const ring r)
 
static void p_ExpVectorSub (poly p1, poly p2, const ring r)
 
static void p_ExpVectorAddSub (poly p1, poly p2, poly p3, const ring r)
 
static void p_ExpVectorDiff (poly pr, poly p1, poly p2, const ring r)
 
static BOOLEAN p_ExpVectorEqual (poly p1, poly p2, const ring r)
 
static long p_Totaldegree (poly p, const ring r)
 
static void p_GetExpV (poly p, int *ev, const ring r)
 
static void p_GetExpVL (poly p, int64 *ev, const ring r)
 
static int64 p_GetExpVLV (poly p, int64 *ev, const ring r)
 
static void p_SetExpV (poly p, int *ev, const ring r)
 
static void p_SetExpVL (poly p, int64 *ev, const ring r)
 
static void p_SetExpVLV (poly p, int64 *ev, int64 comp, const ring r)
 
static int p_LmCmp (poly p, poly q, const ring r)
 
static int p_LtCmp (poly p, poly q, const ring r)
 
static int p_LtCmpNoAbs (poly p, poly q, const ring r)
 
static int p_LtCmpOrdSgnDiffM (poly p, poly q, const ring r)
 
static int p_LtCmpOrdSgnDiffP (poly p, poly q, const ring r)
 
static int p_LtCmpOrdSgnEqM (poly p, poly q, const ring r)
 
static int p_LtCmpOrdSgnEqP (poly p, poly q, const ring r)
 
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
 
static int p_Cmp (poly p1, poly p2, ring r)
 
static int p_CmpPolys (poly p1, poly p2, ring r)
 
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 vars, instead of single exponents (2) Clearly, if la > lb, then FALSE (3) Suppose la <= lb, and consider first bits of single exponents in l: if TRUE, then value of these bits is la ^ lb if FALSE, then la-lb causes an "overflow" into one of those bits, i.e., la ^ lb != la - lb
 
static BOOLEAN _p_LmDivisibleByNoComp (poly a, const ring r_a, poly b, const ring r_b)
 
static BOOLEAN _p_LmDivisibleByNoCompPart (poly a, const ring r_a, poly b, const ring r_b, const int start, const int end)
 
static BOOLEAN _p_LmDivisibleByPart (poly a, const ring r_a, poly b, const ring r_b, const int start, const int end)
 
static BOOLEAN p_LmDivisibleByPart (poly a, poly b, const ring r, const int start, const int end)
 
static BOOLEAN _p_LmDivisibleBy (poly a, poly b, const ring r)
 
static BOOLEAN p_LmDivisibleByNoComp (poly a, poly b, const ring r)
 
static BOOLEAN p_LmDivisibleByNoComp (poly a, const ring ra, poly b, const ring rb)
 
static BOOLEAN p_LmDivisibleBy (poly a, poly b, const ring r)
 
static BOOLEAN p_DivisibleBy (poly a, poly b, const ring r)
 
static BOOLEAN p_LmShortDivisibleBy (poly a, unsigned long sev_a, poly b, unsigned long not_sev_b, const ring r)
 
static BOOLEAN p_LmShortDivisibleByNoComp (poly a, unsigned long sev_a, poly b, unsigned long not_sev_b, const ring r)
 
static BOOLEAN p_IsConstantComp (const poly p, const ring r)
 like the respective p_LmIs* routines, except that p might be empty
 
static BOOLEAN p_IsConstant (const poly p, const ring r)
 
static BOOLEAN p_IsOne (const poly p, const ring R)
 either poly(1) or gen(k)?!
 
static BOOLEAN p_IsConstantPoly (const poly p, const ring r)
 
static BOOLEAN p_IsUnit (const poly p, const ring r)
 
static BOOLEAN p_LmExpVectorAddIsOk (const poly p1, const poly p2, const ring r)
 
void p_Split (poly p, poly *r)
 
BOOLEAN p_HasNotCF (poly p1, poly p2, const ring r)
 
BOOLEAN p_HasNotCFRing (poly p1, poly p2, const ring r)
 
poly p_mInit (const char *s, BOOLEAN &ok, const ring r)
 
const charp_Read (const char *s, poly &p, const ring r)
 
poly p_MDivide (poly a, poly b, const ring r)
 
poly p_DivideM (poly a, poly b, const ring r)
 
poly pp_DivideM (poly a, poly b, const ring r)
 
poly p_Div_nn (poly p, const number n, const ring r)
 
void p_Lcm (const poly a, const poly b, poly m, const ring r)
 
poly p_Lcm (const poly a, const poly b, const ring r)
 
poly p_LcmRat (const poly a, const poly b, const long lCompM, const ring r)
 
poly p_GetCoeffRat (poly p, int ishift, ring r)
 
void p_LmDeleteAndNextRat (poly *p, int ishift, ring r)
 
void p_ContentRat (poly &ph, const ring r)
 
poly p_Diff (poly a, int k, const ring r)
 
poly p_DiffOp (poly a, poly b, BOOLEAN multiply, const ring r)
 
int p_Weight (int c, const ring r)
 
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 divisor != NULL; p may be NULL; assumes a global monomial ordering in r; performs polynomial division of p by divisor:
 
BOOLEAN p_VectorHasUnitB (poly p, int *k, const ring r)
 
void p_VectorHasUnit (poly p, int *k, int *len, const ring r)
 
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 monoms *lq == pLength(*q) On return all components pf *q == 0.
 
poly p_TakeOutComp (poly *p, int k, const ring r)
 
void p_DeleteComp (poly *p, int k, const ring r)
 
void pSetDegProcs (ring r, pFDegProc new_FDeg, pLDegProc new_lDeg=NULL)
 
void pRestoreDegProcs (ring r, pFDegProc old_FDeg, pLDegProc old_lDeg)
 
void p_SetModDeg (intvec *w, ring r)
 
poly pp_Jet (poly p, int m, const ring R)
 
poly pp_Jet0 (poly p, const ring R)
 
poly p_Jet (poly p, int m, const ring R)
 
poly pp_JetW (poly p, int m, int *w, const ring R)
 
poly p_JetW (poly p, int m, int *w, const ring R)
 
poly n_PermNumber (const number z, const int *par_perm, const int OldPar, const ring src, const ring dst)
 
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)
 
poly p_Series (int n, poly p, poly u, intvec *w, const ring R)
 
int p_Var (poly mi, const ring r)
 
int p_LowVar (poly p, const ring r)
 the minimal index of used variables - 1
 
void p_Shift (poly *p, int i, const ring r)
 shifts components of the vector p by i
 
int p_Compare (const poly a, const poly b, const ring R)
 
poly p_GcdMon (poly f, poly g, const ring r)
 polynomial gcd for f=mon
 
poly p_Div_mm (poly p, const poly m, const ring r)
 divide polynomial by monomial
 
int p_MaxExpPerVar (poly p, int i, const ring r)
 max exponent of variable x_i in p
 

Macro Definition Documentation

◆ __p_Mult_nn

#define __p_Mult_nn (   p,
  n,
 
)    r->p_Procs->p_Mult_nn(p, n, r)

Definition at line 971 of file p_polys.h.

◆ __pp_Mult_nn

#define __pp_Mult_nn (   p,
  n,
 
)    r->p_Procs->pp_Mult_nn(p, n, r)

Definition at line 1002 of file p_polys.h.

◆ _p_LmCmpAction

#define _p_LmCmpAction (   p,
  q,
  r,
  actionE,
  actionG,
  actionS 
)
Value:
p_MemCmp_LengthGeneral_OrdGeneral(p->exp, q->exp, r->CmpL_Size, r->ordsgn, \
int p
Definition cfModGcd.cc:4086
#define p_MemCmp_LengthGeneral_OrdGeneral(s1, s2, length, ordsgn, actionE, actionG, actionS)
Definition p_MemCmp.h:719

Definition at line 1276 of file p_polys.h.

1281 {} while (0)
1282
1283
1284
1285/***************************************************************
1286 *
1287 * Allocation/Initalization/Deletion
1288 *
1289 ***************************************************************/
1290// adjustments for negative weights
1291static inline void p_MemAdd_NegWeightAdjust(poly p, const ring r)
1292{
1293 if (r->NegWeightL_Offset != NULL)
1294 {
1295 for (int i=r->NegWeightL_Size-1; i>=0; i--)
1296 {
1297 p->exp[r->NegWeightL_Offset[i]] -= POLY_NEGWEIGHT_OFFSET;
1298 }
1299 }
1300}
1301static inline void p_MemSub_NegWeightAdjust(poly p, const ring r)
1302{
1303 if (r->NegWeightL_Offset != NULL)
1304 {
1305 for (int i=r->NegWeightL_Size-1; i>=0; i--)
1306 {
1307 p->exp[r->NegWeightL_Offset[i]] += POLY_NEGWEIGHT_OFFSET;
1308 }
1309 }
1310}
1311// ExpVextor(d_p) = ExpVector(s_p)
1312static inline void p_ExpVectorCopy(poly d_p, poly s_p, const ring r)
1313{
1316 memcpy(d_p->exp, s_p->exp, r->ExpL_Size*sizeof(long));
1317}
1318
1319static inline poly p_Init(const ring r, omBin bin)
1320{
1321 p_CheckRing1(r);
1322 pAssume1(bin != NULL && omSizeWOfBin(r->PolyBin) == omSizeWOfBin(bin));
1323 poly p;
1324 omTypeAlloc0Bin(poly, p, bin);
1326 p_SetRingOfLm(p, r);
1327 return p;
1328}
1329static inline poly p_Init(const ring r)
1330{
1331 return p_Init(r, r->PolyBin);
1332}
1333
1334static inline poly p_LmInit(poly p, const ring r)
1335{
1337 poly np;
1338 omTypeAllocBin(poly, np, r->PolyBin);
1339 p_SetRingOfLm(np, r);
1340 memcpy(np->exp, p->exp, r->ExpL_Size*sizeof(long));
1341 pNext(np) = NULL;
1342 pSetCoeff0(np, NULL);
1343 return np;
1344}
1345static inline poly p_LmInit(poly s_p, const ring s_r, const ring d_r, omBin d_bin)
1346{
1349 pAssume1(d_r->N <= s_r->N);
1350 poly d_p = p_Init(d_r, d_bin);
1351 for (unsigned i=d_r->N; i!=0; i--)
1352 {
1353 p_SetExp(d_p, i, p_GetExp(s_p, i,s_r), d_r);
1354 }
1355 if (rRing_has_Comp(d_r))
1356 {
1358 }
1359 p_Setm(d_p, d_r);
1360 return d_p;
1361}
1362static inline poly p_LmInit(poly s_p, const ring s_r, const ring d_r)
1363{
1364 pAssume1(d_r != NULL);
1365 return p_LmInit(s_p, s_r, d_r, d_r->PolyBin);
1366}
1367
1368// set all exponents l..k to 0, assume exp. k+1..n and 1..l-1 are in
1369// different blocks
1370// set coeff to 1
1371static inline poly p_GetExp_k_n(poly p, int l, int k, const ring r)
1372{
1373 if (p == NULL) return NULL;
1375 poly np;
1376 omTypeAllocBin(poly, np, r->PolyBin);
1377 p_SetRingOfLm(np, r);
1378 memcpy(np->exp, p->exp, r->ExpL_Size*sizeof(long));
1379 pNext(np) = NULL;
1380 pSetCoeff0(np, n_Init(1, r->cf));
1381 int i;
1382 for(i=l;i<=k;i++)
1383 {
1384 //np->exp[(r->VarOffset[i] & 0xffffff)] =0;
1385 p_SetExp(np,i,0,r);
1386 }
1387 p_Setm(np,r);
1388 return np;
1389}
1390
1391// simialar to p_ShallowCopyDelete but does it only for leading monomial
1392static inline poly p_LmShallowCopyDelete(poly p, const ring r)
1393{
1395 pAssume1(omSizeWOfBin(bin) == omSizeWOfBin(r->PolyBin));
1396 poly new_p = p_New(r);
1397 memcpy(new_p->exp, p->exp, r->ExpL_Size*sizeof(long));
1399 pNext(new_p) = pNext(p);
1401 return new_p;
1402}
1403
1404/***************************************************************
1405 *
1406 * Operation on ExpVectors
1407 *
1408 ***************************************************************/
1409// ExpVector(p1) += ExpVector(p2)
1410static inline void p_ExpVectorAdd(poly p1, poly p2, const ring r)
1411{
1412 p_LmCheckPolyRing1(p1, r);
1413 p_LmCheckPolyRing1(p2, r);
1414#if PDEBUG >= 1
1415 for (int i=1; i<=r->N; i++)
1416 pAssume1((unsigned long) (p_GetExp(p1, i, r) + p_GetExp(p2, i, r)) <= r->bitmask);
1417 pAssume1(p_GetComp(p1, r) == 0 || p_GetComp(p2, r) == 0);
1418#endif
1419
1420 p_MemAdd_LengthGeneral(p1->exp, p2->exp, r->ExpL_Size);
1422}
1423// ExpVector(pr) = ExpVector(p1) + ExpVector(p2)
1424static inline void p_ExpVectorSum(poly pr, poly p1, poly p2, const ring r)
1425{
1426 p_LmCheckPolyRing1(p1, r);
1427 p_LmCheckPolyRing1(p2, r);
1429#if PDEBUG >= 1
1430 for (int i=1; i<=r->N; i++)
1431 pAssume1((unsigned long) (p_GetExp(p1, i, r) + p_GetExp(p2, i, r)) <= r->bitmask);
1432 pAssume1(p_GetComp(p1, r) == 0 || p_GetComp(p2, r) == 0);
1433#endif
1434
1435 p_MemSum_LengthGeneral(pr->exp, p1->exp, p2->exp, r->ExpL_Size);
1437}
1438// ExpVector(p1) -= ExpVector(p2)
1439static inline void p_ExpVectorSub(poly p1, poly p2, const ring r)
1440{
1441 p_LmCheckPolyRing1(p1, r);
1442 p_LmCheckPolyRing1(p2, r);
1443#if PDEBUG >= 1
1444 for (int i=1; i<=r->N; i++)
1445 pAssume1(p_GetExp(p1, i, r) >= p_GetExp(p2, i, r));
1446 pAssume1(p_GetComp(p1, r) == 0 || p_GetComp(p2, r) == 0 ||
1447 p_GetComp(p1, r) == p_GetComp(p2, r));
1448#endif
1449
1450 p_MemSub_LengthGeneral(p1->exp, p2->exp, r->ExpL_Size);
1452}
1453
1454// ExpVector(p1) += ExpVector(p2) - ExpVector(p3)
1455static inline void p_ExpVectorAddSub(poly p1, poly p2, poly p3, const ring r)
1456{
1457 p_LmCheckPolyRing1(p1, r);
1458 p_LmCheckPolyRing1(p2, r);
1460#if PDEBUG >= 1
1461 for (int i=1; i<=r->N; i++)
1462 pAssume1(p_GetExp(p1, i, r) + p_GetExp(p2, i, r) >= p_GetExp(p3, i, r));
1463 pAssume1(p_GetComp(p1, r) == 0 ||
1464 (p_GetComp(p2, r) - p_GetComp(p3, r) == 0) ||
1465 (p_GetComp(p1, r) == p_GetComp(p2, r) - p_GetComp(p3, r)));
1466#endif
1467
1468 p_MemAddSub_LengthGeneral(p1->exp, p2->exp, p3->exp, r->ExpL_Size);
1469 // no need to adjust in case of NegWeights
1470}
1471
1472// ExpVector(pr) = ExpVector(p1) - ExpVector(p2)
1473static inline void p_ExpVectorDiff(poly pr, poly p1, poly p2, const ring r)
1474{
1475 p_LmCheckPolyRing1(p1, r);
1476 p_LmCheckPolyRing1(p2, r);
1478#if PDEBUG >= 2
1479 for (int i=1; i<=r->N; i++)
1480 pAssume1(p_GetExp(p1, i, r) >= p_GetExp(p2, i, r));
1481 pAssume1(!rRing_has_Comp(r) || p_GetComp(p1, r) == p_GetComp(p2, r));
1482#endif
1483
1484 p_MemDiff_LengthGeneral(pr->exp, p1->exp, p2->exp, r->ExpL_Size);
1486}
1487
1488static inline BOOLEAN p_ExpVectorEqual(poly p1, poly p2, const ring r)
1489{
1490 p_LmCheckPolyRing1(p1, r);
1491 p_LmCheckPolyRing1(p2, r);
1492
1493 unsigned i = r->ExpL_Size;
1494 unsigned long *ep = p1->exp;
1495 unsigned long *eq = p2->exp;
1496
1497 do
1498 {
1499 i--;
1500 if (ep[i] != eq[i]) return FALSE;
1501 }
1502 while (i!=0);
1503 return TRUE;
1504}
1505
1506static inline long p_Totaldegree(poly p, const ring r)
1507{
1509 unsigned long s = p_GetTotalDegree(p->exp[r->VarL_Offset[0]],
1510 r,
1511 r->ExpPerLong);
1512 for (unsigned i=r->VarL_Size-1; i!=0; i--)
1513 {
1514 s += p_GetTotalDegree(p->exp[r->VarL_Offset[i]], r,r->ExpPerLong);
1515 }
1516 return (long)s;
1517}
1518
1519static inline void p_GetExpV(poly p, int *ev, const ring r)
1520{
1522 for (unsigned j = r->N; j!=0; j--)
1523 ev[j] = p_GetExp(p, j, r);
1524
1525 ev[0] = p_GetComp(p, r);
1526}
1527// p_GetExpVL is used in Singular,jl
1528static inline void p_GetExpVL(poly p, int64 *ev, const ring r)
1529{
1531 for (unsigned j = r->N; j!=0; j--)
1532 ev[j-1] = p_GetExp(p, j, r);
1533}
1534// p_GetExpVLV is used in Singular,jl
1535static inline int64 p_GetExpVLV(poly p, int64 *ev, const ring r)
1536{
1538 for (unsigned j = r->N; j!=0; j--)
1539 ev[j-1] = p_GetExp(p, j, r);
1540 return (int64)p_GetComp(p,r);
1541}
1542// p_GetExpVL is used in Singular,jl
1543static inline void p_SetExpV(poly p, int *ev, const ring r)
1544{
1546 for (unsigned j = r->N; j!=0; j--)
1547 p_SetExp(p, j, ev[j], r);
1548
1549 if(ev[0]!=0) p_SetComp(p, ev[0],r);
1550 p_Setm(p, r);
1551}
1552static inline void p_SetExpVL(poly p, int64 *ev, const ring r)
1553{
1555 for (unsigned j = r->N; j!=0; j--)
1556 p_SetExp(p, j, ev[j-1], r);
1557 p_SetComp(p, 0,r);
1558
1559 p_Setm(p, r);
1560}
1561
1562// p_SetExpVLV is used in Singular,jl
1563static inline void p_SetExpVLV(poly p, int64 *ev, int64 comp, const ring r)
1564{
1566 for (unsigned j = r->N; j!=0; j--)
1567 p_SetExp(p, j, ev[j-1], r);
1568 p_SetComp(p, comp,r);
1569
1570 p_Setm(p, r);
1571}
1572
1573/***************************************************************
1574 *
1575 * Comparison w.r.t. monomial ordering
1576 *
1577 ***************************************************************/
1578
1579static inline int p_LmCmp(poly p, poly q, const ring r)
1580{
1582 p_LmCheckPolyRing1(q, r);
1583
1584 const unsigned long* _s1 = ((unsigned long*) p->exp);
1585 const unsigned long* _s2 = ((unsigned long*) q->exp);
1586 REGISTER unsigned long _v1;
1587 REGISTER unsigned long _v2;
1588 const unsigned long _l = r->CmpL_Size;
1589
1590 REGISTER unsigned long _i=0;
1591
1593 _v1 = _s1[_i];
1594 _v2 = _s2[_i];
1595 if (_v1 == _v2)
1596 {
1597 _i++;
1598 if (_i == _l) return 0;
1600 }
1601 const long* _ordsgn = (long*) r->ordsgn;
1602#if 1 /* two variants*/
1603 if (_v1 > _v2)
1604 {
1605 return _ordsgn[_i];
1606 }
1607 return -(_ordsgn[_i]);
1608#else
1609 if (_v1 > _v2)
1610 {
1611 if (_ordsgn[_i] == 1) return 1;
1612 return -1;
1613 }
1614 if (_ordsgn[_i] == 1) return -1;
1615 return 1;
1616#endif
1617}
1618
1619// The coefficient will be compared in absolute value
1620static inline int p_LtCmp(poly p, poly q, const ring r)
1621{
1622 int res = p_LmCmp(p,q,r);
1623 if(res == 0)
1624 {
1625 if(p_GetCoeff(p,r) == NULL || p_GetCoeff(q,r) == NULL)
1626 return res;
1627 number pc = n_Copy(p_GetCoeff(p,r),r->cf);
1628 number qc = n_Copy(p_GetCoeff(q,r),r->cf);
1629 if(!n_GreaterZero(pc,r->cf))
1630 pc = n_InpNeg(pc,r->cf);
1631 if(!n_GreaterZero(qc,r->cf))
1632 qc = n_InpNeg(qc,r->cf);
1633 if(n_Greater(pc,qc,r->cf))
1634 res = 1;
1635 else if(n_Greater(qc,pc,r->cf))
1636 res = -1;
1637 else if(n_Equal(pc,qc,r->cf))
1638 res = 0;
1639 n_Delete(&pc,r->cf);
1640 n_Delete(&qc,r->cf);
1641 }
1642 return res;
1643}
1644
1645// The coefficient will be compared in absolute value
1646static inline int p_LtCmpNoAbs(poly p, poly q, const ring r)
1647{
1648 int res = p_LmCmp(p,q,r);
1649 if(res == 0)
1650 {
1651 if(p_GetCoeff(p,r) == NULL || p_GetCoeff(q,r) == NULL)
1652 return res;
1653 number pc = p_GetCoeff(p,r);
1654 number qc = p_GetCoeff(q,r);
1655 if(n_Greater(pc,qc,r->cf))
1656 res = 1;
1657 if(n_Greater(qc,pc,r->cf))
1658 res = -1;
1659 if(n_Equal(pc,qc,r->cf))
1660 res = 0;
1661 }
1662 return res;
1663}
1664
1665#ifdef HAVE_RINGS
1666// This is the equivalent of pLmCmp(p,q) != -currRing->OrdSgn for rings
1667// It is used in posInTRing
1668static inline int p_LtCmpOrdSgnDiffM(poly p, poly q, const ring r)
1669{
1670 return(p_LtCmp(p,q,r) == r->OrdSgn);
1671}
1672#endif
1673
1674#ifdef HAVE_RINGS
1675// This is the equivalent of pLmCmp(p,q) != currRing->OrdSgn for rings
1676// It is used in posInTRing
1677static inline int p_LtCmpOrdSgnDiffP(poly p, poly q, const ring r)
1678{
1679 if(r->OrdSgn == 1)
1680 {
1681 return(p_LmCmp(p,q,r) == -1);
1682 }
1683 else
1684 {
1685 return(p_LtCmp(p,q,r) != -1);
1686 }
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_LtCmpOrdSgnEqM(poly p, poly q, const ring r)
1694{
1695 return(p_LtCmp(p,q,r) == -r->OrdSgn);
1696}
1697#endif
1698
1699#ifdef HAVE_RINGS
1700// This is the equivalent of pLmCmp(p,q) == currRing->OrdSgn for rings
1701// It is used in posInTRing
1702static inline int p_LtCmpOrdSgnEqP(poly p, poly q, const ring r)
1703{
1704 return(p_LtCmp(p,q,r) == r->OrdSgn);
1705}
1706#endif
1707
1708/// returns TRUE if p1 is a skalar multiple of p2
1709/// assume p1 != NULL and p2 != NULL
1710BOOLEAN p_ComparePolys(poly p1,poly p2, const ring r);
1711
1712
1713/***************************************************************
1714 *
1715 * Comparisons: they are all done without regarding coeffs
1716 *
1717 ***************************************************************/
1718#define p_LmCmpAction(p, q, r, actionE, actionG, actionS) \
1719 _p_LmCmpAction(p, q, r, actionE, actionG, actionS)
1720
1721// returns 1 if ExpVector(p)==ExpVector(q): does not compare numbers !!
1722#define p_LmEqual(p1, p2, r) p_ExpVectorEqual(p1, p2, r)
1723
1724// pCmp: args may be NULL
1725// returns: (p2==NULL ? 1 : (p1 == NULL ? -1 : p_LmCmp(p1, p2)))
1726static inline int p_Cmp(poly p1, poly p2, ring r)
1727{
1728 if (p2==NULL)
1729 {
1730 if (p1==NULL) return 0;
1731 return 1;
1732 }
1733 if (p1==NULL)
1734 return -1;
1735 return p_LmCmp(p1,p2,r);
1736}
1737
1738static inline int p_CmpPolys(poly p1, poly p2, ring r)
1739{
1740 if (p2==NULL)
1741 {
1742 if (p1==NULL) return 0;
1743 return 1;
1744 }
1745 if (p1==NULL)
1746 return -1;
1747 return p_ComparePolys(p1,p2,r);
1748}
1749
1750
1751/***************************************************************
1752 *
1753 * divisibility
1754 *
1755 ***************************************************************/
1756/// return: FALSE, if there exists i, such that a->exp[i] > b->exp[i]
1757/// TRUE, otherwise
1758/// (1) Consider long vars, instead of single exponents
1759/// (2) Clearly, if la > lb, then FALSE
1760/// (3) Suppose la <= lb, and consider first bits of single exponents in l:
1761/// if TRUE, then value of these bits is la ^ lb
1762/// if FALSE, then la-lb causes an "overflow" into one of those bits, i.e.,
1763/// la ^ lb != la - lb
1764static inline BOOLEAN _p_LmDivisibleByNoComp(poly a, poly b, const ring r)
1765{
1766 int i=r->VarL_Size - 1;
1767 unsigned long divmask = r->divmask;
1768 unsigned long la, lb;
1769
1770 if (r->VarL_LowIndex >= 0)
1771 {
1772 i += r->VarL_LowIndex;
1773 do
1774 {
1775 la = a->exp[i];
1776 lb = b->exp[i];
1777 if ((la > lb) ||
1778 (((la & divmask) ^ (lb & divmask)) != ((lb - la) & divmask)))
1779 {
1781 return FALSE;
1782 }
1783 i--;
1784 }
1785 while (i>=r->VarL_LowIndex);
1786 }
1787 else
1788 {
1789 do
1790 {
1791 la = a->exp[r->VarL_Offset[i]];
1792 lb = b->exp[r->VarL_Offset[i]];
1793 if ((la > lb) ||
1794 (((la & divmask) ^ (lb & divmask)) != ((lb - la) & divmask)))
1795 {
1797 return FALSE;
1798 }
1799 i--;
1800 }
1801 while (i>=0);
1802 }
1803/*#ifdef HAVE_RINGS
1804 pDivAssume(p_DebugLmDivisibleByNoComp(a, b, r) == n_DivBy(p_GetCoeff(b, r), p_GetCoeff(a, r), r->cf));
1805 return (!rField_is_Ring(r)) || n_DivBy(p_GetCoeff(b, r), p_GetCoeff(a, r), r->cf);
1806#else
1807*/
1809 return TRUE;
1810//#endif
1811}
1812
1813static inline BOOLEAN _p_LmDivisibleByNoComp(poly a, const ring r_a, poly b, const ring r_b)
1814{
1815 int i=r_a->N;
1816 pAssume1(r_a->N == r_b->N);
1817
1818 do
1819 {
1820 if (p_GetExp(a,i,r_a) > p_GetExp(b,i,r_b))
1821 {
1822 return FALSE;
1823 }
1824 i--;
1825 }
1826 while (i);
1827/*#ifdef HAVE_RINGS
1828 return n_DivBy(p_GetCoeff(b, r_b), p_GetCoeff(a, r_a), r_a->cf);
1829#else
1830*/
1831 return TRUE;
1832//#endif
1833}
1834
1835#ifdef HAVE_RATGRING
1836static inline BOOLEAN _p_LmDivisibleByNoCompPart(poly a, const ring r_a, poly b, const ring r_b,const int start, const int end)
1837{
1838 int i=end;
1839 pAssume1(r_a->N == r_b->N);
1840
1841 do
1842 {
1843 if (p_GetExp(a,i,r_a) > p_GetExp(b,i,r_b))
1844 return FALSE;
1845 i--;
1846 }
1847 while (i>=start);
1848/*#ifdef HAVE_RINGS
1849 return n_DivBy(p_GetCoeff(b, r_b), p_GetCoeff(a, r_a), r_a->cf);
1850#else
1851*/
1852 return TRUE;
1853//#endif
1854}
1855static inline BOOLEAN _p_LmDivisibleByPart(poly a, const ring r_a, poly b, const ring r_b,const int start, const int end)
1856{
1857 if (p_GetComp(a, r_a) == 0 || p_GetComp(a,r_a) == p_GetComp(b,r_b))
1858 return _p_LmDivisibleByNoCompPart(a, r_a, b, r_b,start,end);
1859 return FALSE;
1860}
1861static inline BOOLEAN p_LmDivisibleByPart(poly a, poly b, const ring r,const int start, const int end)
1862{
1864 pIfThen1(a != NULL, p_LmCheckPolyRing1(b, r));
1865 if (p_GetComp(a, r) == 0 || p_GetComp(a,r) == p_GetComp(b,r))
1866 return _p_LmDivisibleByNoCompPart(a, r, b, r,start, end);
1867 return FALSE;
1868}
1869#endif
1870static inline BOOLEAN _p_LmDivisibleBy(poly a, poly b, const ring r)
1871{
1872 if (p_GetComp(a, r) == 0 || p_GetComp(a,r) == p_GetComp(b,r))
1873 return _p_LmDivisibleByNoComp(a, b, r);
1874 return FALSE;
1875}
1876static inline BOOLEAN p_LmDivisibleByNoComp(poly a, poly b, const ring r)
1877{
1878 p_LmCheckPolyRing1(a, r);
1880 return _p_LmDivisibleByNoComp(a, b, r);
1881}
1882
1883static inline BOOLEAN p_LmDivisibleByNoComp(poly a, const ring ra, poly b, const ring rb)
1884{
1887 return _p_LmDivisibleByNoComp(a, ra, b, rb);
1888}
1889
1890static inline BOOLEAN p_LmDivisibleBy(poly a, poly b, const ring r)
1891{
1893 pIfThen1(a != NULL, p_LmCheckPolyRing1(b, r));
1894 if (p_GetComp(a, r) == 0 || p_GetComp(a,r) == p_GetComp(b,r))
1895 return _p_LmDivisibleByNoComp(a, b, r);
1896 return FALSE;
1897}
1898
1899static inline BOOLEAN p_DivisibleBy(poly a, poly b, const ring r)
1900{
1902 pIfThen1(a!=NULL, p_LmCheckPolyRing1(a, r));
1903
1904 if (a != NULL && (p_GetComp(a, r) == 0 || p_GetComp(a,r) == p_GetComp(b,r)))
1905 return _p_LmDivisibleByNoComp(a,b,r);
1906 return FALSE;
1907}
1908
1909static inline BOOLEAN p_LmShortDivisibleBy(poly a, unsigned long sev_a,
1910 poly b, unsigned long not_sev_b, const ring r)
1911{
1912 p_LmCheckPolyRing1(a, r);
1914#ifndef PDIV_DEBUG
1915 _pPolyAssume2(p_GetShortExpVector(a, r) == sev_a, a, r);
1917
1918 if (sev_a & not_sev_b)
1919 {
1921 return FALSE;
1922 }
1923 return p_LmDivisibleBy(a, b, r);
1924#else
1925 return pDebugLmShortDivisibleBy(a, sev_a, r, b, not_sev_b, r);
1926#endif
1927}
1928
1929static inline BOOLEAN p_LmShortDivisibleByNoComp(poly a, unsigned long sev_a,
1930 poly b, unsigned long not_sev_b, const ring r)
1931{
1932 p_LmCheckPolyRing1(a, r);
1934#ifndef PDIV_DEBUG
1935 _pPolyAssume2(p_GetShortExpVector(a, r) == sev_a, a, r);
1937
1938 if (sev_a & not_sev_b)
1939 {
1941 return FALSE;
1942 }
1943 return p_LmDivisibleByNoComp(a, b, r);
1944#else
1946#endif
1947}
1948
1949/***************************************************************
1950 *
1951 * Misc things on Lm
1952 *
1953 ***************************************************************/
1954
1955
1956/// like the respective p_LmIs* routines, except that p might be empty
1957static inline BOOLEAN p_IsConstantComp(const poly p, const ring r)
1958{
1959 if (p == NULL) return TRUE;
1960 return (pNext(p)==NULL) && p_LmIsConstantComp(p, r);
1961}
1962
1963static inline BOOLEAN p_IsConstant(const poly p, const ring r)
1964{
1965 if (p == NULL) return TRUE;
1966 return (pNext(p)==NULL) && p_LmIsConstant(p, r);
1967}
1968
1969/// either poly(1) or gen(k)?!
1970static inline BOOLEAN p_IsOne(const poly p, const ring R)
1971{
1972 if (p == NULL) return FALSE; /* TODO check if 0 == 1 */
1973 p_Test(p, R);
1974 return (p_IsConstant(p, R) && n_IsOne(p_GetCoeff(p, R), R->cf));
1975}
1976
1977static inline BOOLEAN p_IsConstantPoly(const poly p, const ring r)
1978{
1979 p_Test(p, r);
1980 poly pp=p;
1981 while(pp!=NULL)
1982 {
1983 if (! p_LmIsConstantComp(pp, r))
1984 return FALSE;
1985 pIter(pp);
1986 }
1987 return TRUE;
1988}
1989
1990static inline BOOLEAN p_IsUnit(const poly p, const ring r)
1991{
1992 if (p == NULL) return FALSE;
1993 if (rField_is_Ring(r))
1994 return (p_LmIsConstant(p, r) && n_IsUnit(pGetCoeff(p),r->cf));
1995 return p_LmIsConstant(p, r);
1996}
1997
1998static inline BOOLEAN p_LmExpVectorAddIsOk(const poly p1, const poly p2,
1999 const ring r)
2000{
2001 p_LmCheckPolyRing(p1, r);
2002 p_LmCheckPolyRing(p2, r);
2003 unsigned long l1, l2, divmask = r->divmask;
2004 int i;
2005
2006 for (i=0; i<r->VarL_Size; i++)
2007 {
2008 l1 = p1->exp[r->VarL_Offset[i]];
2009 l2 = p2->exp[r->VarL_Offset[i]];
2010 // do the divisiblity trick
2011 if ( (l1 > ULONG_MAX - l2) ||
2012 (((l1 & divmask) ^ (l2 & divmask)) != ((l1 + l2) & divmask)))
2013 return FALSE;
2014 }
2015 return TRUE;
2016}
2017void p_Split(poly p, poly * r); /*p => IN(p), r => REST(p) */
2018BOOLEAN p_HasNotCF(poly p1, poly p2, const ring r);
2019BOOLEAN p_HasNotCFRing(poly p1, poly p2, const ring r);
2020poly p_mInit(const char *s, BOOLEAN &ok, const ring r); /* monom s -> poly, interpreter */
2021const char * p_Read(const char *s, poly &p,const ring r); /* monom -> poly */
2022poly p_MDivide(poly a, poly b, const ring r);
2023poly p_DivideM(poly a, poly b, const ring r);
2024poly pp_DivideM(poly a, poly b, const ring r);
2025poly p_Div_nn(poly p, const number n, const ring r);
2026
2027// returns the LCM of the head terms of a and b in *m, does not p_Setm
2028void p_Lcm(const poly a, const poly b, poly m, const ring r);
2029// returns the LCM of the head terms of a and b, does p_Setm
2030poly p_Lcm(const poly a, const poly b, const ring r);
2031
2032#ifdef HAVE_RATGRING
2033poly p_LcmRat(const poly a, const poly b, const long lCompM, const ring r);
2034poly p_GetCoeffRat(poly p, int ishift, ring r);
2035void p_LmDeleteAndNextRat(poly *p, int ishift, ring r);
2036void p_ContentRat(poly &ph, const ring r);
2037#endif /* ifdef HAVE_RATGRING */
2038
2039
2040poly p_Diff(poly a, int k, const ring r);
2041poly p_DiffOp(poly a, poly b,BOOLEAN multiply, const ring r);
2042int p_Weight(int c, const ring r);
2043
2044/// assumes that p and divisor are univariate polynomials in r,
2045/// mentioning the same variable;
2046/// assumes divisor != NULL;
2047/// p may be NULL;
2048/// assumes a global monomial ordering in r;
2049/// performs polynomial division of p by divisor:
2050/// - afterwards p contains the remainder of the division, i.e.,
2051/// p_before = result * divisor + p_afterwards;
2052/// - if needResult == TRUE, then the method computes and returns 'result',
2053/// otherwise NULL is returned (This parametrization can be used when
2054/// one is only interested in the remainder of the division. In this
2055/// case, the method will be slightly faster.)
2056/// leaves divisor unmodified
2057poly p_PolyDiv(poly &p, const poly divisor, const BOOLEAN needResult, const ring r);
2058
2059/* syszygy stuff */
2060BOOLEAN p_VectorHasUnitB(poly p, int * k, const ring r);
2061void p_VectorHasUnit(poly p, int * k, int * len, const ring r);
2062/// Splits *p into two polys: *q which consists of all monoms with
2063/// component == comp and *p of all other monoms *lq == pLength(*q)
2064/// On return all components pf *q == 0
2065void p_TakeOutComp(poly *p, long comp, poly *q, int *lq, const ring r);
2066
2067// This is something weird -- Don't use it, unless you know what you are doing
2068poly p_TakeOutComp(poly * p, int k, const ring r);
2069
2070void p_DeleteComp(poly * p,int k, const ring r);
2071
2072/*-------------ring management:----------------------*/
2073
2074// resets the pFDeg and pLDeg: if pLDeg is not given, it is
2075// set to currRing->pLDegOrig, i.e. to the respective LDegProc which
2076// only uses pFDeg (and not pDeg, or pTotalDegree, etc).
2077// If you use this, make sure your procs does not make any assumptions
2078// on ordering and/or OrdIndex -- otherwise they might return wrong results
2079// on strat->tailRing
2081// restores pFDeg and pLDeg:
2083
2084/*-------------pComp for syzygies:-------------------*/
2085void p_SetModDeg(intvec *w, ring r);
2086
2087/*------------ Jet ----------------------------------*/
2088poly pp_Jet(poly p, int m, const ring R);
2089poly pp_Jet0(poly p, const ring R); /*pp_Jet(p,0,R)*/
2090poly p_Jet(poly p, int m,const ring R);
2091poly pp_JetW(poly p, int m, int *w, const ring R);
2092poly p_JetW(poly p, int m, int *w, const ring R);
2093
2094poly n_PermNumber(const number z, const int *par_perm, const int OldPar, const ring src, const ring dst);
2095
2096poly p_PermPoly (poly p, const int * perm,const ring OldRing, const ring dst,
2097 nMapFunc nMap, const int *par_perm=NULL, int OldPar=0,
2099
2100/*----------------------------------------------------*/
2101poly p_Series(int n,poly p,poly u, intvec *w, const ring R);
2102
2103/*----------------------------------------------------*/
2104int p_Var(poly mi, const ring r);
2105/// the minimal index of used variables - 1
2106int p_LowVar (poly p, const ring r);
2107
2108/*----------------------------------------------------*/
2109/// shifts components of the vector p by i
2110void p_Shift (poly * p,int i, const ring r);
2111/*----------------------------------------------------*/
2112
2113int p_Compare(const poly a, const poly b, const ring R);
2114
2115/// polynomial gcd for f=mon
2116poly p_GcdMon(poly f, poly g, const ring r);
2117
2118/// divide polynomial by monomial
2119poly p_Div_mm(poly p, const poly m, const ring r);
2120
2121
2122/// max exponent of variable x_i in p
2123int p_MaxExpPerVar(poly p, int i, const ring r);
2124#endif // P_POLYS_H
2125
long int64
Definition auxiliary.h:68
int BOOLEAN
Definition auxiliary.h:87
#define TRUE
Definition auxiliary.h:100
#define FALSE
Definition auxiliary.h:96
CanonicalForm FACTORY_PUBLIC pp(const CanonicalForm &)
CanonicalForm pp ( const CanonicalForm & f )
Definition cf_gcd.cc:676
int l
Definition cfEzgcd.cc:100
int m
Definition cfEzgcd.cc:128
int i
Definition cfEzgcd.cc:132
int k
Definition cfEzgcd.cc:99
g
Definition cfModGcd.cc:4098
CanonicalForm b
Definition cfModGcd.cc:4111
FILE * f
Definition checklibs.c:9
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 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 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
const CanonicalForm int s
Definition facAbsFact.cc:51
CanonicalForm res
Definition facAbsFact.cc:60
const CanonicalForm & w
Definition facAbsFact.cc:51
int j
Definition facHensel.cc:110
int comp(const CanonicalForm &A, const CanonicalForm &B)
compare polynomials
#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 pSetCoeff0(p, n)
Definition monomials.h:59
#define p_GetCoeff(p, r)
Definition monomials.h:50
#define p_CheckRing1(r)
Definition monomials.h:178
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_SetRingOfLm(p, r)
Definition monomials.h:144
#define rRing_has_Comp(r)
Definition monomials.h:266
Definition lq.h:40
#define omTypeAlloc0Bin(type, addr, bin)
#define omTypeAllocBin(type, 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
poly p_Diff(poly a, int k, const ring r)
Definition p_polys.cc:1902
static int p_CmpPolys(poly p1, poly p2, ring r)
Definition p_polys.h:1739
poly p_DivideM(poly a, poly b, const ring r)
Definition p_polys.cc:1582
static void p_ExpVectorSum(poly pr, poly p1, poly p2, const ring r)
Definition p_polys.h:1425
poly pp_Jet(poly p, int m, const ring R)
Definition p_polys.cc:4379
void pSetDegProcs(ring r, pFDegProc new_FDeg, pLDegProc new_lDeg=NULL)
Definition p_polys.cc:3658
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:1292
static void p_ExpVectorAdd(poly p1, poly p2, const ring r)
Definition p_polys.h:1411
void pRestoreDegProcs(ring r, pFDegProc old_FDeg, pLDegProc old_lDeg)
Definition p_polys.cc:3670
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:1856
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:1958
static poly p_LmInit(poly p, const ring r)
Definition p_polys.h:1335
poly p_GcdMon(poly f, poly g, const ring r)
polynomial gcd for f=mon
Definition p_polys.cc:4979
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:4625
int p_LowVar(poly p, const ring r)
the minimal index of used variables - 1
Definition p_polys.cc:4729
static void p_ExpVectorCopy(poly d_p, poly s_p, const ring r)
Definition p_polys.h:1313
static int p_Cmp(poly p1, poly p2, ring r)
Definition p_polys.h:1727
static void p_SetExpVL(poly p, int64 *ev, const ring r)
Definition p_polys.h:1553
BOOLEAN p_HasNotCF(poly p1, poly p2, const ring r)
Definition p_polys.cc:1330
static void p_SetExpV(poly p, int *ev, const ring r)
Definition p_polys.h:1544
static int p_LtCmpNoAbs(poly p, poly q, const ring r)
Definition p_polys.h:1647
static void p_MemSub_NegWeightAdjust(poly p, const ring r)
Definition p_polys.h:1302
poly pp_DivideM(poly a, poly b, const ring r)
Definition p_polys.cc:1637
int p_Weight(int c, const ring r)
Definition p_polys.cc:706
static int p_LtCmpOrdSgnEqP(poly p, poly q, const ring r)
Definition p_polys.h:1703
poly p_DiffOp(poly a, poly b, BOOLEAN multiply, const ring r)
Definition p_polys.cc:1977
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:488
poly p_Jet(poly p, int m, const ring R)
Definition p_polys.cc:4435
static void p_ExpVectorDiff(poly pr, poly p1, poly p2, const ring r)
Definition p_polys.h:1474
const char * p_Read(const char *s, poly &p, const ring r)
Definition p_polys.cc:1371
void p_Shift(poly *p, int i, const ring r)
shifts components of the vector p by i
Definition p_polys.cc:4755
poly p_Div_nn(poly p, const number n, const ring r)
Definition p_polys.cc:1506
void p_DeleteComp(poly *p, int k, const ring r)
Definition p_polys.cc:3564
poly p_MDivide(poly a, poly b, const ring r)
Definition p_polys.cc:1493
void p_ContentRat(poly &ph, const ring r)
Definition p_polys.cc:1748
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition p_polys.h:247
poly p_Div_mm(poly p, const poly m, const ring r)
divide polynomial by monomial
Definition p_polys.cc:1542
poly pp_Jet0(poly p, const ring R)
Definition p_polys.cc:4407
static void p_ExpVectorSub(poly p1, poly p2, const ring r)
Definition p_polys.h:1440
int p_MaxExpPerVar(poly p, int i, const ring r)
max exponent of variable x_i in p
Definition p_polys.cc:5041
int p_Var(poly mi, const ring r)
Definition p_polys.cc:4705
int p_Compare(const poly a, const poly b, const ring R)
Definition p_polys.cc:4945
static void p_Setm(poly p, const ring r)
Definition p_polys.h:233
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_LmShallowCopyDelete(poly p, const ring r)
Definition p_polys.h:1393
static void p_GetExpVL(poly p, int64 *ev, const ring r)
Definition p_polys.h:1529
static int p_LtCmp(poly p, poly q, const ring r)
Definition p_polys.h:1621
static BOOLEAN p_LmIsConstantComp(const poly p, const ring r)
Definition p_polys.h:1006
static int p_LmCmp(poly p, poly q, const ring r)
Definition p_polys.h:1580
poly p_Series(int n, poly p, poly u, intvec *w, const ring R)
Definition p_polys.cc:4547
static BOOLEAN p_LmShortDivisibleBy(poly a, unsigned long sev_a, poly b, unsigned long not_sev_b, const ring r)
Definition p_polys.h:1910
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:469
static BOOLEAN p_LmIsConstant(const poly p, const ring r)
Definition p_polys.h:1023
static BOOLEAN p_LmDivisibleByNoComp(poly a, poly b, const ring r)
Definition p_polys.h:1877
static BOOLEAN p_IsOne(const poly p, const ring R)
either poly(1) or gen(k)?!
Definition p_polys.h:1971
static BOOLEAN p_IsConstant(const poly p, const ring r)
Definition p_polys.h:1964
static void p_SetExpVLV(poly p, int64 *ev, int64 comp, const ring r)
Definition p_polys.h:1564
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:1837
BOOLEAN p_CheckRing(ring r)
Definition pDebug.cc:131
static BOOLEAN _p_LmDivisibleBy(poly a, poly b, const ring r)
Definition p_polys.h:1871
static unsigned long p_GetTotalDegree(const unsigned long l, const ring r, const int number_of_exps)
Definition p_polys.h:810
static poly p_New(const ring, omBin bin)
Definition p_polys.h:664
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:4048
static poly p_GetExp_k_n(poly p, int l, int k, const ring r)
Definition p_polys.h:1372
static BOOLEAN p_LmShortDivisibleByNoComp(poly a, unsigned long sev_a, poly b, unsigned long not_sev_b, const ring r)
Definition p_polys.h:1930
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:3383
static BOOLEAN p_LmDivisibleBy(poly a, poly b, const ring r)
Definition p_polys.h:1891
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:1900
static BOOLEAN p_ExpVectorEqual(poly p1, poly p2, const ring r)
Definition p_polys.h:1489
void p_SetModDeg(intvec *w, ring r)
Definition p_polys.cc:3694
static int64 p_GetExpVLV(poly p, int64 *ev, const ring r)
Definition p_polys.h:1536
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:3516
BOOLEAN p_HasNotCFRing(poly p1, poly p2, const ring r)
Definition p_polys.cc:1346
static int p_LtCmpOrdSgnDiffM(poly p, poly q, const ring r)
Definition p_polys.h:1669
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:1765
void p_VectorHasUnit(poly p, int *k, int *len, const ring r)
Definition p_polys.cc:3406
static void p_GetExpV(poly p, int *ev, const ring r)
Definition p_polys.h:1520
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:4151
static int p_LtCmpOrdSgnEqM(poly p, poly q, const ring r)
Definition p_polys.h:1694
#define pDivAssume(x)
Definition p_polys.h:1282
static BOOLEAN p_IsUnit(const poly p, const ring r)
Definition p_polys.h:1991
static poly p_Init(const ring r, omBin bin)
Definition p_polys.h:1320
unsigned long p_GetShortExpVector(const poly a, const ring r)
Definition p_polys.cc:4829
poly pp_JetW(poly p, int m, int *w, const ring R)
Definition p_polys.cc:4452
static BOOLEAN p_LmDivisibleByPart(poly a, poly b, const ring r, const int start, const int end)
Definition p_polys.h:1862
static long p_Totaldegree(poly p, const ring r)
Definition p_polys.h:1507
static BOOLEAN p_LmExpVectorAddIsOk(const poly p1, const poly p2, const ring r)
Definition p_polys.h:1999
static int p_LtCmpOrdSgnDiffP(poly p, poly q, const ring r)
Definition p_polys.h:1678
void p_Lcm(const poly a, const poly b, poly m, const ring r)
Definition p_polys.cc:1659
#define p_Test(p, r)
Definition p_polys.h:161
poly p_JetW(poly p, int m, int *w, const ring R)
Definition p_polys.cc:4479
static BOOLEAN p_IsConstantPoly(const poly p, const ring r)
Definition p_polys.h:1978
static void p_ExpVectorAddSub(poly p1, poly p2, poly p3, const ring r)
Definition p_polys.h:1456
long(* pFDegProc)(poly p, ring r)
Definition ring.h:38
long(* pLDegProc)(poly p, int *length, ring r)
Definition ring.h:37
#define rField_is_Ring(R)
Definition ring.h:490
#define R
Definition sirandom.c:27

◆ p_LmCmpAction

#define p_LmCmpAction (   p,
  q,
  r,
  actionE,
  actionG,
  actionS 
)     _p_LmCmpAction(p, q, r, actionE, actionG, actionS)

Definition at line 1719 of file p_polys.h.

◆ p_LmEqual

#define p_LmEqual (   p1,
  p2,
 
)    p_ExpVectorEqual(p1, p2, r)

Definition at line 1723 of file p_polys.h.

◆ p_LmTest

#define p_LmTest (   p,
 
)    _p_LmTest(p, r, PDEBUG)

Definition at line 162 of file p_polys.h.

◆ p_SetmComp

#define p_SetmComp   p_Setm

Definition at line 244 of file p_polys.h.

◆ p_Test

#define p_Test (   p,
 
)    _p_Test(p, r, PDEBUG)

Definition at line 161 of file p_polys.h.

◆ pDivAssume

#define pDivAssume (   x)    do {} while (0)

Definition at line 1282 of file p_polys.h.

◆ pIfThen

#define pIfThen (   cond,
  check 
)    do {if (cond) {check;}} while (0)

Definition at line 155 of file p_polys.h.

◆ pp_Test

#define pp_Test (   p,
  lmRing,
  tailRing 
)    _pp_Test(p, lmRing, tailRing, PDEBUG)

Definition at line 163 of file p_polys.h.

Function Documentation

◆ _p_LmDivisibleBy()

static BOOLEAN _p_LmDivisibleBy ( poly  a,
poly  b,
const ring  r 
)
inlinestatic

Definition at line 1871 of file p_polys.h.

1872{
1873 if (p_GetComp(a, r) == 0 || p_GetComp(a,r) == p_GetComp(b,r))
1874 return _p_LmDivisibleByNoComp(a, b, r);
1875 return FALSE;
1876}

◆ _p_LmDivisibleByNoComp() [1/2]

static BOOLEAN _p_LmDivisibleByNoComp ( poly  a,
const ring  r_a,
poly  b,
const ring  r_b 
)
inlinestatic

Definition at line 1814 of file p_polys.h.

1815{
1816 int i=r_a->N;
1817 pAssume1(r_a->N == r_b->N);
1818
1819 do
1820 {
1821 if (p_GetExp(a,i,r_a) > p_GetExp(b,i,r_b))
1822 {
1823 return FALSE;
1824 }
1825 i--;
1826 }
1827 while (i);
1828/*#ifdef HAVE_RINGS
1829 return n_DivBy(p_GetCoeff(b, r_b), p_GetCoeff(a, r_a), r_a->cf);
1830#else
1831*/
1832 return TRUE;
1833//#endif
1834}

◆ _p_LmDivisibleByNoComp() [2/2]

static BOOLEAN _p_LmDivisibleByNoComp ( poly  a,
poly  b,
const ring  r 
)
inlinestatic

return: FALSE, if there exists i, such that a->exp[i] > b->exp[i] TRUE, otherwise (1) Consider long vars, instead of single exponents (2) Clearly, if la > lb, then FALSE (3) Suppose la <= lb, and consider first bits of single exponents in l: if TRUE, then value of these bits is la ^ lb if FALSE, then la-lb causes an "overflow" into one of those bits, i.e., la ^ lb != la - lb

Definition at line 1765 of file p_polys.h.

1766{
1767 int i=r->VarL_Size - 1;
1768 unsigned long divmask = r->divmask;
1769 unsigned long la, lb;
1770
1771 if (r->VarL_LowIndex >= 0)
1772 {
1773 i += r->VarL_LowIndex;
1774 do
1775 {
1776 la = a->exp[i];
1777 lb = b->exp[i];
1778 if ((la > lb) ||
1779 (((la & divmask) ^ (lb & divmask)) != ((lb - la) & divmask)))
1780 {
1782 return FALSE;
1783 }
1784 i--;
1785 }
1786 while (i>=r->VarL_LowIndex);
1787 }
1788 else
1789 {
1790 do
1791 {
1792 la = a->exp[r->VarL_Offset[i]];
1793 lb = b->exp[r->VarL_Offset[i]];
1794 if ((la > lb) ||
1795 (((la & divmask) ^ (lb & divmask)) != ((lb - la) & divmask)))
1796 {
1798 return FALSE;
1799 }
1800 i--;
1801 }
1802 while (i>=0);
1803 }
1804/*#ifdef HAVE_RINGS
1805 pDivAssume(p_DebugLmDivisibleByNoComp(a, b, r) == n_DivBy(p_GetCoeff(b, r), p_GetCoeff(a, r), r->cf));
1806 return (!rField_is_Ring(r)) || n_DivBy(p_GetCoeff(b, r), p_GetCoeff(a, r), r->cf);
1807#else
1808*/
1810 return TRUE;
1811//#endif
1812}

◆ _p_LmDivisibleByNoCompPart()

static BOOLEAN _p_LmDivisibleByNoCompPart ( poly  a,
const ring  r_a,
poly  b,
const ring  r_b,
const int  start,
const int  end 
)
inlinestatic

Definition at line 1837 of file p_polys.h.

1838{
1839 int i=end;
1840 pAssume1(r_a->N == r_b->N);
1841
1842 do
1843 {
1844 if (p_GetExp(a,i,r_a) > p_GetExp(b,i,r_b))
1845 return FALSE;
1846 i--;
1847 }
1848 while (i>=start);
1849/*#ifdef HAVE_RINGS
1850 return n_DivBy(p_GetCoeff(b, r_b), p_GetCoeff(a, r_a), r_a->cf);
1851#else
1852*/
1853 return TRUE;
1854//#endif
1855}

◆ _p_LmDivisibleByPart()

static BOOLEAN _p_LmDivisibleByPart ( poly  a,
const ring  r_a,
poly  b,
const ring  r_b,
const int  start,
const int  end 
)
inlinestatic

Definition at line 1856 of file p_polys.h.

1857{
1858 if (p_GetComp(a, r_a) == 0 || p_GetComp(a,r_a) == p_GetComp(b,r_b))
1859 return _p_LmDivisibleByNoCompPart(a, r_a, b, r_b,start,end);
1860 return FALSE;
1861}

◆ _p_LmTest()

BOOLEAN _p_LmTest ( poly  p,
ring  r,
int  level 
)

Definition at line 322 of file pDebug.cc.

323{
324 if (level < 0 || p == NULL) return TRUE;
325 poly pnext = pNext(p);
326 pNext(p) = NULL;
328 pNext(p) = pnext;
329 return test_res;
330}
int level(const CanonicalForm &f)
BOOLEAN _p_Test(poly p, ring r, int level)
Definition pDebug.cc:211

◆ _p_Mult_q()

poly _p_Mult_q ( poly  p,
poly  q,
const int  copy,
const ring  r 
)
extern

Returns: p * q, Destroys: if !copy then p, q Assumes: pLength(p) >= 2 pLength(q) >=2, !rIsPluralRing(r)

Definition at line 313 of file p_Mult_q.cc.

314{
315 assume(r != NULL);
316#ifdef HAVE_RINGS
317 if (!nCoeff_is_Domain(r->cf))
318 return _p_Mult_q_Normal_ZeroDiv(p, q, copy, r);
319#endif
320 int lp, lq, l;
321 poly pt;
322
323 // MIN_LENGTH_FACTORY must be >= MIN_LENGTH_FACTORY_QQ, MIN_FLINT_QQ, MIN_FLINT_Zp 20
325
326 if (lp < lq)
327 {
328 pt = p;
329 p = q;
330 q = pt;
331 l = lp;
332 lp = lq;
333 lq = l;
334 }
335 BOOLEAN pure_polys=(p_GetComp(p,r)==0) && (p_GetComp(q,r)==0);
336 #ifdef HAVE_FLINT
337 #if __FLINT_RELEASE >= 20503
338 if (lq>MIN_FLINT_QQ)
339 {
341 if (pure_polys && rField_is_Q(r) && !convSingRFlintR(ctx,r))
342 {
343 // lq is a lower bound for the length of p and q
344 poly res=Flint_Mult_MP(p,lq,q,lq,ctx,r);
345 if (!copy)
346 {
347 p_Delete(&p,r);
348 p_Delete(&q,r);
349 }
350 return res;
351 }
352 }
353 if (lq>MIN_FLINT_Zp)
354 {
357 {
358 // lq is a lower bound for the length of p and q
359 poly res=Flint_Mult_MP(p,lq,q,lq,ctx,r);
360 if (!copy)
361 {
362 p_Delete(&p,r);
363 p_Delete(&q,r);
364 }
365 return res;
366 }
367 }
368 if (lq>MIN_FLINT_Z)
369 {
371 if (pure_polys && rField_is_Z(r) && !convSingRFlintR(ctx,r))
372 {
373 // lq is a lower bound for the length of p and q
374 poly res=Flint_Mult_MP(p,lq,q,lq,ctx,r);
375 if (!copy)
376 {
377 p_Delete(&p,r);
378 p_Delete(&q,r);
379 }
380 return res;
381 }
382 }
383 #endif
384 #endif
386 return _p_Mult_q_Normal(p, q, copy, r);
387 else if (pure_polys
388 && ((r->cf->extRing==NULL)||(r->cf->extRing->qideal!=NULL))
389 /* exclude trans. extensions: may contain rat.funct as cf */
390 && (((lq >= MIN_LENGTH_FACTORY)
391 && (r->cf->convSingNFactoryN!=ndConvSingNFactoryN))
393 && rField_is_Q(r))))
394 {
395 poly h=singclap_pmult(p,q,r);
396 if (!copy)
397 {
398 p_Delete(&p,r);
399 p_Delete(&q,r);
400 }
401 return h;
402 }
403 else
404 {
405 lp=pLength(p);
406 lq=pLength(q);
407 return _p_Mult_q_Bucket(p, lp, q, lq, copy, r);
408 }
409}
poly singclap_pmult(poly f, poly g, const ring r)
Definition clapsing.cc:577
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
CFArray copy(const CFList &list)
write elements of list into an array
STATIC_VAR Poly * h
Definition janet.cc:971
#define assume(x)
Definition mod2.h:387
CanonicalForm ndConvSingNFactoryN(number, BOOLEAN, const coeffs)
Definition numbers.cc:307
#define TEST_OPT_NOT_BUCKETS
Definition options.h:105
static void pqLengthApprox(poly p, poly q, int &lp, int &lq, const int min)
Definition p_Mult_q.cc:69
#define MIN_LENGTH_FACTORY
Definition p_Mult_q.cc:304
#define MIN_FLINT_Z
Definition p_Mult_q.cc:308
#define MIN_FLINT_QQ
Definition p_Mult_q.cc:306
static poly _p_Mult_q_Normal(poly p, poly q, const int copy, const ring r)
Definition p_Mult_q.cc:223
#define MIN_LENGTH_FACTORY_QQ
Definition p_Mult_q.cc:305
static poly _p_Mult_q_Bucket(poly p, const int lp, poly q, const int lq, const int copy, const ring r)
Definition p_Mult_q.cc:100
static poly _p_Mult_q_Normal_ZeroDiv(poly p, poly q, const int copy, const ring r)
Definition p_Mult_q.cc:195
#define MIN_FLINT_Zp
Definition p_Mult_q.cc:307
#define MIN_LENGTH_BUCKET
Definition p_Mult_q.h:21
static int pLength(poly a)
Definition p_polys.h:190
static void p_Delete(poly *p, const ring r)
Definition p_polys.h:901
static BOOLEAN rField_is_Z(const ring r)
Definition ring.h:514
static BOOLEAN rField_is_Zp(const ring r)
Definition ring.h:505
static BOOLEAN rField_is_Q(const ring r)
Definition ring.h:511

◆ _p_Test()

BOOLEAN _p_Test ( poly  p,
ring  r,
int  level 
)

Definition at line 211 of file pDebug.cc.

212{
213 assume(r->cf !=NULL);
214
215 if (PDEBUG > level) level = PDEBUG;
216 if (level < 0 || p == NULL) return TRUE;
217
218 poly p_prev = NULL;
219
220 #ifndef OM_NDEBUG
221 #ifndef X_OMALLOC
222 // check addr with level+1 so as to check bin/page of addr
224 == omError_NoError, "memory error",p,r);
225 #endif
226 #endif
227
229
230 // this checks that p does not contain a loop: rather expensive O(length^2)
231 #ifndef OM_NDEBUG
232 if (level > 1)
234 #endif
235
236 int ismod = p_GetComp(p, r) != 0;
237
238 while (p != NULL)
239 {
240 // ring check
242 #ifndef OM_NDEBUG
243 #ifndef X_OMALLOC
244 // omAddr check
246 == omError_NoError, "memory error",p,r);
247 #endif
248 #endif
249 // number/coef check
250 _pPolyAssumeReturnMsg(p->coef != NULL || (n_GetChar(r->cf) >= 2), "NULL coef",p,r);
251
252 #ifdef LDEBUG
253 _pPolyAssumeReturnMsg(n_Test(p->coef,r->cf),"coeff err",p,r);
254 #endif
255 _pPolyAssumeReturnMsg(!n_IsZero(p->coef, r->cf), "Zero coef",p,r);
256
257 // check for valid comp
258 _pPolyAssumeReturnMsg(p_GetComp(p, r) >= 0 && (p_GetComp(p, r)<65000), "component out of range ?",p,r);
259 // check for mix poly/vec representation
260 _pPolyAssumeReturnMsg(ismod == (p_GetComp(p, r) != 0), "mixed poly/vector",p,r);
261
262 // special check for ringorder_s/S
263 if ((r->typ!=NULL) && (r->typ[0].ord_typ == ro_syzcomp))
264 {
265 long c1, cc1, ccc1, ec1;
266 sro_ord* o = &(r->typ[0]);
267
268 c1 = p_GetComp(p, r);
269 if (o->data.syzcomp.Components!=NULL)
270 {
271 cc1 = o->data.syzcomp.Components[c1];
272 ccc1 = o->data.syzcomp.ShiftedComponents[cc1];
273 }
274 else { cc1=0; ccc1=0; }
275 _pPolyAssumeReturnMsg(c1 == 0 || cc1 != 0, "Component <-> TrueComponent zero mismatch",p,r);
276 _pPolyAssumeReturnMsg(c1 == 0 || ccc1 != 0,"Component <-> ShiftedComponent zero mismatch",p,r);
277 ec1 = p->exp[o->data.syzcomp.place];
278 //pPolyAssumeReturnMsg(ec1 == ccc1, "Shifted comp out of sync. should %d, is %d");
279 if (ec1 != ccc1)
280 {
281 dPolyReportError(p,r,"Shifted comp out of sync. should %d, is %d",ccc1,ec1);
282 return FALSE;
283 }
284 }
285
286 // check that p_Setm works ok
287 if (level > 0)
288 {
289 poly p_should_equal = p_DebugInit(p, r, r);
290 _pPolyAssumeReturnMsg(p_ExpVectorEqual(p, p_should_equal, r), "p_Setm field(s) out of sync",p,r);
292 }
293
294 // check order
295 if (p_prev != NULL)
296 {
297 int cmp = p_LmCmp(p_prev, p, r);
298 if (cmp == 0)
299 {
300 _pPolyAssumeReturnMsg(0, "monoms p and p->next are equal", p_prev, r);
301 }
302 else
303 _pPolyAssumeReturnMsg(p_LmCmp(p_prev, p, r) == 1, "wrong order", p_prev, r);
304
305 // check that compare worked sensibly
306 if (level > 1 && p_GetComp(p_prev, r) == p_GetComp(p, r))
307 {
308 int i;
309 for (i=r->N; i>0; i--)
310 {
311 if (p_GetExp(p_prev, i, r) != p_GetExp(p, i, r)) break;
312 }
313 _pPolyAssumeReturnMsg(i > 0, "Exponents equal but compare different", p_prev, r);
314 }
315 }
316 p_prev = p;
317 pIter(p);
318 }
319 return TRUE;
320}
#define PDEBUG
Definition auxiliary.h:170
#define n_Test(a, r)
BOOLEAN n_Test(number a, const coeffs r)
Definition coeffs.h:713
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 int n_GetChar(const coeffs r)
Return the characteristic of the coeff. domain.
Definition coeffs.h:448
#define pFalseReturn(cond)
Definition monomials.h:139
#define _pPolyAssumeReturnMsg(cond, msg, p, r)
Definition monomials.h:124
@ omError_NoError
Definition omError.h:18
#define omTestList(ptr, level)
Definition omList.h:81
static poly p_DebugInit(poly p, ring src_ring, ring dest_ring)
Definition pDebug.cc:194
BOOLEAN dPolyReportError(poly p, ring r, const char *fmt,...)
Definition pDebug.cc:43
BOOLEAN p_CheckRing(ring r)
Definition pDebug.cc:131
BOOLEAN p_LmCheckIsFromRing(poly p, ring r)
Definition pDebug.cc:74
static BOOLEAN p_ExpVectorEqual(poly p1, poly p2, const ring r1, const ring r2)
Definition p_polys.cc:4575
static void p_LmFree(poly p, ring)
Definition p_polys.h:683
@ ro_syzcomp
Definition ring.h:59
union sro_ord::@1 data
#define omTestBinAddrSize(A, B, C)
Definition xalloc.h:272

◆ _pp_Test()

BOOLEAN _pp_Test ( poly  p,
ring  lmRing,
ring  tailRing,
int  level 
)

Definition at line 332 of file pDebug.cc.

333{
334 if (PDEBUG > level) level = PDEBUG;
335 if (level < 0 || p == NULL) return TRUE;
336 if (pNext(p) == NULL || lmRing == tailRing) return _p_Test(p, lmRing, level);
337
339 pFalseReturn(_p_Test(pNext(p), tailRing, level));
340
341 // check that lm > Lm(tail)
342 if (level > 1)
343 {
344 poly lm = p;
345 poly tail = p_DebugInit(pNext(p), tailRing, lmRing);
346 poly pnext = pNext(lm);
347 pNext(lm) = tail;
348 BOOLEAN cmp = p_LmCmp(lm, tail, lmRing);
349 if (cmp != 1)
350 dPolyReportError(lm, lmRing, "wrong order: lm <= Lm(tail)");
351 p_LmFree(tail, lmRing);
352 pNext(lm) = pnext;
353 return (cmp == 1);
354 }
355 return TRUE;
356}
BOOLEAN _p_LmTest(poly p, ring r, int level)
Definition pDebug.cc:322

◆ n_PermNumber()

poly n_PermNumber ( const number  z,
const int par_perm,
const int  OldPar,
const ring  src,
const ring  dst 
)

Definition at line 4048 of file p_polys.cc.

4049{
4050#if 0
4051 PrintS("\nSource Ring: \n");
4052 rWrite(src);
4053
4054 if(0)
4055 {
4056 number zz = n_Copy(z, src->cf);
4057 PrintS("z: "); n_Write(zz, src);
4058 n_Delete(&zz, src->cf);
4059 }
4060
4061 PrintS("\nDestination Ring: \n");
4062 rWrite(dst);
4063
4064 /*Print("\nOldPar: %d\n", OldPar);
4065 for( int i = 1; i <= OldPar; i++ )
4066 {
4067 Print("par(%d) -> par/var (%d)\n", i, par_perm[i-1]);
4068 }*/
4069#endif
4070 if( z == NULL )
4071 return NULL;
4072
4073 const coeffs srcCf = src->cf;
4074 assume( srcCf != NULL );
4075
4077 assume( src->cf->extRing!=NULL );
4078
4079 poly zz = NULL;
4080
4081 const ring srcExtRing = srcCf->extRing;
4082 assume( srcExtRing != NULL );
4083
4084 const coeffs dstCf = dst->cf;
4085 assume( dstCf != NULL );
4086
4087 if( nCoeff_is_algExt(srcCf) ) // nCoeff_is_GF(srcCf)?
4088 {
4089 zz = (poly) z;
4090 if( zz == NULL ) return NULL;
4091 }
4092 else if (nCoeff_is_transExt(srcCf))
4093 {
4094 assume( !IS0(z) );
4095
4096 zz = NUM((fraction)z);
4097 p_Test (zz, srcExtRing);
4098
4099 if( zz == NULL ) return NULL;
4100 if( !DENIS1((fraction)z) )
4101 {
4103 WarnS("Not defined: Cannot map a rational fraction and make a polynomial out of it! Ignoring the denominator.");
4104 }
4105 }
4106 else
4107 {
4108 assume (FALSE);
4109 WerrorS("Number permutation is not implemented for this data yet!");
4110 return NULL;
4111 }
4112
4113 assume( zz != NULL );
4114 p_Test (zz, srcExtRing);
4115
4117
4118 assume( nMap != NULL );
4119
4120 poly qq;
4121 if ((par_perm == NULL) && (rPar(dst) != 0 && rVar (srcExtRing) > 0))
4122 {
4123 int* perm;
4124 perm=(int *)omAlloc0((rVar(srcExtRing)+1)*sizeof(int));
4125 for(int i=si_min(rVar(srcExtRing),rPar(dst));i>0;i--)
4126 perm[i]=-i;
4128 omFreeSize ((ADDRESS)perm, (rVar(srcExtRing)+1)*sizeof(int));
4129 }
4130 else
4132
4134 && (!DENIS1((fraction)z))
4136 {
4138 qq=p_Div_nn(qq,n,dst);
4139 n_Delete(&n,dstCf);
4141 }
4142 p_Test (qq, dst);
4143
4144 return qq;
4145}
static int si_min(const int a, const int b)
Definition auxiliary.h:125
static FORCE_INLINE BOOLEAN nCoeff_is_GF(const coeffs r)
Definition coeffs.h:832
static FORCE_INLINE nMapFunc n_SetMap(const coeffs src, const coeffs dst)
set the mapping function pointers for translating numbers from src to dst
Definition coeffs.h:701
static FORCE_INLINE void n_Write(number n, const coeffs r, const BOOLEAN bShortOut=TRUE)
Definition coeffs.h:592
static FORCE_INLINE BOOLEAN nCoeff_is_algExt(const coeffs r)
TRUE iff r represents an algebraic extension field.
Definition coeffs.h:903
static FORCE_INLINE BOOLEAN nCoeff_is_transExt(const coeffs r)
TRUE iff r represents a transcendental extension field.
Definition coeffs.h:911
#define WarnS
Definition emacs.cc:78
void WerrorS(const char *s)
Definition feFopen.cc:24
The main handler for Singular numbers which are suitable for Singular polynomials.
#define omFreeSize(addr, size)
#define omAlloc0(size)
poly p_PermPoly(poly p, const int *perm, const ring oldRing, const ring dst, nMapFunc nMap, const int *par_perm, int OldPar, BOOLEAN use_mult)
Definition p_polys.cc:4151
poly p_Div_nn(poly p, const number n, const ring r)
Definition p_polys.cc:1506
void p_Normalize(poly p, const ring r)
Definition p_polys.cc:3834
#define NUM
Definition readcf.cc:180
void PrintS(const char *s)
Definition reporter.cc:284
void rWrite(ring r, BOOLEAN details)
Definition ring.cc:227
static int rPar(const ring r)
(r->cf->P)
Definition ring.h:604
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition ring.h:597

◆ p_Add_q() [1/2]

static poly p_Add_q ( poly  p,
poly  q,
const ring  r 
)
inlinestatic

Definition at line 936 of file p_polys.h.

937{
938 assume( (p != q) || (p == NULL && q == NULL) );
939 if (q==NULL) return p;
940 if (p==NULL) return q;
941 int shorter;
942 return r->p_Procs->p_Add_q(p, q, shorter, r);
943}

◆ p_Add_q() [2/2]

static poly p_Add_q ( poly  p,
poly  q,
int lp,
int  lq,
const ring  r 
)
inlinestatic

like p_Add_q, except that if lp == pLength(lp) lq == pLength(lq) then lp == pLength(p+q)

Definition at line 946 of file p_polys.h.

947{
948 assume( (p != q) || (p == NULL && q == NULL) );
949 if (q==NULL) return p;
950 if (p==NULL) { lp=lq; return q; }
951 int shorter;
952 poly res = r->p_Procs->p_Add_q(p, q, shorter, r);
953 lp += lq - shorter;
954 return res;
955}

◆ p_AddComp()

static unsigned long p_AddComp ( poly  p,
unsigned long  v,
ring  r 
)
inlinestatic

Definition at line 447 of file p_polys.h.

448{
451 return __p_GetComp(p,r) += v;
452}
const Variable & v
< [in] a sqrfree bivariate poly
Definition facBivar.h:39
#define p_LmCheckPolyRing2(p, r)
Definition monomials.h:199
#define pAssume2(cond)
Definition monomials.h:193
#define __p_GetComp(p, r)
Definition monomials.h:63

◆ p_AddExp()

static long p_AddExp ( poly  p,
int  v,
long  ee,
ring  r 
)
inlinestatic

Definition at line 606 of file p_polys.h.

607{
609 int e = p_GetExp(p,v,r);
610 e += ee;
611 return p_SetExp(p,v,e,r);
612}

◆ p_CheckIsFromRing()

BOOLEAN p_CheckIsFromRing ( poly  p,
ring  r 
)

Definition at line 105 of file pDebug.cc.

106{
107 while (p!=NULL)
108 {
110 pIter(p);
111 }
112 return TRUE;
113}

◆ p_CheckPolyRing()

BOOLEAN p_CheckPolyRing ( poly  p,
ring  r 
)

Definition at line 115 of file pDebug.cc.

116{
117 #ifndef X_OMALLOC
118 pAssumeReturn(r != NULL && r->PolyBin != NULL);
119 #endif
120 return p_CheckIsFromRing(p, r);
121}
#define pAssumeReturn(cond)
Definition monomials.h:78
BOOLEAN p_CheckIsFromRing(poly p, ring r)
Definition pDebug.cc:105

◆ p_CheckRing()

BOOLEAN p_CheckRing ( ring  r)

Definition at line 131 of file pDebug.cc.

132{
133 #ifndef X_OMALLOC
134 pAssumeReturn(r != NULL && r->PolyBin != NULL);
135 #endif
136 return TRUE;
137}

◆ p_ChineseRemainder()

poly p_ChineseRemainder ( poly *  xx,
number x,
number q,
int  rl,
CFArray inv_cache,
const ring  R 
)

Definition at line 88 of file p_polys.cc.

89{
90 poly r,h,hh;
91 int j;
92 poly res_p=NULL;
93 loop
94 {
95 /* search the lead term */
96 r=NULL;
97 for(j=rl-1;j>=0;j--)
98 {
99 h=xx[j];
100 if ((h!=NULL)
101 &&((r==NULL)||(p_LmCmp(r,h,R)==-1)))
102 r=h;
103 }
104 /* nothing found -> return */
105 if (r==NULL) break;
106 /* create the monomial in h */
107 h=p_Head(r,R);
108 /* collect the coeffs in x[..]*/
109 for(j=rl-1;j>=0;j--)
110 {
111 hh=xx[j];
112 if ((hh!=NULL) && (p_LmCmp(h,hh,R)==0))
113 {
114 x[j]=pGetCoeff(hh);
116 xx[j]=hh;
117 }
118 else
119 x[j]=n_Init(0, R->cf);
120 }
122 for(j=rl-1;j>=0;j--)
123 {
124 x[j]=NULL; // n_Init(0...) takes no memory
125 }
126 if (n_IsZero(n,R->cf)) p_Delete(&h,R);
127 else
128 {
129 //Print("new mon:");pWrite(h);
130 p_SetCoeff(h,n,R);
131 pNext(h)=res_p;
132 res_p=h; // building res_p in reverse order!
133 }
134 }
136 p_Test(res_p, R);
137 return res_p;
138}
Variable x
Definition cfModGcd.cc:4090
static FORCE_INLINE number n_ChineseRemainderSym(number *a, number *b, int rl, BOOLEAN sym, CFArray &inv_cache, const coeffs r)
Definition coeffs.h:757
static number p_SetCoeff(poly p, number n, ring r)
Definition p_polys.h:412
static poly pReverse(poly p)
Definition p_polys.h:335
static poly p_Head(const poly p, const ring r)
copy the (leading) term of p
Definition p_polys.h:860
static poly p_LmFreeAndNext(poly p, ring)
Definition p_polys.h:711
#define loop
Definition structs.h:75

◆ p_Cleardenom()

poly p_Cleardenom ( poly  p,
const ring  r 
)

Definition at line 2849 of file p_polys.cc.

2850{
2851 if( p == NULL )
2852 return NULL;
2853
2854 assume( r != NULL );
2855 assume( r->cf != NULL );
2856 const coeffs C = r->cf;
2857
2858#if CLEARENUMERATORS
2859 if( 0 )
2860 {
2863 n_ClearContent(itr, C); // divide out the content
2864 p_Test(p, r); n_Test(pGetCoeff(p), C);
2865 assume(n_GreaterZero(pGetCoeff(p), C)); // ??
2866// if(!n_GreaterZero(pGetCoeff(p),C)) p = p_Neg(p,r);
2867 return p;
2868 }
2869#endif
2870
2871 number d, h;
2872
2873 if (rField_is_Ring(r))
2874 {
2875 if(!n_GreaterZero(pGetCoeff(p),C)) p = p_Neg(p,r);
2876 return p;
2877 }
2878
2880 {
2881 if(!n_GreaterZero(pGetCoeff(p),C)) p = p_Neg(p,r);
2882 return p;
2883 }
2884
2885 assume(p != NULL);
2886
2887 if(pNext(p)==NULL)
2888 {
2889 if (!TEST_OPT_CONTENTSB)
2890 p_SetCoeff(p,n_Init(1,C),r);
2891 else if(!n_GreaterZero(pGetCoeff(p),C))
2892 p = p_Neg(p,r);
2893 return p;
2894 }
2895
2896 assume(pNext(p)!=NULL);
2897 poly start=p;
2898
2899#if 0 && CLEARENUMERATORS
2900//CF: does not seem to work that well..
2901
2902 if( nCoeff_is_Q(C) || nCoeff_is_Q_a(C) )
2903 {
2906 n_ClearContent(itr, C); // divide out the content
2907 p_Test(p, r); n_Test(pGetCoeff(p), C);
2908 assume(n_GreaterZero(pGetCoeff(p), C)); // ??
2909// if(!n_GreaterZero(pGetCoeff(p),C)) p = p_Neg(p,r);
2910 return start;
2911 }
2912#endif
2913
2914 if(1)
2915 {
2916 // get lcm of all denominators ----------------------------------
2917 h = n_Init(1,C);
2918 while (p!=NULL)
2919 {
2922 n_Delete(&h,C);
2923 h=d;
2924 pIter(p);
2925 }
2926 /* h now contains the 1/lcm of all denominators */
2927 if(!n_IsOne(h,C))
2928 {
2929 // multiply by the lcm of all denominators
2930 p = start;
2931 while (p!=NULL)
2932 {
2933 d=n_Mult(h,pGetCoeff(p),C);
2934 n_Normalize(d,C);
2935 p_SetCoeff(p,d,r);
2936 pIter(p);
2937 }
2938 }
2939 n_Delete(&h,C);
2940 p=start;
2941
2942 p_ContentForGB(p,r);
2943#ifdef HAVE_RATGRING
2944 if (rIsRatGRing(r))
2945 {
2946 /* quick unit detection in the rational case is done in gr_nc_bba */
2947 p_ContentRat(p, r);
2948 start=p;
2949 }
2950#endif
2951 }
2952
2953 if(!n_GreaterZero(pGetCoeff(p),C)) p = p_Neg(p,r);
2954
2955 return start;
2956}
This is a polynomial enumerator for simple iteration over coefficients of polynomials.
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of 'a' and 'b', i.e., a*b
Definition coeffs.h:637
static FORCE_INLINE number n_NormalizeHelper(number a, number b, const coeffs r)
assume that r is a quotient field (otherwise, return 1) for arguments (a1/a2,b1/b2) return (lcm(a1,...
Definition coeffs.h:696
static FORCE_INLINE BOOLEAN nCoeff_is_Q(const coeffs r)
Definition coeffs.h:799
static FORCE_INLINE void n_ClearDenominators(ICoeffsEnumerator &numberCollectionEnumerator, number &d, const coeffs r)
(inplace) Clears denominators on a collection of numbers number d is the LCM of all the coefficient d...
Definition coeffs.h:928
static FORCE_INLINE BOOLEAN nCoeff_is_Q_a(const coeffs r)
Definition coeffs.h:878
static FORCE_INLINE void n_ClearContent(ICoeffsEnumerator &numberCollectionEnumerator, number &c, const coeffs r)
Computes the content and (inplace) divides it out on a collection of numbers number c is the content ...
Definition coeffs.h:921
static FORCE_INLINE void n_Normalize(number &n, const coeffs r)
inplace-normalization of n; produces some canonical representation of n;
Definition coeffs.h:579
#define TEST_OPT_INTSTRATEGY
Definition options.h:110
#define TEST_OPT_CONTENTSB
Definition options.h:127
void p_ContentRat(poly &ph, const ring r)
Definition p_polys.cc:1748
void p_ContentForGB(poly ph, const ring r)
Definition p_polys.cc:2359
static poly p_Neg(poly p, const ring r)
Definition p_polys.h:1107
static BOOLEAN rIsRatGRing(const ring r)
Definition ring.h:432

◆ p_Cleardenom_n()

void p_Cleardenom_n ( poly  p,
const ring  r,
number c 
)

Definition at line 2958 of file p_polys.cc.

2959{
2960 const coeffs C = r->cf;
2961 number d, h;
2962
2963 assume( ph != NULL );
2964
2965 poly p = ph;
2966
2967#if CLEARENUMERATORS
2968 if( 0 )
2969 {
2971
2972 n_ClearDenominators(itr, d, C); // multiply with common denom. d
2973 n_ClearContent(itr, h, C); // divide by the content h
2974
2975 c = n_Div(d, h, C); // d/h
2976
2977 n_Delete(&d, C);
2978 n_Delete(&h, C);
2979
2980 n_Test(c, C);
2981
2982 p_Test(ph, r); n_Test(pGetCoeff(ph), C);
2983 assume(n_GreaterZero(pGetCoeff(ph), C)); // ??
2984/*
2985 if(!n_GreaterZero(pGetCoeff(ph),C))
2986 {
2987 ph = p_Neg(ph,r);
2988 c = n_InpNeg(c, C);
2989 }
2990*/
2991 return;
2992 }
2993#endif
2994
2995
2996 if( pNext(p) == NULL )
2997 {
2999 {
3000 c=n_Invers(pGetCoeff(p), C);
3001 p_SetCoeff(p, n_Init(1, C), r);
3002 }
3003 else
3004 {
3005 c=n_Init(1,C);
3006 }
3007
3008 if(!n_GreaterZero(pGetCoeff(ph),C))
3009 {
3010 ph = p_Neg(ph,r);
3011 c = n_InpNeg(c, C);
3012 }
3013
3014 return;
3015 }
3016 if (TEST_OPT_CONTENTSB) { c=n_Init(1,C); return; }
3017
3018 assume( pNext(p) != NULL );
3019
3020#if CLEARENUMERATORS
3021 if( nCoeff_is_Q(C) || nCoeff_is_Q_a(C) )
3022 {
3024
3025 n_ClearDenominators(itr, d, C); // multiply with common denom. d
3026 n_ClearContent(itr, h, C); // divide by the content h
3027
3028 c = n_Div(d, h, C); // d/h
3029
3030 n_Delete(&d, C);
3031 n_Delete(&h, C);
3032
3033 n_Test(c, C);
3034
3035 p_Test(ph, r); n_Test(pGetCoeff(ph), C);
3036 assume(n_GreaterZero(pGetCoeff(ph), C)); // ??
3037/*
3038 if(!n_GreaterZero(pGetCoeff(ph),C))
3039 {
3040 ph = p_Neg(ph,r);
3041 c = n_InpNeg(c, C);
3042 }
3043*/
3044 return;
3045 }
3046#endif
3047
3048
3049
3050
3051 if(1)
3052 {
3053 h = n_Init(1,C);
3054 while (p!=NULL)
3055 {
3058 n_Delete(&h,C);
3059 h=d;
3060 pIter(p);
3061 }
3062 c=h;
3063 /* contains the 1/lcm of all denominators */
3064 if(!n_IsOne(h,C))
3065 {
3066 p = ph;
3067 while (p!=NULL)
3068 {
3069 /* should be: // NOTE: don't use ->coef!!!!
3070 * number hh;
3071 * nGetDenom(p->coef,&hh);
3072 * nMult(&h,&hh,&d);
3073 * nNormalize(d);
3074 * nDelete(&hh);
3075 * nMult(d,p->coef,&hh);
3076 * nDelete(&d);
3077 * nDelete(&(p->coef));
3078 * p->coef =hh;
3079 */
3080 d=n_Mult(h,pGetCoeff(p),C);
3081 n_Normalize(d,C);
3082 p_SetCoeff(p,d,r);
3083 pIter(p);
3084 }
3085 if (rField_is_Q_a(r))
3086 {
3087 loop
3088 {
3089 h = n_Init(1,C);
3090 p=ph;
3091 while (p!=NULL)
3092 {
3094 n_Delete(&h,C);
3095 h=d;
3096 pIter(p);
3097 }
3098 /* contains the 1/lcm of all denominators */
3099 if(!n_IsOne(h,C))
3100 {
3101 p = ph;
3102 while (p!=NULL)
3103 {
3104 /* should be: // NOTE: don't use ->coef!!!!
3105 * number hh;
3106 * nGetDenom(p->coef,&hh);
3107 * nMult(&h,&hh,&d);
3108 * nNormalize(d);
3109 * nDelete(&hh);
3110 * nMult(d,p->coef,&hh);
3111 * nDelete(&d);
3112 * nDelete(&(p->coef));
3113 * p->coef =hh;
3114 */
3115 d=n_Mult(h,pGetCoeff(p),C);
3116 n_Normalize(d,C);
3117 p_SetCoeff(p,d,r);
3118 pIter(p);
3119 }
3120 number t=n_Mult(c,h,C);
3121 n_Delete(&c,C);
3122 c=t;
3123 }
3124 else
3125 {
3126 break;
3127 }
3128 n_Delete(&h,C);
3129 }
3130 }
3131 }
3132 }
3133
3134 if(!n_GreaterZero(pGetCoeff(ph),C))
3135 {
3136 ph = p_Neg(ph,r);
3137 c = n_InpNeg(c, C);
3138 }
3139
3140}
static FORCE_INLINE number n_Invers(number a, const coeffs r)
return the multiplicative inverse of 'a'; raise an error if 'a' is not invertible
Definition coeffs.h:565
static FORCE_INLINE number n_Div(number a, number b, const coeffs r)
return the quotient of 'a' and 'b', i.e., a/b; raises an error if 'b' is not invertible in r exceptio...
Definition coeffs.h:616
static BOOLEAN rField_is_Q_a(const ring r)
Definition ring.h:544

◆ p_Cmp()

static int p_Cmp ( poly  p1,
poly  p2,
ring  r 
)
inlinestatic

Definition at line 1727 of file p_polys.h.

1728{
1729 if (p2==NULL)
1730 {
1731 if (p1==NULL) return 0;
1732 return 1;
1733 }
1734 if (p1==NULL)
1735 return -1;
1736 return p_LmCmp(p1,p2,r);
1737}

◆ p_CmpPolys()

static int p_CmpPolys ( poly  p1,
poly  p2,
ring  r 
)
inlinestatic

Definition at line 1739 of file p_polys.h.

1740{
1741 if (p2==NULL)
1742 {
1743 if (p1==NULL) return 0;
1744 return 1;
1745 }
1746 if (p1==NULL)
1747 return -1;
1748 return p_ComparePolys(p1,p2,r);
1749}

◆ p_Comp_k_n()

static int p_Comp_k_n ( poly  a,
poly  b,
int  k,
ring  r 
)
inlinestatic

Definition at line 640 of file p_polys.h.

641{
642 if ((a==NULL) || (b==NULL) ) return FALSE;
643 p_LmCheckPolyRing2(a, r);
645 pAssume2(k > 0 && k <= r->N);
646 int i=k;
647 for(;i<=r->N;i++)
648 {
649 if (p_GetExp(a,i,r) != p_GetExp(b,i,r)) return FALSE;
650 // if (a->exp[(r->VarOffset[i] & 0xffffff)] != b->exp[(r->VarOffset[i] & 0xffffff)]) return FALSE;
651 }
652 return TRUE;
653}
const CanonicalForm CFMap CFMap & N
Definition cfEzgcd.cc:56

◆ p_Compare()

int p_Compare ( const poly  a,
const poly  b,
const ring  R 
)

Definition at line 4945 of file p_polys.cc.

4946{
4947 int r=p_Cmp(a,b,R);
4948 if ((r==0)&&(a!=NULL))
4949 {
4950 number h=n_Sub(pGetCoeff(a),pGetCoeff(b),R->cf);
4951 /* compare lead coeffs */
4952 r = -1+n_IsZero(h,R->cf)+2*n_GreaterZero(h,R->cf); /* -1: <, 0:==, 1: > */
4953 n_Delete(&h,R->cf);
4954 }
4955 else if (a==NULL)
4956 {
4957 if (b==NULL)
4958 {
4959 /* compare 0, 0 */
4960 r=0;
4961 }
4962 else if(p_IsConstant(b,R))
4963 {
4964 /* compare 0, const */
4965 r = 1-2*n_GreaterZero(pGetCoeff(b),R->cf); /* -1: <, 1: > */
4966 }
4967 }
4968 else if (b==NULL)
4969 {
4970 if (p_IsConstant(a,R))
4971 {
4972 /* compare const, 0 */
4973 r = -1+2*n_GreaterZero(pGetCoeff(a),R->cf); /* -1: <, 1: > */
4974 }
4975 }
4976 return(r);
4977}
static FORCE_INLINE number n_Sub(number a, number b, const coeffs r)
return the difference of 'a' and 'b', i.e., a-b
Definition coeffs.h:656

◆ p_ComparePolys()

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 at line 4625 of file p_polys.cc.

4626{
4627 number n,nn;
4628 pAssume(p1 != NULL && p2 != NULL);
4629
4630 if (!p_LmEqual(p1,p2,r)) //compare leading mons
4631 return FALSE;
4632 if ((pNext(p1)==NULL) && (pNext(p2)!=NULL))
4633 return FALSE;
4634 if ((pNext(p2)==NULL) && (pNext(p1)!=NULL))
4635 return FALSE;
4636 if (pLength(p1) != pLength(p2))
4637 return FALSE;
4638 #ifdef HAVE_RINGS
4639 if (rField_is_Ring(r))
4640 {
4641 if (!n_DivBy(pGetCoeff(p1), pGetCoeff(p2), r->cf)) return FALSE;
4642 }
4643 #endif
4644 n=n_Div(pGetCoeff(p1),pGetCoeff(p2),r->cf);
4645 while ((p1 != NULL) /*&& (p2 != NULL)*/)
4646 {
4647 if ( ! p_LmEqual(p1, p2,r))
4648 {
4649 n_Delete(&n, r->cf);
4650 return FALSE;
4651 }
4652 if (!n_Equal(pGetCoeff(p1), nn = n_Mult(pGetCoeff(p2),n, r->cf), r->cf))
4653 {
4654 n_Delete(&n, r->cf);
4655 n_Delete(&nn, r->cf);
4656 return FALSE;
4657 }
4658 n_Delete(&nn, r->cf);
4659 pIter(p1);
4660 pIter(p2);
4661 }
4662 n_Delete(&n, r->cf);
4663 return TRUE;
4664}
static FORCE_INLINE BOOLEAN n_DivBy(number a, number b, const coeffs r)
test whether 'a' is divisible 'b'; for r encoding a field: TRUE iff 'b' does not represent zero in Z:...
Definition coeffs.h:748
#define pAssume(cond)
Definition monomials.h:90
#define p_LmEqual(p1, p2, r)
Definition p_polys.h:1723

◆ p_Content()

void p_Content ( poly  p,
const ring  r 
)

Definition at line 2299 of file p_polys.cc.

2300{
2301 if (ph==NULL) return;
2302 const coeffs cf=r->cf;
2303 if (pNext(ph)==NULL)
2304 {
2305 p_SetCoeff(ph,n_Init(1,cf),r);
2306 return;
2307 }
2308 if ((cf->cfSubringGcd==ndGcd)
2309 || (cf->cfGcd==ndGcd)) /* trivial gcd*/
2310 return;
2311 number h;
2312 if ((rField_is_Q(r))
2313 || (rField_is_Q_a(r))
2314 || (rField_is_Zp_a)(r)
2315 || (rField_is_Z(r))
2316 )
2317 {
2318 h=p_InitContent(ph,r); /* first guess of a gcd of all coeffs */
2319 }
2320 else
2321 {
2323 }
2324 poly p;
2325 if(n_IsOne(h,cf))
2326 {
2327 goto content_finish;
2328 }
2329 p=ph;
2330 // take the SubringGcd of all coeffs
2331 while (p!=NULL)
2332 {
2335 n_Delete(&h,cf);
2336 h = d;
2337 if(n_IsOne(h,cf))
2338 {
2339 goto content_finish;
2340 }
2341 pIter(p);
2342 }
2343 // if found<>1, divide by it
2344 p = ph;
2345 while (p!=NULL)
2346 {
2348 p_SetCoeff(p,d,r);
2349 pIter(p);
2350 }
2352 n_Delete(&h,r->cf);
2353 // and last: check leading sign:
2354 if(!n_GreaterZero(pGetCoeff(ph),r->cf)) ph = p_Neg(ph,r);
2355}
CanonicalForm cf
Definition cfModGcd.cc:4091
static FORCE_INLINE number n_ExactDiv(number a, number b, const coeffs r)
assume that there is a canonical subring in cf and we know that division is possible for these a and ...
Definition coeffs.h:623
static FORCE_INLINE number n_SubringGcd(number a, number b, const coeffs r)
Definition coeffs.h:667
number ndGcd(number, number, const coeffs r)
Definition numbers.cc:187
number p_InitContent(poly ph, const ring r)
Definition p_polys.cc:2639
static BOOLEAN rField_is_Zp_a(const ring r)
Definition ring.h:534

◆ p_ContentForGB()

void p_ContentForGB ( poly  p,
const ring  r 
)

Definition at line 2359 of file p_polys.cc.

2360{
2361 if(TEST_OPT_CONTENTSB) return;
2362 assume( ph != NULL );
2363
2364 assume( r != NULL ); assume( r->cf != NULL );
2365
2366
2367#if CLEARENUMERATORS
2368 if( 0 )
2369 {
2370 const coeffs C = r->cf;
2371 // experimentall (recursive enumerator treatment) of alg. Ext!
2373 n_ClearContent(itr, r->cf);
2374
2375 p_Test(ph, r); n_Test(pGetCoeff(ph), C);
2376 assume(n_GreaterZero(pGetCoeff(ph), C)); // ??
2377
2378 // if(!n_GreaterZero(pGetCoeff(ph),r->cf)) ph = p_Neg(ph,r);
2379 return;
2380 }
2381#endif
2382
2383
2384#ifdef HAVE_RINGS
2385 if (rField_is_Ring(r))
2386 {
2387 if (rField_has_Units(r))
2388 {
2389 number k = n_GetUnit(pGetCoeff(ph),r->cf);
2390 if (!n_IsOne(k,r->cf))
2391 {
2392 number tmpGMP = k;
2393 k = n_Invers(k,r->cf);
2394 n_Delete(&tmpGMP,r->cf);
2395 poly h = pNext(ph);
2396 p_SetCoeff(ph, n_Mult(pGetCoeff(ph), k,r->cf),r);
2397 while (h != NULL)
2398 {
2399 p_SetCoeff(h, n_Mult(pGetCoeff(h), k,r->cf),r);
2400 pIter(h);
2401 }
2402// assume( n_GreaterZero(pGetCoeff(ph),r->cf) );
2403// if(!n_GreaterZero(pGetCoeff(ph),r->cf)) ph = p_Neg(ph,r);
2404 }
2405 n_Delete(&k,r->cf);
2406 }
2407 return;
2408 }
2409#endif
2410 number h,d;
2411 poly p;
2412
2413 if(pNext(ph)==NULL)
2414 {
2415 p_SetCoeff(ph,n_Init(1,r->cf),r);
2416 }
2417 else
2418 {
2419 assume( pNext(ph) != NULL );
2420#if CLEARENUMERATORS
2421 if( nCoeff_is_Q(r->cf) )
2422 {
2423 // experimentall (recursive enumerator treatment) of alg. Ext!
2425 n_ClearContent(itr, r->cf);
2426
2427 p_Test(ph, r); n_Test(pGetCoeff(ph), r->cf);
2428 assume(n_GreaterZero(pGetCoeff(ph), r->cf)); // ??
2429
2430 // if(!n_GreaterZero(pGetCoeff(ph),r->cf)) ph = p_Neg(ph,r);
2431 return;
2432 }
2433#endif
2434
2435 n_Normalize(pGetCoeff(ph),r->cf);
2436 if(!n_GreaterZero(pGetCoeff(ph),r->cf)) ph = p_Neg(ph,r);
2437 if (rField_is_Q(r)||(getCoeffType(r->cf)==n_transExt)) // should not be used anymore if CLEARENUMERATORS is 1
2438 {
2439 h=p_InitContent(ph,r);
2440 p=ph;
2441 }
2442 else
2443 {
2444 h=n_Copy(pGetCoeff(ph),r->cf);
2445 p = pNext(ph);
2446 }
2447 while (p!=NULL)
2448 {
2449 n_Normalize(pGetCoeff(p),r->cf);
2450 d=n_SubringGcd(h,pGetCoeff(p),r->cf);
2451 n_Delete(&h,r->cf);
2452 h = d;
2453 if(n_IsOne(h,r->cf))
2454 {
2455 break;
2456 }
2457 pIter(p);
2458 }
2459 //number tmp;
2460 if(!n_IsOne(h,r->cf))
2461 {
2462 p = ph;
2463 while (p!=NULL)
2464 {
2465 //d = nDiv(pGetCoeff(p),h);
2466 //tmp = nExactDiv(pGetCoeff(p),h);
2467 //if (!nEqual(d,tmp))
2468 //{
2469 // StringSetS("** div0:");nWrite(pGetCoeff(p));StringAppendS("/");
2470 // nWrite(h);StringAppendS("=");nWrite(d);StringAppendS(" int:");
2471 // nWrite(tmp);Print(StringEndS("\n")); // NOTE/TODO: use StringAppendS("\n"); omFree(s);
2472 //}
2473 //nDelete(&tmp);
2474 d = n_ExactDiv(pGetCoeff(p),h,r->cf);
2475 p_SetCoeff(p,d,r);
2476 pIter(p);
2477 }
2478 }
2479 n_Delete(&h,r->cf);
2480 if (rField_is_Q_a(r))
2481 {
2482 // special handling for alg. ext.:
2483 if (getCoeffType(r->cf)==n_algExt)
2484 {
2485 h = n_Init(1, r->cf->extRing->cf);
2486 p=ph;
2487 while (p!=NULL)
2488 { // each monom: coeff in Q_a
2489 poly c_n_n=(poly)pGetCoeff(p);
2490 poly c_n=c_n_n;
2491 while (c_n!=NULL)
2492 { // each monom: coeff in Q
2493 d=n_NormalizeHelper(h,pGetCoeff(c_n),r->cf->extRing->cf);
2494 n_Delete(&h,r->cf->extRing->cf);
2495 h=d;
2496 pIter(c_n);
2497 }
2498 pIter(p);
2499 }
2500 /* h contains the 1/lcm of all denominators in c_n_n*/
2501 //n_Normalize(h,r->cf->extRing->cf);
2502 if(!n_IsOne(h,r->cf->extRing->cf))
2503 {
2504 p=ph;
2505 while (p!=NULL)
2506 { // each monom: coeff in Q_a
2507 poly c_n=(poly)pGetCoeff(p);
2508 while (c_n!=NULL)
2509 { // each monom: coeff in Q
2510 d=n_Mult(h,pGetCoeff(c_n),r->cf->extRing->cf);
2511 n_Normalize(d,r->cf->extRing->cf);
2512 n_Delete(&pGetCoeff(c_n),r->cf->extRing->cf);
2513 pGetCoeff(c_n)=d;
2514 pIter(c_n);
2515 }
2516 pIter(p);
2517 }
2518 }
2519 n_Delete(&h,r->cf->extRing->cf);
2520 }
2521 /*else
2522 {
2523 // special handling for rat. functions.:
2524 number hzz =NULL;
2525 p=ph;
2526 while (p!=NULL)
2527 { // each monom: coeff in Q_a (Z_a)
2528 fraction f=(fraction)pGetCoeff(p);
2529 poly c_n=NUM(f);
2530 if (hzz==NULL)
2531 {
2532 hzz=n_Copy(pGetCoeff(c_n),r->cf->extRing->cf);
2533 pIter(c_n);
2534 }
2535 while ((c_n!=NULL)&&(!n_IsOne(hzz,r->cf->extRing->cf)))
2536 { // each monom: coeff in Q (Z)
2537 d=n_Gcd(hzz,pGetCoeff(c_n),r->cf->extRing->cf);
2538 n_Delete(&hzz,r->cf->extRing->cf);
2539 hzz=d;
2540 pIter(c_n);
2541 }
2542 pIter(p);
2543 }
2544 // hzz contains the gcd of all numerators in f
2545 h=n_Invers(hzz,r->cf->extRing->cf);
2546 n_Delete(&hzz,r->cf->extRing->cf);
2547 n_Normalize(h,r->cf->extRing->cf);
2548 if(!n_IsOne(h,r->cf->extRing->cf))
2549 {
2550 p=ph;
2551 while (p!=NULL)
2552 { // each monom: coeff in Q_a (Z_a)
2553 fraction f=(fraction)pGetCoeff(p);
2554 NUM(f)=__p_Mult_nn(NUM(f),h,r->cf->extRing);
2555 p_Normalize(NUM(f),r->cf->extRing);
2556 pIter(p);
2557 }
2558 }
2559 n_Delete(&h,r->cf->extRing->cf);
2560 }*/
2561 }
2562 }
2563 if(!n_GreaterZero(pGetCoeff(ph),r->cf)) ph = p_Neg(ph,r);
2564}
@ n_algExt
used for all algebraic extensions, i.e., the top-most extension in an extension tower is algebraic
Definition coeffs.h:35
@ n_transExt
used for all transcendental extensions, i.e., the top-most extension in an extension tower is transce...
Definition coeffs.h:38
static FORCE_INLINE number n_GetUnit(number n, const coeffs r)
in Z: 1 in Z/kZ (where k is not a prime): largest divisor of n (taken in Z) that is co-prime with k i...
Definition coeffs.h:535
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition coeffs.h:429
static BOOLEAN rField_has_Units(const ring r)
Definition ring.h:495

◆ p_ContentRat()

void p_ContentRat ( poly &  ph,
const ring  r 
)

Definition at line 1748 of file p_polys.cc.

1751{
1752 // init array of RatLeadCoeffs
1753 // poly p_GetCoeffRat(poly p, int ishift, ring r);
1754
1755 int len=pLength(ph);
1756 poly *C = (poly *)omAlloc0((len+1)*sizeof(poly)); //rat coeffs
1757 poly *LM = (poly *)omAlloc0((len+1)*sizeof(poly)); // rat lead terms
1758 int *D = (int *)omAlloc0((len+1)*sizeof(int)); //degrees of coeffs
1759 int *L = (int *)omAlloc0((len+1)*sizeof(int)); //lengths of coeffs
1760 int k = 0;
1761 poly p = p_Copy(ph, r); // ph will be needed below
1762 int mintdeg = p_Totaldegree(p, r);
1763 int minlen = len;
1764 int dd = 0; int i;
1765 int HasConstantCoef = 0;
1766 int is = r->real_var_start - 1;
1767 while (p!=NULL)
1768 {
1769 LM[k] = p_GetExp_k_n(p,1,is, r); // need LmRat istead of p_HeadRat(p, is, currRing); !
1770 C[k] = p_GetCoeffRat(p, is, r);
1771 D[k] = p_Totaldegree(C[k], r);
1772 mintdeg = si_min(mintdeg,D[k]);
1773 L[k] = pLength(C[k]);
1774 minlen = si_min(minlen,L[k]);
1775 if (p_IsConstant(C[k], r))
1776 {
1777 // C[k] = const, so the content will be numerical
1778 HasConstantCoef = 1;
1779 // smth like goto cleanup and return(pContent(p));
1780 }
1781 p_LmDeleteAndNextRat(&p, is, r);
1782 k++;
1783 }
1784
1785 // look for 1 element of minimal degree and of minimal length
1786 k--;
1787 poly d;
1788 int mindeglen = len;
1789 if (k<=0) // this poly is not a ratgring poly -> pContent
1790 {
1791 p_Delete(&C[0], r);
1792 p_Delete(&LM[0], r);
1793 p_ContentForGB(ph, r);
1794 goto cleanup;
1795 }
1796
1797 int pmindeglen;
1798 for(i=0; i<=k; i++)
1799 {
1800 if (D[i] == mintdeg)
1801 {
1802 if (L[i] < mindeglen)
1803 {
1804 mindeglen=L[i];
1805 pmindeglen = i;
1806 }
1807 }
1808 }
1809 d = p_Copy(C[pmindeglen], r);
1810 // there are dd>=1 mindeg elements
1811 // and pmideglen is the coordinate of one of the smallest among them
1812
1813 // poly g = singclap_gcd(p_Copy(p,r),p_Copy(q,r));
1814 // return naGcd(d,d2,currRing);
1815
1816 // adjoin pContentRat here?
1817 for(i=0; i<=k; i++)
1818 {
1819 d=singclap_gcd(d,p_Copy(C[i], r), r);
1820 if (p_Totaldegree(d, r)==0)
1821 {
1822 // cleanup, pContent, return
1823 p_Delete(&d, r);
1824 for(;k>=0;k--)
1825 {
1826 p_Delete(&C[k], r);
1827 p_Delete(&LM[k], r);
1828 }
1829 p_ContentForGB(ph, r);
1830 goto cleanup;
1831 }
1832 }
1833 for(i=0; i<=k; i++)
1834 {
1835 poly h=singclap_pdivide(C[i],d, r);
1836 p_Delete(&C[i], r);
1837 C[i]=h;
1838 }
1839
1840 // zusammensetzen,
1841 p=NULL; // just to be sure
1842 for(i=0; i<=k; i++)
1843 {
1844 p = p_Add_q(p, p_Mult_q(C[i],LM[i], r), r);
1845 C[i]=NULL; LM[i]=NULL;
1846 }
1847 p_Delete(&ph, r); // do not need it anymore
1848 ph = p;
1849 // aufraeumen, return
1850cleanup:
1851 omFree(C);
1852 omFree(LM);
1853 omFree(D);
1854 omFree(L);
1855}
poly singclap_pdivide(poly f, poly g, const ring r)
Definition clapsing.cc:624
#define D(A)
Definition gentable.cc:126
#define omFree(addr)
void p_LmDeleteAndNextRat(poly *p, int ishift, ring r)
Definition p_polys.cc:1704
poly p_GetCoeffRat(poly p, int ishift, ring r)
Definition p_polys.cc:1726
static poly p_Add_q(poly p, poly q, const ring r)
Definition p_polys.h:936
static poly p_Mult_q(poly p, poly q, const ring r)
Definition p_polys.h:1114
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition p_polys.h:846
poly singclap_gcd(poly f, poly g, const ring r)
polynomial gcd via singclap_gcd_r resp. idSyzygies destroys f and g
Definition polys.cc:380

◆ p_Copy() [1/2]

static poly p_Copy ( poly  p,
const ring  lmRing,
const ring  tailRing 
)
inlinestatic

returns a copy of p with Lm(p) from lmRing and Tail(p) from tailRing

Definition at line 883 of file p_polys.h.

884{
885 if (p != NULL)
886 {
887#ifndef PDEBUG
888 if (tailRing == lmRing)
889 return p_Copy_noCheck(p, tailRing);
890#endif
891 poly pres = p_Head(p, lmRing);
892 if (pNext(p)!=NULL)
893 pNext(pres) = p_Copy_noCheck(pNext(p), tailRing);
894 return pres;
895 }
896 else
897 return NULL;
898}
static poly p_Copy_noCheck(poly p, const ring r)
returns a copy of p (without any additional testing)
Definition p_polys.h:836

◆ p_Copy() [2/2]

static poly p_Copy ( poly  p,
const ring  r 
)
inlinestatic

returns a copy of p

Definition at line 846 of file p_polys.h.

847{
848 if (p!=NULL)
849 {
850 p_Test(p,r);
851 const poly pp = p_Copy_noCheck(p, r);
852 p_Test(pp,r);
853 return pp;
854 }
855 else
856 return NULL;
857}

◆ p_Copy_noCheck()

static poly p_Copy_noCheck ( poly  p,
const ring  r 
)
inlinestatic

returns a copy of p (without any additional testing)

Definition at line 836 of file p_polys.h.

837{
838 /*assume(p!=NULL);*/
839 assume(r != NULL);
840 assume(r->p_Procs != NULL);
841 assume(r->p_Procs->p_Copy != NULL);
842 return r->p_Procs->p_Copy(p, r);
843}

◆ p_CopyPowerProduct()

poly p_CopyPowerProduct ( const poly  p,
const ring  r 
)

like p_Head, but with coefficient 1

Definition at line 5029 of file p_polys.cc.

5030{
5031 if (p == NULL) return NULL;
5032 return p_CopyPowerProduct0(p,n_Init(1,r->cf),r);
5033}
poly p_CopyPowerProduct0(const poly p, number n, const ring r)
like p_Head, but with coefficient n
Definition p_polys.cc:5017

◆ p_CopyPowerProduct0()

poly p_CopyPowerProduct0 ( const poly  p,
const number  n,
const ring  r 
)

like p_Head, but with coefficient n

Definition at line 5017 of file p_polys.cc.

5018{
5020 poly np;
5021 omTypeAllocBin(poly, np, r->PolyBin);
5022 p_SetRingOfLm(np, r);
5023 memcpy(np->exp, p->exp, r->ExpL_Size*sizeof(long));
5024 pNext(np) = NULL;
5025 pSetCoeff0(np, n);
5026 return np;
5027}

◆ p_DecrExp()

static long p_DecrExp ( poly  p,
int  v,
ring  r 
)
inlinestatic

Definition at line 598 of file p_polys.h.

599{
601 int e = p_GetExp(p,v,r);
602 pAssume2(e > 0);
603 e--;
604 return p_SetExp(p,v,e,r);
605}

◆ p_Deg()

long p_Deg ( poly  a,
const ring  r 
)

Definition at line 586 of file p_polys.cc.

587{
588 p_LmCheckPolyRing(a, r);
589// assume(p_GetOrder(a, r) == p_WTotaldegree(a, r)); // WRONG assume!
590 return p_GetOrder(a, r);
591}
static long p_GetOrder(poly p, ring r)
Definition p_polys.h:421

◆ p_DegW()

long p_DegW ( poly  p,
const int w,
const ring  R 
)

Definition at line 691 of file p_polys.cc.

692{
693 p_Test(p, R);
694 assume( w != NULL );
695 long r=-LONG_MAX;
696
697 while (p!=NULL)
698 {
699 long t=totaldegreeWecart_IV(p,R,w);
700 if (t>r) r=t;
701 pIter(p);
702 }
703 return r;
704}
long totaldegreeWecart_IV(poly p, ring r, const int *w)
Definition weight.cc:231

◆ p_Delete() [1/2]

static void p_Delete ( poly *  p,
const ring  lmRing,
const ring  tailRing 
)
inlinestatic

Definition at line 908 of file p_polys.h.

909{
910 assume( p!= NULL );
911 if (*p != NULL)
912 {
913#ifndef PDEBUG
914 if (tailRing == lmRing)
915 {
916 p_Delete(p, tailRing);
917 return;
918 }
919#endif
920 if (pNext(*p) != NULL)
921 p_Delete(&pNext(*p), tailRing);
923 }
924}
static void p_LmDelete(poly p, const ring r)
Definition p_polys.h:723

◆ p_Delete() [2/2]

static void p_Delete ( poly *  p,
const ring  r 
)
inlinestatic

Definition at line 901 of file p_polys.h.

902{
903 assume( p!= NULL );
904 assume( r!= NULL );
905 if ((*p)!=NULL) r->p_Procs->p_Delete(p, r);
906}

◆ p_DeleteComp()

void p_DeleteComp ( poly *  p,
int  k,
const ring  r 
)

Definition at line 3564 of file p_polys.cc.

3565{
3566 poly q;
3567 long unsigned kk=k;
3568
3569 while ((*p!=NULL) && (__p_GetComp(*p,r)==kk)) p_LmDelete(p,r);
3570 if (*p==NULL) return;
3571 q = *p;
3572 if (__p_GetComp(q,r)>kk)
3573 {
3574 p_SubComp(q,1,r);
3575 p_SetmComp(q,r);
3576 }
3577 while (pNext(q)!=NULL)
3578 {
3579 unsigned long c=__p_GetComp(pNext(q),r);
3580 if (/*__p_GetComp(pNext(q),r)*/c==kk)
3581 p_LmDelete(&(pNext(q)),r);
3582 else
3583 {
3584 pIter(q);
3585 if (/*__p_GetComp(q,r)*/c>kk)
3586 {
3587 p_SubComp(q,1,r);
3588 p_SetmComp(q,r);
3589 }
3590 }
3591 }
3592}
static unsigned long p_SubComp(poly p, unsigned long v, ring r)
Definition p_polys.h:453
#define p_SetmComp
Definition p_polys.h:244

◆ p_Diff()

poly p_Diff ( poly  a,
int  k,
const ring  r 
)

Definition at line 1902 of file p_polys.cc.

1903{
1904 poly res, f, last;
1905 number t;
1906
1907 last = res = NULL;
1908 while (a!=NULL)
1909 {
1910 if (p_GetExp(a,k,r)!=0)
1911 {
1912 f = p_LmInit(a,r);
1913 t = n_Init(p_GetExp(a,k,r),r->cf);
1914 pSetCoeff0(f,n_Mult(t,pGetCoeff(a),r->cf));
1915 n_Delete(&t,r->cf);
1916 if (n_IsZero(pGetCoeff(f),r->cf))
1917 p_LmDelete(&f,r);
1918 else
1919 {
1920 p_DecrExp(f,k,r);
1921 p_Setm(f,r);
1922 if (res==NULL)
1923 {
1924 res=last=f;
1925 }
1926 else
1927 {
1928 pNext(last)=f;
1929 last=f;
1930 }
1931 }
1932 }
1933 pIter(a);
1934 }
1935 return res;
1936}
STATIC_VAR poly last
Definition hdegree.cc:1144
static long p_DecrExp(poly p, int v, ring r)
Definition p_polys.h:598

◆ p_DiffOp()

poly p_DiffOp ( poly  a,
poly  b,
BOOLEAN  multiply,
const ring  r 
)

Definition at line 1977 of file p_polys.cc.

1978{
1979 poly result=NULL;
1980 poly h;
1981 for(;a!=NULL;pIter(a))
1982 {
1983 for(h=b;h!=NULL;pIter(h))
1984 {
1985 result=p_Add_q(result,p_DiffOpM(a,h,multiply,r),r);
1986 }
1987 }
1988 return result;
1989}
return result
static poly p_DiffOpM(poly a, poly b, BOOLEAN multiply, const ring r)
Definition p_polys.cc:1938

◆ p_Div_mm()

poly p_Div_mm ( poly  p,
const poly  m,
const ring  r 
)

divide polynomial by monomial

Definition at line 1542 of file p_polys.cc.

1543{
1544 p_Test(p, r);
1545 p_Test(m, r);
1546 poly result = p;
1547 poly prev = NULL;
1548 number n=pGetCoeff(m);
1549 while (p!=NULL)
1550 {
1551 number nc = n_Div(pGetCoeff(p),n,r->cf);
1552 n_Normalize(nc,r->cf);
1553 if (!n_IsZero(nc,r->cf))
1554 {
1555 p_SetCoeff(p,nc,r);
1556 prev=p;
1557 p_ExpVectorSub(p,m,r);
1558 pIter(p);
1559 }
1560 else
1561 {
1562 if (prev==NULL)
1563 {
1564 p_LmDelete(&result,r);
1565 p=result;
1566 }
1567 else
1568 {
1569 p_LmDelete(&pNext(prev),r);
1570 p=pNext(prev);
1571 }
1572 }
1573 }
1574 p_Test(result,r);
1575 return(result);
1576}

◆ p_Div_nn()

poly p_Div_nn ( poly  p,
const number  n,
const ring  r 
)

Definition at line 1506 of file p_polys.cc.

1507{
1508 pAssume(!n_IsZero(n,r->cf));
1509 p_Test(p, r);
1510 poly result = p;
1511 poly prev = NULL;
1512 if (!n_IsOne(n,r->cf))
1513 {
1514 while (p!=NULL)
1515 {
1516 number nc = n_Div(pGetCoeff(p),n,r->cf);
1517 if (!n_IsZero(nc,r->cf))
1518 {
1519 p_SetCoeff(p,nc,r);
1520 prev=p;
1521 pIter(p);
1522 }
1523 else
1524 {
1525 if (prev==NULL)
1526 {
1527 p_LmDelete(&result,r);
1528 p=result;
1529 }
1530 else
1531 {
1532 p_LmDelete(&pNext(prev),r);
1533 p=pNext(prev);
1534 }
1535 }
1536 }
1537 p_Test(result,r);
1538 }
1539 return(result);
1540}

◆ p_DivideM()

poly p_DivideM ( poly  a,
poly  b,
const ring  r 
)

Definition at line 1582 of file p_polys.cc.

1583{
1584 if (a==NULL) { p_Delete(&b,r); return NULL; }
1585 poly result=a;
1586
1587 if(!p_IsConstant(b,r))
1588 {
1589 if (rIsNCRing(r))
1590 {
1591 WerrorS("p_DivideM not implemented for non-commuative rings");
1592 return NULL;
1593 }
1594 poly prev=NULL;
1595 while (a!=NULL)
1596 {
1597 if (p_DivisibleBy(b,a,r))
1598 {
1599 p_ExpVectorSub(a,b,r);
1600 prev=a;
1601 pIter(a);
1602 }
1603 else
1604 {
1605 if (prev==NULL)
1606 {
1607 p_LmDelete(&result,r);
1608 a=result;
1609 }
1610 else
1611 {
1612 p_LmDelete(&pNext(prev),r);
1613 a=pNext(prev);
1614 }
1615 }
1616 }
1617 }
1618 if (result!=NULL)
1619 {
1621 //if ((!rField_is_Ring(r)) || n_IsUnit(inv,r->cf))
1622 if (rField_is_Zp(r))
1623 {
1624 inv = n_Invers(inv,r->cf);
1626 n_Delete(&inv, r->cf);
1627 }
1628 else
1629 {
1631 }
1632 }
1633 p_Delete(&b, r);
1634 return result;
1635}
#define __p_Mult_nn(p, n, r)
Definition p_polys.h:971
static BOOLEAN rIsNCRing(const ring r)
Definition ring.h:426

◆ p_DivisibleBy()

static BOOLEAN p_DivisibleBy ( poly  a,
poly  b,
const ring  r 
)
inlinestatic

Definition at line 1900 of file p_polys.h.

1901{
1903 pIfThen1(a!=NULL, p_LmCheckPolyRing1(a, r));
1904
1905 if (a != NULL && (p_GetComp(a, r) == 0 || p_GetComp(a,r) == p_GetComp(b,r)))
1906 return _p_LmDivisibleByNoComp(a,b,r);
1907 return FALSE;
1908}

◆ p_DivisibleByRingCase()

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), i.e., LT(f)*c*m = LT(g), for some coefficient c and some monomial m; does not take components into account

Definition at line 1646 of file p_polys.cc.

1647{
1648 int exponent;
1649 for(int i = (int)rVar(r); i>0; i--)
1650 {
1651 exponent = p_GetExp(g, i, r) - p_GetExp(f, i, r);
1652 if (exponent < 0) return FALSE;
1653 }
1654 return n_DivBy(pGetCoeff(g), pGetCoeff(f), r->cf);
1655}
#define exponent

◆ p_EqualPolys() [1/2]

BOOLEAN p_EqualPolys ( poly  p1,
poly  p2,
const ring  r 
)

Definition at line 4561 of file p_polys.cc.

4562{
4563 while ((p1 != NULL) && (p2 != NULL))
4564 {
4565 if (! p_LmEqual(p1, p2,r))
4566 return FALSE;
4567 if (! n_Equal(p_GetCoeff(p1,r), p_GetCoeff(p2,r),r->cf ))
4568 return FALSE;
4569 pIter(p1);
4570 pIter(p2);
4571 }
4572 return (p1==p2);
4573}

◆ p_EqualPolys() [2/2]

BOOLEAN p_EqualPolys ( poly  p1,
poly  p2,
const ring  r1,
const ring  r2 
)

same as the usual p_EqualPolys for polys belonging to equal rings

Definition at line 4599 of file p_polys.cc.

4600{
4601 assume( r1 == r2 || rSamePolyRep(r1, r2) ); // will be used in rEqual!
4602 assume( r1->cf == r2->cf );
4603
4604 while ((p1 != NULL) && (p2 != NULL))
4605 {
4606 // returns 1 if ExpVector(p)==ExpVector(q): does not compare numbers !!
4607 // #define p_LmEqual(p1, p2, r) p_ExpVectorEqual(p1, p2, r)
4608
4609 if (! p_ExpVectorEqual(p1, p2, r1, r2))
4610 return FALSE;
4611
4612 if (! n_Equal(p_GetCoeff(p1,r1), p_GetCoeff(p2,r2), r1->cf ))
4613 return FALSE;
4614
4615 pIter(p1);
4616 pIter(p2);
4617 }
4618 return (p1==p2);
4619}
BOOLEAN rSamePolyRep(ring r1, ring r2)
returns TRUE, if r1 and r2 represents the monomials in the same way FALSE, otherwise this is an analo...
Definition ring.cc:1801

◆ p_ExpVectorAdd()

static void p_ExpVectorAdd ( poly  p1,
poly  p2,
const ring  r 
)
inlinestatic

Definition at line 1411 of file p_polys.h.

1412{
1413 p_LmCheckPolyRing1(p1, r);
1414 p_LmCheckPolyRing1(p2, r);
1415#if PDEBUG >= 1
1416 for (int i=1; i<=r->N; i++)
1417 pAssume1((unsigned long) (p_GetExp(p1, i, r) + p_GetExp(p2, i, r)) <= r->bitmask);
1418 pAssume1(p_GetComp(p1, r) == 0 || p_GetComp(p2, r) == 0);
1419#endif
1420
1421 p_MemAdd_LengthGeneral(p1->exp, p2->exp, r->ExpL_Size);
1423}

◆ p_ExpVectorAddSub()

static void p_ExpVectorAddSub ( poly  p1,
poly  p2,
poly  p3,
const ring  r 
)
inlinestatic

Definition at line 1456 of file p_polys.h.

1457{
1458 p_LmCheckPolyRing1(p1, r);
1459 p_LmCheckPolyRing1(p2, r);
1461#if PDEBUG >= 1
1462 for (int i=1; i<=r->N; i++)
1463 pAssume1(p_GetExp(p1, i, r) + p_GetExp(p2, i, r) >= p_GetExp(p3, i, r));
1464 pAssume1(p_GetComp(p1, r) == 0 ||
1465 (p_GetComp(p2, r) - p_GetComp(p3, r) == 0) ||
1466 (p_GetComp(p1, r) == p_GetComp(p2, r) - p_GetComp(p3, r)));
1467#endif
1468
1469 p_MemAddSub_LengthGeneral(p1->exp, p2->exp, p3->exp, r->ExpL_Size);
1470 // no need to adjust in case of NegWeights
1471}

◆ p_ExpVectorCopy()

static void p_ExpVectorCopy ( poly  d_p,
poly  s_p,
const ring  r 
)
inlinestatic

Definition at line 1313 of file p_polys.h.

1314{
1317 memcpy(d_p->exp, s_p->exp, r->ExpL_Size*sizeof(long));
1318}

◆ p_ExpVectorDiff()

static void p_ExpVectorDiff ( poly  pr,
poly  p1,
poly  p2,
const ring  r 
)
inlinestatic

Definition at line 1474 of file p_polys.h.

1475{
1476 p_LmCheckPolyRing1(p1, r);
1477 p_LmCheckPolyRing1(p2, r);
1479#if PDEBUG >= 2
1480 for (int i=1; i<=r->N; i++)
1481 pAssume1(p_GetExp(p1, i, r) >= p_GetExp(p2, i, r));
1482 pAssume1(!rRing_has_Comp(r) || p_GetComp(p1, r) == p_GetComp(p2, r));
1483#endif
1484
1485 p_MemDiff_LengthGeneral(pr->exp, p1->exp, p2->exp, r->ExpL_Size);
1487}

◆ p_ExpVectorEqual()

static BOOLEAN p_ExpVectorEqual ( poly  p1,
poly  p2,
const ring  r 
)
inlinestatic

Definition at line 1489 of file p_polys.h.

1490{
1491 p_LmCheckPolyRing1(p1, r);
1492 p_LmCheckPolyRing1(p2, r);
1493
1494 unsigned i = r->ExpL_Size;
1495 unsigned long *ep = p1->exp;
1496 unsigned long *eq = p2->exp;
1497
1498 do
1499 {
1500 i--;
1501 if (ep[i] != eq[i]) return FALSE;
1502 }
1503 while (i!=0);
1504 return TRUE;
1505}

◆ p_ExpVectorSub()

static void p_ExpVectorSub ( poly  p1,
poly  p2,
const ring  r 
)
inlinestatic

Definition at line 1440 of file p_polys.h.

1441{
1442 p_LmCheckPolyRing1(p1, r);
1443 p_LmCheckPolyRing1(p2, r);
1444#if PDEBUG >= 1
1445 for (int i=1; i<=r->N; i++)
1446 pAssume1(p_GetExp(p1, i, r) >= p_GetExp(p2, i, r));
1447 pAssume1(p_GetComp(p1, r) == 0 || p_GetComp(p2, r) == 0 ||
1448 p_GetComp(p1, r) == p_GetComp(p2, r));
1449#endif
1450
1451 p_MemSub_LengthGeneral(p1->exp, p2->exp, r->ExpL_Size);
1453}

◆ p_ExpVectorSum()

static void p_ExpVectorSum ( poly  pr,
poly  p1,
poly  p2,
const ring  r 
)
inlinestatic

Definition at line 1425 of file p_polys.h.

1426{
1427 p_LmCheckPolyRing1(p1, r);
1428 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_MemSum_LengthGeneral(pr->exp, p1->exp, p2->exp, r->ExpL_Size);
1438}

◆ p_Farey()

poly p_Farey ( poly  p,
number  N,
const ring  r 
)

Definition at line 54 of file p_polys.cc.

55{
56 poly h=p_Copy(p,r);
57 poly hh=h;
58 while(h!=NULL)
59 {
61 pSetCoeff0(h,n_Farey(c,N,r->cf));
62 n_Delete(&c,r->cf);
63 pIter(h);
64 }
65 while((hh!=NULL)&&(n_IsZero(pGetCoeff(hh),r->cf)))
66 {
67 p_LmDelete(&hh,r);
68 }
69 h=hh;
70 while((h!=NULL) && (pNext(h)!=NULL))
71 {
72 if(n_IsZero(pGetCoeff(pNext(h)),r->cf))
73 {
74 p_LmDelete(&pNext(h),r);
75 }
76 else pIter(h);
77 }
78 return hh;
79}
static FORCE_INLINE number n_Farey(number a, number b, const coeffs r)
Definition coeffs.h:760

◆ p_FDeg()

static long p_FDeg ( const poly  p,
const ring  r 
)
inlinestatic

Definition at line 380 of file p_polys.h.

380{ return r->pFDeg(p,r); }

◆ p_GcdMon()

poly p_GcdMon ( poly  f,
poly  g,
const ring  r 
)

polynomial gcd for f=mon

Definition at line 4979 of file p_polys.cc.

4980{
4981 assume(f!=NULL);
4982 assume(g!=NULL);
4983 assume(pNext(f)==NULL);
4984 poly G=p_Head(f,r);
4985 poly h=g;
4986 int *mf=(int*)omAlloc((r->N+1)*sizeof(int));
4987 p_GetExpV(f,mf,r);
4988 int *mh=(int*)omAlloc((r->N+1)*sizeof(int));
4991 loop
4992 {
4993 if (h==NULL) break;
4994 if(!one_coeff)
4995 {
4997 one_coeff=n_IsOne(n,r->cf);
4998 p_SetCoeff(G,n,r);
4999 }
5000 p_GetExpV(h,mh,r);
5002 for(unsigned j=r->N;j!=0;j--)
5003 {
5004 if (mh[j]<mf[j]) mf[j]=mh[j];
5005 if (mf[j]>0) const_mon=FALSE;
5006 }
5007 if (one_coeff && const_mon) break;
5008 pIter(h);
5009 }
5010 mf[0]=0;
5011 p_SetExpV(G,mf,r); // included is p_SetComp, p_Setm
5012 omFreeSize(mf,(r->N+1)*sizeof(int));
5013 omFreeSize(mh,(r->N+1)*sizeof(int));
5014 return G;
5015}
STATIC_VAR TreeM * G
Definition janet.cc:31
#define omAlloc(size)

◆ p_GetCoeffRat()

poly p_GetCoeffRat ( poly  p,
int  ishift,
ring  r 
)

Definition at line 1726 of file p_polys.cc.

1727{
1728 poly q = pNext(p);
1729 poly res; // = p_Head(p,r);
1730 res = p_GetExp_k_n(p, ishift+1, r->N, r); // does pSetm internally
1731 p_SetCoeff(res,n_Copy(p_GetCoeff(p,r),r),r);
1732 poly s;
1733 long cmp = p_GetComp(p, r);
1734 while ( (q!= NULL) && (p_Comp_k_n(p, q, ishift+1, r)) && (p_GetComp(q, r) == cmp) )
1735 {
1736 s = p_GetExp_k_n(q, ishift+1, r->N, r);
1737 p_SetCoeff(s,n_Copy(p_GetCoeff(q,r),r),r);
1738 res = p_Add_q(res,s,r);
1739 q = pNext(q);
1740 }
1741 cmp = 0;
1742 p_SetCompP(res,cmp,r);
1743 return res;
1744}
static int p_Comp_k_n(poly a, poly b, int k, ring r)
Definition p_polys.h:640
static void p_SetCompP(poly p, int i, ring r)
Definition p_polys.h:254

◆ p_GetExp() [1/3]

static long p_GetExp ( const poly  p,
const int  v,
const ring  r 
)
inlinestatic

get v^th exponent for a monomial

Definition at line 572 of file p_polys.h.

573{
575 pAssume2(v>0 && v <= r->N);
576 pAssume2(r->VarOffset[v] != -1);
577 return p_GetExp(p, r->bitmask, r->VarOffset[v]);
578}

◆ p_GetExp() [2/3]

static long p_GetExp ( const poly  p,
const ring  r,
const int  VarOffset 
)
inlinestatic

Definition at line 555 of file p_polys.h.

556{
558 pAssume2(VarOffset != -1);
559 return p_GetExp(p, r->bitmask, VarOffset);
560}

◆ p_GetExp() [3/3]

static long p_GetExp ( const poly  p,
const unsigned long  iBitmask,
const int  VarOffset 
)
inlinestatic

get a single variable exponent @Note: the integer VarOffset encodes:

  1. the position of a variable in the exponent vector p->exp (lower 24 bits)
  2. number of bits to shift to the right in the upper 8 bits (which takes at most 6 bits for 64 bit) Thus VarOffset always has 2 zero higher bits!

Definition at line 469 of file p_polys.h.

470{
471 pAssume2((VarOffset >> (24 + 6)) == 0);
472#if 0
473 int pos=(VarOffset & 0xffffff);
474 int bitpos=(VarOffset >> 24);
475 unsigned long exp=(p->exp[pos] >> bitmask) & iBitmask;
476 return exp;
477#else
478 return (long)
479 ((p->exp[(VarOffset & 0xffffff)] >> (VarOffset >> 24))
480 & iBitmask);
481#endif
482}
gmp_float exp(const gmp_float &a)

◆ p_GetExp_k_n()

static poly p_GetExp_k_n ( poly  p,
int  l,
int  k,
const ring  r 
)
inlinestatic

Definition at line 1372 of file p_polys.h.

1373{
1374 if (p == NULL) return NULL;
1376 poly np;
1377 omTypeAllocBin(poly, np, r->PolyBin);
1378 p_SetRingOfLm(np, r);
1379 memcpy(np->exp, p->exp, r->ExpL_Size*sizeof(long));
1380 pNext(np) = NULL;
1381 pSetCoeff0(np, n_Init(1, r->cf));
1382 int i;
1383 for(i=l;i<=k;i++)
1384 {
1385 //np->exp[(r->VarOffset[i] & 0xffffff)] =0;
1386 p_SetExp(np,i,0,r);
1387 }
1388 p_Setm(np,r);
1389 return np;
1390}

◆ p_GetExpDiff()

static long p_GetExpDiff ( poly  p1,
poly  p2,
int  i,
ring  r 
)
inlinestatic

Definition at line 635 of file p_polys.h.

636{
637 return p_GetExp(p1,i,r) - p_GetExp(p2,i,r);
638}

◆ p_GetExpSum()

static long p_GetExpSum ( poly  p1,
poly  p2,
int  i,
ring  r 
)
inlinestatic

Definition at line 629 of file p_polys.h.

630{
631 p_LmCheckPolyRing2(p1, r);
632 p_LmCheckPolyRing2(p2, r);
633 return p_GetExp(p1,i,r) + p_GetExp(p2,i,r);
634}

◆ p_GetExpV()

static void p_GetExpV ( poly  p,
int ev,
const ring  r 
)
inlinestatic

Definition at line 1520 of file p_polys.h.

1521{
1523 for (unsigned j = r->N; j!=0; j--)
1524 ev[j] = p_GetExp(p, j, r);
1525
1526 ev[0] = p_GetComp(p, r);
1527}

◆ p_GetExpVL()

static void p_GetExpVL ( poly  p,
int64 ev,
const ring  r 
)
inlinestatic

Definition at line 1529 of file p_polys.h.

1530{
1532 for (unsigned j = r->N; j!=0; j--)
1533 ev[j-1] = p_GetExp(p, j, r);
1534}

◆ p_GetExpVLV()

static int64 p_GetExpVLV ( poly  p,
int64 ev,
const ring  r 
)
inlinestatic

Definition at line 1536 of file p_polys.h.

1537{
1539 for (unsigned j = r->N; j!=0; j--)
1540 ev[j-1] = p_GetExp(p, j, r);
1541 return (int64)p_GetComp(p,r);
1542}

◆ p_GetMaxExp() [1/2]

static unsigned long p_GetMaxExp ( const poly  p,
const ring  r 
)
inlinestatic

Definition at line 804 of file p_polys.h.

805{
806 return p_GetMaxExp(p_GetMaxExpL(p, r), r);
807}
static unsigned long p_GetMaxExp(const unsigned long l, const ring r)
Definition p_polys.h:781
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

◆ p_GetMaxExp() [2/2]

static unsigned long p_GetMaxExp ( const unsigned long  l,
const ring  r 
)
inlinestatic

Definition at line 781 of file p_polys.h.

782{
783 unsigned long bitmask = r->bitmask;
784 unsigned long max = (l & bitmask);
785 unsigned long j = r->ExpPerLong - 1;
786
787 if (j > 0)
788 {
789 unsigned long i = r->BitsPerExp;
790 long e;
791 loop
792 {
793 e = ((l >> i) & bitmask);
794 if ((unsigned long) e > max)
795 max = e;
796 j--;
797 if (j==0) break;
798 i += r->BitsPerExp;
799 }
800 }
801 return max;
802}
static int max(int a, int b)
Definition fast_mult.cc:264

◆ p_GetMaxExpL()

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 at line 1176 of file p_polys.cc.

1177{
1178 unsigned long l_p, divmask = r->divmask;
1179 int i;
1180
1181 while (p != NULL)
1182 {
1183 l_p = p->exp[r->VarL_Offset[0]];
1184 if (l_p > l_max ||
1185 (((l_max & divmask) ^ (l_p & divmask)) != ((l_max-l_p) & divmask)))
1187 for (i=1; i<r->VarL_Size; i++)
1188 {
1189 l_p = p->exp[r->VarL_Offset[i]];
1190 // do the divisibility trick to find out whether l has an exponent
1191 if (l_p > l_max ||
1192 (((l_max & divmask) ^ (l_p & divmask)) != ((l_max-l_p) & divmask)))
1194 }
1195 pIter(p);
1196 }
1197 return l_max;
1198}
static unsigned long p_GetMaxExpL2(unsigned long l1, unsigned long l2, const ring r, unsigned long number_of_exp)
Definition p_polys.cc:1108

◆ p_GetMaxExpP()

poly p_GetMaxExpP ( poly  p,
ring  r 
)

return monomial r such that GetExp(r,i) is maximum of all monomials in p; coeff == 0, next == NULL, ord is not set

Definition at line 1139 of file p_polys.cc.

1140{
1141 p_CheckPolyRing(p, r);
1142 if (p == NULL) return p_Init(r);
1143 poly max = p_LmInit(p, r);
1144 pIter(p);
1145 if (p == NULL) return max;
1146 int i, offset;
1147 unsigned long l_p, l_max;
1148 unsigned long divmask = r->divmask;
1149
1150 do
1151 {
1152 offset = r->VarL_Offset[0];
1153 l_p = p->exp[offset];
1154 l_max = max->exp[offset];
1155 // do the divisibility trick to find out whether l has an exponent
1156 if (l_p > l_max ||
1157 (((l_max & divmask) ^ (l_p & divmask)) != ((l_max-l_p) & divmask)))
1158 max->exp[offset] = p_GetMaxExpL2(l_max, l_p, r);
1159
1160 for (i=1; i<r->VarL_Size; i++)
1161 {
1162 offset = r->VarL_Offset[i];
1163 l_p = p->exp[offset];
1164 l_max = max->exp[offset];
1165 // do the divisibility trick to find out whether l has an exponent
1166 if (l_p > l_max ||
1167 (((l_max & divmask) ^ (l_p & divmask)) != ((l_max-l_p) & divmask)))
1168 max->exp[offset] = p_GetMaxExpL2(l_max, l_p, r);
1169 }
1170 pIter(p);
1171 }
1172 while (p != NULL);
1173 return max;
1174}
STATIC_VAR int offset
Definition janet.cc:29
BOOLEAN p_CheckPolyRing(poly p, ring r)
Definition pDebug.cc:115

◆ p_GetOrder()

static long p_GetOrder ( poly  p,
ring  r 
)
inlinestatic

Definition at line 421 of file p_polys.h.

422{
424 if (r->typ==NULL) return ((p)->exp[r->pOrdIndex]);
425 int i=0;
426 loop
427 {
428 switch(r->typ[i].ord_typ)
429 {
430 case ro_am:
431 case ro_wp_neg:
432 return ((p->exp[r->pOrdIndex])-POLY_NEGWEIGHT_OFFSET);
433 case ro_syzcomp:
434 case ro_syz:
435 case ro_cp:
436 i++;
437 break;
438 //case ro_dp:
439 //case ro_wp:
440 default:
441 return ((p)->exp[r->pOrdIndex]);
442 }
443 }
444}
@ 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

◆ p_GetSetmProc()

p_SetmProc p_GetSetmProc ( const ring  r)

Definition at line 559 of file p_polys.cc.

560{
561 // covers lp, rp, ls,
562 if (r->typ == NULL) return p_Setm_Dummy;
563
564 if (r->OrdSize == 1)
565 {
566 if (r->typ[0].ord_typ == ro_dp &&
567 r->typ[0].data.dp.start == 1 &&
568 r->typ[0].data.dp.end == r->N &&
569 r->typ[0].data.dp.place == r->pOrdIndex)
570 return p_Setm_TotalDegree;
571 if (r->typ[0].ord_typ == ro_wp &&
572 r->typ[0].data.wp.start == 1 &&
573 r->typ[0].data.wp.end == r->N &&
574 r->typ[0].data.wp.place == r->pOrdIndex &&
575 r->typ[0].data.wp.weights == r->firstwv)
577 }
578 return p_Setm_General;
579}
void p_Setm_WFirstTotalDegree(poly p, const ring r)
Definition p_polys.cc:553
void p_Setm_Dummy(poly p, const ring r)
Definition p_polys.cc:540
void p_Setm_TotalDegree(poly p, const ring r)
Definition p_polys.cc:546
void p_Setm_General(poly p, const ring r)
Definition p_polys.cc:158
@ ro_dp
Definition ring.h:52
@ ro_wp
Definition ring.h:53

◆ p_GetShortExpVector()

unsigned long p_GetShortExpVector ( const poly  a,
const ring  r 
)

Definition at line 4829 of file p_polys.cc.

4830{
4831 assume(p != NULL);
4832 unsigned long ev = 0; // short exponent vector
4833 unsigned int n = BIT_SIZEOF_LONG / r->N; // number of bits per exp
4834 unsigned int m1; // highest bit which is filled with (n+1)
4835 unsigned int i=0;
4836 int j=1;
4837
4838 if (n == 0)
4839 {
4840 if (r->N <2*BIT_SIZEOF_LONG)
4841 {
4842 n=1;
4843 m1=0;
4844 }
4845 else
4846 {
4847 for (; j<=r->N; j++)
4848 {
4849 if (p_GetExp(p,j,r) > 0) i++;
4850 if (i == BIT_SIZEOF_LONG) break;
4851 }
4852 if (i>0)
4853 ev = ~(0UL) >> (BIT_SIZEOF_LONG - i);
4854 return ev;
4855 }
4856 }
4857 else
4858 {
4859 m1 = (n+1)*(BIT_SIZEOF_LONG - n*r->N);
4860 }
4861
4862 n++;
4863 while (i<m1)
4864 {
4865 ev |= GetBitFields(p_GetExp(p, j,r), i, n);
4866 i += n;
4867 j++;
4868 }
4869
4870 n--;
4871 while (i<BIT_SIZEOF_LONG)
4872 {
4873 ev |= GetBitFields(p_GetExp(p, j,r), i, n);
4874 i += n;
4875 j++;
4876 }
4877 return ev;
4878}
#define BIT_SIZEOF_LONG
Definition auxiliary.h:80
static unsigned long GetBitFields(const long e, const unsigned int s, const unsigned int n)
Definition p_polys.cc:4797

◆ p_GetShortExpVector0()

unsigned long p_GetShortExpVector0 ( const poly  a,
const ring  r 
)

Definition at line 4880 of file p_polys.cc.

4881{
4882 assume(p != NULL);
4883 assume(r->N >=BIT_SIZEOF_LONG);
4884 unsigned long ev = 0; // short exponent vector
4885
4886 for (int j=BIT_SIZEOF_LONG; j>0; j--)
4887 {
4888 if (p_GetExp(p, j,r)>0)
4889 ev |= Sy_bitL(j-1);
4890 }
4891 return ev;
4892}
#define Sy_bitL(x)
Definition options.h:32

◆ p_GetShortExpVector1()

unsigned long p_GetShortExpVector1 ( const poly  a,
const ring  r 
)

Definition at line 4895 of file p_polys.cc.

4896{
4897 assume(p != NULL);
4898 assume(r->N <BIT_SIZEOF_LONG);
4899 assume(2*r->N >=BIT_SIZEOF_LONG);
4900 unsigned long ev = 0; // short exponent vector
4901 int rest=r->N;
4902 int e;
4903 // 2 bits per exp
4904 int j=r->N;
4905 for (; j>BIT_SIZEOF_LONG-r->N; j--)
4906 {
4907 if ((e=p_GetExp(p, j,r))>0)
4908 {
4909 ev |= Sy_bitL(j-1);
4910 if (e>1)
4911 {
4912 ev|=Sy_bitL(rest+j-1);
4913 }
4914 }
4915 }
4916 // 1 bit per exp
4917 for (; j>0; j--)
4918 {
4919 if (p_GetExp(p, j,r)>0)
4920 {
4921 ev |= Sy_bitL(j-1);
4922 }
4923 }
4924 return ev;
4925}

◆ p_GetTotalDegree()

static unsigned long p_GetTotalDegree ( const unsigned long  l,
const ring  r,
const int  number_of_exps 
)
inlinestatic

Definition at line 810 of file p_polys.h.

811{
812 const unsigned long bitmask = r->bitmask;
813 unsigned long sum = (l & bitmask);
814 unsigned long j = number_of_exps - 1;
815
816 if (j > 0)
817 {
818 unsigned long i = r->BitsPerExp;
819 loop
820 {
821 sum += ((l >> i) & bitmask);
822 j--;
823 if (j==0) break;
824 i += r->BitsPerExp;
825 }
826 }
827 return sum;
828}

◆ p_GetVariables()

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 at line 1268 of file p_polys.cc.

1269{
1270 int i;
1271 int n=0;
1272 while(p!=NULL)
1273 {
1274 n=0;
1275 for(i=r->N; i>0; i--)
1276 {
1277 if(e[i]==0)
1278 {
1279 if (p_GetExp(p,i,r)>0)
1280 {
1281 e[i]=1;
1282 n++;
1283 }
1284 }
1285 else
1286 n++;
1287 }
1288 if (n==r->N) break;
1289 pIter(p);
1290 }
1291 return n;
1292}

◆ p_HasNotCF()

BOOLEAN p_HasNotCF ( poly  p1,
poly  p2,
const ring  r 
)

Definition at line 1330 of file p_polys.cc.

1331{
1332
1333 if (p_GetComp(p1,r) > 0 || p_GetComp(p2,r) > 0)
1334 return FALSE;
1335 int i = rVar(r);
1336 loop
1337 {
1338 if ((p_GetExp(p1, i, r) > 0) && (p_GetExp(p2, i, r) > 0))
1339 return FALSE;
1340 i--;
1341 if (i == 0)
1342 return TRUE;
1343 }
1344}

◆ p_HasNotCFRing()

BOOLEAN p_HasNotCFRing ( poly  p1,
poly  p2,
const ring  r 
)

Definition at line 1346 of file p_polys.cc.

1347{
1348
1349 if (p_GetComp(p1,r) > 0 || p_GetComp(p2,r) > 0)
1350 return FALSE;
1351 int i = rVar(r);
1352 loop
1353 {
1354 if ((p_GetExp(p1, i, r) > 0) && (p_GetExp(p2, i, r) > 0))
1355 return FALSE;
1356 i--;
1357 if (i == 0) {
1358 if (n_DivBy(pGetCoeff(p1), pGetCoeff(p2), r->cf) ||
1359 n_DivBy(pGetCoeff(p2), pGetCoeff(p1), r->cf)) {
1360 return FALSE;
1361 } else {
1362 return TRUE;
1363 }
1364 }
1365 }
1366}

◆ p_Head()

static poly p_Head ( const poly  p,
const ring  r 
)
inlinestatic

copy the (leading) term of p

Definition at line 860 of file p_polys.h.

861{
862 if (p == NULL) return NULL;
864 poly np;
865 omTypeAllocBin(poly, np, r->PolyBin);
866 p_SetRingOfLm(np, r);
867 memcpy(np->exp, p->exp, r->ExpL_Size*sizeof(long));
868 pNext(np) = NULL;
869 pSetCoeff0(np, n_Copy(pGetCoeff(p), r->cf));
870 return np;
871}

◆ p_Head0()

poly p_Head0 ( const poly  p,
const ring  r 
)

like p_Head, but allow NULL coeff

Definition at line 5035 of file p_polys.cc.

5036{
5037 if (p==NULL) return NULL;
5038 if (pGetCoeff(p)==NULL) return p_CopyPowerProduct0(p,NULL,r);
5039 return p_Head(p,r);
5040}

◆ p_Homogen()

poly p_Homogen ( poly  p,
int  varnum,
const ring  r 
)

Definition at line 3274 of file p_polys.cc.

3275{
3276 pFDegProc deg;
3277 if (r->pLexOrder && (r->order[0]==ringorder_lp))
3278 deg=p_Totaldegree;
3279 else
3280 deg=r->pFDeg;
3281
3282 poly q=NULL, qn;
3283 int o,ii;
3284 sBucket_pt bp;
3285
3286 if (p!=NULL)
3287 {
3288 if ((varnum < 1) || (varnum > rVar(r)))
3289 {
3290 return NULL;
3291 }
3292 o=deg(p,r);
3293 q=pNext(p);
3294 while (q != NULL)
3295 {
3296 ii=deg(q,r);
3297 if (ii>o) o=ii;
3298 pIter(q);
3299 }
3300 q = p_Copy(p,r);
3301 bp = sBucketCreate(r);
3302 while (q != NULL)
3303 {
3304 ii = o-deg(q,r);
3305 if (ii!=0)
3306 {
3307 p_AddExp(q,varnum, (long)ii,r);
3308 p_Setm(q,r);
3309 }
3310 qn = pNext(q);
3311 pNext(q) = NULL;
3312 sBucket_Add_m(bp, q);
3313 q = qn;
3314 }
3315 sBucketDestroyAdd(bp, &q, &ii);
3316 }
3317 return q;
3318}
static long p_AddExp(poly p, int v, long ee, ring r)
Definition p_polys.h:606
@ ringorder_lp
Definition ring.h:77
void sBucket_Add_m(sBucket_pt bucket, poly p)
Definition sbuckets.cc:173
sBucket_pt sBucketCreate(const ring r)
Definition sbuckets.cc:96
void sBucketDestroyAdd(sBucket_pt bucket, poly *p, int *length)
Definition sbuckets.h:68

◆ p_IncrExp()

static long p_IncrExp ( poly  p,
int  v,
ring  r 
)
inlinestatic

Definition at line 591 of file p_polys.h.

592{
594 int e = p_GetExp(p,v,r);
595 e++;
596 return p_SetExp(p,v,e,r);
597}

◆ p_Init() [1/2]

static poly p_Init ( const ring  r)
inlinestatic

Definition at line 1330 of file p_polys.h.

1331{
1332 return p_Init(r, r->PolyBin);
1333}

◆ p_Init() [2/2]

static poly p_Init ( const ring  r,
omBin  bin 
)
inlinestatic

Definition at line 1320 of file p_polys.h.

1321{
1322 p_CheckRing1(r);
1323 pAssume1(bin != NULL && omSizeWOfBin(r->PolyBin) == omSizeWOfBin(bin));
1324 poly p;
1325 omTypeAlloc0Bin(poly, p, bin);
1327 p_SetRingOfLm(p, r);
1328 return p;
1329}

◆ p_InitContent()

number p_InitContent ( poly  ph,
const ring  r 
)

Definition at line 2639 of file p_polys.cc.

2642{
2644 assume(ph!=NULL);
2645 assume(pNext(ph)!=NULL);
2646 assume(rField_is_Q(r));
2647 if (pNext(pNext(ph))==NULL)
2648 {
2649 return n_GetNumerator(pGetCoeff(pNext(ph)),r->cf);
2650 }
2651 poly p=ph;
2653 pIter(p);
2655 pIter(p);
2656 number d;
2657 number t;
2658 loop
2659 {
2660 nlNormalize(pGetCoeff(p),r->cf);
2661 t=n_GetNumerator(pGetCoeff(p),r->cf);
2662 if (nlGreaterZero(t,r->cf))
2663 d=nlAdd(n1,t,r->cf);
2664 else
2665 d=nlSub(n1,t,r->cf);
2666 nlDelete(&t,r->cf);
2667 nlDelete(&n1,r->cf);
2668 n1=d;
2669 pIter(p);
2670 if (p==NULL) break;
2671 nlNormalize(pGetCoeff(p),r->cf);
2672 t=n_GetNumerator(pGetCoeff(p),r->cf);
2673 if (nlGreaterZero(t,r->cf))
2674 d=nlAdd(n2,t,r->cf);
2675 else
2676 d=nlSub(n2,t,r->cf);
2677 nlDelete(&t,r->cf);
2678 nlDelete(&n2,r->cf);
2679 n2=d;
2680 pIter(p);
2681 if (p==NULL) break;
2682 }
2683 d=nlGcd(n1,n2,r->cf);
2684 nlDelete(&n1,r->cf);
2685 nlDelete(&n2,r->cf);
2686 return d;
2687}
2688#else
2689{
2690 /* ph has al least 2 terms */
2691 number d=pGetCoeff(ph);
2692 int s=n_Size(d,r->cf);
2693 pIter(ph);
2695 int s2=n_Size(d2,r->cf);
2696 pIter(ph);
2697 if (ph==NULL)
2698 {
2699 if (s<s2) return n_Copy(d,r->cf);
2700 else return n_Copy(d2,r->cf);
2701 }
2702 do
2703 {
2705 int ns=n_Size(nd,r->cf);
2706 if (ns<=2)
2707 {
2708 s2=s;
2709 d2=d;
2710 d=nd;
2711 s=ns;
2712 break;
2713 }
2714 else if (ns<s)
2715 {
2716 s2=s;
2717 d2=d;
2718 d=nd;
2719 s=ns;
2720 }
2721 pIter(ph);
2722 }
2723 while(ph!=NULL);
2724 return n_SubringGcd(d,d2,r->cf);
2725}
static FORCE_INLINE int n_Size(number n, const coeffs r)
return a non-negative measure for the complexity of n; return 0 only when n represents zero; (used fo...
Definition coeffs.h:571
static FORCE_INLINE number n_GetNumerator(number &n, const coeffs r)
return the numerator of n (if elements of r are by nature not fractional, result is n)
Definition coeffs.h:609
LINLINE number nlAdd(number la, number li, const coeffs r)
Definition longrat.cc:2692
LINLINE number nlSub(number la, number li, const coeffs r)
Definition longrat.cc:2758
LINLINE void nlDelete(number *a, const coeffs r)
Definition longrat.cc:2657
BOOLEAN nlGreaterZero(number za, const coeffs r)
Definition longrat.cc:1303
number nlGcd(number a, number b, const coeffs r)
Definition longrat.cc:1340
void nlNormalize(number &x, const coeffs r)
Definition longrat.cc:1481

◆ p_IsConstant()

static BOOLEAN p_IsConstant ( const poly  p,
const ring  r 
)
inlinestatic

Definition at line 1964 of file p_polys.h.

1965{
1966 if (p == NULL) return TRUE;
1967 return (pNext(p)==NULL) && p_LmIsConstant(p, r);
1968}

◆ p_IsConstantComp()

static BOOLEAN p_IsConstantComp ( const poly  p,
const ring  r 
)
inlinestatic

like the respective p_LmIs* routines, except that p might be empty

Definition at line 1958 of file p_polys.h.

1959{
1960 if (p == NULL) return TRUE;
1961 return (pNext(p)==NULL) && p_LmIsConstantComp(p, r);
1962}

◆ p_IsConstantPoly()

static BOOLEAN p_IsConstantPoly ( const poly  p,
const ring  r 
)
inlinestatic

Definition at line 1978 of file p_polys.h.

1979{
1980 p_Test(p, r);
1981 poly pp=p;
1982 while(pp!=NULL)
1983 {
1984 if (! p_LmIsConstantComp(pp, r))
1985 return FALSE;
1986 pIter(pp);
1987 }
1988 return TRUE;
1989}

◆ p_ISet()

poly p_ISet ( long  i,
const ring  r 
)

returns the poly representing the integer i

Definition at line 1298 of file p_polys.cc.

1299{
1300 poly rc = NULL;
1301 if (i!=0)
1302 {
1303 rc = p_Init(r);
1304 pSetCoeff0(rc,n_Init(i,r->cf));
1305 if (n_IsZero(pGetCoeff(rc),r->cf))
1306 p_LmDelete(&rc,r);
1307 }
1308 return rc;
1309}

◆ p_IsHomogeneous()

BOOLEAN p_IsHomogeneous ( poly  p,
const ring  r 
)

Definition at line 3323 of file p_polys.cc.

3324{
3325 poly qp=p;
3326 int o;
3327
3328 if ((p == NULL) || (pNext(p) == NULL)) return TRUE;
3329 pFDegProc d;
3330 if (r->pLexOrder && (r->order[0]==ringorder_lp))
3331 d=p_Totaldegree;
3332 else
3333 d=r->pFDeg;
3334 o = d(p,r);
3335 do
3336 {
3337 if (d(qp,r) != o) return FALSE;
3338 pIter(qp);
3339 }
3340 while (qp != NULL);
3341 return TRUE;
3342}

◆ p_IsHomogeneousW() [1/2]

BOOLEAN p_IsHomogeneousW ( poly  p,
const intvec w,
const intvec module_w,
const ring  r 
)

Definition at line 3364 of file p_polys.cc.

3365{
3366 poly qp=p;
3367 long o;
3368
3369 if ((p == NULL) || (pNext(p) == NULL)) return TRUE;
3370 pIter(qp);
3371 o = totaldegreeWecart_IV(p,r,w->ivGetVec())+(*module_w)[p_GetComp(p,r)];
3372 do
3373 {
3374 long oo=totaldegreeWecart_IV(qp,r,w->ivGetVec())+(*module_w)[p_GetComp(qp,r)];
3375 if (oo != o) return FALSE;
3376 pIter(qp);
3377 }
3378 while (qp != NULL);
3379 return TRUE;
3380}

◆ p_IsHomogeneousW() [2/2]

BOOLEAN p_IsHomogeneousW ( poly  p,
const intvec w,
const ring  r 
)

Definition at line 3347 of file p_polys.cc.

3348{
3349 poly qp=p;
3350 long o;
3351
3352 if ((p == NULL) || (pNext(p) == NULL)) return TRUE;
3353 pIter(qp);
3354 o = totaldegreeWecart_IV(p,r,w->ivGetVec());
3355 do
3356 {
3357 if (totaldegreeWecart_IV(qp,r,w->ivGetVec()) != o) return FALSE;
3358 pIter(qp);
3359 }
3360 while (qp != NULL);
3361 return TRUE;
3362}

◆ p_IsOne()

static BOOLEAN p_IsOne ( const poly  p,
const ring  R 
)
inlinestatic

either poly(1) or gen(k)?!

Definition at line 1971 of file p_polys.h.

1972{
1973 if (p == NULL) return FALSE; /* TODO check if 0 == 1 */
1974 p_Test(p, R);
1975 return (p_IsConstant(p, R) && n_IsOne(p_GetCoeff(p, R), R->cf));
1976}

◆ p_IsPurePower()

int p_IsPurePower ( const poly  p,
const ring  r 
)

return i, if head depends only on var(i)

Definition at line 1227 of file p_polys.cc.

1228{
1229 int i,k=0;
1230
1231 for (i=r->N;i;i--)
1232 {
1233 if (p_GetExp(p,i, r)!=0)
1234 {
1235 if(k!=0) return 0;
1236 k=i;
1237 }
1238 }
1239 return k;
1240}

◆ p_IsUnit()

static BOOLEAN p_IsUnit ( const poly  p,
const ring  r 
)
inlinestatic

Definition at line 1991 of file p_polys.h.

1992{
1993 if (p == NULL) return FALSE;
1994 if (rField_is_Ring(r))
1995 return (p_LmIsConstant(p, r) && n_IsUnit(pGetCoeff(p),r->cf));
1996 return p_LmIsConstant(p, r);
1997}

◆ p_IsUnivariate()

int p_IsUnivariate ( poly  p,
const ring  r 
)

return i, if poly depends only on var(i)

Definition at line 1248 of file p_polys.cc.

1249{
1250 int i,k=-1;
1251
1252 while (p!=NULL)
1253 {
1254 for (i=r->N;i;i--)
1255 {
1256 if (p_GetExp(p,i, r)!=0)
1257 {
1258 if((k!=-1)&&(k!=i)) return 0;
1259 k=i;
1260 }
1261 }
1262 pIter(p);
1263 }
1264 return k;
1265}

◆ p_Jet()

poly p_Jet ( poly  p,
int  m,
const ring  R 
)

Definition at line 4435 of file p_polys.cc.

4436{
4437 while((p!=NULL) && (p_Totaldegree(p,R)>m)) p_LmDelete(&p,R);
4438 if (p==NULL) return NULL;
4439 poly r=p;
4440 while (pNext(p)!=NULL)
4441 {
4442 if (p_Totaldegree(pNext(p),R)>m)
4443 {
4444 p_LmDelete(&pNext(p),R);
4445 }
4446 else
4447 pIter(p);
4448 }
4449 return r;
4450}

◆ p_JetW()

poly p_JetW ( poly  p,
int  m,
int w,
const ring  R 
)

Definition at line 4479 of file p_polys.cc.

4480{
4481 while((p!=NULL) && (totaldegreeWecart_IV(p,R,w)>m)) p_LmDelete(&p,R);
4482 if (p==NULL) return NULL;
4483 poly r=p;
4484 while (pNext(p)!=NULL)
4485 {
4487 {
4488 p_LmDelete(&pNext(p),R);
4489 }
4490 else
4491 pIter(p);
4492 }
4493 return r;
4494}

◆ p_Last()

poly p_Last ( const poly  a,
int l,
const ring  r 
)

Definition at line 4670 of file p_polys.cc.

4671{
4672 if (p == NULL)
4673 {
4674 l = 0;
4675 return NULL;
4676 }
4677 l = 1;
4678 poly a = p;
4679 if (! rIsSyzIndexRing(r))
4680 {
4681 poly next = pNext(a);
4682 while (next!=NULL)
4683 {
4684 a = next;
4685 next = pNext(a);
4686 l++;
4687 }
4688 }
4689 else
4690 {
4691 long unsigned curr_limit = rGetCurrSyzLimit(r);
4692 poly pp = a;
4693 while ((a=pNext(a))!=NULL)
4694 {
4695 if (__p_GetComp(a,r)<=curr_limit/*syzComp*/)
4696 l++;
4697 else break;
4698 pp = a;
4699 }
4700 a=pp;
4701 }
4702 return a;
4703}
ListNode * next
Definition janet.h:31
static int rGetCurrSyzLimit(const ring r)
Definition ring.h:728
static BOOLEAN rIsSyzIndexRing(const ring r)
Definition ring.h:725

◆ p_Lcm() [1/2]

poly p_Lcm ( const poly  a,
const poly  b,
const ring  r 
)

Definition at line 1668 of file p_polys.cc.

1669{
1670 poly m=p_Init(r);
1671 p_Lcm(a, b, m, r);
1672 p_Setm(m,r);
1673 return(m);
1674}
void p_Lcm(const poly a, const poly b, poly m, const ring r)
Definition p_polys.cc:1659

◆ p_Lcm() [2/2]

void p_Lcm ( const poly  a,
const poly  b,
poly  m,
const ring  r 
)

Definition at line 1659 of file p_polys.cc.

1660{
1661 for (int i=r->N; i; --i)
1662 p_SetExp(m,i, si_max( p_GetExp(a,i,r), p_GetExp(b,i,r)),r);
1663
1664 p_SetComp(m, si_max(p_GetComp(a,r), p_GetComp(b,r)),r);
1665 /* Don't do a pSetm here, otherwise hres/lres chockes */
1666}
static int si_max(const int a, const int b)
Definition auxiliary.h:124

◆ p_LcmRat()

poly p_LcmRat ( const poly  a,
const poly  b,
const long  lCompM,
const ring  r 
)

Definition at line 1681 of file p_polys.cc.

1682{
1683 poly m = // p_One( r);
1684 p_Init(r);
1685
1686// const int (currRing->N) = r->N;
1687
1688 // for (int i = (currRing->N); i>=r->real_var_start; i--)
1689 for (int i = r->real_var_end; i>=r->real_var_start; i--)
1690 {
1691 const int lExpA = p_GetExp (a, i, r);
1692 const int lExpB = p_GetExp (b, i, r);
1693
1694 p_SetExp (m, i, si_max(lExpA, lExpB), r);
1695 }
1696
1697 p_SetComp (m, lCompM, r);
1698 p_Setm(m,r);
1699 p_GetCoeff(m, r)=NULL;
1700
1701 return(m);
1702};

◆ p_LDeg()

static long p_LDeg ( const poly  p,
int l,
const ring  r 
)
inlinestatic

Definition at line 381 of file p_polys.h.

381{ return r->pLDeg(p,l,r); }

◆ p_LmCheckIsFromRing()

BOOLEAN p_LmCheckIsFromRing ( poly  p,
ring  r 
)

Definition at line 74 of file pDebug.cc.

75{
76 if (p != NULL)
77 {
78 #if (OM_TRACK > 0) && defined(OM_TRACK_CUSTOM)
79 void* custom = omGetCustomOfAddr(p);
80 if (custom != NULL)
81 {
83 // be more sloppy for qrings
84 (r->qideal != NULL &&
86 omSizeWOfAddr(p)==omSizeWOfBin(r->PolyBin)) ||
88 "monomial not from specified ring",p,r);
89 return TRUE;
90 }
91 else
92 #endif
93 #ifndef X_OMALLOC
94 {
97 return TRUE;
98 }
99 return FALSE;
100 #endif
101 }
102 return TRUE;
103}
#define pPolyAssumeReturnMsg(cond, msg)
Definition monomials.h:137
#define _pPolyAssumeReturn(cond, p, r)
Definition monomials.h:101
#define omIsBinPageAddr(addr)
Definition omBinPage.h:68
#define omSizeWOfAddr(P)
Definition xalloc.h:223

◆ p_LmCheckPolyRing()

BOOLEAN p_LmCheckPolyRing ( poly  p,
ring  r 
)

Definition at line 123 of file pDebug.cc.

124{
125 #ifndef X_OMALLOC
126 pAssumeReturn(r != NULL && r->PolyBin != NULL);
127 #endif
128 pAssumeReturn(p != NULL);
129 return p_LmCheckIsFromRing(p, r);
130}

◆ p_LmCmp()

static int p_LmCmp ( poly  p,
poly  q,
const ring  r 
)
inlinestatic

Definition at line 1580 of file p_polys.h.

1581{
1583 p_LmCheckPolyRing1(q, r);
1584
1585 const unsigned long* _s1 = ((unsigned long*) p->exp);
1586 const unsigned long* _s2 = ((unsigned long*) q->exp);
1587 REGISTER unsigned long _v1;
1588 REGISTER unsigned long _v2;
1589 const unsigned long _l = r->CmpL_Size;
1590
1591 REGISTER unsigned long _i=0;
1592
1594 _v1 = _s1[_i];
1595 _v2 = _s2[_i];
1596 if (_v1 == _v2)
1597 {
1598 _i++;
1599 if (_i == _l) return 0;
1601 }
1602 const long* _ordsgn = (long*) r->ordsgn;
1603#if 1 /* two variants*/
1604 if (_v1 > _v2)
1605 {
1606 return _ordsgn[_i];
1607 }
1608 return -(_ordsgn[_i]);
1609#else
1610 if (_v1 > _v2)
1611 {
1612 if (_ordsgn[_i] == 1) return 1;
1613 return -1;
1614 }
1615 if (_ordsgn[_i] == 1) return -1;
1616 return 1;
1617#endif
1618}

◆ p_LmDelete() [1/2]

static void p_LmDelete ( poly *  p,
const ring  r 
)
inlinestatic

Definition at line 743 of file p_polys.h.

744{
746 poly h = *p;
747 *p = pNext(h);
748 n_Delete(&pGetCoeff(h), r->cf);
749 #ifdef XALLOC_BIN
750 omFreeBin(h,r->PolyBin);
751 #else
753 #endif
754}
#define omFreeBin(addr, bin)

◆ p_LmDelete() [2/2]

static void p_LmDelete ( poly  p,
const ring  r 
)
inlinestatic

Definition at line 723 of file p_polys.h.

724{
726 n_Delete(&pGetCoeff(p), r->cf);
727 #ifdef XALLOC_BIN
728 omFreeBin(p,r->PolyBin);
729 #else
731 #endif
732}

◆ p_LmDelete0()

static void p_LmDelete0 ( poly  p,
const ring  r 
)
inlinestatic

Definition at line 733 of file p_polys.h.

734{
736 if (pGetCoeff(p)!=NULL) n_Delete(&pGetCoeff(p), r->cf);
737 #ifdef XALLOC_BIN
738 omFreeBin(p,r->PolyBin);
739 #else
741 #endif
742}

◆ p_LmDeleteAndNext()

static poly p_LmDeleteAndNext ( poly  p,
const ring  r 
)
inlinestatic

Definition at line 755 of file p_polys.h.

756{
758 poly pnext = pNext(p);
759 n_Delete(&pGetCoeff(p), r->cf);
760 #ifdef XALLOC_BIN
761 omFreeBin(p,r->PolyBin);
762 #else
764 #endif
765 return pnext;
766}

◆ p_LmDeleteAndNextRat()

void p_LmDeleteAndNextRat ( poly *  p,
int  ishift,
ring  r 
)

Definition at line 1704 of file p_polys.cc.

1705{
1706 /* modifies p*/
1707 // Print("start: "); Print(" "); p_wrp(*p,r);
1708 p_LmCheckPolyRing2(*p, r);
1709 poly q = p_Head(*p,r);
1710 const long cmp = p_GetComp(*p, r);
1711 while ( ( (*p)!=NULL ) && ( p_Comp_k_n(*p, q, ishift+1, r) ) && (p_GetComp(*p, r) == cmp) )
1712 {
1713 p_LmDelete(p,r);
1714 // Print("while: ");p_wrp(*p,r);Print(" ");
1715 }
1716 // p_wrp(*p,r);Print(" ");
1717 // PrintS("end\n");
1718 p_LmDelete(&q,r);
1719}

◆ p_LmDivisibleBy()

static BOOLEAN p_LmDivisibleBy ( poly  a,
poly  b,
const ring  r 
)
inlinestatic

Definition at line 1891 of file p_polys.h.

1892{
1894 pIfThen1(a != NULL, p_LmCheckPolyRing1(b, r));
1895 if (p_GetComp(a, r) == 0 || p_GetComp(a,r) == p_GetComp(b,r))
1896 return _p_LmDivisibleByNoComp(a, b, r);
1897 return FALSE;
1898}

◆ p_LmDivisibleByNoComp() [1/2]

static BOOLEAN p_LmDivisibleByNoComp ( poly  a,
const ring  ra,
poly  b,
const ring  rb 
)
inlinestatic

Definition at line 1884 of file p_polys.h.

1885{
1888 return _p_LmDivisibleByNoComp(a, ra, b, rb);
1889}

◆ p_LmDivisibleByNoComp() [2/2]

static BOOLEAN p_LmDivisibleByNoComp ( poly  a,
poly  b,
const ring  r 
)
inlinestatic

Definition at line 1877 of file p_polys.h.

1878{
1879 p_LmCheckPolyRing1(a, r);
1881 return _p_LmDivisibleByNoComp(a, b, r);
1882}

◆ p_LmDivisibleByPart()

static BOOLEAN p_LmDivisibleByPart ( poly  a,
poly  b,
const ring  r,
const int  start,
const int  end 
)
inlinestatic

Definition at line 1862 of file p_polys.h.

1863{
1865 pIfThen1(a != NULL, p_LmCheckPolyRing1(b, r));
1866 if (p_GetComp(a, r) == 0 || p_GetComp(a,r) == p_GetComp(b,r))
1867 return _p_LmDivisibleByNoCompPart(a, r, b, r,start, end);
1868 return FALSE;
1869}

◆ p_LmExpVectorAddIsOk()

static BOOLEAN p_LmExpVectorAddIsOk ( const poly  p1,
const poly  p2,
const ring  r 
)
inlinestatic

Definition at line 1999 of file p_polys.h.

2001{
2002 p_LmCheckPolyRing(p1, r);
2003 p_LmCheckPolyRing(p2, r);
2004 unsigned long l1, l2, divmask = r->divmask;
2005 int i;
2006
2007 for (i=0; i<r->VarL_Size; i++)
2008 {
2009 l1 = p1->exp[r->VarL_Offset[i]];
2010 l2 = p2->exp[r->VarL_Offset[i]];
2011 // do the divisiblity trick
2012 if ( (l1 > ULONG_MAX - l2) ||
2013 (((l1 & divmask) ^ (l2 & divmask)) != ((l1 + l2) & divmask)))
2014 return FALSE;
2015 }
2016 return TRUE;
2017}

◆ p_LmFree() [1/2]

static void p_LmFree ( poly *  p,
ring   
)
inlinestatic

Definition at line 696 of file p_polys.h.

698{
700 poly h = *p;
701 *p = pNext(h);
702 #ifdef XALLOC_BIN
703 omFreeBin(h,r->PolyBin);
704 #else
706 #endif
707}

◆ p_LmFree() [2/2]

static void p_LmFree ( poly  p,
ring   
)
inlinestatic

Definition at line 683 of file p_polys.h.

685{
687 #ifdef XALLOC_BIN
688 omFreeBin(p,r->PolyBin);
689 #else
691 #endif
692}

◆ p_LmFreeAndNext()

static poly p_LmFreeAndNext ( poly  p,
ring   
)
inlinestatic

Definition at line 711 of file p_polys.h.

713{
715 poly pnext = pNext(p);
716 #ifdef XALLOC_BIN
717 omFreeBin(p,r->PolyBin);
718 #else
720 #endif
721 return pnext;
722}

◆ p_LmInit() [1/3]

static poly p_LmInit ( poly  p,
const ring  r 
)
inlinestatic

Definition at line 1335 of file p_polys.h.

1336{
1338 poly np;
1339 omTypeAllocBin(poly, np, r->PolyBin);
1340 p_SetRingOfLm(np, r);
1341 memcpy(np->exp, p->exp, r->ExpL_Size*sizeof(long));
1342 pNext(np) = NULL;
1343 pSetCoeff0(np, NULL);
1344 return np;
1345}

◆ p_LmInit() [2/3]

static poly p_LmInit ( poly  s_p,
const ring  s_r,
const ring  d_r 
)
inlinestatic

Definition at line 1363 of file p_polys.h.

1364{
1365 pAssume1(d_r != NULL);
1366 return p_LmInit(s_p, s_r, d_r, d_r->PolyBin);
1367}

◆ p_LmInit() [3/3]

static poly p_LmInit ( poly  s_p,
const ring  s_r,
const ring  d_r,
omBin  d_bin 
)
inlinestatic

Definition at line 1346 of file p_polys.h.

1347{
1350 pAssume1(d_r->N <= s_r->N);
1351 poly d_p = p_Init(d_r, d_bin);
1352 for (unsigned i=d_r->N; i!=0; i--)
1353 {
1354 p_SetExp(d_p, i, p_GetExp(s_p, i,s_r), d_r);
1355 }
1356 if (rRing_has_Comp(d_r))
1357 {
1359 }
1360 p_Setm(d_p, d_r);
1361 return d_p;
1362}

◆ p_LmIsConstant()

static BOOLEAN p_LmIsConstant ( const poly  p,
const ring  r 
)
inlinestatic

Definition at line 1023 of file p_polys.h.

1024{
1025 if (p_LmIsConstantComp(p, r))
1026 return (p_GetComp(p, r) == 0);
1027 return FALSE;
1028}

◆ p_LmIsConstantComp()

static BOOLEAN p_LmIsConstantComp ( const poly  p,
const ring  r 
)
inlinestatic

Definition at line 1006 of file p_polys.h.

1007{
1008 //p_LmCheckPolyRing(p, r);
1009 int i = r->VarL_Size - 1;
1010
1011 do
1012 {
1013 if (p->exp[r->VarL_Offset[i]] != 0)
1014 return FALSE;
1015 i--;
1016 }
1017 while (i >= 0);
1018 return TRUE;
1019}

◆ p_LmShallowCopyDelete()

static poly p_LmShallowCopyDelete ( poly  p,
const ring  r 
)
inlinestatic

Definition at line 1393 of file p_polys.h.

1394{
1396 pAssume1(omSizeWOfBin(bin) == omSizeWOfBin(r->PolyBin));
1397 poly new_p = p_New(r);
1398 memcpy(new_p->exp, p->exp, r->ExpL_Size*sizeof(long));
1400 pNext(new_p) = pNext(p);
1402 return new_p;
1403}

◆ p_LmShortDivisibleBy()

static BOOLEAN p_LmShortDivisibleBy ( poly  a,
unsigned long  sev_a,
poly  b,
unsigned long  not_sev_b,
const ring  r 
)
inlinestatic

Definition at line 1910 of file p_polys.h.

1912{
1913 p_LmCheckPolyRing1(a, r);
1915#ifndef PDIV_DEBUG
1916 _pPolyAssume2(p_GetShortExpVector(a, r) == sev_a, a, r);
1918
1919 if (sev_a & not_sev_b)
1920 {
1922 return FALSE;
1923 }
1924 return p_LmDivisibleBy(a, b, r);
1925#else
1926 return pDebugLmShortDivisibleBy(a, sev_a, r, b, not_sev_b, r);
1927#endif
1928}

◆ p_LmShortDivisibleByNoComp()

static BOOLEAN p_LmShortDivisibleByNoComp ( poly  a,
unsigned long  sev_a,
poly  b,
unsigned long  not_sev_b,
const ring  r 
)
inlinestatic

Definition at line 1930 of file p_polys.h.

1932{
1933 p_LmCheckPolyRing1(a, r);
1935#ifndef PDIV_DEBUG
1936 _pPolyAssume2(p_GetShortExpVector(a, r) == sev_a, a, r);
1938
1939 if (sev_a & not_sev_b)
1940 {
1942 return FALSE;
1943 }
1944 return p_LmDivisibleByNoComp(a, b, r);
1945#else
1947#endif
1948}

◆ p_LowVar()

int p_LowVar ( poly  p,
const ring  r 
)

the minimal index of used variables - 1

Definition at line 4729 of file p_polys.cc.

4730{
4731 int k,l,lex;
4732
4733 if (p == NULL) return -1;
4734
4735 k = 32000;/*a very large dummy value*/
4736 while (p != NULL)
4737 {
4738 l = 1;
4739 lex = p_GetExp(p,l,r);
4740 while ((l < (rVar(r))) && (lex == 0))
4741 {
4742 l++;
4743 lex = p_GetExp(p,l,r);
4744 }
4745 l--;
4746 if (l < k) k = l;
4747 pIter(p);
4748 }
4749 return k;
4750}

◆ p_LtCmp()

static int p_LtCmp ( poly  p,
poly  q,
const ring  r 
)
inlinestatic

Definition at line 1621 of file p_polys.h.

1622{
1623 int res = p_LmCmp(p,q,r);
1624 if(res == 0)
1625 {
1626 if(p_GetCoeff(p,r) == NULL || p_GetCoeff(q,r) == NULL)
1627 return res;
1628 number pc = n_Copy(p_GetCoeff(p,r),r->cf);
1629 number qc = n_Copy(p_GetCoeff(q,r),r->cf);
1630 if(!n_GreaterZero(pc,r->cf))
1631 pc = n_InpNeg(pc,r->cf);
1632 if(!n_GreaterZero(qc,r->cf))
1633 qc = n_InpNeg(qc,r->cf);
1634 if(n_Greater(pc,qc,r->cf))
1635 res = 1;
1636 else if(n_Greater(qc,pc,r->cf))
1637 res = -1;
1638 else if(n_Equal(pc,qc,r->cf))
1639 res = 0;
1640 n_Delete(&pc,r->cf);
1641 n_Delete(&qc,r->cf);
1642 }
1643 return res;
1644}

◆ p_LtCmpNoAbs()

static int p_LtCmpNoAbs ( poly  p,
poly  q,
const ring  r 
)
inlinestatic

Definition at line 1647 of file p_polys.h.

1648{
1649 int res = p_LmCmp(p,q,r);
1650 if(res == 0)
1651 {
1652 if(p_GetCoeff(p,r) == NULL || p_GetCoeff(q,r) == NULL)
1653 return res;
1654 number pc = p_GetCoeff(p,r);
1655 number qc = p_GetCoeff(q,r);
1656 if(n_Greater(pc,qc,r->cf))
1657 res = 1;
1658 if(n_Greater(qc,pc,r->cf))
1659 res = -1;
1660 if(n_Equal(pc,qc,r->cf))
1661 res = 0;
1662 }
1663 return res;
1664}

◆ p_LtCmpOrdSgnDiffM()

static int p_LtCmpOrdSgnDiffM ( poly  p,
poly  q,
const ring  r 
)
inlinestatic

Definition at line 1669 of file p_polys.h.

1670{
1671 return(p_LtCmp(p,q,r) == r->OrdSgn);
1672}

◆ p_LtCmpOrdSgnDiffP()

static int p_LtCmpOrdSgnDiffP ( poly  p,
poly  q,
const ring  r 
)
inlinestatic

Definition at line 1678 of file p_polys.h.

1679{
1680 if(r->OrdSgn == 1)
1681 {
1682 return(p_LmCmp(p,q,r) == -1);
1683 }
1684 else
1685 {
1686 return(p_LtCmp(p,q,r) != -1);
1687 }
1688}

◆ p_LtCmpOrdSgnEqM()

static int p_LtCmpOrdSgnEqM ( poly  p,
poly  q,
const ring  r 
)
inlinestatic

Definition at line 1694 of file p_polys.h.

1695{
1696 return(p_LtCmp(p,q,r) == -r->OrdSgn);
1697}

◆ p_LtCmpOrdSgnEqP()

static int p_LtCmpOrdSgnEqP ( poly  p,
poly  q,
const ring  r 
)
inlinestatic

Definition at line 1703 of file p_polys.h.

1704{
1705 return(p_LtCmp(p,q,r) == r->OrdSgn);
1706}

◆ p_MaxComp() [1/2]

static long p_MaxComp ( poly  p,
ring  lmRing 
)
inlinestatic

Definition at line 311 of file p_polys.h.

311{return p_MaxComp(p,lmRing,lmRing);}
static long p_MaxComp(poly p, ring lmRing, ring tailRing)
Definition p_polys.h:292

◆ p_MaxComp() [2/2]

static long p_MaxComp ( poly  p,
ring  lmRing,
ring  tailRing 
)
inlinestatic

Definition at line 292 of file p_polys.h.

293{
294 long result,i;
295
296 if(p==NULL) return 0;
298 if (result != 0)
299 {
300 loop
301 {
302 pIter(p);
303 if(p==NULL) break;
304 i = p_GetComp(p, tailRing);
305 if (i>result) result = i;
306 }
307 }
308 return result;
309}

◆ p_MaxExpPerVar()

int p_MaxExpPerVar ( poly  p,
int  i,
const ring  r 
)

max exponent of variable x_i in p

Definition at line 5041 of file p_polys.cc.

5042{
5043 int m=0;
5044 while(p!=NULL)
5045 {
5046 int mm=p_GetExp(p,i,r);
5047 if (mm>m) m=mm;
5048 pIter(p);
5049 }
5050 return m;
5051}

◆ p_MDivide()

poly p_MDivide ( poly  a,
poly  b,
const ring  r 
)

Definition at line 1493 of file p_polys.cc.

1494{
1495 assume((p_GetComp(a,r)==p_GetComp(b,r)) || (p_GetComp(b,r)==0));
1496 int i;
1497 poly result = p_Init(r);
1498
1499 for(i=(int)r->N; i; i--)
1500 p_SetExp(result,i, p_GetExp(a,i,r)- p_GetExp(b,i,r),r);
1501 p_SetComp(result, p_GetComp(a,r) - p_GetComp(b,r),r);
1502 p_Setm(result,r);
1503 return result;
1504}

◆ p_MemAdd_NegWeightAdjust()

static void p_MemAdd_NegWeightAdjust ( poly  p,
const ring  r 
)
inlinestatic

Definition at line 1292 of file p_polys.h.

1293{
1294 if (r->NegWeightL_Offset != NULL)
1295 {
1296 for (int i=r->NegWeightL_Size-1; i>=0; i--)
1297 {
1298 p->exp[r->NegWeightL_Offset[i]] -= POLY_NEGWEIGHT_OFFSET;
1299 }
1300 }
1301}

◆ p_MemSub_NegWeightAdjust()

static void p_MemSub_NegWeightAdjust ( poly  p,
const ring  r 
)
inlinestatic

Definition at line 1302 of file p_polys.h.

1303{
1304 if (r->NegWeightL_Offset != NULL)
1305 {
1306 for (int i=r->NegWeightL_Size-1; i>=0; i--)
1307 {
1308 p->exp[r->NegWeightL_Offset[i]] += POLY_NEGWEIGHT_OFFSET;
1309 }
1310 }
1311}

◆ p_Merge_q()

static poly p_Merge_q ( poly  p,
poly  q,
const ring  r 
)
inlinestatic

Definition at line 1212 of file p_polys.h.

1213{
1214 assume( (p != q) || (p == NULL && q == NULL) );
1215 return r->p_Procs->p_Merge_q(p, q, r);
1216}

◆ p_MinComp() [1/2]

static long p_MinComp ( poly  p,
ring  lmRing 
)
inlinestatic

Definition at line 332 of file p_polys.h.

332{return p_MinComp(p,lmRing,lmRing);}
static long p_MinComp(poly p, ring lmRing, ring tailRing)
Definition p_polys.h:313

◆ p_MinComp() [2/2]

static long p_MinComp ( poly  p,
ring  lmRing,
ring  tailRing 
)
inlinestatic

Definition at line 313 of file p_polys.h.

314{
315 long result,i;
316
317 if(p==NULL) return 0;
319 if (result != 0)
320 {
321 loop
322 {
323 pIter(p);
324 if(p==NULL) break;
325 i = p_GetComp(p,tailRing);
326 if (i<result) result = i;
327 }
328 }
329 return result;
330}

◆ p_MinDeg()

int p_MinDeg ( poly  p,
intvec w,
const ring  R 
)

Definition at line 4497 of file p_polys.cc.

4498{
4499 if(p==NULL)
4500 return -1;
4501 int d=-1;
4502 while(p!=NULL)
4503 {
4504 int d0=0;
4505 for(int j=0;j<rVar(R);j++)
4506 if(w==NULL||j>=w->length())
4507 d0+=p_GetExp(p,j+1,R);
4508 else
4509 d0+=(*w)[j]*p_GetExp(p,j+1,R);
4510 if(d0<d||d==-1)
4511 d=d0;
4512 pIter(p);
4513 }
4514 return d;
4515}

◆ p_mInit()

poly p_mInit ( const char s,
BOOLEAN ok,
const ring  r 
)

Definition at line 1443 of file p_polys.cc.

1444{
1445 poly p;
1446 char *sst=(char*)st;
1447 BOOLEAN neg=FALSE;
1448 if (sst[0]=='-') { neg=TRUE; sst=sst+1; }
1449 const char *s=p_Read(sst,p,r);
1450 if (*s!='\0')
1451 {
1452 if ((s!=sst)&&isdigit(sst[0]))
1453 {
1455 }
1456 ok=FALSE;
1457 if (p!=NULL)
1458 {
1459 if (pGetCoeff(p)==NULL) p_LmFree(p,r);
1460 else p_LmDelete(p,r);
1461 }
1462 return NULL;
1463 }
1464 p_Test(p,r);
1465 ok=!errorreported;
1466 if (neg) p=p_Neg(p,r);
1467 return p;
1468}
VAR short errorreported
Definition feFopen.cc:23
const char * p_Read(const char *st, poly &rc, const ring r)
Definition p_polys.cc:1371

◆ p_Minus_mm_Mult_qq() [1/2]

static poly p_Minus_mm_Mult_qq ( poly  p,
const poly  m,
const poly  q,
const ring  r 
)
inlinestatic

Definition at line 1081 of file p_polys.h.

1082{
1083 int shorter;
1084
1085 return r->p_Procs->p_Minus_mm_Mult_qq(p, m, q, shorter, NULL, r);
1086}

◆ p_Minus_mm_Mult_qq() [2/2]

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 
)
inlinestatic

Definition at line 1070 of file p_polys.h.

1072{
1073 int shorter;
1074 const poly res = r->p_Procs->p_Minus_mm_Mult_qq(p, m, q, shorter, spNoether, r);
1075 lp += lq - shorter;
1076// assume( lp == pLength(res) );
1077 return res;
1078}

◆ p_mm_Mult()

static poly p_mm_Mult ( poly  p,
poly  m,
const ring  r 
)
inlinestatic

Definition at line 1061 of file p_polys.h.

1062{
1063 if (p==NULL) return NULL;
1064 if (p_LmIsConstant(m, r))
1065 return __p_Mult_nn(p, pGetCoeff(m), r);
1066 else
1067 return r->p_Procs->p_mm_Mult(p, m, r);
1068}

◆ p_Mult_mm()

static poly p_Mult_mm ( poly  p,
poly  m,
const ring  r 
)
inlinestatic

Definition at line 1051 of file p_polys.h.

1052{
1053 if (p==NULL) return NULL;
1054 if (p_LmIsConstant(m, r))
1055 return __p_Mult_nn(p, pGetCoeff(m), r);
1056 else
1057 return r->p_Procs->p_Mult_mm(p, m, r);
1058}

◆ p_Mult_nn() [1/2]

static poly p_Mult_nn ( poly  p,
number  n,
const ring  lmRing,
const ring  tailRing 
)
inlinestatic

Definition at line 973 of file p_polys.h.

975{
976 assume(p!=NULL);
977#ifndef PDEBUG
978 if (lmRing == tailRing)
979 return p_Mult_nn(p, n, tailRing);
980#endif
981 poly pnext = pNext(p);
982 pNext(p) = NULL;
983 p = lmRing->p_Procs->p_Mult_nn(p, n, lmRing);
984 if (pnext!=NULL)
985 {
986 pNext(p) = tailRing->p_Procs->p_Mult_nn(pnext, n, tailRing);
987 }
988 return p;
989}
static poly p_Mult_nn(poly p, number n, const ring r)
Definition p_polys.h:958

◆ p_Mult_nn() [2/2]

static poly p_Mult_nn ( poly  p,
number  n,
const ring  r 
)
inlinestatic

Definition at line 958 of file p_polys.h.

959{
960 if (p==NULL) return NULL;
961 if (n_IsOne(n, r->cf))
962 return p;
963 else if (n_IsZero(n, r->cf))
964 {
965 p_Delete(&p, r); // NOTE: without p_Delete - memory leak!
966 return NULL;
967 }
968 else
969 return r->p_Procs->p_Mult_nn(p, n, r);
970}

◆ p_Mult_q()

static poly p_Mult_q ( poly  p,
poly  q,
const ring  r 
)
inlinestatic

Definition at line 1114 of file p_polys.h.

1115{
1116 assume( (p != q) || (p == NULL && q == NULL) );
1117
1118 if (p == NULL)
1119 {
1120 p_Delete(&q, r);
1121 return NULL;
1122 }
1123 if (q == NULL)
1124 {
1125 p_Delete(&p, r);
1126 return NULL;
1127 }
1128
1129 if (pNext(p) == NULL)
1130 {
1131 q = r->p_Procs->p_mm_Mult(q, p, r);
1132 p_LmDelete(&p, r);
1133 return q;
1134 }
1135
1136 if (pNext(q) == NULL)
1137 {
1138 p = r->p_Procs->p_Mult_mm(p, q, r);
1139 p_LmDelete(&q, r);
1140 return p;
1141 }
1142#if defined(HAVE_PLURAL) || defined(HAVE_SHIFTBBA)
1143 if (rIsNCRing(r))
1144 return _nc_p_Mult_q(p, q, r);
1145 else
1146#endif
1147 return _p_Mult_q(p, q, 0, r);
1148}
poly _nc_p_Mult_q(poly p, poly q, const ring r)
general NC-multiplication with destruction
Definition old.gring.cc:215
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:313

◆ p_MultExp()

static long p_MultExp ( poly  p,
int  v,
long  ee,
ring  r 
)
inlinestatic

Definition at line 621 of file p_polys.h.

622{
624 long e = p_GetExp(p,v,r);
625 e *= ee;
626 return p_SetExp(p,v,e,r);
627}

◆ p_Neg()

static poly p_Neg ( poly  p,
const ring  r 
)
inlinestatic

Definition at line 1107 of file p_polys.h.

1108{
1109 return r->p_Procs->p_Neg(p, r);
1110}

◆ p_New() [1/2]

static poly p_New ( const ring  ,
omBin  bin 
)
inlinestatic

Definition at line 664 of file p_polys.h.

666{
667 p_CheckRing2(r);
668 pAssume2(bin != NULL && omSizeWOfBin(r->PolyBin) == omSizeWOfBin(bin));
669 poly p;
670 omTypeAllocBin(poly, p, bin);
671 p_SetRingOfLm(p, r);
672 return p;
673}
#define p_CheckRing2(r)
Definition monomials.h:200

◆ p_New() [2/2]

static poly p_New ( ring  r)
inlinestatic

Definition at line 675 of file p_polys.h.

676{
677 return p_New(r, r->PolyBin);
678}

◆ p_Norm()

void p_Norm ( poly  p1,
const ring  r 
)

Definition at line 3740 of file p_polys.cc.

3741{
3742 if (LIKELY(rField_is_Ring(r)))
3743 {
3744 if(!n_GreaterZero(pGetCoeff(p1),r->cf)) p1 = p_Neg(p1,r);
3745 if (!n_IsUnit(pGetCoeff(p1), r->cf)) return;
3746 // Werror("p_Norm not possible in the case of coefficient rings.");
3747 }
3748 else if (LIKELY(p1!=NULL))
3749 {
3750 if (UNLIKELY(pNext(p1)==NULL))
3751 {
3752 p_SetCoeff(p1,n_Init(1,r->cf),r);
3753 return;
3754 }
3755 if (!n_IsOne(pGetCoeff(p1),r->cf))
3756 {
3757 number k = pGetCoeff(p1);
3758 pSetCoeff0(p1,n_Init(1,r->cf));
3759 poly h = pNext(p1);
3760 if (LIKELY(rField_is_Zp(r)))
3761 {
3762 if (r->cf->ch>32003)
3763 {
3764 number inv=n_Invers(k,r->cf);
3765 while (h!=NULL)
3766 {
3767 number c=n_Mult(pGetCoeff(h),inv,r->cf);
3768 // no need to normalize
3769 p_SetCoeff(h,c,r);
3770 pIter(h);
3771 }
3772 // no need for n_Delete for Zp: n_Delete(&inv,r->cf);
3773 }
3774 else
3775 {
3776 while (h!=NULL)
3777 {
3778 number c=n_Div(pGetCoeff(h),k,r->cf);
3779 // no need to normalize
3780 p_SetCoeff(h,c,r);
3781 pIter(h);
3782 }
3783 }
3784 }
3785 else if(getCoeffType(r->cf)==n_algExt)
3786 {
3787 n_Normalize(k,r->cf);
3788 number inv=n_Invers(k,r->cf);
3789 while (h!=NULL)
3790 {
3791 number c=n_Mult(pGetCoeff(h),inv,r->cf);
3792 // no need to normalize
3793 // normalize already in nMult: Zp_a, Q_a
3794 p_SetCoeff(h,c,r);
3795 pIter(h);
3796 }
3797 n_Delete(&inv,r->cf);
3798 n_Delete(&k,r->cf);
3799 }
3800 else
3801 {
3802 n_Normalize(k,r->cf);
3803 while (h!=NULL)
3804 {
3805 number c=n_Div(pGetCoeff(h),k,r->cf);
3806 // no need to normalize: Z/p, R
3807 // remains: Q
3808 if (rField_is_Q(r)) n_Normalize(c,r->cf);
3809 p_SetCoeff(h,c,r);
3810 pIter(h);
3811 }
3812 n_Delete(&k,r->cf);
3813 }
3814 }
3815 else
3816 {
3817 //if (r->cf->cfNormalize != nDummy2) //TODO: OPTIMIZE
3818 if (rField_is_Q(r))
3819 {
3820 poly h = pNext(p1);
3821 while (h!=NULL)
3822 {
3823 n_Normalize(pGetCoeff(h),r->cf);
3824 pIter(h);
3825 }
3826 }
3827 }
3828 }
3829}
#define UNLIKELY(X)
Definition auxiliary.h:404
#define LIKELY(X)
Definition auxiliary.h:403

◆ p_Normalize()

void p_Normalize ( poly  p,
const ring  r 
)

Definition at line 3834 of file p_polys.cc.

3835{
3836 const coeffs cf=r->cf;
3837 /* Z/p, GF(p,n), R, long R/C, Nemo rings */
3838 if (cf->cfNormalize==ndNormalize)
3839 return;
3840 while (p!=NULL)
3841 {
3842 // no test befor n_Normalize: n_Normalize should fix problems
3844 pIter(p);
3845 }
3846}
void ndNormalize(number &, const coeffs)
Definition numbers.cc:185

◆ p_NSet()

poly p_NSet ( number  n,
const ring  r 
)

returns the poly representing the number n, destroys n

Definition at line 1474 of file p_polys.cc.

1475{
1476 if (n_IsZero(n,r->cf))
1477 {
1478 n_Delete(&n, r->cf);
1479 return NULL;
1480 }
1481 else
1482 {
1483 poly rc = p_Init(r);
1484 pSetCoeff0(rc,n);
1485 return rc;
1486 }
1487}

◆ p_One()

poly p_One ( const ring  r)

Definition at line 1314 of file p_polys.cc.

1315{
1316 poly rc = p_Init(r);
1317 pSetCoeff0(rc,n_Init(1,r->cf));
1318 return rc;
1319}

◆ p_OneComp()

BOOLEAN p_OneComp ( poly  p,
const ring  r 
)

return TRUE if all monoms have the same component

Definition at line 1209 of file p_polys.cc.

1210{
1211 if(p!=NULL)
1212 {
1213 long i = p_GetComp(p, r);
1214 while (pNext(p)!=NULL)
1215 {
1216 pIter(p);
1217 if(i != p_GetComp(p, r)) return FALSE;
1218 }
1219 }
1220 return TRUE;
1221}

◆ p_PermPoly()

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 at line 4151 of file p_polys.cc.

4153{
4154#if 0
4155 p_Test(p, oldRing);
4156 PrintS("p_PermPoly::p: "); p_Write(p, oldRing, oldRing);
4157#endif
4158 const int OldpVariables = rVar(oldRing);
4159 poly result = NULL;
4160 poly result_last = NULL;
4161 poly aq = NULL; /* the map coefficient */
4162 poly qq; /* the mapped monomial */
4163 assume(dst != NULL);
4164 assume(dst->cf != NULL);
4165 #ifdef HAVE_PLURAL
4166 poly tmp_mm=p_One(dst);
4167 #endif
4168 while (p != NULL)
4169 {
4170 // map the coefficient
4171 if ( ((OldPar == 0) || (par_perm == NULL) || rField_is_GF(oldRing) || (nMap==ndCopyMap))
4172 && (nMap != NULL) )
4173 {
4174 qq = p_Init(dst);
4175 assume( nMap != NULL );
4176 number n = nMap(p_GetCoeff(p, oldRing), oldRing->cf, dst->cf);
4177 n_Test (n,dst->cf);
4178 if ( nCoeff_is_algExt(dst->cf) )
4179 n_Normalize(n, dst->cf);
4180 p_GetCoeff(qq, dst) = n;// Note: n can be a ZERO!!!
4181 }
4182 else
4183 {
4184 qq = p_One(dst);
4185// aq = naPermNumber(p_GetCoeff(p, oldRing), par_perm, OldPar, oldRing); // no dst???
4186// poly n_PermNumber(const number z, const int *par_perm, const int P, const ring src, const ring dst)
4188 p_Test(aq, dst);
4189 if ( nCoeff_is_algExt(dst->cf) )
4191 if (aq == NULL)
4192 p_SetCoeff(qq, n_Init(0, dst->cf),dst); // Very dirty trick!!!
4193 p_Test(aq, dst);
4194 }
4195 if (rRing_has_Comp(dst))
4197 if ( n_IsZero(pGetCoeff(qq), dst->cf) )
4198 {
4199 p_LmDelete(&qq,dst);
4200 qq = NULL;
4201 }
4202 else
4203 {
4204 // map pars:
4205 int mapped_to_par = 0;
4206 for(int i = 1; i <= OldpVariables; i++)
4207 {
4208 int e = p_GetExp(p, i, oldRing);
4209 if (e != 0)
4210 {
4211 if (perm==NULL)
4212 p_SetExp(qq, i, e, dst);
4213 else if (perm[i]>0)
4214 {
4215 #ifdef HAVE_PLURAL
4216 if(use_mult)
4217 {
4218 p_SetExp(tmp_mm,perm[i],e,dst);
4219 p_Setm(tmp_mm,dst);
4221 p_SetExp(tmp_mm,perm[i],0,dst);
4222
4223 }
4224 else
4225 #endif
4226 p_AddExp(qq,perm[i], e/*p_GetExp( p,i,oldRing)*/, dst);
4227 }
4228 else if (perm[i]<0)
4229 {
4230 number c = p_GetCoeff(qq, dst);
4231 if (rField_is_GF(dst))
4232 {
4233 assume( dst->cf->extRing == NULL );
4234 number ee = n_Param(1, dst);
4235 number eee;
4236 n_Power(ee, e, &eee, dst->cf); //nfDelete(ee,dst);
4237 ee = n_Mult(c, eee, dst->cf);
4238 //nfDelete(c,dst);nfDelete(eee,dst);
4239 pSetCoeff0(qq,ee);
4240 }
4241 else if (nCoeff_is_Extension(dst->cf))
4242 {
4243 const int par = -perm[i];
4244 assume( par > 0 );
4245// WarnS("longalg missing 3");
4246#if 1
4247 const coeffs C = dst->cf;
4248 assume( C != NULL );
4249 const ring R = C->extRing;
4250 assume( R != NULL );
4251 assume( par <= rVar(R) );
4252 poly pcn; // = (number)c
4253 assume( !n_IsZero(c, C) );
4254 if( nCoeff_is_algExt(C) )
4255 pcn = (poly) c;
4256 else // nCoeff_is_transExt(C)
4257 pcn = NUM((fraction)c);
4258 if (pNext(pcn) == NULL) // c->z
4259 p_AddExp(pcn, -perm[i], e, R);
4260 else /* more difficult: we have really to multiply: */
4261 {
4262 poly mmc = p_ISet(1, R);
4263 p_SetExp(mmc, -perm[i], e, R);
4264 p_Setm(mmc, R);
4265 number nnc;
4266 // convert back to a number: number nnc = mmc;
4267 if( nCoeff_is_algExt(C) )
4268 nnc = (number) mmc;
4269 else // nCoeff_is_transExt(C)
4270 nnc = ntInit(mmc, C);
4271 p_GetCoeff(qq, dst) = n_Mult((number)c, nnc, C);
4272 n_Delete((number *)&c, C);
4273 n_Delete((number *)&nnc, C);
4274 }
4275 mapped_to_par=1;
4276#endif
4277 }
4278 }
4279 else
4280 {
4281 /* this variable maps to 0 !*/
4282 p_LmDelete(&qq, dst);
4283 break;
4284 }
4285 }
4286 }
4287 if ( mapped_to_par && (qq!= NULL) && nCoeff_is_algExt(dst->cf) )
4288 {
4289 number n = p_GetCoeff(qq, dst);
4290 n_Normalize(n, dst->cf);
4291 p_GetCoeff(qq, dst) = n;
4292 }
4293 }
4294 pIter(p);
4295
4296#if 0
4297 p_Test(aq,dst);
4298 PrintS("aq: "); p_Write(aq, dst, dst);
4299#endif
4300
4301
4302#if 1
4303 if (qq!=NULL)
4304 {
4305 p_Setm(qq,dst);
4306
4307 p_Test(aq,dst);
4308 p_Test(qq,dst);
4309
4310#if 0
4311 PrintS("qq: "); p_Write(qq, dst, dst);
4312#endif
4313
4314 if (aq!=NULL)
4315 qq=p_Mult_q(aq,qq,dst);
4316 aq = qq;
4317 while (pNext(aq) != NULL) pIter(aq);
4318 if (result_last==NULL)
4319 {
4320 result=qq;
4321 }
4322 else
4323 {
4325 }
4327 aq = NULL;
4328 }
4329 else if (aq!=NULL)
4330 {
4331 p_Delete(&aq,dst);
4332 }
4333 }
4335#else
4336 // if (qq!=NULL)
4337 // {
4338 // pSetm(qq);
4339 // pTest(qq);
4340 // pTest(aq);
4341 // if (aq!=NULL) qq=pMult(aq,qq);
4342 // aq = qq;
4343 // while (pNext(aq) != NULL) pIter(aq);
4344 // pNext(aq) = result;
4345 // aq = NULL;
4346 // result = qq;
4347 // }
4348 // else if (aq!=NULL)
4349 // {
4350 // pDelete(&aq);
4351 // }
4352 //}
4353 //p = result;
4354 //result = NULL;
4355 //while (p != NULL)
4356 //{
4357 // qq = p;
4358 // pIter(p);
4359 // qq->next = NULL;
4360 // result = pAdd(result, qq);
4361 //}
4362#endif
4363 p_Test(result,dst);
4364#if 0
4365 p_Test(result,dst);
4366 PrintS("result: "); p_Write(result,dst,dst);
4367#endif
4368 #ifdef HAVE_PLURAL
4370 #endif
4371 return result;
4372}
static FORCE_INLINE number n_Param(const int iParameter, const coeffs r)
return the (iParameter^th) parameter as a NEW number NOTE: parameter numbering: 1....
Definition coeffs.h:776
static FORCE_INLINE BOOLEAN nCoeff_is_Extension(const coeffs r)
Definition coeffs.h:839
number ndCopyMap(number a, const coeffs src, const coeffs dst)
Definition numbers.cc:287
static FORCE_INLINE void n_Power(number a, int b, number *res, const coeffs r)
fill res with the power a^b
Definition coeffs.h:633
poly n_PermNumber(const number z, const int *par_perm, const int, const ring src, const ring dst)
Definition p_polys.cc:4048
poly p_ISet(long i, const ring r)
returns the poly representing the integer i
Definition p_polys.cc:1298
poly p_One(const ring r)
Definition p_polys.cc:1314
void p_Write(poly p, ring lmRing, ring tailRing)
Definition polys0.cc:342
static poly p_Mult_mm(poly p, poly m, const ring r)
Definition p_polys.h:1051
static poly p_SortAdd(poly p, const ring r, BOOLEAN revert=FALSE)
Definition p_polys.h:1219
static BOOLEAN rField_is_GF(const ring r)
Definition ring.h:526
number ntInit(long i, const coeffs cf)
Definition transext.cc:704

◆ p_Plus_mm_Mult_qq() [1/2]

static poly p_Plus_mm_Mult_qq ( poly  p,
poly  m,
poly  q,
const ring  r 
)
inlinestatic

Definition at line 1205 of file p_polys.h.

1206{
1207 int lp = 0, lq = 0;
1208 return p_Plus_mm_Mult_qq(p, m, q, lp, lq, r);
1209}
static poly p_Plus_mm_Mult_qq(poly p, poly m, poly q, int &lp, int lq, const ring r)
Definition p_polys.h:1183

◆ p_Plus_mm_Mult_qq() [2/2]

static poly p_Plus_mm_Mult_qq ( poly  p,
poly  m,
poly  q,
int lp,
int  lq,
const ring  r 
)
inlinestatic

Definition at line 1183 of file p_polys.h.

1185{
1186#ifdef HAVE_PLURAL
1187 if (rIsPluralRing(r))
1188 return nc_p_Plus_mm_Mult_qq(p, m, q, lp, lq, r);
1189#endif
1190
1191// this should be implemented more efficiently
1192 poly res;
1193 int shorter;
1195 number n_neg = n_Copy(n_old, r->cf);
1196 n_neg = n_InpNeg(n_neg, r->cf);
1197 pSetCoeff0(m, n_neg);
1198 res = r->p_Procs->p_Minus_mm_Mult_qq(p, m, q, shorter, NULL, r);
1199 lp = (lp + lq) - shorter;
1200 pSetCoeff0(m, n_old);
1201 n_Delete(&n_neg, r->cf);
1202 return res;
1203}
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
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
Definition ring.h:405

◆ p_PolyDiv()

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 divisor != NULL; p may be NULL; assumes a global monomial ordering in r; performs polynomial division of p by divisor:

  • afterwards p contains the remainder of the division, i.e., p_before = result * divisor + p_afterwards;
  • if needResult == TRUE, then the method computes and returns 'result', otherwise NULL is returned (This parametrization can be used when one is only interested in the remainder of the division. In this case, the method will be slightly faster.) leaves divisor unmodified

Definition at line 1874 of file p_polys.cc.

1875{
1876 assume(divisor != NULL);
1877 if (p == NULL) return NULL;
1878
1879 poly result = NULL;
1880 number divisorLC = p_GetCoeff(divisor, r);
1881 int divisorLE = p_GetExp(divisor, 1, r);
1882 while ((p != NULL) && (p_Deg(p, r) >= p_Deg(divisor, r)))
1883 {
1884 /* determine t = LT(p) / LT(divisor) */
1885 poly t = p_ISet(1, r);
1886 number c = n_Div(p_GetCoeff(p, r), divisorLC, r->cf);
1887 n_Normalize(c,r->cf);
1888 p_SetCoeff(t, c, r);
1889 int e = p_GetExp(p, 1, r) - divisorLE;
1890 p_SetExp(t, 1, e, r);
1891 p_Setm(t, r);
1892 if (needResult) result = p_Add_q(result, p_Copy(t, r), r);
1893 p = p_Add_q(p, p_Neg(p_Mult_q(t, p_Copy(divisor, r), r), r), r);
1894 }
1895 return result;
1896}
long p_Deg(poly a, const ring r)
Definition p_polys.cc:586

◆ p_Power()

poly p_Power ( poly  p,
int  i,
const ring  r 
)

Definition at line 2201 of file p_polys.cc.

2202{
2203 poly rc=NULL;
2204
2205 if (i==0)
2206 {
2207 p_Delete(&p,r);
2208 return p_One(r);
2209 }
2210
2211 if(p!=NULL)
2212 {
2213 if ( (i > 0) && ((unsigned long ) i > (r->bitmask))
2215 && (!rIsLPRing(r))
2216 #endif
2217 )
2218 {
2219 Werror("exponent %d is too large, max. is %ld",i,r->bitmask);
2220 return NULL;
2221 }
2222 switch (i)
2223 {
2224// cannot happen, see above
2225// case 0:
2226// {
2227// rc=pOne();
2228// pDelete(&p);
2229// break;
2230// }
2231 case 1:
2232 rc=p;
2233 break;
2234 case 2:
2235 rc=p_Mult_q(p_Copy(p,r),p,r);
2236 break;
2237 default:
2238 if (i < 0)
2239 {
2240 p_Delete(&p,r);
2241 return NULL;
2242 }
2243 else
2244 {
2245#ifdef HAVE_PLURAL
2246 if (rIsNCRing(r)) /* in the NC case nothing helps :-( */
2247 {
2248 int j=i;
2249 rc = p_Copy(p,r);
2250 while (j>1)
2251 {
2252 rc = p_Mult_q(p_Copy(p,r),rc,r);
2253 j--;
2254 }
2255 p_Delete(&p,r);
2256 return rc;
2257 }
2258#endif
2259 rc = pNext(p);
2260 if (rc == NULL)
2261 return p_MonPower(p,i,r);
2262 /* else: binom ?*/
2263 int char_p=rInternalChar(r);
2264 if ((char_p>0) && (i>char_p)
2265 && ((rField_is_Zp(r,char_p)
2266 || (rField_is_Zp_a(r,char_p)))))
2267 {
2268 poly h=p_Pow_charp(p_Copy(p,r),char_p,r);
2269 int rest=i-char_p;
2270 while (rest>=char_p)
2271 {
2272 rest-=char_p;
2274 }
2275 poly res=h;
2276 if (rest>0)
2277 res=p_Mult_q(p_Power(p_Copy(p,r),rest,r),h,r);
2278 p_Delete(&p,r);
2279 return res;
2280 }
2281 if ((pNext(rc) != NULL)
2282 || rField_is_Ring(r)
2283 )
2284 return p_Pow(p,i,r);
2285 if ((char_p==0) || (i<=char_p))
2286 return p_TwoMonPower(p,i,r);
2287 return p_Pow(p,i,r);
2288 }
2289 /*end default:*/
2290 }
2291 }
2292 return rc;
2293}
poly p_Power(poly p, int i, const ring r)
Definition p_polys.cc:2201
static poly p_TwoMonPower(poly p, int exp, const ring r)
Definition p_polys.cc:2110
static poly p_Pow_charp(poly p, int i, const ring r)
Definition p_polys.cc:2189
static poly p_MonPower(poly p, int exp, const ring r)
Definition p_polys.cc:2004
static poly p_Pow(poly p, int i, const ring r)
Definition p_polys.cc:2175
void Werror(const char *fmt,...)
Definition reporter.cc:189
static int rInternalChar(const ring r)
Definition ring.h:694
static BOOLEAN rIsLPRing(const ring r)
Definition ring.h:416

◆ p_ProjectiveUnique()

void p_ProjectiveUnique ( poly  p,
const ring  r 
)

Definition at line 3147 of file p_polys.cc.

3148{
3149 if( ph == NULL )
3150 return;
3151
3152 const coeffs C = r->cf;
3153
3154 number h;
3155 poly p;
3156
3157 if (nCoeff_is_Ring(C))
3158 {
3159 p_ContentForGB(ph,r);
3160 if(!n_GreaterZero(pGetCoeff(ph),C)) ph = p_Neg(ph,r);
3162 return;
3163 }
3164
3166 {
3167 if(!n_GreaterZero(pGetCoeff(ph),C)) ph = p_Neg(ph,r);
3168 return;
3169 }
3170 p = ph;
3171
3172 assume(p != NULL);
3173
3174 if(pNext(p)==NULL) // a monomial
3175 {
3176 p_SetCoeff(p, n_Init(1, C), r);
3177 return;
3178 }
3179
3180 assume(pNext(p)!=NULL);
3181
3182 if(!nCoeff_is_Q(C) && !nCoeff_is_transExt(C))
3183 {
3184 h = p_GetCoeff(p, C);
3185 number hInv = n_Invers(h, C);
3186 pIter(p);
3187 while (p!=NULL)
3188 {
3189 p_SetCoeff(p, n_Mult(p_GetCoeff(p, C), hInv, C), r);
3190 pIter(p);
3191 }
3192 n_Delete(&hInv, C);
3193 p = ph;
3194 p_SetCoeff(p, n_Init(1, C), r);
3195 }
3196
3197 p_Cleardenom(ph, r); //removes also Content
3198
3199
3200 /* normalize ph over a transcendental extension s.t.
3201 lead (ph) is > 0 if extRing->cf == Q
3202 or lead (ph) is monic if extRing->cf == Zp*/
3203 if (nCoeff_is_transExt(C))
3204 {
3205 p= ph;
3206 h= p_GetCoeff (p, C);
3207 fraction f = (fraction) h;
3208 number n=p_GetCoeff (NUM (f),C->extRing->cf);
3209 if (rField_is_Q (C->extRing))
3210 {
3211 if (!n_GreaterZero(n,C->extRing->cf))
3212 {
3213 p=p_Neg (p,r);
3214 }
3215 }
3216 else if (rField_is_Zp(C->extRing))
3217 {
3218 if (!n_IsOne (n, C->extRing->cf))
3219 {
3220 n=n_Invers (n,C->extRing->cf);
3221 nMapFunc nMap;
3222 nMap= n_SetMap (C->extRing->cf, C);
3223 number ninv= nMap (n,C->extRing->cf, C);
3224 p=__p_Mult_nn (p, ninv, r);
3225 n_Delete (&ninv, C);
3226 n_Delete (&n, C->extRing->cf);
3227 }
3228 }
3229 p= ph;
3230 }
3231
3232 return;
3233}
static FORCE_INLINE BOOLEAN nCoeff_is_Ring(const coeffs r)
Definition coeffs.h:730
static FORCE_INLINE BOOLEAN nCoeff_is_Zp(const coeffs r)
Definition coeffs.h:793
poly p_Cleardenom(poly p, const ring r)
Definition p_polys.cc:2849

◆ p_Read()

const char * p_Read ( const char s,
poly &  p,
const ring  r 
)

Definition at line 1371 of file p_polys.cc.

1372{
1373 if (r==NULL) { rc=NULL;return st;}
1374 int i,j;
1375 rc = p_Init(r);
1376 const char *s = n_Read(st,&(p_GetCoeff(rc, r)),r->cf);
1377 if (s==st)
1378 /* i.e. it does not start with a coeff: test if it is a ringvar*/
1379 {
1380 j = r_IsRingVar(s,r->names,r->N);
1381 if (j >= 0)
1382 {
1383 p_IncrExp(rc,1+j,r);
1384 while (*s!='\0') s++;
1385 goto done;
1386 }
1387 }
1388 while (*s!='\0')
1389 {
1390 char ss[2];
1391 ss[0] = *s++;
1392 ss[1] = '\0';
1393 j = r_IsRingVar(ss,r->names,r->N);
1394 if (j >= 0)
1395 {
1396 const char *s_save=s;
1397 s = eati(s,&i);
1398 if (((unsigned long)i) > r->bitmask/2)
1399 {
1400 // exponent to large: it is not a monomial
1401 p_LmDelete(&rc,r);
1402 return s_save;
1403 }
1404 p_AddExp(rc,1+j, (long)i, r);
1405 }
1406 else
1407 {
1408 // 1st char of is not a varname
1409 // We return the parsed polynomial nevertheless. This is needed when
1410 // we are parsing coefficients in a rational function field.
1411 s--;
1412 break;
1413 }
1414 }
1415done:
1416 if (n_IsZero(pGetCoeff(rc),r->cf)) p_LmDelete(&rc,r);
1417 else
1418 {
1419#ifdef HAVE_PLURAL
1420 // in super-commutative ring
1421 // squares of anti-commutative variables are zeroes!
1422 if(rIsSCA(r))
1423 {
1424 const unsigned int iFirstAltVar = scaFirstAltVar(r);
1425 const unsigned int iLastAltVar = scaLastAltVar(r);
1426
1427 assume(rc != NULL);
1428
1429 for(unsigned int k = iFirstAltVar; k <= iLastAltVar; k++)
1430 if( p_GetExp(rc, k, r) > 1 )
1431 {
1432 p_LmDelete(&rc, r);
1433 goto finish;
1434 }
1435 }
1436#endif
1437
1438 p_Setm(rc,r);
1439 }
1440finish:
1441 return s;
1442}
static FORCE_INLINE const char * n_Read(const char *s, number *a, const coeffs r)
!!! Recommendation: This method is too cryptic to be part of the user- !!! interface....
Definition coeffs.h:599
const char * eati(const char *s, int *i)
Definition reporter.cc:373
static bool rIsSCA(const ring r)
Definition nc.h:190
static long p_IncrExp(poly p, int v, ring r)
Definition p_polys.h:591
int r_IsRingVar(const char *n, char **names, int N)
Definition ring.cc:213
static short scaLastAltVar(ring r)
Definition sca.h:25
static short scaFirstAltVar(ring r)
Definition sca.h:18

◆ p_Series()

poly p_Series ( int  n,
poly  p,
poly  u,
intvec w,
const ring  R 
)

Definition at line 4547 of file p_polys.cc.

4548{
4549 int *ww=iv2array(w,R);
4550 if(p!=NULL)
4551 {
4552 if(u==NULL)
4553 p=p_JetW(p,n,ww,R);
4554 else
4555 p=p_JetW(p_Mult_q(p,p_Invers(n-p_MinDeg(p,w,R),u,w,R),R),n,ww,R);
4556 }
4557 omFreeSize((ADDRESS)ww,(rVar(R)+1)*sizeof(int));
4558 return p;
4559}
static poly p_Invers(int n, poly u, intvec *w, const ring R)
Definition p_polys.cc:4518
int p_MinDeg(poly p, intvec *w, const ring R)
Definition p_polys.cc:4497
poly p_JetW(poly p, int m, int *w, const ring R)
Definition p_polys.cc:4479
int * iv2array(intvec *iv, const ring R)
Definition weight.cc:200

◆ p_SetCoeff()

static number p_SetCoeff ( poly  p,
number  n,
ring  r 
)
inlinestatic

Definition at line 412 of file p_polys.h.

413{
415 n_Delete(&(p->coef), r->cf);
416 (p)->coef=n;
417 return n;
418}

◆ p_SetComp()

static unsigned long p_SetComp ( poly  p,
unsigned long  c,
ring  r 
)
inlinestatic

Definition at line 247 of file p_polys.h.

248{
250 if (r->pCompIndex>=0) __p_GetComp(p,r) = c;
251 return c;
252}

◆ p_SetCompP() [1/2]

static void p_SetCompP ( poly  p,
int  i,
ring  lmRing,
ring  tailRing 
)
inlinestatic

Definition at line 281 of file p_polys.h.

282{
283 if (p != NULL)
284 {
285 p_SetComp(p, i, lmRing);
287 p_SetCompP(pNext(p), i, tailRing);
288 }
289}

◆ p_SetCompP() [2/2]

static void p_SetCompP ( poly  p,
int  i,
ring  r 
)
inlinestatic

Definition at line 254 of file p_polys.h.

255{
256 if (p != NULL)
257 {
258 p_Test(p, r);
260 {
261 do
262 {
263 p_SetComp(p, i, r);
264 p_SetmComp(p, r);
265 pIter(p);
266 }
267 while (p != NULL);
268 }
269 else
270 {
271 do
272 {
273 p_SetComp(p, i, r);
274 pIter(p);
275 }
276 while(p != NULL);
277 }
278 }
279}
BOOLEAN rOrd_SetCompRequiresSetm(const ring r)
return TRUE if p_SetComp requires p_Setm
Definition ring.cc:1995

◆ p_SetExp() [1/3]

static long p_SetExp ( poly  p,
const int  v,
const long  e,
const ring  r 
)
inlinestatic

set v^th exponent for a monomial

Definition at line 582 of file p_polys.h.

583{
585 pAssume2(v>0 && v <= r->N);
586 pAssume2(r->VarOffset[v] != -1);
587 return p_SetExp(p, e, r->bitmask, r->VarOffset[v]);
588}

◆ p_SetExp() [2/3]

static long p_SetExp ( poly  p,
const long  e,
const ring  r,
const int  VarOffset 
)
inlinestatic

Definition at line 562 of file p_polys.h.

563{
565 pAssume2(VarOffset != -1);
566 return p_SetExp(p, e, r->bitmask, VarOffset);
567}

◆ p_SetExp() [3/3]

static unsigned long p_SetExp ( poly  p,
const unsigned long  e,
const unsigned long  iBitmask,
const int  VarOffset 
)
inlinestatic

set a single variable exponent @Note: VarOffset encodes the position in p->exp

See also
p_GetExp

Definition at line 488 of file p_polys.h.

489{
490 pAssume2(e>=0);
491 pAssume2(e<=iBitmask);
492 pAssume2((VarOffset >> (24 + 6)) == 0);
493
494 // shift e to the left:
495 REGISTER int shift = VarOffset >> 24;
496 unsigned long ee = e << shift /*(VarOffset >> 24)*/;
497 // find the bits in the exponent vector
498 REGISTER int offset = (VarOffset & 0xffffff);
499 // clear the bits in the exponent vector:
500 p->exp[offset] &= ~( iBitmask << shift );
501 // insert e with |
502 p->exp[ offset ] |= ee;
503 return e;
504}

◆ p_SetExpV()

static void p_SetExpV ( poly  p,
int ev,
const ring  r 
)
inlinestatic

Definition at line 1544 of file p_polys.h.

1545{
1547 for (unsigned j = r->N; j!=0; j--)
1548 p_SetExp(p, j, ev[j], r);
1549
1550 if(ev[0]!=0) p_SetComp(p, ev[0],r);
1551 p_Setm(p, r);
1552}

◆ p_SetExpVL()

static void p_SetExpVL ( poly  p,
int64 ev,
const ring  r 
)
inlinestatic

Definition at line 1553 of file p_polys.h.

1554{
1556 for (unsigned j = r->N; j!=0; j--)
1557 p_SetExp(p, j, ev[j-1], r);
1558 p_SetComp(p, 0,r);
1559
1560 p_Setm(p, r);
1561}

◆ p_SetExpVLV()

static void p_SetExpVLV ( poly  p,
int64 ev,
int64  comp,
const ring  r 
)
inlinestatic

Definition at line 1564 of file p_polys.h.

1565{
1567 for (unsigned j = r->N; j!=0; j--)
1568 p_SetExp(p, j, ev[j-1], r);
1569 p_SetComp(p, comp,r);
1570
1571 p_Setm(p, r);
1572}

◆ p_Setm()

static void p_Setm ( poly  p,
const ring  r 
)
inlinestatic

Definition at line 233 of file p_polys.h.

234{
235 p_CheckRing2(r);
236 r->p_Setm(p, r);
237}

◆ p_SetModDeg()

void p_SetModDeg ( intvec w,
ring  r 
)

Definition at line 3694 of file p_polys.cc.

3695{
3696 if (w!=NULL)
3697 {
3698 r->pModW = w;
3699 pOldFDeg = r->pFDeg;
3700 pOldLDeg = r->pLDeg;
3701 pOldLexOrder = r->pLexOrder;
3703 r->pLexOrder = TRUE;
3704 }
3705 else
3706 {
3707 r->pModW = NULL;
3709 r->pLexOrder = pOldLexOrder;
3710 }
3711}
STATIC_VAR pLDegProc pOldLDeg
Definition p_polys.cc:3682
void pRestoreDegProcs(ring r, pFDegProc old_FDeg, pLDegProc old_lDeg)
Definition p_polys.cc:3670
STATIC_VAR BOOLEAN pOldLexOrder
Definition p_polys.cc:3683
STATIC_VAR pFDegProc pOldFDeg
Definition p_polys.cc:3681
void pSetDegProcs(ring r, pFDegProc new_FDeg, pLDegProc new_lDeg)
Definition p_polys.cc:3658
static long pModDeg(poly p, ring r)
Definition p_polys.cc:3685

◆ p_ShallowCopyDelete()

static poly p_ShallowCopyDelete ( poly  p,
const ring  r,
omBin  bin 
)
inlinestatic

Definition at line 928 of file p_polys.h.

929{
931 pAssume2(omSizeWOfBin(r->PolyBin) == omSizeWOfBin(bin));
932 return r->p_Procs->p_ShallowCopyDelete(p, r, bin);
933}

◆ p_ShallowDelete()

void p_ShallowDelete ( poly *  p,
const ring  r 
)

◆ p_Shift()

void p_Shift ( poly *  p,
int  i,
const ring  r 
)

shifts components of the vector p by i

Definition at line 4755 of file p_polys.cc.

4756{
4757 poly qp1 = *p,qp2 = *p;/*working pointers*/
4758 int j = p_MaxComp(*p,r),k = p_MinComp(*p,r);
4759
4760 if (j+i < 0) return ;
4761 BOOLEAN toPoly= ((j == -i) && (j == k));
4762 while (qp1 != NULL)
4763 {
4764 if (toPoly || (__p_GetComp(qp1,r)+i > 0))
4765 {
4766 p_AddComp(qp1,i,r);
4767 p_SetmComp(qp1,r);
4768 qp2 = qp1;
4769 pIter(qp1);
4770 }
4771 else
4772 {
4773 if (qp2 == *p)
4774 {
4775 pIter(*p);
4776 p_LmDelete(&qp2,r);
4777 qp2 = *p;
4778 qp1 = *p;
4779 }
4780 else
4781 {
4782 qp2->next = qp1->next;
4783 if (qp1!=NULL) p_LmDelete(&qp1,r);
4784 qp1 = qp2->next;
4785 }
4786 }
4787 }
4788}
return
static unsigned long p_AddComp(poly p, unsigned long v, ring r)
Definition p_polys.h:447

◆ p_SimpleContent()

void p_SimpleContent ( poly  p,
int  s,
const ring  r 
)

Definition at line 2568 of file p_polys.cc.

2569{
2570 if(TEST_OPT_CONTENTSB) return;
2571 if (ph==NULL) return;
2572 if (pNext(ph)==NULL)
2573 {
2574 p_SetCoeff(ph,n_Init(1,r->cf),r);
2575 return;
2576 }
2577 if (pNext(pNext(ph))==NULL)
2578 {
2579 return;
2580 }
2581 if (!(rField_is_Q(r))
2582 && (!rField_is_Q_a(r))
2583 && (!rField_is_Zp_a(r))
2584 && (!rField_is_Z(r))
2585 )
2586 {
2587 return;
2588 }
2589 number d=p_InitContent(ph,r);
2590 number h=d;
2591 if (n_Size(d,r->cf)<=smax)
2592 {
2593 n_Delete(&h,r->cf);
2594 //if (TEST_OPT_PROT) PrintS("G");
2595 return;
2596 }
2597
2598 poly p=ph;
2599 if (smax==1) smax=2;
2600 while (p!=NULL)
2601 {
2602#if 1
2603 d=n_SubringGcd(h,pGetCoeff(p),r->cf);
2604 n_Delete(&h,r->cf);
2605 h = d;
2606#else
2607 n_InpGcd(h,pGetCoeff(p),r->cf);
2608#endif
2609 if(n_Size(h,r->cf)<smax)
2610 {
2611 //if (TEST_OPT_PROT) PrintS("g");
2612 n_Delete(&h,r->cf);
2613 return;
2614 }
2615 pIter(p);
2616 }
2617 p = ph;
2618 if (!n_GreaterZero(pGetCoeff(p),r->cf)) h=n_InpNeg(h,r->cf);
2619 if(n_IsOne(h,r->cf))
2620 {
2621 n_Delete(&h,r->cf);
2622 return;
2623 }
2624 if (TEST_OPT_PROT) PrintS("c");
2625 while (p!=NULL)
2626 {
2627#if 1
2628 d = n_ExactDiv(pGetCoeff(p),h,r->cf);
2629 p_SetCoeff(p,d,r);
2630#else
2631 STATISTIC(n_ExactDiv); nlInpExactDiv(pGetCoeff(p),h,r->cf); // no such function... ?
2632#endif
2633 pIter(p);
2634 }
2635 n_Delete(&h,r->cf);
2636}
#define TEST_OPT_PROT
Definition options.h:103

◆ p_Size()

int p_Size ( poly  p,
const ring  r 
)

Definition at line 3257 of file p_polys.cc.

3258{
3259 int count = 0;
3260 if (r->cf->has_simple_Alloc)
3261 return pLength(p);
3262 while ( p != NULL )
3263 {
3264 count+= n_Size( pGetCoeff( p ), r->cf );
3265 pIter( p );
3266 }
3267 return count;
3268}
int status int void size_t count
Definition si_signals.h:69

◆ p_SortAdd()

static poly p_SortAdd ( poly  p,
const ring  r,
BOOLEAN  revert = FALSE 
)
inlinestatic

Definition at line 1219 of file p_polys.h.

1220{
1221 if (revert) p = pReverse(p);
1222 return sBucketSortAdd(p, r);
1223}
poly sBucketSortAdd(poly p, const ring r)
Sorts p with bucketSort: p may have equal monomials.
Definition sbuckets.cc:368

◆ p_SortMerge()

static poly p_SortMerge ( poly  p,
const ring  r,
BOOLEAN  revert = FALSE 
)
inlinestatic

Definition at line 1229 of file p_polys.h.

1230{
1231 if (revert) p = pReverse(p);
1232 return sBucketSortMerge(p, r);
1233}
poly sBucketSortMerge(poly p, const ring r)
Sorts p with bucketSort: assumes all monomials of p are different.
Definition sbuckets.cc:332

◆ p_Split()

void p_Split ( poly  p,
poly *  r 
)

Definition at line 1321 of file p_polys.cc.

1322{
1323 *h=pNext(p);
1324 pNext(p)=NULL;
1325}

◆ p_String() [1/2]

char * p_String ( poly  p,
ring  lmRing,
ring  tailRing 
)

Definition at line 322 of file polys0.cc.

323{
324 StringSetS("");
325 p_String0(p, lmRing, tailRing);
326 return StringEndS();
327}
void p_String0(poly p, ring lmRing, ring tailRing)
print p according to ShortOut in lmRing & tailRing
Definition polys0.cc:223
void StringSetS(const char *st)
Definition reporter.cc:128
char * StringEndS()
Definition reporter.cc:151

◆ p_String() [2/2]

static char * p_String ( poly  p,
ring  p_ring 
)
inlinestatic

Definition at line 1240 of file p_polys.h.

1241{
1242 return p_String(p, p_ring, p_ring);
1243}
char * p_String(poly p, ring lmRing, ring tailRing)
Definition polys0.cc:322

◆ p_String0() [1/2]

void p_String0 ( poly  p,
ring  lmRing,
ring  tailRing 
)

print p according to ShortOut in lmRing & tailRing

Definition at line 223 of file polys0.cc.

224{
225 if (p == NULL)
226 {
227 StringAppendS("0");
228 return;
229 }
231 if ((n_GetChar(lmRing->cf) == 0)
232 && (nCoeff_is_transExt(lmRing->cf)))
233 p_Normalize(p,lmRing); /* Manual/absfact.tst */
234#ifdef HAVE_SHIFTBBA
235 if(lmRing->isLPring)
236 {
237 if ((p_GetComp(p, lmRing) == 0) || (!lmRing->VectorOut))
238 {
239 writemonLP(p,0, lmRing);
240 p = pNext(p);
241 while (p!=NULL)
242 {
243 assume((p->coef==NULL)||(!n_IsZero(p->coef,tailRing->cf)));
244 if ((p->coef==NULL)||n_GreaterZero(p->coef,tailRing->cf))
245 StringAppendS("+");
246 writemonLP(p,0, tailRing);
247 p = pNext(p);
248 }
249 return;
250 }
251 }
252 else
253#endif
254 {
255 if ((p_GetComp(p, lmRing) == 0) || (!lmRing->VectorOut))
256 {
257 writemon(p,0, lmRing);
258 p = pNext(p);
259 while (p!=NULL)
260 {
261 assume((p->coef==NULL)||(!n_IsZero(p->coef,tailRing->cf)));
262 if ((p->coef==NULL)||n_GreaterZero(p->coef,tailRing->cf))
263 StringAppendS("+");
264 writemon(p,0, tailRing);
265 p = pNext(p);
266 }
267 return;
268 }
269 }
270
271 long k = 1;
272 StringAppendS("[");
273#ifdef HAVE_SHIFTBBA
274 if(lmRing->isLPring)
275 {
276 loop
277 {
278 while (k < p_GetComp(p,lmRing))
279 {
280 StringAppendS("0,");
281 k++;
282 }
284 pIter(p);
285 while ((p!=NULL) && (k == p_GetComp(p, tailRing)))
286 {
287 if (n_GreaterZero(p->coef,tailRing->cf)) StringAppendS("+");
288 writemonLP(p,k,tailRing);
289 pIter(p);
290 }
291 if (p == NULL) break;
292 StringAppendS(",");
293 k++;
294 }
295 }
296 else
297#endif
298 {
299 loop
300 {
301 while (k < p_GetComp(p,lmRing))
302 {
303 StringAppendS("0,");
304 k++;
305 }
307 pIter(p);
308 while ((p!=NULL) && (k == p_GetComp(p, tailRing)))
309 {
310 if (n_GreaterZero(p->coef,tailRing->cf)) StringAppendS("+");
311 writemon(p,k,tailRing);
312 pIter(p);
313 }
314 if (p == NULL) break;
315 StringAppendS(",");
316 k++;
317 }
318 }
319 StringAppendS("]");
320}
static void writemon(poly p, int ko, const ring r)
Definition polys0.cc:24
static void writemonLP(poly p, int ko, const ring r)
Definition polys0.cc:104
void StringAppendS(const char *st)
Definition reporter.cc:107

◆ p_String0() [2/2]

static void p_String0 ( poly  p,
ring  p_ring 
)
inlinestatic

Definition at line 1244 of file p_polys.h.

1245{
1247}
void p_String0(poly p, ring lmRing, ring tailRing)
print p according to ShortOut in lmRing & tailRing
Definition polys0.cc:223

◆ p_String0Long()

void p_String0Long ( const poly  p,
ring  lmRing,
ring  tailRing 
)

print p in a long way

print p in a long way

Definition at line 203 of file polys0.cc.

204{
205 // NOTE: the following (non-thread-safe!) UGLYNESS
206 // (changing naRing->ShortOut for a while) is due to Hans!
207 // Just think of other ring using the VERY SAME naRing and possible
208 // side-effects...
209 // but this is not a problem: i/o is not thread-safe anyway.
211 const BOOLEAN bTAILShortOut = rShortOut(tailRing);
212
213 lmRing->ShortOut = FALSE;
214 tailRing->ShortOut = FALSE;
215
216 p_String0(p, lmRing, tailRing);
217
218 lmRing->ShortOut = bLMShortOut;
219 tailRing->ShortOut = bTAILShortOut;
220}
static BOOLEAN rShortOut(const ring r)
Definition ring.h:586

◆ p_String0Short()

void p_String0Short ( const poly  p,
ring  lmRing,
ring  tailRing 
)

print p in a short way, if possible

print p in a short way, if possible

Definition at line 184 of file polys0.cc.

185{
186 // NOTE: the following (non-thread-safe!) UGLYNESS
187 // (changing naRing->ShortOut for a while) is due to Hans!
188 // Just think of other ring using the VERY SAME naRing and possible
189 // side-effects...
191 const BOOLEAN bTAILShortOut = rShortOut(tailRing);
192
193 lmRing->ShortOut = rCanShortOut(lmRing);
194 tailRing->ShortOut = rCanShortOut(tailRing);
195
196 p_String0(p, lmRing, tailRing);
197
198 lmRing->ShortOut = bLMShortOut;
199 tailRing->ShortOut = bTAILShortOut;
200}
static BOOLEAN rCanShortOut(const ring r)
Definition ring.h:591

◆ p_Sub()

poly p_Sub ( poly  a,
poly  b,
const ring  r 
)

Definition at line 1994 of file p_polys.cc.

1995{
1996 return p_Add_q(p1, p_Neg(p2,r),r);
1997}

◆ p_SubComp()

static unsigned long p_SubComp ( poly  p,
unsigned long  v,
ring  r 
)
inlinestatic

Definition at line 453 of file p_polys.h.

454{
457 _pPolyAssume2(__p_GetComp(p,r) >= v,p,r);
458 return __p_GetComp(p,r) -= v;
459}

◆ p_SubExp()

static long p_SubExp ( poly  p,
int  v,
long  ee,
ring  r 
)
inlinestatic

Definition at line 613 of file p_polys.h.

614{
616 long e = p_GetExp(p,v,r);
617 pAssume2(e >= ee);
618 e -= ee;
619 return p_SetExp(p,v,e,r);
620}

◆ p_Subst()

poly p_Subst ( poly  p,
int  n,
poly  e,
const ring  r 
)

Definition at line 3979 of file p_polys.cc.

3980{
3981#ifdef HAVE_SHIFTBBA
3982 // also don't even use p_Subst0 for Letterplace
3983 if (rIsLPRing(r))
3984 {
3985 poly subst = p_LPSubst(p, n, e, r);
3986 p_Delete(&p, r);
3987 return subst;
3988 }
3989#endif
3990
3991 if (e == NULL) return p_Subst0(p, n,r);
3992
3993 if (p_IsConstant(e,r))
3994 {
3995 if (n_IsOne(pGetCoeff(e),r->cf)) return p_Subst1(p,n,r);
3996 else return p_Subst2(p, n, pGetCoeff(e),r);
3997 }
3998
3999#ifdef HAVE_PLURAL
4000 if (rIsPluralRing(r))
4001 {
4002 return nc_pSubst(p,n,e,r);
4003 }
4004#endif
4005
4006 int exponent,i;
4007 poly h, res, m;
4008 int *me,*ee;
4009 number nu,nu1;
4010
4011 me=(int *)omAlloc((rVar(r)+1)*sizeof(int));
4012 ee=(int *)omAlloc((rVar(r)+1)*sizeof(int));
4013 if (e!=NULL) p_GetExpV(e,ee,r);
4014 res=NULL;
4015 h=p;
4016 while (h!=NULL)
4017 {
4018 if ((e!=NULL) || (p_GetExp(h,n,r)==0))
4019 {
4020 m=p_Head(h,r);
4021 p_GetExpV(m,me,r);
4022 exponent=me[n];
4023 me[n]=0;
4024 for(i=rVar(r);i>0;i--)
4025 me[i]+=exponent*ee[i];
4026 p_SetExpV(m,me,r);
4027 if (e!=NULL)
4028 {
4029 n_Power(pGetCoeff(e),exponent,&nu,r->cf);
4030 nu1=n_Mult(pGetCoeff(m),nu,r->cf);
4031 n_Delete(&nu,r->cf);
4032 p_SetCoeff(m,nu1,r);
4033 }
4034 res=p_Add_q(res,m,r);
4035 }
4036 p_LmDelete(&h,r);
4037 }
4038 omFreeSize((ADDRESS)me,(rVar(r)+1)*sizeof(int));
4039 omFreeSize((ADDRESS)ee,(rVar(r)+1)*sizeof(int));
4040 return res;
4041}
CanonicalForm subst(const CanonicalForm &f, const CFList &a, const CFList &b, const CanonicalForm &Rstar, bool isFunctionField)
poly nc_pSubst(poly p, int n, poly e, const ring r)
substitute the n-th variable by e in p destroy p e is not a constant
static poly p_Subst0(poly p, int n, const ring r)
Definition p_polys.cc:3954
static poly p_Subst1(poly p, int n, const ring r)
Definition p_polys.cc:3886
static poly p_Subst2(poly p, int n, number e, const ring r)
Definition p_polys.cc:3913
poly p_LPSubst(poly p, int n, poly e, const ring r)
Definition shiftop.cc:912

◆ p_TakeOutComp() [1/2]

poly p_TakeOutComp ( poly *  p,
int  k,
const ring  r 
)

Definition at line 3439 of file p_polys.cc.

3440{
3441 poly q = *p,qq=NULL,result = NULL;
3442 unsigned long kk=(unsigned long)k;
3443
3444 if (q==NULL) return NULL;
3446 if (__p_GetComp(q,r)==kk)
3447 {
3448 result = q;
3450 {
3451 do
3452 {
3453 p_SetComp(q,0,r);
3454 p_SetmComp(q,r);
3455 qq = q;
3456 pIter(q);
3457 }
3458 while ((q!=NULL) && (__p_GetComp(q,r)==kk));
3459 }
3460 else
3461 {
3462 do
3463 {
3464 p_SetComp(q,0,r);
3465 qq = q;
3466 pIter(q);
3467 }
3468 while ((q!=NULL) && (__p_GetComp(q,r)==kk));
3469 }
3470
3471 *p = q;
3472 pNext(qq) = NULL;
3473 }
3474 if (q==NULL) return result;
3475 if (__p_GetComp(q,r) > kk)
3476 {
3477 p_SubComp(q,1,r);
3478 if (use_setmcomp) p_SetmComp(q,r);
3479 }
3480 poly pNext_q;
3481 while ((pNext_q=pNext(q))!=NULL)
3482 {
3483 unsigned long c=__p_GetComp(pNext_q,r);
3484 if (/*__p_GetComp(pNext_q,r)*/c==kk)
3485 {
3486 if (result==NULL)
3487 {
3488 result = pNext_q;
3489 qq = result;
3490 }
3491 else
3492 {
3493 pNext(qq) = pNext_q;
3494 pIter(qq);
3495 }
3496 pNext(q) = pNext(pNext_q);
3497 pNext(qq) =NULL;
3498 p_SetComp(qq,0,r);
3499 if (use_setmcomp) p_SetmComp(qq,r);
3500 }
3501 else
3502 {
3503 /*pIter(q);*/ q=pNext_q;
3504 if (/*__p_GetComp(q,r)*/c > kk)
3505 {
3506 p_SubComp(q,1,r);
3507 if (use_setmcomp) p_SetmComp(q,r);
3508 }
3509 }
3510 }
3511 return result;
3512}

◆ p_TakeOutComp() [2/2]

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 monoms *lq == pLength(*q) On return all components pf *q == 0.

Definition at line 3516 of file p_polys.cc.

3517{
3518 spolyrec pp, qq;
3519 poly p, q, p_prev;
3520 int l = 0;
3521
3522#ifndef SING_NDEBUG
3523 int lp = pLength(*r_p);
3524#endif
3525
3526 pNext(&pp) = *r_p;
3527 p = *r_p;
3528 p_prev = &pp;
3529 q = &qq;
3530
3531 while(p != NULL)
3532 {
3533 while (__p_GetComp(p,r) == comp)
3534 {
3535 pNext(q) = p;
3536 pIter(q);
3537 p_SetComp(p, 0,r);
3538 p_SetmComp(p,r);
3539 pIter(p);
3540 l++;
3541 if (p == NULL)
3542 {
3543 pNext(p_prev) = NULL;
3544 goto Finish;
3545 }
3546 }
3547 pNext(p_prev) = p;
3548 p_prev = p;
3549 pIter(p);
3550 }
3551
3552 Finish:
3553 pNext(q) = NULL;
3554 *r_p = pNext(&pp);
3555 *r_q = pNext(&qq);
3556 *lq = l;
3557#ifndef SING_NDEBUG
3558 assume(pLength(*r_p) + pLength(*r_q) == lp);
3559#endif
3560 p_Test(*r_p,r);
3561 p_Test(*r_q,r);
3562}

◆ p_Totaldegree()

static long p_Totaldegree ( poly  p,
const ring  r 
)
inlinestatic

Definition at line 1507 of file p_polys.h.

1508{
1510 unsigned long s = p_GetTotalDegree(p->exp[r->VarL_Offset[0]],
1511 r,
1512 r->ExpPerLong);
1513 for (unsigned i=r->VarL_Size-1; i!=0; i--)
1514 {
1515 s += p_GetTotalDegree(p->exp[r->VarL_Offset[i]], r,r->ExpPerLong);
1516 }
1517 return (long)s;
1518}

◆ p_Var()

int p_Var ( poly  mi,
const ring  r 
)

Definition at line 4705 of file p_polys.cc.

4706{
4707 if (m==NULL) return 0;
4708 if (pNext(m)!=NULL) return 0;
4709 int i,e=0;
4710 for (i=rVar(r); i>0; i--)
4711 {
4712 int exp=p_GetExp(m,i,r);
4713 if (exp==1)
4714 {
4715 if (e==0) e=i;
4716 else return 0;
4717 }
4718 else if (exp!=0)
4719 {
4720 return 0;
4721 }
4722 }
4723 return e;
4724}

◆ p_Vec2Array()

void p_Vec2Array ( poly  v,
poly *  p,
int  len,
const ring  r 
)

julia: vector to already allocated array (len=p_MaxComp(v,r))

julia: vector to already allocated array (len=p_MaxComp(v,r))

Definition at line 3616 of file p_polys.cc.

3617{
3618 poly h;
3619 int k;
3620
3621 for(int i=len-1;i>=0;i--) p[i]=NULL;
3622 while (v!=NULL)
3623 {
3624 h=p_Head(v,r);
3625 k=__p_GetComp(h,r);
3626 if (k>len) { Werror("wrong rank:%d, should be %d",len,k); }
3627 else
3628 {
3629 p_SetComp(h,0,r);
3630 p_Setm(h,r);
3631 pNext(h)=p[k-1];p[k-1]=h;
3632 }
3633 pIter(v);
3634 }
3635 for(int i=len-1;i>=0;i--)
3636 {
3637 if (p[i]!=NULL) p[i]=pReverse(p[i]);
3638 }
3639}

◆ p_Vec2Poly()

poly p_Vec2Poly ( poly  v,
int  k,
const ring  r 
)

Definition at line 3594 of file p_polys.cc.

3595{
3596 poly h;
3597 poly res=NULL;
3598 long unsigned kk=k;
3599
3600 while (v!=NULL)
3601 {
3602 if (__p_GetComp(v,r)==kk)
3603 {
3604 h=p_Head(v,r);
3605 p_SetComp(h,0,r);
3606 pNext(h)=res;res=h;
3607 }
3608 pIter(v);
3609 }
3610 if (res!=NULL) res=pReverse(res);
3611 return res;
3612}

◆ p_Vec2Polys()

void p_Vec2Polys ( poly  v,
poly **  p,
int len,
const ring  r 
)

Definition at line 3646 of file p_polys.cc.

3647{
3648 *len=p_MaxComp(v,r);
3649 if (*len==0) *len=1;
3650 *p=(poly*)omAlloc((*len)*sizeof(poly));
3651 p_Vec2Array(v,*p,*len,r);
3652}
void p_Vec2Array(poly v, poly *p, int len, const ring r)
vector to already allocated array (len>=p_MaxComp(v,r))
Definition p_polys.cc:3616

◆ p_VectorHasUnit()

void p_VectorHasUnit ( poly  p,
int k,
int len,
const ring  r 
)

Definition at line 3406 of file p_polys.cc.

3407{
3408 poly q=p,qq;
3409 int j=0;
3410 long unsigned i;
3411
3412 *len = 0;
3413 while (q!=NULL)
3414 {
3415 if (p_LmIsConstantComp(q,r))
3416 {
3417 i = __p_GetComp(q,r);
3418 qq = p;
3419 while ((qq != q) && (__p_GetComp(qq,r) != i)) pIter(qq);
3420 if (qq == q)
3421 {
3422 j = 0;
3423 while (qq!=NULL)
3424 {
3425 if (__p_GetComp(qq,r)==i) j++;
3426 pIter(qq);
3427 }
3428 if ((*len == 0) || (j<*len))
3429 {
3430 *len = j;
3431 *k = i;
3432 }
3433 }
3434 }
3435 pIter(q);
3436 }
3437}

◆ p_VectorHasUnitB()

BOOLEAN p_VectorHasUnitB ( poly  p,
int k,
const ring  r 
)

Definition at line 3383 of file p_polys.cc.

3384{
3385 poly q=p,qq;
3386 long unsigned i;
3387
3388 while (q!=NULL)
3389 {
3390 if (p_LmIsConstantComp(q,r))
3391 {
3392 i = __p_GetComp(q,r);
3393 qq = p;
3394 while ((qq != q) && (__p_GetComp(qq,r) != i)) pIter(qq);
3395 if (qq == q)
3396 {
3397 *k = i;
3398 return TRUE;
3399 }
3400 }
3401 pIter(q);
3402 }
3403 return FALSE;
3404}

◆ p_WDegree()

long p_WDegree ( poly  p,
const ring  r 
)

Definition at line 715 of file p_polys.cc.

716{
717 if (r->firstwv==NULL) return p_Totaldegree(p, r);
719 int i;
720 long j =0;
721
722 for(i=1;i<=r->firstBlockEnds;i++)
723 j+=p_GetExp(p, i, r)*r->firstwv[i-1];
724
725 for (;i<=rVar(r);i++)
726 j+=p_GetExp(p,i, r)*p_Weight(i, r);
727
728 return j;
729}
int p_Weight(int i, const ring r)
Definition p_polys.cc:706

◆ p_Weight()

int p_Weight ( int  c,
const ring  r 
)

Definition at line 706 of file p_polys.cc.

707{
708 if ((r->firstwv==NULL) || (i>r->firstBlockEnds))
709 {
710 return 1;
711 }
712 return r->firstwv[i-1];
713}

◆ p_WFirstTotalDegree()

long p_WFirstTotalDegree ( poly  p,
ring  r 
)

Definition at line 595 of file p_polys.cc.

596{
597 int i;
598 long sum = 0;
599
600 for (i=1; i<= r->firstBlockEnds; i++)
601 {
602 sum += p_GetExp(p, i, r)*r->firstwv[i-1];
603 }
604 return sum;
605}

◆ p_Write() [1/2]

void p_Write ( poly  p,
ring  lmRing,
ring  tailRing 
)

Definition at line 342 of file polys0.cc.

343{
344 p_Write0(p, lmRing, tailRing);
345 PrintLn();
346}
void p_Write0(poly p, ring lmRing, ring tailRing)
Definition polys0.cc:332
void PrintLn()
Definition reporter.cc:310

◆ p_Write() [2/2]

static void p_Write ( poly  p,
ring  p_ring 
)
inlinestatic

Definition at line 1248 of file p_polys.h.

1249{
1251}

◆ p_Write0() [1/2]

void p_Write0 ( poly  p,
ring  lmRing,
ring  tailRing 
)

Definition at line 332 of file polys0.cc.

333{
334 char *s=p_String(p, lmRing, tailRing);
335 PrintS(s);
336 omFree(s);
337}
char * p_String(poly p, ring lmRing, ring tailRing)
Definition polys0.cc:322

◆ p_Write0() [2/2]

static void p_Write0 ( poly  p,
ring  p_ring 
)
inlinestatic

Definition at line 1252 of file p_polys.h.

1253{
1255}
void p_Write0(poly p, ring lmRing, ring tailRing)
Definition polys0.cc:332

◆ p_wrp() [1/2]

void p_wrp ( poly  p,
ring  lmRing,
ring  tailRing 
)

Definition at line 373 of file polys0.cc.

374{
375 poly r;
376
377 if (p==NULL) PrintS("NULL");
378 else if (pNext(p)==NULL) p_Write0(p, lmRing);
379 else
380 {
381 r = pNext(pNext(p));
382 pNext(pNext(p)) = NULL;
383 p_Write0(p, tailRing);
384 if (r!=NULL)
385 {
386 PrintS("+...");
387 pNext(pNext(p)) = r;
388 }
389 }
390}

◆ p_wrp() [2/2]

static void p_wrp ( poly  p,
ring  p_ring 
)
inlinestatic

Definition at line 1256 of file p_polys.h.

1257{
1258 p_wrp(p, p_ring, p_ring);
1259}
void p_wrp(poly p, ring lmRing, ring tailRing)
Definition polys0.cc:373

◆ p_WTotaldegree()

long p_WTotaldegree ( poly  p,
const ring  r 
)

Definition at line 612 of file p_polys.cc.

613{
615 int i, k;
616 long j =0;
617
618 // iterate through each block:
619 for (i=0;r->order[i]!=0;i++)
620 {
621 int b0=r->block0[i];
622 int b1=r->block1[i];
623 switch(r->order[i])
624 {
625 case ringorder_M:
626 for (k=b0 /*r->block0[i]*/;k<=b1 /*r->block1[i]*/;k++)
627 { // in jedem block:
628 j+= p_GetExp(p,k,r)*r->wvhdl[i][k - b0 /*r->block0[i]*/]*r->OrdSgn;
629 }
630 break;
631 case ringorder_am:
632 b1=si_min(b1,r->N); /* no break, continue as ringorder_a*/
633 case ringorder_a:
634 for (k=b0 /*r->block0[i]*/;k<=b1 /*r->block1[i]*/;k++)
635 { // only one line
636 j+= p_GetExp(p,k,r)*r->wvhdl[i][k - b0 /*r->block0[i]*/];
637 }
638 return j*r->OrdSgn;
639 case ringorder_wp:
640 case ringorder_ws:
641 case ringorder_Wp:
642 case ringorder_Ws:
643 for (k=b0 /*r->block0[i]*/;k<=b1 /*r->block1[i]*/;k++)
644 { // in jedem block:
645 j+= p_GetExp(p,k,r)*r->wvhdl[i][k - b0 /*r->block0[i]*/];
646 }
647 break;
648 case ringorder_lp:
649 case ringorder_ls:
650 case ringorder_rs:
651 case ringorder_dp:
652 case ringorder_ds:
653 case ringorder_Dp:
654 case ringorder_Ds:
655 case ringorder_rp:
656 for (k=b0 /*r->block0[i]*/;k<=b1 /*r->block1[i]*/;k++)
657 {
658 j+= p_GetExp(p,k,r);
659 }
660 break;
661 case ringorder_a64:
662 {
663 int64* w=(int64*)r->wvhdl[i];
664 for (k=0;k<=(b1 /*r->block1[i]*/ - b0 /*r->block0[i]*/);k++)
665 {
666 //there should be added a line which checks if w[k]>2^31
667 j+= p_GetExp(p,k+1, r)*(long)w[k];
668 }
669 //break;
670 return j;
671 }
672 default:
673 #if 0
674 case ringorder_c: /* nothing to do*/
675 case ringorder_C: /* nothing to do*/
676 case ringorder_S: /* nothing to do*/
677 case ringorder_s: /* nothing to do*/
678 case ringorder_IS: /* nothing to do */
679 case ringorder_unspec: /* to make clang happy, does not occur*/
680 case ringorder_no: /* to make clang happy, does not occur*/
681 case ringorder_L: /* to make clang happy, does not occur*/
682 case ringorder_aa: /* ignored by p_WTotaldegree*/
683 #endif
684 break;
685 /* no default: all orderings covered */
686 }
687 }
688 return j;
689}
#define ringorder_rp
Definition ring.h:99
@ ringorder_a
Definition ring.h:70
@ ringorder_am
Definition ring.h:89
@ ringorder_a64
for int64 weights
Definition ring.h:71
@ ringorder_C
Definition ring.h:73
@ ringorder_S
S?
Definition ring.h:75
@ ringorder_ds
Definition ring.h:85
@ ringorder_Dp
Definition ring.h:80
@ ringorder_unspec
Definition ring.h:95
@ ringorder_L
Definition ring.h:90
@ ringorder_Ds
Definition ring.h:86
@ ringorder_dp
Definition ring.h:78
@ ringorder_c
Definition ring.h:72
@ ringorder_aa
for idElimination, like a, except pFDeg, pWeigths ignore it
Definition ring.h:92
@ ringorder_no
Definition ring.h:69
@ ringorder_Wp
Definition ring.h:82
@ ringorder_ws
Definition ring.h:87
@ ringorder_Ws
Definition ring.h:88
@ ringorder_IS
Induced (Schreyer) ordering.
Definition ring.h:94
@ ringorder_ls
degree, ip
Definition ring.h:84
@ ringorder_s
s?
Definition ring.h:76
@ ringorder_wp
Definition ring.h:81
@ ringorder_M
Definition ring.h:74
#define ringorder_rs
Definition ring.h:100

◆ pEnlargeSet()

void pEnlargeSet ( poly **  p,
int  length,
int  increment 
)

Definition at line 3717 of file p_polys.cc.

3718{
3719 poly* h;
3720
3721 if (increment==0) return;
3722 if (*p==NULL)
3723 {
3724 h=(poly*)omAlloc0(increment*sizeof(poly));
3725 }
3726 else
3727 {
3728 h=(poly*)omReallocSize((poly*)*p,l*sizeof(poly),(l+increment)*sizeof(poly));
3729 if (increment>0)
3730 {
3731 memset(&(h[l]),0,increment*sizeof(poly));
3732 }
3733 }
3734 *p=h;
3735}
#define omReallocSize(addr, o_size, size)

◆ pHaveCommonMonoms()

BOOLEAN pHaveCommonMonoms ( poly  p,
poly  q 
)

Definition at line 174 of file pDebug.cc.

175{
176 while (p != NULL)
177 {
178 if (pIsMonomOf(q, p))
179 {
180 return TRUE;
181 }
182 pIter(p);
183 }
184 return FALSE;
185}
BOOLEAN pIsMonomOf(poly p, poly m)
Definition pDebug.cc:164

◆ pIsMonomOf()

BOOLEAN pIsMonomOf ( poly  p,
poly  m 
)

Definition at line 164 of file pDebug.cc.

165{
166 if (m == NULL) return TRUE;
167 while (p != NULL)
168 {
169 if (p == m) return TRUE;
170 pIter(p);
171 }
172 return FALSE;
173}

◆ pLDeg0()

long pLDeg0 ( poly  p,
int l,
ring  r 
)

Definition at line 740 of file p_polys.cc.

741{
742 p_CheckPolyRing(p, r);
743 long unsigned k= p_GetComp(p, r);
744 int ll=1;
745
746 if (k > 0)
747 {
748 while ((pNext(p)!=NULL) && (__p_GetComp(pNext(p), r)==k))
749 {
750 pIter(p);
751 ll++;
752 }
753 }
754 else
755 {
756 while (pNext(p)!=NULL)
757 {
758 pIter(p);
759 ll++;
760 }
761 }
762 *l=ll;
763 return r->pFDeg(p, r);
764}

◆ pLDeg0c()

long pLDeg0c ( poly  p,
int l,
ring  r 
)

Definition at line 771 of file p_polys.cc.

772{
773 assume(p!=NULL);
774 p_Test(p,r);
775 p_CheckPolyRing(p, r);
776 long o;
777 int ll=1;
778
779 if (! rIsSyzIndexRing(r))
780 {
781 while (pNext(p) != NULL)
782 {
783 pIter(p);
784 ll++;
785 }
786 o = r->pFDeg(p, r);
787 }
788 else
789 {
790 long unsigned curr_limit = rGetCurrSyzLimit(r);
791 poly pp = p;
792 while ((p=pNext(p))!=NULL)
793 {
794 if (__p_GetComp(p, r)<=curr_limit/*syzComp*/)
795 ll++;
796 else break;
797 pp = p;
798 }
799 p_Test(pp,r);
800 o = r->pFDeg(pp, r);
801 }
802 *l=ll;
803 return o;
804}

◆ pLDeg1()

long pLDeg1 ( poly  p,
int l,
ring  r 
)

Definition at line 842 of file p_polys.cc.

843{
844 p_CheckPolyRing(p, r);
845 long unsigned k= p_GetComp(p, r);
846 int ll=1;
847 long t,max;
848
849 max=r->pFDeg(p, r);
850 if (k > 0)
851 {
852 while (((p=pNext(p))!=NULL) && (__p_GetComp(p, r)==k))
853 {
854 t=r->pFDeg(p, r);
855 if (t>max) max=t;
856 ll++;
857 }
858 }
859 else
860 {
861 while ((p=pNext(p))!=NULL)
862 {
863 t=r->pFDeg(p, r);
864 if (t>max) max=t;
865 ll++;
866 }
867 }
868 *l=ll;
869 return max;
870}

◆ pLDeg1_Deg()

long pLDeg1_Deg ( poly  p,
int l,
ring  r 
)

Definition at line 911 of file p_polys.cc.

912{
913 assume(r->pFDeg == p_Deg);
914 p_CheckPolyRing(p, r);
915 long unsigned k= p_GetComp(p, r);
916 int ll=1;
917 long t,max;
918
919 max=p_GetOrder(p, r);
920 if (k > 0)
921 {
922 while (((p=pNext(p))!=NULL) && (__p_GetComp(p, r)==k))
923 {
924 t=p_GetOrder(p, r);
925 if (t>max) max=t;
926 ll++;
927 }
928 }
929 else
930 {
931 while ((p=pNext(p))!=NULL)
932 {
933 t=p_GetOrder(p, r);
934 if (t>max) max=t;
935 ll++;
936 }
937 }
938 *l=ll;
939 return max;
940}

◆ pLDeg1_Totaldegree()

long pLDeg1_Totaldegree ( poly  p,
int l,
ring  r 
)

Definition at line 976 of file p_polys.cc.

977{
978 p_CheckPolyRing(p, r);
979 long unsigned k= p_GetComp(p, r);
980 int ll=1;
981 long t,max;
982
983 max=p_Totaldegree(p, r);
984 if (k > 0)
985 {
986 while (((p=pNext(p))!=NULL) && (__p_GetComp(p, r)==k))
987 {
988 t=p_Totaldegree(p, r);
989 if (t>max) max=t;
990 ll++;
991 }
992 }
993 else
994 {
995 while ((p=pNext(p))!=NULL)
996 {
997 t=p_Totaldegree(p, r);
998 if (t>max) max=t;
999 ll++;
1000 }
1001 }
1002 *l=ll;
1003 return max;
1004}

◆ pLDeg1_WFirstTotalDegree()

long pLDeg1_WFirstTotalDegree ( poly  p,
int l,
ring  r 
)

Definition at line 1039 of file p_polys.cc.

1040{
1041 p_CheckPolyRing(p, r);
1042 long unsigned k= p_GetComp(p, r);
1043 int ll=1;
1044 long t,max;
1045
1047 if (k > 0)
1048 {
1049 while (((p=pNext(p))!=NULL) && (__p_GetComp(p, r)==k))
1050 {
1051 t=p_WFirstTotalDegree(p, r);
1052 if (t>max) max=t;
1053 ll++;
1054 }
1055 }
1056 else
1057 {
1058 while ((p=pNext(p))!=NULL)
1059 {
1060 t=p_WFirstTotalDegree(p, r);
1061 if (t>max) max=t;
1062 ll++;
1063 }
1064 }
1065 *l=ll;
1066 return max;
1067}
long p_WFirstTotalDegree(poly p, const ring r)
Definition p_polys.cc:595

◆ pLDeg1c()

long pLDeg1c ( poly  p,
int l,
ring  r 
)

Definition at line 878 of file p_polys.cc.

879{
880 p_CheckPolyRing(p, r);
881 int ll=1;
882 long t,max;
883
884 max=r->pFDeg(p, r);
885 if (rIsSyzIndexRing(r))
886 {
887 long unsigned limit = rGetCurrSyzLimit(r);
888 while ((p=pNext(p))!=NULL)
889 {
890 if (__p_GetComp(p, r)<=limit)
891 {
892 if ((t=r->pFDeg(p, r))>max) max=t;
893 ll++;
894 }
895 else break;
896 }
897 }
898 else
899 {
900 while ((p=pNext(p))!=NULL)
901 {
902 if ((t=r->pFDeg(p, r))>max) max=t;
903 ll++;
904 }
905 }
906 *l=ll;
907 return max;
908}

◆ pLDeg1c_Deg()

long pLDeg1c_Deg ( poly  p,
int l,
ring  r 
)

Definition at line 942 of file p_polys.cc.

943{
944 assume(r->pFDeg == p_Deg);
945 p_CheckPolyRing(p, r);
946 int ll=1;
947 long t,max;
948
949 max=p_GetOrder(p, r);
950 if (rIsSyzIndexRing(r))
951 {
952 long unsigned limit = rGetCurrSyzLimit(r);
953 while ((p=pNext(p))!=NULL)
954 {
955 if (__p_GetComp(p, r)<=limit)
956 {
957 if ((t=p_GetOrder(p, r))>max) max=t;
958 ll++;
959 }
960 else break;
961 }
962 }
963 else
964 {
965 while ((p=pNext(p))!=NULL)
966 {
967 if ((t=p_GetOrder(p, r))>max) max=t;
968 ll++;
969 }
970 }
971 *l=ll;
972 return max;
973}

◆ pLDeg1c_Totaldegree()

long pLDeg1c_Totaldegree ( poly  p,
int l,
ring  r 
)

Definition at line 1006 of file p_polys.cc.

1007{
1008 p_CheckPolyRing(p, r);
1009 int ll=1;
1010 long t,max;
1011
1012 max=p_Totaldegree(p, r);
1013 if (rIsSyzIndexRing(r))
1014 {
1015 long unsigned limit = rGetCurrSyzLimit(r);
1016 while ((p=pNext(p))!=NULL)
1017 {
1018 if (__p_GetComp(p, r)<=limit)
1019 {
1020 if ((t=p_Totaldegree(p, r))>max) max=t;
1021 ll++;
1022 }
1023 else break;
1024 }
1025 }
1026 else
1027 {
1028 while ((p=pNext(p))!=NULL)
1029 {
1030 if ((t=p_Totaldegree(p, r))>max) max=t;
1031 ll++;
1032 }
1033 }
1034 *l=ll;
1035 return max;
1036}

◆ pLDeg1c_WFirstTotalDegree()

long pLDeg1c_WFirstTotalDegree ( poly  p,
int l,
ring  r 
)

Definition at line 1069 of file p_polys.cc.

1070{
1071 p_CheckPolyRing(p, r);
1072 int ll=1;
1073 long t,max;
1074
1076 if (rIsSyzIndexRing(r))
1077 {
1078 long unsigned limit = rGetCurrSyzLimit(r);
1079 while ((p=pNext(p))!=NULL)
1080 {
1081 if (__p_GetComp(p, r)<=limit)
1082 {
1083 if ((t=p_Totaldegree(p, r))>max) max=t;
1084 ll++;
1085 }
1086 else break;
1087 }
1088 }
1089 else
1090 {
1091 while ((p=pNext(p))!=NULL)
1092 {
1093 if ((t=p_Totaldegree(p, r))>max) max=t;
1094 ll++;
1095 }
1096 }
1097 *l=ll;
1098 return max;
1099}

◆ pLDegb()

long pLDegb ( poly  p,
int l,
ring  r 
)

Definition at line 812 of file p_polys.cc.

813{
814 p_CheckPolyRing(p, r);
815 long unsigned k= p_GetComp(p, r);
816 long o = r->pFDeg(p, r);
817 int ll=1;
818
819 if (k != 0)
820 {
821 while (((p=pNext(p))!=NULL) && (__p_GetComp(p, r)==k))
822 {
823 ll++;
824 }
825 }
826 else
827 {
828 while ((p=pNext(p)) !=NULL)
829 {
830 ll++;
831 }
832 }
833 *l=ll;
834 return o;
835}

◆ pLength()

static int pLength ( poly  a)
inlinestatic

Definition at line 190 of file p_polys.h.

191{
192 int l = 0;
193 while (a!=NULL)
194 {
195 pIter(a);
196 l++;
197 }
198 return l;
199}

◆ pp_DivideM()

poly pp_DivideM ( poly  a,
poly  b,
const ring  r 
)

Definition at line 1637 of file p_polys.cc.

1638{
1639 if (a==NULL) { return NULL; }
1640 // TODO: better implementation without copying a,b
1641 return p_DivideM(p_Copy(a,r),p_Head(b,r),r);
1642}
poly p_DivideM(poly a, poly b, const ring r)
Definition p_polys.cc:1582

◆ pp_Jet()

poly pp_Jet ( poly  p,
int  m,
const ring  R 
)

Definition at line 4379 of file p_polys.cc.

4380{
4381 poly r=NULL;
4382 poly t=NULL;
4383
4384 while (p!=NULL)
4385 {
4386 if (p_Totaldegree(p,R)<=m)
4387 {
4388 if (r==NULL)
4389 r=p_Head(p,R);
4390 else
4391 if (t==NULL)
4392 {
4393 pNext(r)=p_Head(p,R);
4394 t=pNext(r);
4395 }
4396 else
4397 {
4398 pNext(t)=p_Head(p,R);
4399 pIter(t);
4400 }
4401 }
4402 pIter(p);
4403 }
4404 return r;
4405}

◆ pp_Jet0()

poly pp_Jet0 ( poly  p,
const ring  R 
)

Definition at line 4407 of file p_polys.cc.

4408{
4409 poly r=NULL;
4410 poly t=NULL;
4411
4412 while (p!=NULL)
4413 {
4414 if (p_LmIsConstantComp(p,R))
4415 {
4416 if (r==NULL)
4417 r=p_Head(p,R);
4418 else
4419 if (t==NULL)
4420 {
4421 pNext(r)=p_Head(p,R);
4422 t=pNext(r);
4423 }
4424 else
4425 {
4426 pNext(t)=p_Head(p,R);
4427 pIter(t);
4428 }
4429 }
4430 pIter(p);
4431 }
4432 return r;
4433}

◆ pp_JetW()

poly pp_JetW ( poly  p,
int  m,
int w,
const ring  R 
)

Definition at line 4452 of file p_polys.cc.

4453{
4454 poly r=NULL;
4455 poly t=NULL;
4456 while (p!=NULL)
4457 {
4458 if (totaldegreeWecart_IV(p,R,w)<=m)
4459 {
4460 if (r==NULL)
4461 r=p_Head(p,R);
4462 else
4463 if (t==NULL)
4464 {
4465 pNext(r)=p_Head(p,R);
4466 t=pNext(r);
4467 }
4468 else
4469 {
4470 pNext(t)=p_Head(p,R);
4471 pIter(t);
4472 }
4473 }
4474 pIter(p);
4475 }
4476 return r;
4477}

◆ pp_mm_Mult()

static poly pp_mm_Mult ( poly  p,
poly  m,
const ring  r 
)
inlinestatic

Definition at line 1041 of file p_polys.h.

1042{
1043 if (p==NULL) return NULL;
1044 if (p_LmIsConstant(m, r))
1045 return __pp_Mult_nn(p, pGetCoeff(m), r);
1046 else
1047 return r->p_Procs->pp_mm_Mult(p, m, r);
1048}
#define __pp_Mult_nn(p, n, r)
Definition p_polys.h:1002

◆ pp_Mult_Coeff_mm_DivSelect() [1/2]

static poly pp_Mult_Coeff_mm_DivSelect ( poly  p,
const poly  m,
const ring  r 
)
inlinestatic

Definition at line 1090 of file p_polys.h.

1091{
1092 int shorter;
1093 return r->p_Procs->pp_Mult_Coeff_mm_DivSelect(p, m, shorter, r);
1094}

◆ pp_Mult_Coeff_mm_DivSelect() [2/2]

static poly pp_Mult_Coeff_mm_DivSelect ( poly  p,
int lp,
const poly  m,
const ring  r 
)
inlinestatic

Definition at line 1098 of file p_polys.h.

1099{
1100 int shorter;
1101 poly pp = r->p_Procs->pp_Mult_Coeff_mm_DivSelect(p, m, shorter, r);
1102 lp -= shorter;
1103 return pp;
1104}

◆ pp_Mult_mm()

static poly pp_Mult_mm ( poly  p,
poly  m,
const ring  r 
)
inlinestatic

Definition at line 1031 of file p_polys.h.

1032{
1033 if (p==NULL) return NULL;
1034 if (p_LmIsConstant(m, r))
1035 return __pp_Mult_nn(p, pGetCoeff(m), r);
1036 else
1037 return r->p_Procs->pp_Mult_mm(p, m, r);
1038}

◆ pp_Mult_nn()

static poly pp_Mult_nn ( poly  p,
number  n,
const ring  r 
)
inlinestatic

Definition at line 992 of file p_polys.h.

993{
994 if (p==NULL) return NULL;
995 if (n_IsOne(n, r->cf))
996 return p_Copy(p, r);
997 else if (n_IsZero(n, r->cf))
998 return NULL;
999 else
1000 return r->p_Procs->pp_Mult_nn(p, n, r);
1001}

◆ pp_Mult_qq()

static poly pp_Mult_qq ( poly  p,
poly  q,
const ring  r 
)
inlinestatic

Definition at line 1151 of file p_polys.h.

1152{
1153 if (p == NULL || q == NULL) return NULL;
1154
1155 if (pNext(p) == NULL)
1156 {
1157 return r->p_Procs->pp_mm_Mult(q, p, r);
1158 }
1159
1160 if (pNext(q) == NULL)
1161 {
1162 return r->p_Procs->pp_Mult_mm(p, q, r);
1163 }
1164
1165 poly qq = q;
1166 if (p == q)
1167 qq = p_Copy(q, r);
1168
1169 poly res;
1170#if defined(HAVE_PLURAL) || defined(HAVE_SHIFTBBA)
1171 if (rIsNCRing(r))
1172 res = _nc_pp_Mult_qq(p, qq, r);
1173 else
1174#endif
1175 res = _p_Mult_q(p, qq, 1, r);
1176
1177 if (qq != q)
1178 p_Delete(&qq, r);
1179 return res;
1180}
poly _nc_pp_Mult_qq(const poly p, const poly q, const ring r)
general NC-multiplication without destruction
Definition old.gring.cc:254

◆ pRestoreDegProcs()

void pRestoreDegProcs ( ring  r,
pFDegProc  old_FDeg,
pLDegProc  old_lDeg 
)

Definition at line 3670 of file p_polys.cc.

3671{
3672 assume(old_FDeg != NULL && old_lDeg != NULL);
3673 r->pFDeg = old_FDeg;
3674 r->pLDeg = old_lDeg;
3675}

◆ pReverse()

static poly pReverse ( poly  p)
inlinestatic

Definition at line 335 of file p_polys.h.

336{
337 if (p == NULL || pNext(p) == NULL) return p;
338
339 poly q = pNext(p), // == pNext(p)
340 qn;
341 pNext(p) = NULL;
342 do
343 {
344 qn = pNext(q);
345 pNext(q) = p;
346 p = q;
347 q = qn;
348 }
349 while (qn != NULL);
350 return p;
351}

◆ pSetDegProcs()

void pSetDegProcs ( ring  r,
pFDegProc  new_FDeg,
pLDegProc  new_lDeg = NULL 
)

Definition at line 3658 of file p_polys.cc.

3659{
3660 assume(new_FDeg != NULL);
3661 r->pFDeg = new_FDeg;
3662
3663 if (new_lDeg == NULL)
3664 new_lDeg = r->pLDegOrig;
3665
3666 r->pLDeg = new_lDeg;
3667}