My Project  debian-1:4.1.2-p1+ds-2
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 short *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_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 p_Mult_mm (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. 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 void p_SetExpV (poly p, int *ev, const ring r)
 
static void p_SetExpVL (poly p, int64 *ev, 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 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, short *w, const ring R)
 
poly p_JetW (poly p, int m, short *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...
 

Macro Definition Documentation

◆ __p_Mult_nn

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

Definition at line 930 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 961 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:4019
#define p_MemCmp_LengthGeneral_OrdGeneral(s1, s2, length, ordsgn, actionE, actionG, actionS)
Definition: p_MemCmp.h:719

Definition at line 1215 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 1647 of file p_polys.h.

◆ p_LmEqual

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

Definition at line 1651 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 243 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 1221 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 1803 of file p_polys.h.

1804 {
1805  if (p_GetComp(a, r_a) == 0 || p_GetComp(a,r_a) == p_GetComp(b,r_b))
1806  return _p_LmDivisibleByNoComp(a, r_a, b, r_b);
1807  return FALSE;
1808 }
#define FALSE
Definition: auxiliary.h:96
CanonicalForm b
Definition: cfModGcd.cc:4044
#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:1693

◆ _p_LmDivisibleBy() [2/2]

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

Definition at line 1797 of file p_polys.h.

1798 {
1799  if (p_GetComp(a, r) == 0 || p_GetComp(a,r) == p_GetComp(b,r))
1800  return _p_LmDivisibleByNoComp(a, b, r);
1801  return FALSE;
1802 }

◆ _p_LmDivisibleByNoComp() [1/2]

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

Definition at line 1742 of file p_polys.h.

1743 {
1744  int i=r_a->N;
1745  pAssume1(r_a->N == r_b->N);
1746 
1747  do
1748  {
1749  if (p_GetExp(a,i,r_a) > p_GetExp(b,i,r_b))
1750  return FALSE;
1751  i--;
1752  }
1753  while (i);
1754 /*#ifdef HAVE_RINGS
1755  return n_DivBy(p_GetCoeff(b, r_b), p_GetCoeff(a, r_a), r_a->cf);
1756 #else
1757 */
1758  return TRUE;
1759 //#endif
1760 }
#define TRUE
Definition: auxiliary.h:100
int i
Definition: cfEzgcd.cc:125
#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:468

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

1694 {
1695  int i=r->VarL_Size - 1;
1696  unsigned long divmask = r->divmask;
1697  unsigned long la, lb;
1698 
1699  if (r->VarL_LowIndex >= 0)
1700  {
1701  i += r->VarL_LowIndex;
1702  do
1703  {
1704  la = a->exp[i];
1705  lb = b->exp[i];
1706  if ((la > lb) ||
1707  (((la & divmask) ^ (lb & divmask)) != ((lb - la) & divmask)))
1708  {
1710  return FALSE;
1711  }
1712  i--;
1713  }
1714  while (i>=r->VarL_LowIndex);
1715  }
1716  else
1717  {
1718  do
1719  {
1720  la = a->exp[r->VarL_Offset[i]];
1721  lb = b->exp[r->VarL_Offset[i]];
1722  if ((la > lb) ||
1723  (((la & divmask) ^ (lb & divmask)) != ((lb - la) & divmask)))
1724  {
1726  return FALSE;
1727  }
1728  i--;
1729  }
1730  while (i>=0);
1731  }
1732 /*#ifdef HAVE_RINGS
1733  pDivAssume(p_DebugLmDivisibleByNoComp(a, b, r) == n_DivBy(p_GetCoeff(b, r), p_GetCoeff(a, r), r->cf));
1734  return (!rField_is_Ring(r)) || n_DivBy(p_GetCoeff(b, r), p_GetCoeff(a, r), r->cf);
1735 #else
1736 */
1738  return TRUE;
1739 //#endif
1740 }
BOOLEAN p_DebugLmDivisibleByNoComp(poly a, poly b, ring r)
Definition: pDebug.cc:139
#define pDivAssume(x)
Definition: p_polys.h:1221

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

1764 {
1765  int i=end;
1766  pAssume1(r_a->N == r_b->N);
1767 
1768  do
1769  {
1770  if (p_GetExp(a,i,r_a) > p_GetExp(b,i,r_b))
1771  return FALSE;
1772  i--;
1773  }
1774  while (i>=start);
1775 /*#ifdef HAVE_RINGS
1776  return n_DivBy(p_GetCoeff(b, r_b), p_GetCoeff(a, r_a), r_a->cf);
1777 #else
1778 */
1779  return TRUE;
1780 //#endif
1781 }

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

1783 {
1784  if (p_GetComp(a, r_a) == 0 || p_GetComp(a,r_a) == p_GetComp(b,r_b))
1785  return _p_LmDivisibleByNoCompPart(a, r_a, b, r_b,start,end);
1786  return FALSE;
1787 }
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:1763

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

Definition at line 273 of file p_Mult_q.cc.

274 {
275  assume(r != NULL);
276 #ifdef HAVE_RINGS
277  if (!nCoeff_is_Domain(r->cf))
278  return _p_Mult_q_Normal_ZeroDiv(p, q, copy, r);
279 #endif
280  int lp, lq, l;
281  poly pt;
282 
283  pqLength(p, q, lp, lq, MIN_LENGTH_BUCKET);
284 
285  if (lp < lq)
286  {
287  pt = p;
288  p = q;
289  q = pt;
290  l = lp;
291  lp = lq;
292  lq = l;
293  }
295  return _p_Mult_q_Normal(p, q, copy, r);
296  else if ((lq >= MIN_LENGTH_FACTORY)
297  && (r->cf->convSingNFactoryN!=ndConvSingNFactoryN))
298  {
299  poly h=singclap_pmult(p,q,r);
300  if (!copy)
301  {
302  p_Delete(&p,r);
303  p_Delete(&q,r);
304  }
305  return h;
306  }
307  else
308  {
309  assume(lp == pLength(p));
310  assume(lq == pLength(q));
311  return _p_Mult_q_Bucket(p, lp, q, lq, copy, r);
312  }
313 }
int l
Definition: cfEzgcd.cc:93
poly singclap_pmult(poly f, poly g, const ring r)
Definition: clapsing.cc:511
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:761
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:390
Definition: lq.h:40
CanonicalForm ndConvSingNFactoryN(number, BOOLEAN, const coeffs)
Definition: numbers.cc:272
#define TEST_OPT_NOT_BUCKETS
Definition: options.h:103
BOOLEAN pqLength(poly p, poly q, int &lp, int &lq, const int min)
Definition: p_Mult_q.cc:29
static poly _p_Mult_q_Normal(poly p, poly q, const int copy, const ring r)
Definition: p_Mult_q.cc:191
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:68
static poly _p_Mult_q_Normal_ZeroDiv(poly p, poly q, const int copy, const ring r)
Definition: p_Mult_q.cc:163
#define MIN_LENGTH_FACTORY
Definition: p_Mult_q.h:27
#define MIN_LENGTH_BUCKET
Definition: p_Mult_q.h:21
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:860
static unsigned pLength(poly a)
Definition: p_polys.h:191

◆ _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:186
#define n_Test(a, r)
BOOLEAN n_Test(number a, const coeffs r)
Definition: coeffs.h:738
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
Definition: coeffs.h:464
static FORCE_INLINE int n_GetChar(const coeffs r)
Return the characteristic of the coeff. domain.
Definition: coeffs.h:444
#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:4432
static int p_LmCmp(poly p, poly q, const ring r)
Definition: p_polys.h:1500
static void p_LmFree(poly p, ring)
Definition: p_polys.h:682
@ ro_syzcomp
Definition: ring.h:59
union sro_ord::@0 data
Definition: ring.h:219
#define omTestBinAddrSize(A, B, C)
Definition: xalloc.h:316

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

3934 {
3935 #if 0
3936  PrintS("\nSource Ring: \n");
3937  rWrite(src);
3938 
3939  if(0)
3940  {
3941  number zz = n_Copy(z, src->cf);
3942  PrintS("z: "); n_Write(zz, src);
3943  n_Delete(&zz, src->cf);
3944  }
3945 
3946  PrintS("\nDestination Ring: \n");
3947  rWrite(dst);
3948 
3949  /*Print("\nOldPar: %d\n", OldPar);
3950  for( int i = 1; i <= OldPar; i++ )
3951  {
3952  Print("par(%d) -> par/var (%d)\n", i, par_perm[i-1]);
3953  }*/
3954 #endif
3955  if( z == NULL )
3956  return NULL;
3957 
3958  const coeffs srcCf = src->cf;
3959  assume( srcCf != NULL );
3960 
3961  assume( !nCoeff_is_GF(srcCf) );
3962  assume( src->cf->extRing!=NULL );
3963 
3964  poly zz = NULL;
3965 
3966  const ring srcExtRing = srcCf->extRing;
3967  assume( srcExtRing != NULL );
3968 
3969  const coeffs dstCf = dst->cf;
3970  assume( dstCf != NULL );
3971 
3972  if( nCoeff_is_algExt(srcCf) ) // nCoeff_is_GF(srcCf)?
3973  {
3974  zz = (poly) z;
3975  if( zz == NULL ) return NULL;
3976  }
3977  else if (nCoeff_is_transExt(srcCf))
3978  {
3979  assume( !IS0(z) );
3980 
3981  zz = NUM((fraction)z);
3982  p_Test (zz, srcExtRing);
3983 
3984  if( zz == NULL ) return NULL;
3985  if( !DENIS1((fraction)z) )
3986  {
3987  if (!p_IsConstant(DEN((fraction)z),srcExtRing))
3988  WarnS("Not defined: Cannot map a rational fraction and make a polynomial out of it! Ignoring the denominator.");
3989  }
3990  }
3991  else
3992  {
3993  assume (FALSE);
3994  WerrorS("Number permutation is not implemented for this data yet!");
3995  return NULL;
3996  }
3997 
3998  assume( zz != NULL );
3999  p_Test (zz, srcExtRing);
4000 
4001  nMapFunc nMap = n_SetMap(srcExtRing->cf, dstCf);
4002 
4003  assume( nMap != NULL );
4004 
4005  poly qq;
4006  if ((par_perm == NULL) && (rPar(dst) != 0 && rVar (srcExtRing) > 0))
4007  {
4008  int* perm;
4009  perm=(int *)omAlloc0((rVar(srcExtRing)+1)*sizeof(int));
4010  for(int i=si_min(rVar(srcExtRing),rPar(dst));i>0;i--)
4011  perm[i]=-i;
4012  qq = p_PermPoly(zz, perm, srcExtRing, dst, nMap, NULL, rVar(srcExtRing)-1);
4013  omFreeSize ((ADDRESS)perm, (rVar(srcExtRing)+1)*sizeof(int));
4014  }
4015  else
4016  qq = p_PermPoly(zz, par_perm-1, srcExtRing, dst, nMap, NULL, rVar (srcExtRing)-1);
4017 
4018  if(nCoeff_is_transExt(srcCf)
4019  && (!DENIS1((fraction)z))
4020  && p_IsConstant(DEN((fraction)z),srcExtRing))
4021  {
4022  number n=nMap(pGetCoeff(DEN((fraction)z)),srcExtRing->cf, dstCf);
4023  qq=p_Div_nn(qq,n,dst);
4024  n_Delete(&n,dstCf);
4025  p_Normalize(qq,dst);
4026  }
4027  p_Test (qq, dst);
4028 
4029  return qq;
4030 }
void * ADDRESS
Definition: auxiliary.h:135
static int si_min(const int a, const int b)
Definition: auxiliary.h:141
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of 'n'
Definition: coeffs.h:451
static FORCE_INLINE BOOLEAN nCoeff_is_GF(const coeffs r)
Definition: coeffs.h:861
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:721
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:455
static FORCE_INLINE void n_Write(number n, const coeffs r, const BOOLEAN bShortOut=TRUE)
Definition: coeffs.h:591
static FORCE_INLINE BOOLEAN nCoeff_is_algExt(const coeffs r)
TRUE iff r represents an algebraic extension field.
Definition: coeffs.h:932
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:73
static FORCE_INLINE BOOLEAN nCoeff_is_transExt(const coeffs r)
TRUE iff r represents a transcendental extension field.
Definition: coeffs.h:940
#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:4036
poly p_Div_nn(poly p, const number n, const ring r)
Definition: p_polys.cc:1487
void p_Normalize(poly p, const ring r)
Definition: p_polys.cc:3732
static BOOLEAN p_IsConstant(const poly p, const ring r)
Definition: p_polys.h:1931
#define p_Test(p, r)
Definition: p_polys.h:162
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:594
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:587

◆ p_Add_q() [1/2]

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

Definition at line 895 of file p_polys.h.

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

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

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

◆ p_AddComp()

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

Definition at line 446 of file p_polys.h.

447 {
448  p_LmCheckPolyRing2(p, r);
450  return __p_GetComp(p,r) += v;
451 }
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
#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 605 of file p_polys.h.

606 {
607  p_LmCheckPolyRing2(p, r);
608  int e = p_GetExp(p,v,r);
609  e += ee;
610  return p_SetExp(p,v,e,r);
611 }
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:487

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

84 {
85  poly r,h,hh;
86  int j;
87  poly res_p=NULL;
88  loop
89  {
90  /* search the lead term */
91  r=NULL;
92  for(j=rl-1;j>=0;j--)
93  {
94  h=xx[j];
95  if ((h!=NULL)
96  &&((r==NULL)||(p_LmCmp(r,h,R)==-1)))
97  r=h;
98  }
99  /* nothing found -> return */
100  if (r==NULL) break;
101  /* create the monomial in h */
102  h=p_Head(r,R);
103  /* collect the coeffs in x[..]*/
104  for(j=rl-1;j>=0;j--)
105  {
106  hh=xx[j];
107  if ((hh!=NULL) && (p_LmCmp(h,hh,R)==0))
108  {
109  x[j]=pGetCoeff(hh);
110  hh=p_LmFreeAndNext(hh,R);
111  xx[j]=hh;
112  }
113  else
114  x[j]=n_Init(0, R->cf);
115  }
116  number n=n_ChineseRemainderSym(x,q,rl,TRUE,inv_cache,R->cf);
117  for(j=rl-1;j>=0;j--)
118  {
119  x[j]=NULL; // n_Init(0...) takes no memory
120  }
121  if (n_IsZero(n,R->cf)) p_Delete(&h,R);
122  else
123  {
124  //Print("new mon:");pWrite(h);
125  p_SetCoeff(h,n,R);
126  pNext(h)=res_p;
127  res_p=h; // building res_p in reverse order!
128  }
129  }
130  res_p=pReverse(res_p);
131  p_Test(res_p, R);
132  return res_p;
133 }
Variable x
Definition: cfModGcd.cc:4023
static FORCE_INLINE number n_ChineseRemainderSym(number *a, number *b, int rl, BOOLEAN sym, CFArray &inv_cache, const coeffs r)
Definition: coeffs.h:786
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:538
int j
Definition: facHensel.cc:105
static poly p_Head(poly p, const ring r)
copy the i(leading) term of p
Definition: p_polys.h:825
static number p_SetCoeff(poly p, number n, ring r)
Definition: p_polys.h:411
static poly pReverse(poly p)
Definition: p_polys.h:334
static poly p_LmFreeAndNext(poly p, ring)
Definition: p_polys.h:702
#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 2791 of file p_polys.cc.

2792 {
2793  if( p == NULL )
2794  return NULL;
2795 
2796  assume( r != NULL ); assume( r->cf != NULL ); const coeffs C = r->cf;
2797 
2798 #if CLEARENUMERATORS
2799  if( 0 )
2800  {
2801  CPolyCoeffsEnumerator itr(p);
2802  n_ClearDenominators(itr, C);
2803  n_ClearContent(itr, C); // divide out the content
2804  p_Test(p, r); n_Test(pGetCoeff(p), C);
2805  assume(n_GreaterZero(pGetCoeff(p), C)); // ??
2806 // if(!n_GreaterZero(pGetCoeff(p),C)) p = p_Neg(p,r);
2807  return p;
2808  }
2809 #endif
2810 
2811  number d, h;
2812 
2813  if (rField_is_Ring(r))
2814  {
2815  p_ContentForGB(p,r);
2816  if(!n_GreaterZero(pGetCoeff(p),C)) p = p_Neg(p,r);
2817  return p;
2818  }
2819 
2821  {
2822  if(!n_GreaterZero(pGetCoeff(p),C)) p = p_Neg(p,r);
2823  return p;
2824  }
2825 
2826  assume(p != NULL);
2827 
2828  if(pNext(p)==NULL)
2829  {
2830  if (!TEST_OPT_CONTENTSB
2831  && !rField_is_Ring(r))
2832  p_SetCoeff(p,n_Init(1,r->cf),r);
2833  else if(!n_GreaterZero(pGetCoeff(p),C))
2834  p = p_Neg(p,r);
2835  return p;
2836  }
2837 
2838  assume(pNext(p)!=NULL);
2839  poly start=p;
2840 
2841 #if 0 && CLEARENUMERATORS
2842 //CF: does not seem to work that well..
2843 
2844  if( nCoeff_is_Q(C) || nCoeff_is_Q_a(C) )
2845  {
2846  CPolyCoeffsEnumerator itr(p);
2847  n_ClearDenominators(itr, C);
2848  n_ClearContent(itr, C); // divide out the content
2849  p_Test(p, r); n_Test(pGetCoeff(p), C);
2850  assume(n_GreaterZero(pGetCoeff(p), C)); // ??
2851 // if(!n_GreaterZero(pGetCoeff(p),C)) p = p_Neg(p,r);
2852  return start;
2853  }
2854 #endif
2855 
2856  if(1)
2857  {
2858  // get lcm of all denominators ----------------------------------
2859  h = n_Init(1,r->cf);
2860  while (p!=NULL)
2861  {
2862  n_Normalize(pGetCoeff(p),r->cf);
2863  d=n_NormalizeHelper(h,pGetCoeff(p),r->cf);
2864  n_Delete(&h,r->cf);
2865  h=d;
2866  pIter(p);
2867  }
2868  /* h now contains the 1/lcm of all denominators */
2869  if(!n_IsOne(h,r->cf))
2870  {
2871  // multiply by the lcm of all denominators
2872  p = start;
2873  while (p!=NULL)
2874  {
2875  d=n_Mult(h,pGetCoeff(p),r->cf);
2876  n_Normalize(d,r->cf);
2877  p_SetCoeff(p,d,r);
2878  pIter(p);
2879  }
2880  }
2881  n_Delete(&h,r->cf);
2882  p=start;
2883 
2884  p_ContentForGB(p,r);
2885 #ifdef HAVE_RATGRING
2886  if (rIsRatGRing(r))
2887  {
2888  /* quick unit detection in the rational case is done in gr_nc_bba */
2889  p_ContentRat(p, r);
2890  start=p;
2891  }
2892 #endif
2893  }
2894 
2895  if(!n_GreaterZero(pGetCoeff(p),C)) p = p_Neg(p,r);
2896 
2897  return start;
2898 }
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:636
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:717
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:494
static FORCE_INLINE BOOLEAN nCoeff_is_Q(const coeffs r)
Definition: coeffs.h:828
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:957
static FORCE_INLINE BOOLEAN nCoeff_is_Q_a(const coeffs r)
Definition: coeffs.h:907
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:950
static FORCE_INLINE void n_Normalize(number &n, const coeffs r)
inplace-normalization of n; produces some canonical representation of n;
Definition: coeffs.h:578
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff 'n' represents the one element.
Definition: coeffs.h:468
#define TEST_OPT_INTSTRATEGY
Definition: options.h:108
#define TEST_OPT_CONTENTSB
Definition: options.h:124
void p_ContentRat(poly &ph, const ring r)
Definition: p_polys.cc:1719
void p_ContentForGB(poly ph, const ring r)
Definition: p_polys.cc:2315
static poly p_Neg(poly p, const ring r)
Definition: p_polys.h:1046
static BOOLEAN rField_is_Ring(const ring r)
Definition: ring.h:479
static BOOLEAN rField_is_Zp(const ring r)
Definition: ring.h:495
static BOOLEAN rIsRatGRing(const ring r)
Definition: ring.h:423

◆ p_Cleardenom_n()

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

Definition at line 2900 of file p_polys.cc.

2901 {
2902  const coeffs C = r->cf;
2903  number d, h;
2904 
2905  assume( ph != NULL );
2906 
2907  poly p = ph;
2908 
2909 #if CLEARENUMERATORS
2910  if( 0 )
2911  {
2912  CPolyCoeffsEnumerator itr(ph);
2913 
2914  n_ClearDenominators(itr, d, C); // multiply with common denom. d
2915  n_ClearContent(itr, h, C); // divide by the content h
2916 
2917  c = n_Div(d, h, C); // d/h
2918 
2919  n_Delete(&d, C);
2920  n_Delete(&h, C);
2921 
2922  n_Test(c, C);
2923 
2924  p_Test(ph, r); n_Test(pGetCoeff(ph), C);
2925  assume(n_GreaterZero(pGetCoeff(ph), C)); // ??
2926 /*
2927  if(!n_GreaterZero(pGetCoeff(ph),C))
2928  {
2929  ph = p_Neg(ph,r);
2930  c = n_InpNeg(c, C);
2931  }
2932 */
2933  return;
2934  }
2935 #endif
2936 
2937 
2938  if( pNext(p) == NULL )
2939  {
2940  if(!TEST_OPT_CONTENTSB)
2941  {
2942  c=n_Invers(pGetCoeff(p), C);
2943  p_SetCoeff(p, n_Init(1, C), r);
2944  }
2945  else
2946  {
2947  c=n_Init(1,C);
2948  }
2949 
2950  if(!n_GreaterZero(pGetCoeff(ph),C))
2951  {
2952  ph = p_Neg(ph,r);
2953  c = n_InpNeg(c, C);
2954  }
2955 
2956  return;
2957  }
2958  if (TEST_OPT_CONTENTSB) { c=n_Init(1,C); return; }
2959 
2960  assume( pNext(p) != NULL );
2961 
2962 #if CLEARENUMERATORS
2963  if( nCoeff_is_Q(C) || nCoeff_is_Q_a(C) )
2964  {
2965  CPolyCoeffsEnumerator itr(ph);
2966 
2967  n_ClearDenominators(itr, d, C); // multiply with common denom. d
2968  n_ClearContent(itr, h, C); // divide by the content h
2969 
2970  c = n_Div(d, h, C); // d/h
2971 
2972  n_Delete(&d, C);
2973  n_Delete(&h, C);
2974 
2975  n_Test(c, C);
2976 
2977  p_Test(ph, r); n_Test(pGetCoeff(ph), C);
2978  assume(n_GreaterZero(pGetCoeff(ph), C)); // ??
2979 /*
2980  if(!n_GreaterZero(pGetCoeff(ph),C))
2981  {
2982  ph = p_Neg(ph,r);
2983  c = n_InpNeg(c, C);
2984  }
2985 */
2986  return;
2987  }
2988 #endif
2989 
2990 
2991 
2992 
2993  if(1)
2994  {
2995  h = n_Init(1,r->cf);
2996  while (p!=NULL)
2997  {
2998  n_Normalize(pGetCoeff(p),r->cf);
2999  d=n_NormalizeHelper(h,pGetCoeff(p),r->cf);
3000  n_Delete(&h,r->cf);
3001  h=d;
3002  pIter(p);
3003  }
3004  c=h;
3005  /* contains the 1/lcm of all denominators */
3006  if(!n_IsOne(h,r->cf))
3007  {
3008  p = ph;
3009  while (p!=NULL)
3010  {
3011  /* should be: // NOTE: don't use ->coef!!!!
3012  * number hh;
3013  * nGetDenom(p->coef,&hh);
3014  * nMult(&h,&hh,&d);
3015  * nNormalize(d);
3016  * nDelete(&hh);
3017  * nMult(d,p->coef,&hh);
3018  * nDelete(&d);
3019  * nDelete(&(p->coef));
3020  * p->coef =hh;
3021  */
3022  d=n_Mult(h,pGetCoeff(p),r->cf);
3023  n_Normalize(d,r->cf);
3024  p_SetCoeff(p,d,r);
3025  pIter(p);
3026  }
3027  if (rField_is_Q_a(r))
3028  {
3029  loop
3030  {
3031  h = n_Init(1,r->cf);
3032  p=ph;
3033  while (p!=NULL)
3034  {
3035  d=n_NormalizeHelper(h,pGetCoeff(p),r->cf);
3036  n_Delete(&h,r->cf);
3037  h=d;
3038  pIter(p);
3039  }
3040  /* contains the 1/lcm of all denominators */
3041  if(!n_IsOne(h,r->cf))
3042  {
3043  p = ph;
3044  while (p!=NULL)
3045  {
3046  /* should be: // NOTE: don't use ->coef!!!!
3047  * number hh;
3048  * nGetDenom(p->coef,&hh);
3049  * nMult(&h,&hh,&d);
3050  * nNormalize(d);
3051  * nDelete(&hh);
3052  * nMult(d,p->coef,&hh);
3053  * nDelete(&d);
3054  * nDelete(&(p->coef));
3055  * p->coef =hh;
3056  */
3057  d=n_Mult(h,pGetCoeff(p),r->cf);
3058  n_Normalize(d,r->cf);
3059  p_SetCoeff(p,d,r);
3060  pIter(p);
3061  }
3062  number t=n_Mult(c,h,r->cf);
3063  n_Delete(&c,r->cf);
3064  c=t;
3065  }
3066  else
3067  {
3068  break;
3069  }
3070  n_Delete(&h,r->cf);
3071  }
3072  }
3073  }
3074  }
3075 
3076  if(!n_GreaterZero(pGetCoeff(ph),C))
3077  {
3078  ph = p_Neg(ph,r);
3079  c = n_InpNeg(c, C);
3080  }
3081 
3082 }
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:564
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:557
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:615
static BOOLEAN rField_is_Q_a(const ring r)
Definition: ring.h:534

◆ p_Cmp()

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

Definition at line 1655 of file p_polys.h.

1656 {
1657  if (p2==NULL)
1658  {
1659  if (p1==NULL) return 0;
1660  return 1;
1661  }
1662  if (p1==NULL)
1663  return -1;
1664  return p_LmCmp(p1,p2,r);
1665 }

◆ p_CmpPolys()

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

Definition at line 1667 of file p_polys.h.

1668 {
1669  if (p2==NULL)
1670  {
1671  if (p1==NULL) return 0;
1672  return 1;
1673  }
1674  if (p1==NULL)
1675  return -1;
1676  return p_ComparePolys(p1,p2,r);
1677 }
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:4482

◆ p_Comp_k_n()

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

Definition at line 639 of file p_polys.h.

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

◆ p_Compare()

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

Definition at line 4812 of file p_polys.cc.

4813 {
4814  int r=p_Cmp(a,b,R);
4815  if ((r==0)&&(a!=NULL))
4816  {
4817  number h=n_Sub(pGetCoeff(a),pGetCoeff(b),R->cf);
4818  /* compare lead coeffs */
4819  r = -1+n_IsZero(h,R->cf)+2*n_GreaterZero(h,R->cf); /* -1: <, 0:==, 1: > */
4820  n_Delete(&h,R->cf);
4821  }
4822  else if (a==NULL)
4823  {
4824  if (b==NULL)
4825  {
4826  /* compare 0, 0 */
4827  r=0;
4828  }
4829  else if(p_IsConstant(b,R))
4830  {
4831  /* compare 0, const */
4832  r = 1-2*n_GreaterZero(pGetCoeff(b),R->cf); /* -1: <, 1: > */
4833  }
4834  }
4835  else if (b==NULL)
4836  {
4837  if (p_IsConstant(a,R))
4838  {
4839  /* compare const, 0 */
4840  r = -1+2*n_GreaterZero(pGetCoeff(a),R->cf); /* -1: <, 1: > */
4841  }
4842  }
4843  return(r);
4844 }
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:669
static int p_Cmp(poly p1, poly p2, ring r)
Definition: p_polys.h:1655

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

4483 {
4484  number n,nn;
4485  pAssume(p1 != NULL && p2 != NULL);
4486 
4487  if (!p_LmEqual(p1,p2,r)) //compare leading mons
4488  return FALSE;
4489  if ((pNext(p1)==NULL) && (pNext(p2)!=NULL))
4490  return FALSE;
4491  if ((pNext(p2)==NULL) && (pNext(p1)!=NULL))
4492  return FALSE;
4493  if (pLength(p1) != pLength(p2))
4494  return FALSE;
4495  #ifdef HAVE_RINGS
4496  if (rField_is_Ring(r))
4497  {
4498  if (!n_DivBy(pGetCoeff(p1), pGetCoeff(p2), r->cf)) return FALSE;
4499  }
4500  #endif
4501  n=n_Div(pGetCoeff(p1),pGetCoeff(p2),r->cf);
4502  while ((p1 != NULL) /*&& (p2 != NULL)*/)
4503  {
4504  if ( ! p_LmEqual(p1, p2,r))
4505  {
4506  n_Delete(&n, r->cf);
4507  return FALSE;
4508  }
4509  if (!n_Equal(pGetCoeff(p1), nn = n_Mult(pGetCoeff(p2),n, r->cf), r->cf))
4510  {
4511  n_Delete(&n, r->cf);
4512  n_Delete(&nn, r->cf);
4513  return FALSE;
4514  }
4515  n_Delete(&nn, r->cf);
4516  pIter(p1);
4517  pIter(p2);
4518  }
4519  n_Delete(&n, r->cf);
4520  return TRUE;
4521 }
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:775
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:460
#define pAssume(cond)
Definition: monomials.h:90
#define p_LmEqual(p1, p2, r)
Definition: p_polys.h:1651

◆ p_Content()

void p_Content ( poly  p,
const ring  r 
)

Definition at line 2270 of file p_polys.cc.

2271 {
2272  if (ph==NULL) return;
2273  const coeffs cf=r->cf;
2274  if (pNext(ph)==NULL)
2275  {
2276  p_SetCoeff(ph,n_Init(1,cf),r);
2277  }
2278  if (cf->cfSubringGcd==ndGcd) /* trivial gcd*/ return;
2279  number h=p_InitContent(ph,r); /* first guess of a gcd of all coeffs */
2280  poly p;
2281  if(n_IsOne(h,cf))
2282  {
2283  goto content_finish;
2284  }
2285  p=ph;
2286  // take the SubringGcd of all coeffs
2287  while (p!=NULL)
2288  {
2290  number d=n_SubringGcd(h,pGetCoeff(p),cf);
2291  n_Delete(&h,cf);
2292  h = d;
2293  if(n_IsOne(h,cf))
2294  {
2295  goto content_finish;
2296  }
2297  pIter(p);
2298  }
2299  // if found<>1, divide by it
2300  p = ph;
2301  while (p!=NULL)
2302  {
2303  number d = n_ExactDiv(pGetCoeff(p),h,cf);
2304  p_SetCoeff(p,d,r);
2305  pIter(p);
2306  }
2307 content_finish:
2308  n_Delete(&h,r->cf);
2309  // and last: check leading sign:
2310  if(!n_GreaterZero(pGetCoeff(ph),r->cf)) ph = p_Neg(ph,r);
2311 }
CanonicalForm cf
Definition: cfModGcd.cc:4024
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:622
static FORCE_INLINE number n_SubringGcd(number a, number b, const coeffs r)
Definition: coeffs.h:688
number ndGcd(number, number, const coeffs r)
Definition: numbers.cc:161
number p_InitContent(poly ph, const ring r)
Definition: p_polys.cc:2581

◆ p_ContentForGB()

void p_ContentForGB ( poly  p,
const ring  r 
)

Definition at line 2315 of file p_polys.cc.

2316 {
2317  if(TEST_OPT_CONTENTSB) return;
2318  assume( ph != NULL );
2319 
2320  assume( r != NULL ); assume( r->cf != NULL );
2321 
2322 
2323 #if CLEARENUMERATORS
2324  if( 0 )
2325  {
2326  const coeffs C = r->cf;
2327  // experimentall (recursive enumerator treatment) of alg. Ext!
2328  CPolyCoeffsEnumerator itr(ph);
2329  n_ClearContent(itr, r->cf);
2330 
2331  p_Test(ph, r); n_Test(pGetCoeff(ph), C);
2332  assume(n_GreaterZero(pGetCoeff(ph), C)); // ??
2333 
2334  // if(!n_GreaterZero(pGetCoeff(ph),r->cf)) ph = p_Neg(ph,r);
2335  return;
2336  }
2337 #endif
2338 
2339 
2340 #ifdef HAVE_RINGS
2341  if (rField_is_Ring(r))
2342  {
2343  if (rField_has_Units(r))
2344  {
2345  number k = n_GetUnit(pGetCoeff(ph),r->cf);
2346  if (!n_IsOne(k,r->cf))
2347  {
2348  number tmpGMP = k;
2349  k = n_Invers(k,r->cf);
2350  n_Delete(&tmpGMP,r->cf);
2351  poly h = pNext(ph);
2352  p_SetCoeff(ph, n_Mult(pGetCoeff(ph), k,r->cf),r);
2353  while (h != NULL)
2354  {
2355  p_SetCoeff(h, n_Mult(pGetCoeff(h), k,r->cf),r);
2356  pIter(h);
2357  }
2358 // assume( n_GreaterZero(pGetCoeff(ph),r->cf) );
2359 // if(!n_GreaterZero(pGetCoeff(ph),r->cf)) ph = p_Neg(ph,r);
2360  }
2361  n_Delete(&k,r->cf);
2362  }
2363  return;
2364  }
2365 #endif
2366  number h,d;
2367  poly p;
2368 
2369  if(pNext(ph)==NULL)
2370  {
2371  p_SetCoeff(ph,n_Init(1,r->cf),r);
2372  }
2373  else
2374  {
2375  assume( pNext(ph) != NULL );
2376 #if CLEARENUMERATORS
2377  if( nCoeff_is_Q(r->cf) )
2378  {
2379  // experimentall (recursive enumerator treatment) of alg. Ext!
2380  CPolyCoeffsEnumerator itr(ph);
2381  n_ClearContent(itr, r->cf);
2382 
2383  p_Test(ph, r); n_Test(pGetCoeff(ph), r->cf);
2384  assume(n_GreaterZero(pGetCoeff(ph), r->cf)); // ??
2385 
2386  // if(!n_GreaterZero(pGetCoeff(ph),r->cf)) ph = p_Neg(ph,r);
2387  return;
2388  }
2389 #endif
2390 
2391  n_Normalize(pGetCoeff(ph),r->cf);
2392  if(!n_GreaterZero(pGetCoeff(ph),r->cf)) ph = p_Neg(ph,r);
2393  if (rField_is_Q(r)||(getCoeffType(r->cf)==n_transExt)) // should not be used anymore if CLEARENUMERATORS is 1
2394  {
2395  h=p_InitContent(ph,r);
2396  p=ph;
2397  }
2398  else
2399  {
2400  h=n_Copy(pGetCoeff(ph),r->cf);
2401  p = pNext(ph);
2402  }
2403  while (p!=NULL)
2404  {
2405  n_Normalize(pGetCoeff(p),r->cf);
2406  d=n_SubringGcd(h,pGetCoeff(p),r->cf);
2407  n_Delete(&h,r->cf);
2408  h = d;
2409  if(n_IsOne(h,r->cf))
2410  {
2411  break;
2412  }
2413  pIter(p);
2414  }
2415  //number tmp;
2416  if(!n_IsOne(h,r->cf))
2417  {
2418  p = ph;
2419  while (p!=NULL)
2420  {
2421  //d = nDiv(pGetCoeff(p),h);
2422  //tmp = nExactDiv(pGetCoeff(p),h);
2423  //if (!nEqual(d,tmp))
2424  //{
2425  // StringSetS("** div0:");nWrite(pGetCoeff(p));StringAppendS("/");
2426  // nWrite(h);StringAppendS("=");nWrite(d);StringAppendS(" int:");
2427  // nWrite(tmp);Print(StringEndS("\n")); // NOTE/TODO: use StringAppendS("\n"); omFree(s);
2428  //}
2429  //nDelete(&tmp);
2430  d = n_ExactDiv(pGetCoeff(p),h,r->cf);
2431  p_SetCoeff(p,d,r);
2432  pIter(p);
2433  }
2434  }
2435  n_Delete(&h,r->cf);
2436  if (rField_is_Q_a(r))
2437  {
2438  // special handling for alg. ext.:
2439  if (getCoeffType(r->cf)==n_algExt)
2440  {
2441  h = n_Init(1, r->cf->extRing->cf);
2442  p=ph;
2443  while (p!=NULL)
2444  { // each monom: coeff in Q_a
2445  poly c_n_n=(poly)pGetCoeff(p);
2446  poly c_n=c_n_n;
2447  while (c_n!=NULL)
2448  { // each monom: coeff in Q
2449  d=n_NormalizeHelper(h,pGetCoeff(c_n),r->cf->extRing->cf);
2450  n_Delete(&h,r->cf->extRing->cf);
2451  h=d;
2452  pIter(c_n);
2453  }
2454  pIter(p);
2455  }
2456  /* h contains the 1/lcm of all denominators in c_n_n*/
2457  //n_Normalize(h,r->cf->extRing->cf);
2458  if(!n_IsOne(h,r->cf->extRing->cf))
2459  {
2460  p=ph;
2461  while (p!=NULL)
2462  { // each monom: coeff in Q_a
2463  poly c_n=(poly)pGetCoeff(p);
2464  while (c_n!=NULL)
2465  { // each monom: coeff in Q
2466  d=n_Mult(h,pGetCoeff(c_n),r->cf->extRing->cf);
2467  n_Normalize(d,r->cf->extRing->cf);
2468  n_Delete(&pGetCoeff(c_n),r->cf->extRing->cf);
2469  pGetCoeff(c_n)=d;
2470  pIter(c_n);
2471  }
2472  pIter(p);
2473  }
2474  }
2475  n_Delete(&h,r->cf->extRing->cf);
2476  }
2477  /*else
2478  {
2479  // special handling for rat. functions.:
2480  number hzz =NULL;
2481  p=ph;
2482  while (p!=NULL)
2483  { // each monom: coeff in Q_a (Z_a)
2484  fraction f=(fraction)pGetCoeff(p);
2485  poly c_n=NUM(f);
2486  if (hzz==NULL)
2487  {
2488  hzz=n_Copy(pGetCoeff(c_n),r->cf->extRing->cf);
2489  pIter(c_n);
2490  }
2491  while ((c_n!=NULL)&&(!n_IsOne(hzz,r->cf->extRing->cf)))
2492  { // each monom: coeff in Q (Z)
2493  d=n_Gcd(hzz,pGetCoeff(c_n),r->cf->extRing->cf);
2494  n_Delete(&hzz,r->cf->extRing->cf);
2495  hzz=d;
2496  pIter(c_n);
2497  }
2498  pIter(p);
2499  }
2500  // hzz contains the gcd of all numerators in f
2501  h=n_Invers(hzz,r->cf->extRing->cf);
2502  n_Delete(&hzz,r->cf->extRing->cf);
2503  n_Normalize(h,r->cf->extRing->cf);
2504  if(!n_IsOne(h,r->cf->extRing->cf))
2505  {
2506  p=ph;
2507  while (p!=NULL)
2508  { // each monom: coeff in Q_a (Z_a)
2509  fraction f=(fraction)pGetCoeff(p);
2510  NUM(f)=__p_Mult_nn(NUM(f),h,r->cf->extRing);
2511  p_Normalize(NUM(f),r->cf->extRing);
2512  pIter(p);
2513  }
2514  }
2515  n_Delete(&h,r->cf->extRing->cf);
2516  }*/
2517  }
2518  }
2519  if(!n_GreaterZero(pGetCoeff(ph),r->cf)) ph = p_Neg(ph,r);
2520 }
@ 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:532
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:421
static BOOLEAN rField_is_Q(const ring r)
Definition: ring.h:501
static BOOLEAN rField_has_Units(const ring r)
Definition: ring.h:485

◆ p_ContentRat()

void p_ContentRat ( poly &  ph,
const ring  r 
)

Definition at line 1719 of file p_polys.cc.

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

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

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

◆ p_Copy() [2/2]

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

returns a copy of p

Definition at line 811 of file p_polys.h.

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

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

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

◆ p_CopyPowerProduct()

poly p_CopyPowerProduct ( poly  p,
const ring  r 
)

like p_Head, but with coefficient 1

Definition at line 4884 of file p_polys.cc.

4885 {
4886  if (p == NULL) return NULL;
4887  p_LmCheckPolyRing1(p, r);
4888  poly np;
4889  omTypeAllocBin(poly, np, r->PolyBin);
4890  p_SetRingOfLm(np, r);
4891  memcpy(np->exp, p->exp, r->ExpL_Size*sizeof(long));
4892  pNext(np) = NULL;
4893  pSetCoeff0(np, n_Init(1, r->cf));
4894  return np;
4895 }
#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 597 of file p_polys.h.

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

◆ p_Deg()

long p_Deg ( poly  a,
const ring  r 
)

Definition at line 577 of file p_polys.cc.

578 {
579  p_LmCheckPolyRing(a, r);
580 // assume(p_GetOrder(a, r) == p_WTotaldegree(a, r)); // WRONG assume!
581  return p_GetOrder(a, r);
582 }
BOOLEAN p_LmCheckPolyRing(poly p, ring r)
Definition: pDebug.cc:118
static long p_GetOrder(poly p, ring r)
Definition: p_polys.h:420

◆ p_DegW()

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

Definition at line 680 of file p_polys.cc.

681 {
682  p_Test(p, R);
683  assume( w != NULL );
684  long r=-LONG_MAX;
685 
686  while (p!=NULL)
687  {
688  long t=totaldegreeWecart_IV(p,R,w);
689  if (t>r) r=t;
690  pIter(p);
691  }
692  return r;
693 }
const CanonicalForm & w
Definition: facAbsFact.cc:55
long totaldegreeWecart_IV(poly p, ring r, const short *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 867 of file p_polys.h.

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

◆ p_Delete() [2/2]

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

Definition at line 860 of file p_polys.h.

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

◆ p_DeleteComp()

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

Definition at line 3503 of file p_polys.cc.

3504 {
3505  poly q;
3506 
3507  while ((*p!=NULL) && (__p_GetComp(*p,r)==k)) p_LmDelete(p,r);
3508  if (*p==NULL) return;
3509  q = *p;
3510  if (__p_GetComp(q,r)>k)
3511  {
3512  p_SubComp(q,1,r);
3513  p_SetmComp(q,r);
3514  }
3515  while (pNext(q)!=NULL)
3516  {
3517  if (__p_GetComp(pNext(q),r)==k)
3518  p_LmDelete(&(pNext(q)),r);
3519  else
3520  {
3521  pIter(q);
3522  if (__p_GetComp(q,r)>k)
3523  {
3524  p_SubComp(q,1,r);
3525  p_SetmComp(q,r);
3526  }
3527  }
3528  }
3529 }
static unsigned long p_SubComp(poly p, unsigned long v, ring r)
Definition: p_polys.h:452
#define p_SetmComp
Definition: p_polys.h:243

◆ p_Diff()

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

Definition at line 1873 of file p_polys.cc.

1874 {
1875  poly res, f, last;
1876  number t;
1877 
1878  last = res = NULL;
1879  while (a!=NULL)
1880  {
1881  if (p_GetExp(a,k,r)!=0)
1882  {
1883  f = p_LmInit(a,r);
1884  t = n_Init(p_GetExp(a,k,r),r->cf);
1885  pSetCoeff0(f,n_Mult(t,pGetCoeff(a),r->cf));
1886  n_Delete(&t,r->cf);
1887  if (n_IsZero(pGetCoeff(f),r->cf))
1888  p_LmDelete(&f,r);
1889  else
1890  {
1891  p_DecrExp(f,k,r);
1892  p_Setm(f,r);
1893  if (res==NULL)
1894  {
1895  res=last=f;
1896  }
1897  else
1898  {
1899  pNext(last)=f;
1900  last=f;
1901  }
1902  }
1903  }
1904  pIter(a);
1905  }
1906  return res;
1907 }
FILE * f
Definition: checklibs.c:9
STATIC_VAR poly last
Definition: hdegree.cc:1076
static poly p_LmInit(poly p, const ring r)
Definition: p_polys.h:1274
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:232
static long p_DecrExp(poly p, int v, ring r)
Definition: p_polys.h:597

◆ p_DiffOp()

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

Definition at line 1948 of file p_polys.cc.

1949 {
1950  poly result=NULL;
1951  poly h;
1952  for(;a!=NULL;pIter(a))
1953  {
1954  for(h=b;h!=NULL;pIter(h))
1955  {
1956  result=p_Add_q(result,p_DiffOpM(a,h,multiply,r),r);
1957  }
1958  }
1959  return result;
1960 }
return result
Definition: facAbsBiFact.cc:76
static poly p_DiffOpM(poly a, poly b, BOOLEAN multiply, const ring r)
Definition: p_polys.cc:1909

◆ p_Div_mm()

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

divide polynomial by monomial

Definition at line 1520 of file p_polys.cc.

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

◆ p_Div_nn()

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

Definition at line 1487 of file p_polys.cc.

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

◆ p_DivideM()

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

Definition at line 1560 of file p_polys.cc.

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

◆ p_DivisibleBy() [1/2]

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

Definition at line 1841 of file p_polys.h.

1842 {
1843  pIfThen1(b!=NULL, p_LmCheckPolyRing1(b, r_b));
1844  pIfThen1(a!=NULL, p_LmCheckPolyRing1(a, r_a));
1845  if (a != NULL) {
1846  return _p_LmDivisibleBy(a, r_a, b, r_b);
1847  }
1848  return FALSE;
1849 }
#define pIfThen1(cond, check)
Definition: monomials.h:179
static BOOLEAN _p_LmDivisibleBy(poly a, poly b, const ring r)
Definition: p_polys.h:1797

◆ p_DivisibleBy() [2/2]

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

Definition at line 1832 of file p_polys.h.

1833 {
1835  pIfThen1(a!=NULL, p_LmCheckPolyRing1(a, r));
1836 
1837  if (a != NULL && (p_GetComp(a, r) == 0 || p_GetComp(a,r) == p_GetComp(b,r)))
1838  return _p_LmDivisibleByNoComp(a,b,r);
1839  return FALSE;
1840 }

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

1618 {
1619  int exponent;
1620  for(int i = (int)rVar(r); i>0; i--)
1621  {
1622  exponent = p_GetExp(g, i, r) - p_GetExp(f, i, r);
1623  if (exponent < 0) return FALSE;
1624  }
1625  return n_DivBy(pGetCoeff(g), pGetCoeff(f), r->cf);
1626 }
g
Definition: cfModGcd.cc:4031
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 4418 of file p_polys.cc.

4419 {
4420  while ((p1 != NULL) && (p2 != NULL))
4421  {
4422  if (! p_LmEqual(p1, p2,r))
4423  return FALSE;
4424  if (! n_Equal(p_GetCoeff(p1,r), p_GetCoeff(p2,r),r->cf ))
4425  return FALSE;
4426  pIter(p1);
4427  pIter(p2);
4428  }
4429  return (p1==p2);
4430 }
#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 4456 of file p_polys.cc.

4457 {
4458  assume( r1 == r2 || rSamePolyRep(r1, r2) ); // will be used in rEqual!
4459  assume( r1->cf == r2->cf );
4460 
4461  while ((p1 != NULL) && (p2 != NULL))
4462  {
4463  // returns 1 if ExpVector(p)==ExpVector(q): does not compare numbers !!
4464  // #define p_LmEqual(p1, p2, r) p_ExpVectorEqual(p1, p2, r)
4465 
4466  if (! p_ExpVectorEqual(p1, p2, r1, r2))
4467  return FALSE;
4468 
4469  if (! n_Equal(p_GetCoeff(p1,r1), p_GetCoeff(p2,r2), r1->cf ))
4470  return FALSE;
4471 
4472  pIter(p1);
4473  pIter(p2);
4474  }
4475  return (p1==p2);
4476 }
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:1712

◆ p_ExpVectorAdd()

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

Definition at line 1350 of file p_polys.h.

1351 {
1352  p_LmCheckPolyRing1(p1, r);
1353  p_LmCheckPolyRing1(p2, r);
1354 #if PDEBUG >= 1
1355  for (int i=1; i<=r->N; i++)
1356  pAssume1((unsigned long) (p_GetExp(p1, i, r) + p_GetExp(p2, i, r)) <= r->bitmask);
1357  pAssume1(p_GetComp(p1, r) == 0 || p_GetComp(p2, r) == 0);
1358 #endif
1359 
1360  p_MemAdd_LengthGeneral(p1->exp, p2->exp, r->ExpL_Size);
1361  p_MemAdd_NegWeightAdjust(p1, r);
1362 }
#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:1231

◆ p_ExpVectorAddSub()

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

Definition at line 1395 of file p_polys.h.

1396 {
1397  p_LmCheckPolyRing1(p1, r);
1398  p_LmCheckPolyRing1(p2, r);
1399  p_LmCheckPolyRing1(p3, r);
1400 #if PDEBUG >= 1
1401  for (int i=1; i<=r->N; i++)
1402  pAssume1(p_GetExp(p1, i, r) + p_GetExp(p2, i, r) >= p_GetExp(p3, i, r));
1403  pAssume1(p_GetComp(p1, r) == 0 ||
1404  (p_GetComp(p2, r) - p_GetComp(p3, r) == 0) ||
1405  (p_GetComp(p1, r) == p_GetComp(p2, r) - p_GetComp(p3, r)));
1406 #endif
1407 
1408  p_MemAddSub_LengthGeneral(p1->exp, p2->exp, p3->exp, r->ExpL_Size);
1409  // no need to adjust in case of NegWeights
1410 }
#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 1252 of file p_polys.h.

1253 {
1254  p_LmCheckPolyRing1(d_p, r);
1255  p_LmCheckPolyRing1(s_p, r);
1256  memcpy(d_p->exp, s_p->exp, r->ExpL_Size*sizeof(long));
1257 }

◆ p_ExpVectorDiff()

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

Definition at line 1413 of file p_polys.h.

1414 {
1415  p_LmCheckPolyRing1(p1, r);
1416  p_LmCheckPolyRing1(p2, r);
1417  p_LmCheckPolyRing1(pr, r);
1418 #if PDEBUG >= 2
1419  for (int i=1; i<=r->N; i++)
1420  pAssume1(p_GetExp(p1, i, r) >= p_GetExp(p2, i, r));
1421  pAssume1(!rRing_has_Comp(r) || p_GetComp(p1, r) == p_GetComp(p2, r));
1422 #endif
1423 
1424  p_MemDiff_LengthGeneral(pr->exp, p1->exp, p2->exp, r->ExpL_Size);
1425  p_MemSub_NegWeightAdjust(pr, r);
1426 }
#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:1241

◆ p_ExpVectorEqual()

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

Definition at line 1428 of file p_polys.h.

1429 {
1430  p_LmCheckPolyRing1(p1, r);
1431  p_LmCheckPolyRing1(p2, r);
1432 
1433  unsigned i = r->ExpL_Size;
1434  unsigned long *ep = p1->exp;
1435  unsigned long *eq = p2->exp;
1436 
1437  do
1438  {
1439  i--;
1440  if (ep[i] != eq[i]) return FALSE;
1441  }
1442  while (i!=0);
1443  return TRUE;
1444 }

◆ p_ExpVectorSub()

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

Definition at line 1379 of file p_polys.h.

1380 {
1381  p_LmCheckPolyRing1(p1, r);
1382  p_LmCheckPolyRing1(p2, r);
1383 #if PDEBUG >= 1
1384  for (int i=1; i<=r->N; i++)
1385  pAssume1(p_GetExp(p1, i, r) >= p_GetExp(p2, i, r));
1386  pAssume1(p_GetComp(p1, r) == 0 || p_GetComp(p2, r) == 0 ||
1387  p_GetComp(p1, r) == p_GetComp(p2, r));
1388 #endif
1389 
1390  p_MemSub_LengthGeneral(p1->exp, p2->exp, r->ExpL_Size);
1391  p_MemSub_NegWeightAdjust(p1, r);
1392 }
#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 1364 of file p_polys.h.

1365 {
1366  p_LmCheckPolyRing1(p1, r);
1367  p_LmCheckPolyRing1(p2, r);
1368  p_LmCheckPolyRing1(pr, r);
1369 #if PDEBUG >= 1
1370  for (int i=1; i<=r->N; i++)
1371  pAssume1((unsigned long) (p_GetExp(p1, i, r) + p_GetExp(p2, i, r)) <= r->bitmask);
1372  pAssume1(p_GetComp(p1, r) == 0 || p_GetComp(p2, r) == 0);
1373 #endif
1374 
1375  p_MemSum_LengthGeneral(pr->exp, p1->exp, p2->exp, r->ExpL_Size);
1376  p_MemAdd_NegWeightAdjust(pr, r);
1377 }
#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 50 of file p_polys.cc.

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

◆ p_FDeg()

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

Definition at line 379 of file p_polys.h.

379 { 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 4846 of file p_polys.cc.

4847 {
4848  assume(f!=NULL);
4849  assume(g!=NULL);
4850  assume(pNext(f)==NULL);
4851  poly G=p_Head(f,r);
4852  poly h=g;
4853  int *mf=(int*)omAlloc((r->N+1)*sizeof(int));
4854  p_GetExpV(f,mf,r);
4855  int *mh=(int*)omAlloc((r->N+1)*sizeof(int));
4856  BOOLEAN const_mon;
4857  BOOLEAN one_coeff=n_IsOne(pGetCoeff(G),r->cf);
4858  loop
4859  {
4860  if (h==NULL) break;
4861  if(!one_coeff)
4862  {
4863  number n=n_SubringGcd(pGetCoeff(G),pGetCoeff(h),r->cf);
4864  one_coeff=n_IsOne(n,r->cf);
4865  p_SetCoeff(G,n,r);
4866  }
4867  p_GetExpV(h,mh,r);
4868  const_mon=TRUE;
4869  for(unsigned j=r->N;j!=0;j--)
4870  {
4871  if (mh[j]<mf[j]) mf[j]=mh[j];
4872  if (mf[j]>0) const_mon=FALSE;
4873  }
4874  if (one_coeff && const_mon) break;
4875  pIter(h);
4876  }
4877  mf[0]=0;
4878  p_SetExpV(G,mf,r); // included is p_SetComp, p_Setm
4879  omFreeSize(mf,(r->N+1)*sizeof(int));
4880  omFreeSize(mh,(r->N+1)*sizeof(int));
4881  return G;
4882 }
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:1474
static void p_GetExpV(poly p, int *ev, const ring r)
Definition: p_polys.h:1459

◆ p_GetCoeffRat()

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

Definition at line 1697 of file p_polys.cc.

1698 {
1699  poly q = pNext(p);
1700  poly res; // = p_Head(p,r);
1701  res = p_GetExp_k_n(p, ishift+1, r->N, r); // does pSetm internally
1702  p_SetCoeff(res,n_Copy(p_GetCoeff(p,r),r),r);
1703  poly s;
1704  long cmp = p_GetComp(p, r);
1705  while ( (q!= NULL) && (p_Comp_k_n(p, q, ishift+1, r)) && (p_GetComp(q, r) == cmp) )
1706  {
1707  s = p_GetExp_k_n(q, ishift+1, r->N, r);
1708  p_SetCoeff(s,n_Copy(p_GetCoeff(q,r),r),r);
1709  res = p_Add_q(res,s,r);
1710  q = pNext(q);
1711  }
1712  cmp = 0;
1713  p_SetCompP(res,cmp,r);
1714  return res;
1715 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
static int p_Comp_k_n(poly a, poly b, int k, ring r)
Definition: p_polys.h:639
static void p_SetCompP(poly p, int i, ring r)
Definition: p_polys.h:253

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

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

◆ p_GetExp() [2/3]

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

Definition at line 554 of file p_polys.h.

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

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

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

1312 {
1313  if (p == NULL) return NULL;
1314  p_LmCheckPolyRing1(p, r);
1315  poly np;
1316  omTypeAllocBin(poly, np, r->PolyBin);
1317  p_SetRingOfLm(np, r);
1318  memcpy(np->exp, p->exp, r->ExpL_Size*sizeof(long));
1319  pNext(np) = NULL;
1320  pSetCoeff0(np, n_Init(1, r->cf));
1321  int i;
1322  for(i=l;i<=k;i++)
1323  {
1324  //np->exp[(r->VarOffset[i] & 0xffffff)] =0;
1325  p_SetExp(np,i,0,r);
1326  }
1327  p_Setm(np,r);
1328  return np;
1329 }

◆ p_GetExpDiff()

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

Definition at line 634 of file p_polys.h.

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

◆ p_GetExpSum()

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

Definition at line 628 of file p_polys.h.

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

◆ p_GetExpV()

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

Definition at line 1459 of file p_polys.h.

1460 {
1461  p_LmCheckPolyRing1(p, r);
1462  for (unsigned j = r->N; j!=0; j--)
1463  ev[j] = p_GetExp(p, j, r);
1464 
1465  ev[0] = p_GetComp(p, r);
1466 }

◆ p_GetExpVL()

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

Definition at line 1468 of file p_polys.h.

1469 {
1470  p_LmCheckPolyRing1(p, r);
1471  for (unsigned j = r->N; j!=0; j--)
1472  ev[j-1] = p_GetExp(p, j, r);
1473 }

◆ p_GetMaxExp() [1/2]

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

Definition at line 769 of file p_polys.h.

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

◆ p_GetMaxExp() [2/2]

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

Definition at line 746 of file p_polys.h.

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

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

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

1129 {
1130  p_CheckPolyRing(p, r);
1131  if (p == NULL) return p_Init(r);
1132  poly max = p_LmInit(p, r);
1133  pIter(p);
1134  if (p == NULL) return max;
1135  int i, offset;
1136  unsigned long l_p, l_max;
1137  unsigned long divmask = r->divmask;
1138 
1139  do
1140  {
1141  offset = r->VarL_Offset[0];
1142  l_p = p->exp[offset];
1143  l_max = max->exp[offset];
1144  // do the divisibility trick to find out whether l has an exponent
1145  if (l_p > l_max ||
1146  (((l_max & divmask) ^ (l_p & divmask)) != ((l_max-l_p) & divmask)))
1147  max->exp[offset] = p_GetMaxExpL2(l_max, l_p, r);
1148 
1149  for (i=1; i<r->VarL_Size; i++)
1150  {
1151  offset = r->VarL_Offset[i];
1152  l_p = p->exp[offset];
1153  l_max = max->exp[offset];
1154  // do the divisibility trick to find out whether l has an exponent
1155  if (l_p > l_max ||
1156  (((l_max & divmask) ^ (l_p & divmask)) != ((l_max-l_p) & divmask)))
1157  max->exp[offset] = p_GetMaxExpL2(l_max, l_p, r);
1158  }
1159  pIter(p);
1160  }
1161  while (p != NULL);
1162  return max;
1163 }
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:1259

◆ p_GetOrder()

static long p_GetOrder ( poly  p,
ring  r 
)
inlinestatic

Definition at line 420 of file p_polys.h.

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

551 {
552  // covers lp, rp, ls,
553  if (r->typ == NULL) return p_Setm_Dummy;
554 
555  if (r->OrdSize == 1)
556  {
557  if (r->typ[0].ord_typ == ro_dp &&
558  r->typ[0].data.dp.start == 1 &&
559  r->typ[0].data.dp.end == r->N &&
560  r->typ[0].data.dp.place == r->pOrdIndex)
561  return p_Setm_TotalDegree;
562  if (r->typ[0].ord_typ == ro_wp &&
563  r->typ[0].data.wp.start == 1 &&
564  r->typ[0].data.wp.end == r->N &&
565  r->typ[0].data.wp.place == r->pOrdIndex &&
566  r->typ[0].data.wp.weights == r->firstwv)
568  }
569  return p_Setm_General;
570 }
void p_Setm_WFirstTotalDegree(poly p, const ring r)
Definition: p_polys.cc:544
void p_Setm_Dummy(poly p, const ring r)
Definition: p_polys.cc:531
void p_Setm_TotalDegree(poly p, const ring r)
Definition: p_polys.cc:537
void p_Setm_General(poly p, const ring r)
Definition: p_polys.cc:152
@ 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 4687 of file p_polys.cc.

4688 {
4689  assume(p != NULL);
4690  unsigned long ev = 0; // short exponent vector
4691  unsigned int n = BIT_SIZEOF_LONG / r->N; // number of bits per exp
4692  unsigned int m1; // highest bit which is filled with (n+1)
4693  int i=0,j=1;
4694 
4695  if (n == 0)
4696  {
4697  if (r->N <2*BIT_SIZEOF_LONG)
4698  {
4699  n=1;
4700  m1=0;
4701  }
4702  else
4703  {
4704  for (; j<=r->N; j++)
4705  {
4706  if (p_GetExp(p,j,r) > 0) i++;
4707  if (i == BIT_SIZEOF_LONG) break;
4708  }
4709  if (i>0)
4710  ev = ~(0UL) >> (BIT_SIZEOF_LONG - i);
4711  return ev;
4712  }
4713  }
4714  else
4715  {
4716  m1 = (n+1)*(BIT_SIZEOF_LONG - n*r->N);
4717  }
4718 
4719  n++;
4720  while (i<m1)
4721  {
4722  ev |= GetBitFields(p_GetExp(p, j,r), i, n);
4723  i += n;
4724  j++;
4725  }
4726 
4727  n--;
4728  while (i<BIT_SIZEOF_LONG)
4729  {
4730  ev |= GetBitFields(p_GetExp(p, j,r), i, n);
4731  i += n;
4732  j++;
4733  }
4734  return ev;
4735 }
#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:4654

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

4740 {
4741  assume(p != NULL);
4742  assume(pp != NULL);
4743 
4744  unsigned long ev = 0; // short exponent vector
4745  unsigned int n = BIT_SIZEOF_LONG / r->N; // number of bits per exp
4746  unsigned int m1; // highest bit which is filled with (n+1)
4747  int j=1;
4748  unsigned long i = 0L;
4749 
4750  if (n == 0)
4751  {
4752  if (r->N <2*BIT_SIZEOF_LONG)
4753  {
4754  n=1;
4755  m1=0;
4756  }
4757  else
4758  {
4759  for (; j<=r->N; j++)
4760  {
4761  if (p_GetExp(p,j,r) > 0 || p_GetExp(pp,j,r) > 0) i++;
4762  if (i == BIT_SIZEOF_LONG) break;
4763  }
4764  if (i>0)
4765  ev = ~(0UL) >> (BIT_SIZEOF_LONG - i);
4766  return ev;
4767  }
4768  }
4769  else
4770  {
4771  m1 = (n+1)*(BIT_SIZEOF_LONG - n*r->N);
4772  }
4773 
4774  n++;
4775  while (i<m1)
4776  {
4777  ev |= GetBitFields(p_GetExp(p, j,r) + p_GetExp(pp, j,r), i, n);
4778  i += n;
4779  j++;
4780  }
4781 
4782  n--;
4783  while (i<BIT_SIZEOF_LONG)
4784  {
4785  ev |= GetBitFields(p_GetExp(p, j,r) + p_GetExp(pp, j,r), i, n);
4786  i += n;
4787  j++;
4788  }
4789  return ev;
4790 }

◆ p_GetTotalDegree()

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

Definition at line 775 of file p_polys.h.

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

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

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

◆ p_HasNotCF()

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

Definition at line 1319 of file p_polys.cc.

1320 {
1321 
1322  if (p_GetComp(p1,r) > 0 || p_GetComp(p2,r) > 0)
1323  return FALSE;
1324  int i = rVar(r);
1325  loop
1326  {
1327  if ((p_GetExp(p1, i, r) > 0) && (p_GetExp(p2, i, r) > 0))
1328  return FALSE;
1329  i--;
1330  if (i == 0)
1331  return TRUE;
1332  }
1333 }

◆ p_HasNotCFRing()

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

Definition at line 1335 of file p_polys.cc.

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

◆ p_Head()

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

copy the i(leading) term of p

Definition at line 825 of file p_polys.h.

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

◆ p_Homogen()

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

Definition at line 3217 of file p_polys.cc.

3218 {
3219  pFDegProc deg;
3220  if (r->pLexOrder && (r->order[0]==ringorder_lp))
3221  deg=p_Totaldegree;
3222  else
3223  deg=r->pFDeg;
3224 
3225  poly q=NULL, qn;
3226  int o,ii;
3227  sBucket_pt bp;
3228 
3229  if (p!=NULL)
3230  {
3231  if ((varnum < 1) || (varnum > rVar(r)))
3232  {
3233  return NULL;
3234  }
3235  o=deg(p,r);
3236  q=pNext(p);
3237  while (q != NULL)
3238  {
3239  ii=deg(q,r);
3240  if (ii>o) o=ii;
3241  pIter(q);
3242  }
3243  q = p_Copy(p,r);
3244  bp = sBucketCreate(r);
3245  while (q != NULL)
3246  {
3247  ii = o-deg(q,r);
3248  if (ii!=0)
3249  {
3250  p_AddExp(q,varnum, (long)ii,r);
3251  p_Setm(q,r);
3252  }
3253  qn = pNext(q);
3254  pNext(q) = NULL;
3255  sBucket_Add_m(bp, q);
3256  q = qn;
3257  }
3258  sBucketDestroyAdd(bp, &q, &ii);
3259  }
3260  return q;
3261 }
static long p_AddExp(poly p, int v, long ee, ring r)
Definition: p_polys.h:605
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 590 of file p_polys.h.

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

◆ p_Init() [1/2]

static poly p_Init ( const ring  r)
inlinestatic

Definition at line 1269 of file p_polys.h.

1270 {
1271  return p_Init(r, r->PolyBin);
1272 }

◆ p_Init() [2/2]

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

Definition at line 1259 of file p_polys.h.

1260 {
1261  p_CheckRing1(r);
1262  pAssume1(bin != NULL && omSizeWOfBin(r->PolyBin) == omSizeWOfBin(bin));
1263  poly p;
1264  omTypeAlloc0Bin(poly, p, bin);
1266  p_SetRingOfLm(p, r);
1267  return p;
1268 }
#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 2581 of file p_polys.cc.

2584 {
2586  assume(ph!=NULL);
2587  assume(pNext(ph)!=NULL);
2588  assume(rField_is_Q(r));
2589  if (pNext(pNext(ph))==NULL)
2590  {
2591  return n_GetNumerator(pGetCoeff(pNext(ph)),r->cf);
2592  }
2593  poly p=ph;
2594  number n1=n_GetNumerator(pGetCoeff(p),r->cf);
2595  pIter(p);
2596  number n2=n_GetNumerator(pGetCoeff(p),r->cf);
2597  pIter(p);
2598  number d;
2599  number t;
2600  loop
2601  {
2602  nlNormalize(pGetCoeff(p),r->cf);
2603  t=n_GetNumerator(pGetCoeff(p),r->cf);
2604  if (nlGreaterZero(t,r->cf))
2605  d=nlAdd(n1,t,r->cf);
2606  else
2607  d=nlSub(n1,t,r->cf);
2608  nlDelete(&t,r->cf);
2609  nlDelete(&n1,r->cf);
2610  n1=d;
2611  pIter(p);
2612  if (p==NULL) break;
2613  nlNormalize(pGetCoeff(p),r->cf);
2614  t=n_GetNumerator(pGetCoeff(p),r->cf);
2615  if (nlGreaterZero(t,r->cf))
2616  d=nlAdd(n2,t,r->cf);
2617  else
2618  d=nlSub(n2,t,r->cf);
2619  nlDelete(&t,r->cf);
2620  nlDelete(&n2,r->cf);
2621  n2=d;
2622  pIter(p);
2623  if (p==NULL) break;
2624  }
2625  d=nlGcd(n1,n2,r->cf);
2626  nlDelete(&n1,r->cf);
2627  nlDelete(&n2,r->cf);
2628  return d;
2629 }
2630 #else
2631 {
2632  /* ph has al least 2 terms */
2633  number d=pGetCoeff(ph);
2634  int s=n_Size(d,r->cf);
2635  pIter(ph);
2636  number d2=pGetCoeff(ph);
2637  int s2=n_Size(d2,r->cf);
2638  pIter(ph);
2639  if (ph==NULL)
2640  {
2641  if (s<s2) return n_Copy(d,r->cf);
2642  else return n_Copy(d2,r->cf);
2643  }
2644  do
2645  {
2646  number nd=pGetCoeff(ph);
2647  int ns=n_Size(nd,r->cf);
2648  if (ns<=2)
2649  {
2650  s2=s;
2651  d2=d;
2652  d=nd;
2653  s=ns;
2654  break;
2655  }
2656  else if (ns<s)
2657  {
2658  s2=s;
2659  d2=d;
2660  d=nd;
2661  s=ns;
2662  }
2663  pIter(ph);
2664  }
2665  while(ph!=NULL);
2666  return n_SubringGcd(d,d2,r->cf);
2667 }
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:570
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:608
LINLINE number nlAdd(number la, number li, const coeffs r)
Definition: longrat.cc:2532
LINLINE number nlSub(number la, number li, const coeffs r)
Definition: longrat.cc:2598
LINLINE void nlDelete(number *a, const coeffs r)
Definition: longrat.cc:2497
BOOLEAN nlGreaterZero(number za, const coeffs r)
Definition: longrat.cc:1165
number nlGcd(number a, number b, const coeffs r)
Definition: longrat.cc:1202
void nlNormalize(number &x, const coeffs r)
Definition: longrat.cc:1344

◆ p_IsConstant()

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

Definition at line 1931 of file p_polys.h.

1932 {
1933  if (p == NULL) return TRUE;
1934  p_Test(p, r);
1935  return (pNext(p)==NULL) && p_LmIsConstant(p, r);
1936 }
static BOOLEAN p_LmIsConstant(const poly p, const ring r)
Definition: p_polys.h:982

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

1926 {
1927  if (p == NULL) return TRUE;
1928  return (pNext(p)==NULL) && p_LmIsConstantComp(p, r);
1929 }
static BOOLEAN p_LmIsConstantComp(const poly p, const ring r)
Definition: p_polys.h:965

◆ p_IsConstantPoly()

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

Definition at line 1945 of file p_polys.h.

1946 {
1947  p_Test(p, r);
1948  poly pp=p;
1949  while(pp!=NULL)
1950  {
1951  if (! p_LmIsConstantComp(pp, r))
1952  return FALSE;
1953  pIter(pp);
1954  }
1955  return TRUE;
1956 }

◆ p_ISet()

poly p_ISet ( long  i,
const ring  r 
)

returns the poly representing the integer i

Definition at line 1287 of file p_polys.cc.

1288 {
1289  poly rc = NULL;
1290  if (i!=0)
1291  {
1292  rc = p_Init(r);
1293  pSetCoeff0(rc,n_Init(i,r->cf));
1294  if (n_IsZero(pGetCoeff(rc),r->cf))
1295  p_LmDelete(&rc,r);
1296  }
1297  return rc;
1298 }

◆ p_IsHomogeneous()

BOOLEAN p_IsHomogeneous ( poly  p,
const ring  r 
)

Definition at line 3266 of file p_polys.cc.

3267 {
3268  poly qp=p;
3269  int o;
3270 
3271  if ((p == NULL) || (pNext(p) == NULL)) return TRUE;
3272  pFDegProc d;
3273  if (r->pLexOrder && (r->order[0]==ringorder_lp))
3274  d=p_Totaldegree;
3275  else
3276  d=r->pFDeg;
3277  o = d(p,r);
3278  do
3279  {
3280  if (d(qp,r) != o) return FALSE;
3281  pIter(qp);
3282  }
3283  while (qp != NULL);
3284  return TRUE;
3285 }

◆ p_IsOne()

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

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

Definition at line 1939 of file p_polys.h.

1940 {
1941  p_Test(p, R);
1942  return (p_IsConstant(p, R) && n_IsOne(p_GetCoeff(p, R), R->cf));
1943 }

◆ p_IsPurePower()

int p_IsPurePower ( const poly  p,
const ring  r 
)

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

Definition at line 1216 of file p_polys.cc.

1217 {
1218  int i,k=0;
1219 
1220  for (i=r->N;i;i--)
1221  {
1222  if (p_GetExp(p,i, r)!=0)
1223  {
1224  if(k!=0) return 0;
1225  k=i;
1226  }
1227  }
1228  return k;
1229 }

◆ p_IsUnit()

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

Definition at line 1958 of file p_polys.h.

1959 {
1960  if (p == NULL) return FALSE;
1961  if (rField_is_Ring(r))
1962  return (p_LmIsConstant(p, r) && n_IsUnit(pGetCoeff(p),r->cf));
1963  return p_LmIsConstant(p, r);
1964 }
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:515

◆ p_IsUnivariate()

int p_IsUnivariate ( poly  p,
const ring  r 
)

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

Definition at line 1237 of file p_polys.cc.

1238 {
1239  int i,k=-1;
1240 
1241  while (p!=NULL)
1242  {
1243  for (i=r->N;i;i--)
1244  {
1245  if (p_GetExp(p,i, r)!=0)
1246  {
1247  if((k!=-1)&&(k!=i)) return 0;
1248  k=i;
1249  }
1250  }
1251  pIter(p);
1252  }
1253  return k;
1254 }

◆ p_Jet()

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

Definition at line 4292 of file p_polys.cc.

4293 {
4294  while((p!=NULL) && (p_Totaldegree(p,R)>m)) p_LmDelete(&p,R);
4295  if (p==NULL) return NULL;
4296  poly r=p;
4297  while (pNext(p)!=NULL)
4298  {
4299  if (p_Totaldegree(pNext(p),R)>m)
4300  {
4301  p_LmDelete(&pNext(p),R);
4302  }
4303  else
4304  pIter(p);
4305  }
4306  return r;
4307 }

◆ p_JetW()

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

Definition at line 4336 of file p_polys.cc.

4337 {
4338  while((p!=NULL) && (totaldegreeWecart_IV(p,R,w)>m)) p_LmDelete(&p,R);
4339  if (p==NULL) return NULL;
4340  poly r=p;
4341  while (pNext(p)!=NULL)
4342  {
4343  if (totaldegreeWecart_IV(pNext(p),R,w)>m)
4344  {
4345  p_LmDelete(&pNext(p),R);
4346  }
4347  else
4348  pIter(p);
4349  }
4350  return r;
4351 }

◆ p_Last()

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

Definition at line 4527 of file p_polys.cc.

4528 {
4529  if (p == NULL)
4530  {
4531  l = 0;
4532  return NULL;
4533  }
4534  l = 1;
4535  poly a = p;
4536  if (! rIsSyzIndexRing(r))
4537  {
4538  poly next = pNext(a);
4539  while (next!=NULL)
4540  {
4541  a = next;
4542  next = pNext(a);
4543  l++;
4544  }
4545  }
4546  else
4547  {
4548  int curr_limit = rGetCurrSyzLimit(r);
4549  poly pp = a;
4550  while ((a=pNext(a))!=NULL)
4551  {
4552  if (__p_GetComp(a,r)<=curr_limit/*syzComp*/)
4553  l++;
4554  else break;
4555  pp = a;
4556  }
4557  a=pp;
4558  }
4559  return a;
4560 }
ListNode * next
Definition: janet.h:31
static int rGetCurrSyzLimit(const ring r)
Definition: ring.h:718
static BOOLEAN rIsSyzIndexRing(const ring r)
Definition: ring.h:715

◆ p_Lcm() [1/2]

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

Definition at line 1639 of file p_polys.cc.

1640 {
1641  poly m=p_Init(r);
1642  p_Lcm(a, b, m, r);
1643  p_Setm(m,r);
1644  return(m);
1645 }
void p_Lcm(const poly a, const poly b, poly m, const ring r)
Definition: p_polys.cc:1630

◆ p_Lcm() [2/2]

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

Definition at line 1630 of file p_polys.cc.

1631 {
1632  for (int i=r->N; i; --i)
1633  p_SetExp(m,i, si_max( p_GetExp(a,i,r), p_GetExp(b,i,r)),r);
1634 
1635  p_SetComp(m, si_max(p_GetComp(a,r), p_GetComp(b,r)),r);
1636  /* Don't do a pSetm here, otherwise hres/lres chockes */
1637 }
static int si_max(const int a, const int b)
Definition: auxiliary.h:140
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition: p_polys.h:246

◆ p_LcmRat()

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

Definition at line 1652 of file p_polys.cc.

1653 {
1654  poly m = // p_One( r);
1655  p_Init(r);
1656 
1657 // const int (currRing->N) = r->N;
1658 
1659  // for (int i = (currRing->N); i>=r->real_var_start; i--)
1660  for (int i = r->real_var_end; i>=r->real_var_start; i--)
1661  {
1662  const int lExpA = p_GetExp (a, i, r);
1663  const int lExpB = p_GetExp (b, i, r);
1664 
1665  p_SetExp (m, i, si_max(lExpA, lExpB), r);
1666  }
1667 
1668  p_SetComp (m, lCompM, r);
1669  p_Setm(m,r);
1670  n_New(&(p_GetCoeff(m, r)), r);
1671 
1672  return(m);
1673 };
#define n_New(n, r)
Definition: coeffs.h:440

◆ p_LDeg()

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

Definition at line 380 of file p_polys.h.

380 { 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:258

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

1501 {
1502  p_LmCheckPolyRing1(p, r);
1503  p_LmCheckPolyRing1(q, r);
1504 
1505  const unsigned long* _s1 = ((unsigned long*) p->exp);
1506  const unsigned long* _s2 = ((unsigned long*) q->exp);
1507  REGISTER unsigned long _v1;
1508  REGISTER unsigned long _v2;
1509  const unsigned long _l = r->CmpL_Size;
1510 
1511  REGISTER unsigned long _i=0;
1512 
1513  LengthGeneral_OrdGeneral_LoopTop:
1514  _v1 = _s1[_i];
1515  _v2 = _s2[_i];
1516  if (_v1 == _v2)
1517  {
1518  _i++;
1519  if (_i == _l) return 0;
1520  goto LengthGeneral_OrdGeneral_LoopTop;
1521  }
1522  const long* _ordsgn = (long*) r->ordsgn;
1523 #if 1 /* two variants*/
1524  if (_v1 > _v2)
1525  {
1526  return _ordsgn[_i];
1527  }
1528  return -(_ordsgn[_i]);
1529 #else
1530  if (_v1 > _v2)
1531  {
1532  if (_ordsgn[_i] == 1) return 1;
1533  return -1;
1534  }
1535  if (_ordsgn[_i] == 1) return -1;
1536  return 1;
1537 #endif
1538 }
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 716 of file p_polys.h.

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

◆ p_LmDelete() [2/2]

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

Definition at line 710 of file p_polys.h.

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

◆ p_LmDeleteAndNext()

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

Definition at line 724 of file p_polys.h.

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

◆ p_LmDeleteAndNextRat()

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

Definition at line 1675 of file p_polys.cc.

1676 {
1677  /* modifies p*/
1678  // Print("start: "); Print(" "); p_wrp(*p,r);
1679  p_LmCheckPolyRing2(*p, r);
1680  poly q = p_Head(*p,r);
1681  const long cmp = p_GetComp(*p, r);
1682  while ( ( (*p)!=NULL ) && ( p_Comp_k_n(*p, q, ishift+1, r) ) && (p_GetComp(*p, r) == cmp) )
1683  {
1684  p_LmDelete(p,r);
1685  // Print("while: ");p_wrp(*p,r);Print(" ");
1686  }
1687  // p_wrp(*p,r);Print(" ");
1688  // PrintS("end\n");
1689  p_LmDelete(&q,r);
1690 }

◆ p_LmDivisibleBy() [1/2]

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

Definition at line 1850 of file p_polys.h.

1851 {
1852  p_LmCheckPolyRing(a, r_a);
1853  p_LmCheckPolyRing(b, r_b);
1854  return _p_LmDivisibleBy(a, r_a, b, r_b);
1855 }

◆ p_LmDivisibleBy() [2/2]

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

Definition at line 1823 of file p_polys.h.

1824 {
1825  p_LmCheckPolyRing1(b, r);
1826  pIfThen1(a != NULL, p_LmCheckPolyRing1(b, r));
1827  if (p_GetComp(a, r) == 0 || p_GetComp(a,r) == p_GetComp(b,r))
1828  return _p_LmDivisibleByNoComp(a, b, r);
1829  return FALSE;
1830 }

◆ p_LmDivisibleByNoComp() [1/2]

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

Definition at line 1816 of file p_polys.h.

1817 {
1818  p_LmCheckPolyRing1(a, ra);
1819  p_LmCheckPolyRing1(b, rb);
1820  return _p_LmDivisibleByNoComp(a, ra, b, rb);
1821 }

◆ p_LmDivisibleByNoComp() [2/2]

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

Definition at line 1809 of file p_polys.h.

1810 {
1811  p_LmCheckPolyRing1(a, r);
1812  p_LmCheckPolyRing1(b, r);
1813  return _p_LmDivisibleByNoComp(a, b, r);
1814 }

◆ p_LmDivisibleByPart()

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

Definition at line 1788 of file p_polys.h.

1789 {
1790  p_LmCheckPolyRing1(b, r);
1791  pIfThen1(a != NULL, p_LmCheckPolyRing1(b, r));
1792  if (p_GetComp(a, r) == 0 || p_GetComp(a,r) == p_GetComp(b,r))
1793  return _p_LmDivisibleByNoCompPart(a, r, b, r,start, end);
1794  return FALSE;
1795 }

◆ p_LmExpVectorAddIsOk()

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

Definition at line 1966 of file p_polys.h.

1968 {
1969  p_LmCheckPolyRing(p1, r);
1970  p_LmCheckPolyRing(p2, r);
1971  unsigned long l1, l2, divmask = r->divmask;
1972  int i;
1973 
1974  for (i=0; i<r->VarL_Size; i++)
1975  {
1976  l1 = p1->exp[r->VarL_Offset[i]];
1977  l2 = p2->exp[r->VarL_Offset[i]];
1978  // do the divisiblity trick
1979  if ( (l1 > ULONG_MAX - l2) ||
1980  (((l1 & divmask) ^ (l2 & divmask)) != ((l1 + l2) & divmask)))
1981  return FALSE;
1982  }
1983  return TRUE;
1984 }

◆ p_LmFree() [1/2]

static void p_LmFree ( poly *  p,
ring   
)
inlinestatic

Definition at line 691 of file p_polys.h.

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

◆ p_LmFree() [2/2]

static void p_LmFree ( poly  p,
ring   
)
inlinestatic

Definition at line 682 of file p_polys.h.

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

◆ p_LmFreeAndNext()

static poly p_LmFreeAndNext ( poly  p,
ring   
)
inlinestatic

Definition at line 702 of file p_polys.h.

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

◆ p_LmInit() [1/3]

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

Definition at line 1274 of file p_polys.h.

1275 {
1276  p_LmCheckPolyRing1(p, r);
1277  poly np;
1278  omTypeAllocBin(poly, np, r->PolyBin);
1279  p_SetRingOfLm(np, r);
1280  memcpy(np->exp, p->exp, r->ExpL_Size*sizeof(long));
1281  pNext(np) = NULL;
1282  pSetCoeff0(np, NULL);
1283  return np;
1284 }

◆ p_LmInit() [2/3]

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

Definition at line 1302 of file p_polys.h.

1303 {
1304  pAssume1(d_r != NULL);
1305  return p_LmInit(s_p, s_r, d_r, d_r->PolyBin);
1306 }

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

1286 {
1287  p_LmCheckPolyRing1(s_p, s_r);
1288  p_CheckRing(d_r);
1289  pAssume1(d_r->N <= s_r->N);
1290  poly d_p = p_Init(d_r, d_bin);
1291  for (unsigned i=d_r->N; i!=0; i--)
1292  {
1293  p_SetExp(d_p, i, p_GetExp(s_p, i,s_r), d_r);
1294  }
1295  if (rRing_has_Comp(d_r))
1296  {
1297  p_SetComp(d_p, p_GetComp(s_p,s_r), d_r);
1298  }
1299  p_Setm(d_p, d_r);
1300  return d_p;
1301 }
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 982 of file p_polys.h.

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

◆ p_LmIsConstantComp()

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

Definition at line 965 of file p_polys.h.

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

◆ p_LmShallowCopyDelete()

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

Definition at line 1332 of file p_polys.h.

1333 {
1334  p_LmCheckPolyRing1(p, r);
1335  pAssume1(omSizeWOfBin(bin) == omSizeWOfBin(r->PolyBin));
1336  poly new_p = p_New(r);
1337  memcpy(new_p->exp, p->exp, r->ExpL_Size*sizeof(long));
1338  pSetCoeff0(new_p, pGetCoeff(p));
1339  pNext(new_p) = pNext(p);
1340  omFreeBinAddr(p);
1341  return new_p;
1342 }
static poly p_New(const ring, omBin bin)
Definition: p_polys.h:663

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

1899 {
1900  p_LmCheckPolyRing1(a, r_a);
1901  p_LmCheckPolyRing1(b, r_b);
1902 #ifndef PDIV_DEBUG
1903  _pPolyAssume2(p_GetShortExpVector(a, r_a) == sev_a, a, r_a);
1904  _pPolyAssume2(p_GetShortExpVector(b, r_b) == ~ not_sev_b, b, r_b);
1905 
1906  if (sev_a & not_sev_b)
1907  {
1908  pAssume1(_p_LmDivisibleByNoComp(a, r_a, b, r_b) == FALSE);
1909  return FALSE;
1910  }
1911  return _p_LmDivisibleBy(a, r_a, b, r_b);
1912 #else
1913  return pDebugLmShortDivisibleBy(a, sev_a, r_a, b, not_sev_b, r_b);
1914 #endif
1915 }
#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:4687

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

1859 {
1860  p_LmCheckPolyRing1(a, r);
1861  p_LmCheckPolyRing1(b, r);
1862 #ifndef PDIV_DEBUG
1863  _pPolyAssume2(p_GetShortExpVector(a, r) == sev_a, a, r);
1864  _pPolyAssume2(p_GetShortExpVector(b, r) == ~ not_sev_b, b, r);
1865 
1866  if (sev_a & not_sev_b)
1867  {
1869  return FALSE;
1870  }
1871  return p_LmDivisibleBy(a, b, r);
1872 #else
1873  return pDebugLmShortDivisibleBy(a, sev_a, r, b, not_sev_b, r);
1874 #endif
1875 }
static BOOLEAN p_LmDivisibleByNoComp(poly a, poly b, const ring r)
Definition: p_polys.h:1809
static BOOLEAN p_LmDivisibleBy(poly a, poly b, const ring r)
Definition: p_polys.h:1823

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

1879 {
1880  p_LmCheckPolyRing1(a, r);
1881  p_LmCheckPolyRing1(b, r);
1882 #ifndef PDIV_DEBUG
1883  _pPolyAssume2(p_GetShortExpVector(a, r) == sev_a, a, r);
1884  _pPolyAssume2(p_GetShortExpVector(b, r) == ~ not_sev_b, b, r);
1885 
1886  if (sev_a & not_sev_b)
1887  {
1889  return FALSE;
1890  }
1891  return p_LmDivisibleByNoComp(a, b, r);
1892 #else
1893  return pDebugLmShortDivisibleByNoComp(a, sev_a, r, b, not_sev_b, r);
1894 #endif
1895 }
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 4586 of file p_polys.cc.

4587 {
4588  int k,l,lex;
4589 
4590  if (p == NULL) return -1;
4591 
4592  k = 32000;/*a very large dummy value*/
4593  while (p != NULL)
4594  {
4595  l = 1;
4596  lex = p_GetExp(p,l,r);
4597  while ((l < (rVar(r))) && (lex == 0))
4598  {
4599  l++;
4600  lex = p_GetExp(p,l,r);
4601  }
4602  l--;
4603  if (l < k) k = l;
4604  pIter(p);
4605  }
4606  return k;
4607 }

◆ p_LtCmp()

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

Definition at line 1541 of file p_polys.h.

1542 {
1543  int res = p_LmCmp(p,q,r);
1544  if(res == 0)
1545  {
1546  if(p_GetCoeff(p,r) == NULL || p_GetCoeff(q,r) == NULL)
1547  return res;
1548  number pc = n_Copy(p_GetCoeff(p,r),r->cf);
1549  number qc = n_Copy(p_GetCoeff(q,r),r->cf);
1550  if(!n_GreaterZero(pc,r->cf))
1551  pc = n_InpNeg(pc,r->cf);
1552  if(!n_GreaterZero(qc,r->cf))
1553  qc = n_InpNeg(qc,r->cf);
1554  if(n_Greater(pc,qc,r->cf))
1555  res = 1;
1556  else if(n_Greater(qc,pc,r->cf))
1557  res = -1;
1558  else if(n_Equal(pc,qc,r->cf))
1559  res = 0;
1560  n_Delete(&pc,r->cf);
1561  n_Delete(&qc,r->cf);
1562  }
1563  return res;
1564 }
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:511

◆ p_LtCmpNoAbs()

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

Definition at line 1567 of file p_polys.h.

1568 {
1569  int res = p_LmCmp(p,q,r);
1570  if(res == 0)
1571  {
1572  if(p_GetCoeff(p,r) == NULL || p_GetCoeff(q,r) == NULL)
1573  return res;
1574  number pc = p_GetCoeff(p,r);
1575  number qc = p_GetCoeff(q,r);
1576  if(n_Greater(pc,qc,r->cf))
1577  res = 1;
1578  if(n_Greater(qc,pc,r->cf))
1579  res = -1;
1580  if(n_Equal(pc,qc,r->cf))
1581  res = 0;
1582  }
1583  return res;
1584 }

◆ p_LtCmpOrdSgnDiffM()

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

Definition at line 1589 of file p_polys.h.

1590 {
1591  if(r->OrdSgn == 1)
1592  {
1593  return(p_LtCmp(p,q,r) == 1);
1594  }
1595  else
1596  {
1597  return(p_LmCmp(p,q,r) == -1);
1598  }
1599 }
static int p_LtCmp(poly p, poly q, const ring r)
Definition: p_polys.h:1541

◆ p_LtCmpOrdSgnDiffP()

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

Definition at line 1605 of file p_polys.h.

1606 {
1607  if(r->OrdSgn == 1)
1608  {
1609  return(p_LmCmp(p,q,r) == -1);
1610  }
1611  else
1612  {
1613  return(p_LtCmp(p,q,r) != -1);
1614  }
1615 
1616 }

◆ p_LtCmpOrdSgnEqM()

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

Definition at line 1622 of file p_polys.h.

1623 {
1624  return(p_LtCmp(p,q,r) == -r->OrdSgn);
1625 }

◆ p_LtCmpOrdSgnEqP()

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

Definition at line 1631 of file p_polys.h.

1632 {
1633  return(p_LtCmp(p,q,r) == r->OrdSgn);
1634 }

◆ p_MaxComp() [1/2]

static long p_MaxComp ( poly  p,
ring  lmRing 
)
inlinestatic

Definition at line 310 of file p_polys.h.

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

◆ p_MaxComp() [2/2]

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

Definition at line 291 of file p_polys.h.

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

◆ p_MDivide()

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

Definition at line 1474 of file p_polys.cc.

1475 {
1476  assume((p_GetComp(a,r)==p_GetComp(b,r)) || (p_GetComp(b,r)==0));
1477  int i;
1478  poly result = p_Init(r);
1479 
1480  for(i=(int)r->N; i; i--)
1481  p_SetExp(result,i, p_GetExp(a,i,r)- p_GetExp(b,i,r),r);
1482  p_SetComp(result, p_GetComp(a,r) - p_GetComp(b,r),r);
1483  p_Setm(result,r);
1484  return result;
1485 }

◆ p_MemAdd_NegWeightAdjust()

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

Definition at line 1231 of file p_polys.h.

1232 {
1233  if (r->NegWeightL_Offset != NULL)
1234  {
1235  for (int i=r->NegWeightL_Size-1; i>=0; i--)
1236  {
1237  p->exp[r->NegWeightL_Offset[i]] -= POLY_NEGWEIGHT_OFFSET;
1238  }
1239  }
1240 }

◆ p_MemSub_NegWeightAdjust()

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

Definition at line 1241 of file p_polys.h.

1242 {
1243  if (r->NegWeightL_Offset != NULL)
1244  {
1245  for (int i=r->NegWeightL_Size-1; i>=0; i--)
1246  {
1247  p->exp[r->NegWeightL_Offset[i]] += POLY_NEGWEIGHT_OFFSET;
1248  }
1249  }
1250 }

◆ p_Merge_q()

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

Definition at line 1151 of file p_polys.h.

1152 {
1153  assume( (p != q) || (p == NULL && q == NULL) );
1154  return r->p_Procs->p_Merge_q(p, q, r);
1155 }

◆ p_MinComp() [1/2]

static long p_MinComp ( poly  p,
ring  lmRing 
)
inlinestatic

Definition at line 331 of file p_polys.h.

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

◆ p_MinComp() [2/2]

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

Definition at line 312 of file p_polys.h.

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

◆ p_MinDeg()

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

Definition at line 4354 of file p_polys.cc.

4355 {
4356  if(p==NULL)
4357  return -1;
4358  int d=-1;
4359  while(p!=NULL)
4360  {
4361  int d0=0;
4362  for(int j=0;j<rVar(R);j++)
4363  if(w==NULL||j>=w->length())
4364  d0+=p_GetExp(p,j+1,R);
4365  else
4366  d0+=(*w)[j]*p_GetExp(p,j+1,R);
4367  if(d0<d||d==-1)
4368  d=d0;
4369  pIter(p);
4370  }
4371  return d;
4372 }

◆ p_mInit()

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

Definition at line 1432 of file p_polys.cc.

1433 {
1434  poly p;
1435  const char *s=p_Read(st,p,r);
1436  if (*s!='\0')
1437  {
1438  if ((s!=st)&&isdigit(st[0]))
1439  {
1441  }
1442  ok=FALSE;
1443  p_Delete(&p,r);
1444  return NULL;
1445  }
1446  p_Test(p,r);
1447  ok=!errorreported;
1448  return p;
1449 }
VAR short errorreported
Definition: feFopen.cc:23
const char * p_Read(const char *st, poly &rc, const ring r)
Definition: p_polys.cc:1360

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

1021 {
1022  int shorter;
1023 
1024  return r->p_Procs->p_Minus_mm_Mult_qq(p, m, q, shorter, NULL, r);
1025 }

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

1011 {
1012  int shorter;
1013  const poly res = r->p_Procs->p_Minus_mm_Mult_qq(p, m, q, shorter, spNoether, r);
1014  lp += lq - shorter;
1015 // assume( lp == pLength(res) );
1016  return res;
1017 }

◆ p_Mult_mm()

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

Definition at line 1000 of file p_polys.h.

1001 {
1002  if (p==NULL) return NULL;
1003  if (p_LmIsConstant(m, r))
1004  return __p_Mult_nn(p, pGetCoeff(m), r);
1005  else
1006  return r->p_Procs->p_Mult_mm(p, m, r);
1007 }

◆ p_Mult_nn() [1/2]

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

Definition at line 932 of file p_polys.h.

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

◆ p_Mult_nn() [2/2]

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

Definition at line 917 of file p_polys.h.

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

◆ p_Mult_q()

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

Definition at line 1053 of file p_polys.h.

1054 {
1055  assume( (p != q) || (p == NULL && q == NULL) );
1056 
1057  if (p == NULL)
1058  {
1059  p_Delete(&q, r);
1060  return NULL;
1061  }
1062  if (q == NULL)
1063  {
1064  p_Delete(&p, r);
1065  return NULL;
1066  }
1067 
1068  if (pNext(p) == NULL)
1069  {
1070  q = r->p_Procs->p_mm_Mult(q, p, r);
1071  p_LmDelete(&p, r);
1072  return q;
1073  }
1074 
1075  if (pNext(q) == NULL)
1076  {
1077  p = r->p_Procs->p_Mult_mm(p, q, r);
1078  p_LmDelete(&q, r);
1079  return p;
1080  }
1081 #ifdef HAVE_PLURAL
1082  if (rIsNCRing(r))
1083  return _nc_p_Mult_q(p, q, r);
1084  else
1085 #endif
1086  return _p_Mult_q(p, q, 0, r);
1087 }
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:273
static BOOLEAN rIsNCRing(const ring r)
Definition: ring.h:418

◆ p_MultExp()

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

Definition at line 620 of file p_polys.h.

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

◆ p_Neg()

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

Definition at line 1046 of file p_polys.h.

1047 {
1048  return r->p_Procs->p_Neg(p, r);
1049 }

◆ p_New() [1/2]

static poly p_New ( const  ring,
omBin  bin 
)
inlinestatic

Definition at line 663 of file p_polys.h.

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

◆ p_New() [2/2]

static poly p_New ( ring  r)
inlinestatic

Definition at line 674 of file p_polys.h.

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

◆ p_Norm()

void p_Norm ( poly  p1,
const ring  r 
)

Definition at line 3679 of file p_polys.cc.

3680 {
3681  if (rField_is_Ring(r))
3682  {
3683  if (!n_IsUnit(pGetCoeff(p1), r->cf)) return;
3684  // Werror("p_Norm not possible in the case of coefficient rings.");
3685  }
3686  else if (p1!=NULL)
3687  {
3688  if (pNext(p1)==NULL)
3689  {
3690  p_SetCoeff(p1,n_Init(1,r->cf),r);
3691  return;
3692  }
3693  poly h;
3694  if (!n_IsOne(pGetCoeff(p1),r->cf))
3695  {
3696  number k, c;
3697  n_Normalize(pGetCoeff(p1),r->cf);
3698  k = pGetCoeff(p1);
3699  c = n_Init(1,r->cf);
3700  pSetCoeff0(p1,c);
3701  h = pNext(p1);
3702  while (h!=NULL)
3703  {
3704  c=n_Div(pGetCoeff(h),k,r->cf);
3705  // no need to normalize: Z/p, R
3706  // normalize already in nDiv: Q_a, Z/p_a
3707  // remains: Q
3708  if (rField_is_Q(r) && (!n_IsOne(c,r->cf))) n_Normalize(c,r->cf);
3709  p_SetCoeff(h,c,r);
3710  pIter(h);
3711  }
3712  n_Delete(&k,r->cf);
3713  }
3714  else
3715  {
3716  //if (r->cf->cfNormalize != nDummy2) //TODO: OPTIMIZE
3717  {
3718  h = pNext(p1);
3719  while (h!=NULL)
3720  {
3721  n_Normalize(pGetCoeff(h),r->cf);
3722  pIter(h);
3723  }
3724  }
3725  }
3726  }
3727 }

◆ p_Normalize()

void p_Normalize ( poly  p,
const ring  r 
)

Definition at line 3732 of file p_polys.cc.

3733 {
3734  if (rField_has_simple_inverse(r)) return; /* Z/p, GF(p,n), R, long R/C */
3735  while (p!=NULL)
3736  {
3737  // no test befor n_Normalize: n_Normalize should fix problems
3738  n_Normalize(pGetCoeff(p),r->cf);
3739  pIter(p);
3740  }
3741 }
static BOOLEAN rField_has_simple_inverse(const ring r)
Definition: ring.h:543

◆ p_NSet()

poly p_NSet ( number  n,
const ring  r 
)

returns the poly representing the number n, destroys n

Definition at line 1455 of file p_polys.cc.

1456 {
1457  if (n_IsZero(n,r->cf))
1458  {
1459  n_Delete(&n, r->cf);
1460  return NULL;
1461  }
1462  else
1463  {
1464  poly rc = p_Init(r);
1465  pSetCoeff0(rc,n);
1466  return rc;
1467  }
1468 }

◆ p_One()

poly p_One ( const ring  r)

Definition at line 1303 of file p_polys.cc.

1304 {
1305  poly rc = p_Init(r);
1306  pSetCoeff0(rc,n_Init(1,r->cf));
1307  return rc;
1308 }

◆ p_OneComp()

BOOLEAN p_OneComp ( poly  p,
const ring  r 
)

return TRUE if all monoms have the same component

Definition at line 1198 of file p_polys.cc.

1199 {
1200  if(p!=NULL)
1201  {
1202  long i = p_GetComp(p, r);
1203  while (pNext(p)!=NULL)
1204  {
1205  pIter(p);
1206  if(i != p_GetComp(p, r)) return FALSE;
1207  }
1208  }
1209  return TRUE;
1210 }

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

4038 {
4039 #if 0
4040  p_Test(p, oldRing);
4041  PrintS("p_PermPoly::p: "); p_Write(p, oldRing, oldRing);
4042 #endif
4043  const int OldpVariables = rVar(oldRing);
4044  poly result = NULL;
4045  poly result_last = NULL;
4046  poly aq = NULL; /* the map coefficient */
4047  poly qq; /* the mapped monomial */
4048  assume(dst != NULL);
4049  assume(dst->cf != NULL);
4050  #ifdef HAVE_PLURAL
4051  poly tmp_mm=p_One(dst);
4052  #endif
4053  while (p != NULL)
4054  {
4055  // map the coefficient
4056  if ( ((OldPar == 0) || (par_perm == NULL) || rField_is_GF(oldRing) || (nMap==ndCopyMap))
4057  && (nMap != NULL) )
4058  {
4059  qq = p_Init(dst);
4060  assume( nMap != NULL );
4061  number n = nMap(p_GetCoeff(p, oldRing), oldRing->cf, dst->cf);
4062  n_Test (n,dst->cf);
4063  if ( nCoeff_is_algExt(dst->cf) )
4064  n_Normalize(n, dst->cf);
4065  p_GetCoeff(qq, dst) = n;// Note: n can be a ZERO!!!
4066  }
4067  else
4068  {
4069  qq = p_One(dst);
4070 // aq = naPermNumber(p_GetCoeff(p, oldRing), par_perm, OldPar, oldRing); // no dst???
4071 // poly n_PermNumber(const number z, const int *par_perm, const int P, const ring src, const ring dst)
4072  aq = n_PermNumber(p_GetCoeff(p, oldRing), par_perm, OldPar, oldRing, dst);
4073  p_Test(aq, dst);
4074  if ( nCoeff_is_algExt(dst->cf) )
4075  p_Normalize(aq,dst);
4076  if (aq == NULL)
4077  p_SetCoeff(qq, n_Init(0, dst->cf),dst); // Very dirty trick!!!
4078  p_Test(aq, dst);
4079  }
4080  if (rRing_has_Comp(dst))
4081  p_SetComp(qq, p_GetComp(p, oldRing), dst);
4082  if ( n_IsZero(pGetCoeff(qq), dst->cf) )
4083  {
4084  p_LmDelete(&qq,dst);
4085  qq = NULL;
4086  }
4087  else
4088  {
4089  // map pars:
4090  int mapped_to_par = 0;
4091  for(int i = 1; i <= OldpVariables; i++)
4092  {
4093  int e = p_GetExp(p, i, oldRing);
4094  if (e != 0)
4095  {
4096  if (perm==NULL)
4097  p_SetExp(qq, i, e, dst);
4098  else if (perm[i]>0)
4099  {
4100  #ifdef HAVE_PLURAL
4101  if(use_mult)
4102  {
4103  p_SetExp(tmp_mm,perm[i],e,dst);
4104  p_Setm(tmp_mm,dst);
4105  qq=p_Mult_mm(qq,tmp_mm,dst);
4106  p_SetExp(tmp_mm,perm[i],0,dst);
4107 
4108  }
4109  else
4110  #endif
4111  p_AddExp(qq,perm[i], e/*p_GetExp( p,i,oldRing)*/, dst);
4112  }
4113  else if (perm[i]<0)
4114  {
4115  number c = p_GetCoeff(qq, dst);
4116  if (rField_is_GF(dst))
4117  {
4118  assume( dst->cf->extRing == NULL );
4119  number ee = n_Param(1, dst);
4120  number eee;
4121  n_Power(ee, e, &eee, dst->cf); //nfDelete(ee,dst);
4122  ee = n_Mult(c, eee, dst->cf);
4123  //nfDelete(c,dst);nfDelete(eee,dst);
4124  pSetCoeff0(qq,ee);
4125  }
4126  else if (nCoeff_is_Extension(dst->cf))
4127  {
4128  const int par = -perm[i];
4129  assume( par > 0 );
4130 // WarnS("longalg missing 3");
4131 #if 1
4132  const coeffs C = dst->cf;
4133  assume( C != NULL );
4134  const ring R = C->extRing;
4135  assume( R != NULL );
4136  assume( par <= rVar(R) );
4137  poly pcn; // = (number)c
4138  assume( !n_IsZero(c, C) );
4139  if( nCoeff_is_algExt(C) )
4140  pcn = (poly) c;
4141  else // nCoeff_is_transExt(C)
4142  pcn = NUM((fraction)c);
4143  if (pNext(pcn) == NULL) // c->z
4144  p_AddExp(pcn, -perm[i], e, R);
4145  else /* more difficult: we have really to multiply: */
4146  {
4147  poly mmc = p_ISet(1, R);
4148  p_SetExp(mmc, -perm[i], e, R);
4149  p_Setm(mmc, R);
4150  number nnc;
4151  // convert back to a number: number nnc = mmc;
4152  if( nCoeff_is_algExt(C) )
4153  nnc = (number) mmc;
4154  else // nCoeff_is_transExt(C)
4155  nnc = ntInit(mmc, C);
4156  p_GetCoeff(qq, dst) = n_Mult((number)c, nnc, C);
4157  n_Delete((number *)&c, C);
4158  n_Delete((number *)&nnc, C);
4159  }
4160  mapped_to_par=1;
4161 #endif
4162  }
4163  }
4164  else
4165  {
4166  /* this variable maps to 0 !*/
4167  p_LmDelete(&qq, dst);
4168  break;
4169  }
4170  }
4171  }
4172  if ( mapped_to_par && (qq!= NULL) && nCoeff_is_algExt(dst->cf) )
4173  {
4174  number n = p_GetCoeff(qq, dst);
4175  n_Normalize(n, dst->cf);
4176  p_GetCoeff(qq, dst) = n;
4177  }
4178  }
4179  pIter(p);
4180 
4181 #if 0
4182  p_Test(aq,dst);
4183  PrintS("aq: "); p_Write(aq, dst, dst);
4184 #endif
4185 
4186 
4187 #if 1
4188  if (qq!=NULL)
4189  {
4190  p_Setm(qq,dst);
4191 
4192  p_Test(aq,dst);
4193  p_Test(qq,dst);
4194 
4195 #if 0
4196  PrintS("qq: "); p_Write(qq, dst, dst);
4197 #endif
4198 
4199  if (aq!=NULL)
4200  qq=p_Mult_q(aq,qq,dst);
4201  aq = qq;
4202  while (pNext(aq) != NULL) pIter(aq);
4203  if (result_last==NULL)
4204  {
4205  result=qq;
4206  }
4207  else
4208  {
4209  pNext(result_last)=qq;
4210  }
4211  result_last=aq;
4212  aq = NULL;
4213  }
4214  else if (aq!=NULL)
4215  {
4216  p_Delete(&aq,dst);
4217  }
4218  }
4219  result=p_SortAdd(result,dst);
4220 #else
4221  // if (qq!=NULL)
4222  // {
4223  // pSetm(qq);
4224  // pTest(qq);
4225  // pTest(aq);
4226  // if (aq!=NULL) qq=pMult(aq,qq);
4227  // aq = qq;
4228  // while (pNext(aq) != NULL) pIter(aq);
4229  // pNext(aq) = result;
4230  // aq = NULL;
4231  // result = qq;
4232  // }
4233  // else if (aq!=NULL)
4234  // {
4235  // pDelete(&aq);
4236  // }
4237  //}
4238  //p = result;
4239  //result = NULL;
4240  //while (p != NULL)
4241  //{
4242  // qq = p;
4243  // pIter(p);
4244  // qq->next = NULL;
4245  // result = pAdd(result, qq);
4246  //}
4247 #endif
4248  p_Test(result,dst);
4249 #if 0
4250  p_Test(result,dst);
4251  PrintS("result: "); p_Write(result,dst,dst);
4252 #endif
4253  #ifdef HAVE_PLURAL
4254  p_LmDelete(&tmp_mm,dst);
4255  #endif
4256  return result;
4257 }
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:805
static FORCE_INLINE BOOLEAN nCoeff_is_Extension(const coeffs r)
Definition: coeffs.h:868
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:632
number ndCopyMap(number a, const coeffs aRing, const coeffs r)
Definition: numbers.cc:251
poly n_PermNumber(const number z, const int *par_perm, const int, const ring src, const ring dst)
Definition: p_polys.cc:3933
poly p_ISet(long i, const ring r)
returns the poly representing the integer i
Definition: p_polys.cc:1287
poly p_One(const ring r)
Definition: p_polys.cc:1303
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:1000
static poly p_SortAdd(poly p, const ring r, BOOLEAN revert=FALSE)
Definition: p_polys.h:1158
static BOOLEAN rField_is_GF(const ring r)
Definition: ring.h:516
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 1144 of file p_polys.h.

1145 {
1146  int lp = 0, lq = 0;
1147  return p_Plus_mm_Mult_qq(p, m, q, lp, lq, r);
1148 }
static poly p_Plus_mm_Mult_qq(poly p, poly m, poly q, int &lp, int lq, const ring r)
Definition: p_polys.h:1122

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

1124 {
1125 #ifdef HAVE_PLURAL
1126  if (rIsPluralRing(r))
1127  return nc_p_Plus_mm_Mult_qq(p, m, q, lp, lq, r);
1128 #endif
1129 
1130 // this should be implemented more efficiently
1131  poly res;
1132  int shorter;
1133  number n_old = pGetCoeff(m);
1134  number n_neg = n_Copy(n_old, r->cf);
1135  n_neg = n_InpNeg(n_neg, r->cf);
1136  pSetCoeff0(m, n_neg);
1137  res = r->p_Procs->p_Minus_mm_Mult_qq(p, m, q, shorter, NULL, r);
1138  lp = (lp + lq) - shorter;
1139  pSetCoeff0(m, n_old);
1140  n_Delete(&n_neg, r->cf);
1141  return res;
1142 }
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:397

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

1846 {
1847  assume(divisor != NULL);
1848  if (p == NULL) return NULL;
1849 
1850  poly result = NULL;
1851  number divisorLC = p_GetCoeff(divisor, r);
1852  int divisorLE = p_GetExp(divisor, 1, r);
1853  while ((p != NULL) && (p_Deg(p, r) >= p_Deg(divisor, r)))
1854  {
1855  /* determine t = LT(p) / LT(divisor) */
1856  poly t = p_ISet(1, r);
1857  number c = n_Div(p_GetCoeff(p, r), divisorLC, r->cf);
1858  n_Normalize(c,r->cf);
1859  p_SetCoeff(t, c, r);
1860  int e = p_GetExp(p, 1, r) - divisorLE;
1861  p_SetExp(t, 1, e, r);
1862  p_Setm(t, r);
1863  if (needResult) result = p_Add_q(result, p_Copy(t, r), r);
1864  p = p_Add_q(p, p_Neg(p_Mult_q(t, p_Copy(divisor, r), r), r), r);
1865  }
1866  return result;
1867 }
long p_Deg(poly a, const ring r)
Definition: p_polys.cc:577

◆ p_Power()

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

Definition at line 2172 of file p_polys.cc.

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

◆ p_ProjectiveUnique()

void p_ProjectiveUnique ( poly  p,
const ring  r 
)

Definition at line 3089 of file p_polys.cc.

3090 {
3091  if( ph == NULL )
3092  return;
3093 
3094  assume( r != NULL ); assume( r->cf != NULL ); const coeffs C = r->cf;
3095 
3096  number h;
3097  poly p;
3098 
3099  if (rField_is_Ring(r))
3100  {
3101  p_ContentForGB(ph,r);
3102  if(!n_GreaterZero(pGetCoeff(ph),C)) ph = p_Neg(ph,r);
3103  assume( n_GreaterZero(pGetCoeff(ph),C) );
3104  return;
3105  }
3106 
3108  {
3109  assume( n_GreaterZero(pGetCoeff(ph),C) );
3110  if(!n_GreaterZero(pGetCoeff(ph),C)) ph = p_Neg(ph,r);
3111  return;
3112  }
3113  p = ph;
3114 
3115  assume(p != NULL);
3116 
3117  if(pNext(p)==NULL) // a monomial
3118  {
3119  p_SetCoeff(p, n_Init(1, C), r);
3120  return;
3121  }
3122 
3123  assume(pNext(p)!=NULL);
3124 
3125  if(!rField_is_Q(r) && !nCoeff_is_transExt(C))
3126  {
3127  h = p_GetCoeff(p, C);
3128  number hInv = n_Invers(h, C);
3129  pIter(p);
3130  while (p!=NULL)
3131  {
3132  p_SetCoeff(p, n_Mult(p_GetCoeff(p, C), hInv, C), r);
3133  pIter(p);
3134  }
3135  n_Delete(&hInv, C);
3136  p = ph;
3137  p_SetCoeff(p, n_Init(1, C), r);
3138  }
3139 
3140  p_Cleardenom(ph, r); //removes also Content
3141 
3142 
3143  /* normalize ph over a transcendental extension s.t.
3144  lead (ph) is > 0 if extRing->cf == Q
3145  or lead (ph) is monic if extRing->cf == Zp*/
3146  if (nCoeff_is_transExt(C))
3147  {
3148  p= ph;
3149  h= p_GetCoeff (p, C);
3150  fraction f = (fraction) h;
3151  number n=p_GetCoeff (NUM (f),C->extRing->cf);
3152  if (rField_is_Q (C->extRing))
3153  {
3154  if (!n_GreaterZero(n,C->extRing->cf))
3155  {
3156  p=p_Neg (p,r);
3157  }
3158  }
3159  else if (rField_is_Zp(C->extRing))
3160  {
3161  if (!n_IsOne (n, C->extRing->cf))
3162  {
3163  n=n_Invers (n,C->extRing->cf);
3164  nMapFunc nMap;
3165  nMap= n_SetMap (C->extRing->cf, C);
3166  number ninv= nMap (n,C->extRing->cf, C);
3167  p=__p_Mult_nn (p, ninv, r);
3168  n_Delete (&ninv, C);
3169  n_Delete (&n, C->extRing->cf);
3170  }
3171  }
3172  p= ph;
3173  }
3174 
3175  return;
3176 }
poly p_Cleardenom(poly p, const ring r)
Definition: p_polys.cc:2791

◆ p_Read()

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

Definition at line 1360 of file p_polys.cc.

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

4405 {
4406  short *ww=iv2array(w,R);
4407  if(p!=NULL)
4408  {
4409  if(u==NULL)
4410  p=p_JetW(p,n,ww,R);
4411  else
4412  p=p_JetW(p_Mult_q(p,p_Invers(n-p_MinDeg(p,w,R),u,w,R),R),n,ww,R);
4413  }
4414  omFreeSize((ADDRESS)ww,(rVar(R)+1)*sizeof(short));
4415  return p;
4416 }
static poly p_Invers(int n, poly u, intvec *w, const ring R)
Definition: p_polys.cc:4375
int p_MinDeg(poly p, intvec *w, const ring R)
Definition: p_polys.cc:4354
poly p_JetW(poly p, int m, short *w, const ring R)
Definition: p_polys.cc:4336
short * 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 411 of file p_polys.h.

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

◆ p_SetComp()

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

Definition at line 246 of file p_polys.h.

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

◆ p_SetCompP() [1/2]

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

Definition at line 280 of file p_polys.h.

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

◆ p_SetCompP() [2/2]

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

Definition at line 253 of file p_polys.h.

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

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

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

◆ p_SetExp() [2/3]

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

Definition at line 561 of file p_polys.h.

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

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

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

◆ p_SetExpV()

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

Definition at line 1474 of file p_polys.h.

1475 {
1476  p_LmCheckPolyRing1(p, r);
1477  for (unsigned j = r->N; j!=0; j--)
1478  p_SetExp(p, j, ev[j], r);
1479 
1480  if(ev[0]!=0) p_SetComp(p, ev[0],r);
1481  p_Setm(p, r);
1482 }

◆ p_SetExpVL()

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

Definition at line 1484 of file p_polys.h.

1485 {
1486  p_LmCheckPolyRing1(p, r);
1487  for (unsigned j = r->N; j!=0; j--)
1488  p_SetExp(p, j, ev[j], r);
1489 
1490  if(ev[0]!=0) p_SetComp(p, ev[0],r);
1491  p_Setm(p, r);
1492 }

◆ p_Setm()

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

Definition at line 232 of file p_polys.h.

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

◆ p_SetModDeg()

void p_SetModDeg ( intvec w,
ring  r 
)

Definition at line 3633 of file p_polys.cc.

3634 {
3635  if (w!=NULL)
3636  {
3637  r->pModW = w;
3638  pOldFDeg = r->pFDeg;
3639  pOldLDeg = r->pLDeg;
3640  pOldLexOrder = r->pLexOrder;
3641  pSetDegProcs(r,pModDeg);
3642  r->pLexOrder = TRUE;
3643  }
3644  else
3645  {
3646  r->pModW = NULL;
3648  r->pLexOrder = pOldLexOrder;
3649  }
3650 }
STATIC_VAR pLDegProc pOldLDeg
Definition: p_polys.cc:3621
void pRestoreDegProcs(ring r, pFDegProc old_FDeg, pLDegProc old_lDeg)
Definition: p_polys.cc:3609
STATIC_VAR BOOLEAN pOldLexOrder
Definition: p_polys.cc:3622
STATIC_VAR pFDegProc pOldFDeg
Definition: p_polys.cc:3620
void pSetDegProcs(ring r, pFDegProc new_FDeg, pLDegProc new_lDeg)
Definition: p_polys.cc:3597
static long pModDeg(poly p, ring r)
Definition: p_polys.cc:3624

◆ p_ShallowCopyDelete()

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

Definition at line 887 of file p_polys.h.

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

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

4613 {
4614  poly qp1 = *p,qp2 = *p;/*working pointers*/
4615  int j = p_MaxComp(*p,r),k = p_MinComp(*p,r);
4616 
4617  if (j+i < 0) return ;
4618  BOOLEAN toPoly= ((j == -i) && (j == k));
4619  while (qp1 != NULL)
4620  {
4621  if (toPoly || (__p_GetComp(qp1,r)+i > 0))
4622  {
4623  p_AddComp(qp1,i,r);
4624  p_SetmComp(qp1,r);
4625  qp2 = qp1;
4626  pIter(qp1);
4627  }
4628  else
4629  {
4630  if (qp2 == *p)
4631  {
4632  pIter(*p);
4633  p_LmDelete(&qp2,r);
4634  qp2 = *p;
4635  qp1 = *p;
4636  }
4637  else
4638  {
4639  qp2->next = qp1->next;
4640  if (qp1!=NULL) p_LmDelete(&qp1,r);
4641  qp1 = qp2->next;
4642  }
4643  }
4644  }
4645 }
return
Definition: cfGcdAlgExt.cc:218
static unsigned long p_AddComp(poly p, unsigned long v, ring r)
Definition: p_polys.h:446

◆ p_SimpleContent()

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

Definition at line 2524 of file p_polys.cc.

2525 {
2526  if(TEST_OPT_CONTENTSB) return;
2527  if (ph==NULL) return;
2528  if (pNext(ph)==NULL)
2529  {
2530  p_SetCoeff(ph,n_Init(1,r->cf),r);
2531  return;
2532  }
2533  if ((pNext(pNext(ph))==NULL)||(!rField_is_Q(r)))
2534  {
2535  return;
2536  }
2537  number d=p_InitContent(ph,r);
2538  if (n_Size(d,r->cf)<=smax)
2539  {
2540  //if (TEST_OPT_PROT) PrintS("G");
2541  return;
2542  }
2543 
2544  poly p=ph;
2545  number h=d;
2546  if (smax==1) smax=2;
2547  while (p!=NULL)
2548  {
2549 #if 0
2550  d=n_Gcd(h,pGetCoeff(p),r->cf);
2551  n_Delete(&h,r->cf);
2552  h = d;
2553 #else
2554  STATISTIC(n_Gcd); nlInpGcd(h,pGetCoeff(p),r->cf);
2555 #endif
2556  if(n_Size(h,r->cf)<smax)
2557  {
2558  //if (TEST_OPT_PROT) PrintS("g");
2559  return;
2560  }
2561  pIter(p);
2562  }
2563  p = ph;
2564  if (!n_GreaterZero(pGetCoeff(p),r->cf)) h=n_InpNeg(h,r->cf);
2565  if(n_IsOne(h,r->cf)) return;
2566  //if (TEST_OPT_PROT) PrintS("c");
2567  while (p!=NULL)
2568  {
2569 #if 1
2570  d = n_ExactDiv(pGetCoeff(p),h,r->cf);
2571  p_SetCoeff(p,d,r);
2572 #else
2573  STATISTIC(n_ExactDiv); nlInpExactDiv(pGetCoeff(p),h,r->cf); // no such function... ?
2574 #endif
2575  pIter(p);
2576  }
2577  n_Delete(&h,r->cf);
2578 }
static FORCE_INLINE number n_Gcd(number a, number b, const coeffs r)
in Z: return the gcd of 'a' and 'b' in Z/nZ, Z/2^kZ: computed as in the case Z in Z/pZ,...
Definition: coeffs.h:686
void nlInpGcd(number &a, number b, const coeffs r)
Definition: longrat.cc:2776
#define STATISTIC(f)
Definition: numstats.h:16

◆ p_Size()

int p_Size ( poly  p,
const ring  r 
)

Definition at line 3200 of file p_polys.cc.

3201 {
3202  int count = 0;
3203  if (r->cf->has_simple_Alloc)
3204  return pLength(p);
3205  while ( p != NULL )
3206  {
3207  count+= n_Size( pGetCoeff( p ), r->cf );
3208  pIter( p );
3209  }
3210  return count;
3211 }
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 1158 of file p_polys.h.

1159 {
1160  if (revert) p = pReverse(p);
1161  return sBucketSortAdd(p, r);
1162 }
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 1168 of file p_polys.h.

1169 {
1170  if (revert) p = pReverse(p);
1171  return sBucketSortMerge(p, r);
1172 }
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 1310 of file p_polys.cc.

1311 {
1312  *h=pNext(p);
1313  pNext(p)=NULL;
1314 }

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

1180 {
1181  return p_String(p, p_ring, p_ring);
1182 }
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 1183 of file p_polys.h.

1184 {
1185  p_String0(p, p_ring, p_ring);
1186 }
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:576

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

◆ p_Sub()

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

Definition at line 1965 of file p_polys.cc.

1966 {
1967  return p_Add_q(p1, p_Neg(p2,r),r);
1968 }

◆ p_SubComp()

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

Definition at line 452 of file p_polys.h.

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

◆ p_SubExp()

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

Definition at line 612 of file p_polys.h.

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

◆ p_Subst()

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

Definition at line 3874 of file p_polys.cc.

3875 {
3876  if (e == NULL) return p_Subst0(p, n,r);
3877 
3878  if (p_IsConstant(e,r))
3879  {
3880  if (n_IsOne(pGetCoeff(e),r->cf)) return p_Subst1(p,n,r);
3881  else return p_Subst2(p, n, pGetCoeff(e),r);
3882  }
3883 
3884 #ifdef HAVE_PLURAL
3885  if (rIsPluralRing(r))
3886  {
3887  return nc_pSubst(p,n,e,r);
3888  }
3889 #endif
3890 
3891  int exponent,i;
3892  poly h, res, m;
3893  int *me,*ee;
3894  number nu,nu1;
3895 
3896  me=(int *)omAlloc((rVar(r)+1)*sizeof(int));
3897  ee=(int *)omAlloc((rVar(r)+1)*sizeof(int));
3898  if (e!=NULL) p_GetExpV(e,ee,r);
3899  res=NULL;
3900  h=p;
3901  while (h!=NULL)
3902  {
3903  if ((e!=NULL) || (p_GetExp(h,n,r)==0))
3904  {
3905  m=p_Head(h,r);
3906  p_GetExpV(m,me,r);
3907  exponent=me[n];
3908  me[n]=0;
3909  for(i=rVar(r);i>0;i--)
3910  me[i]+=exponent*ee[i];
3911  p_SetExpV(m,me,r);
3912  if (e!=NULL)
3913  {
3914  n_Power(pGetCoeff(e),exponent,&nu,r->cf);
3915  nu1=n_Mult(pGetCoeff(m),nu,r->cf);
3916  n_Delete(&nu,r->cf);
3917  p_SetCoeff(m,nu1,r);
3918  }
3919  res=p_Add_q(res,m,r);
3920  }
3921  p_LmDelete(&h,r);
3922  }
3923  omFreeSize((ADDRESS)me,(rVar(r)+1)*sizeof(int));
3924  omFreeSize((ADDRESS)ee,(rVar(r)+1)*sizeof(int));
3925  return res;
3926 }
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:3229
static poly p_Subst0(poly p, int n, const ring r)
Definition: p_polys.cc:3849
static poly p_Subst1(poly p, int n, const ring r)
Definition: p_polys.cc:3781
static poly p_Subst2(poly p, int n, number e, const ring r)
Definition: p_polys.cc:3808

◆ p_TakeOutComp() [1/2]

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

Definition at line 3394 of file p_polys.cc.

3395 {
3396  poly q = *p,qq=NULL,result = NULL;
3397 
3398  if (q==NULL) return NULL;
3399  BOOLEAN use_setmcomp=rOrd_SetCompRequiresSetm(r);
3400  if (__p_GetComp(q,r)==k)
3401  {
3402  result = q;
3403  do
3404  {
3405  p_SetComp(q,0,r);
3406  if (use_setmcomp) p_SetmComp(q,r);
3407  qq = q;
3408  pIter(q);
3409  }
3410  while ((q!=NULL) && (__p_GetComp(q,r)==k));
3411  *p = q;
3412  pNext(qq) = NULL;
3413  }
3414  if (q==NULL) return result;
3415  if (__p_GetComp(q,r) > k)
3416  {
3417  p_SubComp(q,1,r);
3418  if (use_setmcomp) p_SetmComp(q,r);
3419  }
3420  poly pNext_q;
3421  while ((pNext_q=pNext(q))!=NULL)
3422  {
3423  if (__p_GetComp(pNext_q,r)==k)
3424  {
3425  if (result==NULL)
3426  {
3427  result = pNext_q;
3428  qq = result;
3429  }
3430  else
3431  {
3432  pNext(qq) = pNext_q;
3433  pIter(qq);
3434  }
3435  pNext(q) = pNext(pNext_q);
3436  pNext(qq) =NULL;
3437  p_SetComp(qq,0,r);
3438  if (use_setmcomp) p_SetmComp(qq,r);
3439  }
3440  else
3441  {
3442  /*pIter(q);*/ q=pNext_q;
3443  if (__p_GetComp(q,r) > k)
3444  {
3445  p_SubComp(q,1,r);
3446  if (use_setmcomp) p_SetmComp(q,r);
3447  }
3448  }
3449  }
3450  return result;
3451 }

◆ p_TakeOutComp() [2/2]

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

Definition at line 3455 of file p_polys.cc.

3456 {
3457  spolyrec pp, qq;
3458  poly p, q, p_prev;
3459  int l = 0;
3460 
3461 #ifndef SING_NDEBUG
3462  int lp = pLength(*r_p);
3463 #endif
3464 
3465  pNext(&pp) = *r_p;
3466  p = *r_p;
3467  p_prev = &pp;
3468  q = &qq;
3469 
3470  while(p != NULL)
3471  {
3472  while (__p_GetComp(p,r) == comp)
3473  {
3474  pNext(q) = p;
3475  pIter(q);
3476  p_SetComp(p, 0,r);
3477  p_SetmComp(p,r);
3478  pIter(p);
3479  l++;
3480  if (p == NULL)
3481  {
3482  pNext(p_prev) = NULL;
3483  goto Finish;
3484  }
3485  }
3486  pNext(p_prev) = p;
3487  p_prev = p;
3488  pIter(p);
3489  }
3490 
3491  Finish:
3492  pNext(q) = NULL;
3493  *r_p = pNext(&pp);
3494  *r_q = pNext(&qq);
3495  *lq = l;
3496 #ifndef SING_NDEBUG
3497  assume(pLength(*r_p) + pLength(*r_q) == lp);
3498 #endif
3499  p_Test(*r_p,r);
3500  p_Test(*r_q,r);
3501 }
int comp(const CanonicalForm &A, const CanonicalForm &B)
compare polynomials

◆ p_TakeOutComp1()

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

Definition at line 3343 of file p_polys.cc.

3344 {
3345  poly q = *p;
3346 
3347  if (q==NULL) return NULL;
3348 
3349  poly qq=NULL,result = NULL;
3350 
3351  if (__p_GetComp(q,r)==k)
3352  {
3353  result = q; /* *p */
3354  while ((q!=NULL) && (__p_GetComp(q,r)==k))
3355  {
3356  p_SetComp(q,0,r);
3357  p_SetmComp(q,r);
3358  qq = q;
3359  pIter(q);
3360  }
3361  *p = q;
3362  pNext(qq) = NULL;
3363  }
3364  if (q==NULL) return result;
3365 // if (pGetComp(q) > k) pGetComp(q)--;
3366  while (pNext(q)!=NULL)
3367  {
3368  if (__p_GetComp(pNext(q),r)==k)
3369  {
3370  if (result==NULL)
3371  {
3372  result = pNext(q);
3373  qq = result;
3374  }
3375  else
3376  {
3377  pNext(qq) = pNext(q);
3378  pIter(qq);
3379  }
3380  pNext(q) = pNext(pNext(q));
3381  pNext(qq) =NULL;
3382  p_SetComp(qq,0,r);
3383  p_SetmComp(qq,r);
3384  }
3385  else
3386  {
3387  pIter(q);
3388 // if (pGetComp(q) > k) pGetComp(q)--;
3389  }
3390  }
3391  return result;
3392 }

◆ p_Totaldegree()

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

Definition at line 1446 of file p_polys.h.

1447 {
1448  p_LmCheckPolyRing1(p, r);
1449  unsigned long s = p_GetTotalDegree(p->exp[r->VarL_Offset[0]],
1450  r,
1451  r->ExpPerLong);
1452  for (unsigned i=r->VarL_Size-1; i!=0; i--)
1453  {
1454  s += p_GetTotalDegree(p->exp[r->VarL_Offset[i]], r,r->ExpPerLong);
1455  }
1456  return (long)s;
1457 }
static unsigned long p_GetTotalDegree(const unsigned long l, const ring r, const int number_of_exps)
Definition: p_polys.h:775

◆ p_Var()

int p_Var ( poly  mi,
const ring  r 
)

Definition at line 4562 of file p_polys.cc.

4563 {
4564  if (m==NULL) return 0;
4565  if (pNext(m)!=NULL) return 0;
4566  int i,e=0;
4567  for (i=rVar(r); i>0; i--)
4568  {
4569  int exp=p_GetExp(m,i,r);
4570  if (exp==1)
4571  {
4572  if (e==0) e=i;
4573  else return 0;
4574  }
4575  else if (exp!=0)
4576  {
4577  return 0;
4578  }
4579  }
4580  return e;
4581 }

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

3553 {
3554  poly h;
3555  int k;
3556 
3557  for(int i=len-1;i>=0;i--) p[i]=NULL;
3558  while (v!=NULL)
3559  {
3560  h=p_Head(v,r);
3561  k=__p_GetComp(h,r);
3562  if (k>len) { Werror("wrong rank:%d, should be %d",len,k); }
3563  else
3564  {
3565  p_SetComp(h,0,r);
3566  p_Setm(h,r);
3567  pNext(h)=p[k-1];p[k-1]=h;
3568  }
3569  pIter(v);
3570  }
3571  for(int i=len-1;i>=0;i--)
3572  {
3573  if (p[i]!=NULL) p[i]=pReverse(p[i]);
3574  }
3575 }

◆ p_Vec2Poly()

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

Definition at line 3531 of file p_polys.cc.

3532 {
3533  poly h;
3534  poly res=NULL;
3535 
3536  while (v!=NULL)
3537  {
3538  if (__p_GetComp(v,r)==k)
3539  {
3540  h=p_Head(v,r);
3541  p_SetComp(h,0,r);
3542  pNext(h)=res;res=h;
3543  }
3544  pIter(v);
3545  }
3546  if (res!=NULL) res=pReverse(res);
3547  return res;
3548 }

◆ p_Vec2Polys()

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

Definition at line 3582 of file p_polys.cc.

3583 {
3584  poly h;
3585  int k;
3586 
3587  *len=p_MaxComp(v,r);
3588  if (*len==0) *len=1;
3589  *p=(poly*)omAlloc((*len)*sizeof(poly));
3590  p_Vec2Array(v,*p,*len,r);
3591 }
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:3552

◆ p_VectorHasUnit()

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

Definition at line 3311 of file p_polys.cc.

3312 {
3313  poly q=p,qq;
3314  int i,j=0;
3315 
3316  *len = 0;
3317  while (q!=NULL)
3318  {
3319  if (p_LmIsConstantComp(q,r))
3320  {
3321  i = __p_GetComp(q,r);
3322  qq = p;
3323  while ((qq != q) && (__p_GetComp(qq,r) != i)) pIter(qq);
3324  if (qq == q)
3325  {
3326  j = 0;
3327  while (qq!=NULL)
3328  {
3329  if (__p_GetComp(qq,r)==i) j++;
3330  pIter(qq);
3331  }
3332  if ((*len == 0) || (j<*len))
3333  {
3334  *len = j;
3335  *k = i;
3336  }
3337  }
3338  }
3339  pIter(q);
3340  }
3341 }

◆ p_VectorHasUnitB()

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

Definition at line 3288 of file p_polys.cc.

3289 {
3290  poly q=p,qq;
3291  int i;
3292 
3293  while (q!=NULL)
3294  {
3295  if (p_LmIsConstantComp(q,r))
3296  {
3297  i = __p_GetComp(q,r);
3298  qq = p;
3299  while ((qq != q) && (__p_GetComp(qq,r) != i)) pIter(qq);
3300  if (qq == q)
3301  {
3302  *k = i;
3303  return TRUE;
3304  }
3305  }
3306  pIter(q);
3307  }
3308  return FALSE;
3309 }

◆ p_WDegree()

long p_WDegree ( poly  p,
const ring  r 
)

Definition at line 704 of file p_polys.cc.

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

◆ p_Weight()

int p_Weight ( int  c,
const ring  r 
)

Definition at line 695 of file p_polys.cc.

696 {
697  if ((r->firstwv==NULL) || (i>r->firstBlockEnds))
698  {
699  return 1;
700  }
701  return r->firstwv[i-1];
702 }

◆ p_WFirstTotalDegree()

long p_WFirstTotalDegree ( poly  p,
ring  r 
)

Definition at line 586 of file p_polys.cc.

587 {
588  int i;
589  long sum = 0;
590 
591  for (i=1; i<= r->firstBlockEnds; i++)
592  {
593  sum += p_GetExp(p, i, r)*r->firstwv[i-1];
594  }
595  return sum;
596 }

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

1188 {
1189  p_Write(p, p_ring, p_ring);
1190 }

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

1192 {
1193  p_Write0(p, p_ring, p_ring);
1194 }
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 1195 of file p_polys.h.

1196 {
1197  p_wrp(p, p_ring, p_ring);
1198 }
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 603 of file p_polys.cc.

604 {
605  p_LmCheckPolyRing(p, r);
606  int i, k;
607  long j =0;
608 
609  // iterate through each block:
610  for (i=0;r->order[i]!=0;i++)
611  {
612  int b0=r->block0[i];
613  int b1=r->block1[i];
614  switch(r->order[i])
615  {
616  case ringorder_M:
617  for (k=b0 /*r->block0[i]*/;k<=b1 /*r->block1[i]*/;k++)
618  { // in jedem block:
619  j+= p_GetExp(p,k,r)*r->wvhdl[i][k - b0 /*r->block0[i]*/]*r->OrdSgn;
620  }
621  break;
622  case ringorder_am:
623  b1=si_min(b1,r->N);
624  /* no break, continue as ringorder_a*/
625  case ringorder_a:
626  for (k=b0 /*r->block0[i]*/;k<=b1 /*r->block1[i]*/;k++)
627  { // only one line
628  j+= p_GetExp(p,k,r)*r->wvhdl[i][k - b0 /*r->block0[i]*/];
629  }
630  return j*r->OrdSgn;
631  case ringorder_wp:
632  case ringorder_ws:
633  case ringorder_Wp:
634  case ringorder_Ws:
635  for (k=b0 /*r->block0[i]*/;k<=b1 /*r->block1[i]*/;k++)
636  { // in jedem block:
637  j+= p_GetExp(p,k,r)*r->wvhdl[i][k - b0 /*r->block0[i]*/];
638  }
639  break;
640  case ringorder_lp:
641  case ringorder_ls:
642  case ringorder_rs:
643  case ringorder_dp:
644  case ringorder_ds:
645  case ringorder_Dp:
646  case ringorder_Ds:
647  case ringorder_rp:
648  for (k=b0 /*r->block0[i]*/;k<=b1 /*r->block1[i]*/;k++)
649  {
650  j+= p_GetExp(p,k,r);
651  }
652  break;
653  case ringorder_a64:
654  {
655  int64* w=(int64*)r->wvhdl[i];
656  for (k=0;k<=(b1 /*r->block1[i]*/ - b0 /*r->block0[i]*/);k++)
657  {
658  //there should be added a line which checks if w[k]>2^31
659  j+= p_GetExp(p,k+1, r)*(long)w[k];
660  }
661  //break;
662  return j;
663  }
664  case ringorder_c: /* nothing to do*/
665  case ringorder_C: /* nothing to do*/
666  case ringorder_S: /* nothing to do*/
667  case ringorder_s: /* nothing to do*/
668  case ringorder_IS: /* nothing to do */
669  case ringorder_unspec: /* to make clang happy, does not occur*/
670  case ringorder_no: /* to make clang happy, does not occur*/
671  case ringorder_L: /* to make clang happy, does not occur*/
672  case ringorder_aa: /* ignored by p_WTotaldegree*/
673  break;
674  /* no default: all orderings covered */
675  }
676  }
677  return j;
678 }
long int64
Definition: auxiliary.h:68
for(int i=0;i<=n;i++) degsf[i]
Definition: cfEzgcd.cc:65
@ 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 3656 of file p_polys.cc.

3657 {
3658  poly* h;
3659 
3660  if (*p==NULL)
3661  {
3662  if (increment==0) return;
3663  h=(poly*)omAlloc0(increment*sizeof(poly));
3664  }
3665  else
3666  {
3667  h=(poly*)omReallocSize((poly*)*p,l*sizeof(poly),(l+increment)*sizeof(poly));
3668  if (increment>0)
3669  {
3670  memset(&(h[l]),0,increment*sizeof(poly));
3671  }
3672  }
3673  *p=h;
3674 }
#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 729 of file p_polys.cc.

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

◆ pLDeg0c()

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

Definition at line 760 of file p_polys.cc.

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

◆ pLDeg1()

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

Definition at line 831 of file p_polys.cc.

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

◆ pLDeg1_Deg()

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

Definition at line 900 of file p_polys.cc.

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

◆ pLDeg1_Totaldegree()

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

Definition at line 965 of file p_polys.cc.

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

◆ pLDeg1_WFirstTotalDegree()

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

Definition at line 1028 of file p_polys.cc.

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

◆ pLDeg1c()

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

Definition at line 867 of file p_polys.cc.

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

◆ pLDeg1c_Deg()

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

Definition at line 931 of file p_polys.cc.

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

◆ pLDeg1c_Totaldegree()

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

Definition at line 995 of file p_polys.cc.

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

◆ pLDeg1c_WFirstTotalDegree()

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

Definition at line 1058 of file p_polys.cc.

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

◆ pLDegb()

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

Definition at line 801 of file p_polys.cc.

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

◆ 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_Jet()

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

Definition at line 4264 of file p_polys.cc.

4265 {
4266  poly r=NULL;
4267  poly t=NULL;
4268 
4269  while (p!=NULL)
4270  {
4271  if (p_Totaldegree(p,R)<=m)
4272  {
4273  if (r==NULL)
4274  r=p_Head(p,R);
4275  else
4276  if (t==NULL)
4277  {
4278  pNext(r)=p_Head(p,R);
4279  t=pNext(r);
4280  }
4281  else
4282  {
4283  pNext(t)=p_Head(p,R);
4284  pIter(t);
4285  }
4286  }
4287  pIter(p);
4288  }
4289  return r;
4290 }

◆ pp_JetW()

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

Definition at line 4309 of file p_polys.cc.

4310 {
4311  poly r=NULL;
4312  poly t=NULL;
4313  while (p!=NULL)
4314  {
4315  if (totaldegreeWecart_IV(p,R,w)<=m)
4316  {
4317  if (r==NULL)
4318  r=p_Head(p,R);
4319  else
4320  if (t==NULL)
4321  {
4322  pNext(r)=p_Head(p,R);
4323  t=pNext(r);
4324  }
4325  else
4326  {
4327  pNext(t)=p_Head(p,R);
4328  pIter(t);
4329  }
4330  }
4331  pIter(p);
4332  }
4333  return r;
4334 }

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

1030 {
1031  int shorter;
1032  return r->p_Procs->pp_Mult_Coeff_mm_DivSelect(p, m, shorter, r);
1033 }

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

1038 {
1039  int shorter;
1040  poly pp = r->p_Procs->pp_Mult_Coeff_mm_DivSelect(p, m, shorter, r);
1041  lp -= shorter;
1042  return pp;
1043 }

◆ pp_Mult_mm()

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

Definition at line 990 of file p_polys.h.

991 {
992  if (p==NULL) return NULL;
993  if (p_LmIsConstant(m, r))
994  return __pp_Mult_nn(p, pGetCoeff(m), r);
995  else
996  return r->p_Procs->pp_Mult_mm(p, m, r);
997 }
#define __pp_Mult_nn(p, n, r)
Definition: p_polys.h:961

◆ pp_Mult_nn()

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

Definition at line 951 of file p_polys.h.

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

◆ pp_Mult_qq()

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

Definition at line 1090 of file p_polys.h.

1091 {
1092  if (p == NULL || q == NULL) return NULL;
1093 
1094  if (pNext(p) == NULL)
1095  {
1096  return r->p_Procs->pp_mm_Mult(q, p, r);
1097  }
1098 
1099  if (pNext(q) == NULL)
1100  {
1101  return r->p_Procs->pp_Mult_mm(p, q, r);
1102  }
1103 
1104  poly qq = q;
1105  if (p == q)
1106  qq = p_Copy(q, r);
1107 
1108  poly res;
1109 #ifdef HAVE_PLURAL
1110  if (rIsPluralRing(r))
1111  res = _nc_pp_Mult_qq(p, qq, r);
1112  else
1113 #endif
1114  res = _p_Mult_q(p, qq, 1, r);
1115 
1116  if (qq != q)
1117  p_Delete(&qq, r);
1118  return res;
1119 }
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 3609 of file p_polys.cc.

3610 {
3611  assume(old_FDeg != NULL && old_lDeg != NULL);
3612  r->pFDeg = old_FDeg;
3613  r->pLDeg = old_lDeg;
3614 }

◆ pReverse()

static poly pReverse ( poly  p)
inlinestatic

Definition at line 334 of file p_polys.h.

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

◆ pSetDegProcs()

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

Definition at line 3597 of file p_polys.cc.

3598 {
3599  assume(new_FDeg != NULL);
3600  r->pFDeg = new_FDeg;
3601 
3602  if (new_lDeg == NULL)
3603  new_lDeg = r->pLDegOrig;
3604 
3605  r->pLDeg = new_lDeg;
3606 }