My Project
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_GetShortExpVector (const poly p, const poly pp, const ring r)
 p_GetShortExpVector of p * pp More...
 
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 More...
 
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 More...
 
int p_IsPurePower (const poly p, const ring r)
 return i, if head depends only on var(i) More...
 
int p_IsUnivariate (poly p, const ring r)
 return i, if poly depends only on var(i) More...
 
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) More...
 
poly p_ISet (long i, const ring r)
 returns the poly representing the integer i More...
 
poly p_NSet (number n, const ring r)
 returns the poly representing the number n, destroys n More...
 
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)) More...
 
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 unsigned 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_Content_n (poly p, number &c, const ring r)
 
void p_SimpleContent (poly p, int s, const ring r)
 
number p_InitContent (poly ph, const ring r)
 
poly p_Cleardenom (poly p, const ring r)
 
void p_Cleardenom_n (poly p, const ring r, number &c)
 
int p_Size (poly p, const ring r)
 
poly p_Homogen (poly p, int varnum, const ring r)
 
BOOLEAN p_IsHomogeneous (poly p, const ring r)
 
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 More...
 
char * p_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 More...
 
void p_String0Long (const poly p, ring lmRing, ring tailRing)
 print p in a long way More...
 
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 More...
 
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: More...
 
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 More...
 
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 More...
 
static long p_SetExp (poly p, const int v, const long e, const ring r)
 set v^th exponent for a monomial More...
 
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_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 More...
 
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 More...
 
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) More...
 
static poly p_Copy (poly p, const ring r)
 returns a copy of p More...
 
static poly p_Head (poly p, const ring r)
 copy the i(leading) term of p More...
 
poly p_CopyPowerProduct (poly p, const ring r)
 like p_Head, but with coefficient 1 More...
 
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 More...
 
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) More...
 
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) More...
 
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 char * p_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 More...
 
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 More...
 
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_LmDivisibleBy (poly a, const ring r_a, poly b, const ring r_b)
 
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_DivisibleBy (poly a, const ring r_a, poly b, const ring r_b)
 
static BOOLEAN p_LmDivisibleBy (poly a, const ring r_a, poly b, const ring r_b)
 
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_LmShortDivisibleBy (poly a, unsigned long sev_a, const ring r_a, poly b, unsigned long not_sev_b, const ring r_b)
 
static BOOLEAN p_IsConstantComp (const poly p, const ring r)
 like the respective p_LmIs* routines, except that p might be empty More...
 
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)?! More...
 
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 char * p_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: More...
 
BOOLEAN p_VectorHasUnitB (poly p, int *k, const ring r)
 
void p_VectorHasUnit (poly p, int *k, int *len, const ring r)
 
poly p_TakeOutComp1 (poly *p, int k, const ring r)
 
void p_TakeOutComp (poly *p, long comp, poly *q, int *lq, const ring r)
 
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 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 More...
 
void p_Shift (poly *p, int i, const ring r)
 shifts components of the vector p by i More...
 
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 More...
 
poly p_Div_mm (poly p, const poly m, const ring r)
 divide polynomial by monomial More...
 
int p_MaxExpPerVar (poly p, int i, const ring r)
 max exponent of variable x_i in p More...
 

Macro Definition Documentation

◆ __p_Mult_nn

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

Definition at line 931 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 962 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, \
actionE, actionG, actionS)
int p
Definition: cfModGcd.cc:4080
#define p_MemCmp_LengthGeneral_OrdGeneral(s1, s2, length, ordsgn, actionE, actionG, actionS)
Definition: p_MemCmp.h:719

Definition at line 1236 of file p_polys.h.

◆ p_LmCmpAction

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

Definition at line 1687 of file p_polys.h.

◆ p_LmEqual

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

Definition at line 1691 of file p_polys.h.

◆ p_LmTest

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

Definition at line 163 of file p_polys.h.

◆ p_SetmComp

#define p_SetmComp   p_Setm

Definition at line 244 of file p_polys.h.

◆ p_Test

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

Definition at line 162 of file p_polys.h.

◆ pDivAssume

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

Definition at line 1242 of file p_polys.h.

◆ pIfThen

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

Definition at line 156 of file p_polys.h.

◆ pp_Test

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

Definition at line 164 of file p_polys.h.

Function Documentation

◆ _p_LmDivisibleBy() [1/2]

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

Definition at line 1843 of file p_polys.h.

1844 {
1845  if (p_GetComp(a, r_a) == 0 || p_GetComp(a,r_a) == p_GetComp(b,r_b))
1846  return _p_LmDivisibleByNoComp(a, r_a, b, r_b);
1847  return FALSE;
1848 }
#define FALSE
Definition: auxiliary.h:96
CanonicalForm b
Definition: cfModGcd.cc:4105
#define p_GetComp(p, r)
Definition: monomials.h:64
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:1733

◆ _p_LmDivisibleBy() [2/2]

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

Definition at line 1837 of file p_polys.h.

1838 {
1839  if (p_GetComp(a, r) == 0 || p_GetComp(a,r) == p_GetComp(b,r))
1840  return _p_LmDivisibleByNoComp(a, b, r);
1841  return FALSE;
1842 }

◆ _p_LmDivisibleByNoComp() [1/2]

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

Definition at line 1782 of file p_polys.h.

1783 {
1784  int i=r_a->N;
1785  pAssume1(r_a->N == r_b->N);
1786 
1787  do
1788  {
1789  if (p_GetExp(a,i,r_a) > p_GetExp(b,i,r_b))
1790  return FALSE;
1791  i--;
1792  }
1793  while (i);
1794 /*#ifdef HAVE_RINGS
1795  return n_DivBy(p_GetCoeff(b, r_b), p_GetCoeff(a, r_a), r_a->cf);
1796 #else
1797 */
1798  return TRUE;
1799 //#endif
1800 }
#define TRUE
Definition: auxiliary.h:100
int i
Definition: cfEzgcd.cc:132
#define pAssume1(cond)
Definition: monomials.h:171
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent @Note: the integer VarOffset encodes:
Definition: p_polys.h:469

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

1734 {
1735  int i=r->VarL_Size - 1;
1736  unsigned long divmask = r->divmask;
1737  unsigned long la, lb;
1738 
1739  if (r->VarL_LowIndex >= 0)
1740  {
1741  i += r->VarL_LowIndex;
1742  do
1743  {
1744  la = a->exp[i];
1745  lb = b->exp[i];
1746  if ((la > lb) ||
1747  (((la & divmask) ^ (lb & divmask)) != ((lb - la) & divmask)))
1748  {
1750  return FALSE;
1751  }
1752  i--;
1753  }
1754  while (i>=r->VarL_LowIndex);
1755  }
1756  else
1757  {
1758  do
1759  {
1760  la = a->exp[r->VarL_Offset[i]];
1761  lb = b->exp[r->VarL_Offset[i]];
1762  if ((la > lb) ||
1763  (((la & divmask) ^ (lb & divmask)) != ((lb - la) & divmask)))
1764  {
1766  return FALSE;
1767  }
1768  i--;
1769  }
1770  while (i>=0);
1771  }
1772 /*#ifdef HAVE_RINGS
1773  pDivAssume(p_DebugLmDivisibleByNoComp(a, b, r) == n_DivBy(p_GetCoeff(b, r), p_GetCoeff(a, r), r->cf));
1774  return (!rField_is_Ring(r)) || n_DivBy(p_GetCoeff(b, r), p_GetCoeff(a, r), r->cf);
1775 #else
1776 */
1778  return TRUE;
1779 //#endif
1780 }
BOOLEAN p_DebugLmDivisibleByNoComp(poly a, poly b, ring r)
Definition: pDebug.cc:139
#define pDivAssume(x)
Definition: p_polys.h:1242

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

1804 {
1805  int i=end;
1806  pAssume1(r_a->N == r_b->N);
1807 
1808  do
1809  {
1810  if (p_GetExp(a,i,r_a) > p_GetExp(b,i,r_b))
1811  return FALSE;
1812  i--;
1813  }
1814  while (i>=start);
1815 /*#ifdef HAVE_RINGS
1816  return n_DivBy(p_GetCoeff(b, r_b), p_GetCoeff(a, r_a), r_a->cf);
1817 #else
1818 */
1819  return TRUE;
1820 //#endif
1821 }

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

1823 {
1824  if (p_GetComp(a, r_a) == 0 || p_GetComp(a,r_a) == p_GetComp(b,r_b))
1825  return _p_LmDivisibleByNoCompPart(a, r_a, b, r_b,start,end);
1826  return FALSE;
1827 }
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:1803

◆ _p_LmTest()

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

Definition at line 321 of file pDebug.cc.

322 {
323  if (level < 0 || p == NULL) return TRUE;
324  poly pnext = pNext(p);
325  pNext(p) = NULL;
326  BOOLEAN test_res = _p_Test(p, r, level);
327  pNext(p) = pnext;
328  return test_res;
329 }
int BOOLEAN
Definition: auxiliary.h:87
int level(const CanonicalForm &f)
#define pNext(p)
Definition: monomials.h:36
#define NULL
Definition: omList.c:12
BOOLEAN _p_Test(poly p, ring r, int level)
Definition: pDebug.cc:210

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

Definition at line 313 of file p_Mult_q.cc.

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

◆ _p_Test()

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

Definition at line 210 of file pDebug.cc.

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

◆ _pp_Test()

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

Definition at line 331 of file pDebug.cc.

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

◆ n_PermNumber()

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

Definition at line 4053 of file p_polys.cc.

4054 {
4055 #if 0
4056  PrintS("\nSource Ring: \n");
4057  rWrite(src);
4058 
4059  if(0)
4060  {
4061  number zz = n_Copy(z, src->cf);
4062  PrintS("z: "); n_Write(zz, src);
4063  n_Delete(&zz, src->cf);
4064  }
4065 
4066  PrintS("\nDestination Ring: \n");
4067  rWrite(dst);
4068 
4069  /*Print("\nOldPar: %d\n", OldPar);
4070  for( int i = 1; i <= OldPar; i++ )
4071  {
4072  Print("par(%d) -> par/var (%d)\n", i, par_perm[i-1]);
4073  }*/
4074 #endif
4075  if( z == NULL )
4076  return NULL;
4077 
4078  const coeffs srcCf = src->cf;
4079  assume( srcCf != NULL );
4080 
4081  assume( !nCoeff_is_GF(srcCf) );
4082  assume( src->cf->extRing!=NULL );
4083 
4084  poly zz = NULL;
4085 
4086  const ring srcExtRing = srcCf->extRing;
4087  assume( srcExtRing != NULL );
4088 
4089  const coeffs dstCf = dst->cf;
4090  assume( dstCf != NULL );
4091 
4092  if( nCoeff_is_algExt(srcCf) ) // nCoeff_is_GF(srcCf)?
4093  {
4094  zz = (poly) z;
4095  if( zz == NULL ) return NULL;
4096  }
4097  else if (nCoeff_is_transExt(srcCf))
4098  {
4099  assume( !IS0(z) );
4100 
4101  zz = NUM((fraction)z);
4102  p_Test (zz, srcExtRing);
4103 
4104  if( zz == NULL ) return NULL;
4105  if( !DENIS1((fraction)z) )
4106  {
4107  if (!p_IsConstant(DEN((fraction)z),srcExtRing))
4108  WarnS("Not defined: Cannot map a rational fraction and make a polynomial out of it! Ignoring the denominator.");
4109  }
4110  }
4111  else
4112  {
4113  assume (FALSE);
4114  WerrorS("Number permutation is not implemented for this data yet!");
4115  return NULL;
4116  }
4117 
4118  assume( zz != NULL );
4119  p_Test (zz, srcExtRing);
4120 
4121  nMapFunc nMap = n_SetMap(srcExtRing->cf, dstCf);
4122 
4123  assume( nMap != NULL );
4124 
4125  poly qq;
4126  if ((par_perm == NULL) && (rPar(dst) != 0 && rVar (srcExtRing) > 0))
4127  {
4128  int* perm;
4129  perm=(int *)omAlloc0((rVar(srcExtRing)+1)*sizeof(int));
4130  for(int i=si_min(rVar(srcExtRing),rPar(dst));i>0;i--)
4131  perm[i]=-i;
4132  qq = p_PermPoly(zz, perm, srcExtRing, dst, nMap, NULL, rVar(srcExtRing)-1);
4133  omFreeSize ((ADDRESS)perm, (rVar(srcExtRing)+1)*sizeof(int));
4134  }
4135  else
4136  qq = p_PermPoly(zz, par_perm-1, srcExtRing, dst, nMap, NULL, rVar (srcExtRing)-1);
4137 
4138  if(nCoeff_is_transExt(srcCf)
4139  && (!DENIS1((fraction)z))
4140  && p_IsConstant(DEN((fraction)z),srcExtRing))
4141  {
4142  number n=nMap(pGetCoeff(DEN((fraction)z)),srcExtRing->cf, dstCf);
4143  qq=p_Div_nn(qq,n,dst);
4144  n_Delete(&n,dstCf);
4145  p_Normalize(qq,dst);
4146  }
4147  p_Test (qq, dst);
4148 
4149  return qq;
4150 }
void * ADDRESS
Definition: auxiliary.h:119
static int si_min(const int a, const int b)
Definition: auxiliary.h:125
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of 'n'
Definition: coeffs.h:452
static FORCE_INLINE BOOLEAN nCoeff_is_GF(const coeffs r)
Definition: coeffs.h:863
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:723
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:456
static FORCE_INLINE void n_Write(number n, const coeffs r, const BOOLEAN bShortOut=TRUE)
Definition: coeffs.h:592
static FORCE_INLINE BOOLEAN nCoeff_is_algExt(const coeffs r)
TRUE iff r represents an algebraic extension field.
Definition: coeffs.h:934
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:74
static FORCE_INLINE BOOLEAN nCoeff_is_transExt(const coeffs r)
TRUE iff r represents a transcendental extension field.
Definition: coeffs.h:942
#define WarnS
Definition: emacs.cc:78
void WerrorS(const char *s)
Definition: feFopen.cc:24
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
The main handler for Singular numbers which are suitable for Singular polynomials.
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
#define omAlloc0(size)
Definition: omAllocDecl.h:211
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:4156
poly p_Div_nn(poly p, const number n, const ring r)
Definition: p_polys.cc:1492
void p_Normalize(poly p, const ring r)
Definition: p_polys.cc:3842
static BOOLEAN p_IsConstant(const poly p, const ring r)
Definition: p_polys.h:1971
#define p_Test(p, r)
Definition: p_polys.h:162
@ NUM
Definition: readcf.cc:170
void PrintS(const char *s)
Definition: reporter.cc:284
void rWrite(ring r, BOOLEAN details)
Definition: ring.cc:226
static int rPar(const ring r)
(r->cf->P)
Definition: ring.h:604
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:597

◆ p_Add_q() [1/2]

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

Definition at line 896 of file p_polys.h.

897 {
898  assume( (p != q) || (p == NULL && q == NULL) );
899  if (q==NULL) return p;
900  if (p==NULL) return q;
901  int shorter;
902  return r->p_Procs->p_Add_q(p, q, shorter, r);
903 }

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

907 {
908  assume( (p != q) || (p == NULL && q == NULL) );
909  if (q==NULL) return p;
910  if (p==NULL) { lp=lq; return q; }
911  int shorter;
912  poly res = r->p_Procs->p_Add_q(p, q, shorter, r);
913  lp += lq - shorter;
914  return res;
915 }

◆ p_AddComp()

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

Definition at line 447 of file p_polys.h.

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

◆ p_AddExp()

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

Definition at line 606 of file p_polys.h.

607 {
608  p_LmCheckPolyRing2(p, r);
609  int e = p_GetExp(p,v,r);
610  e += ee;
611  return p_SetExp(p,v,e,r);
612 }
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent @Note: VarOffset encodes the position in p->exp
Definition: p_polys.h:488

◆ p_CheckIsFromRing()

BOOLEAN p_CheckIsFromRing ( poly  p,
ring  r 
)

Definition at line 100 of file pDebug.cc.

101 {
102  while (p!=NULL)
103  {
105  pIter(p);
106  }
107  return TRUE;
108 }

◆ p_CheckPolyRing()

BOOLEAN p_CheckPolyRing ( poly  p,
ring  r 
)

Definition at line 110 of file pDebug.cc.

111 {
112  #ifndef X_OMALLOC
113  pAssumeReturn(r != NULL && r->PolyBin != NULL);
114  #endif
115  return p_CheckIsFromRing(p, r);
116 }
#define pAssumeReturn(cond)
Definition: monomials.h:78
BOOLEAN p_CheckIsFromRing(poly p, ring r)
Definition: pDebug.cc:100

◆ p_CheckRing()

BOOLEAN p_CheckRing ( ring  r)

Definition at line 126 of file pDebug.cc.

127 {
128  #ifndef X_OMALLOC
129  pAssumeReturn(r != NULL && r->PolyBin != NULL);
130  #endif
131  return TRUE;
132 }

◆ 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);
115  hh=p_LmFreeAndNext(hh,R);
116  xx[j]=hh;
117  }
118  else
119  x[j]=n_Init(0, R->cf);
120  }
121  number n=n_ChineseRemainderSym(x,q,rl,TRUE,inv_cache,R->cf);
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  }
135  res_p=pReverse(res_p);
136  p_Test(res_p, R);
137  return res_p;
138 }
Variable x
Definition: cfModGcd.cc:4084
static FORCE_INLINE number n_ChineseRemainderSym(number *a, number *b, int rl, BOOLEAN sym, CFArray &inv_cache, const coeffs r)
Definition: coeffs.h:788
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition: coeffs.h:539
int j
Definition: facHensel.cc:110
static poly p_Head(poly p, const ring r)
copy the i(leading) term of p
Definition: p_polys.h:826
static number p_SetCoeff(poly p, number n, ring r)
Definition: p_polys.h:412
static poly pReverse(poly p)
Definition: p_polys.h:335
static poly p_LmFreeAndNext(poly p, ring)
Definition: p_polys.h:703
#define R
Definition: sirandom.c:27
#define loop
Definition: structs.h:80

◆ p_Cleardenom()

poly p_Cleardenom ( poly  p,
const ring  r 
)

Definition at line 2900 of file p_polys.cc.

2901 {
2902  if( p == NULL )
2903  return NULL;
2904 
2905  assume( r != NULL ); assume( r->cf != NULL ); const coeffs C = r->cf;
2906 
2907 #if CLEARENUMERATORS
2908  if( 0 )
2909  {
2910  CPolyCoeffsEnumerator itr(p);
2911  n_ClearDenominators(itr, C);
2912  n_ClearContent(itr, C); // divide out the content
2913  p_Test(p, r); n_Test(pGetCoeff(p), C);
2914  assume(n_GreaterZero(pGetCoeff(p), C)); // ??
2915 // if(!n_GreaterZero(pGetCoeff(p),C)) p = p_Neg(p,r);
2916  return p;
2917  }
2918 #endif
2919 
2920  number d, h;
2921 
2922  if (rField_is_Ring(r))
2923  {
2924  p_ContentForGB(p,r);
2925  if(!n_GreaterZero(pGetCoeff(p),C)) p = p_Neg(p,r);
2926  return p;
2927  }
2928 
2930  {
2931  if(!n_GreaterZero(pGetCoeff(p),C)) p = p_Neg(p,r);
2932  return p;
2933  }
2934 
2935  assume(p != NULL);
2936 
2937  if(pNext(p)==NULL)
2938  {
2939  if (!TEST_OPT_CONTENTSB
2940  && !rField_is_Ring(r))
2941  p_SetCoeff(p,n_Init(1,r->cf),r);
2942  else if(!n_GreaterZero(pGetCoeff(p),C))
2943  p = p_Neg(p,r);
2944  return p;
2945  }
2946 
2947  assume(pNext(p)!=NULL);
2948  poly start=p;
2949 
2950 #if 0 && CLEARENUMERATORS
2951 //CF: does not seem to work that well..
2952 
2953  if( nCoeff_is_Q(C) || nCoeff_is_Q_a(C) )
2954  {
2955  CPolyCoeffsEnumerator itr(p);
2956  n_ClearDenominators(itr, C);
2957  n_ClearContent(itr, C); // divide out the content
2958  p_Test(p, r); n_Test(pGetCoeff(p), C);
2959  assume(n_GreaterZero(pGetCoeff(p), C)); // ??
2960 // if(!n_GreaterZero(pGetCoeff(p),C)) p = p_Neg(p,r);
2961  return start;
2962  }
2963 #endif
2964 
2965  if(1)
2966  {
2967  // get lcm of all denominators ----------------------------------
2968  h = n_Init(1,r->cf);
2969  while (p!=NULL)
2970  {
2971  n_Normalize(pGetCoeff(p),r->cf);
2972  d=n_NormalizeHelper(h,pGetCoeff(p),r->cf);
2973  n_Delete(&h,r->cf);
2974  h=d;
2975  pIter(p);
2976  }
2977  /* h now contains the 1/lcm of all denominators */
2978  if(!n_IsOne(h,r->cf))
2979  {
2980  // multiply by the lcm of all denominators
2981  p = start;
2982  while (p!=NULL)
2983  {
2984  d=n_Mult(h,pGetCoeff(p),r->cf);
2985  n_Normalize(d,r->cf);
2986  p_SetCoeff(p,d,r);
2987  pIter(p);
2988  }
2989  }
2990  n_Delete(&h,r->cf);
2991  p=start;
2992 
2993  p_ContentForGB(p,r);
2994 #ifdef HAVE_RATGRING
2995  if (rIsRatGRing(r))
2996  {
2997  /* quick unit detection in the rational case is done in gr_nc_bba */
2998  p_ContentRat(p, r);
2999  start=p;
3000  }
3001 #endif
3002  }
3003 
3004  if(!n_GreaterZero(pGetCoeff(p),C)) p = p_Neg(p,r);
3005 
3006  return start;
3007 }
This is a polynomial enumerator for simple iteration over coefficients of polynomials.
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of 'a' and 'b', i.e., a*b
Definition: coeffs.h:637
static FORCE_INLINE number n_NormalizeHelper(number a, number b, const coeffs r)
assume that r is a quotient field (otherwise, return 1) for arguments (a1/a2,b1/b2) return (lcm(a1,...
Definition: coeffs.h:718
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:495
static FORCE_INLINE BOOLEAN nCoeff_is_Q(const coeffs r)
Definition: coeffs.h:830
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:959
static FORCE_INLINE BOOLEAN nCoeff_is_Q_a(const coeffs r)
Definition: coeffs.h:909
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:952
static FORCE_INLINE void n_Normalize(number &n, const coeffs r)
inplace-normalization of n; produces some canonical representation of n;
Definition: coeffs.h:579
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff 'n' represents the one element.
Definition: coeffs.h:469
#define TEST_OPT_INTSTRATEGY
Definition: options.h:109
#define TEST_OPT_CONTENTSB
Definition: options.h:126
void p_ContentRat(poly &ph, const ring r)
Definition: p_polys.cc:1731
void p_ContentForGB(poly ph, const ring r)
Definition: p_polys.cc:2410
static poly p_Neg(poly p, const ring r)
Definition: p_polys.h:1067
static BOOLEAN rField_is_Ring(const ring r)
Definition: ring.h:489
static BOOLEAN rIsRatGRing(const ring r)
Definition: ring.h:430

◆ p_Cleardenom_n()

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

Definition at line 3009 of file p_polys.cc.

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

◆ p_Cmp()

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

Definition at line 1695 of file p_polys.h.

1696 {
1697  if (p2==NULL)
1698  {
1699  if (p1==NULL) return 0;
1700  return 1;
1701  }
1702  if (p1==NULL)
1703  return -1;
1704  return p_LmCmp(p1,p2,r);
1705 }

◆ p_CmpPolys()

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

Definition at line 1707 of file p_polys.h.

1708 {
1709  if (p2==NULL)
1710  {
1711  if (p1==NULL) return 0;
1712  return 1;
1713  }
1714  if (p1==NULL)
1715  return -1;
1716  return p_ComparePolys(p1,p2,r);
1717 }
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:4602

◆ p_Comp_k_n()

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

Definition at line 640 of file p_polys.h.

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

◆ p_Compare()

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

Definition at line 4932 of file p_polys.cc.

4933 {
4934  int r=p_Cmp(a,b,R);
4935  if ((r==0)&&(a!=NULL))
4936  {
4937  number h=n_Sub(pGetCoeff(a),pGetCoeff(b),R->cf);
4938  /* compare lead coeffs */
4939  r = -1+n_IsZero(h,R->cf)+2*n_GreaterZero(h,R->cf); /* -1: <, 0:==, 1: > */
4940  n_Delete(&h,R->cf);
4941  }
4942  else if (a==NULL)
4943  {
4944  if (b==NULL)
4945  {
4946  /* compare 0, 0 */
4947  r=0;
4948  }
4949  else if(p_IsConstant(b,R))
4950  {
4951  /* compare 0, const */
4952  r = 1-2*n_GreaterZero(pGetCoeff(b),R->cf); /* -1: <, 1: > */
4953  }
4954  }
4955  else if (b==NULL)
4956  {
4957  if (p_IsConstant(a,R))
4958  {
4959  /* compare const, 0 */
4960  r = -1+2*n_GreaterZero(pGetCoeff(a),R->cf); /* -1: <, 1: > */
4961  }
4962  }
4963  return(r);
4964 }
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:670
static int p_Cmp(poly p1, poly p2, ring r)
Definition: p_polys.h:1695

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

4603 {
4604  number n,nn;
4605  pAssume(p1 != NULL && p2 != NULL);
4606 
4607  if (!p_LmEqual(p1,p2,r)) //compare leading mons
4608  return FALSE;
4609  if ((pNext(p1)==NULL) && (pNext(p2)!=NULL))
4610  return FALSE;
4611  if ((pNext(p2)==NULL) && (pNext(p1)!=NULL))
4612  return FALSE;
4613  if (pLength(p1) != pLength(p2))
4614  return FALSE;
4615  #ifdef HAVE_RINGS
4616  if (rField_is_Ring(r))
4617  {
4618  if (!n_DivBy(pGetCoeff(p1), pGetCoeff(p2), r->cf)) return FALSE;
4619  }
4620  #endif
4621  n=n_Div(pGetCoeff(p1),pGetCoeff(p2),r->cf);
4622  while ((p1 != NULL) /*&& (p2 != NULL)*/)
4623  {
4624  if ( ! p_LmEqual(p1, p2,r))
4625  {
4626  n_Delete(&n, r->cf);
4627  return FALSE;
4628  }
4629  if (!n_Equal(pGetCoeff(p1), nn = n_Mult(pGetCoeff(p2),n, r->cf), r->cf))
4630  {
4631  n_Delete(&n, r->cf);
4632  n_Delete(&nn, r->cf);
4633  return FALSE;
4634  }
4635  n_Delete(&nn, r->cf);
4636  pIter(p1);
4637  pIter(p2);
4638  }
4639  n_Delete(&n, r->cf);
4640  return TRUE;
4641 }
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:777
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:461
#define pAssume(cond)
Definition: monomials.h:90
#define p_LmEqual(p1, p2, r)
Definition: p_polys.h:1691

◆ p_Content()

void p_Content ( poly  p,
const ring  r 
)

Definition at line 2282 of file p_polys.cc.

2283 {
2284  if (ph==NULL) return;
2285  const coeffs cf=r->cf;
2286  if (pNext(ph)==NULL)
2287  {
2288  p_SetCoeff(ph,n_Init(1,cf),r);
2289  }
2290  if ((cf->cfSubringGcd==ndGcd)
2291  || (cf->cfGcd==ndGcd)) /* trivial gcd*/
2292  return;
2293  number h;
2294  if ((rField_is_Q(r))
2295  || (rField_is_Q_a(r))
2296  || (rField_is_Zp_a)(r)
2297  || (rField_is_Z(r))
2298  )
2299  {
2300  h=p_InitContent(ph,r); /* first guess of a gcd of all coeffs */
2301  }
2302  else
2303  {
2304  h=n_Copy(pGetCoeff(ph),cf);
2305  }
2306  poly p;
2307  if(n_IsOne(h,cf))
2308  {
2309  goto content_finish;
2310  }
2311  p=ph;
2312  // take the SubringGcd of all coeffs
2313  while (p!=NULL)
2314  {
2316  number d=n_SubringGcd(h,pGetCoeff(p),cf);
2317  n_Delete(&h,cf);
2318  h = d;
2319  if(n_IsOne(h,cf))
2320  {
2321  goto content_finish;
2322  }
2323  pIter(p);
2324  }
2325  // if found<>1, divide by it
2326  p = ph;
2327  while (p!=NULL)
2328  {
2329  number d = n_ExactDiv(pGetCoeff(p),h,cf);
2330  p_SetCoeff(p,d,r);
2331  pIter(p);
2332  }
2333 content_finish:
2334  n_Delete(&h,r->cf);
2335  // and last: check leading sign:
2336  if(!n_GreaterZero(pGetCoeff(ph),r->cf)) ph = p_Neg(ph,r);
2337 }
CanonicalForm cf
Definition: cfModGcd.cc:4085
static FORCE_INLINE number n_ExactDiv(number a, number b, const coeffs r)
assume that there is a canonical subring in cf and we know that division is possible for these a and ...
Definition: coeffs.h:623
static FORCE_INLINE number n_SubringGcd(number a, number b, const coeffs r)
Definition: coeffs.h:689
number ndGcd(number, number, const coeffs r)
Definition: numbers.cc:164
number p_InitContent(poly ph, const ring r)
Definition: p_polys.cc:2690
static BOOLEAN rField_is_Zp_a(const ring r)
Definition: ring.h:534

◆ p_Content_n()

void p_Content_n ( poly  p,
number &  c,
const ring  r 
)

Definition at line 2339 of file p_polys.cc.

2340 {
2341  if (ph==NULL)
2342  {
2343  c=n_Init(1,r->cf);
2344  return;
2345  }
2346  const coeffs cf=r->cf;
2347  if (pNext(ph)==NULL)
2348  {
2349  c=pGetCoeff(ph);
2350  p_SetCoeff0(ph,n_Init(1,cf),r);
2351  }
2352  if ((cf->cfSubringGcd==ndGcd)
2353  || (cf->cfGcd==ndGcd)) /* trivial gcd*/
2354  {
2355  c=n_Init(1,r->cf);
2356  return;
2357  }
2358  number h;
2359  if ((rField_is_Q(r))
2360  || (rField_is_Q_a(r))
2361  || (rField_is_Zp_a)(r)
2362  || (rField_is_Z(r))
2363  )
2364  {
2365  h=p_InitContent(ph,r); /* first guess of a gcd of all coeffs */
2366  }
2367  else
2368  {
2369  h=n_Copy(pGetCoeff(ph),cf);
2370  }
2371  poly p;
2372  if(n_IsOne(h,cf))
2373  {
2374  goto content_finish;
2375  }
2376  p=ph;
2377  // take the SubringGcd of all coeffs
2378  while (p!=NULL)
2379  {
2381  number d=n_SubringGcd(h,pGetCoeff(p),cf);
2382  n_Delete(&h,cf);
2383  h = d;
2384  if(n_IsOne(h,cf))
2385  {
2386  goto content_finish;
2387  }
2388  pIter(p);
2389  }
2390  // if found<>1, divide by it
2391  p = ph;
2392  while (p!=NULL)
2393  {
2394  number d = n_ExactDiv(pGetCoeff(p),h,cf);
2395  p_SetCoeff(p,d,r);
2396  pIter(p);
2397  }
2398 content_finish:
2399  c=h;
2400  // and last: check leading sign:
2401  if(!n_GreaterZero(pGetCoeff(ph),r->cf))
2402  {
2403  c = n_InpNeg(c,r->cf);
2404  ph = p_Neg(ph,r);
2405  }
2406 }
#define p_SetCoeff0(p, n, r)
Definition: monomials.h:60

◆ p_ContentForGB()

void p_ContentForGB ( poly  p,
const ring  r 
)

Definition at line 2410 of file p_polys.cc.

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

◆ p_ContentRat()

void p_ContentRat ( poly &  ph,
const ring  r 
)

Definition at line 1731 of file p_polys.cc.

1734 {
1735  // init array of RatLeadCoeffs
1736  // poly p_GetCoeffRat(poly p, int ishift, ring r);
1737 
1738  int len=pLength(ph);
1739  poly *C = (poly *)omAlloc0((len+1)*sizeof(poly)); //rat coeffs
1740  poly *LM = (poly *)omAlloc0((len+1)*sizeof(poly)); // rat lead terms
1741  int *D = (int *)omAlloc0((len+1)*sizeof(int)); //degrees of coeffs
1742  int *L = (int *)omAlloc0((len+1)*sizeof(int)); //lengths of coeffs
1743  int k = 0;
1744  poly p = p_Copy(ph, r); // ph will be needed below
1745  int mintdeg = p_Totaldegree(p, r);
1746  int minlen = len;
1747  int dd = 0; int i;
1748  int HasConstantCoef = 0;
1749  int is = r->real_var_start - 1;
1750  while (p!=NULL)
1751  {
1752  LM[k] = p_GetExp_k_n(p,1,is, r); // need LmRat istead of p_HeadRat(p, is, currRing); !
1753  C[k] = p_GetCoeffRat(p, is, r);
1754  D[k] = p_Totaldegree(C[k], r);
1755  mintdeg = si_min(mintdeg,D[k]);
1756  L[k] = pLength(C[k]);
1757  minlen = si_min(minlen,L[k]);
1758  if (p_IsConstant(C[k], r))
1759  {
1760  // C[k] = const, so the content will be numerical
1761  HasConstantCoef = 1;
1762  // smth like goto cleanup and return(pContent(p));
1763  }
1764  p_LmDeleteAndNextRat(&p, is, r);
1765  k++;
1766  }
1767 
1768  // look for 1 element of minimal degree and of minimal length
1769  k--;
1770  poly d;
1771  int mindeglen = len;
1772  if (k<=0) // this poly is not a ratgring poly -> pContent
1773  {
1774  p_Delete(&C[0], r);
1775  p_Delete(&LM[0], r);
1776  p_ContentForGB(ph, r);
1777  goto cleanup;
1778  }
1779 
1780  int pmindeglen;
1781  for(i=0; i<=k; i++)
1782  {
1783  if (D[i] == mintdeg)
1784  {
1785  if (L[i] < mindeglen)
1786  {
1787  mindeglen=L[i];
1788  pmindeglen = i;
1789  }
1790  }
1791  }
1792  d = p_Copy(C[pmindeglen], r);
1793  // there are dd>=1 mindeg elements
1794  // and pmideglen is the coordinate of one of the smallest among them
1795 
1796  // poly g = singclap_gcd(p_Copy(p,r),p_Copy(q,r));
1797  // return naGcd(d,d2,currRing);
1798 
1799  // adjoin pContentRat here?
1800  for(i=0; i<=k; i++)
1801  {
1802  d=singclap_gcd(d,p_Copy(C[i], r), r);
1803  if (p_Totaldegree(d, r)==0)
1804  {
1805  // cleanup, pContent, return
1806  p_Delete(&d, r);
1807  for(;k>=0;k--)
1808  {
1809  p_Delete(&C[k], r);
1810  p_Delete(&LM[k], r);
1811  }
1812  p_ContentForGB(ph, r);
1813  goto cleanup;
1814  }
1815  }
1816  for(i=0; i<=k; i++)
1817  {
1818  poly h=singclap_pdivide(C[i],d, r);
1819  p_Delete(&C[i], r);
1820  C[i]=h;
1821  }
1822 
1823  // zusammensetzen,
1824  p=NULL; // just to be sure
1825  for(i=0; i<=k; i++)
1826  {
1827  p = p_Add_q(p, p_Mult_q(C[i],LM[i], r), r);
1828  C[i]=NULL; LM[i]=NULL;
1829  }
1830  p_Delete(&ph, r); // do not need it anymore
1831  ph = p;
1832  // aufraeumen, return
1833 cleanup:
1834  omFree(C);
1835  omFree(LM);
1836  omFree(D);
1837  omFree(L);
1838 }
poly singclap_pdivide(poly f, poly g, const ring r)
Definition: clapsing.cc:590
#define D(A)
Definition: gentable.cc:131
#define omFree(addr)
Definition: omAllocDecl.h:261
void p_LmDeleteAndNextRat(poly *p, int ishift, ring r)
Definition: p_polys.cc:1687
poly p_GetCoeffRat(poly p, int ishift, ring r)
Definition: p_polys.cc:1709
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:896
static poly p_Mult_q(poly p, poly q, const ring r)
Definition: p_polys.h:1074
static poly p_GetExp_k_n(poly p, int l, int k, const ring r)
Definition: p_polys.h:1332
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:812
static long p_Totaldegree(poly p, const ring r)
Definition: p_polys.h:1467
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:382

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

844 {
845  if (p != NULL)
846  {
847 #ifndef PDEBUG
848  if (tailRing == lmRing)
849  return p_Copy_noCheck(p, tailRing);
850 #endif
851  poly pres = p_Head(p, lmRing);
852  if (pNext(p)!=NULL)
853  pNext(pres) = p_Copy_noCheck(pNext(p), tailRing);
854  return pres;
855  }
856  else
857  return NULL;
858 }
static poly p_Copy_noCheck(poly p, const ring r)
returns a copy of p (without any additional testing)
Definition: p_polys.h:802

◆ p_Copy() [2/2]

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

returns a copy of p

Definition at line 812 of file p_polys.h.

813 {
814  if (p!=NULL)
815  {
816  p_Test(p,r);
817  const poly pp = p_Copy_noCheck(p, r);
818  p_Test(pp,r);
819  return pp;
820  }
821  else
822  return NULL;
823 }
CanonicalForm pp(const CanonicalForm &)
CanonicalForm pp ( const CanonicalForm & f )
Definition: cf_gcd.cc:676

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

803 {
804  /*assume(p!=NULL);*/
805  assume(r != NULL);
806  assume(r->p_Procs != NULL);
807  assume(r->p_Procs->p_Copy != NULL);
808  return r->p_Procs->p_Copy(p, r);
809 }

◆ p_CopyPowerProduct()

poly p_CopyPowerProduct ( poly  p,
const ring  r 
)

like p_Head, but with coefficient 1

Definition at line 5004 of file p_polys.cc.

5005 {
5006  if (p == NULL) return NULL;
5007  p_LmCheckPolyRing1(p, r);
5008  poly np;
5009  omTypeAllocBin(poly, np, r->PolyBin);
5010  p_SetRingOfLm(np, r);
5011  memcpy(np->exp, p->exp, r->ExpL_Size*sizeof(long));
5012  pNext(np) = NULL;
5013  pSetCoeff0(np, n_Init(1, r->cf));
5014  return np;
5015 }
#define p_LmCheckPolyRing1(p, r)
Definition: monomials.h:177
#define pSetCoeff0(p, n)
Definition: monomials.h:59
#define p_SetRingOfLm(p, r)
Definition: monomials.h:144
#define omTypeAllocBin(type, addr, bin)
Definition: omAllocDecl.h:203

◆ p_DecrExp()

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

Definition at line 598 of file p_polys.h.

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

◆ p_Deg()

long p_Deg ( poly  a,
const ring  r 
)

Definition at line 582 of file p_polys.cc.

583 {
584  p_LmCheckPolyRing(a, r);
585 // assume(p_GetOrder(a, r) == p_WTotaldegree(a, r)); // WRONG assume!
586  return p_GetOrder(a, r);
587 }
BOOLEAN p_LmCheckPolyRing(poly p, ring r)
Definition: pDebug.cc:118
static long p_GetOrder(poly p, ring r)
Definition: p_polys.h:421

◆ p_DegW()

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

Definition at line 685 of file p_polys.cc.

686 {
687  p_Test(p, R);
688  assume( w != NULL );
689  long r=-LONG_MAX;
690 
691  while (p!=NULL)
692  {
693  long t=totaldegreeWecart_IV(p,R,w);
694  if (t>r) r=t;
695  pIter(p);
696  }
697  return r;
698 }
const CanonicalForm & w
Definition: facAbsFact.cc:51
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 868 of file p_polys.h.

869 {
870  assume( p!= NULL );
871  if (*p != NULL)
872  {
873 #ifndef PDEBUG
874  if (tailRing == lmRing)
875  {
876  p_Delete(p, tailRing);
877  return;
878  }
879 #endif
880  if (pNext(*p) != NULL)
881  p_Delete(&pNext(*p), tailRing);
882  p_LmDelete(p, lmRing);
883  }
884 }
static void p_LmDelete(poly p, const ring r)
Definition: p_polys.h:711

◆ p_Delete() [2/2]

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

Definition at line 861 of file p_polys.h.

862 {
863  assume( p!= NULL );
864  assume( r!= NULL );
865  if ((*p)!=NULL) r->p_Procs->p_Delete(p, r);
866 }

◆ p_DeleteComp()

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

Definition at line 3613 of file p_polys.cc.

3614 {
3615  poly q;
3616 
3617  while ((*p!=NULL) && (__p_GetComp(*p,r)==k)) p_LmDelete(p,r);
3618  if (*p==NULL) return;
3619  q = *p;
3620  if (__p_GetComp(q,r)>k)
3621  {
3622  p_SubComp(q,1,r);
3623  p_SetmComp(q,r);
3624  }
3625  while (pNext(q)!=NULL)
3626  {
3627  if (__p_GetComp(pNext(q),r)==k)
3628  p_LmDelete(&(pNext(q)),r);
3629  else
3630  {
3631  pIter(q);
3632  if (__p_GetComp(q,r)>k)
3633  {
3634  p_SubComp(q,1,r);
3635  p_SetmComp(q,r);
3636  }
3637  }
3638  }
3639 }
static unsigned long p_SubComp(poly p, unsigned long v, ring r)
Definition: p_polys.h:453
#define p_SetmComp
Definition: p_polys.h:244

◆ p_Diff()

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

Definition at line 1885 of file p_polys.cc.

1886 {
1887  poly res, f, last;
1888  number t;
1889 
1890  last = res = NULL;
1891  while (a!=NULL)
1892  {
1893  if (p_GetExp(a,k,r)!=0)
1894  {
1895  f = p_LmInit(a,r);
1896  t = n_Init(p_GetExp(a,k,r),r->cf);
1897  pSetCoeff0(f,n_Mult(t,pGetCoeff(a),r->cf));
1898  n_Delete(&t,r->cf);
1899  if (n_IsZero(pGetCoeff(f),r->cf))
1900  p_LmDelete(&f,r);
1901  else
1902  {
1903  p_DecrExp(f,k,r);
1904  p_Setm(f,r);
1905  if (res==NULL)
1906  {
1907  res=last=f;
1908  }
1909  else
1910  {
1911  pNext(last)=f;
1912  last=f;
1913  }
1914  }
1915  }
1916  pIter(a);
1917  }
1918  return res;
1919 }
FILE * f
Definition: checklibs.c:9
STATIC_VAR poly last
Definition: hdegree.cc:1150
static poly p_LmInit(poly p, const ring r)
Definition: p_polys.h:1295
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:233
static long p_DecrExp(poly p, int v, ring r)
Definition: p_polys.h:598

◆ p_DiffOp()

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

Definition at line 1960 of file p_polys.cc.

1961 {
1962  poly result=NULL;
1963  poly h;
1964  for(;a!=NULL;pIter(a))
1965  {
1966  for(h=b;h!=NULL;pIter(h))
1967  {
1968  result=p_Add_q(result,p_DiffOpM(a,h,multiply,r),r);
1969  }
1970  }
1971  return result;
1972 }
return result
Definition: facAbsBiFact.cc:75
static poly p_DiffOpM(poly a, poly b, BOOLEAN multiply, const ring r)
Definition: p_polys.cc:1921

◆ p_Div_mm()

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

divide polynomial by monomial

Definition at line 1525 of file p_polys.cc.

1526 {
1527  p_Test(p, r);
1528  p_Test(m, r);
1529  poly result = p;
1530  poly prev = NULL;
1531  number n=pGetCoeff(m);
1532  while (p!=NULL)
1533  {
1534  number nc = n_Div(pGetCoeff(p),n,r->cf);
1535  n_Normalize(nc,r->cf);
1536  if (!n_IsZero(nc,r->cf))
1537  {
1538  p_SetCoeff(p,nc,r);
1539  prev=p;
1540  p_ExpVectorSub(p,m,r);
1541  pIter(p);
1542  }
1543  else
1544  {
1545  if (prev==NULL)
1546  {
1547  p_LmDelete(&result,r);
1548  p=result;
1549  }
1550  else
1551  {
1552  p_LmDelete(&pNext(prev),r);
1553  p=pNext(prev);
1554  }
1555  }
1556  }
1557  p_Test(result,r);
1558  return(result);
1559 }
int m
Definition: cfEzgcd.cc:128
static void p_ExpVectorSub(poly p1, poly p2, const ring r)
Definition: p_polys.h:1400

◆ p_Div_nn()

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

Definition at line 1492 of file p_polys.cc.

1493 {
1494  pAssume(!n_IsZero(n,r->cf));
1495  p_Test(p, r);
1496  poly result = p;
1497  poly prev = NULL;
1498  while (p!=NULL)
1499  {
1500  number nc = n_Div(pGetCoeff(p),n,r->cf);
1501  if (!n_IsZero(nc,r->cf))
1502  {
1503  p_SetCoeff(p,nc,r);
1504  prev=p;
1505  pIter(p);
1506  }
1507  else
1508  {
1509  if (prev==NULL)
1510  {
1511  p_LmDelete(&result,r);
1512  p=result;
1513  }
1514  else
1515  {
1516  p_LmDelete(&pNext(prev),r);
1517  p=pNext(prev);
1518  }
1519  }
1520  }
1521  p_Test(result,r);
1522  return(result);
1523 }

◆ p_DivideM()

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

Definition at line 1565 of file p_polys.cc.

1566 {
1567  if (a==NULL) { p_Delete(&b,r); return NULL; }
1568  poly result=a;
1569 
1570  if(!p_IsConstant(b,r))
1571  {
1572  if (rIsNCRing(r))
1573  {
1574  WerrorS("p_DivideM not implemented for non-commuative rings");
1575  return NULL;
1576  }
1577  poly prev=NULL;
1578  while (a!=NULL)
1579  {
1580  if (p_DivisibleBy(b,a,r))
1581  {
1582  p_ExpVectorSub(a,b,r);
1583  prev=a;
1584  pIter(a);
1585  }
1586  else
1587  {
1588  if (prev==NULL)
1589  {
1590  p_LmDelete(&result,r);
1591  a=result;
1592  }
1593  else
1594  {
1595  p_LmDelete(&pNext(prev),r);
1596  a=pNext(prev);
1597  }
1598  }
1599  }
1600  }
1601  if (result!=NULL)
1602  {
1603  number inv=pGetCoeff(b);
1604  //if ((!rField_is_Ring(r)) || n_IsUnit(inv,r->cf))
1605  if (rField_is_Zp(r))
1606  {
1607  inv = n_Invers(inv,r->cf);
1608  __p_Mult_nn(result,inv,r);
1609  n_Delete(&inv, r->cf);
1610  }
1611  else
1612  {
1613  result = p_Div_nn(result,inv,r);
1614  }
1615  }
1616  p_Delete(&b, r);
1617  return result;
1618 }
static BOOLEAN p_DivisibleBy(poly a, poly b, const ring r)
Definition: p_polys.h:1872
#define __p_Mult_nn(p, n, r)
Definition: p_polys.h:931
static BOOLEAN rIsNCRing(const ring r)
Definition: ring.h:421

◆ p_DivisibleBy() [1/2]

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

Definition at line 1881 of file p_polys.h.

1882 {
1883  pIfThen1(b!=NULL, p_LmCheckPolyRing1(b, r_b));
1884  pIfThen1(a!=NULL, p_LmCheckPolyRing1(a, r_a));
1885  if (a != NULL) {
1886  return _p_LmDivisibleBy(a, r_a, b, r_b);
1887  }
1888  return FALSE;
1889 }
#define pIfThen1(cond, check)
Definition: monomials.h:179
static BOOLEAN _p_LmDivisibleBy(poly a, poly b, const ring r)
Definition: p_polys.h:1837

◆ p_DivisibleBy() [2/2]

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

Definition at line 1872 of file p_polys.h.

1873 {
1875  pIfThen1(a!=NULL, p_LmCheckPolyRing1(a, r));
1876 
1877  if (a != NULL && (p_GetComp(a, r) == 0 || p_GetComp(a,r) == p_GetComp(b,r)))
1878  return _p_LmDivisibleByNoComp(a,b,r);
1879  return FALSE;
1880 }

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

1630 {
1631  int exponent;
1632  for(int i = (int)rVar(r); i>0; i--)
1633  {
1634  exponent = p_GetExp(g, i, r) - p_GetExp(f, i, r);
1635  if (exponent < 0) return FALSE;
1636  }
1637  return n_DivBy(pGetCoeff(g), pGetCoeff(f), r->cf);
1638 }
g
Definition: cfModGcd.cc:4092
int exponent(const CanonicalForm &f, int q)
int exponent ( const CanonicalForm & f, int q )

◆ p_EqualPolys() [1/2]

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

Definition at line 4538 of file p_polys.cc.

4539 {
4540  while ((p1 != NULL) && (p2 != NULL))
4541  {
4542  if (! p_LmEqual(p1, p2,r))
4543  return FALSE;
4544  if (! n_Equal(p_GetCoeff(p1,r), p_GetCoeff(p2,r),r->cf ))
4545  return FALSE;
4546  pIter(p1);
4547  pIter(p2);
4548  }
4549  return (p1==p2);
4550 }
#define p_GetCoeff(p, r)
Definition: monomials.h:50

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

4577 {
4578  assume( r1 == r2 || rSamePolyRep(r1, r2) ); // will be used in rEqual!
4579  assume( r1->cf == r2->cf );
4580 
4581  while ((p1 != NULL) && (p2 != NULL))
4582  {
4583  // returns 1 if ExpVector(p)==ExpVector(q): does not compare numbers !!
4584  // #define p_LmEqual(p1, p2, r) p_ExpVectorEqual(p1, p2, r)
4585 
4586  if (! p_ExpVectorEqual(p1, p2, r1, r2))
4587  return FALSE;
4588 
4589  if (! n_Equal(p_GetCoeff(p1,r1), p_GetCoeff(p2,r2), r1->cf ))
4590  return FALSE;
4591 
4592  pIter(p1);
4593  pIter(p2);
4594  }
4595  return (p1==p2);
4596 }
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:1716

◆ p_ExpVectorAdd()

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

Definition at line 1371 of file p_polys.h.

1372 {
1373  p_LmCheckPolyRing1(p1, r);
1374  p_LmCheckPolyRing1(p2, r);
1375 #if PDEBUG >= 1
1376  for (int i=1; i<=r->N; i++)
1377  pAssume1((unsigned long) (p_GetExp(p1, i, r) + p_GetExp(p2, i, r)) <= r->bitmask);
1378  pAssume1(p_GetComp(p1, r) == 0 || p_GetComp(p2, r) == 0);
1379 #endif
1380 
1381  p_MemAdd_LengthGeneral(p1->exp, p2->exp, r->ExpL_Size);
1382  p_MemAdd_NegWeightAdjust(p1, r);
1383 }
#define p_MemAdd_LengthGeneral(r, s, length)
Definition: p_MemAdd.h:173
static void p_MemAdd_NegWeightAdjust(poly p, const ring r)
Definition: p_polys.h:1252

◆ p_ExpVectorAddSub()

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

Definition at line 1416 of file p_polys.h.

1417 {
1418  p_LmCheckPolyRing1(p1, r);
1419  p_LmCheckPolyRing1(p2, r);
1420  p_LmCheckPolyRing1(p3, r);
1421 #if PDEBUG >= 1
1422  for (int i=1; i<=r->N; i++)
1423  pAssume1(p_GetExp(p1, i, r) + p_GetExp(p2, i, r) >= p_GetExp(p3, i, r));
1424  pAssume1(p_GetComp(p1, r) == 0 ||
1425  (p_GetComp(p2, r) - p_GetComp(p3, r) == 0) ||
1426  (p_GetComp(p1, r) == p_GetComp(p2, r) - p_GetComp(p3, r)));
1427 #endif
1428 
1429  p_MemAddSub_LengthGeneral(p1->exp, p2->exp, p3->exp, r->ExpL_Size);
1430  // no need to adjust in case of NegWeights
1431 }
#define p_MemAddSub_LengthGeneral(r, s, t, length)
Definition: p_MemAdd.h:312

◆ p_ExpVectorCopy()

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

Definition at line 1273 of file p_polys.h.

1274 {
1275  p_LmCheckPolyRing1(d_p, r);
1276  p_LmCheckPolyRing1(s_p, r);
1277  memcpy(d_p->exp, s_p->exp, r->ExpL_Size*sizeof(long));
1278 }

◆ p_ExpVectorDiff()

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

Definition at line 1434 of file p_polys.h.

1435 {
1436  p_LmCheckPolyRing1(p1, r);
1437  p_LmCheckPolyRing1(p2, r);
1438  p_LmCheckPolyRing1(pr, r);
1439 #if PDEBUG >= 2
1440  for (int i=1; i<=r->N; i++)
1441  pAssume1(p_GetExp(p1, i, r) >= p_GetExp(p2, i, r));
1442  pAssume1(!rRing_has_Comp(r) || p_GetComp(p1, r) == p_GetComp(p2, r));
1443 #endif
1444 
1445  p_MemDiff_LengthGeneral(pr->exp, p1->exp, p2->exp, r->ExpL_Size);
1446  p_MemSub_NegWeightAdjust(pr, r);
1447 }
#define p_MemDiff_LengthGeneral(r, s1, s2, length)
Definition: p_MemAdd.h:262
static void p_MemSub_NegWeightAdjust(poly p, const ring r)
Definition: p_polys.h:1262

◆ p_ExpVectorEqual()

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

Definition at line 1449 of file p_polys.h.

1450 {
1451  p_LmCheckPolyRing1(p1, r);
1452  p_LmCheckPolyRing1(p2, r);
1453 
1454  unsigned i = r->ExpL_Size;
1455  unsigned long *ep = p1->exp;
1456  unsigned long *eq = p2->exp;
1457 
1458  do
1459  {
1460  i--;
1461  if (ep[i] != eq[i]) return FALSE;
1462  }
1463  while (i!=0);
1464  return TRUE;
1465 }

◆ p_ExpVectorSub()

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

Definition at line 1400 of file p_polys.h.

1401 {
1402  p_LmCheckPolyRing1(p1, r);
1403  p_LmCheckPolyRing1(p2, r);
1404 #if PDEBUG >= 1
1405  for (int i=1; i<=r->N; i++)
1406  pAssume1(p_GetExp(p1, i, r) >= p_GetExp(p2, i, r));
1407  pAssume1(p_GetComp(p1, r) == 0 || p_GetComp(p2, r) == 0 ||
1408  p_GetComp(p1, r) == p_GetComp(p2, r));
1409 #endif
1410 
1411  p_MemSub_LengthGeneral(p1->exp, p2->exp, r->ExpL_Size);
1412  p_MemSub_NegWeightAdjust(p1, r);
1413 }
#define p_MemSub_LengthGeneral(r, s, length)
Definition: p_MemAdd.h:291

◆ p_ExpVectorSum()

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

Definition at line 1385 of file p_polys.h.

1386 {
1387  p_LmCheckPolyRing1(p1, r);
1388  p_LmCheckPolyRing1(p2, r);
1389  p_LmCheckPolyRing1(pr, r);
1390 #if PDEBUG >= 1
1391  for (int i=1; i<=r->N; i++)
1392  pAssume1((unsigned long) (p_GetExp(p1, i, r) + p_GetExp(p2, i, r)) <= r->bitmask);
1393  pAssume1(p_GetComp(p1, r) == 0 || p_GetComp(p2, r) == 0);
1394 #endif
1395 
1396  p_MemSum_LengthGeneral(pr->exp, p1->exp, p2->exp, r->ExpL_Size);
1397  p_MemAdd_NegWeightAdjust(pr, r);
1398 }
#define p_MemSum_LengthGeneral(r, s1, s2, length)
Definition: p_MemAdd.h:86

◆ 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  {
60  number c=pGetCoeff(h);
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:791

◆ p_FDeg()

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

Definition at line 380 of file p_polys.h.

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

◆ p_GcdMon()

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

polynomial gcd for f=mon

Definition at line 4966 of file p_polys.cc.

4967 {
4968  assume(f!=NULL);
4969  assume(g!=NULL);
4970  assume(pNext(f)==NULL);
4971  poly G=p_Head(f,r);
4972  poly h=g;
4973  int *mf=(int*)omAlloc((r->N+1)*sizeof(int));
4974  p_GetExpV(f,mf,r);
4975  int *mh=(int*)omAlloc((r->N+1)*sizeof(int));
4976  BOOLEAN const_mon;
4977  BOOLEAN one_coeff=n_IsOne(pGetCoeff(G),r->cf);
4978  loop
4979  {
4980  if (h==NULL) break;
4981  if(!one_coeff)
4982  {
4983  number n=n_SubringGcd(pGetCoeff(G),pGetCoeff(h),r->cf);
4984  one_coeff=n_IsOne(n,r->cf);
4985  p_SetCoeff(G,n,r);
4986  }
4987  p_GetExpV(h,mh,r);
4988  const_mon=TRUE;
4989  for(unsigned j=r->N;j!=0;j--)
4990  {
4991  if (mh[j]<mf[j]) mf[j]=mh[j];
4992  if (mf[j]>0) const_mon=FALSE;
4993  }
4994  if (one_coeff && const_mon) break;
4995  pIter(h);
4996  }
4997  mf[0]=0;
4998  p_SetExpV(G,mf,r); // included is p_SetComp, p_Setm
4999  omFreeSize(mf,(r->N+1)*sizeof(int));
5000  omFreeSize(mh,(r->N+1)*sizeof(int));
5001  return G;
5002 }
STATIC_VAR TreeM * G
Definition: janet.cc:31
#define omAlloc(size)
Definition: omAllocDecl.h:210
static void p_SetExpV(poly p, int *ev, const ring r)
Definition: p_polys.h:1504
static void p_GetExpV(poly p, int *ev, const ring r)
Definition: p_polys.h:1480

◆ p_GetCoeffRat()

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

Definition at line 1709 of file p_polys.cc.

1710 {
1711  poly q = pNext(p);
1712  poly res; // = p_Head(p,r);
1713  res = p_GetExp_k_n(p, ishift+1, r->N, r); // does pSetm internally
1714  p_SetCoeff(res,n_Copy(p_GetCoeff(p,r),r),r);
1715  poly s;
1716  long cmp = p_GetComp(p, r);
1717  while ( (q!= NULL) && (p_Comp_k_n(p, q, ishift+1, r)) && (p_GetComp(q, r) == cmp) )
1718  {
1719  s = p_GetExp_k_n(q, ishift+1, r->N, r);
1720  p_SetCoeff(s,n_Copy(p_GetCoeff(q,r),r),r);
1721  res = p_Add_q(res,s,r);
1722  q = pNext(q);
1723  }
1724  cmp = 0;
1725  p_SetCompP(res,cmp,r);
1726  return res;
1727 }
const CanonicalForm int s
Definition: facAbsFact.cc:51
static int p_Comp_k_n(poly a, poly b, int k, ring r)
Definition: p_polys.h:640
static void p_SetCompP(poly p, int i, ring r)
Definition: p_polys.h:254

◆ p_GetExp() [1/3]

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

get v^th exponent for a monomial

Definition at line 572 of file p_polys.h.

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

◆ p_GetExp() [2/3]

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

Definition at line 555 of file p_polys.h.

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

◆ p_GetExp() [3/3]

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

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

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

Definition at line 469 of file p_polys.h.

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

◆ p_GetExp_k_n()

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

Definition at line 1332 of file p_polys.h.

1333 {
1334  if (p == NULL) return NULL;
1335  p_LmCheckPolyRing1(p, r);
1336  poly np;
1337  omTypeAllocBin(poly, np, r->PolyBin);
1338  p_SetRingOfLm(np, r);
1339  memcpy(np->exp, p->exp, r->ExpL_Size*sizeof(long));
1340  pNext(np) = NULL;
1341  pSetCoeff0(np, n_Init(1, r->cf));
1342  int i;
1343  for(i=l;i<=k;i++)
1344  {
1345  //np->exp[(r->VarOffset[i] & 0xffffff)] =0;
1346  p_SetExp(np,i,0,r);
1347  }
1348  p_Setm(np,r);
1349  return np;
1350 }

◆ p_GetExpDiff()

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

Definition at line 635 of file p_polys.h.

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

◆ p_GetExpSum()

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

Definition at line 629 of file p_polys.h.

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

◆ p_GetExpV()

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

Definition at line 1480 of file p_polys.h.

1481 {
1482  p_LmCheckPolyRing1(p, r);
1483  for (unsigned j = r->N; j!=0; j--)
1484  ev[j] = p_GetExp(p, j, r);
1485 
1486  ev[0] = p_GetComp(p, r);
1487 }

◆ p_GetExpVL()

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

Definition at line 1489 of file p_polys.h.

1490 {
1491  p_LmCheckPolyRing1(p, r);
1492  for (unsigned j = r->N; j!=0; j--)
1493  ev[j-1] = p_GetExp(p, j, r);
1494 }

◆ p_GetExpVLV()

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

Definition at line 1496 of file p_polys.h.

1497 {
1498  p_LmCheckPolyRing1(p, r);
1499  for (unsigned j = r->N; j!=0; j--)
1500  ev[j-1] = p_GetExp(p, j, r);
1501  return (int64)p_GetComp(p,r);
1502 }
long int64
Definition: auxiliary.h:68

◆ p_GetMaxExp() [1/2]

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

Definition at line 770 of file p_polys.h.

771 {
772  return p_GetMaxExp(p_GetMaxExpL(p, r), r);
773 }
static unsigned long p_GetMaxExp(const unsigned long l, const ring r)
Definition: p_polys.h:747
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:1170

◆ p_GetMaxExp() [2/2]

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

Definition at line 747 of file p_polys.h.

748 {
749  unsigned long bitmask = r->bitmask;
750  unsigned long max = (l & bitmask);
751  unsigned long j = r->ExpPerLong - 1;
752 
753  if (j > 0)
754  {
755  unsigned long i = r->BitsPerExp;
756  long e;
757  loop
758  {
759  e = ((l >> i) & bitmask);
760  if ((unsigned long) e > max)
761  max = e;
762  j--;
763  if (j==0) break;
764  i += r->BitsPerExp;
765  }
766  }
767  return max;
768 }
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 1170 of file p_polys.cc.

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

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

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

◆ p_GetOrder()

static long p_GetOrder ( poly  p,
ring  r 
)
inlinestatic

Definition at line 421 of file p_polys.h.

422 {
423  p_LmCheckPolyRing2(p, r);
424  if (r->typ==NULL) return ((p)->exp[r->pOrdIndex]);
425  int i=0;
426  loop
427  {
428  switch(r->typ[i].ord_typ)
429  {
430  case ro_am:
431  case ro_wp_neg:
432  return ((p->exp[r->pOrdIndex])-POLY_NEGWEIGHT_OFFSET);
433  case ro_syzcomp:
434  case ro_syz:
435  case ro_cp:
436  i++;
437  break;
438  //case ro_dp:
439  //case ro_wp:
440  default:
441  return ((p)->exp[r->pOrdIndex]);
442  }
443  }
444 }
#define POLY_NEGWEIGHT_OFFSET
Definition: monomials.h:236
@ ro_syz
Definition: ring.h:60
@ ro_cp
Definition: ring.h:58
@ ro_wp_neg
Definition: ring.h:56
@ ro_am
Definition: ring.h:54

◆ p_GetSetmProc()

p_SetmProc p_GetSetmProc ( const ring  r)

Definition at line 555 of file p_polys.cc.

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

◆ p_GetShortExpVector() [1/2]

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

Definition at line 4807 of file p_polys.cc.

4808 {
4809  assume(p != NULL);
4810  unsigned long ev = 0; // short exponent vector
4811  unsigned int n = BIT_SIZEOF_LONG / r->N; // number of bits per exp
4812  unsigned int m1; // highest bit which is filled with (n+1)
4813  int i=0,j=1;
4814 
4815  if (n == 0)
4816  {
4817  if (r->N <2*BIT_SIZEOF_LONG)
4818  {
4819  n=1;
4820  m1=0;
4821  }
4822  else
4823  {
4824  for (; j<=r->N; j++)
4825  {
4826  if (p_GetExp(p,j,r) > 0) i++;
4827  if (i == BIT_SIZEOF_LONG) break;
4828  }
4829  if (i>0)
4830  ev = ~(0UL) >> (BIT_SIZEOF_LONG - i);
4831  return ev;
4832  }
4833  }
4834  else
4835  {
4836  m1 = (n+1)*(BIT_SIZEOF_LONG - n*r->N);
4837  }
4838 
4839  n++;
4840  while (i<m1)
4841  {
4842  ev |= GetBitFields(p_GetExp(p, j,r), i, n);
4843  i += n;
4844  j++;
4845  }
4846 
4847  n--;
4848  while (i<BIT_SIZEOF_LONG)
4849  {
4850  ev |= GetBitFields(p_GetExp(p, j,r), i, n);
4851  i += n;
4852  j++;
4853  }
4854  return ev;
4855 }
#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:4774

◆ p_GetShortExpVector() [2/2]

unsigned long p_GetShortExpVector ( const poly  p,
const poly  pp,
const ring  r 
)

p_GetShortExpVector of p * pp

Definition at line 4859 of file p_polys.cc.

4860 {
4861  assume(p != NULL);
4862  assume(pp != NULL);
4863 
4864  unsigned long ev = 0; // short exponent vector
4865  unsigned int n = BIT_SIZEOF_LONG / r->N; // number of bits per exp
4866  unsigned int m1; // highest bit which is filled with (n+1)
4867  int j=1;
4868  unsigned long i = 0L;
4869 
4870  if (n == 0)
4871  {
4872  if (r->N <2*BIT_SIZEOF_LONG)
4873  {
4874  n=1;
4875  m1=0;
4876  }
4877  else
4878  {
4879  for (; j<=r->N; j++)
4880  {
4881  if (p_GetExp(p,j,r) > 0 || p_GetExp(pp,j,r) > 0) i++;
4882  if (i == BIT_SIZEOF_LONG) break;
4883  }
4884  if (i>0)
4885  ev = ~(0UL) >> (BIT_SIZEOF_LONG - i);
4886  return ev;
4887  }
4888  }
4889  else
4890  {
4891  m1 = (n+1)*(BIT_SIZEOF_LONG - n*r->N);
4892  }
4893 
4894  n++;
4895  while (i<m1)
4896  {
4897  ev |= GetBitFields(p_GetExp(p, j,r) + p_GetExp(pp, j,r), i, n);
4898  i += n;
4899  j++;
4900  }
4901 
4902  n--;
4903  while (i<BIT_SIZEOF_LONG)
4904  {
4905  ev |= GetBitFields(p_GetExp(p, j,r) + p_GetExp(pp, j,r), i, n);
4906  i += n;
4907  j++;
4908  }
4909  return ev;
4910 }

◆ p_GetTotalDegree()

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

Definition at line 776 of file p_polys.h.

777 {
778  const unsigned long bitmask = r->bitmask;
779  unsigned long sum = (l & bitmask);
780  unsigned long j = number_of_exps - 1;
781 
782  if (j > 0)
783  {
784  unsigned long i = r->BitsPerExp;
785  loop
786  {
787  sum += ((l >> i) & bitmask);
788  j--;
789  if (j==0) break;
790  i += r->BitsPerExp;
791  }
792  }
793  return sum;
794 }

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

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

◆ p_HasNotCF()

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

Definition at line 1324 of file p_polys.cc.

1325 {
1326 
1327  if (p_GetComp(p1,r) > 0 || p_GetComp(p2,r) > 0)
1328  return FALSE;
1329  int i = rVar(r);
1330  loop
1331  {
1332  if ((p_GetExp(p1, i, r) > 0) && (p_GetExp(p2, i, r) > 0))
1333  return FALSE;
1334  i--;
1335  if (i == 0)
1336  return TRUE;
1337  }
1338 }

◆ p_HasNotCFRing()

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

Definition at line 1340 of file p_polys.cc.

1341 {
1342 
1343  if (p_GetComp(p1,r) > 0 || p_GetComp(p2,r) > 0)
1344  return FALSE;
1345  int i = rVar(r);
1346  loop
1347  {
1348  if ((p_GetExp(p1, i, r) > 0) && (p_GetExp(p2, i, r) > 0))
1349  return FALSE;
1350  i--;
1351  if (i == 0) {
1352  if (n_DivBy(pGetCoeff(p1), pGetCoeff(p2), r->cf) ||
1353  n_DivBy(pGetCoeff(p2), pGetCoeff(p1), r->cf)) {
1354  return FALSE;
1355  } else {
1356  return TRUE;
1357  }
1358  }
1359  }
1360 }

◆ p_Head()

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

copy the i(leading) term of p

Definition at line 826 of file p_polys.h.

827 {
828  if (p == NULL) return NULL;
829  p_LmCheckPolyRing1(p, r);
830  poly np;
831  omTypeAllocBin(poly, np, r->PolyBin);
832  p_SetRingOfLm(np, r);
833  memcpy(np->exp, p->exp, r->ExpL_Size*sizeof(long));
834  pNext(np) = NULL;
835  pSetCoeff0(np, n_Copy(pGetCoeff(p), r->cf));
836  return np;
837 }

◆ p_Homogen()

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

Definition at line 3327 of file p_polys.cc.

3328 {
3329  pFDegProc deg;
3330  if (r->pLexOrder && (r->order[0]==ringorder_lp))
3331  deg=p_Totaldegree;
3332  else
3333  deg=r->pFDeg;
3334 
3335  poly q=NULL, qn;
3336  int o,ii;
3337  sBucket_pt bp;
3338 
3339  if (p!=NULL)
3340  {
3341  if ((varnum < 1) || (varnum > rVar(r)))
3342  {
3343  return NULL;
3344  }
3345  o=deg(p,r);
3346  q=pNext(p);
3347  while (q != NULL)
3348  {
3349  ii=deg(q,r);
3350  if (ii>o) o=ii;
3351  pIter(q);
3352  }
3353  q = p_Copy(p,r);
3354  bp = sBucketCreate(r);
3355  while (q != NULL)
3356  {
3357  ii = o-deg(q,r);
3358  if (ii!=0)
3359  {
3360  p_AddExp(q,varnum, (long)ii,r);
3361  p_Setm(q,r);
3362  }
3363  qn = pNext(q);
3364  pNext(q) = NULL;
3365  sBucket_Add_m(bp, q);
3366  q = qn;
3367  }
3368  sBucketDestroyAdd(bp, &q, &ii);
3369  }
3370  return q;
3371 }
static long p_AddExp(poly p, int v, long ee, ring r)
Definition: p_polys.h:606
long(* pFDegProc)(poly p, ring r)
Definition: ring.h:38
@ ringorder_lp
Definition: ring.h:77
void sBucket_Add_m(sBucket_pt bucket, poly p)
Definition: sbuckets.cc:173
sBucket_pt sBucketCreate(const ring r)
Definition: sbuckets.cc:96
void sBucketDestroyAdd(sBucket_pt bucket, poly *p, int *length)
Definition: sbuckets.h:68

◆ p_IncrExp()

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

Definition at line 591 of file p_polys.h.

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

◆ p_Init() [1/2]

static poly p_Init ( const ring  r)
inlinestatic

Definition at line 1290 of file p_polys.h.

1291 {
1292  return p_Init(r, r->PolyBin);
1293 }

◆ p_Init() [2/2]

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

Definition at line 1280 of file p_polys.h.

1281 {
1282  p_CheckRing1(r);
1283  pAssume1(bin != NULL && omSizeWOfBin(r->PolyBin) == omSizeWOfBin(bin));
1284  poly p;
1285  omTypeAlloc0Bin(poly, p, bin);
1287  p_SetRingOfLm(p, r);
1288  return p;
1289 }
#define p_CheckRing1(r)
Definition: monomials.h:178
#define omTypeAlloc0Bin(type, addr, bin)
Definition: omAllocDecl.h:204

◆ p_InitContent()

number p_InitContent ( poly  ph,
const ring  r 
)

Definition at line 2690 of file p_polys.cc.

2693 {
2695  assume(ph!=NULL);
2696  assume(pNext(ph)!=NULL);
2697  assume(rField_is_Q(r));
2698  if (pNext(pNext(ph))==NULL)
2699  {
2700  return n_GetNumerator(pGetCoeff(pNext(ph)),r->cf);
2701  }
2702  poly p=ph;
2703  number n1=n_GetNumerator(pGetCoeff(p),r->cf);
2704  pIter(p);
2705  number n2=n_GetNumerator(pGetCoeff(p),r->cf);
2706  pIter(p);
2707  number d;
2708  number t;
2709  loop
2710  {
2711  nlNormalize(pGetCoeff(p),r->cf);
2712  t=n_GetNumerator(pGetCoeff(p),r->cf);
2713  if (nlGreaterZero(t,r->cf))
2714  d=nlAdd(n1,t,r->cf);
2715  else
2716  d=nlSub(n1,t,r->cf);
2717  nlDelete(&t,r->cf);
2718  nlDelete(&n1,r->cf);
2719  n1=d;
2720  pIter(p);
2721  if (p==NULL) break;
2722  nlNormalize(pGetCoeff(p),r->cf);
2723  t=n_GetNumerator(pGetCoeff(p),r->cf);
2724  if (nlGreaterZero(t,r->cf))
2725  d=nlAdd(n2,t,r->cf);
2726  else
2727  d=nlSub(n2,t,r->cf);
2728  nlDelete(&t,r->cf);
2729  nlDelete(&n2,r->cf);
2730  n2=d;
2731  pIter(p);
2732  if (p==NULL) break;
2733  }
2734  d=nlGcd(n1,n2,r->cf);
2735  nlDelete(&n1,r->cf);
2736  nlDelete(&n2,r->cf);
2737  return d;
2738 }
2739 #else
2740 {
2741  /* ph has al least 2 terms */
2742  number d=pGetCoeff(ph);
2743  int s=n_Size(d,r->cf);
2744  pIter(ph);
2745  number d2=pGetCoeff(ph);
2746  int s2=n_Size(d2,r->cf);
2747  pIter(ph);
2748  if (ph==NULL)
2749  {
2750  if (s<s2) return n_Copy(d,r->cf);
2751  else return n_Copy(d2,r->cf);
2752  }
2753  do
2754  {
2755  number nd=pGetCoeff(ph);
2756  int ns=n_Size(nd,r->cf);
2757  if (ns<=2)
2758  {
2759  s2=s;
2760  d2=d;
2761  d=nd;
2762  s=ns;
2763  break;
2764  }
2765  else if (ns<s)
2766  {
2767  s2=s;
2768  d2=d;
2769  d=nd;
2770  s=ns;
2771  }
2772  pIter(ph);
2773  }
2774  while(ph!=NULL);
2775  return n_SubringGcd(d,d2,r->cf);
2776 }
static FORCE_INLINE int n_Size(number n, const coeffs r)
return a non-negative measure for the complexity of n; return 0 only when n represents zero; (used fo...
Definition: coeffs.h:571
static FORCE_INLINE number n_GetNumerator(number &n, const coeffs r)
return the numerator of n (if elements of r are by nature not fractional, result is n)
Definition: coeffs.h:609
LINLINE number nlAdd(number la, number li, const coeffs r)
Definition: longrat.cc:2661
LINLINE number nlSub(number la, number li, const coeffs r)
Definition: longrat.cc:2727
LINLINE void nlDelete(number *a, const coeffs r)
Definition: longrat.cc:2626
BOOLEAN nlGreaterZero(number za, const coeffs r)
Definition: longrat.cc:1268
number nlGcd(number a, number b, const coeffs r)
Definition: longrat.cc:1305
void nlNormalize(number &x, const coeffs r)
Definition: longrat.cc:1447

◆ p_IsConstant()

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

Definition at line 1971 of file p_polys.h.

1972 {
1973  if (p == NULL) return TRUE;
1974  p_Test(p, r);
1975  return (pNext(p)==NULL) && p_LmIsConstant(p, r);
1976 }
static BOOLEAN p_LmIsConstant(const poly p, const ring r)
Definition: p_polys.h:983

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

1966 {
1967  if (p == NULL) return TRUE;
1968  return (pNext(p)==NULL) && p_LmIsConstantComp(p, r);
1969 }
static BOOLEAN p_LmIsConstantComp(const poly p, const ring r)
Definition: p_polys.h:966

◆ p_IsConstantPoly()

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

Definition at line 1986 of file p_polys.h.

1987 {
1988  p_Test(p, r);
1989  poly pp=p;
1990  while(pp!=NULL)
1991  {
1992  if (! p_LmIsConstantComp(pp, r))
1993  return FALSE;
1994  pIter(pp);
1995  }
1996  return TRUE;
1997 }

◆ p_ISet()

poly p_ISet ( long  i,
const ring  r 
)

returns the poly representing the integer i

Definition at line 1292 of file p_polys.cc.

1293 {
1294  poly rc = NULL;
1295  if (i!=0)
1296  {
1297  rc = p_Init(r);
1298  pSetCoeff0(rc,n_Init(i,r->cf));
1299  if (n_IsZero(pGetCoeff(rc),r->cf))
1300  p_LmDelete(&rc,r);
1301  }
1302  return rc;
1303 }

◆ p_IsHomogeneous()

BOOLEAN p_IsHomogeneous ( poly  p,
const ring  r 
)

Definition at line 3376 of file p_polys.cc.

3377 {
3378  poly qp=p;
3379  int o;
3380 
3381  if ((p == NULL) || (pNext(p) == NULL)) return TRUE;
3382  pFDegProc d;
3383  if (r->pLexOrder && (r->order[0]==ringorder_lp))
3384  d=p_Totaldegree;
3385  else
3386  d=r->pFDeg;
3387  o = d(p,r);
3388  do
3389  {
3390  if (d(qp,r) != o) return FALSE;
3391  pIter(qp);
3392  }
3393  while (qp != NULL);
3394  return TRUE;
3395 }

◆ p_IsOne()

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

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

Definition at line 1979 of file p_polys.h.

1980 {
1981  if (p == NULL) return FALSE; /* TODO check if 0 == 1 */
1982  p_Test(p, R);
1983  return (p_IsConstant(p, R) && n_IsOne(p_GetCoeff(p, R), R->cf));
1984 }

◆ p_IsPurePower()

int p_IsPurePower ( const poly  p,
const ring  r 
)

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

Definition at line 1221 of file p_polys.cc.

1222 {
1223  int i,k=0;
1224 
1225  for (i=r->N;i;i--)
1226  {
1227  if (p_GetExp(p,i, r)!=0)
1228  {
1229  if(k!=0) return 0;
1230  k=i;
1231  }
1232  }
1233  return k;
1234 }

◆ p_IsUnit()

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

Definition at line 1999 of file p_polys.h.

2000 {
2001  if (p == NULL) return FALSE;
2002  if (rField_is_Ring(r))
2003  return (p_LmIsConstant(p, r) && n_IsUnit(pGetCoeff(p),r->cf));
2004  return p_LmIsConstant(p, r);
2005 }
static FORCE_INLINE BOOLEAN n_IsUnit(number n, const coeffs r)
TRUE iff n has a multiplicative inverse in the given coeff field/ring r.
Definition: coeffs.h:516

◆ p_IsUnivariate()

int p_IsUnivariate ( poly  p,
const ring  r 
)

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

Definition at line 1242 of file p_polys.cc.

1243 {
1244  int i,k=-1;
1245 
1246  while (p!=NULL)
1247  {
1248  for (i=r->N;i;i--)
1249  {
1250  if (p_GetExp(p,i, r)!=0)
1251  {
1252  if((k!=-1)&&(k!=i)) return 0;
1253  k=i;
1254  }
1255  }
1256  pIter(p);
1257  }
1258  return k;
1259 }

◆ p_Jet()

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

Definition at line 4412 of file p_polys.cc.

4413 {
4414  while((p!=NULL) && (p_Totaldegree(p,R)>m)) p_LmDelete(&p,R);
4415  if (p==NULL) return NULL;
4416  poly r=p;
4417  while (pNext(p)!=NULL)
4418  {
4419  if (p_Totaldegree(pNext(p),R)>m)
4420  {
4421  p_LmDelete(&pNext(p),R);
4422  }
4423  else
4424  pIter(p);
4425  }
4426  return r;
4427 }

◆ p_JetW()

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

Definition at line 4456 of file p_polys.cc.

4457 {
4458  while((p!=NULL) && (totaldegreeWecart_IV(p,R,w)>m)) p_LmDelete(&p,R);
4459  if (p==NULL) return NULL;
4460  poly r=p;
4461  while (pNext(p)!=NULL)
4462  {
4463  if (totaldegreeWecart_IV(pNext(p),R,w)>m)
4464  {
4465  p_LmDelete(&pNext(p),R);
4466  }
4467  else
4468  pIter(p);
4469  }
4470  return r;
4471 }

◆ p_Last()

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

Definition at line 4647 of file p_polys.cc.

4648 {
4649  if (p == NULL)
4650  {
4651  l = 0;
4652  return NULL;
4653  }
4654  l = 1;
4655  poly a = p;
4656  if (! rIsSyzIndexRing(r))
4657  {
4658  poly next = pNext(a);
4659  while (next!=NULL)
4660  {
4661  a = next;
4662  next = pNext(a);
4663  l++;
4664  }
4665  }
4666  else
4667  {
4668  int curr_limit = rGetCurrSyzLimit(r);
4669  poly pp = a;
4670  while ((a=pNext(a))!=NULL)
4671  {
4672  if (__p_GetComp(a,r)<=curr_limit/*syzComp*/)
4673  l++;
4674  else break;
4675  pp = a;
4676  }
4677  a=pp;
4678  }
4679  return a;
4680 }
ListNode * next
Definition: janet.h:31
static int rGetCurrSyzLimit(const ring r)
Definition: ring.h:728
static BOOLEAN rIsSyzIndexRing(const ring r)
Definition: ring.h:725

◆ p_Lcm() [1/2]

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

Definition at line 1651 of file p_polys.cc.

1652 {
1653  poly m=p_Init(r);
1654  p_Lcm(a, b, m, r);
1655  p_Setm(m,r);
1656  return(m);
1657 }
void p_Lcm(const poly a, const poly b, poly m, const ring r)
Definition: p_polys.cc:1642

◆ p_Lcm() [2/2]

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

Definition at line 1642 of file p_polys.cc.

1643 {
1644  for (int i=r->N; i; --i)
1645  p_SetExp(m,i, si_max( p_GetExp(a,i,r), p_GetExp(b,i,r)),r);
1646 
1647  p_SetComp(m, si_max(p_GetComp(a,r), p_GetComp(b,r)),r);
1648  /* Don't do a pSetm here, otherwise hres/lres chockes */
1649 }
static int si_max(const int a, const int b)
Definition: auxiliary.h:124
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition: p_polys.h:247

◆ p_LcmRat()

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

Definition at line 1664 of file p_polys.cc.

1665 {
1666  poly m = // p_One( r);
1667  p_Init(r);
1668 
1669 // const int (currRing->N) = r->N;
1670 
1671  // for (int i = (currRing->N); i>=r->real_var_start; i--)
1672  for (int i = r->real_var_end; i>=r->real_var_start; i--)
1673  {
1674  const int lExpA = p_GetExp (a, i, r);
1675  const int lExpB = p_GetExp (b, i, r);
1676 
1677  p_SetExp (m, i, si_max(lExpA, lExpB), r);
1678  }
1679 
1680  p_SetComp (m, lCompM, r);
1681  p_Setm(m,r);
1682  n_New(&(p_GetCoeff(m, r)), r);
1683 
1684  return(m);
1685 };
#define n_New(n, r)
Definition: coeffs.h:441

◆ p_LDeg()

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

Definition at line 381 of file p_polys.h.

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

◆ p_LmCheckIsFromRing()

BOOLEAN p_LmCheckIsFromRing ( poly  p,
ring  r 
)

Definition at line 69 of file pDebug.cc.

70 {
71  if (p != NULL)
72  {
73  #if (OM_TRACK > 0) && defined(OM_TRACK_CUSTOM)
74  void* custom = omGetCustomOfAddr(p);
75  if (custom != NULL)
76  {
77  pPolyAssumeReturnMsg(custom == r ||
78  // be more sloppy for qrings
79  (r->qideal != NULL &&
80  omIsBinPageAddr(p) &&
81  omSizeWOfAddr(p)==omSizeWOfBin(r->PolyBin)) ||
82  rSamePolyRep((ring) custom, r),
83  "monomial not from specified ring",p,r);
84  return TRUE;
85  }
86  else
87  #endif
88  #ifndef X_OMALLOC
89  {
92  return TRUE;
93  }
94  return FALSE;
95  #endif
96  }
97  return TRUE;
98 }
#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:262

◆ p_LmCheckPolyRing()

BOOLEAN p_LmCheckPolyRing ( poly  p,
ring  r 
)

Definition at line 118 of file pDebug.cc.

119 {
120  #ifndef X_OMALLOC
121  pAssumeReturn(r != NULL && r->PolyBin != NULL);
122  #endif
123  pAssumeReturn(p != NULL);
124  return p_LmCheckIsFromRing(p, r);
125 }

◆ p_LmCmp()

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

Definition at line 1540 of file p_polys.h.

1541 {
1542  p_LmCheckPolyRing1(p, r);
1543  p_LmCheckPolyRing1(q, r);
1544 
1545  const unsigned long* _s1 = ((unsigned long*) p->exp);
1546  const unsigned long* _s2 = ((unsigned long*) q->exp);
1547  REGISTER unsigned long _v1;
1548  REGISTER unsigned long _v2;
1549  const unsigned long _l = r->CmpL_Size;
1550 
1551  REGISTER unsigned long _i=0;
1552 
1553  LengthGeneral_OrdGeneral_LoopTop:
1554  _v1 = _s1[_i];
1555  _v2 = _s2[_i];
1556  if (_v1 == _v2)
1557  {
1558  _i++;
1559  if (_i == _l) return 0;
1560  goto LengthGeneral_OrdGeneral_LoopTop;
1561  }
1562  const long* _ordsgn = (long*) r->ordsgn;
1563 #if 1 /* two variants*/
1564  if (_v1 > _v2)
1565  {
1566  return _ordsgn[_i];
1567  }
1568  return -(_ordsgn[_i]);
1569 #else
1570  if (_v1 > _v2)
1571  {
1572  if (_ordsgn[_i] == 1) return 1;
1573  return -1;
1574  }
1575  if (_ordsgn[_i] == 1) return -1;
1576  return 1;
1577 #endif
1578 }
if(yy_init)
Definition: libparse.cc:1420
#define REGISTER
Definition: omalloc.h:27

◆ p_LmDelete() [1/2]

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

Definition at line 717 of file p_polys.h.

718 {
719  p_LmCheckPolyRing2(*p, r);
720  poly h = *p;
721  *p = pNext(h);
722  n_Delete(&pGetCoeff(h), r->cf);
723  omFreeBinAddr(h);
724 }
#define omFreeBinAddr(addr)
Definition: omAllocDecl.h:258

◆ p_LmDelete() [2/2]

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

Definition at line 711 of file p_polys.h.

712 {
713  p_LmCheckPolyRing2(p, r);
714  n_Delete(&pGetCoeff(p), r->cf);
715  omFreeBinAddr(p);
716 }

◆ p_LmDeleteAndNext()

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

Definition at line 725 of file p_polys.h.

726 {
727  p_LmCheckPolyRing2(p, r);
728  poly pnext = pNext(p);
729  n_Delete(&pGetCoeff(p), r->cf);
730  omFreeBinAddr(p);
731  return pnext;
732 }

◆ p_LmDeleteAndNextRat()

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

Definition at line 1687 of file p_polys.cc.

1688 {
1689  /* modifies p*/
1690  // Print("start: "); Print(" "); p_wrp(*p,r);
1691  p_LmCheckPolyRing2(*p, r);
1692  poly q = p_Head(*p,r);
1693  const long cmp = p_GetComp(*p, r);
1694  while ( ( (*p)!=NULL ) && ( p_Comp_k_n(*p, q, ishift+1, r) ) && (p_GetComp(*p, r) == cmp) )
1695  {
1696  p_LmDelete(p,r);
1697  // Print("while: ");p_wrp(*p,r);Print(" ");
1698  }
1699  // p_wrp(*p,r);Print(" ");
1700  // PrintS("end\n");
1701  p_LmDelete(&q,r);
1702 }

◆ p_LmDivisibleBy() [1/2]

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

Definition at line 1890 of file p_polys.h.

1891 {
1892  p_LmCheckPolyRing(a, r_a);
1893  p_LmCheckPolyRing(b, r_b);
1894  return _p_LmDivisibleBy(a, r_a, b, r_b);
1895 }

◆ p_LmDivisibleBy() [2/2]

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

Definition at line 1863 of file p_polys.h.

1864 {
1865  p_LmCheckPolyRing1(b, r);
1866  pIfThen1(a != NULL, p_LmCheckPolyRing1(b, r));
1867  if (p_GetComp(a, r) == 0 || p_GetComp(a,r) == p_GetComp(b,r))
1868  return _p_LmDivisibleByNoComp(a, b, r);
1869  return FALSE;
1870 }

◆ p_LmDivisibleByNoComp() [1/2]

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

Definition at line 1856 of file p_polys.h.

1857 {
1858  p_LmCheckPolyRing1(a, ra);
1859  p_LmCheckPolyRing1(b, rb);
1860  return _p_LmDivisibleByNoComp(a, ra, b, rb);
1861 }

◆ p_LmDivisibleByNoComp() [2/2]

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

Definition at line 1849 of file p_polys.h.

1850 {
1851  p_LmCheckPolyRing1(a, r);
1852  p_LmCheckPolyRing1(b, r);
1853  return _p_LmDivisibleByNoComp(a, b, r);
1854 }

◆ p_LmDivisibleByPart()

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

Definition at line 1828 of file p_polys.h.

1829 {
1830  p_LmCheckPolyRing1(b, r);
1831  pIfThen1(a != NULL, p_LmCheckPolyRing1(b, r));
1832  if (p_GetComp(a, r) == 0 || p_GetComp(a,r) == p_GetComp(b,r))
1833  return _p_LmDivisibleByNoCompPart(a, r, b, r,start, end);
1834  return FALSE;
1835 }

◆ p_LmExpVectorAddIsOk()

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

Definition at line 2007 of file p_polys.h.

2009 {
2010  p_LmCheckPolyRing(p1, r);
2011  p_LmCheckPolyRing(p2, r);
2012  unsigned long l1, l2, divmask = r->divmask;
2013  int i;
2014 
2015  for (i=0; i<r->VarL_Size; i++)
2016  {
2017  l1 = p1->exp[r->VarL_Offset[i]];
2018  l2 = p2->exp[r->VarL_Offset[i]];
2019  // do the divisiblity trick
2020  if ( (l1 > ULONG_MAX - l2) ||
2021  (((l1 & divmask) ^ (l2 & divmask)) != ((l1 + l2) & divmask)))
2022  return FALSE;
2023  }
2024  return TRUE;
2025 }

◆ p_LmFree() [1/2]

static void p_LmFree ( poly *  p,
ring   
)
inlinestatic

Definition at line 692 of file p_polys.h.

694 {
695  p_LmCheckPolyRing2(*p, r);
696  poly h = *p;
697  *p = pNext(h);
698  omFreeBinAddr(h);
699 }

◆ p_LmFree() [2/2]

static void p_LmFree ( poly  p,
ring   
)
inlinestatic

Definition at line 683 of file p_polys.h.

685 {
686  p_LmCheckPolyRing2(p, r);
687  omFreeBinAddr(p);
688 }

◆ p_LmFreeAndNext()

static poly p_LmFreeAndNext ( poly  p,
ring   
)
inlinestatic

Definition at line 703 of file p_polys.h.

705 {
706  p_LmCheckPolyRing2(p, r);
707  poly pnext = pNext(p);
708  omFreeBinAddr(p);
709  return pnext;
710 }

◆ p_LmInit() [1/3]

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

Definition at line 1295 of file p_polys.h.

1296 {
1297  p_LmCheckPolyRing1(p, r);
1298  poly np;
1299  omTypeAllocBin(poly, np, r->PolyBin);
1300  p_SetRingOfLm(np, r);
1301  memcpy(np->exp, p->exp, r->ExpL_Size*sizeof(long));
1302  pNext(np) = NULL;
1303  pSetCoeff0(np, NULL);
1304  return np;
1305 }

◆ p_LmInit() [2/3]

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

Definition at line 1323 of file p_polys.h.

1324 {
1325  pAssume1(d_r != NULL);
1326  return p_LmInit(s_p, s_r, d_r, d_r->PolyBin);
1327 }

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

1307 {
1308  p_LmCheckPolyRing1(s_p, s_r);
1309  p_CheckRing(d_r);
1310  pAssume1(d_r->N <= s_r->N);
1311  poly d_p = p_Init(d_r, d_bin);
1312  for (unsigned i=d_r->N; i!=0; i--)
1313  {
1314  p_SetExp(d_p, i, p_GetExp(s_p, i,s_r), d_r);
1315  }
1316  if (rRing_has_Comp(d_r))
1317  {
1318  p_SetComp(d_p, p_GetComp(s_p,s_r), d_r);
1319  }
1320  p_Setm(d_p, d_r);
1321  return d_p;
1322 }
BOOLEAN p_CheckRing(ring r)
Definition: pDebug.cc:126

◆ p_LmIsConstant()

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

Definition at line 983 of file p_polys.h.

984 {
985  if (p_LmIsConstantComp(p, r))
986  return (p_GetComp(p, r) == 0);
987  return FALSE;
988 }

◆ p_LmIsConstantComp()

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

Definition at line 966 of file p_polys.h.

967 {
968  //p_LmCheckPolyRing(p, r);
969  int i = r->VarL_Size - 1;
970 
971  do
972  {
973  if (p->exp[r->VarL_Offset[i]] != 0)
974  return FALSE;
975  i--;
976  }
977  while (i >= 0);
978  return TRUE;
979 }

◆ p_LmShallowCopyDelete()

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

Definition at line 1353 of file p_polys.h.

1354 {
1355  p_LmCheckPolyRing1(p, r);
1356  pAssume1(omSizeWOfBin(bin) == omSizeWOfBin(r->PolyBin));
1357  poly new_p = p_New(r);
1358  memcpy(new_p->exp, p->exp, r->ExpL_Size*sizeof(long));
1359  pSetCoeff0(new_p, pGetCoeff(p));
1360  pNext(new_p) = pNext(p);
1361  omFreeBinAddr(p);
1362  return new_p;
1363 }
static poly p_New(const ring, omBin bin)
Definition: p_polys.h:664

◆ p_LmShortDivisibleBy() [1/2]

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

Definition at line 1937 of file p_polys.h.

1939 {
1940  p_LmCheckPolyRing1(a, r_a);
1941  p_LmCheckPolyRing1(b, r_b);
1942 #ifndef PDIV_DEBUG
1943  _pPolyAssume2(p_GetShortExpVector(a, r_a) == sev_a, a, r_a);
1944  _pPolyAssume2(p_GetShortExpVector(b, r_b) == ~ not_sev_b, b, r_b);
1945 
1946  if (sev_a & not_sev_b)
1947  {
1948  pAssume1(_p_LmDivisibleByNoComp(a, r_a, b, r_b) == FALSE);
1949  return FALSE;
1950  }
1951  return _p_LmDivisibleBy(a, r_a, b, r_b);
1952 #else
1953  return pDebugLmShortDivisibleBy(a, sev_a, r_a, b, not_sev_b, r_b);
1954 #endif
1955 }
#define _pPolyAssume2(cond, p, r)
Definition: monomials.h:195
BOOLEAN pDebugLmShortDivisibleBy(poly p1, unsigned long sev_1, ring r_1, poly p2, unsigned long not_sev_2, ring r_2)
Definition: pDebug.cc:364
unsigned long p_GetShortExpVector(const poly a, const ring r)
Definition: p_polys.cc:4807

◆ p_LmShortDivisibleBy() [2/2]

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

Definition at line 1897 of file p_polys.h.

1899 {
1900  p_LmCheckPolyRing1(a, r);
1901  p_LmCheckPolyRing1(b, r);
1902 #ifndef PDIV_DEBUG
1903  _pPolyAssume2(p_GetShortExpVector(a, r) == sev_a, a, r);
1904  _pPolyAssume2(p_GetShortExpVector(b, r) == ~ not_sev_b, b, r);
1905 
1906  if (sev_a & not_sev_b)
1907  {
1909  return FALSE;
1910  }
1911  return p_LmDivisibleBy(a, b, r);
1912 #else
1913  return pDebugLmShortDivisibleBy(a, sev_a, r, b, not_sev_b, r);
1914 #endif
1915 }
static BOOLEAN p_LmDivisibleByNoComp(poly a, poly b, const ring r)
Definition: p_polys.h:1849
static BOOLEAN p_LmDivisibleBy(poly a, poly b, const ring r)
Definition: p_polys.h:1863

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

1919 {
1920  p_LmCheckPolyRing1(a, r);
1921  p_LmCheckPolyRing1(b, r);
1922 #ifndef PDIV_DEBUG
1923  _pPolyAssume2(p_GetShortExpVector(a, r) == sev_a, a, r);
1924  _pPolyAssume2(p_GetShortExpVector(b, r) == ~ not_sev_b, b, r);
1925 
1926  if (sev_a & not_sev_b)
1927  {
1929  return FALSE;
1930  }
1931  return p_LmDivisibleByNoComp(a, b, r);
1932 #else
1933  return pDebugLmShortDivisibleByNoComp(a, sev_a, r, b, not_sev_b, r);
1934 #endif
1935 }
BOOLEAN pDebugLmShortDivisibleByNoComp(poly p1, unsigned long sev_1, ring r_1, poly p2, unsigned long not_sev_2, ring r_2)
Definition: pDebug.cc:387

◆ p_LowVar()

int p_LowVar ( poly  p,
const ring  r 
)

the minimal index of used variables - 1

Definition at line 4706 of file p_polys.cc.

4707 {
4708  int k,l,lex;
4709 
4710  if (p == NULL) return -1;
4711 
4712  k = 32000;/*a very large dummy value*/
4713  while (p != NULL)
4714  {
4715  l = 1;
4716  lex = p_GetExp(p,l,r);
4717  while ((l < (rVar(r))) && (lex == 0))
4718  {
4719  l++;
4720  lex = p_GetExp(p,l,r);
4721  }
4722  l--;
4723  if (l < k) k = l;
4724  pIter(p);
4725  }
4726  return k;
4727 }

◆ p_LtCmp()

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

Definition at line 1581 of file p_polys.h.

1582 {
1583  int res = p_LmCmp(p,q,r);
1584  if(res == 0)
1585  {
1586  if(p_GetCoeff(p,r) == NULL || p_GetCoeff(q,r) == NULL)
1587  return res;
1588  number pc = n_Copy(p_GetCoeff(p,r),r->cf);
1589  number qc = n_Copy(p_GetCoeff(q,r),r->cf);
1590  if(!n_GreaterZero(pc,r->cf))
1591  pc = n_InpNeg(pc,r->cf);
1592  if(!n_GreaterZero(qc,r->cf))
1593  qc = n_InpNeg(qc,r->cf);
1594  if(n_Greater(pc,qc,r->cf))
1595  res = 1;
1596  else if(n_Greater(qc,pc,r->cf))
1597  res = -1;
1598  else if(n_Equal(pc,qc,r->cf))
1599  res = 0;
1600  n_Delete(&pc,r->cf);
1601  n_Delete(&qc,r->cf);
1602  }
1603  return res;
1604 }
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:512

◆ p_LtCmpNoAbs()

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

Definition at line 1607 of file p_polys.h.

1608 {
1609  int res = p_LmCmp(p,q,r);
1610  if(res == 0)
1611  {
1612  if(p_GetCoeff(p,r) == NULL || p_GetCoeff(q,r) == NULL)
1613  return res;
1614  number pc = p_GetCoeff(p,r);
1615  number qc = p_GetCoeff(q,r);
1616  if(n_Greater(pc,qc,r->cf))
1617  res = 1;
1618  if(n_Greater(qc,pc,r->cf))
1619  res = -1;
1620  if(n_Equal(pc,qc,r->cf))
1621  res = 0;
1622  }
1623  return res;
1624 }

◆ p_LtCmpOrdSgnDiffM()

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

Definition at line 1629 of file p_polys.h.

1630 {
1631  if(r->OrdSgn == 1)
1632  {
1633  return(p_LtCmp(p,q,r) == 1);
1634  }
1635  else
1636  {
1637  return(p_LmCmp(p,q,r) == -1);
1638  }
1639 }
static int p_LtCmp(poly p, poly q, const ring r)
Definition: p_polys.h:1581

◆ p_LtCmpOrdSgnDiffP()

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

Definition at line 1645 of file p_polys.h.

1646 {
1647  if(r->OrdSgn == 1)
1648  {
1649  return(p_LmCmp(p,q,r) == -1);
1650  }
1651  else
1652  {
1653  return(p_LtCmp(p,q,r) != -1);
1654  }
1655 
1656 }

◆ p_LtCmpOrdSgnEqM()

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

Definition at line 1662 of file p_polys.h.

1663 {
1664  return(p_LtCmp(p,q,r) == -r->OrdSgn);
1665 }

◆ p_LtCmpOrdSgnEqP()

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

Definition at line 1671 of file p_polys.h.

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

◆ p_MaxComp() [1/2]

static long p_MaxComp ( poly  p,
ring  lmRing 
)
inlinestatic

Definition at line 311 of file p_polys.h.

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

◆ p_MaxComp() [2/2]

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

Definition at line 292 of file p_polys.h.

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

◆ p_MaxExpPerVar()

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

max exponent of variable x_i in p

Definition at line 5017 of file p_polys.cc.

5018 {
5019  int m=0;
5020  while(p!=NULL)
5021  {
5022  int mm=p_GetExp(p,i,r);
5023  if (mm>m) m=mm;
5024  pIter(p);
5025  }
5026  return m;
5027 }

◆ p_MDivide()

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

Definition at line 1479 of file p_polys.cc.

1480 {
1481  assume((p_GetComp(a,r)==p_GetComp(b,r)) || (p_GetComp(b,r)==0));
1482  int i;
1483  poly result = p_Init(r);
1484 
1485  for(i=(int)r->N; i; i--)
1486  p_SetExp(result,i, p_GetExp(a,i,r)- p_GetExp(b,i,r),r);
1487  p_SetComp(result, p_GetComp(a,r) - p_GetComp(b,r),r);
1488  p_Setm(result,r);
1489  return result;
1490 }

◆ p_MemAdd_NegWeightAdjust()

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

Definition at line 1252 of file p_polys.h.

1253 {
1254  if (r->NegWeightL_Offset != NULL)
1255  {
1256  for (int i=r->NegWeightL_Size-1; i>=0; i--)
1257  {
1258  p->exp[r->NegWeightL_Offset[i]] -= POLY_NEGWEIGHT_OFFSET;
1259  }
1260  }
1261 }

◆ p_MemSub_NegWeightAdjust()

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

Definition at line 1262 of file p_polys.h.

1263 {
1264  if (r->NegWeightL_Offset != NULL)
1265  {
1266  for (int i=r->NegWeightL_Size-1; i>=0; i--)
1267  {
1268  p->exp[r->NegWeightL_Offset[i]] += POLY_NEGWEIGHT_OFFSET;
1269  }
1270  }
1271 }

◆ p_Merge_q()

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

Definition at line 1172 of file p_polys.h.

1173 {
1174  assume( (p != q) || (p == NULL && q == NULL) );
1175  return r->p_Procs->p_Merge_q(p, q, r);
1176 }

◆ p_MinComp() [1/2]

static long p_MinComp ( poly  p,
ring  lmRing 
)
inlinestatic

Definition at line 332 of file p_polys.h.

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

◆ p_MinComp() [2/2]

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

Definition at line 313 of file p_polys.h.

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

◆ p_MinDeg()

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

Definition at line 4474 of file p_polys.cc.

4475 {
4476  if(p==NULL)
4477  return -1;
4478  int d=-1;
4479  while(p!=NULL)
4480  {
4481  int d0=0;
4482  for(int j=0;j<rVar(R);j++)
4483  if(w==NULL||j>=w->length())
4484  d0+=p_GetExp(p,j+1,R);
4485  else
4486  d0+=(*w)[j]*p_GetExp(p,j+1,R);
4487  if(d0<d||d==-1)
4488  d=d0;
4489  pIter(p);
4490  }
4491  return d;
4492 }

◆ p_mInit()

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

Definition at line 1437 of file p_polys.cc.

1438 {
1439  poly p;
1440  const char *s=p_Read(st,p,r);
1441  if (*s!='\0')
1442  {
1443  if ((s!=st)&&isdigit(st[0]))
1444  {
1446  }
1447  ok=FALSE;
1448  p_Delete(&p,r);
1449  return NULL;
1450  }
1451  p_Test(p,r);
1452  ok=!errorreported;
1453  return p;
1454 }
VAR short errorreported
Definition: feFopen.cc:23
const char * p_Read(const char *st, poly &rc, const ring r)
Definition: p_polys.cc:1365

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

1042 {
1043  int shorter;
1044 
1045  return r->p_Procs->p_Minus_mm_Mult_qq(p, m, q, shorter, NULL, r);
1046 }

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

1032 {
1033  int shorter;
1034  const poly res = r->p_Procs->p_Minus_mm_Mult_qq(p, m, q, shorter, spNoether, r);
1035  lp += lq - shorter;
1036 // assume( lp == pLength(res) );
1037  return res;
1038 }

◆ p_mm_Mult()

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

Definition at line 1021 of file p_polys.h.

1022 {
1023  if (p==NULL) return NULL;
1024  if (p_LmIsConstant(m, r))
1025  return __p_Mult_nn(p, pGetCoeff(m), r);
1026  else
1027  return r->p_Procs->p_mm_Mult(p, m, r);
1028 }

◆ p_Mult_mm()

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

Definition at line 1011 of file p_polys.h.

1012 {
1013  if (p==NULL) return NULL;
1014  if (p_LmIsConstant(m, r))
1015  return __p_Mult_nn(p, pGetCoeff(m), r);
1016  else
1017  return r->p_Procs->p_Mult_mm(p, m, r);
1018 }

◆ p_Mult_nn() [1/2]

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

Definition at line 933 of file p_polys.h.

935 {
936  assume(p!=NULL);
937 #ifndef PDEBUG
938  if (lmRing == tailRing)
939  return p_Mult_nn(p, n, tailRing);
940 #endif
941  poly pnext = pNext(p);
942  pNext(p) = NULL;
943  p = lmRing->p_Procs->p_Mult_nn(p, n, lmRing);
944  if (pnext!=NULL)
945  {
946  pNext(p) = tailRing->p_Procs->p_Mult_nn(pnext, n, tailRing);
947  }
948  return p;
949 }
static poly p_Mult_nn(poly p, number n, const ring r)
Definition: p_polys.h:918

◆ p_Mult_nn() [2/2]

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

Definition at line 918 of file p_polys.h.

919 {
920  if (p==NULL) return NULL;
921  if (n_IsOne(n, r->cf))
922  return p;
923  else if (n_IsZero(n, r->cf))
924  {
925  p_Delete(&p, r); // NOTE: without p_Delete - memory leak!
926  return NULL;
927  }
928  else
929  return r->p_Procs->p_Mult_nn(p, n, r);
930 }

◆ p_Mult_q()

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

Definition at line 1074 of file p_polys.h.

1075 {
1076  assume( (p != q) || (p == NULL && q == NULL) );
1077 
1078  if (p == NULL)
1079  {
1080  p_Delete(&q, r);
1081  return NULL;
1082  }
1083  if (q == NULL)
1084  {
1085  p_Delete(&p, r);
1086  return NULL;
1087  }
1088 
1089  if (pNext(p) == NULL)
1090  {
1091  q = r->p_Procs->p_mm_Mult(q, p, r);
1092  p_LmDelete(&p, r);
1093  return q;
1094  }
1095 
1096  if (pNext(q) == NULL)
1097  {
1098  p = r->p_Procs->p_Mult_mm(p, q, r);
1099  p_LmDelete(&q, r);
1100  return p;
1101  }
1102 #if defined(HAVE_PLURAL) || defined(HAVE_SHIFTBBA)
1103  if (rIsNCRing(r))
1104  return _nc_p_Mult_q(p, q, r);
1105  else
1106 #endif
1107  return _p_Mult_q(p, q, 0, r);
1108 }
poly _nc_p_Mult_q(poly p, poly q, const ring r)
general NC-multiplication with destruction
Definition: old.gring.cc:215
poly _p_Mult_q(poly p, poly q, const int copy, const ring r)
Returns: p * q, Destroys: if !copy then p, q Assumes: pLength(p) >= 2 pLength(q) >=2,...
Definition: p_Mult_q.cc:313

◆ p_MultExp()

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

Definition at line 621 of file p_polys.h.

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

◆ p_Neg()

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

Definition at line 1067 of file p_polys.h.

1068 {
1069  return r->p_Procs->p_Neg(p, r);
1070 }

◆ p_New() [1/2]

static poly p_New ( const  ring,
omBin  bin 
)
inlinestatic

Definition at line 664 of file p_polys.h.

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

◆ p_New() [2/2]

static poly p_New ( ring  r)
inlinestatic

Definition at line 675 of file p_polys.h.

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

◆ p_Norm()

void p_Norm ( poly  p1,
const ring  r 
)

Definition at line 3789 of file p_polys.cc.

3790 {
3791  if (rField_is_Ring(r))
3792  {
3793  if (!n_IsUnit(pGetCoeff(p1), r->cf)) return;
3794  // Werror("p_Norm not possible in the case of coefficient rings.");
3795  }
3796  else if (p1!=NULL)
3797  {
3798  if (pNext(p1)==NULL)
3799  {
3800  p_SetCoeff(p1,n_Init(1,r->cf),r);
3801  return;
3802  }
3803  poly h;
3804  if (!n_IsOne(pGetCoeff(p1),r->cf))
3805  {
3806  number k, c;
3807  n_Normalize(pGetCoeff(p1),r->cf);
3808  k = pGetCoeff(p1);
3809  c = n_Init(1,r->cf);
3810  pSetCoeff0(p1,c);
3811  h = pNext(p1);
3812  while (h!=NULL)
3813  {
3814  c=n_Div(pGetCoeff(h),k,r->cf);
3815  // no need to normalize: Z/p, R
3816  // normalize already in nDiv: Q_a, Z/p_a
3817  // remains: Q
3818  if (rField_is_Q(r) && (!n_IsOne(c,r->cf))) n_Normalize(c,r->cf);
3819  p_SetCoeff(h,c,r);
3820  pIter(h);
3821  }
3822  n_Delete(&k,r->cf);
3823  }
3824  else
3825  {
3826  //if (r->cf->cfNormalize != nDummy2) //TODO: OPTIMIZE
3827  {
3828  h = pNext(p1);
3829  while (h!=NULL)
3830  {
3831  n_Normalize(pGetCoeff(h),r->cf);
3832  pIter(h);
3833  }
3834  }
3835  }
3836  }
3837 }

◆ p_Normalize()

void p_Normalize ( poly  p,
const ring  r 
)

Definition at line 3842 of file p_polys.cc.

3843 {
3844  if (rField_has_simple_inverse(r)) return; /* Z/p, GF(p,n), R, long R/C */
3845  while (p!=NULL)
3846  {
3847  // no test befor n_Normalize: n_Normalize should fix problems
3848  n_Normalize(pGetCoeff(p),r->cf);
3849  pIter(p);
3850  }
3851 }
static BOOLEAN rField_has_simple_inverse(const ring r)
Definition: ring.h:553

◆ p_NSet()

poly p_NSet ( number  n,
const ring  r 
)

returns the poly representing the number n, destroys n

Definition at line 1460 of file p_polys.cc.

1461 {
1462  if (n_IsZero(n,r->cf))
1463  {
1464  n_Delete(&n, r->cf);
1465  return NULL;
1466  }
1467  else
1468  {
1469  poly rc = p_Init(r);
1470  pSetCoeff0(rc,n);
1471  return rc;
1472  }
1473 }

◆ p_One()

poly p_One ( const ring  r)

Definition at line 1308 of file p_polys.cc.

1309 {
1310  poly rc = p_Init(r);
1311  pSetCoeff0(rc,n_Init(1,r->cf));
1312  return rc;
1313 }

◆ p_OneComp()

BOOLEAN p_OneComp ( poly  p,
const ring  r 
)

return TRUE if all monoms have the same component

Definition at line 1203 of file p_polys.cc.

1204 {
1205  if(p!=NULL)
1206  {
1207  long i = p_GetComp(p, r);
1208  while (pNext(p)!=NULL)
1209  {
1210  pIter(p);
1211  if(i != p_GetComp(p, r)) return FALSE;
1212  }
1213  }
1214  return TRUE;
1215 }

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

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

◆ p_Plus_mm_Mult_qq() [1/2]

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

Definition at line 1165 of file p_polys.h.

1166 {
1167  int lp = 0, lq = 0;
1168  return p_Plus_mm_Mult_qq(p, m, q, lp, lq, r);
1169 }
static poly p_Plus_mm_Mult_qq(poly p, poly m, poly q, int &lp, int lq, const ring r)
Definition: p_polys.h:1143

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

1145 {
1146 #ifdef HAVE_PLURAL
1147  if (rIsPluralRing(r))
1148  return nc_p_Plus_mm_Mult_qq(p, m, q, lp, lq, r);
1149 #endif
1150 
1151 // this should be implemented more efficiently
1152  poly res;
1153  int shorter;
1154  number n_old = pGetCoeff(m);
1155  number n_neg = n_Copy(n_old, r->cf);
1156  n_neg = n_InpNeg(n_neg, r->cf);
1157  pSetCoeff0(m, n_neg);
1158  res = r->p_Procs->p_Minus_mm_Mult_qq(p, m, q, shorter, NULL, r);
1159  lp = (lp + lq) - shorter;
1160  pSetCoeff0(m, n_old);
1161  n_Delete(&n_neg, r->cf);
1162  return res;
1163 }
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:400

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

1858 {
1859  assume(divisor != NULL);
1860  if (p == NULL) return NULL;
1861 
1862  poly result = NULL;
1863  number divisorLC = p_GetCoeff(divisor, r);
1864  int divisorLE = p_GetExp(divisor, 1, r);
1865  while ((p != NULL) && (p_Deg(p, r) >= p_Deg(divisor, r)))
1866  {
1867  /* determine t = LT(p) / LT(divisor) */
1868  poly t = p_ISet(1, r);
1869  number c = n_Div(p_GetCoeff(p, r), divisorLC, r->cf);
1870  n_Normalize(c,r->cf);
1871  p_SetCoeff(t, c, r);
1872  int e = p_GetExp(p, 1, r) - divisorLE;
1873  p_SetExp(t, 1, e, r);
1874  p_Setm(t, r);
1875  if (needResult) result = p_Add_q(result, p_Copy(t, r), r);
1876  p = p_Add_q(p, p_Neg(p_Mult_q(t, p_Copy(divisor, r), r), r), r);
1877  }
1878  return result;
1879 }
long p_Deg(poly a, const ring r)
Definition: p_polys.cc:582

◆ p_Power()

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

Definition at line 2184 of file p_polys.cc.

2185 {
2186  poly rc=NULL;
2187 
2188  if (i==0)
2189  {
2190  p_Delete(&p,r);
2191  return p_One(r);
2192  }
2193 
2194  if(p!=NULL)
2195  {
2196  if ( (i > 0) && ((unsigned long ) i > (r->bitmask))
2197  #ifdef HAVE_SHIFTBBA
2198  && (!rIsLPRing(r))
2199  #endif
2200  )
2201  {
2202  Werror("exponent %d is too large, max. is %ld",i,r->bitmask);
2203  return NULL;
2204  }
2205  switch (i)
2206  {
2207 // cannot happen, see above
2208 // case 0:
2209 // {
2210 // rc=pOne();
2211 // pDelete(&p);
2212 // break;
2213 // }
2214  case 1:
2215  rc=p;
2216  break;
2217  case 2:
2218  rc=p_Mult_q(p_Copy(p,r),p,r);
2219  break;
2220  default:
2221  if (i < 0)
2222  {
2223  p_Delete(&p,r);
2224  return NULL;
2225  }
2226  else
2227  {
2228 #ifdef HAVE_PLURAL
2229  if (rIsNCRing(r)) /* in the NC case nothing helps :-( */
2230  {
2231  int j=i;
2232  rc = p_Copy(p,r);
2233  while (j>1)
2234  {
2235  rc = p_Mult_q(p_Copy(p,r),rc,r);
2236  j--;
2237  }
2238  p_Delete(&p,r);
2239  return rc;
2240  }
2241 #endif
2242  rc = pNext(p);
2243  if (rc == NULL)
2244  return p_MonPower(p,i,r);
2245  /* else: binom ?*/
2246  int char_p=rChar(r);
2247  if ((char_p>0) && (i>char_p)
2248  && ((rField_is_Zp(r,char_p)
2249  || (rField_is_Zp_a(r,char_p)))))
2250  {
2251  poly h=p_Pow_charp(p_Copy(p,r),char_p,r);
2252  int rest=i-char_p;
2253  while (rest>=char_p)
2254  {
2255  rest-=char_p;
2256  h=p_Mult_q(h,p_Pow_charp(p_Copy(p,r),char_p,r),r);
2257  }
2258  poly res=h;
2259  if (rest>0)
2260  res=p_Mult_q(p_Power(p_Copy(p,r),rest,r),h,r);
2261  p_Delete(&p,r);
2262  return res;
2263  }
2264  if ((pNext(rc) != NULL)
2265  || rField_is_Ring(r)
2266  )
2267  return p_Pow(p,i,r);
2268  if ((char_p==0) || (i<=char_p))
2269  return p_TwoMonPower(p,i,r);
2270  return p_Pow(p,i,r);
2271  }
2272  /*end default:*/
2273  }
2274  }
2275  return rc;
2276 }
poly p_Power(poly p, int i, const ring r)
Definition: p_polys.cc:2184
static poly p_TwoMonPower(poly p, int exp, const ring r)
Definition: p_polys.cc:2093
static poly p_Pow_charp(poly p, int i, const ring r)
Definition: p_polys.cc:2172
static poly p_MonPower(poly p, int exp, const ring r)
Definition: p_polys.cc:1987
static poly p_Pow(poly p, int i, const ring r)
Definition: p_polys.cc:2158
void Werror(const char *fmt,...)
Definition: reporter.cc:189
int rChar(ring r)
Definition: ring.cc:714
static BOOLEAN rIsLPRing(const ring r)
Definition: ring.h:411

◆ p_ProjectiveUnique()

void p_ProjectiveUnique ( poly  p,
const ring  r 
)

Definition at line 3198 of file p_polys.cc.

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

◆ p_Read()

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

Definition at line 1365 of file p_polys.cc.

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

4525 {
4526  int *ww=iv2array(w,R);
4527  if(p!=NULL)
4528  {
4529  if(u==NULL)
4530  p=p_JetW(p,n,ww,R);
4531  else
4532  p=p_JetW(p_Mult_q(p,p_Invers(n-p_MinDeg(p,w,R),u,w,R),R),n,ww,R);
4533  }
4534  omFreeSize((ADDRESS)ww,(rVar(R)+1)*sizeof(int));
4535  return p;
4536 }
static poly p_Invers(int n, poly u, intvec *w, const ring R)
Definition: p_polys.cc:4495
int p_MinDeg(poly p, intvec *w, const ring R)
Definition: p_polys.cc:4474
poly p_JetW(poly p, int m, int *w, const ring R)
Definition: p_polys.cc:4456
int * iv2array(intvec *iv, const ring R)
Definition: weight.cc:200

◆ p_SetCoeff()

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

Definition at line 412 of file p_polys.h.

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

◆ p_SetComp()

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

Definition at line 247 of file p_polys.h.

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

◆ p_SetCompP() [1/2]

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

Definition at line 281 of file p_polys.h.

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

◆ p_SetCompP() [2/2]

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

Definition at line 254 of file p_polys.h.

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

◆ p_SetExp() [1/3]

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

set v^th exponent for a monomial

Definition at line 582 of file p_polys.h.

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

◆ p_SetExp() [2/3]

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

Definition at line 562 of file p_polys.h.

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

◆ p_SetExp() [3/3]

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

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

See also
p_GetExp

Definition at line 488 of file p_polys.h.

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

◆ p_SetExpV()

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

Definition at line 1504 of file p_polys.h.

1505 {
1506  p_LmCheckPolyRing1(p, r);
1507  for (unsigned j = r->N; j!=0; j--)
1508  p_SetExp(p, j, ev[j], r);
1509 
1510  if(ev[0]!=0) p_SetComp(p, ev[0],r);
1511  p_Setm(p, r);
1512 }

◆ p_SetExpVL()

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

Definition at line 1513 of file p_polys.h.

1514 {
1515  p_LmCheckPolyRing1(p, r);
1516  for (unsigned j = r->N; j!=0; j--)
1517  p_SetExp(p, j, ev[j-1], r);
1518  p_SetComp(p, 0,r);
1519 
1520  p_Setm(p, r);
1521 }

◆ p_SetExpVLV()

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

Definition at line 1524 of file p_polys.h.

1525 {
1526  p_LmCheckPolyRing1(p, r);
1527  for (unsigned j = r->N; j!=0; j--)
1528  p_SetExp(p, j, ev[j-1], r);
1529  p_SetComp(p, comp,r);
1530 
1531  p_Setm(p, r);
1532 }
int comp(const CanonicalForm &A, const CanonicalForm &B)
compare polynomials

◆ p_Setm()

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

Definition at line 233 of file p_polys.h.

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

◆ p_SetModDeg()

void p_SetModDeg ( intvec w,
ring  r 
)

Definition at line 3743 of file p_polys.cc.

3744 {
3745  if (w!=NULL)
3746  {
3747  r->pModW = w;
3748  pOldFDeg = r->pFDeg;
3749  pOldLDeg = r->pLDeg;
3750  pOldLexOrder = r->pLexOrder;
3751  pSetDegProcs(r,pModDeg);
3752  r->pLexOrder = TRUE;
3753  }
3754  else
3755  {
3756  r->pModW = NULL;
3758  r->pLexOrder = pOldLexOrder;
3759  }
3760 }
STATIC_VAR pLDegProc pOldLDeg
Definition: p_polys.cc:3731
void pRestoreDegProcs(ring r, pFDegProc old_FDeg, pLDegProc old_lDeg)
Definition: p_polys.cc:3719
STATIC_VAR BOOLEAN pOldLexOrder
Definition: p_polys.cc:3732
STATIC_VAR pFDegProc pOldFDeg
Definition: p_polys.cc:3730
void pSetDegProcs(ring r, pFDegProc new_FDeg, pLDegProc new_lDeg)
Definition: p_polys.cc:3707
static long pModDeg(poly p, ring r)
Definition: p_polys.cc:3734

◆ p_ShallowCopyDelete()

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

Definition at line 888 of file p_polys.h.

889 {
890  p_LmCheckPolyRing2(p, r);
891  pAssume2(omSizeWOfBin(r->PolyBin) == omSizeWOfBin(bin));
892  return r->p_Procs->p_ShallowCopyDelete(p, r, bin);
893 }

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

4733 {
4734  poly qp1 = *p,qp2 = *p;/*working pointers*/
4735  int j = p_MaxComp(*p,r),k = p_MinComp(*p,r);
4736 
4737  if (j+i < 0) return ;
4738  BOOLEAN toPoly= ((j == -i) && (j == k));
4739  while (qp1 != NULL)
4740  {
4741  if (toPoly || (__p_GetComp(qp1,r)+i > 0))
4742  {
4743  p_AddComp(qp1,i,r);
4744  p_SetmComp(qp1,r);
4745  qp2 = qp1;
4746  pIter(qp1);
4747  }
4748  else
4749  {
4750  if (qp2 == *p)
4751  {
4752  pIter(*p);
4753  p_LmDelete(&qp2,r);
4754  qp2 = *p;
4755  qp1 = *p;
4756  }
4757  else
4758  {
4759  qp2->next = qp1->next;
4760  if (qp1!=NULL) p_LmDelete(&qp1,r);
4761  qp1 = qp2->next;
4762  }
4763  }
4764  }
4765 }
return
Definition: cfGcdAlgExt.cc:218
static unsigned long p_AddComp(poly p, unsigned long v, ring r)
Definition: p_polys.h:447

◆ p_SimpleContent()

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

Definition at line 2619 of file p_polys.cc.

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

◆ p_Size()

int p_Size ( poly  p,
const ring  r 
)

Definition at line 3310 of file p_polys.cc.

3311 {
3312  int count = 0;
3313  if (r->cf->has_simple_Alloc)
3314  return pLength(p);
3315  while ( p != NULL )
3316  {
3317  count+= n_Size( pGetCoeff( p ), r->cf );
3318  pIter( p );
3319  }
3320  return count;
3321 }
int status int void size_t count
Definition: si_signals.h:59

◆ p_SortAdd()

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

Definition at line 1179 of file p_polys.h.

1180 {
1181  if (revert) p = pReverse(p);
1182  return sBucketSortAdd(p, r);
1183 }
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 1189 of file p_polys.h.

1190 {
1191  if (revert) p = pReverse(p);
1192  return sBucketSortMerge(p, r);
1193 }
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 1315 of file p_polys.cc.

1316 {
1317  *h=pNext(p);
1318  pNext(p)=NULL;
1319 }

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

1201 {
1202  return p_String(p, p_ring, p_ring);
1203 }
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  }
230  p_Normalize(p,lmRing);
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  }
283  writemonLP(p,k,lmRing);
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  }
306  writemon(p,k,lmRing);
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 1204 of file p_polys.h.

1205 {
1206  p_String0(p, p_ring, p_ring);
1207 }
void p_String0(poly p, ring lmRing, ring tailRing)
print p according to ShortOut in lmRing & tailRing
Definition: polys0.cc:223

◆ p_String0Long()

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

print p in a long way

print p in a long way

Definition at line 203 of file polys0.cc.

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

◆ p_String0Short()

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

print p in a short way, if possible

print p in a short way, if possible

Definition at line 184 of file polys0.cc.

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

◆ p_Sub()

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

Definition at line 1977 of file p_polys.cc.

1978 {
1979  return p_Add_q(p1, p_Neg(p2,r),r);
1980 }

◆ p_SubComp()

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

Definition at line 453 of file p_polys.h.

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

◆ p_SubExp()

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

Definition at line 613 of file p_polys.h.

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

◆ p_Subst()

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

Definition at line 3984 of file p_polys.cc.

3985 {
3986 #ifdef HAVE_SHIFTBBA
3987  // also don't even use p_Subst0 for Letterplace
3988  if (rIsLPRing(r))
3989  {
3990  poly subst = p_LPSubst(p, n, e, r);
3991  p_Delete(&p, r);
3992  return subst;
3993  }
3994 #endif
3995 
3996  if (e == NULL) return p_Subst0(p, n,r);
3997 
3998  if (p_IsConstant(e,r))
3999  {
4000  if (n_IsOne(pGetCoeff(e),r->cf)) return p_Subst1(p,n,r);
4001  else return p_Subst2(p, n, pGetCoeff(e),r);
4002  }
4003 
4004 #ifdef HAVE_PLURAL
4005  if (rIsPluralRing(r))
4006  {
4007  return nc_pSubst(p,n,e,r);
4008  }
4009 #endif
4010 
4011  int exponent,i;
4012  poly h, res, m;
4013  int *me,*ee;
4014  number nu,nu1;
4015 
4016  me=(int *)omAlloc((rVar(r)+1)*sizeof(int));
4017  ee=(int *)omAlloc((rVar(r)+1)*sizeof(int));
4018  if (e!=NULL) p_GetExpV(e,ee,r);
4019  res=NULL;
4020  h=p;
4021  while (h!=NULL)
4022  {
4023  if ((e!=NULL) || (p_GetExp(h,n,r)==0))
4024  {
4025  m=p_Head(h,r);
4026  p_GetExpV(m,me,r);
4027  exponent=me[n];
4028  me[n]=0;
4029  for(i=rVar(r);i>0;i--)
4030  me[i]+=exponent*ee[i];
4031  p_SetExpV(m,me,r);
4032  if (e!=NULL)
4033  {
4034  n_Power(pGetCoeff(e),exponent,&nu,r->cf);
4035  nu1=n_Mult(pGetCoeff(m),nu,r->cf);
4036  n_Delete(&nu,r->cf);
4037  p_SetCoeff(m,nu1,r);
4038  }
4039  res=p_Add_q(res,m,r);
4040  }
4041  p_LmDelete(&h,r);
4042  }
4043  omFreeSize((ADDRESS)me,(rVar(r)+1)*sizeof(int));
4044  omFreeSize((ADDRESS)ee,(rVar(r)+1)*sizeof(int));
4045  return res;
4046 }
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
Definition: old.gring.cc:3203
static poly p_Subst0(poly p, int n, const ring r)
Definition: p_polys.cc:3959
static poly p_Subst1(poly p, int n, const ring r)
Definition: p_polys.cc:3891
static poly p_Subst2(poly p, int n, number e, const ring r)
Definition: p_polys.cc:3918
poly p_LPSubst(poly p, int n, poly e, const ring r)
Definition: shiftop.cc:902

◆ p_TakeOutComp() [1/2]

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

Definition at line 3504 of file p_polys.cc.

3505 {
3506  poly q = *p,qq=NULL,result = NULL;
3507 
3508  if (q==NULL) return NULL;
3509  BOOLEAN use_setmcomp=rOrd_SetCompRequiresSetm(r);
3510  if (__p_GetComp(q,r)==k)
3511  {
3512  result = q;
3513  do
3514  {
3515  p_SetComp(q,0,r);
3516  if (use_setmcomp) p_SetmComp(q,r);
3517  qq = q;
3518  pIter(q);
3519  }
3520  while ((q!=NULL) && (__p_GetComp(q,r)==k));
3521  *p = q;
3522  pNext(qq) = NULL;
3523  }
3524  if (q==NULL) return result;
3525  if (__p_GetComp(q,r) > k)
3526  {
3527  p_SubComp(q,1,r);
3528  if (use_setmcomp) p_SetmComp(q,r);
3529  }
3530  poly pNext_q;
3531  while ((pNext_q=pNext(q))!=NULL)
3532  {
3533  if (__p_GetComp(pNext_q,r)==k)
3534  {
3535  if (result==NULL)
3536  {
3537  result = pNext_q;
3538  qq = result;
3539  }
3540  else
3541  {
3542  pNext(qq) = pNext_q;
3543  pIter(qq);
3544  }
3545  pNext(q) = pNext(pNext_q);
3546  pNext(qq) =NULL;
3547  p_SetComp(qq,0,r);
3548  if (use_setmcomp) p_SetmComp(qq,r);
3549  }
3550  else
3551  {
3552  /*pIter(q);*/ q=pNext_q;
3553  if (__p_GetComp(q,r) > k)
3554  {
3555  p_SubComp(q,1,r);
3556  if (use_setmcomp) p_SetmComp(q,r);
3557  }
3558  }
3559  }
3560  return result;
3561 }

◆ p_TakeOutComp() [2/2]

void p_TakeOutComp ( poly *  p,
long  comp,
poly *  q,
int *  lq,
const ring  r 
)

Definition at line 3565 of file p_polys.cc.

3566 {
3567  spolyrec pp, qq;
3568  poly p, q, p_prev;
3569  int l = 0;
3570 
3571 #ifndef SING_NDEBUG
3572  int lp = pLength(*r_p);
3573 #endif
3574 
3575  pNext(&pp) = *r_p;
3576  p = *r_p;
3577  p_prev = &pp;
3578  q = &qq;
3579 
3580  while(p != NULL)
3581  {
3582  while (__p_GetComp(p,r) == comp)
3583  {
3584  pNext(q) = p;
3585  pIter(q);
3586  p_SetComp(p, 0,r);
3587  p_SetmComp(p,r);
3588  pIter(p);
3589  l++;
3590  if (p == NULL)
3591  {
3592  pNext(p_prev) = NULL;
3593  goto Finish;
3594  }
3595  }
3596  pNext(p_prev) = p;
3597  p_prev = p;
3598  pIter(p);
3599  }
3600 
3601  Finish:
3602  pNext(q) = NULL;
3603  *r_p = pNext(&pp);
3604  *r_q = pNext(&qq);
3605  *lq = l;
3606 #ifndef SING_NDEBUG
3607  assume(pLength(*r_p) + pLength(*r_q) == lp);
3608 #endif
3609  p_Test(*r_p,r);
3610  p_Test(*r_q,r);
3611 }

◆ p_TakeOutComp1()

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

Definition at line 3453 of file p_polys.cc.

3454 {
3455  poly q = *p;
3456 
3457  if (q==NULL) return NULL;
3458 
3459  poly qq=NULL,result = NULL;
3460 
3461  if (__p_GetComp(q,r)==k)
3462  {
3463  result = q; /* *p */
3464  while ((q!=NULL) && (__p_GetComp(q,r)==k))
3465  {
3466  p_SetComp(q,0,r);
3467  p_SetmComp(q,r);
3468  qq = q;
3469  pIter(q);
3470  }
3471  *p = q;
3472  pNext(qq) = NULL;
3473  }
3474  if (q==NULL) return result;
3475 // if (pGetComp(q) > k) pGetComp(q)--;
3476  while (pNext(q)!=NULL)
3477  {
3478  if (__p_GetComp(pNext(q),r)==k)
3479  {
3480  if (result==NULL)
3481  {
3482  result = pNext(q);
3483  qq = result;
3484  }
3485  else
3486  {
3487  pNext(qq) = pNext(q);
3488  pIter(qq);
3489  }
3490  pNext(q) = pNext(pNext(q));
3491  pNext(qq) =NULL;
3492  p_SetComp(qq,0,r);
3493  p_SetmComp(qq,r);
3494  }
3495  else
3496  {
3497  pIter(q);
3498 // if (pGetComp(q) > k) pGetComp(q)--;
3499  }
3500  }
3501  return result;
3502 }

◆ p_Totaldegree()

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

Definition at line 1467 of file p_polys.h.

1468 {
1469  p_LmCheckPolyRing1(p, r);
1470  unsigned long s = p_GetTotalDegree(p->exp[r->VarL_Offset[0]],
1471  r,
1472  r->ExpPerLong);
1473  for (unsigned i=r->VarL_Size-1; i!=0; i--)
1474  {
1475  s += p_GetTotalDegree(p->exp[r->VarL_Offset[i]], r,r->ExpPerLong);
1476  }
1477  return (long)s;
1478 }
static unsigned long p_GetTotalDegree(const unsigned long l, const ring r, const int number_of_exps)
Definition: p_polys.h:776

◆ p_Var()

int p_Var ( poly  mi,
const ring  r 
)

Definition at line 4682 of file p_polys.cc.

4683 {
4684  if (m==NULL) return 0;
4685  if (pNext(m)!=NULL) return 0;
4686  int i,e=0;
4687  for (i=rVar(r); i>0; i--)
4688  {
4689  int exp=p_GetExp(m,i,r);
4690  if (exp==1)
4691  {
4692  if (e==0) e=i;
4693  else return 0;
4694  }
4695  else if (exp!=0)
4696  {
4697  return 0;
4698  }
4699  }
4700  return e;
4701 }

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

3663 {
3664  poly h;
3665  int k;
3666 
3667  for(int i=len-1;i>=0;i--) p[i]=NULL;
3668  while (v!=NULL)
3669  {
3670  h=p_Head(v,r);
3671  k=__p_GetComp(h,r);
3672  if (k>len) { Werror("wrong rank:%d, should be %d",len,k); }
3673  else
3674  {
3675  p_SetComp(h,0,r);
3676  p_Setm(h,r);
3677  pNext(h)=p[k-1];p[k-1]=h;
3678  }
3679  pIter(v);
3680  }
3681  for(int i=len-1;i>=0;i--)
3682  {
3683  if (p[i]!=NULL) p[i]=pReverse(p[i]);
3684  }
3685 }

◆ p_Vec2Poly()

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

Definition at line 3641 of file p_polys.cc.

3642 {
3643  poly h;
3644  poly res=NULL;
3645 
3646  while (v!=NULL)
3647  {
3648  if (__p_GetComp(v,r)==k)
3649  {
3650  h=p_Head(v,r);
3651  p_SetComp(h,0,r);
3652  pNext(h)=res;res=h;
3653  }
3654  pIter(v);
3655  }
3656  if (res!=NULL) res=pReverse(res);
3657  return res;
3658 }

◆ p_Vec2Polys()

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

Definition at line 3692 of file p_polys.cc.

3693 {
3694  poly h;
3695  int k;
3696 
3697  *len=p_MaxComp(v,r);
3698  if (*len==0) *len=1;
3699  *p=(poly*)omAlloc((*len)*sizeof(poly));
3700  p_Vec2Array(v,*p,*len,r);
3701 }
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:3662

◆ p_VectorHasUnit()

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

Definition at line 3421 of file p_polys.cc.

3422 {
3423  poly q=p,qq;
3424  int i,j=0;
3425 
3426  *len = 0;
3427  while (q!=NULL)
3428  {
3429  if (p_LmIsConstantComp(q,r))
3430  {
3431  i = __p_GetComp(q,r);
3432  qq = p;
3433  while ((qq != q) && (__p_GetComp(qq,r) != i)) pIter(qq);
3434  if (qq == q)
3435  {
3436  j = 0;
3437  while (qq!=NULL)
3438  {
3439  if (__p_GetComp(qq,r)==i) j++;
3440  pIter(qq);
3441  }
3442  if ((*len == 0) || (j<*len))
3443  {
3444  *len = j;
3445  *k = i;
3446  }
3447  }
3448  }
3449  pIter(q);
3450  }
3451 }

◆ p_VectorHasUnitB()

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

Definition at line 3398 of file p_polys.cc.

3399 {
3400  poly q=p,qq;
3401  int i;
3402 
3403  while (q!=NULL)
3404  {
3405  if (p_LmIsConstantComp(q,r))
3406  {
3407  i = __p_GetComp(q,r);
3408  qq = p;
3409  while ((qq != q) && (__p_GetComp(qq,r) != i)) pIter(qq);
3410  if (qq == q)
3411  {
3412  *k = i;
3413  return TRUE;
3414  }
3415  }
3416  pIter(q);
3417  }
3418  return FALSE;
3419 }

◆ p_WDegree()

long p_WDegree ( poly  p,
const ring  r 
)

Definition at line 709 of file p_polys.cc.

710 {
711  if (r->firstwv==NULL) return p_Totaldegree(p, r);
712  p_LmCheckPolyRing(p, r);
713  int i;
714  long j =0;
715 
716  for(i=1;i<=r->firstBlockEnds;i++)
717  j+=p_GetExp(p, i, r)*r->firstwv[i-1];
718 
719  for (;i<=rVar(r);i++)
720  j+=p_GetExp(p,i, r)*p_Weight(i, r);
721 
722  return j;
723 }
int p_Weight(int i, const ring r)
Definition: p_polys.cc:700

◆ p_Weight()

int p_Weight ( int  c,
const ring  r 
)

Definition at line 700 of file p_polys.cc.

701 {
702  if ((r->firstwv==NULL) || (i>r->firstBlockEnds))
703  {
704  return 1;
705  }
706  return r->firstwv[i-1];
707 }

◆ p_WFirstTotalDegree()

long p_WFirstTotalDegree ( poly  p,
ring  r 
)

Definition at line 591 of file p_polys.cc.

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

◆ p_Write() [1/2]

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

Definition at line 342 of file polys0.cc.

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

◆ p_Write() [2/2]

static void p_Write ( poly  p,
ring  p_ring 
)
inlinestatic

Definition at line 1208 of file p_polys.h.

1209 {
1210  p_Write(p, p_ring, p_ring);
1211 }

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

1213 {
1214  p_Write0(p, p_ring, p_ring);
1215 }
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 1216 of file p_polys.h.

1217 {
1218  p_wrp(p, p_ring, p_ring);
1219 }
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 608 of file p_polys.cc.

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

◆ pEnlargeSet()

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

Definition at line 3766 of file p_polys.cc.

3767 {
3768  poly* h;
3769 
3770  if (*p==NULL)
3771  {
3772  if (increment==0) return;
3773  h=(poly*)omAlloc0(increment*sizeof(poly));
3774  }
3775  else
3776  {
3777  h=(poly*)omReallocSize((poly*)*p,l*sizeof(poly),(l+increment)*sizeof(poly));
3778  if (increment>0)
3779  {
3780  memset(&(h[l]),0,increment*sizeof(poly));
3781  }
3782  }
3783  *p=h;
3784 }
#define omReallocSize(addr, o_size, size)
Definition: omAllocDecl.h:220

◆ pHaveCommonMonoms()

BOOLEAN pHaveCommonMonoms ( poly  p,
poly  q 
)

Definition at line 173 of file pDebug.cc.

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

◆ pIsMonomOf()

BOOLEAN pIsMonomOf ( poly  p,
poly  m 
)

Definition at line 163 of file pDebug.cc.

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

◆ pLDeg0()

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

Definition at line 734 of file p_polys.cc.

735 {
736  p_CheckPolyRing(p, r);
737  long k= p_GetComp(p, r);
738  int ll=1;
739 
740  if (k > 0)
741  {
742  while ((pNext(p)!=NULL) && (__p_GetComp(pNext(p), r)==k))
743  {
744  pIter(p);
745  ll++;
746  }
747  }
748  else
749  {
750  while (pNext(p)!=NULL)
751  {
752  pIter(p);
753  ll++;
754  }
755  }
756  *l=ll;
757  return r->pFDeg(p, r);
758 }

◆ pLDeg0c()

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

Definition at line 765 of file p_polys.cc.

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

◆ pLDeg1()

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

Definition at line 836 of file p_polys.cc.

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

◆ pLDeg1_Deg()

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

Definition at line 905 of file p_polys.cc.

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

◆ pLDeg1_Totaldegree()

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

Definition at line 970 of file p_polys.cc.

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

◆ pLDeg1_WFirstTotalDegree()

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

Definition at line 1033 of file p_polys.cc.

1034 {
1035  p_CheckPolyRing(p, r);
1036  long k= p_GetComp(p, r);
1037  int ll=1;
1038  long t,max;
1039 
1041  if (k > 0)
1042  {
1043  while (((p=pNext(p))!=NULL) && (__p_GetComp(p, r)==k))
1044  {
1045  t=p_WFirstTotalDegree(p, r);
1046  if (t>max) max=t;
1047  ll++;
1048  }
1049  }
1050  else
1051  {
1052  while ((p=pNext(p))!=NULL)
1053  {
1054  t=p_WFirstTotalDegree(p, r);
1055  if (t>max) max=t;
1056  ll++;
1057  }
1058  }
1059  *l=ll;
1060  return max;
1061 }
long p_WFirstTotalDegree(poly p, const ring r)
Definition: p_polys.cc:591

◆ pLDeg1c()

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

Definition at line 872 of file p_polys.cc.

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

◆ pLDeg1c_Deg()

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

Definition at line 936 of file p_polys.cc.

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

◆ pLDeg1c_Totaldegree()

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

Definition at line 1000 of file p_polys.cc.

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

◆ pLDeg1c_WFirstTotalDegree()

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

Definition at line 1063 of file p_polys.cc.

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

◆ pLDegb()

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

Definition at line 806 of file p_polys.cc.

807 {
808  p_CheckPolyRing(p, r);
809  long k= p_GetComp(p, r);
810  long o = r->pFDeg(p, r);
811  int ll=1;
812 
813  if (k != 0)
814  {
815  while (((p=pNext(p))!=NULL) && (__p_GetComp(p, r)==k))
816  {
817  ll++;
818  }
819  }
820  else
821  {
822  while ((p=pNext(p)) !=NULL)
823  {
824  ll++;
825  }
826  }
827  *l=ll;
828  return o;
829 }

◆ pLength()

static unsigned pLength ( poly  a)
inlinestatic

Definition at line 191 of file p_polys.h.

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

◆ pp_DivideM()

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

Definition at line 1620 of file p_polys.cc.

1621 {
1622  if (a==NULL) { return NULL; }
1623  // TODO: better implementation without copying a,b
1624  return p_DivideM(p_Copy(a,r),p_Head(b,r),r);
1625 }
poly p_DivideM(poly a, poly b, const ring r)
Definition: p_polys.cc:1565

◆ pp_Jet()

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

Definition at line 4384 of file p_polys.cc.

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

◆ pp_JetW()

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

Definition at line 4429 of file p_polys.cc.

4430 {
4431  poly r=NULL;
4432  poly t=NULL;
4433  while (p!=NULL)
4434  {
4435  if (totaldegreeWecart_IV(p,R,w)<=m)
4436  {
4437  if (r==NULL)
4438  r=p_Head(p,R);
4439  else
4440  if (t==NULL)
4441  {
4442  pNext(r)=p_Head(p,R);
4443  t=pNext(r);
4444  }
4445  else
4446  {
4447  pNext(t)=p_Head(p,R);
4448  pIter(t);
4449  }
4450  }
4451  pIter(p);
4452  }
4453  return r;
4454 }

◆ pp_mm_Mult()

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

Definition at line 1001 of file p_polys.h.

1002 {
1003  if (p==NULL) return NULL;
1004  if (p_LmIsConstant(m, r))
1005  return __pp_Mult_nn(p, pGetCoeff(m), r);
1006  else
1007  return r->p_Procs->pp_mm_Mult(p, m, r);
1008 }
#define __pp_Mult_nn(p, n, r)
Definition: p_polys.h:962

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

1051 {
1052  int shorter;
1053  return r->p_Procs->pp_Mult_Coeff_mm_DivSelect(p, m, shorter, r);
1054 }

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

1059 {
1060  int shorter;
1061  poly pp = r->p_Procs->pp_Mult_Coeff_mm_DivSelect(p, m, shorter, r);
1062  lp -= shorter;
1063  return pp;
1064 }

◆ pp_Mult_mm()

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

Definition at line 991 of file p_polys.h.

992 {
993  if (p==NULL) return NULL;
994  if (p_LmIsConstant(m, r))
995  return __pp_Mult_nn(p, pGetCoeff(m), r);
996  else
997  return r->p_Procs->pp_Mult_mm(p, m, r);
998 }

◆ pp_Mult_nn()

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

Definition at line 952 of file p_polys.h.

953 {
954  if (p==NULL) return NULL;
955  if (n_IsOne(n, r->cf))
956  return p_Copy(p, r);
957  else if (n_IsZero(n, r->cf))
958  return NULL;
959  else
960  return r->p_Procs->pp_Mult_nn(p, n, r);
961 }

◆ pp_Mult_qq()

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

Definition at line 1111 of file p_polys.h.

1112 {
1113  if (p == NULL || q == NULL) return NULL;
1114 
1115  if (pNext(p) == NULL)
1116  {
1117  return r->p_Procs->pp_mm_Mult(q, p, r);
1118  }
1119 
1120  if (pNext(q) == NULL)
1121  {
1122  return r->p_Procs->pp_Mult_mm(p, q, r);
1123  }
1124 
1125  poly qq = q;
1126  if (p == q)
1127  qq = p_Copy(q, r);
1128 
1129  poly res;
1130 #if defined(HAVE_PLURAL) || defined(HAVE_SHIFTBBA)
1131  if (rIsNCRing(r))
1132  res = _nc_pp_Mult_qq(p, qq, r);
1133  else
1134 #endif
1135  res = _p_Mult_q(p, qq, 1, r);
1136 
1137  if (qq != q)
1138  p_Delete(&qq, r);
1139  return res;
1140 }
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 3719 of file p_polys.cc.

3720 {
3721  assume(old_FDeg != NULL && old_lDeg != NULL);
3722  r->pFDeg = old_FDeg;
3723  r->pLDeg = old_lDeg;
3724 }

◆ pReverse()

static poly pReverse ( poly  p)
inlinestatic

Definition at line 335 of file p_polys.h.

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

◆ pSetDegProcs()

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

Definition at line 3707 of file p_polys.cc.

3708 {
3709  assume(new_FDeg != NULL);
3710  r->pFDeg = new_FDeg;
3711 
3712  if (new_lDeg == NULL)
3713  new_lDeg = r->pLDegOrig;
3714 
3715  r->pLDeg = new_lDeg;
3716 }