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)
 
poly p_HomogenDP (poly p, int varnum, const ring r)
 
BOOLEAN p_IsHomogeneous (poly p, const ring r)
 
BOOLEAN p_IsHomogeneousDP (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), nCoeff_is_Domain.
 
poly _p_Mult_q_Normal_ZeroDiv (poly p, poly q, const int copy, const ring 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 973 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 1004 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 1297 of file p_polys.h.

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

◆ p_LmEqual

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

Definition at line 1744 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 246 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 1303 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 1892 of file p_polys.h.

1893{
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}

◆ _p_LmDivisibleByNoComp() [1/2]

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

Definition at line 1835 of file p_polys.h.

1836{
1837 int i=r_a->N;
1838 pAssume1(r_a->N == r_b->N);
1839
1840 do
1841 {
1842 if (p_GetExp(a,i,r_a) > p_GetExp(b,i,r_b))
1843 {
1844 return FALSE;
1845 }
1846 i--;
1847 }
1848 while (i);
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_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 1786 of file p_polys.h.

1787{
1788 int i=r->VarL_Size - 1;
1789 unsigned long divmask = r->divmask;
1790 unsigned long la, lb;
1791
1792 if (r->VarL_LowIndex >= 0)
1793 {
1794 i += r->VarL_LowIndex;
1795 do
1796 {
1797 la = a->exp[i];
1798 lb = b->exp[i];
1799 if ((la > lb) ||
1800 (((la & divmask) ^ (lb & divmask)) != ((lb - la) & divmask)))
1801 {
1803 return FALSE;
1804 }
1805 i--;
1806 }
1807 while (i>=r->VarL_LowIndex);
1808 }
1809 else
1810 {
1811 do
1812 {
1813 la = a->exp[r->VarL_Offset[i]];
1814 lb = b->exp[r->VarL_Offset[i]];
1815 if ((la > lb) ||
1816 (((la & divmask) ^ (lb & divmask)) != ((lb - la) & divmask)))
1817 {
1819 return FALSE;
1820 }
1821 i--;
1822 }
1823 while (i>=0);
1824 }
1825/*#ifdef HAVE_RINGS
1826 pDivAssume(p_DebugLmDivisibleByNoComp(a, b, r) == n_DivBy(p_GetCoeff(b, r), p_GetCoeff(a, r), r->cf));
1827 return (!rField_is_Ring(r)) || n_DivBy(p_GetCoeff(b, r), p_GetCoeff(a, r), r->cf);
1828#else
1829*/
1831 return TRUE;
1832//#endif
1833}

◆ _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 1858 of file p_polys.h.

1859{
1860 int i=end;
1861 pAssume1(r_a->N == r_b->N);
1862
1863 do
1864 {
1865 if (p_GetExp(a,i,r_a) > p_GetExp(b,i,r_b))
1866 return FALSE;
1867 i--;
1868 }
1869 while (i>=start);
1870/*#ifdef HAVE_RINGS
1871 return n_DivBy(p_GetCoeff(b, r_b), p_GetCoeff(a, r_a), r_a->cf);
1872#else
1873*/
1874 return TRUE;
1875//#endif
1876}

◆ _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 1877 of file p_polys.h.

1878{
1879 if (p_GetComp(a, r_a) == 0 || p_GetComp(a,r_a) == p_GetComp(b,r_b))
1880 return _p_LmDivisibleByNoCompPart(a, r_a, b, r_b,start,end);
1881 return FALSE;
1882}

◆ _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 
)

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

Definition at line 309 of file p_Mult_q.cc.

310{
311 assume(r != NULL);
312 int lp=0, lq=0;
313 poly pt;
314
315 BOOLEAN pure_polys=(p_GetComp(p,r)==0) && (p_GetComp(q,r)==0);
316 #ifdef HAVE_FLINT
317 #if __FLINT_RELEASE >= 20503
318 if (pure_polys)
319 {
321 if (lp < lq)
322 {
323 int l;
324 pt = p;
325 p = q;
326 q = pt;
327 l = lp;
328 lp = lq;
329 lq = l;
330 }
331 if ((lq>MIN_FLINT_QQ) && rField_is_Q(r))
332 {
334 if (!convSingRFlintR(ctx,r))
335 {
336 // lq is a lower bound for the length of p and q
337 poly res=Flint_Mult_MP(p,lq,q,lq,ctx,r);
338 if (!copy)
339 {
340 p_Delete(&p,r);
341 p_Delete(&q,r);
342 }
343 return res;
344 }
345 }
346 else if ((lq>MIN_FLINT_Zp) && rField_is_Zp(r))
347 {
349 if (!convSingRFlintR(ctx,r))
350 {
351 // lq is a lower bound for the length of p and q
352 poly res=Flint_Mult_MP(p,lq,q,lq,ctx,r);
353 if (!copy)
354 {
355 p_Delete(&p,r);
356 p_Delete(&q,r);
357 }
358 return res;
359 }
360 }
361 else if ((lq>MIN_FLINT_Z) && rField_is_Z(r))
362 {
364 if (!convSingRFlintR(ctx,r))
365 {
366 // lq is a lower bound for the length of p and q
367 poly res=Flint_Mult_MP(p,lq,q,lq,ctx,r);
368 if (!copy)
369 {
370 p_Delete(&p,r);
371 p_Delete(&q,r);
372 }
373 return res;
374 }
375 }
376 }
377 #endif
378 #endif
379 if (lp==0)
381 if (lp < lq)
382 {
383 int l;
384 pt = p;
385 p = q;
386 q = pt;
387 l = lp;
388 lp = lq;
389 lq = l;
390 }
392 return _p_Mult_q_Normal(p, q, copy, r);
393 #if 0
394 else if (pure_polys
395 && ((r->cf->extRing==NULL)||(r->cf->extRing->qideal!=NULL))
396 /* exclude trans. extensions: may contain rat.funct as cf */
397 && (lq >= MIN_LENGTH_FACTORY)
398 && (r->cf->convSingNFactoryN!=ndConvSingNFactoryN))
399 {
400 poly h=singclap_pmult(p,q,r);
401 if (!copy)
402 {
403 p_Delete(&p,r);
404 p_Delete(&q,r);
405 }
406 return h;
407 }
408 #endif
409 else
410 {
411 lp=pLength(p);
412 lq=pLength(q);
413 if (lp < lq)
414 {
415 int l;
416 pt = p;
417 p = q;
418 q = pt;
419 l = lp;
420 lp = lq;
421 lq = l;
422 }
423 return _p_Mult_q_Bucket(p, lp, q, lq, copy, r);
424 }
425}
poly singclap_pmult(poly f, poly g, const ring r)
Definition clapsing.cc:597
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:389
CanonicalForm ndConvSingNFactoryN(number, BOOLEAN, const coeffs)
Definition numbers.cc:313
#define TEST_OPT_NOT_BUCKETS
Definition options.h:107
static void pqLengthApprox(poly p, poly q, int &lp, int &lq, const int min)
Definition p_Mult_q.cc:69
poly _p_Mult_q_Normal(poly p, poly q, const int copy, const ring r)
Definition p_Mult_q.cc:223
#define MIN_FLINT_Z
Definition p_Mult_q.cc:304
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
#define MIN_LENGTH_MAX
Definition p_Mult_q.cc:301
#define MIN_FLINT_QQ
Definition p_Mult_q.cc:302
#define MIN_FLINT_Zp
Definition p_Mult_q.cc:303
#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:903
static BOOLEAN rField_is_Z(const ring r)
Definition ring.h:515
static BOOLEAN rField_is_Zp(const ring r)
Definition ring.h:506
static BOOLEAN rField_is_Q(const ring r)
Definition ring.h:512

◆ _p_Mult_q_Normal_ZeroDiv()

poly _p_Mult_q_Normal_ZeroDiv ( poly  p,
poly  q,
const int  copy,
const ring  r 
)

Definition at line 195 of file p_Mult_q.cc.

196{
197 assume(p != NULL && pNext(p) != NULL && q != NULL && pNext(q) != NULL);
199 p_Test(p, r);
200 p_Test(q, r);
201
202 poly res = pp_Mult_mm(p,q,r); // holds initially q1*p
203 poly qq = pNext(q); // we iter of this
204
205 while (qq != NULL)
206 {
207 res = p_Plus_mm_Mult_qq(res, qq, p, r);
208 pIter(qq);
209 }
210
211 if (!copy)
212 {
213 p_Delete(&p, r);
214 p_Delete(&q, r);
215 }
216
217 p_Test(res, r);
218
219 return res;
220}
static poly pp_Mult_mm(poly p, poly m, const ring r)
Definition p_polys.h:1033
static poly p_Plus_mm_Mult_qq(poly p, poly m, poly q, int &lp, int lq, const ring r)
Definition p_polys.h:1204
BOOLEAN pHaveCommonMonoms(poly p, poly q)
Definition pDebug.cc:174

◆ _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:171
#define n_Test(a, r)
BOOLEAN n_Test(number a, const coeffs r)
Definition coeffs.h:715
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
Definition coeffs.h:470
static FORCE_INLINE int n_GetChar(const coeffs r)
Return the characteristic of the coeff. domain.
Definition coeffs.h:450
#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:4680
static void p_LmFree(poly p, ring)
Definition p_polys.h:685
@ ro_syzcomp
Definition ring.h:60
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 4153 of file p_polys.cc.

4154{
4155#if 0
4156 PrintS("\nSource Ring: \n");
4157 rWrite(src);
4158
4159 if(0)
4160 {
4161 number zz = n_Copy(z, src->cf);
4162 PrintS("z: "); n_Write(zz, src);
4163 n_Delete(&zz, src->cf);
4164 }
4165
4166 PrintS("\nDestination Ring: \n");
4167 rWrite(dst);
4168
4169 /*Print("\nOldPar: %d\n", OldPar);
4170 for( int i = 1; i <= OldPar; i++ )
4171 {
4172 Print("par(%d) -> par/var (%d)\n", i, par_perm[i-1]);
4173 }*/
4174#endif
4175 if( z == NULL )
4176 return NULL;
4177
4178 const coeffs srcCf = src->cf;
4179 assume( srcCf != NULL );
4180
4182 assume( src->cf->extRing!=NULL );
4183
4184 poly zz = NULL;
4185
4186 const ring srcExtRing = srcCf->extRing;
4187 assume( srcExtRing != NULL );
4188
4189 const coeffs dstCf = dst->cf;
4190 assume( dstCf != NULL );
4191
4192 if( nCoeff_is_algExt(srcCf) ) // nCoeff_is_GF(srcCf)?
4193 {
4194 zz = (poly) z;
4195 if( zz == NULL ) return NULL;
4196 }
4197 else if (nCoeff_is_transExt(srcCf))
4198 {
4199 assume( !IS0(z) );
4200
4201 zz = NUM((fraction)z);
4202 p_Test (zz, srcExtRing);
4203
4204 if( zz == NULL ) return NULL;
4205 if( !DENIS1((fraction)z) )
4206 {
4208 WarnS("Not defined: Cannot map a rational fraction and make a polynomial out of it! Ignoring the denominator.");
4209 }
4210 }
4211 else
4212 {
4213 assume (FALSE);
4214 WerrorS("Number permutation is not implemented for this data yet!");
4215 return NULL;
4216 }
4217
4218 assume( zz != NULL );
4219 p_Test (zz, srcExtRing);
4220
4222
4223 assume( nMap != NULL );
4224
4225 poly qq;
4226 if ((par_perm == NULL) && (rPar(dst) != 0 && rVar (srcExtRing) > 0))
4227 {
4228 int* perm;
4229 perm=(int *)omAlloc0((rVar(srcExtRing)+1)*sizeof(int));
4230 for(int i=si_min(rVar(srcExtRing),rPar(dst));i>0;i--)
4231 perm[i]=-i;
4233 omFreeSize ((ADDRESS)perm, (rVar(srcExtRing)+1)*sizeof(int));
4234 }
4235 else
4237
4239 && (!DENIS1((fraction)z))
4241 {
4243 qq=p_Div_nn(qq,n,dst);
4244 n_Delete(&n,dstCf);
4246 }
4247 p_Test (qq, dst);
4248
4249 return qq;
4250}
static int si_min(const int a, const int b)
Definition auxiliary.h:126
static FORCE_INLINE BOOLEAN nCoeff_is_GF(const coeffs r)
Definition coeffs.h:834
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:703
static FORCE_INLINE void n_Write(number n, const coeffs r, const BOOLEAN bShortOut=TRUE)
Definition coeffs.h:594
static FORCE_INLINE BOOLEAN nCoeff_is_algExt(const coeffs r)
TRUE iff r represents an algebraic extension field.
Definition coeffs.h:905
static FORCE_INLINE BOOLEAN nCoeff_is_transExt(const coeffs r)
TRUE iff r represents a transcendental extension field.
Definition coeffs.h:913
#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:4256
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:3939
#define NUM
Definition readcf.cc:180
void PrintS(const char *s)
Definition reporter.cc:288
void rWrite(ring r, BOOLEAN details)
Definition ring.cc:227
static int rPar(const ring r)
(r->cf->P)
Definition ring.h:605
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition ring.h:598

◆ p_Add_q() [1/2]

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

Definition at line 938 of file p_polys.h.

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

◆ 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 948 of file p_polys.h.

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

◆ p_AddComp()

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

Definition at line 449 of file p_polys.h.

450{
453 return __p_GetComp(p,r) += v;
454}
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 608 of file p_polys.h.

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

◆ 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:759
static number p_SetCoeff(poly p, number n, ring r)
Definition p_polys.h:414
static poly pReverse(poly p)
Definition p_polys.h:337
static poly p_Head(const poly p, const ring r)
copy the (leading) term of p
Definition p_polys.h:862
static poly p_LmFreeAndNext(poly p, ring)
Definition p_polys.h:713
#define loop
Definition structs.h:71

◆ p_Cleardenom()

poly p_Cleardenom ( poly  p,
const ring  r 
)

Definition at line 2893 of file p_polys.cc.

2894{
2895 if( p == NULL )
2896 return NULL;
2897
2898 assume( r != NULL );
2899 assume( r->cf != NULL );
2900 const coeffs C = r->cf;
2901
2902#if CLEARENUMERATORS
2903 if( 0 )
2904 {
2907 n_ClearContent(itr, C); // divide out the content
2908 p_Test(p, r); n_Test(pGetCoeff(p), C);
2909 assume(n_GreaterZero(pGetCoeff(p), C)); // ??
2910// if(!n_GreaterZero(pGetCoeff(p),C)) p = p_Neg(p,r);
2911 return p;
2912 }
2913#endif
2914
2915 number d, h;
2916
2917 if (rField_is_Ring(r))
2918 {
2919 if(!n_GreaterZero(pGetCoeff(p),C)) p = p_Neg(p,r);
2920 return p;
2921 }
2922
2924 {
2925 if(!n_GreaterZero(pGetCoeff(p),C)) p = p_Neg(p,r);
2926 return p;
2927 }
2928
2929 assume(p != NULL);
2930
2931 if(pNext(p)==NULL)
2932 {
2933 if (!TEST_OPT_CONTENTSB)
2934 p_SetCoeff(p,n_Init(1,C),r);
2935 else if(!n_GreaterZero(pGetCoeff(p),C))
2936 p = p_Neg(p,r);
2937 return p;
2938 }
2939
2940 assume(pNext(p)!=NULL);
2941 poly start=p;
2942
2943#if 0 && CLEARENUMERATORS
2944//CF: does not seem to work that well..
2945
2946 if( nCoeff_is_Q(C) || nCoeff_is_Q_a(C) )
2947 {
2950 n_ClearContent(itr, C); // divide out the content
2951 p_Test(p, r); n_Test(pGetCoeff(p), C);
2952 assume(n_GreaterZero(pGetCoeff(p), C)); // ??
2953// if(!n_GreaterZero(pGetCoeff(p),C)) p = p_Neg(p,r);
2954 return start;
2955 }
2956#endif
2957
2958 if(1)
2959 {
2960 // get lcm of all denominators ----------------------------------
2961 h = n_Init(1,C);
2962 while (p!=NULL)
2963 {
2966 n_Delete(&h,C);
2967 h=d;
2968 pIter(p);
2969 }
2970 /* h now contains the 1/lcm of all denominators */
2971 if(!n_IsOne(h,C))
2972 {
2973 // multiply by the lcm of all denominators
2974 p = start;
2975 while (p!=NULL)
2976 {
2977 d=n_Mult(h,pGetCoeff(p),C);
2978 n_Normalize(d,C);
2979 p_SetCoeff(p,d,r);
2980 pIter(p);
2981 }
2982 }
2983 n_Delete(&h,C);
2984 p=start;
2985
2986 p_ContentForGB(p,r);
2987#ifdef HAVE_RATGRING
2988 if (rIsRatGRing(r))
2989 {
2990 /* quick unit detection in the rational case is done in gr_nc_bba */
2991 p_ContentRat(p, r);
2992 start=p;
2993 }
2994#endif
2995 }
2996
2997 if(!n_GreaterZero(pGetCoeff(p),C)) p = p_Neg(p,r);
2998
2999 return start;
3000}
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:639
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:698
static FORCE_INLINE BOOLEAN nCoeff_is_Q(const coeffs r)
Definition coeffs.h:801
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:934
static FORCE_INLINE BOOLEAN nCoeff_is_Q_a(const coeffs r)
Definition coeffs.h:880
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:927
static FORCE_INLINE void n_Normalize(number &n, const coeffs r)
inplace-normalization of n; produces some canonical representation of n;
Definition coeffs.h:581
#define TEST_OPT_INTSTRATEGY
Definition options.h:112
#define TEST_OPT_CONTENTSB
Definition options.h:129
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:2403
static poly p_Neg(poly p, const ring r)
Definition p_polys.h:1114
static BOOLEAN rIsRatGRing(const ring r)
Definition ring.h:433

◆ p_Cleardenom_n()

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

Definition at line 3002 of file p_polys.cc.

3003{
3004 const coeffs C = r->cf;
3005 number d, h;
3006
3007 assume( ph != NULL );
3008
3009 poly p = ph;
3010
3011#if CLEARENUMERATORS
3012 if( 0 )
3013 {
3015
3016 n_ClearDenominators(itr, d, C); // multiply with common denom. d
3017 n_ClearContent(itr, h, C); // divide by the content h
3018
3019 c = n_Div(d, h, C); // d/h
3020
3021 n_Delete(&d, C);
3022 n_Delete(&h, C);
3023
3024 n_Test(c, C);
3025
3026 p_Test(ph, r); n_Test(pGetCoeff(ph), C);
3027 assume(n_GreaterZero(pGetCoeff(ph), C)); // ??
3028/*
3029 if(!n_GreaterZero(pGetCoeff(ph),C))
3030 {
3031 ph = p_Neg(ph,r);
3032 c = n_InpNeg(c, C);
3033 }
3034*/
3035 return;
3036 }
3037#endif
3038
3039
3040 if( pNext(p) == NULL )
3041 {
3043 {
3044 c=n_Invers(pGetCoeff(p), C);
3045 p_SetCoeff(p, n_Init(1, C), r);
3046 }
3047 else
3048 {
3049 c=n_Init(1,C);
3050 }
3051
3052 if(!n_GreaterZero(pGetCoeff(ph),C))
3053 {
3054 ph = p_Neg(ph,r);
3055 c = n_InpNeg(c, C);
3056 }
3057
3058 return;
3059 }
3060 if (TEST_OPT_CONTENTSB) { c=n_Init(1,C); return; }
3061
3062 assume( pNext(p) != NULL );
3063
3064#if CLEARENUMERATORS
3065 if( nCoeff_is_Q(C) || nCoeff_is_Q_a(C) )
3066 {
3068
3069 n_ClearDenominators(itr, d, C); // multiply with common denom. d
3070 n_ClearContent(itr, h, C); // divide by the content h
3071
3072 c = n_Div(d, h, C); // d/h
3073
3074 n_Delete(&d, C);
3075 n_Delete(&h, C);
3076
3077 n_Test(c, C);
3078
3079 p_Test(ph, r); n_Test(pGetCoeff(ph), C);
3080 assume(n_GreaterZero(pGetCoeff(ph), C)); // ??
3081/*
3082 if(!n_GreaterZero(pGetCoeff(ph),C))
3083 {
3084 ph = p_Neg(ph,r);
3085 c = n_InpNeg(c, C);
3086 }
3087*/
3088 return;
3089 }
3090#endif
3091
3092
3093
3094
3095 if(1)
3096 {
3097 h = n_Init(1,C);
3098 while (p!=NULL)
3099 {
3102 n_Delete(&h,C);
3103 h=d;
3104 pIter(p);
3105 }
3106 c=h;
3107 /* contains the 1/lcm of all denominators */
3108 if(!n_IsOne(h,C))
3109 {
3110 p = ph;
3111 while (p!=NULL)
3112 {
3113 /* should be: // NOTE: don't use ->coef!!!!
3114 * number hh;
3115 * nGetDenom(p->coef,&hh);
3116 * nMult(&h,&hh,&d);
3117 * nNormalize(d);
3118 * nDelete(&hh);
3119 * nMult(d,p->coef,&hh);
3120 * nDelete(&d);
3121 * nDelete(&(p->coef));
3122 * p->coef =hh;
3123 */
3124 d=n_Mult(h,pGetCoeff(p),C);
3125 n_Normalize(d,C);
3126 p_SetCoeff(p,d,r);
3127 pIter(p);
3128 }
3129 if (rField_is_Q_a(r))
3130 {
3131 loop
3132 {
3133 h = n_Init(1,C);
3134 p=ph;
3135 while (p!=NULL)
3136 {
3138 n_Delete(&h,C);
3139 h=d;
3140 pIter(p);
3141 }
3142 /* contains the 1/lcm of all denominators */
3143 if(!n_IsOne(h,C))
3144 {
3145 p = ph;
3146 while (p!=NULL)
3147 {
3148 /* should be: // NOTE: don't use ->coef!!!!
3149 * number hh;
3150 * nGetDenom(p->coef,&hh);
3151 * nMult(&h,&hh,&d);
3152 * nNormalize(d);
3153 * nDelete(&hh);
3154 * nMult(d,p->coef,&hh);
3155 * nDelete(&d);
3156 * nDelete(&(p->coef));
3157 * p->coef =hh;
3158 */
3159 d=n_Mult(h,pGetCoeff(p),C);
3160 n_Normalize(d,C);
3161 p_SetCoeff(p,d,r);
3162 pIter(p);
3163 }
3164 number t=n_Mult(c,h,C);
3165 n_Delete(&c,C);
3166 c=t;
3167 }
3168 else
3169 {
3170 break;
3171 }
3172 n_Delete(&h,C);
3173 }
3174 }
3175 }
3176 }
3177
3178 if(!n_GreaterZero(pGetCoeff(ph),C))
3179 {
3180 ph = p_Neg(ph,r);
3181 c = n_InpNeg(c, C);
3182 }
3183
3184}
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:567
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:618
static BOOLEAN rField_is_Q_a(const ring r)
Definition ring.h:545

◆ p_Cmp()

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

Definition at line 1748 of file p_polys.h.

1749{
1750 if (p2==NULL)
1751 {
1752 if (p1==NULL) return 0;
1753 return 1;
1754 }
1755 if (p1==NULL)
1756 return -1;
1757 return p_LmCmp(p1,p2,r);
1758}

◆ p_CmpPolys()

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

Definition at line 1760 of file p_polys.h.

1761{
1762 if (p2==NULL)
1763 {
1764 if (p1==NULL) return 0;
1765 return 1;
1766 }
1767 if (p1==NULL)
1768 return -1;
1769 return p_ComparePolys(p1,p2,r);
1770}

◆ p_Comp_k_n()

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

Definition at line 642 of file p_polys.h.

643{
644 if ((a==NULL) || (b==NULL) ) return FALSE;
645 p_LmCheckPolyRing2(a, r);
647 pAssume2(k > 0 && k <= r->N);
648 int i=k;
649 for(;i<=r->N;i++)
650 {
651 if (p_GetExp(a,i,r) != p_GetExp(b,i,r)) return FALSE;
652 // if (a->exp[(r->VarOffset[i] & 0xffffff)] != b->exp[(r->VarOffset[i] & 0xffffff)]) return FALSE;
653 }
654 return TRUE;
655}
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 5050 of file p_polys.cc.

5051{
5052 int r=p_Cmp(a,b,R);
5053 if ((r==0)&&(a!=NULL))
5054 {
5055 number h=n_Sub(pGetCoeff(a),pGetCoeff(b),R->cf);
5056 /* compare lead coeffs */
5057 r = -1+n_IsZero(h,R->cf)+2*n_GreaterZero(h,R->cf); /* -1: <, 0:==, 1: > */
5058 n_Delete(&h,R->cf);
5059 }
5060 else if (a==NULL)
5061 {
5062 if (b==NULL)
5063 {
5064 /* compare 0, 0 */
5065 r=0;
5066 }
5067 else if(p_IsConstant(b,R))
5068 {
5069 /* compare 0, const */
5070 r = 1-2*n_GreaterZero(pGetCoeff(b),R->cf); /* -1: <, 1: > */
5071 }
5072 }
5073 else if (b==NULL)
5074 {
5075 if (p_IsConstant(a,R))
5076 {
5077 /* compare const, 0 */
5078 r = -1+2*n_GreaterZero(pGetCoeff(a),R->cf); /* -1: <, 1: > */
5079 }
5080 }
5081 return(r);
5082}
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:658

◆ 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 4730 of file p_polys.cc.

4731{
4732 number n,nn;
4733 pAssume(p1 != NULL && p2 != NULL);
4734
4735 if (!p_LmEqual(p1,p2,r)) //compare leading mons
4736 return FALSE;
4737 if ((pNext(p1)==NULL) && (pNext(p2)!=NULL))
4738 return FALSE;
4739 if ((pNext(p2)==NULL) && (pNext(p1)!=NULL))
4740 return FALSE;
4741 if (pLength(p1) != pLength(p2))
4742 return FALSE;
4743 #ifdef HAVE_RINGS
4744 if (rField_is_Ring(r))
4745 {
4746 if (!n_DivBy(pGetCoeff(p1), pGetCoeff(p2), r->cf)) return FALSE;
4747 }
4748 #endif
4749 n=n_Div(pGetCoeff(p1),pGetCoeff(p2),r->cf);
4750 while ((p1 != NULL) /*&& (p2 != NULL)*/)
4751 {
4752 if ( ! p_LmEqual(p1, p2,r))
4753 {
4754 n_Delete(&n, r->cf);
4755 return FALSE;
4756 }
4757 if (!n_Equal(pGetCoeff(p1), nn = n_Mult(pGetCoeff(p2),n, r->cf), r->cf))
4758 {
4759 n_Delete(&n, r->cf);
4760 n_Delete(&nn, r->cf);
4761 return FALSE;
4762 }
4763 n_Delete(&nn, r->cf);
4764 pIter(p1);
4765 pIter(p2);
4766 }
4767 n_Delete(&n, r->cf);
4768 return TRUE;
4769}
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:750
#define pAssume(cond)
Definition monomials.h:90
#define p_LmEqual(p1, p2, r)
Definition p_polys.h:1744

◆ p_Content()

void p_Content ( poly  p,
const ring  r 
)

Definition at line 2343 of file p_polys.cc.

2344{
2345 if (ph==NULL) return;
2346 const coeffs cf=r->cf;
2347 if (pNext(ph)==NULL)
2348 {
2349 p_SetCoeff(ph,n_Init(1,cf),r);
2350 return;
2351 }
2352 if ((cf->cfSubringGcd==ndGcd)
2353 || (cf->cfGcd==ndGcd)) /* trivial gcd*/
2354 return;
2355 number h;
2356 if ((rField_is_Q(r))
2357 || (rField_is_Q_a(r))
2358 || (rField_is_Zp_a)(r)
2359 || (rField_is_Z(r))
2360 )
2361 {
2362 h=p_InitContent(ph,r); /* first guess of a gcd of all coeffs */
2363 }
2364 else
2365 {
2367 }
2368 poly p;
2369 if(n_IsOne(h,cf))
2370 {
2371 goto content_finish;
2372 }
2373 p=ph;
2374 // take the SubringGcd of all coeffs
2375 while (p!=NULL)
2376 {
2379 n_Delete(&h,cf);
2380 h = d;
2381 if(n_IsOne(h,cf))
2382 {
2383 goto content_finish;
2384 }
2385 pIter(p);
2386 }
2387 // if found<>1, divide by it
2388 p = ph;
2389 while (p!=NULL)
2390 {
2392 p_SetCoeff(p,d,r);
2393 pIter(p);
2394 }
2396 n_Delete(&h,r->cf);
2397 // and last: check leading sign:
2398 if(!n_GreaterZero(pGetCoeff(ph),r->cf)) ph = p_Neg(ph,r);
2399}
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:625
static FORCE_INLINE number n_SubringGcd(number a, number b, const coeffs r)
Definition coeffs.h:669
number ndGcd(number, number, const coeffs r)
Definition numbers.cc:193
number p_InitContent(poly ph, const ring r)
Definition p_polys.cc:2683
static BOOLEAN rField_is_Zp_a(const ring r)
Definition ring.h:535

◆ p_ContentForGB()

void p_ContentForGB ( poly  p,
const ring  r 
)

Definition at line 2403 of file p_polys.cc.

2404{
2405 if(TEST_OPT_CONTENTSB) return;
2406 assume( ph != NULL );
2407
2408 assume( r != NULL ); assume( r->cf != NULL );
2409
2410
2411#if CLEARENUMERATORS
2412 if( 0 )
2413 {
2414 const coeffs C = r->cf;
2415 // experimentall (recursive enumerator treatment) of alg. Ext!
2417 n_ClearContent(itr, r->cf);
2418
2419 p_Test(ph, r); n_Test(pGetCoeff(ph), C);
2420 assume(n_GreaterZero(pGetCoeff(ph), C)); // ??
2421
2422 // if(!n_GreaterZero(pGetCoeff(ph),r->cf)) ph = p_Neg(ph,r);
2423 return;
2424 }
2425#endif
2426
2427
2428#ifdef HAVE_RINGS
2429 if (rField_is_Ring(r))
2430 {
2431 if (rField_has_Units(r))
2432 {
2433 number k = n_GetUnit(pGetCoeff(ph),r->cf);
2434 if (!n_IsOne(k,r->cf))
2435 {
2436 number tmpGMP = k;
2437 k = n_Invers(k,r->cf);
2438 n_Delete(&tmpGMP,r->cf);
2439 poly h = pNext(ph);
2440 p_SetCoeff(ph, n_Mult(pGetCoeff(ph), k,r->cf),r);
2441 while (h != NULL)
2442 {
2443 p_SetCoeff(h, n_Mult(pGetCoeff(h), k,r->cf),r);
2444 pIter(h);
2445 }
2446// assume( n_GreaterZero(pGetCoeff(ph),r->cf) );
2447// if(!n_GreaterZero(pGetCoeff(ph),r->cf)) ph = p_Neg(ph,r);
2448 }
2449 n_Delete(&k,r->cf);
2450 }
2451 return;
2452 }
2453#endif
2454 number h,d;
2455 poly p;
2456
2457 if(pNext(ph)==NULL)
2458 {
2459 p_SetCoeff(ph,n_Init(1,r->cf),r);
2460 }
2461 else
2462 {
2463 assume( pNext(ph) != NULL );
2464#if CLEARENUMERATORS
2465 if( nCoeff_is_Q(r->cf) )
2466 {
2467 // experimentall (recursive enumerator treatment) of alg. Ext!
2469 n_ClearContent(itr, r->cf);
2470
2471 p_Test(ph, r); n_Test(pGetCoeff(ph), r->cf);
2472 assume(n_GreaterZero(pGetCoeff(ph), r->cf)); // ??
2473
2474 // if(!n_GreaterZero(pGetCoeff(ph),r->cf)) ph = p_Neg(ph,r);
2475 return;
2476 }
2477#endif
2478
2479 n_Normalize(pGetCoeff(ph),r->cf);
2480 if(!n_GreaterZero(pGetCoeff(ph),r->cf)) ph = p_Neg(ph,r);
2481 if (rField_is_Q(r)||(getCoeffType(r->cf)==n_transExt)) // should not be used anymore if CLEARENUMERATORS is 1
2482 {
2483 h=p_InitContent(ph,r);
2484 p=ph;
2485 }
2486 else
2487 {
2488 h=n_Copy(pGetCoeff(ph),r->cf);
2489 p = pNext(ph);
2490 }
2491 while (p!=NULL)
2492 {
2493 n_Normalize(pGetCoeff(p),r->cf);
2494 d=n_SubringGcd(h,pGetCoeff(p),r->cf);
2495 n_Delete(&h,r->cf);
2496 h = d;
2497 if(n_IsOne(h,r->cf))
2498 {
2499 break;
2500 }
2501 pIter(p);
2502 }
2503 //number tmp;
2504 if(!n_IsOne(h,r->cf))
2505 {
2506 p = ph;
2507 while (p!=NULL)
2508 {
2509 //d = nDiv(pGetCoeff(p),h);
2510 //tmp = nExactDiv(pGetCoeff(p),h);
2511 //if (!nEqual(d,tmp))
2512 //{
2513 // StringSetS("** div0:");nWrite(pGetCoeff(p));StringAppendS("/");
2514 // nWrite(h);StringAppendS("=");nWrite(d);StringAppendS(" int:");
2515 // nWrite(tmp);Print(StringEndS("\n")); // NOTE/TODO: use StringAppendS("\n"); omFree(s);
2516 //}
2517 //nDelete(&tmp);
2518 d = n_ExactDiv(pGetCoeff(p),h,r->cf);
2519 p_SetCoeff(p,d,r);
2520 pIter(p);
2521 }
2522 }
2523 n_Delete(&h,r->cf);
2524 if (rField_is_Q_a(r))
2525 {
2526 // special handling for alg. ext.:
2527 if (getCoeffType(r->cf)==n_algExt)
2528 {
2529 h = n_Init(1, r->cf->extRing->cf);
2530 p=ph;
2531 while (p!=NULL)
2532 { // each monom: coeff in Q_a
2533 poly c_n_n=(poly)pGetCoeff(p);
2534 poly c_n=c_n_n;
2535 while (c_n!=NULL)
2536 { // each monom: coeff in Q
2537 d=n_NormalizeHelper(h,pGetCoeff(c_n),r->cf->extRing->cf);
2538 n_Delete(&h,r->cf->extRing->cf);
2539 h=d;
2540 pIter(c_n);
2541 }
2542 pIter(p);
2543 }
2544 /* h contains the 1/lcm of all denominators in c_n_n*/
2545 //n_Normalize(h,r->cf->extRing->cf);
2546 if(!n_IsOne(h,r->cf->extRing->cf))
2547 {
2548 p=ph;
2549 while (p!=NULL)
2550 { // each monom: coeff in Q_a
2551 poly c_n=(poly)pGetCoeff(p);
2552 while (c_n!=NULL)
2553 { // each monom: coeff in Q
2554 d=n_Mult(h,pGetCoeff(c_n),r->cf->extRing->cf);
2555 n_Normalize(d,r->cf->extRing->cf);
2556 n_Delete(&pGetCoeff(c_n),r->cf->extRing->cf);
2557 pGetCoeff(c_n)=d;
2558 pIter(c_n);
2559 }
2560 pIter(p);
2561 }
2562 }
2563 n_Delete(&h,r->cf->extRing->cf);
2564 }
2565 /*else
2566 {
2567 // special handling for rat. functions.:
2568 number hzz =NULL;
2569 p=ph;
2570 while (p!=NULL)
2571 { // each monom: coeff in Q_a (Z_a)
2572 fraction f=(fraction)pGetCoeff(p);
2573 poly c_n=NUM(f);
2574 if (hzz==NULL)
2575 {
2576 hzz=n_Copy(pGetCoeff(c_n),r->cf->extRing->cf);
2577 pIter(c_n);
2578 }
2579 while ((c_n!=NULL)&&(!n_IsOne(hzz,r->cf->extRing->cf)))
2580 { // each monom: coeff in Q (Z)
2581 d=n_Gcd(hzz,pGetCoeff(c_n),r->cf->extRing->cf);
2582 n_Delete(&hzz,r->cf->extRing->cf);
2583 hzz=d;
2584 pIter(c_n);
2585 }
2586 pIter(p);
2587 }
2588 // hzz contains the gcd of all numerators in f
2589 h=n_Invers(hzz,r->cf->extRing->cf);
2590 n_Delete(&hzz,r->cf->extRing->cf);
2591 n_Normalize(h,r->cf->extRing->cf);
2592 if(!n_IsOne(h,r->cf->extRing->cf))
2593 {
2594 p=ph;
2595 while (p!=NULL)
2596 { // each monom: coeff in Q_a (Z_a)
2597 fraction f=(fraction)pGetCoeff(p);
2598 NUM(f)=__p_Mult_nn(NUM(f),h,r->cf->extRing);
2599 p_Normalize(NUM(f),r->cf->extRing);
2600 pIter(p);
2601 }
2602 }
2603 n_Delete(&h,r->cf->extRing->cf);
2604 }*/
2605 }
2606 }
2607 if(!n_GreaterZero(pGetCoeff(ph),r->cf)) ph = p_Neg(ph,r);
2608}
@ 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:537
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition coeffs.h:431
static BOOLEAN rField_has_Units(const ring r)
Definition ring.h:496

◆ 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 instead 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:649
#define D(A)
Definition gentable.cc:128
#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:938
static poly p_Mult_q(poly p, poly q, const ring r)
Definition p_polys.h:1125
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition p_polys.h:848
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:409

◆ 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 885 of file p_polys.h.

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

◆ p_Copy() [2/2]

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

returns a copy of p

Definition at line 848 of file p_polys.h.

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

◆ 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 838 of file p_polys.h.

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

◆ p_CopyPowerProduct()

poly p_CopyPowerProduct ( const poly  p,
const ring  r 
)

like p_Head, but with coefficient 1

Definition at line 5134 of file p_polys.cc.

5135{
5136 if (p == NULL) return NULL;
5137 return p_CopyPowerProduct0(p,n_Init(1,r->cf),r);
5138}
poly p_CopyPowerProduct0(const poly p, number n, const ring r)
like p_Head, but with coefficient n
Definition p_polys.cc:5122

◆ p_CopyPowerProduct0()

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

like p_Head, but with coefficient n

Definition at line 5122 of file p_polys.cc.

5123{
5125 poly np;
5126 omTypeAllocBin(poly, np, r->PolyBin);
5127 p_SetRingOfLm(np, r);
5128 memcpy(np->exp, p->exp, r->ExpL_Size*sizeof(long));
5129 pNext(np) = NULL;
5130 pSetCoeff0(np, n);
5131 return np;
5132}

◆ p_DecrExp()

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

Definition at line 600 of file p_polys.h.

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

◆ 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:423

◆ 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 910 of file p_polys.h.

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

◆ p_Delete() [2/2]

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

Definition at line 903 of file p_polys.h.

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

◆ p_DeleteComp()

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

Definition at line 3668 of file p_polys.cc.

3669{
3670 poly q;
3671 long unsigned kk=k;
3672
3673 while ((*p!=NULL) && (__p_GetComp(*p,r)==kk)) p_LmDelete(p,r);
3674 if (*p==NULL) return;
3675 q = *p;
3676 if (__p_GetComp(q,r)>kk)
3677 {
3678 p_SubComp(q,1,r);
3679 p_SetmComp(q,r);
3680 }
3681 while (pNext(q)!=NULL)
3682 {
3683 unsigned long c=__p_GetComp(pNext(q),r);
3684 if (/*__p_GetComp(pNext(q),r)*/c==kk)
3685 p_LmDelete(&(pNext(q)),r);
3686 else
3687 {
3688 pIter(q);
3689 if (/*__p_GetComp(q,r)*/c>kk)
3690 {
3691 p_SubComp(q,1,r);
3692 p_SetmComp(q,r);
3693 }
3694 }
3695 }
3696}
static unsigned long p_SubComp(poly p, unsigned long v, ring r)
Definition p_polys.h:455
#define p_SetmComp
Definition p_polys.h:246

◆ 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:1138
static long p_DecrExp(poly p, int v, ring r)
Definition p_polys.h:600

◆ 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:973
static BOOLEAN rIsNCRing(const ring r)
Definition ring.h:427

◆ p_DivisibleBy()

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

Definition at line 1921 of file p_polys.h.

1922{
1924 pIfThen1(a!=NULL, p_LmCheckPolyRing1(a, r));
1925
1926 if (a != NULL && (p_GetComp(a, r) == 0 || p_GetComp(a,r) == p_GetComp(b,r)))
1927 return _p_LmDivisibleByNoComp(a,b,r);
1928 return FALSE;
1929}

◆ 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 4666 of file p_polys.cc.

4667{
4668 while ((p1 != NULL) && (p2 != NULL))
4669 {
4670 if (! p_LmEqual(p1, p2,r))
4671 return FALSE;
4672 if (! n_Equal(p_GetCoeff(p1,r), p_GetCoeff(p2,r),r->cf ))
4673 return FALSE;
4674 pIter(p1);
4675 pIter(p2);
4676 }
4677 return (p1==p2);
4678}

◆ 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 4704 of file p_polys.cc.

4705{
4706 assume( r1 == r2 || rSamePolyRep(r1, r2) ); // will be used in rEqual!
4707 assume( r1->cf == r2->cf );
4708
4709 while ((p1 != NULL) && (p2 != NULL))
4710 {
4711 // returns 1 if ExpVector(p)==ExpVector(q): does not compare numbers !!
4712 // #define p_LmEqual(p1, p2, r) p_ExpVectorEqual(p1, p2, r)
4713
4714 if (! p_ExpVectorEqual(p1, p2, r1, r2))
4715 return FALSE;
4716
4717 if (! n_Equal(p_GetCoeff(p1,r1), p_GetCoeff(p2,r2), r1->cf ))
4718 return FALSE;
4719
4720 pIter(p1);
4721 pIter(p2);
4722 }
4723 return (p1==p2);
4724}
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:1805

◆ p_ExpVectorAdd()

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

Definition at line 1432 of file p_polys.h.

1433{
1434 p_LmCheckPolyRing1(p1, r);
1435 p_LmCheckPolyRing1(p2, r);
1436#if PDEBUG >= 1
1437 for (int i=1; i<=r->N; i++)
1438 pAssume1((unsigned long) (p_GetExp(p1, i, r) + p_GetExp(p2, i, r)) <= r->bitmask);
1439 pAssume1(p_GetComp(p1, r) == 0 || p_GetComp(p2, r) == 0);
1440#endif
1441
1442 p_MemAdd_LengthGeneral(p1->exp, p2->exp, r->ExpL_Size);
1444}

◆ p_ExpVectorAddSub()

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

Definition at line 1477 of file p_polys.h.

1478{
1479 p_LmCheckPolyRing1(p1, r);
1480 p_LmCheckPolyRing1(p2, r);
1482#if PDEBUG >= 1
1483 for (int i=1; i<=r->N; i++)
1484 pAssume1(p_GetExp(p1, i, r) + p_GetExp(p2, i, r) >= p_GetExp(p3, i, r));
1485 pAssume1(p_GetComp(p1, r) == 0 ||
1486 (p_GetComp(p2, r) - p_GetComp(p3, r) == 0) ||
1487 (p_GetComp(p1, r) == p_GetComp(p2, r) - p_GetComp(p3, r)));
1488#endif
1489
1490 p_MemAddSub_LengthGeneral(p1->exp, p2->exp, p3->exp, r->ExpL_Size);
1491 // no need to adjust in case of NegWeights
1492}

◆ p_ExpVectorCopy()

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

Definition at line 1334 of file p_polys.h.

1335{
1338 memcpy(d_p->exp, s_p->exp, r->ExpL_Size*sizeof(long));
1339}

◆ p_ExpVectorDiff()

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

Definition at line 1495 of file p_polys.h.

1496{
1497 p_LmCheckPolyRing1(p1, r);
1498 p_LmCheckPolyRing1(p2, r);
1500#if PDEBUG >= 2
1501 for (int i=1; i<=r->N; i++)
1502 pAssume1(p_GetExp(p1, i, r) >= p_GetExp(p2, i, r));
1503 pAssume1(!rRing_has_Comp(r) || p_GetComp(p1, r) == p_GetComp(p2, r));
1504#endif
1505
1506 p_MemDiff_LengthGeneral(pr->exp, p1->exp, p2->exp, r->ExpL_Size);
1508}

◆ p_ExpVectorEqual()

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

Definition at line 1510 of file p_polys.h.

1511{
1512 p_LmCheckPolyRing1(p1, r);
1513 p_LmCheckPolyRing1(p2, r);
1514
1515 unsigned i = r->ExpL_Size;
1516 unsigned long *ep = p1->exp;
1517 unsigned long *eq = p2->exp;
1518
1519 do
1520 {
1521 i--;
1522 if (ep[i] != eq[i]) return FALSE;
1523 }
1524 while (i!=0);
1525 return TRUE;
1526}

◆ p_ExpVectorSub()

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

Definition at line 1461 of file p_polys.h.

1462{
1463 p_LmCheckPolyRing1(p1, r);
1464 p_LmCheckPolyRing1(p2, r);
1465#if PDEBUG >= 1
1466 for (int i=1; i<=r->N; i++)
1467 pAssume1(p_GetExp(p1, i, r) >= p_GetExp(p2, i, r));
1468 pAssume1(p_GetComp(p1, r) == 0 || p_GetComp(p2, r) == 0 ||
1469 p_GetComp(p1, r) == p_GetComp(p2, r));
1470#endif
1471
1472 p_MemSub_LengthGeneral(p1->exp, p2->exp, r->ExpL_Size);
1474}

◆ p_ExpVectorSum()

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

Definition at line 1446 of file p_polys.h.

1447{
1448 p_LmCheckPolyRing1(p1, r);
1449 p_LmCheckPolyRing1(p2, r);
1451#if PDEBUG >= 1
1452 for (int i=1; i<=r->N; i++)
1453 pAssume1((unsigned long) (p_GetExp(p1, i, r) + p_GetExp(p2, i, r)) <= r->bitmask);
1454 pAssume1(p_GetComp(p1, r) == 0 || p_GetComp(p2, r) == 0);
1455#endif
1456
1457 p_MemSum_LengthGeneral(pr->exp, p1->exp, p2->exp, r->ExpL_Size);
1459}

◆ 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:762

◆ p_FDeg()

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

Definition at line 382 of file p_polys.h.

382{ 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 5084 of file p_polys.cc.

5085{
5086 assume(f!=NULL);
5087 assume(g!=NULL);
5088 assume(pNext(f)==NULL);
5089 poly G=p_Head(f,r);
5090 poly h=g;
5091 int *mf=(int*)omAlloc((r->N+1)*sizeof(int));
5092 p_GetExpV(f,mf,r);
5093 int *mh=(int*)omAlloc((r->N+1)*sizeof(int));
5096 loop
5097 {
5098 if (h==NULL) break;
5099 if(!one_coeff)
5100 {
5102 one_coeff=n_IsOne(n,r->cf);
5103 p_SetCoeff(G,n,r);
5104 }
5105 p_GetExpV(h,mh,r);
5107 for(unsigned j=r->N;j!=0;j--)
5108 {
5109 if (mh[j]<mf[j]) mf[j]=mh[j];
5110 if (mf[j]>0) const_mon=FALSE;
5111 }
5112 if (one_coeff && const_mon) break;
5113 pIter(h);
5114 }
5115 mf[0]=0;
5116 p_SetExpV(G,mf,r); // included is p_SetComp, p_Setm
5117 omFreeSize(mf,(r->N+1)*sizeof(int));
5118 omFreeSize(mh,(r->N+1)*sizeof(int));
5119 return G;
5120}
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:642
static void p_SetCompP(poly p, int i, ring r)
Definition p_polys.h:256

◆ 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 574 of file p_polys.h.

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

◆ p_GetExp() [2/3]

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

Definition at line 557 of file p_polys.h.

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

◆ 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 471 of file p_polys.h.

472{
473 pAssume2((VarOffset >> (24 + 6)) == 0);
474#if 0
475 int pos=(VarOffset & 0xffffff);
476 int bitpos=(VarOffset >> 24);
477 unsigned long exp=(p->exp[pos] >> bitmask) & iBitmask;
478 return exp;
479#else
480 return (long)
481 ((p->exp[(VarOffset & 0xffffff)] >> (VarOffset >> 24))
482 & iBitmask);
483#endif
484}
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 1393 of file p_polys.h.

1394{
1395 if (p == NULL) return NULL;
1397 poly np;
1398 omTypeAllocBin(poly, np, r->PolyBin);
1399 p_SetRingOfLm(np, r);
1400 memcpy(np->exp, p->exp, r->ExpL_Size*sizeof(long));
1401 pNext(np) = NULL;
1402 pSetCoeff0(np, n_Init(1, r->cf));
1403 int i;
1404 for(i=l;i<=k;i++)
1405 {
1406 //np->exp[(r->VarOffset[i] & 0xffffff)] =0;
1407 p_SetExp(np,i,0,r);
1408 }
1409 p_Setm(np,r);
1410 return np;
1411}

◆ p_GetExpDiff()

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

Definition at line 637 of file p_polys.h.

638{
639 return p_GetExp(p1,i,r) - p_GetExp(p2,i,r);
640}

◆ p_GetExpSum()

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

Definition at line 631 of file p_polys.h.

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

◆ p_GetExpV()

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

Definition at line 1541 of file p_polys.h.

1542{
1544 for (unsigned j = r->N; j!=0; j--)
1545 ev[j] = p_GetExp(p, j, r);
1546
1547 ev[0] = p_GetComp(p, r);
1548}

◆ p_GetExpVL()

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

Definition at line 1550 of file p_polys.h.

1551{
1553 for (unsigned j = r->N; j!=0; j--)
1554 ev[j-1] = p_GetExp(p, j, r);
1555}

◆ p_GetExpVLV()

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

Definition at line 1557 of file p_polys.h.

1558{
1560 for (unsigned j = r->N; j!=0; j--)
1561 ev[j-1] = p_GetExp(p, j, r);
1562 return (int64)p_GetComp(p,r);
1563}

◆ p_GetMaxExp() [1/2]

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

Definition at line 806 of file p_polys.h.

807{
808 return p_GetMaxExp(p_GetMaxExpL(p, r), r);
809}
static unsigned long p_GetMaxExp(const unsigned long l, const ring r)
Definition p_polys.h:783
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 783 of file p_polys.h.

784{
785 unsigned long bitmask = r->bitmask;
786 unsigned long max = (l & bitmask);
787 unsigned long j = r->ExpPerLong - 1;
788
789 if (j > 0)
790 {
791 unsigned long i = r->BitsPerExp;
792 long e;
793 loop
794 {
795 e = ((l >> i) & bitmask);
796 if ((unsigned long) e > max)
797 max = e;
798 j--;
799 if (j==0) break;
800 i += r->BitsPerExp;
801 }
802 }
803 return max;
804}
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 423 of file p_polys.h.

424{
426 if (r->typ==NULL) return ((p)->exp[r->pOrdIndex]);
427 int i=0;
428 loop
429 {
430 switch(r->typ[i].ord_typ)
431 {
432 case ro_am:
433 case ro_wp_neg:
434 return ((p->exp[r->pOrdIndex])-POLY_NEGWEIGHT_OFFSET);
435 case ro_syzcomp:
436 case ro_syz:
437 case ro_cp:
438 i++;
439 break;
440 //case ro_dp:
441 //case ro_wp:
442 default:
443 return ((p)->exp[r->pOrdIndex]);
444 }
445 }
446}
@ ro_syz
Definition ring.h:61
@ ro_cp
Definition ring.h:59
@ ro_wp_neg
Definition ring.h:57
@ ro_am
Definition ring.h:55

◆ 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:53
@ ro_wp
Definition ring.h:54

◆ p_GetShortExpVector()

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

Definition at line 4934 of file p_polys.cc.

4935{
4936 assume(p != NULL);
4937 unsigned long ev = 0; // short exponent vector
4938 unsigned int n = BIT_SIZEOF_LONG / r->N; // number of bits per exp
4939 unsigned int m1; // highest bit which is filled with (n+1)
4940 unsigned int i=0;
4941 int j=1;
4942
4943 if (n == 0)
4944 {
4945 if (r->N <2*BIT_SIZEOF_LONG)
4946 {
4947 n=1;
4948 m1=0;
4949 }
4950 else
4951 {
4952 for (; j<=r->N; j++)
4953 {
4954 if (p_GetExp(p,j,r) > 0) i++;
4955 if (i == BIT_SIZEOF_LONG) break;
4956 }
4957 if (i>0)
4958 ev = ~(0UL) >> (BIT_SIZEOF_LONG - i);
4959 return ev;
4960 }
4961 }
4962 else
4963 {
4964 m1 = (n+1)*(BIT_SIZEOF_LONG - n*r->N);
4965 }
4966
4967 n++;
4968 while (i<m1)
4969 {
4970 ev |= GetBitFields(p_GetExp(p, j,r), i, n);
4971 i += n;
4972 j++;
4973 }
4974
4975 n--;
4976 while (i<BIT_SIZEOF_LONG)
4977 {
4978 ev |= GetBitFields(p_GetExp(p, j,r), i, n);
4979 i += n;
4980 j++;
4981 }
4982 return ev;
4983}
#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:4902

◆ p_GetShortExpVector0()

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

Definition at line 4985 of file p_polys.cc.

4986{
4987 assume(p != NULL);
4988 assume(r->N >=BIT_SIZEOF_LONG);
4989 unsigned long ev = 0; // short exponent vector
4990
4991 for (int j=BIT_SIZEOF_LONG; j>0; j--)
4992 {
4993 if (p_GetExp(p, j,r)>0)
4994 ev |= Sy_bitL(j-1);
4995 }
4996 return ev;
4997}
#define Sy_bitL(x)
Definition options.h:32

◆ p_GetShortExpVector1()

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

Definition at line 5000 of file p_polys.cc.

5001{
5002 assume(p != NULL);
5003 assume(r->N <BIT_SIZEOF_LONG);
5004 assume(2*r->N >=BIT_SIZEOF_LONG);
5005 unsigned long ev = 0; // short exponent vector
5006 int rest=r->N;
5007 int e;
5008 // 2 bits per exp
5009 int j=r->N;
5010 for (; j>BIT_SIZEOF_LONG-r->N; j--)
5011 {
5012 if ((e=p_GetExp(p, j,r))>0)
5013 {
5014 ev |= Sy_bitL(j-1);
5015 if (e>1)
5016 {
5017 ev|=Sy_bitL(rest+j-1);
5018 }
5019 }
5020 }
5021 // 1 bit per exp
5022 for (; j>0; j--)
5023 {
5024 if (p_GetExp(p, j,r)>0)
5025 {
5026 ev |= Sy_bitL(j-1);
5027 }
5028 }
5029 return ev;
5030}

◆ p_GetTotalDegree()

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

Definition at line 812 of file p_polys.h.

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

◆ 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 862 of file p_polys.h.

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

◆ p_Head0()

poly p_Head0 ( const poly  p,
const ring  r 
)

like p_Head, but allow NULL coeff

Definition at line 5140 of file p_polys.cc.

5141{
5142 if (p==NULL) return NULL;
5143 if (pGetCoeff(p)==NULL) return p_CopyPowerProduct0(p,NULL,r);
5144 return p_Head(p,r);
5145}

◆ p_Homogen()

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

Definition at line 3319 of file p_polys.cc.

3320{
3321 pFDegProc deg;
3322 if (r->pLexOrder && (r->order[0]==ringorder_lp))
3323 deg=p_Totaldegree;
3324 else
3325 deg=r->pFDeg;
3326
3327 poly q=NULL, qn;
3328 int o,ii;
3329 sBucket_pt bp;
3330
3331 if (p!=NULL)
3332 {
3333 if ((varnum < 1) || (varnum > rVar(r)))
3334 {
3335 return NULL;
3336 }
3337 o=deg(p,r);
3338 q=pNext(p);
3339 while (q != NULL)
3340 {
3341 ii=deg(q,r);
3342 if (ii>o) o=ii;
3343 pIter(q);
3344 }
3345 q = p_Copy(p,r);
3346 bp = sBucketCreate(r);
3347 while (q != NULL)
3348 {
3349 ii = o-deg(q,r);
3350 if (ii!=0)
3351 {
3352 p_AddExp(q,varnum, (long)ii,r);
3353 p_Setm(q,r);
3354 }
3355 qn = pNext(q);
3356 pNext(q) = NULL;
3357 sBucket_Add_m(bp, q);
3358 q = qn;
3359 }
3360 sBucketDestroyAdd(bp, &q, &ii);
3361 }
3362 return q;
3363}
static long p_AddExp(poly p, int v, long ee, ring r)
Definition p_polys.h:608
@ ringorder_lp
Definition ring.h:78
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_HomogenDP()

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

Definition at line 3365 of file p_polys.cc.

3366{
3367 poly q=NULL, qn;
3368 int o,ii;
3369 sBucket_pt bp;
3370
3371 if (p!=NULL)
3372 {
3373 if ((varnum < 1) || (varnum > rVar(r)))
3374 {
3375 return NULL;
3376 }
3377 o=p_Totaldegree(p,r);
3378 q=pNext(p);
3379 while (q != NULL)
3380 {
3381 ii=p_Totaldegree(q,r);
3382 if (ii>o) o=ii;
3383 pIter(q);
3384 }
3385 q = p_Copy(p,r);
3386 bp = sBucketCreate(r);
3387 while (q != NULL)
3388 {
3389 ii = o-p_Totaldegree(q,r);
3390 if (ii!=0)
3391 {
3392 p_AddExp(q,varnum, (long)ii,r);
3393 p_Setm(q,r);
3394 }
3395 qn = pNext(q);
3396 pNext(q) = NULL;
3397 sBucket_Add_m(bp, q);
3398 q = qn;
3399 }
3400 sBucketDestroyAdd(bp, &q, &ii);
3401 }
3402 return q;
3403}

◆ p_IncrExp()

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

Definition at line 593 of file p_polys.h.

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

◆ p_Init() [1/2]

static poly p_Init ( const ring  r)
inlinestatic

Definition at line 1351 of file p_polys.h.

1352{
1353 return p_Init(r, r->PolyBin);
1354}

◆ p_Init() [2/2]

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

Definition at line 1341 of file p_polys.h.

1342{
1343 p_CheckRing1(r);
1344 pAssume1(bin != NULL && omSizeWOfBin(r->PolyBin) == omSizeWOfBin(bin));
1345 poly p;
1346 omTypeAlloc0Bin(poly, p, bin);
1348 p_SetRingOfLm(p, r);
1349 return p;
1350}

◆ p_InitContent()

number p_InitContent ( poly  ph,
const ring  r 
)

Definition at line 2683 of file p_polys.cc.

2686{
2688 assume(ph!=NULL);
2689 assume(pNext(ph)!=NULL);
2690 assume(rField_is_Q(r));
2691 if (pNext(pNext(ph))==NULL)
2692 {
2693 return n_GetNumerator(pGetCoeff(pNext(ph)),r->cf);
2694 }
2695 poly p=ph;
2697 pIter(p);
2699 pIter(p);
2700 number d;
2701 number t;
2702 loop
2703 {
2704 nlNormalize(pGetCoeff(p),r->cf);
2705 t=n_GetNumerator(pGetCoeff(p),r->cf);
2706 if (nlGreaterZero(t,r->cf))
2707 d=nlAdd(n1,t,r->cf);
2708 else
2709 d=nlSub(n1,t,r->cf);
2710 nlDelete(&t,r->cf);
2711 nlDelete(&n1,r->cf);
2712 n1=d;
2713 pIter(p);
2714 if (p==NULL) break;
2715 nlNormalize(pGetCoeff(p),r->cf);
2716 t=n_GetNumerator(pGetCoeff(p),r->cf);
2717 if (nlGreaterZero(t,r->cf))
2718 d=nlAdd(n2,t,r->cf);
2719 else
2720 d=nlSub(n2,t,r->cf);
2721 nlDelete(&t,r->cf);
2722 nlDelete(&n2,r->cf);
2723 n2=d;
2724 pIter(p);
2725 if (p==NULL) break;
2726 }
2727 d=nlGcd(n1,n2,r->cf);
2728 nlDelete(&n1,r->cf);
2729 nlDelete(&n2,r->cf);
2730 return d;
2731}
2732#else
2733{
2734 /* ph has al least 2 terms */
2735 number d=pGetCoeff(ph);
2736 int s=n_Size(d,r->cf);
2737 pIter(ph);
2739 int s2=n_Size(d2,r->cf);
2740 pIter(ph);
2741 if (ph==NULL)
2742 {
2743 if (s<s2) return n_Copy(d,r->cf);
2744 else return n_Copy(d2,r->cf);
2745 }
2746 do
2747 {
2749 int ns=n_Size(nd,r->cf);
2750 if (ns<=2)
2751 {
2752 s2=s;
2753 d2=d;
2754 d=nd;
2755 s=ns;
2756 break;
2757 }
2758 else if (ns<s)
2759 {
2760 s2=s;
2761 d2=d;
2762 d=nd;
2763 s=ns;
2764 }
2765 pIter(ph);
2766 }
2767 while(ph!=NULL);
2768 return n_SubringGcd(d,d2,r->cf);
2769}
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:573
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:611
LINLINE number nlAdd(number la, number li, const coeffs r)
Definition longrat.cc:2672
LINLINE number nlSub(number la, number li, const coeffs r)
Definition longrat.cc:2738
LINLINE void nlDelete(number *a, const coeffs r)
Definition longrat.cc:2637
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 1985 of file p_polys.h.

1986{
1987 if (p == NULL) return TRUE;
1988 return (pNext(p)==NULL) && p_LmIsConstant(p, r);
1989}

◆ 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 1979 of file p_polys.h.

1980{
1981 if (p == NULL) return TRUE;
1982 return (pNext(p)==NULL) && p_LmIsConstantComp(p, r);
1983}

◆ p_IsConstantPoly()

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

Definition at line 1999 of file p_polys.h.

2000{
2001 p_Test(p, r);
2002 poly pp=p;
2003 while(pp!=NULL)
2004 {
2005 if (! p_LmIsConstantComp(pp, r))
2006 return FALSE;
2007 pIter(pp);
2008 }
2009 return TRUE;
2010}

◆ 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 3408 of file p_polys.cc.

3409{
3410 poly qp=p;
3411 int o;
3412
3413 if ((p == NULL) || (pNext(p) == NULL)) return TRUE;
3414 pFDegProc d;
3415 if (r->pLexOrder && (r->order[0]==ringorder_lp))
3416 d=p_Totaldegree;
3417 else
3418 d=r->pFDeg;
3419 o = d(p,r);
3420 do
3421 {
3422 if (d(qp,r) != o) return FALSE;
3423 pIter(qp);
3424 }
3425 while (qp != NULL);
3426 return TRUE;
3427}

◆ p_IsHomogeneousDP()

BOOLEAN p_IsHomogeneousDP ( poly  p,
const ring  r 
)

Definition at line 3432 of file p_polys.cc.

3433{
3434 poly qp=p;
3435 int o;
3436
3437 if ((p == NULL) || (pNext(p) == NULL)) return TRUE;
3438 o = p_Totaldegree(p,r);
3439 do
3440 {
3441 if (p_Totaldegree(qp,r) != o) return FALSE;
3442 pIter(qp);
3443 }
3444 while (qp != NULL);
3445 return TRUE;
3446}

◆ p_IsHomogeneousW() [1/2]

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

Definition at line 3468 of file p_polys.cc.

3469{
3470 poly qp=p;
3471 long o;
3472
3473 if ((p == NULL) || (pNext(p) == NULL)) return TRUE;
3474 pIter(qp);
3475 o = totaldegreeWecart_IV(p,r,w->ivGetVec())+(*module_w)[p_GetComp(p,r)];
3476 do
3477 {
3478 long oo=totaldegreeWecart_IV(qp,r,w->ivGetVec())+(*module_w)[p_GetComp(qp,r)];
3479 if (oo != o) return FALSE;
3480 pIter(qp);
3481 }
3482 while (qp != NULL);
3483 return TRUE;
3484}

◆ p_IsHomogeneousW() [2/2]

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

Definition at line 3451 of file p_polys.cc.

3452{
3453 poly qp=p;
3454 long o;
3455
3456 if ((p == NULL) || (pNext(p) == NULL)) return TRUE;
3457 pIter(qp);
3458 o = totaldegreeWecart_IV(p,r,w->ivGetVec());
3459 do
3460 {
3461 if (totaldegreeWecart_IV(qp,r,w->ivGetVec()) != o) return FALSE;
3462 pIter(qp);
3463 }
3464 while (qp != NULL);
3465 return TRUE;
3466}

◆ p_IsOne()

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

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

Definition at line 1992 of file p_polys.h.

1993{
1994 if (p == NULL) return FALSE; /* TODO check if 0 == 1 */
1995 p_Test(p, R);
1996 return (p_IsConstant(p, R) && n_IsOne(p_GetCoeff(p, R), R->cf));
1997}

◆ 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 2012 of file p_polys.h.

2013{
2014 if (p == NULL) return FALSE;
2015 if (rField_is_Ring(r))
2016 return (p_LmIsConstant(p, r) && n_IsUnit(pGetCoeff(p),r->cf));
2017 return p_LmIsConstant(p, r);
2018}

◆ 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 4540 of file p_polys.cc.

4541{
4542 while((p!=NULL) && (p_Totaldegree(p,R)>m)) p_LmDelete(&p,R);
4543 if (p==NULL) return NULL;
4544 poly r=p;
4545 while (pNext(p)!=NULL)
4546 {
4547 if (p_Totaldegree(pNext(p),R)>m)
4548 {
4549 p_LmDelete(&pNext(p),R);
4550 }
4551 else
4552 pIter(p);
4553 }
4554 return r;
4555}

◆ p_JetW()

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

Definition at line 4584 of file p_polys.cc.

4585{
4586 while((p!=NULL) && (totaldegreeWecart_IV(p,R,w)>m)) p_LmDelete(&p,R);
4587 if (p==NULL) return NULL;
4588 poly r=p;
4589 while (pNext(p)!=NULL)
4590 {
4592 {
4593 p_LmDelete(&pNext(p),R);
4594 }
4595 else
4596 pIter(p);
4597 }
4598 return r;
4599}

◆ p_Last()

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

Definition at line 4775 of file p_polys.cc.

4776{
4777 if (p == NULL)
4778 {
4779 l = 0;
4780 return NULL;
4781 }
4782 l = 1;
4783 poly a = p;
4784 if (! rIsSyzIndexRing(r))
4785 {
4786 poly next = pNext(a);
4787 while (next!=NULL)
4788 {
4789 a = next;
4790 next = pNext(a);
4791 l++;
4792 }
4793 }
4794 else
4795 {
4796 long unsigned curr_limit = rGetCurrSyzLimit(r);
4797 poly pp = a;
4798 while ((a=pNext(a))!=NULL)
4799 {
4800 if (__p_GetComp(a,r)<=curr_limit/*syzComp*/)
4801 l++;
4802 else break;
4803 pp = a;
4804 }
4805 a=pp;
4806 }
4807 return a;
4808}
ListNode * next
Definition janet.h:31
static int rGetCurrSyzLimit(const ring r)
Definition ring.h:729
static BOOLEAN rIsSyzIndexRing(const ring r)
Definition ring.h:726

◆ 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:125

◆ 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 383 of file p_polys.h.

383{ 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 1601 of file p_polys.h.

1602{
1604 p_LmCheckPolyRing1(q, r);
1605
1606 const unsigned long* _s1 = ((unsigned long*) p->exp);
1607 const unsigned long* _s2 = ((unsigned long*) q->exp);
1608 REGISTER unsigned long _v1;
1609 REGISTER unsigned long _v2;
1610 const unsigned long _l = r->CmpL_Size;
1611
1612 REGISTER unsigned long _i=0;
1613
1615 _v1 = _s1[_i];
1616 _v2 = _s2[_i];
1617 if (_v1 == _v2)
1618 {
1619 _i++;
1620 if (_i == _l) return 0;
1622 }
1623 const long* _ordsgn = (long*) r->ordsgn;
1624#if 1 /* two variants*/
1625 if (_v1 > _v2)
1626 {
1627 return _ordsgn[_i];
1628 }
1629 return -(_ordsgn[_i]);
1630#else
1631 if (_v1 > _v2)
1632 {
1633 if (_ordsgn[_i] == 1) return 1;
1634 return -1;
1635 }
1636 if (_ordsgn[_i] == 1) return -1;
1637 return 1;
1638#endif
1639}

◆ p_LmDelete() [1/2]

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

Definition at line 745 of file p_polys.h.

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

◆ p_LmDelete() [2/2]

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

Definition at line 725 of file p_polys.h.

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

◆ p_LmDelete0()

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

Definition at line 735 of file p_polys.h.

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

◆ p_LmDeleteAndNext()

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

Definition at line 757 of file p_polys.h.

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

◆ 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 1912 of file p_polys.h.

1913{
1915 pIfThen1(a != NULL, p_LmCheckPolyRing1(b, r));
1916 if (p_GetComp(a, r) == 0 || p_GetComp(a,r) == p_GetComp(b,r))
1917 return _p_LmDivisibleByNoComp(a, b, r);
1918 return FALSE;
1919}

◆ p_LmDivisibleByNoComp() [1/2]

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

Definition at line 1905 of file p_polys.h.

1906{
1909 return _p_LmDivisibleByNoComp(a, ra, b, rb);
1910}

◆ p_LmDivisibleByNoComp() [2/2]

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

Definition at line 1898 of file p_polys.h.

1899{
1900 p_LmCheckPolyRing1(a, r);
1902 return _p_LmDivisibleByNoComp(a, b, r);
1903}

◆ p_LmDivisibleByPart()

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

Definition at line 1883 of file p_polys.h.

1884{
1886 pIfThen1(a != NULL, p_LmCheckPolyRing1(b, r));
1887 if (p_GetComp(a, r) == 0 || p_GetComp(a,r) == p_GetComp(b,r))
1888 return _p_LmDivisibleByNoCompPart(a, r, b, r,start, end);
1889 return FALSE;
1890}

◆ p_LmExpVectorAddIsOk()

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

Definition at line 2020 of file p_polys.h.

2022{
2023 p_LmCheckPolyRing(p1, r);
2024 p_LmCheckPolyRing(p2, r);
2025 unsigned long l1, l2, divmask = r->divmask;
2026 int i;
2027
2028 for (i=0; i<r->VarL_Size; i++)
2029 {
2030 l1 = p1->exp[r->VarL_Offset[i]];
2031 l2 = p2->exp[r->VarL_Offset[i]];
2032 // do the divisiblity trick
2033 if ( (l1 > ULONG_MAX - l2) ||
2034 (((l1 & divmask) ^ (l2 & divmask)) != ((l1 + l2) & divmask)))
2035 return FALSE;
2036 }
2037 return TRUE;
2038}

◆ p_LmFree() [1/2]

static void p_LmFree ( poly *  p,
ring   
)
inlinestatic

Definition at line 698 of file p_polys.h.

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

◆ p_LmFree() [2/2]

static void p_LmFree ( poly  p,
ring   
)
inlinestatic

Definition at line 685 of file p_polys.h.

687{
689 #ifdef XALLOC_BIN
690 omFreeBin(p,r->PolyBin);
691 #else
693 #endif
694}

◆ p_LmFreeAndNext()

static poly p_LmFreeAndNext ( poly  p,
ring   
)
inlinestatic

Definition at line 713 of file p_polys.h.

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

◆ p_LmInit() [1/3]

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

Definition at line 1356 of file p_polys.h.

1357{
1359 poly np;
1360 omTypeAllocBin(poly, np, r->PolyBin);
1361 p_SetRingOfLm(np, r);
1362 memcpy(np->exp, p->exp, r->ExpL_Size*sizeof(long));
1363 pNext(np) = NULL;
1364 pSetCoeff0(np, NULL);
1365 return np;
1366}

◆ p_LmInit() [2/3]

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

Definition at line 1384 of file p_polys.h.

1385{
1386 pAssume1(d_r != NULL);
1387 return p_LmInit(s_p, s_r, d_r, d_r->PolyBin);
1388}

◆ 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 1367 of file p_polys.h.

1368{
1371 pAssume1(d_r->N <= s_r->N);
1372 poly d_p = p_Init(d_r, d_bin);
1373 for (unsigned i=d_r->N; i!=0; i--)
1374 {
1375 p_SetExp(d_p, i, p_GetExp(s_p, i,s_r), d_r);
1376 }
1377 if (rRing_has_Comp(d_r))
1378 {
1380 }
1381 p_Setm(d_p, d_r);
1382 return d_p;
1383}

◆ p_LmIsConstant()

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

Definition at line 1025 of file p_polys.h.

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

◆ p_LmIsConstantComp()

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

Definition at line 1008 of file p_polys.h.

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

◆ p_LmShallowCopyDelete()

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

Definition at line 1414 of file p_polys.h.

1415{
1417 pAssume1(omSizeWOfBin(bin) == omSizeWOfBin(r->PolyBin));
1418 poly new_p = p_New(r);
1419 memcpy(new_p->exp, p->exp, r->ExpL_Size*sizeof(long));
1421 pNext(new_p) = pNext(p);
1423 return new_p;
1424}

◆ 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 1931 of file p_polys.h.

1933{
1934 p_LmCheckPolyRing1(a, r);
1936#ifndef PDIV_DEBUG
1937 _pPolyAssume2(p_GetShortExpVector(a, r) == sev_a, a, r);
1939
1940 if (sev_a & not_sev_b)
1941 {
1943 return FALSE;
1944 }
1945 return p_LmDivisibleBy(a, b, r);
1946#else
1947 return pDebugLmShortDivisibleBy(a, sev_a, r, b, not_sev_b, r);
1948#endif
1949}

◆ 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 1951 of file p_polys.h.

1953{
1954 p_LmCheckPolyRing1(a, r);
1956#ifndef PDIV_DEBUG
1957 _pPolyAssume2(p_GetShortExpVector(a, r) == sev_a, a, r);
1959
1960 if (sev_a & not_sev_b)
1961 {
1963 return FALSE;
1964 }
1965 return p_LmDivisibleByNoComp(a, b, r);
1966#else
1968#endif
1969}

◆ p_LowVar()

int p_LowVar ( poly  p,
const ring  r 
)

the minimal index of used variables - 1

Definition at line 4834 of file p_polys.cc.

4835{
4836 int k,l,lex;
4837
4838 if (p == NULL) return -1;
4839
4840 k = 32000;/*a very large dummy value*/
4841 while (p != NULL)
4842 {
4843 l = 1;
4844 lex = p_GetExp(p,l,r);
4845 while ((l < (rVar(r))) && (lex == 0))
4846 {
4847 l++;
4848 lex = p_GetExp(p,l,r);
4849 }
4850 l--;
4851 if (l < k) k = l;
4852 pIter(p);
4853 }
4854 return k;
4855}

◆ p_LtCmp()

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

Definition at line 1642 of file p_polys.h.

1643{
1644 int res = p_LmCmp(p,q,r);
1645 if(res == 0)
1646 {
1647 if(p_GetCoeff(p,r) == NULL || p_GetCoeff(q,r) == NULL)
1648 return res;
1649 number pc = n_Copy(p_GetCoeff(p,r),r->cf);
1650 number qc = n_Copy(p_GetCoeff(q,r),r->cf);
1651 if(!n_GreaterZero(pc,r->cf))
1652 pc = n_InpNeg(pc,r->cf);
1653 if(!n_GreaterZero(qc,r->cf))
1654 qc = n_InpNeg(qc,r->cf);
1655 if(n_Greater(pc,qc,r->cf))
1656 res = 1;
1657 else if(n_Greater(qc,pc,r->cf))
1658 res = -1;
1659 else if(n_Equal(pc,qc,r->cf))
1660 res = 0;
1661 n_Delete(&pc,r->cf);
1662 n_Delete(&qc,r->cf);
1663 }
1664 return res;
1665}

◆ p_LtCmpNoAbs()

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

Definition at line 1668 of file p_polys.h.

1669{
1670 int res = p_LmCmp(p,q,r);
1671 if(res == 0)
1672 {
1673 if(p_GetCoeff(p,r) == NULL || p_GetCoeff(q,r) == NULL)
1674 return res;
1675 number pc = p_GetCoeff(p,r);
1676 number qc = p_GetCoeff(q,r);
1677 if(n_Greater(pc,qc,r->cf))
1678 res = 1;
1679 if(n_Greater(qc,pc,r->cf))
1680 res = -1;
1681 if(n_Equal(pc,qc,r->cf))
1682 res = 0;
1683 }
1684 return res;
1685}

◆ p_LtCmpOrdSgnDiffM()

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

Definition at line 1690 of file p_polys.h.

1691{
1692 return(p_LtCmp(p,q,r) == r->OrdSgn);
1693}

◆ p_LtCmpOrdSgnDiffP()

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

Definition at line 1699 of file p_polys.h.

1700{
1701 if(r->OrdSgn == 1)
1702 {
1703 return(p_LmCmp(p,q,r) == -1);
1704 }
1705 else
1706 {
1707 return(p_LtCmp(p,q,r) != -1);
1708 }
1709}

◆ p_LtCmpOrdSgnEqM()

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

Definition at line 1715 of file p_polys.h.

1716{
1717 return(p_LtCmp(p,q,r) == -r->OrdSgn);
1718}

◆ p_LtCmpOrdSgnEqP()

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

Definition at line 1724 of file p_polys.h.

1725{
1726 return(p_LtCmp(p,q,r) == r->OrdSgn);
1727}

◆ p_MaxComp() [1/2]

static long p_MaxComp ( poly  p,
ring  lmRing 
)
inlinestatic

Definition at line 313 of file p_polys.h.

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

◆ p_MaxComp() [2/2]

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

Definition at line 294 of file p_polys.h.

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

◆ p_MaxExpPerVar()

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

max exponent of variable x_i in p

Definition at line 5146 of file p_polys.cc.

5147{
5148 int m=0;
5149 while(p!=NULL)
5150 {
5151 int mm=p_GetExp(p,i,r);
5152 if (mm>m) m=mm;
5153 pIter(p);
5154 }
5155 return m;
5156}

◆ 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 1313 of file p_polys.h.

1314{
1315 if (r->NegWeightL_Offset != NULL)
1316 {
1317 for (int i=r->NegWeightL_Size-1; i>=0; i--)
1318 {
1319 p->exp[r->NegWeightL_Offset[i]] -= POLY_NEGWEIGHT_OFFSET;
1320 }
1321 }
1322}

◆ p_MemSub_NegWeightAdjust()

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

Definition at line 1323 of file p_polys.h.

1324{
1325 if (r->NegWeightL_Offset != NULL)
1326 {
1327 for (int i=r->NegWeightL_Size-1; i>=0; i--)
1328 {
1329 p->exp[r->NegWeightL_Offset[i]] += POLY_NEGWEIGHT_OFFSET;
1330 }
1331 }
1332}

◆ p_Merge_q()

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

Definition at line 1233 of file p_polys.h.

1234{
1235 assume( (p != q) || (p == NULL && q == NULL) );
1236 return r->p_Procs->p_Merge_q(p, q, r);
1237}

◆ p_MinComp() [1/2]

static long p_MinComp ( poly  p,
ring  lmRing 
)
inlinestatic

Definition at line 334 of file p_polys.h.

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

◆ p_MinComp() [2/2]

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

Definition at line 315 of file p_polys.h.

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

◆ p_MinDeg()

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

Definition at line 4602 of file p_polys.cc.

4603{
4604 if(p==NULL)
4605 return -1;
4606 int d=-1;
4607 while(p!=NULL)
4608 {
4609 int d0=0;
4610 for(int j=0;j<rVar(R);j++)
4611 if(w==NULL||j>=w->length())
4612 d0+=p_GetExp(p,j+1,R);
4613 else
4614 d0+=(*w)[j]*p_GetExp(p,j+1,R);
4615 if(d0<d||d==-1)
4616 d=d0;
4617 pIter(p);
4618 }
4619 return d;
4620}

◆ 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 1088 of file p_polys.h.

1089{
1090 int shorter;
1091
1092 return r->p_Procs->p_Minus_mm_Mult_qq(p, m, q, shorter, NULL, r);
1093}

◆ 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 1077 of file p_polys.h.

1079{
1080 int shorter;
1081 const poly res = r->p_Procs->p_Minus_mm_Mult_qq(p, m, q, shorter, spNoether, r);
1082 lp += lq - shorter;
1083// assume( lp == pLength(res) );
1084 return res;
1085}

◆ p_mm_Mult()

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

Definition at line 1068 of file p_polys.h.

1069{
1070 if (p==NULL) return NULL;
1071 if (p_LmIsConstant(m, r))
1072 return __p_Mult_nn(p, pGetCoeff(m), r);
1073 else
1074 return r->p_Procs->p_mm_Mult(p, m, r);
1075}

◆ p_Mult_mm()

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

Definition at line 1053 of file p_polys.h.

1054{
1055 if (p==NULL) return NULL;
1056 if (UNLIKELY(m==NULL)) /* && (p!=NULL) */
1057 {
1058 r->p_Procs->p_Delete(&p, r);
1059 return NULL;
1060 }
1061 if (p_LmIsConstant(m, r))
1062 return __p_Mult_nn(p, pGetCoeff(m), r);
1063 else
1064 return r->p_Procs->p_Mult_mm(p, m, r);
1065}
#define UNLIKELY(X)
Definition auxiliary.h:405

◆ p_Mult_nn() [1/2]

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

Definition at line 975 of file p_polys.h.

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

◆ p_Mult_nn() [2/2]

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

Definition at line 960 of file p_polys.h.

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

◆ p_Mult_q()

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

Definition at line 1125 of file p_polys.h.

1126{
1127 assume( (p != q) || (p == NULL && q == NULL) );
1128
1129 if (UNLIKELY(p == NULL))
1130 {
1131 p_Delete(&q, r);
1132 return NULL;
1133 }
1134 if (UNLIKELY(q == NULL))
1135 {
1136 p_Delete(&p, r);
1137 return NULL;
1138 }
1139
1140 if (pNext(p) == NULL)
1141 {
1142 q = r->p_Procs->p_mm_Mult(q, p, r);
1143 p_LmDelete(&p, r);
1144 return q;
1145 }
1146
1147 if (pNext(q) == NULL)
1148 {
1149 p = r->p_Procs->p_Mult_mm(p, q, r);
1150 p_LmDelete(&q, r);
1151 return p;
1152 }
1153#if defined(HAVE_PLURAL) || defined(HAVE_SHIFTBBA)
1154 if (UNLIKELY(rIsNCRing(r)))
1155 return _nc_p_Mult_q(p, q, r);
1156 else
1157#endif
1158#ifdef HAVE_RINGS
1159 if (UNLIKELY(!nCoeff_is_Domain(r->cf)))
1160 return _p_Mult_q_Normal_ZeroDiv(p, q, 0, r);
1161 else
1162#endif
1163 return _p_Mult_q(p, q, 0, r);
1164}
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:736
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:309
poly _p_Mult_q_Normal_ZeroDiv(poly p, poly q, const int copy, const ring r)
Definition p_Mult_q.cc:195

◆ p_MultExp()

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

Definition at line 623 of file p_polys.h.

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

◆ p_Neg()

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

Definition at line 1114 of file p_polys.h.

1115{
1116 return r->p_Procs->p_Neg(p, r);
1117}

◆ p_New() [1/2]

static poly p_New ( const ring  ,
omBin  bin 
)
inlinestatic

Definition at line 666 of file p_polys.h.

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

◆ p_New() [2/2]

static poly p_New ( ring  r)
inlinestatic

Definition at line 677 of file p_polys.h.

678{
679 return p_New(r, r->PolyBin);
680}

◆ p_Norm()

void p_Norm ( poly  p1,
const ring  r 
)

Definition at line 3844 of file p_polys.cc.

3845{
3846 if (UNLIKELY(p1==NULL)) return;
3847 if (rField_is_Ring(r))
3848 {
3849 if(!n_GreaterZero(pGetCoeff(p1),r->cf)) p1 = p_Neg(p1,r);
3850 if (!n_IsUnit(pGetCoeff(p1), r->cf)) return;
3851 // Werror("p_Norm not possible in the case of coefficient rings.");
3852 }
3853 else //(p1!=NULL)
3854 {
3855 if (!n_IsOne(pGetCoeff(p1),r->cf))
3856 {
3857 if (UNLIKELY(pNext(p1)==NULL))
3858 {
3859 p_SetCoeff(p1,n_Init(1,r->cf),r);
3860 return;
3861 }
3862 number k = pGetCoeff(p1);
3863 pSetCoeff0(p1,n_Init(1,r->cf));
3864 poly h = pNext(p1);
3865 if (LIKELY(rField_is_Zp(r)))
3866 {
3867 if (r->cf->ch>32003)
3868 {
3869 number inv=n_Invers(k,r->cf);
3870 while (h!=NULL)
3871 {
3872 number c=n_Mult(pGetCoeff(h),inv,r->cf);
3873 // no need to normalize
3874 p_SetCoeff(h,c,r);
3875 pIter(h);
3876 }
3877 // no need for n_Delete for Zp: n_Delete(&inv,r->cf);
3878 }
3879 else
3880 {
3881 while (h!=NULL)
3882 {
3883 number c=n_Div(pGetCoeff(h),k,r->cf);
3884 // no need to normalize
3885 p_SetCoeff(h,c,r);
3886 pIter(h);
3887 }
3888 }
3889 }
3890 else if(getCoeffType(r->cf)==n_algExt)
3891 {
3892 n_Normalize(k,r->cf);
3893 number inv=n_Invers(k,r->cf);
3894 while (h!=NULL)
3895 {
3896 number c=n_Mult(pGetCoeff(h),inv,r->cf);
3897 // no need to normalize
3898 // normalize already in nMult: Zp_a, Q_a
3899 p_SetCoeff(h,c,r);
3900 pIter(h);
3901 }
3902 n_Delete(&inv,r->cf);
3903 n_Delete(&k,r->cf);
3904 }
3905 else
3906 {
3907 n_Normalize(k,r->cf);
3908 while (h!=NULL)
3909 {
3910 number c=n_Div(pGetCoeff(h),k,r->cf);
3911 // no need to normalize: Z/p, R
3912 // remains: Q
3913 if (rField_is_Q(r)) n_Normalize(c,r->cf);
3914 p_SetCoeff(h,c,r);
3915 pIter(h);
3916 }
3917 n_Delete(&k,r->cf);
3918 }
3919 }
3920 else
3921 {
3922 //if (r->cf->cfNormalize != nDummy2) //TODO: OPTIMIZE
3923 if (rField_is_Q(r))
3924 {
3925 poly h = pNext(p1);
3926 while (h!=NULL)
3927 {
3928 n_Normalize(pGetCoeff(h),r->cf);
3929 pIter(h);
3930 }
3931 }
3932 }
3933 }
3934}
#define LIKELY(X)
Definition auxiliary.h:404

◆ p_Normalize()

void p_Normalize ( poly  p,
const ring  r 
)

Definition at line 3939 of file p_polys.cc.

3940{
3941 const coeffs cf=r->cf;
3942 /* Z/p, GF(p,n), R, long R/C, Nemo rings */
3943 if (cf->cfNormalize==ndNormalize)
3944 return;
3945 while (p!=NULL)
3946 {
3947 // no test before n_Normalize: n_Normalize should fix problems
3949 pIter(p);
3950 }
3951}
void ndNormalize(number &, const coeffs)
Definition numbers.cc:191

◆ 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 4256 of file p_polys.cc.

4258{
4259#if 0
4260 p_Test(p, oldRing);
4261 PrintS("p_PermPoly::p: "); p_Write(p, oldRing, oldRing);
4262#endif
4263 const int OldpVariables = rVar(oldRing);
4264 poly result = NULL;
4265 poly result_last = NULL;
4266 poly aq = NULL; /* the map coefficient */
4267 poly qq; /* the mapped monomial */
4268 assume(dst != NULL);
4269 assume(dst->cf != NULL);
4270 #ifdef HAVE_PLURAL
4271 poly tmp_mm=p_One(dst);
4272 #endif
4273 while (p != NULL)
4274 {
4275 // map the coefficient
4276 if ( ((OldPar == 0) || (par_perm == NULL) || rField_is_GF(oldRing) || (nMap==ndCopyMap))
4277 && (nMap != NULL) )
4278 {
4279 qq = p_Init(dst);
4280 assume( nMap != NULL );
4281 number n = nMap(p_GetCoeff(p, oldRing), oldRing->cf, dst->cf);
4282 n_Test (n,dst->cf);
4283 if ( nCoeff_is_algExt(dst->cf) )
4284 n_Normalize(n, dst->cf);
4285 p_GetCoeff(qq, dst) = n;// Note: n can be a ZERO!!!
4286 }
4287 else
4288 {
4289 qq = p_One(dst);
4290// aq = naPermNumber(p_GetCoeff(p, oldRing), par_perm, OldPar, oldRing); // no dst???
4291// poly n_PermNumber(const number z, const int *par_perm, const int P, const ring src, const ring dst)
4293 p_Test(aq, dst);
4294 if ( nCoeff_is_algExt(dst->cf) )
4296 if (aq == NULL)
4297 p_SetCoeff(qq, n_Init(0, dst->cf),dst); // Very dirty trick!!!
4298 p_Test(aq, dst);
4299 }
4300 if (rRing_has_Comp(dst))
4302 if ( n_IsZero(pGetCoeff(qq), dst->cf) )
4303 {
4304 p_LmDelete(&qq,dst);
4305 qq = NULL;
4306 }
4307 else
4308 {
4309 // map pars:
4310 int mapped_to_par = 0;
4311 for(int i = 1; i <= OldpVariables; i++)
4312 {
4313 int e = p_GetExp(p, i, oldRing);
4314 if (e != 0)
4315 {
4316 if (perm==NULL)
4317 p_SetExp(qq, i, e, dst);
4318 else if (perm[i]>0)
4319 {
4320 #ifdef HAVE_PLURAL
4321 if(use_mult)
4322 {
4323 p_SetExp(tmp_mm,perm[i],e,dst);
4324 p_Setm(tmp_mm,dst);
4326 p_SetExp(tmp_mm,perm[i],0,dst);
4327
4328 }
4329 else
4330 #endif
4331 p_AddExp(qq,perm[i], e/*p_GetExp( p,i,oldRing)*/, dst);
4332 }
4333 else if (perm[i]<0)
4334 {
4335 number c = p_GetCoeff(qq, dst);
4336 if (rField_is_GF(dst))
4337 {
4338 assume( dst->cf->extRing == NULL );
4339 number ee = n_Param(1, dst);
4340 number eee;
4341 n_Power(ee, e, &eee, dst->cf); //nfDelete(ee,dst);
4342 ee = n_Mult(c, eee, dst->cf);
4343 //nfDelete(c,dst);nfDelete(eee,dst);
4344 pSetCoeff0(qq,ee);
4345 }
4346 else if (nCoeff_is_Extension(dst->cf))
4347 {
4348 const int par = -perm[i];
4349 assume( par > 0 );
4350// WarnS("longalg missing 3");
4351#if 1
4352 const coeffs C = dst->cf;
4353 assume( C != NULL );
4354 const ring R = C->extRing;
4355 assume( R != NULL );
4356 assume( par <= rVar(R) );
4357 poly pcn; // = (number)c
4358 assume( !n_IsZero(c, C) );
4359 if( nCoeff_is_algExt(C) )
4360 pcn = (poly) c;
4361 else // nCoeff_is_transExt(C)
4362 pcn = NUM((fraction)c);
4363 if (pNext(pcn) == NULL) // c->z
4364 p_AddExp(pcn, -perm[i], e, R);
4365 else /* more difficult: we have really to multiply: */
4366 {
4367 poly mmc = p_ISet(1, R);
4368 p_SetExp(mmc, -perm[i], e, R);
4369 p_Setm(mmc, R);
4370 number nnc;
4371 // convert back to a number: number nnc = mmc;
4372 if( nCoeff_is_algExt(C) )
4373 nnc = (number) mmc;
4374 else // nCoeff_is_transExt(C)
4375 nnc = ntInit(mmc, C);
4376 p_GetCoeff(qq, dst) = n_Mult((number)c, nnc, C);
4377 n_Delete((number *)&c, C);
4378 n_Delete((number *)&nnc, C);
4379 }
4380 mapped_to_par=1;
4381#endif
4382 }
4383 }
4384 else
4385 {
4386 /* this variable maps to 0 !*/
4387 p_LmDelete(&qq, dst);
4388 break;
4389 }
4390 }
4391 }
4392 if ( mapped_to_par && (qq!= NULL) && nCoeff_is_algExt(dst->cf) )
4393 {
4394 number n = p_GetCoeff(qq, dst);
4395 n_Normalize(n, dst->cf);
4396 p_GetCoeff(qq, dst) = n;
4397 }
4398 }
4399 pIter(p);
4400
4401#if 0
4402 p_Test(aq,dst);
4403 PrintS("aq: "); p_Write(aq, dst, dst);
4404#endif
4405
4406
4407#if 1
4408 if (qq!=NULL)
4409 {
4410 p_Setm(qq,dst);
4411
4412 p_Test(aq,dst);
4413 p_Test(qq,dst);
4414
4415#if 0
4416 PrintS("qq: "); p_Write(qq, dst, dst);
4417#endif
4418
4419 if (aq!=NULL)
4420 qq=p_Mult_q(aq,qq,dst);
4421 aq = qq;
4422 while (pNext(aq) != NULL) pIter(aq);
4423 if (result_last==NULL)
4424 {
4425 result=qq;
4426 }
4427 else
4428 {
4430 }
4432 aq = NULL;
4433 }
4434 else if (aq!=NULL)
4435 {
4436 p_Delete(&aq,dst);
4437 }
4438 }
4440#else
4441 // if (qq!=NULL)
4442 // {
4443 // pSetm(qq);
4444 // pTest(qq);
4445 // pTest(aq);
4446 // if (aq!=NULL) qq=pMult(aq,qq);
4447 // aq = qq;
4448 // while (pNext(aq) != NULL) pIter(aq);
4449 // pNext(aq) = result;
4450 // aq = NULL;
4451 // result = qq;
4452 // }
4453 // else if (aq!=NULL)
4454 // {
4455 // pDelete(&aq);
4456 // }
4457 //}
4458 //p = result;
4459 //result = NULL;
4460 //while (p != NULL)
4461 //{
4462 // qq = p;
4463 // pIter(p);
4464 // qq->next = NULL;
4465 // result = pAdd(result, qq);
4466 //}
4467#endif
4468 p_Test(result,dst);
4469#if 0
4470 p_Test(result,dst);
4471 PrintS("result: "); p_Write(result,dst,dst);
4472#endif
4473 #ifdef HAVE_PLURAL
4475 #endif
4476 return result;
4477}
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:778
static FORCE_INLINE BOOLEAN nCoeff_is_Extension(const coeffs r)
Definition coeffs.h:841
number ndCopyMap(number a, const coeffs src, const coeffs dst)
Definition numbers.cc:293
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:635
poly n_PermNumber(const number z, const int *par_perm, const int, const ring src, const ring dst)
Definition p_polys.cc:4153
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:1053
static poly p_SortAdd(poly p, const ring r, BOOLEAN revert=FALSE)
Definition p_polys.h:1240
static BOOLEAN rField_is_GF(const ring r)
Definition ring.h:527
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 1226 of file p_polys.h.

1227{
1228 int lp = 0, lq = 0;
1229 return p_Plus_mm_Mult_qq(p, m, q, lp, lq, r);
1230}

◆ 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 1204 of file p_polys.h.

1206{
1207#ifdef HAVE_PLURAL
1208 if (rIsPluralRing(r))
1209 return nc_p_Plus_mm_Mult_qq(p, m, q, lp, lq, r);
1210#endif
1211
1212// this should be implemented more efficiently
1213 poly res;
1214 int shorter;
1216 number n_neg = n_Copy(n_old, r->cf);
1217 n_neg = n_InpNeg(n_neg, r->cf);
1218 pSetCoeff0(m, n_neg);
1219 res = r->p_Procs->p_Minus_mm_Mult_qq(p, m, q, shorter, NULL, r);
1220 lp = (lp + lq) - shorter;
1221 pSetCoeff0(m, n_old);
1222 n_Delete(&n_neg, r->cf);
1223 return res;
1224}
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:406

◆ 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 2245 of file p_polys.cc.

2246{
2247 poly rc=NULL;
2248
2249 if (i==0)
2250 {
2251 p_Delete(&p,r);
2252 return p_One(r);
2253 }
2254
2255 if(p!=NULL)
2256 {
2257 if ( (i > 0) && ((unsigned long ) i > (r->bitmask))
2259 && (!rIsLPRing(r))
2260 #endif
2261 )
2262 {
2263 Werror("exponent %d is too large, max. is %ld",i,r->bitmask);
2264 return NULL;
2265 }
2266 switch (i)
2267 {
2268// cannot happen, see above
2269// case 0:
2270// {
2271// rc=pOne();
2272// pDelete(&p);
2273// break;
2274// }
2275 case 1:
2276 rc=p;
2277 break;
2278 case 2:
2279 rc=p_Mult_q(p_Copy(p,r),p,r);
2280 break;
2281 default:
2282 if (i < 0)
2283 {
2284 p_Delete(&p,r);
2285 return NULL;
2286 }
2287 else
2288 {
2289#ifdef HAVE_PLURAL
2290 if (rIsNCRing(r)) /* in the NC case nothing helps :-( */
2291 {
2292 int j=i;
2293 rc = p_Copy(p,r);
2294 while (j>1)
2295 {
2296 rc = p_Mult_q(p_Copy(p,r),rc,r);
2297 j--;
2298 }
2299 p_Delete(&p,r);
2300 return rc;
2301 }
2302#endif
2303 rc = pNext(p);
2304 if (rc == NULL)
2305 return p_MonPower(p,i,r);
2306 /* else: binom ?*/
2307 int char_p=rInternalChar(r);
2308 if ((char_p>0) && (i>char_p)
2309 && ((rField_is_Zp(r,char_p)
2310 || (rField_is_Zp_a(r,char_p)))))
2311 {
2312 poly h=p_Pow_charp(p_Copy(p,r),char_p,r);
2313 int rest=i-char_p;
2314 while (rest>=char_p)
2315 {
2316 rest-=char_p;
2318 }
2319 poly res=h;
2320 if (rest>0)
2321 res=p_Mult_q(p_Power(p_Copy(p,r),rest,r),h,r);
2322 p_Delete(&p,r);
2323 return res;
2324 }
2325 if ((pNext(rc) != NULL)
2326 || rField_is_Ring(r)
2327 )
2328 return p_Pow(p,i,r);
2329 if ((char_p==0) || (i<=char_p)) /* && pNext(rc)==NULL */
2330 return p_TwoMonPower(p,i,r);
2331 return p_Pow(p,i,r);
2332 }
2333 /*end default:*/
2334 }
2335 }
2336 return rc;
2337}
poly p_Power(poly p, int i, const ring r)
Definition p_polys.cc:2245
static poly p_TwoMonPower(poly p, int exp, const ring r)
Definition p_polys.cc:2118
static poly p_Pow_charp(poly p, int i, const ring r)
Definition p_polys.cc:2233
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:2183
void Werror(const char *fmt,...)
Definition reporter.cc:189
static int rInternalChar(const ring r)
Definition ring.h:695
static BOOLEAN rIsLPRing(const ring r)
Definition ring.h:417

◆ p_ProjectiveUnique()

void p_ProjectiveUnique ( poly  p,
const ring  r 
)

Definition at line 3191 of file p_polys.cc.

3192{
3193 if( ph == NULL )
3194 return;
3195
3196 const coeffs C = r->cf;
3197
3198 number h;
3199 poly p;
3200
3201 if (nCoeff_is_Ring(C))
3202 {
3203 p_ContentForGB(ph,r);
3204 if(!n_GreaterZero(pGetCoeff(ph),C)) ph = p_Neg(ph,r);
3206 return;
3207 }
3208
3210 {
3211 if(!n_GreaterZero(pGetCoeff(ph),C)) ph = p_Neg(ph,r);
3212 return;
3213 }
3214 p = ph;
3215
3216 assume(p != NULL);
3217
3218 if(pNext(p)==NULL) // a monomial
3219 {
3220 p_SetCoeff(p, n_Init(1, C), r);
3221 return;
3222 }
3223
3224 assume(pNext(p)!=NULL);
3225
3226 if(!nCoeff_is_Q(C) && !nCoeff_is_transExt(C))
3227 {
3228 h = p_GetCoeff(p, C);
3229 number hInv = n_Invers(h, C);
3230 if(errorreported) return;
3231 pIter(p);
3232 while (p!=NULL)
3233 {
3234 p_SetCoeff(p, n_Mult(p_GetCoeff(p, C), hInv, C), r);
3235 pIter(p);
3236 }
3237 n_Delete(&hInv, C);
3238 p = ph;
3239 p_SetCoeff(p, n_Init(1, C), r);
3240 }
3241
3242 p_Cleardenom(ph, r); //removes also Content
3243
3244
3245 /* normalize ph over a transcendental extension s.t.
3246 lead (ph) is > 0 if extRing->cf == Q
3247 or lead (ph) is monic if extRing->cf == Zp*/
3248 if (nCoeff_is_transExt(C))
3249 {
3250 p= ph;
3251 h= p_GetCoeff (p, C);
3252 fraction f = (fraction) h;
3253 number n=p_GetCoeff (NUM (f),C->extRing->cf);
3254 if (rField_is_Q (C->extRing))
3255 {
3256 if (!n_GreaterZero(n,C->extRing->cf))
3257 {
3258 p=p_Neg (p,r);
3259 }
3260 }
3261 else if (rField_is_Zp(C->extRing))
3262 {
3263 if (!n_IsOne (n, C->extRing->cf))
3264 {
3265 n=n_Invers (n,C->extRing->cf);
3266 nMapFunc nMap;
3267 nMap= n_SetMap (C->extRing->cf, C);
3268 number ninv= nMap (n,C->extRing->cf, C);
3269 p=__p_Mult_nn (p, ninv, r);
3270 n_Delete (&ninv, C);
3271 n_Delete (&n, C->extRing->cf);
3272 }
3273 }
3274 p= ph;
3275 }
3276
3277 return;
3278}
static FORCE_INLINE BOOLEAN nCoeff_is_Ring(const coeffs r)
Definition coeffs.h:732
static FORCE_INLINE BOOLEAN nCoeff_is_Zp(const coeffs r)
Definition coeffs.h:795
poly p_Cleardenom(poly p, const ring r)
Definition p_polys.cc:2893

◆ 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:601
const char * eati(const char *s, int *i)
Definition reporter.cc:377
static bool rIsSCA(const ring r)
Definition nc.h:190
static long p_IncrExp(poly p, int v, ring r)
Definition p_polys.h:593
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 4652 of file p_polys.cc.

4653{
4654 int *ww=iv2array(w,R);
4655 if(p!=NULL)
4656 {
4657 if(u==NULL)
4658 p=p_JetW(p,n,ww,R);
4659 else
4660 p=p_JetW(p_Mult_q(p,p_Invers(n-p_MinDeg(p,w,R),u,w,R),R),n,ww,R);
4661 }
4662 omFreeSize((ADDRESS)ww,(rVar(R)+1)*sizeof(int));
4663 return p;
4664}
static poly p_Invers(int n, poly u, intvec *w, const ring R)
Definition p_polys.cc:4623
int p_MinDeg(poly p, intvec *w, const ring R)
Definition p_polys.cc:4602
poly p_JetW(poly p, int m, int *w, const ring R)
Definition p_polys.cc:4584
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 414 of file p_polys.h.

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

◆ p_SetComp()

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

Definition at line 249 of file p_polys.h.

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

◆ p_SetCompP() [1/2]

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

Definition at line 283 of file p_polys.h.

284{
285 if (p != NULL)
286 {
287 p_SetComp(p, i, lmRing);
289 p_SetCompP(pNext(p), i, tailRing);
290 }
291}

◆ p_SetCompP() [2/2]

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

Definition at line 256 of file p_polys.h.

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

◆ 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 584 of file p_polys.h.

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

◆ p_SetExp() [2/3]

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

Definition at line 564 of file p_polys.h.

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

◆ 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 490 of file p_polys.h.

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

◆ p_SetExpV()

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

Definition at line 1565 of file p_polys.h.

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

◆ p_SetExpVL()

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

Definition at line 1574 of file p_polys.h.

1575{
1577 for (unsigned j = r->N; j!=0; j--)
1578 p_SetExp(p, j, ev[j-1], r);
1579 p_SetComp(p, 0,r);
1580
1581 p_Setm(p, r);
1582}

◆ p_SetExpVLV()

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

Definition at line 1585 of file p_polys.h.

1586{
1588 for (unsigned j = r->N; j!=0; j--)
1589 p_SetExp(p, j, ev[j-1], r);
1590 p_SetComp(p, comp,r);
1591
1592 p_Setm(p, r);
1593}

◆ p_Setm()

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

Definition at line 235 of file p_polys.h.

236{
237 p_CheckRing2(r);
238 r->p_Setm(p, r);
239}

◆ p_SetModDeg()

void p_SetModDeg ( intvec w,
ring  r 
)

Definition at line 3798 of file p_polys.cc.

3799{
3800 if (w!=NULL)
3801 {
3802 r->pModW = w;
3803 pOldFDeg = r->pFDeg;
3804 pOldLDeg = r->pLDeg;
3805 pOldLexOrder = r->pLexOrder;
3807 r->pLexOrder = TRUE;
3808 }
3809 else
3810 {
3811 r->pModW = NULL;
3813 r->pLexOrder = pOldLexOrder;
3814 }
3815}
STATIC_VAR pLDegProc pOldLDeg
Definition p_polys.cc:3786
void pRestoreDegProcs(ring r, pFDegProc old_FDeg, pLDegProc old_lDeg)
Definition p_polys.cc:3774
STATIC_VAR BOOLEAN pOldLexOrder
Definition p_polys.cc:3787
STATIC_VAR pFDegProc pOldFDeg
Definition p_polys.cc:3785
void pSetDegProcs(ring r, pFDegProc new_FDeg, pLDegProc new_lDeg)
Definition p_polys.cc:3762
static long pModDeg(poly p, ring r)
Definition p_polys.cc:3789

◆ p_ShallowCopyDelete()

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

Definition at line 930 of file p_polys.h.

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

◆ 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 4860 of file p_polys.cc.

4861{
4862 poly qp1 = *p,qp2 = *p;/*working pointers*/
4863 int j = p_MaxComp(*p,r),k = p_MinComp(*p,r);
4864
4865 if (j+i < 0) return ;
4866 BOOLEAN toPoly= ((j == -i) && (j == k));
4867 while (qp1 != NULL)
4868 {
4869 if (toPoly || (__p_GetComp(qp1,r)+i > 0))
4870 {
4871 p_AddComp(qp1,i,r);
4872 p_SetmComp(qp1,r);
4873 qp2 = qp1;
4874 pIter(qp1);
4875 }
4876 else
4877 {
4878 if (qp2 == *p)
4879 {
4880 pIter(*p);
4881 p_LmDelete(&qp2,r);
4882 qp2 = *p;
4883 qp1 = *p;
4884 }
4885 else
4886 {
4887 qp2->next = qp1->next;
4888 if (qp1!=NULL) p_LmDelete(&qp1,r);
4889 qp1 = qp2->next;
4890 }
4891 }
4892 }
4893}
return
static unsigned long p_AddComp(poly p, unsigned long v, ring r)
Definition p_polys.h:449

◆ p_SimpleContent()

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

Definition at line 2612 of file p_polys.cc.

2613{
2614 if(TEST_OPT_CONTENTSB) return;
2615 if (ph==NULL) return;
2616 if (pNext(ph)==NULL)
2617 {
2618 p_SetCoeff(ph,n_Init(1,r->cf),r);
2619 return;
2620 }
2621 if (pNext(pNext(ph))==NULL)
2622 {
2623 return;
2624 }
2625 if (!(rField_is_Q(r))
2626 && (!rField_is_Q_a(r))
2627 && (!rField_is_Zp_a(r))
2628 && (!rField_is_Z(r))
2629 )
2630 {
2631 return;
2632 }
2633 number d=p_InitContent(ph,r);
2634 number h=d;
2635 if (n_Size(d,r->cf)<=smax)
2636 {
2637 n_Delete(&h,r->cf);
2638 //if (TEST_OPT_PROT) PrintS("G");
2639 return;
2640 }
2641
2642 poly p=ph;
2643 if (smax==1) smax=2;
2644 while (p!=NULL)
2645 {
2646#if 1
2647 d=n_SubringGcd(h,pGetCoeff(p),r->cf);
2648 n_Delete(&h,r->cf);
2649 h = d;
2650#else
2651 n_InpGcd(h,pGetCoeff(p),r->cf);
2652#endif
2653 if(n_Size(h,r->cf)<smax)
2654 {
2655 //if (TEST_OPT_PROT) PrintS("g");
2656 n_Delete(&h,r->cf);
2657 return;
2658 }
2659 pIter(p);
2660 }
2661 p = ph;
2662 if (!n_GreaterZero(pGetCoeff(p),r->cf)) h=n_InpNeg(h,r->cf);
2663 if(n_IsOne(h,r->cf))
2664 {
2665 n_Delete(&h,r->cf);
2666 return;
2667 }
2668 if (TEST_OPT_PROT) PrintS("c");
2669 while (p!=NULL)
2670 {
2671#if 1
2672 d = n_ExactDiv(pGetCoeff(p),h,r->cf);
2673 p_SetCoeff(p,d,r);
2674#else
2675 STATISTIC(n_ExactDiv); nlInpExactDiv(pGetCoeff(p),h,r->cf); // no such function... ?
2676#endif
2677 pIter(p);
2678 }
2679 n_Delete(&h,r->cf);
2680}
#define TEST_OPT_PROT
Definition options.h:105

◆ p_Size()

int p_Size ( poly  p,
const ring  r 
)

Definition at line 3302 of file p_polys.cc.

3303{
3304 int count = 0;
3305 if (r->cf->has_simple_Alloc)
3306 return pLength(p);
3307 while ( p != NULL )
3308 {
3309 count+= n_Size( pGetCoeff( p ), r->cf );
3310 pIter( p );
3311 }
3312 return count;
3313}
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 1240 of file p_polys.h.

1241{
1242 if (revert) p = pReverse(p);
1243 return sBucketSortAdd(p, r);
1244}
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 1250 of file p_polys.h.

1251{
1252 if (revert) p = pReverse(p);
1253 return sBucketSortMerge(p, r);
1254}
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 1261 of file p_polys.h.

1262{
1263 return p_String(p, p_ring, p_ring);
1264}
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 1265 of file p_polys.h.

1266{
1268}
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!) UGLINESS
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:587

◆ 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!) UGLINESS
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:592

◆ 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 455 of file p_polys.h.

456{
459 _pPolyAssume2(__p_GetComp(p,r) >= v,p,r);
460 return __p_GetComp(p,r) -= v;
461}

◆ p_SubExp()

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

Definition at line 615 of file p_polys.h.

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

◆ p_Subst()

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

Definition at line 4084 of file p_polys.cc.

4085{
4086#ifdef HAVE_SHIFTBBA
4087 // also don't even use p_Subst0 for Letterplace
4088 if (rIsLPRing(r))
4089 {
4090 poly subst = p_LPSubst(p, n, e, r);
4091 p_Delete(&p, r);
4092 return subst;
4093 }
4094#endif
4095
4096 if (e == NULL) return p_Subst0(p, n,r);
4097
4098 if (p_IsConstant(e,r))
4099 {
4100 if (n_IsOne(pGetCoeff(e),r->cf)) return p_Subst1(p,n,r);
4101 else return p_Subst2(p, n, pGetCoeff(e),r);
4102 }
4103
4104#ifdef HAVE_PLURAL
4105 if (rIsPluralRing(r))
4106 {
4107 return nc_pSubst(p,n,e,r);
4108 }
4109#endif
4110
4111 int exponent,i;
4112 poly h, res, m;
4113 int *me,*ee;
4114 number nu,nu1;
4115
4116 me=(int *)omAlloc((rVar(r)+1)*sizeof(int));
4117 ee=(int *)omAlloc((rVar(r)+1)*sizeof(int));
4118 if (e!=NULL) p_GetExpV(e,ee,r);
4119 res=NULL;
4120 h=p;
4121 while (h!=NULL)
4122 {
4123 if ((e!=NULL) || (p_GetExp(h,n,r)==0))
4124 {
4125 m=p_Head(h,r);
4126 p_GetExpV(m,me,r);
4127 exponent=me[n];
4128 me[n]=0;
4129 for(i=rVar(r);i>0;i--)
4130 me[i]+=exponent*ee[i];
4131 p_SetExpV(m,me,r);
4132 if (e!=NULL)
4133 {
4134 n_Power(pGetCoeff(e),exponent,&nu,r->cf);
4135 nu1=n_Mult(pGetCoeff(m),nu,r->cf);
4136 n_Delete(&nu,r->cf);
4137 p_SetCoeff(m,nu1,r);
4138 }
4139 res=p_Add_q(res,m,r);
4140 }
4141 p_LmDelete(&h,r);
4142 }
4143 omFreeSize((ADDRESS)me,(rVar(r)+1)*sizeof(int));
4144 omFreeSize((ADDRESS)ee,(rVar(r)+1)*sizeof(int));
4145 return res;
4146}
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:4059
static poly p_Subst1(poly p, int n, const ring r)
Definition p_polys.cc:3991
static poly p_Subst2(poly p, int n, number e, const ring r)
Definition p_polys.cc:4018
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 3543 of file p_polys.cc.

3544{
3545 poly q = *p,qq=NULL,result = NULL;
3546 unsigned long kk=(unsigned long)k;
3547
3548 if (q==NULL) return NULL;
3550 if (__p_GetComp(q,r)==kk)
3551 {
3552 result = q;
3554 {
3555 do
3556 {
3557 p_SetComp(q,0,r);
3558 p_SetmComp(q,r);
3559 qq = q;
3560 pIter(q);
3561 }
3562 while ((q!=NULL) && (__p_GetComp(q,r)==kk));
3563 }
3564 else
3565 {
3566 do
3567 {
3568 p_SetComp(q,0,r);
3569 qq = q;
3570 pIter(q);
3571 }
3572 while ((q!=NULL) && (__p_GetComp(q,r)==kk));
3573 }
3574
3575 *p = q;
3576 pNext(qq) = NULL;
3577 }
3578 if (q==NULL) return result;
3579 if (__p_GetComp(q,r) > kk)
3580 {
3581 p_SubComp(q,1,r);
3582 if (use_setmcomp) p_SetmComp(q,r);
3583 }
3584 poly pNext_q;
3585 while ((pNext_q=pNext(q))!=NULL)
3586 {
3587 unsigned long c=__p_GetComp(pNext_q,r);
3588 if (/*__p_GetComp(pNext_q,r)*/c==kk)
3589 {
3590 if (result==NULL)
3591 {
3592 result = pNext_q;
3593 qq = result;
3594 }
3595 else
3596 {
3597 pNext(qq) = pNext_q;
3598 pIter(qq);
3599 }
3600 pNext(q) = pNext(pNext_q);
3601 pNext(qq) =NULL;
3602 p_SetComp(qq,0,r);
3603 if (use_setmcomp) p_SetmComp(qq,r);
3604 }
3605 else
3606 {
3607 /*pIter(q);*/ q=pNext_q;
3608 if (/*__p_GetComp(q,r)*/c > kk)
3609 {
3610 p_SubComp(q,1,r);
3611 if (use_setmcomp) p_SetmComp(q,r);
3612 }
3613 }
3614 }
3615 return result;
3616}

◆ 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 3620 of file p_polys.cc.

3621{
3622 spolyrec pp, qq;
3623 poly p, q, p_prev;
3624 int l = 0;
3625
3626#ifndef SING_NDEBUG
3627 int lp = pLength(*r_p);
3628#endif
3629
3630 pNext(&pp) = *r_p;
3631 p = *r_p;
3632 p_prev = &pp;
3633 q = &qq;
3634
3635 while(p != NULL)
3636 {
3637 while (__p_GetComp(p,r) == (unsigned long)comp)
3638 {
3639 pNext(q) = p;
3640 pIter(q);
3641 p_SetComp(p, 0,r);
3642 p_SetmComp(p,r);
3643 pIter(p);
3644 l++;
3645 if (p == NULL)
3646 {
3647 pNext(p_prev) = NULL;
3648 goto Finish;
3649 }
3650 }
3651 pNext(p_prev) = p;
3652 p_prev = p;
3653 pIter(p);
3654 }
3655
3656 Finish:
3657 pNext(q) = NULL;
3658 *r_p = pNext(&pp);
3659 *r_q = pNext(&qq);
3660 *lq = l;
3661#ifndef SING_NDEBUG
3662 assume(pLength(*r_p) + pLength(*r_q) == lp);
3663#endif
3664 p_Test(*r_p,r);
3665 p_Test(*r_q,r);
3666}

◆ p_Totaldegree()

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

Definition at line 1528 of file p_polys.h.

1529{
1531 unsigned long s = p_GetTotalDegree(p->exp[r->VarL_Offset[0]],
1532 r,
1533 r->ExpPerLong);
1534 for (unsigned i=r->VarL_Size-1; i!=0; i--)
1535 {
1536 s += p_GetTotalDegree(p->exp[r->VarL_Offset[i]], r,r->ExpPerLong);
1537 }
1538 return (long)s;
1539}

◆ p_Var()

int p_Var ( poly  mi,
const ring  r 
)

Definition at line 4810 of file p_polys.cc.

4811{
4812 if (m==NULL) return 0;
4813 if (pNext(m)!=NULL) return 0;
4814 int i,e=0;
4815 for (i=rVar(r); i>0; i--)
4816 {
4817 int exp=p_GetExp(m,i,r);
4818 if (exp==1)
4819 {
4820 if (e==0) e=i;
4821 else return 0;
4822 }
4823 else if (exp!=0)
4824 {
4825 return 0;
4826 }
4827 }
4828 return e;
4829}

◆ 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 3720 of file p_polys.cc.

3721{
3722 poly h;
3723 int k;
3724
3725 for(int i=len-1;i>=0;i--) p[i]=NULL;
3726 while (v!=NULL)
3727 {
3728 h=p_Head(v,r);
3729 k=__p_GetComp(h,r);
3730 if (k>len) { Werror("wrong rank:%d, should be %d",len,k); }
3731 else
3732 {
3733 p_SetComp(h,0,r);
3734 p_Setm(h,r);
3735 pNext(h)=p[k-1];p[k-1]=h;
3736 }
3737 pIter(v);
3738 }
3739 for(int i=len-1;i>=0;i--)
3740 {
3741 if (p[i]!=NULL) p[i]=pReverse(p[i]);
3742 }
3743}

◆ p_Vec2Poly()

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

Definition at line 3698 of file p_polys.cc.

3699{
3700 poly h;
3701 poly res=NULL;
3702 long unsigned kk=k;
3703
3704 while (v!=NULL)
3705 {
3706 if (__p_GetComp(v,r)==kk)
3707 {
3708 h=p_Head(v,r);
3709 p_SetComp(h,0,r);
3710 pNext(h)=res;res=h;
3711 }
3712 pIter(v);
3713 }
3714 if (res!=NULL) res=pReverse(res);
3715 return res;
3716}

◆ p_Vec2Polys()

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

Definition at line 3750 of file p_polys.cc.

3751{
3752 *len=p_MaxComp(v,r);
3753 if (*len==0) *len=1;
3754 *p=(poly*)omAlloc((*len)*sizeof(poly));
3755 p_Vec2Array(v,*p,*len,r);
3756}
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:3720

◆ p_VectorHasUnit()

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

Definition at line 3510 of file p_polys.cc.

3511{
3512 poly q=p,qq;
3513 int j=0;
3514 long unsigned i;
3515
3516 *len = 0;
3517 while (q!=NULL)
3518 {
3519 if (p_LmIsConstantComp(q,r))
3520 {
3521 i = __p_GetComp(q,r);
3522 qq = p;
3523 while ((qq != q) && (__p_GetComp(qq,r) != i)) pIter(qq);
3524 if (qq == q)
3525 {
3526 j = 0;
3527 while (qq!=NULL)
3528 {
3529 if (__p_GetComp(qq,r)==i) j++;
3530 pIter(qq);
3531 }
3532 if ((*len == 0) || (j<*len))
3533 {
3534 *len = j;
3535 *k = i;
3536 }
3537 }
3538 }
3539 pIter(q);
3540 }
3541}

◆ p_VectorHasUnitB()

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

Definition at line 3487 of file p_polys.cc.

3488{
3489 poly q=p,qq;
3490 long unsigned i;
3491
3492 while (q!=NULL)
3493 {
3494 if (p_LmIsConstantComp(q,r))
3495 {
3496 i = __p_GetComp(q,r);
3497 qq = p;
3498 while ((qq != q) && (__p_GetComp(qq,r) != i)) pIter(qq);
3499 if (qq == q)
3500 {
3501 *k = i;
3502 return TRUE;
3503 }
3504 }
3505 pIter(q);
3506 }
3507 return FALSE;
3508}

◆ 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:314

◆ p_Write() [2/2]

static void p_Write ( poly  p,
ring  p_ring 
)
inlinestatic

Definition at line 1269 of file p_polys.h.

1270{
1272}

◆ 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 1273 of file p_polys.h.

1274{
1276}
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 1277 of file p_polys.h.

1278{
1279 p_wrp(p, p_ring, p_ring);
1280}
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:100
@ ringorder_a
Definition ring.h:71
@ ringorder_am
Definition ring.h:90
@ ringorder_a64
for int64 weights
Definition ring.h:72
@ ringorder_C
Definition ring.h:74
@ ringorder_S
S?
Definition ring.h:76
@ ringorder_ds
Definition ring.h:86
@ ringorder_Dp
Definition ring.h:81
@ ringorder_unspec
Definition ring.h:96
@ ringorder_L
Definition ring.h:91
@ ringorder_Ds
Definition ring.h:87
@ ringorder_dp
Definition ring.h:79
@ ringorder_c
Definition ring.h:73
@ ringorder_aa
for idElimination, like a, except pFDeg, pWeigths ignore it
Definition ring.h:93
@ ringorder_no
Definition ring.h:70
@ ringorder_Wp
Definition ring.h:83
@ ringorder_ws
Definition ring.h:88
@ ringorder_Ws
Definition ring.h:89
@ ringorder_IS
Induced (Schreyer) ordering.
Definition ring.h:95
@ ringorder_ls
degree, ip
Definition ring.h:85
@ ringorder_s
s?
Definition ring.h:77
@ ringorder_wp
Definition ring.h:82
@ ringorder_M
Definition ring.h:75
#define ringorder_rs
Definition ring.h:101

◆ pEnlargeSet()

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

Definition at line 3821 of file p_polys.cc.

3822{
3823 poly* h;
3824
3825 if (increment==0) return;
3826 if (*p==NULL)
3827 {
3828 h=(poly*)omAlloc0(increment*sizeof(poly));
3829 }
3830 else
3831 {
3832 h=(poly*)omReallocSize((poly*)*p,l*sizeof(poly),(l+increment)*sizeof(poly));
3833 if (increment>0)
3834 {
3835 memset(&(h[l]),0,increment*sizeof(poly));
3836 }
3837 }
3838 *p=h;
3839}
#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 4484 of file p_polys.cc.

4485{
4486 poly r=NULL;
4487 poly t=NULL;
4488
4489 while (p!=NULL)
4490 {
4491 if (p_Totaldegree(p,R)<=m)
4492 {
4493 if (r==NULL)
4494 r=p_Head(p,R);
4495 else
4496 if (t==NULL)
4497 {
4498 pNext(r)=p_Head(p,R);
4499 t=pNext(r);
4500 }
4501 else
4502 {
4503 pNext(t)=p_Head(p,R);
4504 pIter(t);
4505 }
4506 }
4507 pIter(p);
4508 }
4509 return r;
4510}

◆ pp_Jet0()

poly pp_Jet0 ( poly  p,
const ring  R 
)

Definition at line 4512 of file p_polys.cc.

4513{
4514 poly r=NULL;
4515 poly t=NULL;
4516
4517 while (p!=NULL)
4518 {
4519 if (p_LmIsConstantComp(p,R))
4520 {
4521 if (r==NULL)
4522 r=p_Head(p,R);
4523 else
4524 if (t==NULL)
4525 {
4526 pNext(r)=p_Head(p,R);
4527 t=pNext(r);
4528 }
4529 else
4530 {
4531 pNext(t)=p_Head(p,R);
4532 pIter(t);
4533 }
4534 }
4535 pIter(p);
4536 }
4537 return r;
4538}

◆ pp_JetW()

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

Definition at line 4557 of file p_polys.cc.

4558{
4559 poly r=NULL;
4560 poly t=NULL;
4561 while (p!=NULL)
4562 {
4563 if (totaldegreeWecart_IV(p,R,w)<=m)
4564 {
4565 if (r==NULL)
4566 r=p_Head(p,R);
4567 else
4568 if (t==NULL)
4569 {
4570 pNext(r)=p_Head(p,R);
4571 t=pNext(r);
4572 }
4573 else
4574 {
4575 pNext(t)=p_Head(p,R);
4576 pIter(t);
4577 }
4578 }
4579 pIter(p);
4580 }
4581 return r;
4582}

◆ pp_mm_Mult()

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

Definition at line 1043 of file p_polys.h.

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

◆ 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 1097 of file p_polys.h.

1098{
1099 int shorter;
1100 return r->p_Procs->pp_Mult_Coeff_mm_DivSelect(p, m, shorter, r);
1101}

◆ 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 1105 of file p_polys.h.

1106{
1107 int shorter;
1108 poly pp = r->p_Procs->pp_Mult_Coeff_mm_DivSelect(p, m, shorter, r);
1109 lp -= shorter;
1110 return pp;
1111}

◆ pp_Mult_mm()

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

Definition at line 1033 of file p_polys.h.

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

◆ pp_Mult_nn()

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

Definition at line 994 of file p_polys.h.

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

◆ pp_Mult_qq()

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

Definition at line 1167 of file p_polys.h.

1168{
1169 if (UNLIKELY(p == NULL || q == NULL)) return NULL;
1170
1171 if (pNext(p) == NULL)
1172 {
1173 return r->p_Procs->pp_mm_Mult(q, p, r);
1174 }
1175
1176 if (pNext(q) == NULL)
1177 {
1178 return r->p_Procs->pp_Mult_mm(p, q, r);
1179 }
1180
1181 poly qq = q;
1182 if (UNLIKELY(p == q))
1183 qq = p_Copy(q, r);
1184
1185 poly res;
1186#if defined(HAVE_PLURAL) || defined(HAVE_SHIFTBBA)
1187 if (UNLIKELY(rIsNCRing(r)))
1188 res = _nc_pp_Mult_qq(p, qq, r);
1189 else
1190#endif
1191#ifdef HAVE_RINGS
1192 if (UNLIKELY(!nCoeff_is_Domain(r->cf)))
1193 res = _p_Mult_q_Normal_ZeroDiv(p, qq, 1, r);
1194 else
1195#endif
1196 res = _p_Mult_q(p, qq, 1, r);
1197
1198 if (UNLIKELY(qq != q))
1199 p_Delete(&qq, r);
1200 return res;
1201}
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 3774 of file p_polys.cc.

3775{
3776 assume(old_FDeg != NULL && old_lDeg != NULL);
3777 r->pFDeg = old_FDeg;
3778 r->pLDeg = old_lDeg;
3779}

◆ pReverse()

static poly pReverse ( poly  p)
inlinestatic

Definition at line 337 of file p_polys.h.

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

◆ pSetDegProcs()

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

Definition at line 3762 of file p_polys.cc.

3763{
3764 assume(new_FDeg != NULL);
3765 r->pFDeg = new_FDeg;
3766
3767 if (new_lDeg == NULL)
3768 new_lDeg = r->pLDegOrig;
3769
3770 r->pLDeg = new_lDeg;
3771}