My Project  debian-1:4.1.1-p2+ds-4build4
Macros | Functions
p_polys.h File Reference
#include "omalloc/omalloc.h"
#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)
 
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)
 
static poly p_Copy (poly p, const ring lmRing, const ring tailRing)
 
static void p_Delete (poly *p, const ring r)
 
static void p_Delete (poly *p, const ring lmRing, const ring tailRing)
 
static poly p_ShallowCopyDelete (poly p, const ring r, omBin bin)
 
static poly p_Add_q (poly p, poly q, const ring r)
 
static poly p_Add_q (poly p, poly q, int &lp, int lq, const ring r)
 like p_Add_q, except that if lp == pLength(lp) lq == pLength(lq) then lp == pLength(p+q) 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 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)
 
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)
 
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 927 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 958 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 1222 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 1654 of file p_polys.h.

◆ p_LmEqual

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

Definition at line 1658 of file p_polys.h.

◆ p_LmTest

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

Definition at line 164 of file p_polys.h.

◆ p_SetmComp

#define p_SetmComp   p_Setm

Definition at line 244 of file p_polys.h.

◆ p_Test

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

Definition at line 163 of file p_polys.h.

◆ pDivAssume

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

Definition at line 1228 of file p_polys.h.

◆ pIfThen

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

Definition at line 157 of file p_polys.h.

◆ pp_Test

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

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

1796 {
1797  if (p_GetComp(a, r_a) == 0 || p_GetComp(a,r_a) == p_GetComp(b,r_b))
1798  return _p_LmDivisibleByNoComp(a, r_a, b, r_b);
1799  return FALSE;
1800 }
#define FALSE
Definition: auxiliary.h:94
CanonicalForm b
Definition: cfModGcd.cc:4044
#define p_GetComp(p, r)
Definition: monomials.h:71
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:1685

◆ _p_LmDivisibleBy() [2/2]

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

Definition at line 1789 of file p_polys.h.

1790 {
1791  if (p_GetComp(a, r) == 0 || p_GetComp(a,r) == p_GetComp(b,r))
1792  return _p_LmDivisibleByNoComp(a, b, r);
1793  return FALSE;
1794 }

◆ _p_LmDivisibleByNoComp() [1/2]

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

Definition at line 1734 of file p_polys.h.

1735 {
1736  int i=r_a->N;
1737  pAssume1(r_a->N == r_b->N);
1738 
1739  do
1740  {
1741  if (p_GetExp(a,i,r_a) > p_GetExp(b,i,r_b))
1742  return FALSE;
1743  i--;
1744  }
1745  while (i);
1746 /*#ifdef HAVE_RINGS
1747  return n_DivBy(p_GetCoeff(b, r_b), p_GetCoeff(a, r_a), r_a->cf);
1748 #else
1749 */
1750  return TRUE;
1751 //#endif
1752 }
#define TRUE
Definition: auxiliary.h:98
int i
Definition: cfEzgcd.cc:125
#define pAssume1(cond)
Definition: monomials.h:178
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent @Note: the integer VarOffset encodes:
Definition: p_polys.h:469

◆ _p_LmDivisibleByNoComp() [2/2]

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

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

Definition at line 1685 of file p_polys.h.

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

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

1756 {
1757  int i=end;
1758  pAssume1(r_a->N == r_b->N);
1759 
1760  do
1761  {
1762  if (p_GetExp(a,i,r_a) > p_GetExp(b,i,r_b))
1763  return FALSE;
1764  i--;
1765  }
1766  while (i>=start);
1767 /*#ifdef HAVE_RINGS
1768  return n_DivBy(p_GetCoeff(b, r_b), p_GetCoeff(a, r_a), r_a->cf);
1769 #else
1770 */
1771  return TRUE;
1772 //#endif
1773 }

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

1775 {
1776  if (p_GetComp(a, r_a) == 0 || p_GetComp(a,r_a) == p_GetComp(b,r_b))
1777  return _p_LmDivisibleByNoCompPart(a, r_a, b, r_b,start,end);
1778  return FALSE;
1779 }
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:1755

◆ _p_LmTest()

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

Definition at line 323 of file pDebug.cc.

324 {
325  if (level < 0 || p == NULL) return TRUE;
326  poly pnext = pNext(p);
327  pNext(p) = NULL;
328  BOOLEAN test_res = _p_Test(p, r, level);
329  pNext(p) = pnext;
330  return test_res;
331 }
int BOOLEAN
Definition: auxiliary.h:85
int level(const CanonicalForm &f)
#define pNext(p)
Definition: monomials.h:43
#define NULL
Definition: omList.c:10
BOOLEAN _p_Test(poly p, ring r, int level)
Definition: pDebug.cc:212

◆ _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:525
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:770
CFArray copy(const CFList &list)
write elements of list into an array
static Poly * h
Definition: janet.cc:972
#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:104
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:857
static unsigned pLength(poly a)
Definition: p_polys.h:192

◆ _p_Test()

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

Definition at line 212 of file pDebug.cc.

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

◆ _pp_Test()

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

Definition at line 333 of file pDebug.cc.

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

◆ n_PermNumber()

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

Definition at line 3910 of file p_polys.cc.

3911 {
3912 #if 0
3913  PrintS("\nSource Ring: \n");
3914  rWrite(src);
3915 
3916  if(0)
3917  {
3918  number zz = n_Copy(z, src->cf);
3919  PrintS("z: "); n_Write(zz, src);
3920  n_Delete(&zz, src->cf);
3921  }
3922 
3923  PrintS("\nDestination Ring: \n");
3924  rWrite(dst);
3925 
3926  /*Print("\nOldPar: %d\n", OldPar);
3927  for( int i = 1; i <= OldPar; i++ )
3928  {
3929  Print("par(%d) -> par/var (%d)\n", i, par_perm[i-1]);
3930  }*/
3931 #endif
3932  if( z == NULL )
3933  return NULL;
3934 
3935  const coeffs srcCf = src->cf;
3936  assume( srcCf != NULL );
3937 
3938  assume( !nCoeff_is_GF(srcCf) );
3939  assume( src->cf->extRing!=NULL );
3940 
3941  poly zz = NULL;
3942 
3943  const ring srcExtRing = srcCf->extRing;
3944  assume( srcExtRing != NULL );
3945 
3946  const coeffs dstCf = dst->cf;
3947  assume( dstCf != NULL );
3948 
3949  if( nCoeff_is_algExt(srcCf) ) // nCoeff_is_GF(srcCf)?
3950  {
3951  zz = (poly) z;
3952  if( zz == NULL ) return NULL;
3953  }
3954  else if (nCoeff_is_transExt(srcCf))
3955  {
3956  assume( !IS0(z) );
3957 
3958  zz = NUM((fraction)z);
3959  p_Test (zz, srcExtRing);
3960 
3961  if( zz == NULL ) return NULL;
3962  if( !DENIS1((fraction)z) )
3963  {
3964  if (!p_IsConstant(DEN((fraction)z),srcExtRing))
3965  WarnS("Not defined: Cannot map a rational fraction and make a polynomial out of it! Ignoring the denominator.");
3966  }
3967  }
3968  else
3969  {
3970  assume (FALSE);
3971  WerrorS("Number permutation is not implemented for this data yet!");
3972  return NULL;
3973  }
3974 
3975  assume( zz != NULL );
3976  p_Test (zz, srcExtRing);
3977 
3978  nMapFunc nMap = n_SetMap(srcExtRing->cf, dstCf);
3979 
3980  assume( nMap != NULL );
3981 
3982  poly qq;
3983  if ((par_perm == NULL) && (rPar(dst) != 0 && rVar (srcExtRing) > 0))
3984  {
3985  int* perm;
3986  perm=(int *)omAlloc0((rVar(srcExtRing)+1)*sizeof(int));
3987  perm[0]= 0;
3988  for(int i=si_min(rVar(srcExtRing),rPar(dst));i>0;i--)
3989  perm[i]=-i;
3990  qq = p_PermPoly(zz, perm, srcExtRing, dst, nMap, NULL, rVar(srcExtRing)-1);
3991  omFreeSize ((ADDRESS)perm, (rVar(srcExtRing)+1)*sizeof(int));
3992  }
3993  else
3994  qq = p_PermPoly(zz, par_perm-1, srcExtRing, dst, nMap, NULL, rVar (srcExtRing)-1);
3995 
3996  if(nCoeff_is_transExt(srcCf)
3997  && (!DENIS1((fraction)z))
3998  && p_IsConstant(DEN((fraction)z),srcExtRing))
3999  {
4000  number n=nMap(pGetCoeff(DEN((fraction)z)),srcExtRing->cf, dstCf);
4001  qq=p_Div_nn(qq,n,dst);
4002  n_Delete(&n,dstCf);
4003  p_Normalize(qq,dst);
4004  }
4005  p_Test (qq, dst);
4006 
4007  return qq;
4008 }
void * ADDRESS
Definition: auxiliary.h:133
static int si_min(const int a, const int b)
Definition: auxiliary.h:139
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of 'n'
Definition: coeffs.h:452
static FORCE_INLINE BOOLEAN nCoeff_is_GF(const coeffs r)
Definition: coeffs.h:853
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:722
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:456
static FORCE_INLINE void n_Write(number n, const coeffs r, const BOOLEAN bShortOut=TRUE)
Definition: coeffs.h:592
static FORCE_INLINE BOOLEAN nCoeff_is_algExt(const coeffs r)
TRUE iff r represents an algebraic extension field.
Definition: coeffs.h:924
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:74
static FORCE_INLINE BOOLEAN nCoeff_is_transExt(const coeffs r)
TRUE iff r represents a transcendental extension field.
Definition: coeffs.h:932
#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:51
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:4014
poly p_Div_nn(poly p, const number n, const ring r)
Definition: p_polys.cc:1467
void p_Normalize(poly p, const ring r)
Definition: p_polys.cc:3709
static BOOLEAN p_IsConstant(const poly p, const ring r)
Definition: p_polys.h:1923
#define p_Test(p, r)
Definition: p_polys.h:163
void PrintS(const char *s)
Definition: reporter.cc:284
void rWrite(ring r, BOOLEAN details)
Definition: ring.cc:227
static int rPar(const ring r)
(r->cf->P)
Definition: ring.h:590
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:583

◆ p_Add_q() [1/2]

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

Definition at line 892 of file p_polys.h.

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

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

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

◆ p_AddComp()

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

Definition at line 447 of file p_polys.h.

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

◆ p_AddExp()

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

Definition at line 606 of file p_polys.h.

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

◆ p_CheckIsFromRing()

BOOLEAN p_CheckIsFromRing ( poly  p,
ring  r 
)

Definition at line 102 of file pDebug.cc.

103 {
104  while (p!=NULL)
105  {
107  pIter(p);
108  }
109  return TRUE;
110 }

◆ p_CheckPolyRing()

BOOLEAN p_CheckPolyRing ( poly  p,
ring  r 
)

Definition at line 112 of file pDebug.cc.

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

◆ p_CheckRing()

BOOLEAN p_CheckRing ( ring  r)

Definition at line 128 of file pDebug.cc.

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

◆ p_ChineseRemainder()

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

Definition at line 85 of file p_polys.cc.

86 {
87  poly r,h,hh;
88  int j;
89  poly res_p=NULL;
90  loop
91  {
92  /* search the lead term */
93  r=NULL;
94  for(j=rl-1;j>=0;j--)
95  {
96  h=xx[j];
97  if ((h!=NULL)
98  &&((r==NULL)||(p_LmCmp(r,h,R)==-1)))
99  r=h;
100  }
101  /* nothing found -> return */
102  if (r==NULL) break;
103  /* create the monomial in h */
104  h=p_Head(r,R);
105  /* collect the coeffs in x[..]*/
106  for(j=rl-1;j>=0;j--)
107  {
108  hh=xx[j];
109  if ((hh!=NULL) && (p_LmCmp(h,hh,R)==0))
110  {
111  x[j]=pGetCoeff(hh);
112  hh=p_LmFreeAndNext(hh,R);
113  xx[j]=hh;
114  }
115  else
116  x[j]=n_Init(0, R->cf);
117  }
118  number n=n_ChineseRemainderSym(x,q,rl,TRUE,inv_cache,R->cf);
119  for(j=rl-1;j>=0;j--)
120  {
121  x[j]=NULL; // n_Init(0...) takes no memory
122  }
123  if (n_IsZero(n,R->cf)) p_Delete(&h,R);
124  else
125  {
126  //Print("new mon:");pWrite(h);
127  p_SetCoeff(h,n,R);
128  pNext(h)=res_p;
129  res_p=h; // building res_p in reverse order!
130  }
131  }
132  res_p=pReverse(res_p);
133  p_Test(res_p, R);
134  return res_p;
135 }
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:795
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition: coeffs.h:539
int j
Definition: facHensel.cc:105
static poly p_Head(poly p, const ring r)
Definition: p_polys.h:825
static number p_SetCoeff(poly p, number n, ring r)
Definition: p_polys.h:412
static poly pReverse(poly p)
Definition: p_polys.h:335
static poly p_LmFreeAndNext(poly p, ring)
Definition: p_polys.h:703
#define R
Definition: sirandom.c:26
#define loop
Definition: structs.h:78

◆ p_Cleardenom()

poly p_Cleardenom ( poly  p,
const ring  r 
)

Definition at line 2782 of file p_polys.cc.

2783 {
2784  if( p == NULL )
2785  return NULL;
2786 
2787  assume( r != NULL ); assume( r->cf != NULL ); const coeffs C = r->cf;
2788 
2789 #if CLEARENUMERATORS
2790  if( 0 )
2791  {
2792  CPolyCoeffsEnumerator itr(p);
2793  n_ClearDenominators(itr, C);
2794  n_ClearContent(itr, C); // divide out the content
2795  p_Test(p, r); n_Test(pGetCoeff(p), C);
2796  assume(n_GreaterZero(pGetCoeff(p), C)); // ??
2797 // if(!n_GreaterZero(pGetCoeff(p),C)) p = p_Neg(p,r);
2798  return p;
2799  }
2800 #endif
2801 
2802  number d, h;
2803 
2804  if (rField_is_Ring(r))
2805  {
2806  p_ContentForGB(p,r);
2807  if(!n_GreaterZero(pGetCoeff(p),C)) p = p_Neg(p,r);
2808  return p;
2809  }
2810 
2812  {
2813  if(!n_GreaterZero(pGetCoeff(p),C)) p = p_Neg(p,r);
2814  return p;
2815  }
2816 
2817  assume(p != NULL);
2818 
2819  if(pNext(p)==NULL)
2820  {
2821  if (!TEST_OPT_CONTENTSB
2822  && !rField_is_Ring(r))
2823  p_SetCoeff(p,n_Init(1,r->cf),r);
2824  else if(!n_GreaterZero(pGetCoeff(p),C))
2825  p = p_Neg(p,r);
2826  return p;
2827  }
2828 
2829  assume(pNext(p)!=NULL);
2830  poly start=p;
2831 
2832 #if 0 && CLEARENUMERATORS
2833 //CF: does not seem to work that well..
2834 
2835  if( nCoeff_is_Q(C) || nCoeff_is_Q_a(C) )
2836  {
2837  CPolyCoeffsEnumerator itr(p);
2838  n_ClearDenominators(itr, C);
2839  n_ClearContent(itr, C); // divide out the content
2840  p_Test(p, r); n_Test(pGetCoeff(p), C);
2841  assume(n_GreaterZero(pGetCoeff(p), C)); // ??
2842 // if(!n_GreaterZero(pGetCoeff(p),C)) p = p_Neg(p,r);
2843  return start;
2844  }
2845 #endif
2846 
2847  if(1)
2848  {
2849  // get lcm of all denominators ----------------------------------
2850  h = n_Init(1,r->cf);
2851  while (p!=NULL)
2852  {
2853  n_Normalize(pGetCoeff(p),r->cf);
2854  d=n_NormalizeHelper(h,pGetCoeff(p),r->cf);
2855  n_Delete(&h,r->cf);
2856  h=d;
2857  pIter(p);
2858  }
2859  /* h now contains the 1/lcm of all denominators */
2860  if(!n_IsOne(h,r->cf))
2861  {
2862  // multiply by the lcm of all denominators
2863  p = start;
2864  while (p!=NULL)
2865  {
2866  d=n_Mult(h,pGetCoeff(p),r->cf);
2867  n_Normalize(d,r->cf);
2868  p_SetCoeff(p,d,r);
2869  pIter(p);
2870  }
2871  }
2872  n_Delete(&h,r->cf);
2873  p=start;
2874 
2875  p_ContentForGB(p,r);
2876 #ifdef HAVE_RATGRING
2877  if (rIsRatGRing(r))
2878  {
2879  /* quick unit detection in the rational case is done in gr_nc_bba */
2880  p_ContentRat(p, r);
2881  start=p;
2882  }
2883 #endif
2884  }
2885 
2886  if(!n_GreaterZero(pGetCoeff(p),C)) p = p_Neg(p,r);
2887 
2888  return start;
2889 }
This is a polynomial enumerator for simple iteration over coefficients of polynomials.
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of 'a' and 'b', i.e., a*b
Definition: coeffs.h:637
static FORCE_INLINE number n_NormalizeHelper(number a, number b, const coeffs r)
assume that r is a quotient field (otherwise, return 1) for arguments (a1/a2,b1/b2) return (lcm(a1,...
Definition: coeffs.h:718
static FORCE_INLINE BOOLEAN n_GreaterZero(number n, const coeffs r)
ordered fields: TRUE iff 'n' is positive; in Z/pZ: TRUE iff 0 < m <= roundedBelow(p/2),...
Definition: coeffs.h:495
static FORCE_INLINE BOOLEAN nCoeff_is_Q(const coeffs r)
Definition: coeffs.h:837
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:949
static FORCE_INLINE BOOLEAN nCoeff_is_Q_a(const coeffs r)
Definition: coeffs.h:899
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:942
static FORCE_INLINE void n_Normalize(number &n, const coeffs r)
inplace-normalization of n; produces some canonical representation of n;
Definition: coeffs.h:579
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff 'n' represents the one element.
Definition: coeffs.h:469
#define TEST_OPT_INTSTRATEGY
Definition: options.h:109
#define TEST_OPT_CONTENTSB
Definition: options.h:125
void p_ContentRat(poly &ph, const ring r)
Definition: p_polys.cc:1691
void p_ContentForGB(poly ph, const ring r)
Definition: p_polys.cc:2283
static poly p_Neg(poly p, const ring r)
Definition: p_polys.h:1043
static BOOLEAN rField_is_Ring(const ring r)
Definition: ring.h:477
static BOOLEAN rField_is_Zp(const ring r)
Definition: ring.h:495
static BOOLEAN rIsRatGRing(const ring r)
Definition: ring.h:415

◆ p_Cleardenom_n()

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

Definition at line 2891 of file p_polys.cc.

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

◆ p_Cmp()

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

Definition at line 1662 of file p_polys.h.

1663 {
1664  if (p2==NULL)
1665  return 1;
1666  if (p1==NULL)
1667  return -1;
1668  return p_LmCmp(p1,p2,r);
1669 }

◆ p_Comp_k_n()

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

Definition at line 640 of file p_polys.h.

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

◆ p_Compare()

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

Definition at line 4790 of file p_polys.cc.

4791 {
4792  int r=p_Cmp(a,b,R);
4793  if ((r==0)&&(a!=NULL))
4794  {
4795  number h=n_Sub(pGetCoeff(a),pGetCoeff(b),R->cf);
4796  /* compare lead coeffs */
4797  r = -1+n_IsZero(h,R->cf)+2*n_GreaterZero(h,R->cf); /* -1: <, 0:==, 1: > */
4798  n_Delete(&h,R->cf);
4799  }
4800  else if (a==NULL)
4801  {
4802  if (b==NULL)
4803  {
4804  /* compare 0, 0 */
4805  r=0;
4806  }
4807  else if(p_IsConstant(b,R))
4808  {
4809  /* compare 0, const */
4810  r = 1-2*n_GreaterZero(pGetCoeff(b),R->cf); /* -1: <, 1: > */
4811  }
4812  }
4813  else if (b==NULL)
4814  {
4815  if (p_IsConstant(a,R))
4816  {
4817  /* compare const, 0 */
4818  r = -1+2*n_GreaterZero(pGetCoeff(a),R->cf); /* -1: <, 1: > */
4819  }
4820  }
4821  return(r);
4822 }
static FORCE_INLINE number n_Sub(number a, number b, const coeffs r)
return the difference of 'a' and 'b', i.e., a-b
Definition: coeffs.h:670
static int p_Cmp(poly p1, poly p2, ring r)
Definition: p_polys.h:1662

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

4461 {
4462  number n,nn;
4463  pAssume(p1 != NULL && p2 != NULL);
4464 
4465  if (!p_LmEqual(p1,p2,r)) //compare leading mons
4466  return FALSE;
4467  if ((pNext(p1)==NULL) && (pNext(p2)!=NULL))
4468  return FALSE;
4469  if ((pNext(p2)==NULL) && (pNext(p1)!=NULL))
4470  return FALSE;
4471  if (pLength(p1) != pLength(p2))
4472  return FALSE;
4473  #ifdef HAVE_RINGS
4474  if (rField_is_Ring(r))
4475  {
4476  if (!n_DivBy(pGetCoeff(p1), pGetCoeff(p2), r->cf)) return FALSE;
4477  }
4478  #endif
4479  n=n_Div(pGetCoeff(p1),pGetCoeff(p2),r->cf);
4480  while ((p1 != NULL) /*&& (p2 != NULL)*/)
4481  {
4482  if ( ! p_LmEqual(p1, p2,r))
4483  {
4484  n_Delete(&n, r->cf);
4485  return FALSE;
4486  }
4487  if (!n_Equal(pGetCoeff(p1), nn = n_Mult(pGetCoeff(p2),n, r->cf), r->cf))
4488  {
4489  n_Delete(&n, r->cf);
4490  n_Delete(&nn, r->cf);
4491  return FALSE;
4492  }
4493  n_Delete(&nn, r->cf);
4494  pIter(p1);
4495  pIter(p2);
4496  }
4497  n_Delete(&n, r->cf);
4498  return TRUE;
4499 }
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:784
static FORCE_INLINE BOOLEAN n_Equal(number a, number b, const coeffs r)
TRUE iff 'a' and 'b' represent the same number; they may have different representations.
Definition: coeffs.h:461
#define pAssume(cond)
Definition: monomials.h:97
#define p_LmEqual(p1, p2, r)
Definition: p_polys.h:1658

◆ p_Content()

void p_Content ( poly  p,
const ring  r 
)

Definition at line 2238 of file p_polys.cc.

2239 {
2240  if (ph==NULL) return;
2241  const coeffs cf=r->cf;
2242  if (pNext(ph)==NULL)
2243  {
2244  p_SetCoeff(ph,n_Init(1,cf),r);
2245  }
2246  if (cf->cfSubringGcd==ndGcd) /* trivial gcd*/ return;
2247  number h=p_InitContent(ph,r); /* first guess of a gcd of all coeffs */
2248  poly p;
2249  if(n_IsOne(h,cf))
2250  {
2251  goto content_finish;
2252  }
2253  p=ph;
2254  // take the SubringGcd of all coeffs
2255  while (p!=NULL)
2256  {
2258  number d=n_SubringGcd(h,pGetCoeff(p),cf);
2259  n_Delete(&h,cf);
2260  h = d;
2261  if(n_IsOne(h,cf))
2262  {
2263  goto content_finish;
2264  }
2265  pIter(p);
2266  }
2267  // if found<>1, divide by it
2268  p = ph;
2269  while (p!=NULL)
2270  {
2271  number d = n_ExactDiv(pGetCoeff(p),h,cf);
2272  p_SetCoeff(p,d,r);
2273  pIter(p);
2274  }
2275 content_finish:
2276  n_Delete(&h,r->cf);
2277  // and last: check leading sign:
2278  if(!n_GreaterZero(pGetCoeff(ph),r->cf)) ph = p_Neg(ph,r);
2279 }
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:623
static FORCE_INLINE number n_SubringGcd(number a, number b, const coeffs r)
Definition: coeffs.h:689
number ndGcd(number, number, const coeffs r)
Definition: numbers.cc:161
number p_InitContent(poly ph, const ring r)
Definition: p_polys.cc:2549

◆ p_ContentForGB()

void p_ContentForGB ( poly  p,
const ring  r 
)

Definition at line 2283 of file p_polys.cc.

2284 {
2285  if(TEST_OPT_CONTENTSB) return;
2286  assume( ph != NULL );
2287 
2288  assume( r != NULL ); assume( r->cf != NULL );
2289 
2290 
2291 #if CLEARENUMERATORS
2292  if( 0 )
2293  {
2294  const coeffs C = r->cf;
2295  // experimentall (recursive enumerator treatment) of alg. Ext!
2296  CPolyCoeffsEnumerator itr(ph);
2297  n_ClearContent(itr, r->cf);
2298 
2299  p_Test(ph, r); n_Test(pGetCoeff(ph), C);
2300  assume(n_GreaterZero(pGetCoeff(ph), C)); // ??
2301 
2302  // if(!n_GreaterZero(pGetCoeff(ph),r->cf)) ph = p_Neg(ph,r);
2303  return;
2304  }
2305 #endif
2306 
2307 
2308 #ifdef HAVE_RINGS
2309  if (rField_is_Ring(r))
2310  {
2311  if (rField_has_Units(r))
2312  {
2313  number k = n_GetUnit(pGetCoeff(ph),r->cf);
2314  if (!n_IsOne(k,r->cf))
2315  {
2316  number tmpGMP = k;
2317  k = n_Invers(k,r->cf);
2318  n_Delete(&tmpGMP,r->cf);
2319  poly h = pNext(ph);
2320  p_SetCoeff(ph, n_Mult(pGetCoeff(ph), k,r->cf),r);
2321  while (h != NULL)
2322  {
2323  p_SetCoeff(h, n_Mult(pGetCoeff(h), k,r->cf),r);
2324  pIter(h);
2325  }
2326 // assume( n_GreaterZero(pGetCoeff(ph),r->cf) );
2327 // if(!n_GreaterZero(pGetCoeff(ph),r->cf)) ph = p_Neg(ph,r);
2328  }
2329  n_Delete(&k,r->cf);
2330  }
2331  return;
2332  }
2333 #endif
2334  number h,d;
2335  poly p;
2336 
2337  if(pNext(ph)==NULL)
2338  {
2339  p_SetCoeff(ph,n_Init(1,r->cf),r);
2340  }
2341  else
2342  {
2343  assume( pNext(ph) != NULL );
2344 #if CLEARENUMERATORS
2345  if( nCoeff_is_Q(r->cf) )
2346  {
2347  // experimentall (recursive enumerator treatment) of alg. Ext!
2348  CPolyCoeffsEnumerator itr(ph);
2349  n_ClearContent(itr, r->cf);
2350 
2351  p_Test(ph, r); n_Test(pGetCoeff(ph), r->cf);
2352  assume(n_GreaterZero(pGetCoeff(ph), r->cf)); // ??
2353 
2354  // if(!n_GreaterZero(pGetCoeff(ph),r->cf)) ph = p_Neg(ph,r);
2355  return;
2356  }
2357 #endif
2358 
2359  n_Normalize(pGetCoeff(ph),r->cf);
2360  if(!n_GreaterZero(pGetCoeff(ph),r->cf)) ph = p_Neg(ph,r);
2361  if (rField_is_Q(r)||(getCoeffType(r->cf)==n_transExt)) // should not be used anymore if CLEARENUMERATORS is 1
2362  {
2363  h=p_InitContent(ph,r);
2364  p=ph;
2365  }
2366  else
2367  {
2368  h=n_Copy(pGetCoeff(ph),r->cf);
2369  p = pNext(ph);
2370  }
2371  while (p!=NULL)
2372  {
2373  n_Normalize(pGetCoeff(p),r->cf);
2374  d=n_SubringGcd(h,pGetCoeff(p),r->cf);
2375  n_Delete(&h,r->cf);
2376  h = d;
2377  if(n_IsOne(h,r->cf))
2378  {
2379  break;
2380  }
2381  pIter(p);
2382  }
2383  //number tmp;
2384  if(!n_IsOne(h,r->cf))
2385  {
2386  p = ph;
2387  while (p!=NULL)
2388  {
2389  //d = nDiv(pGetCoeff(p),h);
2390  //tmp = nExactDiv(pGetCoeff(p),h);
2391  //if (!nEqual(d,tmp))
2392  //{
2393  // StringSetS("** div0:");nWrite(pGetCoeff(p));StringAppendS("/");
2394  // nWrite(h);StringAppendS("=");nWrite(d);StringAppendS(" int:");
2395  // nWrite(tmp);Print(StringEndS("\n")); // NOTE/TODO: use StringAppendS("\n"); omFree(s);
2396  //}
2397  //nDelete(&tmp);
2398  d = n_ExactDiv(pGetCoeff(p),h,r->cf);
2399  p_SetCoeff(p,d,r);
2400  pIter(p);
2401  }
2402  }
2403  n_Delete(&h,r->cf);
2404  if (rField_is_Q_a(r))
2405  {
2406  // special handling for alg. ext.:
2407  if (getCoeffType(r->cf)==n_algExt)
2408  {
2409  h = n_Init(1, r->cf->extRing->cf);
2410  p=ph;
2411  while (p!=NULL)
2412  { // each monom: coeff in Q_a
2413  poly c_n_n=(poly)pGetCoeff(p);
2414  poly c_n=c_n_n;
2415  while (c_n!=NULL)
2416  { // each monom: coeff in Q
2417  d=n_NormalizeHelper(h,pGetCoeff(c_n),r->cf->extRing->cf);
2418  n_Delete(&h,r->cf->extRing->cf);
2419  h=d;
2420  pIter(c_n);
2421  }
2422  pIter(p);
2423  }
2424  /* h contains the 1/lcm of all denominators in c_n_n*/
2425  //n_Normalize(h,r->cf->extRing->cf);
2426  if(!n_IsOne(h,r->cf->extRing->cf))
2427  {
2428  p=ph;
2429  while (p!=NULL)
2430  { // each monom: coeff in Q_a
2431  poly c_n=(poly)pGetCoeff(p);
2432  while (c_n!=NULL)
2433  { // each monom: coeff in Q
2434  d=n_Mult(h,pGetCoeff(c_n),r->cf->extRing->cf);
2435  n_Normalize(d,r->cf->extRing->cf);
2436  n_Delete(&pGetCoeff(c_n),r->cf->extRing->cf);
2437  pGetCoeff(c_n)=d;
2438  pIter(c_n);
2439  }
2440  pIter(p);
2441  }
2442  }
2443  n_Delete(&h,r->cf->extRing->cf);
2444  }
2445  /*else
2446  {
2447  // special handling for rat. functions.:
2448  number hzz =NULL;
2449  p=ph;
2450  while (p!=NULL)
2451  { // each monom: coeff in Q_a (Z_a)
2452  fraction f=(fraction)pGetCoeff(p);
2453  poly c_n=NUM(f);
2454  if (hzz==NULL)
2455  {
2456  hzz=n_Copy(pGetCoeff(c_n),r->cf->extRing->cf);
2457  pIter(c_n);
2458  }
2459  while ((c_n!=NULL)&&(!n_IsOne(hzz,r->cf->extRing->cf)))
2460  { // each monom: coeff in Q (Z)
2461  d=n_Gcd(hzz,pGetCoeff(c_n),r->cf->extRing->cf);
2462  n_Delete(&hzz,r->cf->extRing->cf);
2463  hzz=d;
2464  pIter(c_n);
2465  }
2466  pIter(p);
2467  }
2468  // hzz contains the gcd of all numerators in f
2469  h=n_Invers(hzz,r->cf->extRing->cf);
2470  n_Delete(&hzz,r->cf->extRing->cf);
2471  n_Normalize(h,r->cf->extRing->cf);
2472  if(!n_IsOne(h,r->cf->extRing->cf))
2473  {
2474  p=ph;
2475  while (p!=NULL)
2476  { // each monom: coeff in Q_a (Z_a)
2477  fraction f=(fraction)pGetCoeff(p);
2478  NUM(f)=__p_Mult_nn(NUM(f),h,r->cf->extRing);
2479  p_Normalize(NUM(f),r->cf->extRing);
2480  pIter(p);
2481  }
2482  }
2483  n_Delete(&h,r->cf->extRing->cf);
2484  }*/
2485  }
2486  }
2487  if(!n_GreaterZero(pGetCoeff(ph),r->cf)) ph = p_Neg(ph,r);
2488 }
@ n_algExt
used for all algebraic extensions, i.e., the top-most extension in an extension tower is algebraic
Definition: coeffs.h:36
@ n_transExt
used for all transcendental extensions, i.e., the top-most extension in an extension tower is transce...
Definition: coeffs.h:39
static FORCE_INLINE number n_GetUnit(number n, const coeffs r)
in Z: 1 in Z/kZ (where k is not a prime): largest divisor of n (taken in Z) that is co-prime with k i...
Definition: coeffs.h:533
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:422
static BOOLEAN rField_is_Q(const ring r)
Definition: ring.h:501
static BOOLEAN rField_has_Units(const ring r)
Definition: ring.h:483

◆ p_ContentRat()

void p_ContentRat ( poly &  ph,
const ring  r 
)

Definition at line 1691 of file p_polys.cc.

1694 {
1695  // init array of RatLeadCoeffs
1696  // poly p_GetCoeffRat(poly p, int ishift, ring r);
1697 
1698  int len=pLength(ph);
1699  poly *C = (poly *)omAlloc0((len+1)*sizeof(poly)); //rat coeffs
1700  poly *LM = (poly *)omAlloc0((len+1)*sizeof(poly)); // rat lead terms
1701  int *D = (int *)omAlloc0((len+1)*sizeof(int)); //degrees of coeffs
1702  int *L = (int *)omAlloc0((len+1)*sizeof(int)); //lengths of coeffs
1703  int k = 0;
1704  poly p = p_Copy(ph, r); // ph will be needed below
1705  int mintdeg = p_Totaldegree(p, r);
1706  int minlen = len;
1707  int dd = 0; int i;
1708  int HasConstantCoef = 0;
1709  int is = r->real_var_start - 1;
1710  while (p!=NULL)
1711  {
1712  LM[k] = p_GetExp_k_n(p,1,is, r); // need LmRat istead of p_HeadRat(p, is, currRing); !
1713  C[k] = p_GetCoeffRat(p, is, r);
1714  D[k] = p_Totaldegree(C[k], r);
1715  mintdeg = si_min(mintdeg,D[k]);
1716  L[k] = pLength(C[k]);
1717  minlen = si_min(minlen,L[k]);
1718  if (p_IsConstant(C[k], r))
1719  {
1720  // C[k] = const, so the content will be numerical
1721  HasConstantCoef = 1;
1722  // smth like goto cleanup and return(pContent(p));
1723  }
1724  p_LmDeleteAndNextRat(&p, is, r);
1725  k++;
1726  }
1727 
1728  // look for 1 element of minimal degree and of minimal length
1729  k--;
1730  poly d;
1731  int mindeglen = len;
1732  if (k<=0) // this poly is not a ratgring poly -> pContent
1733  {
1734  p_Delete(&C[0], r);
1735  p_Delete(&LM[0], r);
1736  p_ContentForGB(ph, r);
1737  goto cleanup;
1738  }
1739 
1740  int pmindeglen;
1741  for(i=0; i<=k; i++)
1742  {
1743  if (D[i] == mintdeg)
1744  {
1745  if (L[i] < mindeglen)
1746  {
1747  mindeglen=L[i];
1748  pmindeglen = i;
1749  }
1750  }
1751  }
1752  d = p_Copy(C[pmindeglen], r);
1753  // there are dd>=1 mindeg elements
1754  // and pmideglen is the coordinate of one of the smallest among them
1755 
1756  // poly g = singclap_gcd(p_Copy(p,r),p_Copy(q,r));
1757  // return naGcd(d,d2,currRing);
1758 
1759  // adjoin pContentRat here?
1760  for(i=0; i<=k; i++)
1761  {
1762  d=singclap_gcd(d,p_Copy(C[i], r), r);
1763  if (p_Totaldegree(d, r)==0)
1764  {
1765  // cleanup, pContent, return
1766  p_Delete(&d, r);
1767  for(;k>=0;k--)
1768  {
1769  p_Delete(&C[k], r);
1770  p_Delete(&LM[k], r);
1771  }
1772  p_ContentForGB(ph, r);
1773  goto cleanup;
1774  }
1775  }
1776  for(i=0; i<=k; i++)
1777  {
1778  poly h=singclap_pdivide(C[i],d, r);
1779  p_Delete(&C[i], r);
1780  C[i]=h;
1781  }
1782 
1783  // zusammensetzen,
1784  p=NULL; // just to be sure
1785  for(i=0; i<=k; i++)
1786  {
1787  p = p_Add_q(p, p_Mult_q(C[i],LM[i], r), r);
1788  C[i]=NULL; LM[i]=NULL;
1789  }
1790  p_Delete(&ph, r); // do not need it anymore
1791  ph = p;
1792  // aufraeumen, return
1793 cleanup:
1794  omFree(C);
1795  omFree(LM);
1796  omFree(D);
1797  omFree(L);
1798 }
poly singclap_pdivide(poly f, poly g, const ring r)
Definition: clapsing.cc:577
poly singclap_gcd(poly f, poly g, const ring r)
destroys f and g
Definition: clapsing.cc:255
#define D(A)
Definition: gentable.cc:129
#define omFree(addr)
Definition: omAllocDecl.h:261
void p_LmDeleteAndNextRat(poly *p, int ishift, ring r)
Definition: p_polys.cc:1647
poly p_GetCoeffRat(poly p, int ishift, ring r)
Definition: p_polys.cc:1669
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:892
static poly p_Mult_q(poly p, poly q, const ring r)
Definition: p_polys.h:1050
static poly p_GetExp_k_n(poly p, int l, int k, const ring r)
Definition: p_polys.h:1318
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:812
static long p_Totaldegree(poly p, const ring r)
Definition: p_polys.h:1453

◆ p_Copy() [1/2]

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

Definition at line 839 of file p_polys.h.

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

◆ p_Copy() [2/2]

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

returns a copy of p

Definition at line 812 of file p_polys.h.

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

◆ p_Copy_noCheck()

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

returns a copy of p (without any additional testing)

Definition at line 802 of file p_polys.h.

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

◆ p_DecrExp()

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

Definition at line 598 of file p_polys.h.

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

◆ p_Deg()

long p_Deg ( poly  a,
const ring  r 
)

Definition at line 579 of file p_polys.cc.

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

◆ p_DegW()

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

Definition at line 682 of file p_polys.cc.

683 {
684  p_Test(p, R);
685  assume( w != NULL );
686  long r=-LONG_MAX;
687 
688  while (p!=NULL)
689  {
690  long t=totaldegreeWecart_IV(p,R,w);
691  if (t>r) r=t;
692  pIter(p);
693  }
694  return r;
695 }
const CanonicalForm & w
Definition: facAbsFact.cc:55
long totaldegreeWecart_IV(poly p, ring r, const short *w)
Definition: weight.cc:237

◆ p_Delete() [1/2]

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

Definition at line 864 of file p_polys.h.

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

◆ p_Delete() [2/2]

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

Definition at line 857 of file p_polys.h.

858 {
859  assume( p!= NULL );
860  assume( r!= NULL );
861  if ((*p)!=NULL) r->p_Procs->p_Delete(p, r);
862 }

◆ p_DeleteComp()

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

Definition at line 3494 of file p_polys.cc.

3495 {
3496  poly q;
3497 
3498  while ((*p!=NULL) && (__p_GetComp(*p,r)==k)) p_LmDelete(p,r);
3499  if (*p==NULL) return;
3500  q = *p;
3501  if (__p_GetComp(q,r)>k)
3502  {
3503  p_SubComp(q,1,r);
3504  p_SetmComp(q,r);
3505  }
3506  while (pNext(q)!=NULL)
3507  {
3508  if (__p_GetComp(pNext(q),r)==k)
3509  p_LmDelete(&(pNext(q)),r);
3510  else
3511  {
3512  pIter(q);
3513  if (__p_GetComp(q,r)>k)
3514  {
3515  p_SubComp(q,1,r);
3516  p_SetmComp(q,r);
3517  }
3518  }
3519  }
3520 }
static unsigned long p_SubComp(poly p, unsigned long v, ring r)
Definition: p_polys.h:453
#define p_SetmComp
Definition: p_polys.h:244

◆ p_Diff()

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

Definition at line 1845 of file p_polys.cc.

1846 {
1847  poly res, f, last;
1848  number t;
1849 
1850  last = res = NULL;
1851  while (a!=NULL)
1852  {
1853  if (p_GetExp(a,k,r)!=0)
1854  {
1855  f = p_LmInit(a,r);
1856  t = n_Init(p_GetExp(a,k,r),r->cf);
1857  pSetCoeff0(f,n_Mult(t,pGetCoeff(a),r->cf));
1858  n_Delete(&t,r->cf);
1859  if (n_IsZero(pGetCoeff(f),r->cf))
1860  p_LmDelete(&f,r);
1861  else
1862  {
1863  p_DecrExp(f,k,r);
1864  p_Setm(f,r);
1865  if (res==NULL)
1866  {
1867  res=last=f;
1868  }
1869  else
1870  {
1871  pNext(last)=f;
1872  last=f;
1873  }
1874  }
1875  }
1876  pIter(a);
1877  }
1878  return res;
1879 }
FILE * f
Definition: checklibs.c:9
static poly last
Definition: hdegree.cc:1077
#define pSetCoeff0(p, n)
Definition: monomials.h:66
static poly p_LmInit(poly p, const ring r)
Definition: p_polys.h:1281
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:233
static long p_DecrExp(poly p, int v, ring r)
Definition: p_polys.h:598

◆ p_DiffOp()

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

Definition at line 1920 of file p_polys.cc.

1921 {
1922  poly result=NULL;
1923  poly h;
1924  for(;a!=NULL;pIter(a))
1925  {
1926  for(h=b;h!=NULL;pIter(h))
1927  {
1928  result=p_Add_q(result,p_DiffOpM(a,h,multiply,r),r);
1929  }
1930  }
1931  return result;
1932 }
return result
Definition: facAbsBiFact.cc:76
static poly p_DiffOpM(poly a, poly b, BOOLEAN multiply, const ring r)
Definition: p_polys.cc:1881

◆ p_Div_mm()

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

divide polynomial by monomial

Definition at line 1500 of file p_polys.cc.

1501 {
1502  p_Test(p, r);
1503  p_Test(m, r);
1504  poly result = p;
1505  poly prev = NULL;
1506  number n=pGetCoeff(m);
1507  while (p!=NULL)
1508  {
1509  number nc = n_Div(pGetCoeff(p),n,r->cf);
1510  n_Normalize(nc,r->cf);
1511  if (!n_IsZero(nc,r->cf))
1512  {
1513  p_SetCoeff(p,nc,r);
1514  prev=p;
1515  p_ExpVectorSub(p,m,r);
1516  pIter(p);
1517  }
1518  else
1519  {
1520  if (prev==NULL)
1521  {
1522  p_LmDelete(&result,r);
1523  p=result;
1524  }
1525  else
1526  {
1527  p_LmDelete(&pNext(prev),r);
1528  p=pNext(prev);
1529  }
1530  }
1531  }
1532  p_Test(result,r);
1533  return(result);
1534 }
int m
Definition: cfEzgcd.cc:121
static void p_ExpVectorSub(poly p1, poly p2, const ring r)
Definition: p_polys.h:1386

◆ p_Div_nn()

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

Definition at line 1467 of file p_polys.cc.

1468 {
1469  pAssume(!n_IsZero(n,r->cf));
1470  p_Test(p, r);
1471  poly result = p;
1472  poly prev = NULL;
1473  while (p!=NULL)
1474  {
1475  number nc = n_Div(pGetCoeff(p),n,r->cf);
1476  if (!n_IsZero(nc,r->cf))
1477  {
1478  p_SetCoeff(p,nc,r);
1479  prev=p;
1480  pIter(p);
1481  }
1482  else
1483  {
1484  if (prev==NULL)
1485  {
1486  p_LmDelete(&result,r);
1487  p=result;
1488  }
1489  else
1490  {
1491  p_LmDelete(&pNext(prev),r);
1492  p=pNext(prev);
1493  }
1494  }
1495  }
1496  p_Test(result,r);
1497  return(result);
1498 }

◆ p_DivideM()

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

Definition at line 1540 of file p_polys.cc.

1541 {
1542  if (a==NULL) { p_Delete(&b,r); return NULL; }
1543  poly result=a;
1544  poly prev=NULL;
1545  number inv=pGetCoeff(b);
1546 
1547  while (a!=NULL)
1548  {
1549  if (p_DivisibleBy(b,a,r))
1550  {
1551  p_ExpVectorSub(a,b,r);
1552  prev=a;
1553  pIter(a);
1554  }
1555  else
1556  {
1557  if (prev==NULL)
1558  {
1559  p_LmDelete(&result,r);
1560  a=result;
1561  }
1562  else
1563  {
1564  p_LmDelete(&pNext(prev),r);
1565  a=pNext(prev);
1566  }
1567  }
1568  }
1569  if (result!=NULL)
1570  {
1571  //if ((!rField_is_Ring(r)) || n_IsUnit(inv,r->cf))
1572  if (rField_is_Zp(r))
1573  {
1574  inv = n_Invers(inv,r->cf);
1575  __p_Mult_nn(result,inv,r);
1576  n_Delete(&inv, r->cf);
1577  }
1578  else
1579  {
1580  result = p_Div_nn(result,inv,r);
1581  }
1582  }
1583  p_Delete(&b, r);
1584  return result;
1585 }
static BOOLEAN p_DivisibleBy(poly a, poly b, const ring r)
Definition: p_polys.h:1824
#define __p_Mult_nn(p, n, r)
Definition: p_polys.h:927

◆ p_DivisibleBy() [1/2]

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

Definition at line 1833 of file p_polys.h.

1834 {
1835  pIfThen1(b!=NULL, p_LmCheckPolyRing1(b, r_b));
1836  pIfThen1(a!=NULL, p_LmCheckPolyRing1(a, r_a));
1837  if (a != NULL) {
1838  return _p_LmDivisibleBy(a, r_a, b, r_b);
1839  }
1840  return FALSE;
1841 }
#define pIfThen1(cond, check)
Definition: monomials.h:186
#define p_LmCheckPolyRing1(p, r)
Definition: monomials.h:184
static BOOLEAN _p_LmDivisibleBy(poly a, poly b, const ring r)
Definition: p_polys.h:1789

◆ p_DivisibleBy() [2/2]

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

Definition at line 1824 of file p_polys.h.

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

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

1590 {
1591  int exponent;
1592  for(int i = (int)rVar(r); i>0; i--)
1593  {
1594  exponent = p_GetExp(g, i, r) - p_GetExp(f, i, r);
1595  if (exponent < 0) return FALSE;
1596  }
1597  return n_DivBy(pGetCoeff(g), pGetCoeff(f), r->cf);
1598 }
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 4396 of file p_polys.cc.

4397 {
4398  while ((p1 != NULL) && (p2 != NULL))
4399  {
4400  if (! p_LmEqual(p1, p2,r))
4401  return FALSE;
4402  if (! n_Equal(p_GetCoeff(p1,r), p_GetCoeff(p2,r),r->cf ))
4403  return FALSE;
4404  pIter(p1);
4405  pIter(p2);
4406  }
4407  return (p1==p2);
4408 }
#define p_GetCoeff(p, r)
Definition: monomials.h:57

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

4435 {
4436  assume( r1 == r2 || rSamePolyRep(r1, r2) ); // will be used in rEqual!
4437  assume( r1->cf == r2->cf );
4438 
4439  while ((p1 != NULL) && (p2 != NULL))
4440  {
4441  // returns 1 if ExpVector(p)==ExpVector(q): does not compare numbers !!
4442  // #define p_LmEqual(p1, p2, r) p_ExpVectorEqual(p1, p2, r)
4443 
4444  if (! p_ExpVectorEqual(p1, p2, r1, r2))
4445  return FALSE;
4446 
4447  if (! n_Equal(p_GetCoeff(p1,r1), p_GetCoeff(p2,r2), r1->cf ))
4448  return FALSE;
4449 
4450  pIter(p1);
4451  pIter(p2);
4452  }
4453  return (p1==p2);
4454 }
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:1668

◆ p_ExpVectorAdd()

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

Definition at line 1357 of file p_polys.h.

1358 {
1359  p_LmCheckPolyRing1(p1, r);
1360  p_LmCheckPolyRing1(p2, r);
1361 #if PDEBUG >= 1
1362  for (int i=1; i<=r->N; i++)
1363  pAssume1((unsigned long) (p_GetExp(p1, i, r) + p_GetExp(p2, i, r)) <= r->bitmask);
1364  pAssume1(p_GetComp(p1, r) == 0 || p_GetComp(p2, r) == 0);
1365 #endif
1366 
1367  p_MemAdd_LengthGeneral(p1->exp, p2->exp, r->ExpL_Size);
1368  p_MemAdd_NegWeightAdjust(p1, r);
1369 }
#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:1238

◆ p_ExpVectorAddSub()

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

Definition at line 1402 of file p_polys.h.

1403 {
1404  p_LmCheckPolyRing1(p1, r);
1405  p_LmCheckPolyRing1(p2, r);
1406  p_LmCheckPolyRing1(p3, r);
1407 #if PDEBUG >= 1
1408  for (int i=1; i<=r->N; i++)
1409  pAssume1(p_GetExp(p1, i, r) + p_GetExp(p2, i, r) >= p_GetExp(p3, i, r));
1410  pAssume1(p_GetComp(p1, r) == 0 ||
1411  (p_GetComp(p2, r) - p_GetComp(p3, r) == 0) ||
1412  (p_GetComp(p1, r) == p_GetComp(p2, r) - p_GetComp(p3, r)));
1413 #endif
1414 
1415  p_MemAddSub_LengthGeneral(p1->exp, p2->exp, p3->exp, r->ExpL_Size);
1416  // no need to adjust in case of NegWeights
1417 }
#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 1259 of file p_polys.h.

1260 {
1261  p_LmCheckPolyRing1(d_p, r);
1262  p_LmCheckPolyRing1(s_p, r);
1263  memcpy(d_p->exp, s_p->exp, r->ExpL_Size*sizeof(long));
1264 }

◆ p_ExpVectorDiff()

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

Definition at line 1420 of file p_polys.h.

1421 {
1422  p_LmCheckPolyRing1(p1, r);
1423  p_LmCheckPolyRing1(p2, r);
1424  p_LmCheckPolyRing1(pr, r);
1425 #if PDEBUG >= 2
1426  for (int i=1; i<=r->N; i++)
1427  pAssume1(p_GetExp(p1, i, r) >= p_GetExp(p2, i, r));
1428  pAssume1(!rRing_has_Comp(r) || p_GetComp(p1, r) == p_GetComp(p2, r));
1429 #endif
1430 
1431  p_MemDiff_LengthGeneral(pr->exp, p1->exp, p2->exp, r->ExpL_Size);
1432  p_MemSub_NegWeightAdjust(pr, r);
1433 }
#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:1248

◆ p_ExpVectorEqual()

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

Definition at line 1435 of file p_polys.h.

1436 {
1437  p_LmCheckPolyRing1(p1, r);
1438  p_LmCheckPolyRing1(p2, r);
1439 
1440  unsigned i = r->ExpL_Size;
1441  unsigned long *ep = p1->exp;
1442  unsigned long *eq = p2->exp;
1443 
1444  do
1445  {
1446  i--;
1447  if (ep[i] != eq[i]) return FALSE;
1448  }
1449  while (i!=0);
1450  return TRUE;
1451 }

◆ p_ExpVectorSub()

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

Definition at line 1386 of file p_polys.h.

1387 {
1388  p_LmCheckPolyRing1(p1, r);
1389  p_LmCheckPolyRing1(p2, r);
1390 #if PDEBUG >= 1
1391  for (int i=1; i<=r->N; i++)
1392  pAssume1(p_GetExp(p1, i, r) >= p_GetExp(p2, i, r));
1393  pAssume1(p_GetComp(p1, r) == 0 || p_GetComp(p2, r) == 0 ||
1394  p_GetComp(p1, r) == p_GetComp(p2, r));
1395 #endif
1396 
1397  p_MemSub_LengthGeneral(p1->exp, p2->exp, r->ExpL_Size);
1398  p_MemSub_NegWeightAdjust(p1, r);
1399 }
#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 1371 of file p_polys.h.

1372 {
1373  p_LmCheckPolyRing1(p1, r);
1374  p_LmCheckPolyRing1(p2, r);
1375  p_LmCheckPolyRing1(pr, r);
1376 #if PDEBUG >= 1
1377  for (int i=1; i<=r->N; i++)
1378  pAssume1((unsigned long) (p_GetExp(p1, i, r) + p_GetExp(p2, i, r)) <= r->bitmask);
1379  pAssume1(p_GetComp(p1, r) == 0 || p_GetComp(p2, r) == 0);
1380 #endif
1381 
1382  p_MemSum_LengthGeneral(pr->exp, p1->exp, p2->exp, r->ExpL_Size);
1383  p_MemAdd_NegWeightAdjust(pr, r);
1384 }
#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 52 of file p_polys.cc.

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

◆ p_FDeg()

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

Definition at line 380 of file p_polys.h.

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

◆ p_GcdMon()

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

polynomial gcd for f=mon

Definition at line 4824 of file p_polys.cc.

4825 {
4826  assume(f!=NULL);
4827  assume(g!=NULL);
4828  assume(pNext(f)==NULL);
4829  poly G=p_Head(f,r);
4830  poly h=g;
4831  int *mf=(int*)omAlloc((r->N+1)*sizeof(int));
4832  p_GetExpV(f,mf,r);
4833  int *mh=(int*)omAlloc((r->N+1)*sizeof(int));
4834  BOOLEAN const_mon;
4835  BOOLEAN one_coeff=n_IsOne(pGetCoeff(G),r->cf);
4836  loop
4837  {
4838  if (h==NULL) break;
4839  if(!one_coeff)
4840  {
4841  number n=n_SubringGcd(pGetCoeff(G),pGetCoeff(h),r->cf);
4842  one_coeff=n_IsOne(n,r->cf);
4843  p_SetCoeff(G,n,r);
4844  }
4845  p_GetExpV(h,mh,r);
4846  const_mon=TRUE;
4847  for(unsigned j=r->N;j!=0;j--)
4848  {
4849  if (mh[j]<mf[j]) mf[j]=mh[j];
4850  if (mf[j]>0) const_mon=FALSE;
4851  }
4852  if (one_coeff && const_mon) break;
4853  pIter(h);
4854  }
4855  mf[0]=0;
4856  p_SetExpV(G,mf,r); // included is p_SetComp, p_Setm
4857  omFreeSize(mf,(r->N+1)*sizeof(int));
4858  omFreeSize(mh,(r->N+1)*sizeof(int));
4859  return G;
4860 }
static TreeM * G
Definition: janet.cc:32
#define omAlloc(size)
Definition: omAllocDecl.h:210
static void p_SetExpV(poly p, int *ev, const ring r)
Definition: p_polys.h:1481
static void p_GetExpV(poly p, int *ev, const ring r)
Definition: p_polys.h:1466

◆ p_GetCoeffRat()

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

Definition at line 1669 of file p_polys.cc.

1670 {
1671  poly q = pNext(p);
1672  poly res; // = p_Head(p,r);
1673  res = p_GetExp_k_n(p, ishift+1, r->N, r); // does pSetm internally
1674  p_SetCoeff(res,n_Copy(p_GetCoeff(p,r),r),r);
1675  poly s;
1676  long cmp = p_GetComp(p, r);
1677  while ( (q!= NULL) && (p_Comp_k_n(p, q, ishift+1, r)) && (p_GetComp(q, r) == cmp) )
1678  {
1679  s = p_GetExp_k_n(q, ishift+1, r->N, r);
1680  p_SetCoeff(s,n_Copy(p_GetCoeff(q,r),r),r);
1681  res = p_Add_q(res,s,r);
1682  q = pNext(q);
1683  }
1684  cmp = 0;
1685  p_SetCompP(res,cmp,r);
1686  return res;
1687 }
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:640
static void p_SetCompP(poly p, int i, ring r)
Definition: p_polys.h:254

◆ p_GetExp() [1/3]

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

get v^th exponent for a monomial

Definition at line 572 of file p_polys.h.

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

◆ p_GetExp() [2/3]

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

Definition at line 555 of file p_polys.h.

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

◆ p_GetExp() [3/3]

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

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

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

Definition at line 469 of file p_polys.h.

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

◆ p_GetExp_k_n()

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

Definition at line 1318 of file p_polys.h.

1319 {
1320  if (p == NULL) return NULL;
1321  p_LmCheckPolyRing1(p, r);
1322  poly np;
1323  omTypeAllocBin(poly, np, r->PolyBin);
1324  p_SetRingOfLm(np, r);
1325  memcpy(np->exp, p->exp, r->ExpL_Size*sizeof(long));
1326  pNext(np) = NULL;
1327  pSetCoeff0(np, n_Init(1, r->cf));
1328  int i;
1329  for(i=l;i<=k;i++)
1330  {
1331  //np->exp[(r->VarOffset[i] & 0xffffff)] =0;
1332  p_SetExp(np,i,0,r);
1333  }
1334  p_Setm(np,r);
1335  return np;
1336 }
#define p_SetRingOfLm(p, r)
Definition: monomials.h:151
#define omTypeAllocBin(type, addr, bin)
Definition: omAllocDecl.h:203

◆ p_GetExpDiff()

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

Definition at line 635 of file p_polys.h.

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

◆ p_GetExpSum()

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

Definition at line 629 of file p_polys.h.

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

◆ p_GetExpV()

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

Definition at line 1466 of file p_polys.h.

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

◆ p_GetExpVL()

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

Definition at line 1475 of file p_polys.h.

1476 {
1477  p_LmCheckPolyRing1(p, r);
1478  for (unsigned j = r->N; j!=0; j--)
1479  ev[j-1] = p_GetExp(p, j, r);
1480 }

◆ p_GetMaxExp() [1/2]

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

Definition at line 770 of file p_polys.h.

771 {
772  return p_GetMaxExp(p_GetMaxExpL(p, r), r);
773 }
static unsigned long p_GetMaxExp(const unsigned long l, const ring r)
Definition: p_polys.h:747
unsigned long p_GetMaxExpL(poly p, const ring r, unsigned long l_max=0)
return the maximal exponent of p in form of the maximal long var
Definition: p_polys.cc:1167

◆ p_GetMaxExp() [2/2]

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

Definition at line 747 of file p_polys.h.

748 {
749  unsigned long bitmask = r->bitmask;
750  unsigned long max = (l & bitmask);
751  unsigned long j = r->ExpPerLong - 1;
752 
753  if (j > 0)
754  {
755  unsigned long i = r->BitsPerExp;
756  long e;
757  loop
758  {
759  e = ((l >> i) & bitmask);
760  if ((unsigned long) e > max)
761  max = e;
762  j--;
763  if (j==0) break;
764  i += r->BitsPerExp;
765  }
766  }
767  return max;
768 }
static int max(int a, int b)
Definition: fast_mult.cc:264

◆ p_GetMaxExpL()

unsigned long p_GetMaxExpL ( poly  p,
const ring  r,
unsigned long  l_max = 0 
)

return the maximal exponent of p in form of the maximal long var

Definition at line 1167 of file p_polys.cc.

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

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

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

◆ p_GetOrder()

static long p_GetOrder ( poly  p,
ring  r 
)
inlinestatic

Definition at line 421 of file p_polys.h.

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

◆ p_GetSetmProc()

p_SetmProc p_GetSetmProc ( const ring  r)

Definition at line 552 of file p_polys.cc.

553 {
554  // covers lp, rp, ls,
555  if (r->typ == NULL) return p_Setm_Dummy;
556 
557  if (r->OrdSize == 1)
558  {
559  if (r->typ[0].ord_typ == ro_dp &&
560  r->typ[0].data.dp.start == 1 &&
561  r->typ[0].data.dp.end == r->N &&
562  r->typ[0].data.dp.place == r->pOrdIndex)
563  return p_Setm_TotalDegree;
564  if (r->typ[0].ord_typ == ro_wp &&
565  r->typ[0].data.wp.start == 1 &&
566  r->typ[0].data.wp.end == r->N &&
567  r->typ[0].data.wp.place == r->pOrdIndex &&
568  r->typ[0].data.wp.weights == r->firstwv)
570  }
571  return p_Setm_General;
572 }
void p_Setm_WFirstTotalDegree(poly p, const ring r)
Definition: p_polys.cc:546
void p_Setm_Dummy(poly p, const ring r)
Definition: p_polys.cc:533
void p_Setm_TotalDegree(poly p, const ring r)
Definition: p_polys.cc:539
void p_Setm_General(poly p, const ring r)
Definition: p_polys.cc:154
@ ro_dp
Definition: ring.h:59
@ ro_wp
Definition: ring.h:60

◆ p_GetShortExpVector() [1/2]

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

Definition at line 4665 of file p_polys.cc.

4666 {
4667  assume(p != NULL);
4668  unsigned long ev = 0; // short exponent vector
4669  unsigned int n = BIT_SIZEOF_LONG / r->N; // number of bits per exp
4670  unsigned int m1; // highest bit which is filled with (n+1)
4671  int i=0,j=1;
4672 
4673  if (n == 0)
4674  {
4675  if (r->N <2*BIT_SIZEOF_LONG)
4676  {
4677  n=1;
4678  m1=0;
4679  }
4680  else
4681  {
4682  for (; j<=r->N; j++)
4683  {
4684  if (p_GetExp(p,j,r) > 0) i++;
4685  if (i == BIT_SIZEOF_LONG) break;
4686  }
4687  if (i>0)
4688  ev = ~(0UL) >> (BIT_SIZEOF_LONG - i);
4689  return ev;
4690  }
4691  }
4692  else
4693  {
4694  m1 = (n+1)*(BIT_SIZEOF_LONG - n*r->N);
4695  }
4696 
4697  n++;
4698  while (i<m1)
4699  {
4700  ev |= GetBitFields(p_GetExp(p, j,r), i, n);
4701  i += n;
4702  j++;
4703  }
4704 
4705  n--;
4706  while (i<BIT_SIZEOF_LONG)
4707  {
4708  ev |= GetBitFields(p_GetExp(p, j,r), i, n);
4709  i += n;
4710  j++;
4711  }
4712  return ev;
4713 }
#define BIT_SIZEOF_LONG
Definition: auxiliary.h:78
static unsigned long GetBitFields(const long e, const unsigned int s, const unsigned int n)
Definition: p_polys.cc:4632

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

4718 {
4719  assume(p != NULL);
4720  assume(pp != NULL);
4721 
4722  unsigned long ev = 0; // short exponent vector
4723  unsigned int n = BIT_SIZEOF_LONG / r->N; // number of bits per exp
4724  unsigned int m1; // highest bit which is filled with (n+1)
4725  int j=1;
4726  unsigned long i = 0L;
4727 
4728  if (n == 0)
4729  {
4730  if (r->N <2*BIT_SIZEOF_LONG)
4731  {
4732  n=1;
4733  m1=0;
4734  }
4735  else
4736  {
4737  for (; j<=r->N; j++)
4738  {
4739  if (p_GetExp(p,j,r) > 0 || p_GetExp(pp,j,r) > 0) i++;
4740  if (i == BIT_SIZEOF_LONG) break;
4741  }
4742  if (i>0)
4743  ev = ~(0UL) >> (BIT_SIZEOF_LONG - i);
4744  return ev;
4745  }
4746  }
4747  else
4748  {
4749  m1 = (n+1)*(BIT_SIZEOF_LONG - n*r->N);
4750  }
4751 
4752  n++;
4753  while (i<m1)
4754  {
4755  ev |= GetBitFields(p_GetExp(p, j,r) + p_GetExp(pp, j,r), i, n);
4756  i += n;
4757  j++;
4758  }
4759 
4760  n--;
4761  while (i<BIT_SIZEOF_LONG)
4762  {
4763  ev |= GetBitFields(p_GetExp(p, j,r) + p_GetExp(pp, j,r), i, n);
4764  i += n;
4765  j++;
4766  }
4767  return ev;
4768 }

◆ p_GetTotalDegree()

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

Definition at line 776 of file p_polys.h.

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

◆ p_GetVariables()

int p_GetVariables ( poly  p,
int *  e,
const ring  r 
)

set entry e[i] to 1 if var(i) occurs in p, ignore var(j) if e[j]>0 return #(e[i]>0)

Definition at line 1259 of file p_polys.cc.

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

◆ p_HasNotCF()

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

Definition at line 1321 of file p_polys.cc.

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

◆ p_Head()

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

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

3209 {
3210  pFDegProc deg;
3211  if (r->pLexOrder && (r->order[0]==ringorder_lp))
3212  deg=p_Totaldegree;
3213  else
3214  deg=r->pFDeg;
3215 
3216  poly q=NULL, qn;
3217  int o,ii;
3218  sBucket_pt bp;
3219 
3220  if (p!=NULL)
3221  {
3222  if ((varnum < 1) || (varnum > rVar(r)))
3223  {
3224  return NULL;
3225  }
3226  o=deg(p,r);
3227  q=pNext(p);
3228  while (q != NULL)
3229  {
3230  ii=deg(q,r);
3231  if (ii>o) o=ii;
3232  pIter(q);
3233  }
3234  q = p_Copy(p,r);
3235  bp = sBucketCreate(r);
3236  while (q != NULL)
3237  {
3238  ii = o-deg(q,r);
3239  if (ii!=0)
3240  {
3241  p_AddExp(q,varnum, (long)ii,r);
3242  p_Setm(q,r);
3243  }
3244  qn = pNext(q);
3245  pNext(q) = NULL;
3246  sBucket_Add_m(bp, q);
3247  q = qn;
3248  }
3249  sBucketDestroyAdd(bp, &q, &ii);
3250  }
3251  return q;
3252 }
static long p_AddExp(poly p, int v, long ee, ring r)
Definition: p_polys.h:606
long(* pFDegProc)(poly p, ring r)
Definition: ring.h:45
@ ringorder_lp
Definition: ring.h:84
void sBucket_Add_m(sBucket_pt bucket, poly p)
Definition: sbuckets.cc:176
sBucket_pt sBucketCreate(const ring r)
Definition: sbuckets.cc:99
void sBucketDestroyAdd(sBucket_pt bucket, poly *p, int *length)
Definition: sbuckets.h:68

◆ p_IncrExp()

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

Definition at line 591 of file p_polys.h.

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

◆ p_Init() [1/2]

static poly p_Init ( const ring  r)
inlinestatic

Definition at line 1276 of file p_polys.h.

1277 {
1278  return p_Init(r, r->PolyBin);
1279 }

◆ p_Init() [2/2]

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

Definition at line 1266 of file p_polys.h.

1267 {
1268  p_CheckRing1(r);
1269  pAssume1(bin != NULL && omSizeWOfBin(r->PolyBin) == omSizeWOfBin(bin));
1270  poly p;
1271  omTypeAlloc0Bin(poly, p, bin);
1273  p_SetRingOfLm(p, r);
1274  return p;
1275 }
#define p_CheckRing1(r)
Definition: monomials.h:185
#define omTypeAlloc0Bin(type, addr, bin)
Definition: omAllocDecl.h:204

◆ p_InitContent()

number p_InitContent ( poly  ph,
const ring  r 
)

Definition at line 2549 of file p_polys.cc.

2552 {
2554  assume(ph!=NULL);
2555  assume(pNext(ph)!=NULL);
2556  assume(rField_is_Q(r));
2557  if (pNext(pNext(ph))==NULL)
2558  {
2559  return n_GetNumerator(pGetCoeff(pNext(ph)),r->cf);
2560  }
2561  poly p=ph;
2562  number n1=n_GetNumerator(pGetCoeff(p),r->cf);
2563  pIter(p);
2564  number n2=n_GetNumerator(pGetCoeff(p),r->cf);
2565  pIter(p);
2566  number d;
2567  number t;
2568  loop
2569  {
2570  nlNormalize(pGetCoeff(p),r->cf);
2571  t=n_GetNumerator(pGetCoeff(p),r->cf);
2572  if (nlGreaterZero(t,r->cf))
2573  d=nlAdd(n1,t,r->cf);
2574  else
2575  d=nlSub(n1,t,r->cf);
2576  nlDelete(&t,r->cf);
2577  nlDelete(&n1,r->cf);
2578  n1=d;
2579  pIter(p);
2580  if (p==NULL) break;
2581  nlNormalize(pGetCoeff(p),r->cf);
2582  t=n_GetNumerator(pGetCoeff(p),r->cf);
2583  if (nlGreaterZero(t,r->cf))
2584  d=nlAdd(n2,t,r->cf);
2585  else
2586  d=nlSub(n2,t,r->cf);
2587  nlDelete(&t,r->cf);
2588  nlDelete(&n2,r->cf);
2589  n2=d;
2590  pIter(p);
2591  if (p==NULL) break;
2592  }
2593  d=nlGcd(n1,n2,r->cf);
2594  nlDelete(&n1,r->cf);
2595  nlDelete(&n2,r->cf);
2596  return d;
2597 }
2598 #else
2599 {
2600  number d=pGetCoeff(ph);
2601  int s;
2602  int s2=-1;
2603  if(rField_is_Q(r))
2604  {
2605  if (SR_HDL(d)&SR_INT) return d;
2606  s=mpz_size1(d->z);
2607  }
2608  else
2609  s=n_Size(d,r->cf);
2610  number d2=d;
2611  loop
2612  {
2613  pIter(ph);
2614  if(ph==NULL)
2615  {
2616  if (s2==-1) return n_Copy(d,r->cf);
2617  break;
2618  }
2619  if (rField_is_Q(r))
2620  {
2621  if (SR_HDL(pGetCoeff(ph))&SR_INT)
2622  {
2623  s2=s;
2624  d2=d;
2625  s=0;
2626  d=pGetCoeff(ph);
2627  if (s2==0) break;
2628  }
2629  else if (mpz_size1((pGetCoeff(ph)->z))<=s)
2630  {
2631  s2=s;
2632  d2=d;
2633  d=pGetCoeff(ph);
2634  s=mpz_size1(d->z);
2635  }
2636  }
2637  else
2638  {
2639  int ns=n_Size(pGetCoeff(ph),r->cf);
2640  if (ns<=3)
2641  {
2642  s2=s;
2643  d2=d;
2644  d=pGetCoeff(ph);
2645  s=ns;
2646  if (s2<=3) break;
2647  }
2648  else if (ns<s)
2649  {
2650  s2=s;
2651  d2=d;
2652  d=pGetCoeff(ph);
2653  s=ns;
2654  }
2655  }
2656  }
2657  return n_SubringGcd(d,d2,r->cf);
2658 }
static FORCE_INLINE int n_Size(number n, const coeffs r)
return a non-negative measure for the complexity of n; return 0 only when n represents zero; (used fo...
Definition: coeffs.h:571
static FORCE_INLINE number n_GetNumerator(number &n, const coeffs r)
return the numerator of n (if elements of r are by nature not fractional, result is n)
Definition: coeffs.h:609
LINLINE number nlAdd(number la, number li, const coeffs r)
Definition: longrat.cc:2530
LINLINE number nlSub(number la, number li, const coeffs r)
Definition: longrat.cc:2596
LINLINE void nlDelete(number *a, const coeffs r)
Definition: longrat.cc:2495
BOOLEAN nlGreaterZero(number za, const coeffs r)
Definition: longrat.cc:1166
number nlGcd(number a, number b, const coeffs r)
Definition: longrat.cc:1203
void nlNormalize(number &x, const coeffs r)
Definition: longrat.cc:1345
#define SR_INT
Definition: longrat.h:68
#define mpz_size1(A)
Definition: si_gmp.h:12
#define SR_HDL(A)
Definition: tgb.cc:35

◆ p_IsConstant()

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

Definition at line 1923 of file p_polys.h.

1924 {
1925  if (p == NULL) return TRUE;
1926  p_Test(p, r);
1927  return (pNext(p)==NULL) && p_LmIsConstant(p, r);
1928 }
static BOOLEAN p_LmIsConstant(const poly p, const ring r)
Definition: p_polys.h:979

◆ p_IsConstantComp()

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

Definition at line 1917 of file p_polys.h.

1918 {
1919  if (p == NULL) return TRUE;
1920  return (pNext(p)==NULL) && p_LmIsConstantComp(p, r);
1921 }
static BOOLEAN p_LmIsConstantComp(const poly p, const ring r)
Definition: p_polys.h:962

◆ p_IsConstantPoly()

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

Definition at line 1937 of file p_polys.h.

1938 {
1939  p_Test(p, r);
1940  poly pp=p;
1941  while(pp!=NULL)
1942  {
1943  if (! p_LmIsConstantComp(pp, r))
1944  return FALSE;
1945  pIter(pp);
1946  }
1947  return TRUE;
1948 }

◆ p_ISet()

poly p_ISet ( long  i,
const ring  r 
)

returns the poly representing the integer i

Definition at line 1289 of file p_polys.cc.

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

◆ p_IsHomogeneous()

BOOLEAN p_IsHomogeneous ( poly  p,
const ring  r 
)

Definition at line 3257 of file p_polys.cc.

3258 {
3259  poly qp=p;
3260  int o;
3261 
3262  if ((p == NULL) || (pNext(p) == NULL)) return TRUE;
3263  pFDegProc d;
3264  if (r->pLexOrder && (r->order[0]==ringorder_lp))
3265  d=p_Totaldegree;
3266  else
3267  d=r->pFDeg;
3268  o = d(p,r);
3269  do
3270  {
3271  if (d(qp,r) != o) return FALSE;
3272  pIter(qp);
3273  }
3274  while (qp != NULL);
3275  return TRUE;
3276 }

◆ p_IsOne()

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

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

Definition at line 1931 of file p_polys.h.

1932 {
1933  p_Test(p, R);
1934  return (p_IsConstant(p, R) && n_IsOne(p_GetCoeff(p, R), R->cf));
1935 }

◆ p_IsPurePower()

int p_IsPurePower ( const poly  p,
const ring  r 
)

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

Definition at line 1218 of file p_polys.cc.

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

◆ p_IsUnit()

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

Definition at line 1950 of file p_polys.h.

1951 {
1952  if (p == NULL) return FALSE;
1953  if (rField_is_Ring(r))
1954  return (p_LmIsConstant(p, r) && n_IsUnit(pGetCoeff(p),r->cf));
1955  return p_LmIsConstant(p, r);
1956 }
static FORCE_INLINE BOOLEAN n_IsUnit(number n, const coeffs r)
TRUE iff n has a multiplicative inverse in the given coeff field/ring r.
Definition: coeffs.h:516

◆ p_IsUnivariate()

int p_IsUnivariate ( poly  p,
const ring  r 
)

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

Definition at line 1239 of file p_polys.cc.

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

◆ p_Jet()

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

Definition at line 4270 of file p_polys.cc.

4271 {
4272  while((p!=NULL) && (p_Totaldegree(p,R)>m)) p_LmDelete(&p,R);
4273  if (p==NULL) return NULL;
4274  poly r=p;
4275  while (pNext(p)!=NULL)
4276  {
4277  if (p_Totaldegree(pNext(p),R)>m)
4278  {
4279  p_LmDelete(&pNext(p),R);
4280  }
4281  else
4282  pIter(p);
4283  }
4284  return r;
4285 }

◆ p_JetW()

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

Definition at line 4314 of file p_polys.cc.

4315 {
4316  while((p!=NULL) && (totaldegreeWecart_IV(p,R,w)>m)) p_LmDelete(&p,R);
4317  if (p==NULL) return NULL;
4318  poly r=p;
4319  while (pNext(p)!=NULL)
4320  {
4321  if (totaldegreeWecart_IV(pNext(p),R,w)>m)
4322  {
4323  p_LmDelete(&pNext(p),R);
4324  }
4325  else
4326  pIter(p);
4327  }
4328  return r;
4329 }

◆ p_Last()

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

Definition at line 4505 of file p_polys.cc.

4506 {
4507  if (p == NULL)
4508  {
4509  l = 0;
4510  return NULL;
4511  }
4512  l = 1;
4513  poly a = p;
4514  if (! rIsSyzIndexRing(r))
4515  {
4516  poly next = pNext(a);
4517  while (next!=NULL)
4518  {
4519  a = next;
4520  next = pNext(a);
4521  l++;
4522  }
4523  }
4524  else
4525  {
4526  int curr_limit = rGetCurrSyzLimit(r);
4527  poly pp = a;
4528  while ((a=pNext(a))!=NULL)
4529  {
4530  if (__p_GetComp(a,r)<=curr_limit/*syzComp*/)
4531  l++;
4532  else break;
4533  pp = a;
4534  }
4535  a=pp;
4536  }
4537  return a;
4538 }
ListNode * next
Definition: janet.h:31
static int rGetCurrSyzLimit(const ring r)
Definition: ring.h:714
static BOOLEAN rIsSyzIndexRing(const ring r)
Definition: ring.h:711

◆ p_Lcm() [1/2]

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

Definition at line 1611 of file p_polys.cc.

1612 {
1613  poly m=p_Init(r);
1614  p_Lcm(a, b, m, r);
1615  p_Setm(m,r);
1616  return(m);
1617 }
void p_Lcm(const poly a, const poly b, poly m, const ring r)
Definition: p_polys.cc:1602

◆ p_Lcm() [2/2]

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

Definition at line 1602 of file p_polys.cc.

1603 {
1604  for (int i=r->N; i; --i)
1605  p_SetExp(m,i, si_max( p_GetExp(a,i,r), p_GetExp(b,i,r)),r);
1606 
1607  p_SetComp(m, si_max(p_GetComp(a,r), p_GetComp(b,r)),r);
1608  /* Don't do a pSetm here, otherwise hres/lres chockes */
1609 }
static int si_max(const int a, const int b)
Definition: auxiliary.h:138
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition: p_polys.h:247

◆ p_LcmRat()

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

Definition at line 1624 of file p_polys.cc.

1625 {
1626  poly m = // p_One( r);
1627  p_Init(r);
1628 
1629 // const int (currRing->N) = r->N;
1630 
1631  // for (int i = (currRing->N); i>=r->real_var_start; i--)
1632  for (int i = r->real_var_end; i>=r->real_var_start; i--)
1633  {
1634  const int lExpA = p_GetExp (a, i, r);
1635  const int lExpB = p_GetExp (b, i, r);
1636 
1637  p_SetExp (m, i, si_max(lExpA, lExpB), r);
1638  }
1639 
1640  p_SetComp (m, lCompM, r);
1641  p_Setm(m,r);
1642  n_New(&(p_GetCoeff(m, r)), r);
1643 
1644  return(m);
1645 };
#define n_New(n, r)
Definition: coeffs.h:441

◆ p_LDeg()

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

Definition at line 381 of file p_polys.h.

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

◆ p_LmCheckIsFromRing()

BOOLEAN p_LmCheckIsFromRing ( poly  p,
ring  r 
)

Definition at line 71 of file pDebug.cc.

72 {
73  if (p != NULL)
74  {
75  #if (OM_TRACK > 0) && defined(OM_TRACK_CUSTOM)
76  void* custom = omGetCustomOfAddr(p);
77  if (custom != NULL)
78  {
79  pPolyAssumeReturnMsg(custom == r ||
80  // be more sloppy for qrings
81  (r->qideal != NULL &&
82  omIsBinPageAddr(p) &&
83  omSizeWOfAddr(p)==omSizeWOfBin(r->PolyBin)) ||
84  rSamePolyRep((ring) custom, r),
85  "monomial not from specified ring",p,r);
86  return TRUE;
87  }
88  else
89  #endif
90  #ifndef X_OMALLOC
91  {
94  return TRUE;
95  }
96  return FALSE;
97  #endif
98  }
99  return TRUE;
100 }
#define pPolyAssumeReturnMsg(cond, msg)
Definition: monomials.h:144
#define _pPolyAssumeReturn(cond, p, r)
Definition: monomials.h:108
size_t omSizeWOfAddr(void *addr)
#define omIsBinPageAddr(addr)
Definition: omBinPage.h:68

◆ p_LmCheckPolyRing()

BOOLEAN p_LmCheckPolyRing ( poly  p,
ring  r 
)

Definition at line 120 of file pDebug.cc.

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

◆ p_LmCmp()

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

Definition at line 1507 of file p_polys.h.

1508 {
1509  p_LmCheckPolyRing1(p, r);
1510  p_LmCheckPolyRing1(q, r);
1511 
1512  const unsigned long* _s1 = ((unsigned long*) p->exp);
1513  const unsigned long* _s2 = ((unsigned long*) q->exp);
1514  REGISTER unsigned long _v1;
1515  REGISTER unsigned long _v2;
1516  const unsigned long _l = r->CmpL_Size;
1517 
1518  REGISTER unsigned long _i=0;
1519 
1520  LengthGeneral_OrdGeneral_LoopTop:
1521  _v1 = _s1[_i];
1522  _v2 = _s2[_i];
1523  if (_v1 == _v2)
1524  {
1525  _i++;
1526  if (_i == _l) return 0;
1527  goto LengthGeneral_OrdGeneral_LoopTop;
1528  }
1529  const long* _ordsgn = (long*) r->ordsgn;
1530 #if 1 /* two variants*/
1531  if (_v1 > _v2)
1532  {
1533  return _ordsgn[_i];
1534  }
1535  return -(_ordsgn[_i]);
1536 #else
1537  if (_v1 > _v2)
1538  {
1539  if (_ordsgn[_i] == 1) return 1;
1540  return -1;
1541  }
1542  if (_ordsgn[_i] == 1) return -1;
1543  return 1;
1544 #endif
1545 }
if(yy_init)
Definition: libparse.cc:1418
#define REGISTER
Definition: omalloc.h:20

◆ p_LmDelete() [1/2]

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

Definition at line 717 of file p_polys.h.

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

◆ p_LmDelete() [2/2]

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

Definition at line 711 of file p_polys.h.

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

◆ p_LmDeleteAndNext()

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

Definition at line 725 of file p_polys.h.

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

◆ p_LmDeleteAndNextRat()

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

Definition at line 1647 of file p_polys.cc.

1648 {
1649  /* modifies p*/
1650  // Print("start: "); Print(" "); p_wrp(*p,r);
1651  p_LmCheckPolyRing2(*p, r);
1652  poly q = p_Head(*p,r);
1653  const long cmp = p_GetComp(*p, r);
1654  while ( ( (*p)!=NULL ) && ( p_Comp_k_n(*p, q, ishift+1, r) ) && (p_GetComp(*p, r) == cmp) )
1655  {
1656  p_LmDelete(p,r);
1657  // Print("while: ");p_wrp(*p,r);Print(" ");
1658  }
1659  // p_wrp(*p,r);Print(" ");
1660  // PrintS("end\n");
1661  p_LmDelete(&q,r);
1662 }

◆ p_LmDivisibleBy() [1/2]

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

Definition at line 1842 of file p_polys.h.

1843 {
1844  p_LmCheckPolyRing(a, r_a);
1845  p_LmCheckPolyRing(b, r_b);
1846  return _p_LmDivisibleBy(a, r_a, b, r_b);
1847 }

◆ p_LmDivisibleBy() [2/2]

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

Definition at line 1815 of file p_polys.h.

1816 {
1817  p_LmCheckPolyRing1(b, r);
1818  pIfThen1(a != NULL, p_LmCheckPolyRing1(b, r));
1819  if (p_GetComp(a, r) == 0 || p_GetComp(a,r) == p_GetComp(b,r))
1820  return _p_LmDivisibleByNoComp(a, b, r);
1821  return FALSE;
1822 }

◆ p_LmDivisibleByNoComp() [1/2]

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

Definition at line 1808 of file p_polys.h.

1809 {
1810  p_LmCheckPolyRing1(a, ra);
1811  p_LmCheckPolyRing1(b, rb);
1812  return _p_LmDivisibleByNoComp(a, ra, b, rb);
1813 }

◆ p_LmDivisibleByNoComp() [2/2]

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

Definition at line 1801 of file p_polys.h.

1802 {
1803  p_LmCheckPolyRing1(a, r);
1804  p_LmCheckPolyRing1(b, r);
1805  return _p_LmDivisibleByNoComp(a, b, r);
1806 }

◆ p_LmDivisibleByPart()

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

Definition at line 1780 of file p_polys.h.

1781 {
1782  p_LmCheckPolyRing1(b, r);
1783  pIfThen1(a != NULL, p_LmCheckPolyRing1(b, r));
1784  if (p_GetComp(a, r) == 0 || p_GetComp(a,r) == p_GetComp(b,r))
1785  return _p_LmDivisibleByNoCompPart(a, r, b, r,start, end);
1786  return FALSE;
1787 }

◆ p_LmExpVectorAddIsOk()

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

Definition at line 1958 of file p_polys.h.

1960 {
1961  p_LmCheckPolyRing(p1, r);
1962  p_LmCheckPolyRing(p2, r);
1963  unsigned long l1, l2, divmask = r->divmask;
1964  int i;
1965 
1966  for (i=0; i<r->VarL_Size; i++)
1967  {
1968  l1 = p1->exp[r->VarL_Offset[i]];
1969  l2 = p2->exp[r->VarL_Offset[i]];
1970  // do the divisiblity trick
1971  if ( (l1 > ULONG_MAX - l2) ||
1972  (((l1 & divmask) ^ (l2 & divmask)) != ((l1 + l2) & divmask)))
1973  return FALSE;
1974  }
1975  return TRUE;
1976 }

◆ p_LmFree() [1/2]

static void p_LmFree ( poly *  p,
ring   
)
inlinestatic

Definition at line 692 of file p_polys.h.

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

◆ p_LmFree() [2/2]

static void p_LmFree ( poly  p,
ring   
)
inlinestatic

Definition at line 683 of file p_polys.h.

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

◆ p_LmFreeAndNext()

static poly p_LmFreeAndNext ( poly  p,
ring   
)
inlinestatic

Definition at line 703 of file p_polys.h.

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

◆ p_LmInit() [1/3]

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

Definition at line 1281 of file p_polys.h.

1282 {
1283  p_LmCheckPolyRing1(p, r);
1284  poly np;
1285  omTypeAllocBin(poly, np, r->PolyBin);
1286  p_SetRingOfLm(np, r);
1287  memcpy(np->exp, p->exp, r->ExpL_Size*sizeof(long));
1288  pNext(np) = NULL;
1289  pSetCoeff0(np, NULL);
1290  return np;
1291 }

◆ p_LmInit() [2/3]

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

Definition at line 1309 of file p_polys.h.

1310 {
1311  pAssume1(d_r != NULL);
1312  return p_LmInit(s_p, s_r, d_r, d_r->PolyBin);
1313 }

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

1293 {
1294  p_LmCheckPolyRing1(s_p, s_r);
1295  p_CheckRing(d_r);
1296  pAssume1(d_r->N <= s_r->N);
1297  poly d_p = p_Init(d_r, d_bin);
1298  for (unsigned i=d_r->N; i!=0; i--)
1299  {
1300  p_SetExp(d_p, i, p_GetExp(s_p, i,s_r), d_r);
1301  }
1302  if (rRing_has_Comp(d_r))
1303  {
1304  p_SetComp(d_p, p_GetComp(s_p,s_r), d_r);
1305  }
1306  p_Setm(d_p, d_r);
1307  return d_p;
1308 }
BOOLEAN p_CheckRing(ring r)
Definition: pDebug.cc:128

◆ p_LmIsConstant()

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

Definition at line 979 of file p_polys.h.

980 {
981  if (p_LmIsConstantComp(p, r))
982  return (p_GetComp(p, r) == 0);
983  return FALSE;
984 }

◆ p_LmIsConstantComp()

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

Definition at line 962 of file p_polys.h.

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

◆ p_LmShallowCopyDelete()

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

Definition at line 1339 of file p_polys.h.

1340 {
1341  p_LmCheckPolyRing1(p, r);
1342  pAssume1(omSizeWOfBin(bin) == omSizeWOfBin(r->PolyBin));
1343  poly new_p = p_New(r);
1344  memcpy(new_p->exp, p->exp, r->ExpL_Size*sizeof(long));
1345  pSetCoeff0(new_p, pGetCoeff(p));
1346  pNext(new_p) = pNext(p);
1347  omFreeBinAddr(p);
1348  return new_p;
1349 }
static poly p_New(const ring, omBin bin)
Definition: p_polys.h:664

◆ p_LmShortDivisibleBy() [1/2]

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

Definition at line 1889 of file p_polys.h.

1891 {
1892  p_LmCheckPolyRing1(a, r_a);
1893  p_LmCheckPolyRing1(b, r_b);
1894 #ifndef PDIV_DEBUG
1895  _pPolyAssume2(p_GetShortExpVector(a, r_a) == sev_a, a, r_a);
1896  _pPolyAssume2(p_GetShortExpVector(b, r_b) == ~ not_sev_b, b, r_b);
1897 
1898  if (sev_a & not_sev_b)
1899  {
1900  pAssume1(_p_LmDivisibleByNoComp(a, r_a, b, r_b) == FALSE);
1901  return FALSE;
1902  }
1903  return _p_LmDivisibleBy(a, r_a, b, r_b);
1904 #else
1905  return pDebugLmShortDivisibleBy(a, sev_a, r_a, b, not_sev_b, r_b);
1906 #endif
1907 }
#define _pPolyAssume2(cond, p, r)
Definition: monomials.h:202
BOOLEAN pDebugLmShortDivisibleBy(poly p1, unsigned long sev_1, ring r_1, poly p2, unsigned long not_sev_2, ring r_2)
Definition: pDebug.cc:366
unsigned long p_GetShortExpVector(const poly a, const ring r)
Definition: p_polys.cc:4665

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

1851 {
1852  p_LmCheckPolyRing1(a, r);
1853  p_LmCheckPolyRing1(b, r);
1854 #ifndef PDIV_DEBUG
1855  _pPolyAssume2(p_GetShortExpVector(a, r) == sev_a, a, r);
1856  _pPolyAssume2(p_GetShortExpVector(b, r) == ~ not_sev_b, b, r);
1857 
1858  if (sev_a & not_sev_b)
1859  {
1861  return FALSE;
1862  }
1863  return p_LmDivisibleBy(a, b, r);
1864 #else
1865  return pDebugLmShortDivisibleBy(a, sev_a, r, b, not_sev_b, r);
1866 #endif
1867 }
static BOOLEAN p_LmDivisibleByNoComp(poly a, poly b, const ring r)
Definition: p_polys.h:1801
static BOOLEAN p_LmDivisibleBy(poly a, poly b, const ring r)
Definition: p_polys.h:1815

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

1871 {
1872  p_LmCheckPolyRing1(a, r);
1873  p_LmCheckPolyRing1(b, r);
1874 #ifndef PDIV_DEBUG
1875  _pPolyAssume2(p_GetShortExpVector(a, r) == sev_a, a, r);
1876  _pPolyAssume2(p_GetShortExpVector(b, r) == ~ not_sev_b, b, r);
1877 
1878  if (sev_a & not_sev_b)
1879  {
1881  return FALSE;
1882  }
1883  return p_LmDivisibleByNoComp(a, b, r);
1884 #else
1885  return pDebugLmShortDivisibleByNoComp(a, sev_a, r, b, not_sev_b, r);
1886 #endif
1887 }
BOOLEAN pDebugLmShortDivisibleByNoComp(poly p1, unsigned long sev_1, ring r_1, poly p2, unsigned long not_sev_2, ring r_2)
Definition: pDebug.cc:389

◆ p_LowVar()

int p_LowVar ( poly  p,
const ring  r 
)

the minimal index of used variables - 1

Definition at line 4564 of file p_polys.cc.

4565 {
4566  int k,l,lex;
4567 
4568  if (p == NULL) return -1;
4569 
4570  k = 32000;/*a very large dummy value*/
4571  while (p != NULL)
4572  {
4573  l = 1;
4574  lex = p_GetExp(p,l,r);
4575  while ((l < (rVar(r))) && (lex == 0))
4576  {
4577  l++;
4578  lex = p_GetExp(p,l,r);
4579  }
4580  l--;
4581  if (l < k) k = l;
4582  pIter(p);
4583  }
4584  return k;
4585 }

◆ p_LtCmp()

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

Definition at line 1548 of file p_polys.h.

1549 {
1550  int res = p_LmCmp(p,q,r);
1551  if(res == 0)
1552  {
1553  if(p_GetCoeff(p,r) == NULL || p_GetCoeff(q,r) == NULL)
1554  return res;
1555  number pc = n_Copy(p_GetCoeff(p,r),r->cf);
1556  number qc = n_Copy(p_GetCoeff(q,r),r->cf);
1557  if(!n_GreaterZero(pc,r->cf))
1558  pc = n_InpNeg(pc,r->cf);
1559  if(!n_GreaterZero(qc,r->cf))
1560  qc = n_InpNeg(qc,r->cf);
1561  if(n_Greater(pc,qc,r->cf))
1562  res = 1;
1563  else if(n_Greater(qc,pc,r->cf))
1564  res = -1;
1565  else if(n_Equal(pc,qc,r->cf))
1566  res = 0;
1567  n_Delete(&pc,r->cf);
1568  n_Delete(&qc,r->cf);
1569  }
1570  return res;
1571 }
static FORCE_INLINE BOOLEAN n_Greater(number a, number b, const coeffs r)
ordered fields: TRUE iff 'a' is larger than 'b'; in Z/pZ: TRUE iff la > lb, where la and lb are the l...
Definition: coeffs.h:512

◆ p_LtCmpNoAbs()

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

Definition at line 1574 of file p_polys.h.

1575 {
1576  int res = p_LmCmp(p,q,r);
1577  if(res == 0)
1578  {
1579  if(p_GetCoeff(p,r) == NULL || p_GetCoeff(q,r) == NULL)
1580  return res;
1581  number pc = p_GetCoeff(p,r);
1582  number qc = p_GetCoeff(q,r);
1583  if(n_Greater(pc,qc,r->cf))
1584  res = 1;
1585  if(n_Greater(qc,pc,r->cf))
1586  res = -1;
1587  if(n_Equal(pc,qc,r->cf))
1588  res = 0;
1589  }
1590  return res;
1591 }

◆ p_LtCmpOrdSgnDiffM()

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

Definition at line 1596 of file p_polys.h.

1597 {
1598  if(r->OrdSgn == 1)
1599  {
1600  return(p_LtCmp(p,q,r) == 1);
1601  }
1602  else
1603  {
1604  return(p_LmCmp(p,q,r) == -1);
1605  }
1606 }
static int p_LtCmp(poly p, poly q, const ring r)
Definition: p_polys.h:1548

◆ p_LtCmpOrdSgnDiffP()

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

Definition at line 1612 of file p_polys.h.

1613 {
1614  if(r->OrdSgn == 1)
1615  {
1616  return(p_LmCmp(p,q,r) == -1);
1617  }
1618  else
1619  {
1620  return(p_LtCmp(p,q,r) != -1);
1621  }
1622 
1623 }

◆ p_LtCmpOrdSgnEqM()

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

Definition at line 1629 of file p_polys.h.

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

◆ p_LtCmpOrdSgnEqP()

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

Definition at line 1638 of file p_polys.h.

1639 {
1640  return(p_LtCmp(p,q,r) == r->OrdSgn);
1641 }

◆ p_MaxComp() [1/2]

static long p_MaxComp ( poly  p,
ring  lmRing 
)
inlinestatic

Definition at line 311 of file p_polys.h.

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

◆ p_MaxComp() [2/2]

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

Definition at line 292 of file p_polys.h.

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

◆ p_MDivide()

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

Definition at line 1454 of file p_polys.cc.

1455 {
1456  assume((p_GetComp(a,r)==p_GetComp(b,r)) || (p_GetComp(b,r)==0));
1457  int i;
1458  poly result = p_Init(r);
1459 
1460  for(i=(int)r->N; i; i--)
1461  p_SetExp(result,i, p_GetExp(a,i,r)- p_GetExp(b,i,r),r);
1462  p_SetComp(result, p_GetComp(a,r) - p_GetComp(b,r),r);
1463  p_Setm(result,r);
1464  return result;
1465 }

◆ p_MemAdd_NegWeightAdjust()

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

Definition at line 1238 of file p_polys.h.

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

◆ p_MemSub_NegWeightAdjust()

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

Definition at line 1248 of file p_polys.h.

1249 {
1250  if (r->NegWeightL_Offset != NULL)
1251  {
1252  for (int i=r->NegWeightL_Size-1; i>=0; i--)
1253  {
1254  p->exp[r->NegWeightL_Offset[i]] += POLY_NEGWEIGHT_OFFSET;
1255  }
1256  }
1257 }

◆ p_Merge_q()

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

Definition at line 1158 of file p_polys.h.

1159 {
1160  assume( (p != q) || (p == NULL && q == NULL) );
1161  return r->p_Procs->p_Merge_q(p, q, r);
1162 }

◆ p_MinComp() [1/2]

static long p_MinComp ( poly  p,
ring  lmRing 
)
inlinestatic

Definition at line 332 of file p_polys.h.

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

◆ p_MinComp() [2/2]

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

Definition at line 313 of file p_polys.h.

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

◆ p_MinDeg()

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

Definition at line 4332 of file p_polys.cc.

4333 {
4334  if(p==NULL)
4335  return -1;
4336  int d=-1;
4337  while(p!=NULL)
4338  {
4339  int d0=0;
4340  for(int j=0;j<rVar(R);j++)
4341  if(w==NULL||j>=w->length())
4342  d0+=p_GetExp(p,j+1,R);
4343  else
4344  d0+=(*w)[j]*p_GetExp(p,j+1,R);
4345  if(d0<d||d==-1)
4346  d=d0;
4347  pIter(p);
4348  }
4349  return d;
4350 }

◆ p_mInit()

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

Definition at line 1412 of file p_polys.cc.

1413 {
1414  poly p;
1415  const char *s=p_Read(st,p,r);
1416  if (*s!='\0')
1417  {
1418  if ((s!=st)&&isdigit(st[0]))
1419  {
1421  }
1422  ok=FALSE;
1423  p_Delete(&p,r);
1424  return NULL;
1425  }
1426  p_Test(p,r);
1427  ok=!errorreported;
1428  return p;
1429 }
short errorreported
Definition: feFopen.cc:23
const char * p_Read(const char *st, poly &rc, const ring r)
Definition: p_polys.cc:1340

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

1018 {
1019  int shorter;
1020 
1021  return r->p_Procs->p_Minus_mm_Mult_qq(p, m, q, shorter, NULL, r);
1022 }

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

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

◆ p_Mult_mm()

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

Definition at line 997 of file p_polys.h.

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

◆ p_Mult_nn() [1/2]

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

Definition at line 929 of file p_polys.h.

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

◆ p_Mult_nn() [2/2]

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

Definition at line 914 of file p_polys.h.

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

◆ p_Mult_q()

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

Definition at line 1050 of file p_polys.h.

1051 {
1052  assume( (p != q) || (p == NULL && q == NULL) );
1053 
1054  if (p == NULL)
1055  {
1056  p_Delete(&q, r);
1057  return NULL;
1058  }
1059  if (q == NULL)
1060  {
1061  p_Delete(&p, r);
1062  return NULL;
1063  }
1064 
1065  if (pNext(p) == NULL)
1066  {
1067 #ifdef HAVE_PLURAL
1068  if (rIsPluralRing(r))
1069  q = nc_mm_Mult_p(p, q, r);
1070  else
1071 #endif /* HAVE_PLURAL */
1072  q = r->p_Procs->p_Mult_mm(q, p, r);
1073 
1074  p_LmDelete(&p, r);
1075  return q;
1076  }
1077 
1078  if (pNext(q) == NULL)
1079  {
1080  p = r->p_Procs->p_Mult_mm(p, q, r);
1081  p_LmDelete(&q, r);
1082  return p;
1083  }
1084 #ifdef HAVE_PLURAL
1085  if (rIsPluralRing(r))
1086  return _nc_p_Mult_q(p, q, r);
1087  else
1088 #endif
1089  return _p_Mult_q(p, q, 0, r);
1090 }
static poly nc_mm_Mult_p(const poly m, poly p, const ring r)
Definition: nc.h:242
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 rIsPluralRing(const ring r)
we must always have this test!
Definition: ring.h:404

◆ p_MultExp()

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

Definition at line 621 of file p_polys.h.

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

◆ p_Neg()

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

Definition at line 1043 of file p_polys.h.

1044 {
1045  return r->p_Procs->p_Neg(p, r);
1046 }

◆ p_New() [1/2]

static poly p_New ( const  ring,
omBin  bin 
)
inlinestatic

Definition at line 664 of file p_polys.h.

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

◆ p_New() [2/2]

static poly p_New ( ring  r)
inlinestatic

Definition at line 675 of file p_polys.h.

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

◆ p_Norm()

void p_Norm ( poly  p1,
const ring  r 
)

Definition at line 3656 of file p_polys.cc.

3657 {
3658  if (rField_is_Ring(r))
3659  {
3660  if (!n_IsUnit(pGetCoeff(p1), r->cf)) return;
3661  // Werror("p_Norm not possible in the case of coefficient rings.");
3662  }
3663  else if (p1!=NULL)
3664  {
3665  if (pNext(p1)==NULL)
3666  {
3667  p_SetCoeff(p1,n_Init(1,r->cf),r);
3668  return;
3669  }
3670  poly h;
3671  if (!n_IsOne(pGetCoeff(p1),r->cf))
3672  {
3673  number k, c;
3674  n_Normalize(pGetCoeff(p1),r->cf);
3675  k = pGetCoeff(p1);
3676  c = n_Init(1,r->cf);
3677  pSetCoeff0(p1,c);
3678  h = pNext(p1);
3679  while (h!=NULL)
3680  {
3681  c=n_Div(pGetCoeff(h),k,r->cf);
3682  // no need to normalize: Z/p, R
3683  // normalize already in nDiv: Q_a, Z/p_a
3684  // remains: Q
3685  if (rField_is_Q(r) && (!n_IsOne(c,r->cf))) n_Normalize(c,r->cf);
3686  p_SetCoeff(h,c,r);
3687  pIter(h);
3688  }
3689  n_Delete(&k,r->cf);
3690  }
3691  else
3692  {
3693  //if (r->cf->cfNormalize != nDummy2) //TODO: OPTIMIZE
3694  {
3695  h = pNext(p1);
3696  while (h!=NULL)
3697  {
3698  n_Normalize(pGetCoeff(h),r->cf);
3699  pIter(h);
3700  }
3701  }
3702  }
3703  }
3704 }

◆ p_Normalize()

void p_Normalize ( poly  p,
const ring  r 
)

Definition at line 3709 of file p_polys.cc.

3710 {
3711  if (rField_has_simple_inverse(r)) return; /* Z/p, GF(p,n), R, long R/C */
3712  while (p!=NULL)
3713  {
3714  // no test befor n_Normalize: n_Normalize should fix problems
3715  n_Normalize(pGetCoeff(p),r->cf);
3716  pIter(p);
3717  }
3718 }
static BOOLEAN rField_has_simple_inverse(const ring r)
Definition: ring.h:540

◆ p_NSet()

poly p_NSet ( number  n,
const ring  r 
)

returns the poly representing the number n, destroys n

Definition at line 1435 of file p_polys.cc.

1436 {
1437  if (n_IsZero(n,r->cf))
1438  {
1439  n_Delete(&n, r->cf);
1440  return NULL;
1441  }
1442  else
1443  {
1444  poly rc = p_Init(r);
1445  pSetCoeff0(rc,n);
1446  return rc;
1447  }
1448 }

◆ p_One()

poly p_One ( const ring  r)

Definition at line 1305 of file p_polys.cc.

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

◆ p_OneComp()

BOOLEAN p_OneComp ( poly  p,
const ring  r 
)

return TRUE if all monoms have the same component

Definition at line 1200 of file p_polys.cc.

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

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

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

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

1152 {
1153  int lp = 0, lq = 0;
1154  return p_Plus_mm_Mult_qq(p, m, q, lp, lq, r);
1155 }
static poly p_Plus_mm_Mult_qq(poly p, poly m, poly q, int &lp, int lq, const ring r)
Definition: p_polys.h:1129

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

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

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

1818 {
1819  assume(divisor != NULL);
1820  if (p == NULL) return NULL;
1821 
1822  poly result = NULL;
1823  number divisorLC = p_GetCoeff(divisor, r);
1824  int divisorLE = p_GetExp(divisor, 1, r);
1825  while ((p != NULL) && (p_Deg(p, r) >= p_Deg(divisor, r)))
1826  {
1827  /* determine t = LT(p) / LT(divisor) */
1828  poly t = p_ISet(1, r);
1829  number c = n_Div(p_GetCoeff(p, r), divisorLC, r->cf);
1830  n_Normalize(c,r->cf);
1831  p_SetCoeff(t, c, r);
1832  int e = p_GetExp(p, 1, r) - divisorLE;
1833  p_SetExp(t, 1, e, r);
1834  p_Setm(t, r);
1835  if (needResult) result = p_Add_q(result, p_Copy(t, r), r);
1836  p = p_Add_q(p, p_Neg(p_Mult_q(t, p_Copy(divisor, r), r), r), r);
1837  }
1838  return result;
1839 }
long p_Deg(poly a, const ring r)
Definition: p_polys.cc:579

◆ p_Power()

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

Definition at line 2144 of file p_polys.cc.

2145 {
2146  poly rc=NULL;
2147 
2148  if (i==0)
2149  {
2150  p_Delete(&p,r);
2151  return p_One(r);
2152  }
2153 
2154  if(p!=NULL)
2155  {
2156  if ( (i > 0) && ((unsigned long ) i > (r->bitmask)))
2157  {
2158  Werror("exponent %d is too large, max. is %ld",i,r->bitmask);
2159  return NULL;
2160  }
2161  switch (i)
2162  {
2163 // cannot happen, see above
2164 // case 0:
2165 // {
2166 // rc=pOne();
2167 // pDelete(&p);
2168 // break;
2169 // }
2170  case 1:
2171  rc=p;
2172  break;
2173  case 2:
2174  rc=p_Mult_q(p_Copy(p,r),p,r);
2175  break;
2176  default:
2177  if (i < 0)
2178  {
2179  p_Delete(&p,r);
2180  return NULL;
2181  }
2182  else
2183  {
2184 #ifdef HAVE_PLURAL
2185  if (rIsPluralRing(r)) /* in the NC case nothing helps :-( */
2186  {
2187  int j=i;
2188  rc = p_Copy(p,r);
2189  while (j>1)
2190  {
2191  rc = p_Mult_q(p_Copy(p,r),rc,r);
2192  j--;
2193  }
2194  p_Delete(&p,r);
2195  return rc;
2196  }
2197 #endif
2198  rc = pNext(p);
2199  if (rc == NULL)
2200  return p_MonPower(p,i,r);
2201  /* else: binom ?*/
2202  int char_p=rChar(r);
2203  if ((char_p>0) && (i>char_p)
2204  && ((rField_is_Zp(r,char_p)
2205  || (rField_is_Zp_a(r,char_p)))))
2206  {
2207  poly h=p_Pow_charp(p_Copy(p,r),char_p,r);
2208  int rest=i-char_p;
2209  while (rest>=char_p)
2210  {
2211  rest-=char_p;
2212  h=p_Mult_q(h,p_Pow_charp(p_Copy(p,r),char_p,r),r);
2213  }
2214  poly res=h;
2215  if (rest>0)
2216  res=p_Mult_q(p_Power(p_Copy(p,r),rest,r),h,r);
2217  p_Delete(&p,r);
2218  return res;
2219  }
2220  if ((pNext(rc) != NULL)
2221  || rField_is_Ring(r)
2222  )
2223  return p_Pow(p,i,r);
2224  if ((char_p==0) || (i<=char_p))
2225  return p_TwoMonPower(p,i,r);
2226  return p_Pow(p,i,r);
2227  }
2228  /*end default:*/
2229  }
2230  }
2231  return rc;
2232 }
poly p_Power(poly p, int i, const ring r)
Definition: p_polys.cc:2144
static poly p_TwoMonPower(poly p, int exp, const ring r)
Definition: p_polys.cc:2053
static poly p_Pow_charp(poly p, int i, const ring r)
Definition: p_polys.cc:2132
static poly p_MonPower(poly p, int exp, const ring r)
Definition: p_polys.cc:1947
static poly p_Pow(poly p, int i, const ring r)
Definition: p_polys.cc:2118
void Werror(const char *fmt,...)
Definition: reporter.cc:189
int rChar(ring r)
Definition: ring.cc:688
static BOOLEAN rField_is_Zp_a(const ring r)
Definition: ring.h:521

◆ p_ProjectiveUnique()

void p_ProjectiveUnique ( poly  p,
const ring  r 
)

Definition at line 3080 of file p_polys.cc.

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

◆ p_Read()

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

Definition at line 1340 of file p_polys.cc.

1341 {
1342  if (r==NULL) { rc=NULL;return st;}
1343  int i,j;
1344  rc = p_Init(r);
1345  const char *s = n_Read(st,&(p_GetCoeff(rc, r)),r->cf);
1346  if (s==st)
1347  /* i.e. it does not start with a coeff: test if it is a ringvar*/
1348  {
1349  j = r_IsRingVar(s,r->names,r->N);
1350  if (j >= 0)
1351  {
1352  p_IncrExp(rc,1+j,r);
1353  while (*s!='\0') s++;
1354  goto done;
1355  }
1356  }
1357  while (*s!='\0')
1358  {
1359  char ss[2];
1360  ss[0] = *s++;
1361  ss[1] = '\0';
1362  j = r_IsRingVar(ss,r->names,r->N);
1363  if (j >= 0)
1364  {
1365  const char *s_save=s;
1366  s = eati(s,&i);
1367  if (((unsigned long)i) > r->bitmask/2)
1368  {
1369  // exponent to large: it is not a monomial
1370  p_LmDelete(&rc,r);
1371  return s_save;
1372  }
1373  p_AddExp(rc,1+j, (long)i, r);
1374  }
1375  else
1376  {
1377  // 1st char of is not a varname
1378  // We return the parsed polynomial nevertheless. This is needed when
1379  // we are parsing coefficients in a rational function field.
1380  s--;
1381  break;
1382  }
1383  }
1384 done:
1385  if (n_IsZero(pGetCoeff(rc),r->cf)) p_LmDelete(&rc,r);
1386  else
1387  {
1388 #ifdef HAVE_PLURAL
1389  // in super-commutative ring
1390  // squares of anti-commutative variables are zeroes!
1391  if(rIsSCA(r))
1392  {
1393  const unsigned int iFirstAltVar = scaFirstAltVar(r);
1394  const unsigned int iLastAltVar = scaLastAltVar(r);
1395 
1396  assume(rc != NULL);
1397 
1398  for(unsigned int k = iFirstAltVar; k <= iLastAltVar; k++)
1399  if( p_GetExp(rc, k, r) > 1 )
1400  {
1401  p_LmDelete(&rc, r);
1402  goto finish;
1403  }
1404  }
1405 #endif
1406 
1407  p_Setm(rc,r);
1408  }
1409 finish:
1410  return s;
1411 }
static FORCE_INLINE const char * n_Read(const char *s, number *a, const coeffs r)
!!! Recommendation: This method is too cryptic to be part of the user- !!! interface....
Definition: coeffs.h:599
const char * eati(const char *s, int *i)
Definition: reporter.cc:373
static bool rIsSCA(const ring r)
Definition: nc.h:198
static long p_IncrExp(poly p, int v, ring r)
Definition: p_polys.h:591
int r_IsRingVar(const char *n, char **names, int N)
Definition: ring.cc:213
static short scaLastAltVar(ring r)
Definition: sca.h:25
static short scaFirstAltVar(ring r)
Definition: sca.h:18

◆ p_Series()

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

Definition at line 4382 of file p_polys.cc.

4383 {
4384  short *ww=iv2array(w,R);
4385  if(p!=NULL)
4386  {
4387  if(u==NULL)
4388  p=p_JetW(p,n,ww,R);
4389  else
4390  p=p_JetW(p_Mult_q(p,p_Invers(n-p_MinDeg(p,w,R),u,w,R),R),n,ww,R);
4391  }
4392  omFreeSize((ADDRESS)ww,(rVar(R)+1)*sizeof(short));
4393  return p;
4394 }
static poly p_Invers(int n, poly u, intvec *w, const ring R)
Definition: p_polys.cc:4353
int p_MinDeg(poly p, intvec *w, const ring R)
Definition: p_polys.cc:4332
poly p_JetW(poly p, int m, short *w, const ring R)
Definition: p_polys.cc:4314
short * iv2array(intvec *iv, const ring R)
Definition: weight.cc:206

◆ p_SetCoeff()

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

Definition at line 412 of file p_polys.h.

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

◆ p_SetComp()

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

Definition at line 247 of file p_polys.h.

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

◆ p_SetCompP() [1/2]

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

Definition at line 281 of file p_polys.h.

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

◆ p_SetCompP() [2/2]

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

Definition at line 254 of file p_polys.h.

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

◆ p_SetExp() [1/3]

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

set v^th exponent for a monomial

Definition at line 582 of file p_polys.h.

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

◆ p_SetExp() [2/3]

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

Definition at line 562 of file p_polys.h.

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

◆ p_SetExp() [3/3]

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

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

See also
p_GetExp

Definition at line 488 of file p_polys.h.

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

◆ p_SetExpV()

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

Definition at line 1481 of file p_polys.h.

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

◆ p_SetExpVL()

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

Definition at line 1491 of file p_polys.h.

1492 {
1493  p_LmCheckPolyRing1(p, r);
1494  for (unsigned j = r->N; j!=0; j--)
1495  p_SetExp(p, j, ev[j], r);
1496 
1497  if(ev[0]!=0) p_SetComp(p, ev[0],r);
1498  p_Setm(p, r);
1499 }

◆ p_Setm()

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

Definition at line 233 of file p_polys.h.

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

◆ p_SetModDeg()

void p_SetModDeg ( intvec w,
ring  r 
)

Definition at line 3610 of file p_polys.cc.

3611 {
3612  if (w!=NULL)
3613  {
3614  r->pModW = w;
3615  pOldFDeg = r->pFDeg;
3616  pOldLDeg = r->pLDeg;
3617  pOldLexOrder = r->pLexOrder;
3618  pSetDegProcs(r,pModDeg);
3619  r->pLexOrder = TRUE;
3620  }
3621  else
3622  {
3623  r->pModW = NULL;
3625  r->pLexOrder = pOldLexOrder;
3626  }
3627 }
void pRestoreDegProcs(ring r, pFDegProc old_FDeg, pLDegProc old_lDeg)
Definition: p_polys.cc:3586
static BOOLEAN pOldLexOrder
Definition: p_polys.cc:3599
static pLDegProc pOldLDeg
Definition: p_polys.cc:3598
void pSetDegProcs(ring r, pFDegProc new_FDeg, pLDegProc new_lDeg)
Definition: p_polys.cc:3574
static long pModDeg(poly p, ring r)
Definition: p_polys.cc:3601
static pFDegProc pOldFDeg
Definition: p_polys.cc:3597

◆ p_ShallowCopyDelete()

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

Definition at line 884 of file p_polys.h.

885 {
886  p_LmCheckPolyRing2(p, r);
887  pAssume2(omSizeWOfBin(r->PolyBin) == omSizeWOfBin(bin));
888  return r->p_Procs->p_ShallowCopyDelete(p, r, bin);
889 }

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

4591 {
4592  poly qp1 = *p,qp2 = *p;/*working pointers*/
4593  int j = p_MaxComp(*p,r),k = p_MinComp(*p,r);
4594 
4595  if (j+i < 0) return ;
4596  BOOLEAN toPoly= ((j == -i) && (j == k));
4597  while (qp1 != NULL)
4598  {
4599  if (toPoly || (__p_GetComp(qp1,r)+i > 0))
4600  {
4601  p_AddComp(qp1,i,r);
4602  p_SetmComp(qp1,r);
4603  qp2 = qp1;
4604  pIter(qp1);
4605  }
4606  else
4607  {
4608  if (qp2 == *p)
4609  {
4610  pIter(*p);
4611  p_LmDelete(&qp2,r);
4612  qp2 = *p;
4613  qp1 = *p;
4614  }
4615  else
4616  {
4617  qp2->next = qp1->next;
4618  if (qp1!=NULL) p_LmDelete(&qp1,r);
4619  qp1 = qp2->next;
4620  }
4621  }
4622  }
4623 }
return
Definition: cfGcdAlgExt.cc:218
static unsigned long p_AddComp(poly p, unsigned long v, ring r)
Definition: p_polys.h:447

◆ p_SimpleContent()

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

Definition at line 2492 of file p_polys.cc.

2493 {
2494  if(TEST_OPT_CONTENTSB) return;
2495  if (ph==NULL) return;
2496  if (pNext(ph)==NULL)
2497  {
2498  p_SetCoeff(ph,n_Init(1,r->cf),r);
2499  return;
2500  }
2501  if ((pNext(pNext(ph))==NULL)||(!rField_is_Q(r)))
2502  {
2503  return;
2504  }
2505  number d=p_InitContent(ph,r);
2506  if (n_Size(d,r->cf)<=smax)
2507  {
2508  //if (TEST_OPT_PROT) PrintS("G");
2509  return;
2510  }
2511 
2512  poly p=ph;
2513  number h=d;
2514  if (smax==1) smax=2;
2515  while (p!=NULL)
2516  {
2517 #if 0
2518  d=n_Gcd(h,pGetCoeff(p),r->cf);
2519  n_Delete(&h,r->cf);
2520  h = d;
2521 #else
2522  STATISTIC(n_Gcd); nlInpGcd(h,pGetCoeff(p),r->cf);
2523 #endif
2524  if(n_Size(h,r->cf)<smax)
2525  {
2526  //if (TEST_OPT_PROT) PrintS("g");
2527  return;
2528  }
2529  pIter(p);
2530  }
2531  p = ph;
2532  if (!n_GreaterZero(pGetCoeff(p),r->cf)) h=n_InpNeg(h,r->cf);
2533  if(n_IsOne(h,r->cf)) return;
2534  //if (TEST_OPT_PROT) PrintS("c");
2535  while (p!=NULL)
2536  {
2537 #if 1
2538  d = n_ExactDiv(pGetCoeff(p),h,r->cf);
2539  p_SetCoeff(p,d,r);
2540 #else
2541  STATISTIC(n_ExactDiv); nlInpExactDiv(pGetCoeff(p),h,r->cf); // no such function... ?
2542 #endif
2543  pIter(p);
2544  }
2545  n_Delete(&h,r->cf);
2546 }
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:687
void nlInpGcd(number &a, number b, const coeffs r)
Definition: longrat.cc:2774
#define STATISTIC(f)
Definition: numstats.h:16

◆ p_Size()

int p_Size ( poly  p,
const ring  r 
)

Definition at line 3191 of file p_polys.cc.

3192 {
3193  int count = 0;
3194  if (r->cf->has_simple_Alloc)
3195  return pLength(p);
3196  while ( p != NULL )
3197  {
3198  count+= n_Size( pGetCoeff( p ), r->cf );
3199  pIter( p );
3200  }
3201  return count;
3202 }
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 1165 of file p_polys.h.

1166 {
1167  if (revert) p = pReverse(p);
1168  return sBucketSortAdd(p, r);
1169 }
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 1175 of file p_polys.h.

1176 {
1177  if (revert) p = pReverse(p);
1178  return sBucketSortMerge(p, r);
1179 }
poly sBucketSortMerge(poly p, const ring r)
Sorts p with bucketSort: assumes all monomials of p are different.
Definition: sbuckets.cc:334

◆ p_Split()

void p_Split ( poly  p,
poly *  r 
)

Definition at line 1312 of file p_polys.cc.

1313 {
1314  *h=pNext(p);
1315  pNext(p)=NULL;
1316 }

◆ p_String() [1/2]

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

Definition at line 184 of file polys0.cc.

185 {
186  StringSetS("");
187  p_String0(p, lmRing, tailRing);
188  return StringEndS();
189 }
void p_String0(poly p, ring lmRing, ring tailRing)
print p according to ShortOut in lmRing & tailRing
Definition: polys0.cc:134
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 1186 of file p_polys.h.

1187 {
1188  return p_String(p, p_ring, p_ring);
1189 }
char * p_String(poly p, ring lmRing, ring tailRing)
Definition: polys0.cc:184

◆ p_String0() [1/2]

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

print p according to ShortOut in lmRing & tailRing

Definition at line 134 of file polys0.cc.

135 {
136  if (p == NULL)
137  {
138  StringAppendS("0");
139  return;
140  }
141  p_Normalize(p,lmRing);
142  if ((n_GetChar(lmRing->cf) == 0)
143  && (nCoeff_is_transExt(lmRing->cf)))
144  p_Normalize(p,lmRing); /* Manual/absfact.tst */
145  if ((p_GetComp(p, lmRing) == 0) || (!lmRing->VectorOut))
146  {
147  writemon(p,0, lmRing);
148  p = pNext(p);
149  while (p!=NULL)
150  {
151  assume((p->coef==NULL)||(!n_IsZero(p->coef,tailRing->cf)));
152  if ((p->coef==NULL)||n_GreaterZero(p->coef,tailRing->cf))
153  StringAppendS("+");
154  writemon(p,0, tailRing);
155  p = pNext(p);
156  }
157  return;
158  }
159 
160  long k = 1;
161  StringAppendS("[");
162  loop
163  {
164  while (k < p_GetComp(p,lmRing))
165  {
166  StringAppendS("0,");
167  k++;
168  }
169  writemon(p,k,lmRing);
170  pIter(p);
171  while ((p!=NULL) && (k == p_GetComp(p, tailRing)))
172  {
173  if (n_GreaterZero(p->coef,tailRing->cf)) StringAppendS("+");
174  writemon(p,k,tailRing);
175  pIter(p);
176  }
177  if (p == NULL) break;
178  StringAppendS(",");
179  k++;
180  }
181  StringAppendS("]");
182 }
static void writemon(poly p, int ko, const ring r)
Definition: polys0.cc:21
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 1190 of file p_polys.h.

1191 {
1192  p_String0(p, p_ring, p_ring);
1193 }
void p_String0(poly p, ring lmRing, ring tailRing)
print p according to ShortOut in lmRing & tailRing
Definition: polys0.cc:134

◆ 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 114 of file polys0.cc.

115 {
116  // NOTE: the following (non-thread-safe!) UGLYNESS
117  // (changing naRing->ShortOut for a while) is due to Hans!
118  // Just think of other ring using the VERY SAME naRing and possible
119  // side-effects...
120  // but this is not a problem: i/o is not thread-safe anyway.
121  const BOOLEAN bLMShortOut = rShortOut(lmRing);
122  const BOOLEAN bTAILShortOut = rShortOut(tailRing);
123 
124  lmRing->ShortOut = FALSE;
125  tailRing->ShortOut = FALSE;
126 
127  p_String0(p, lmRing, tailRing);
128 
129  lmRing->ShortOut = bLMShortOut;
130  tailRing->ShortOut = bTAILShortOut;
131 }
static BOOLEAN rShortOut(const ring r)
Definition: ring.h:572

◆ 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 95 of file polys0.cc.

96 {
97  // NOTE: the following (non-thread-safe!) UGLYNESS
98  // (changing naRing->ShortOut for a while) is due to Hans!
99  // Just think of other ring using the VERY SAME naRing and possible
100  // side-effects...
101  const BOOLEAN bLMShortOut = rShortOut(lmRing);
102  const BOOLEAN bTAILShortOut = rShortOut(tailRing);
103 
104  lmRing->ShortOut = rCanShortOut(lmRing);
105  tailRing->ShortOut = rCanShortOut(tailRing);
106 
107  p_String0(p, lmRing, tailRing);
108 
109  lmRing->ShortOut = bLMShortOut;
110  tailRing->ShortOut = bTAILShortOut;
111 }
static BOOLEAN rCanShortOut(const ring r)
Definition: ring.h:577

◆ p_Sub()

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

Definition at line 1937 of file p_polys.cc.

1938 {
1939  return p_Add_q(p1, p_Neg(p2,r),r);
1940 }

◆ p_SubComp()

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

Definition at line 453 of file p_polys.h.

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

◆ p_SubExp()

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

Definition at line 613 of file p_polys.h.

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

◆ p_Subst()

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

Definition at line 3851 of file p_polys.cc.

3852 {
3853  if (e == NULL) return p_Subst0(p, n,r);
3854 
3855  if (p_IsConstant(e,r))
3856  {
3857  if (n_IsOne(pGetCoeff(e),r->cf)) return p_Subst1(p,n,r);
3858  else return p_Subst2(p, n, pGetCoeff(e),r);
3859  }
3860 
3861 #ifdef HAVE_PLURAL
3862  if (rIsPluralRing(r))
3863  {
3864  return nc_pSubst(p,n,e,r);
3865  }
3866 #endif
3867 
3868  int exponent,i;
3869  poly h, res, m;
3870  int *me,*ee;
3871  number nu,nu1;
3872 
3873  me=(int *)omAlloc((rVar(r)+1)*sizeof(int));
3874  ee=(int *)omAlloc((rVar(r)+1)*sizeof(int));
3875  if (e!=NULL) p_GetExpV(e,ee,r);
3876  res=NULL;
3877  h=p;
3878  while (h!=NULL)
3879  {
3880  if ((e!=NULL) || (p_GetExp(h,n,r)==0))
3881  {
3882  m=p_Head(h,r);
3883  p_GetExpV(m,me,r);
3884  exponent=me[n];
3885  me[n]=0;
3886  for(i=rVar(r);i>0;i--)
3887  me[i]+=exponent*ee[i];
3888  p_SetExpV(m,me,r);
3889  if (e!=NULL)
3890  {
3891  n_Power(pGetCoeff(e),exponent,&nu,r->cf);
3892  nu1=n_Mult(pGetCoeff(m),nu,r->cf);
3893  n_Delete(&nu,r->cf);
3894  p_SetCoeff(m,nu1,r);
3895  }
3896  res=p_Add_q(res,m,r);
3897  }
3898  p_LmDelete(&h,r);
3899  }
3900  omFreeSize((ADDRESS)me,(rVar(r)+1)*sizeof(int));
3901  omFreeSize((ADDRESS)ee,(rVar(r)+1)*sizeof(int));
3902  return res;
3903 }
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:3228
static poly p_Subst0(poly p, int n, const ring r)
Definition: p_polys.cc:3826
static poly p_Subst1(poly p, int n, const ring r)
Definition: p_polys.cc:3758
static poly p_Subst2(poly p, int n, number e, const ring r)
Definition: p_polys.cc:3785

◆ p_TakeOutComp() [1/2]

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

Definition at line 3385 of file p_polys.cc.

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

◆ p_TakeOutComp() [2/2]

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

Definition at line 3446 of file p_polys.cc.

3447 {
3448  spolyrec pp, qq;
3449  poly p, q, p_prev;
3450  int l = 0;
3451 
3452 #ifndef SING_NDEBUG
3453  int lp = pLength(*r_p);
3454 #endif
3455 
3456  pNext(&pp) = *r_p;
3457  p = *r_p;
3458  p_prev = &pp;
3459  q = &qq;
3460 
3461  while(p != NULL)
3462  {
3463  while (__p_GetComp(p,r) == comp)
3464  {
3465  pNext(q) = p;
3466  pIter(q);
3467  p_SetComp(p, 0,r);
3468  p_SetmComp(p,r);
3469  pIter(p);
3470  l++;
3471  if (p == NULL)
3472  {
3473  pNext(p_prev) = NULL;
3474  goto Finish;
3475  }
3476  }
3477  pNext(p_prev) = p;
3478  p_prev = p;
3479  pIter(p);
3480  }
3481 
3482  Finish:
3483  pNext(q) = NULL;
3484  *r_p = pNext(&pp);
3485  *r_q = pNext(&qq);
3486  *lq = l;
3487 #ifndef SING_NDEBUG
3488  assume(pLength(*r_p) + pLength(*r_q) == lp);
3489 #endif
3490  p_Test(*r_p,r);
3491  p_Test(*r_q,r);
3492 }
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 3334 of file p_polys.cc.

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

◆ p_Totaldegree()

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

Definition at line 1453 of file p_polys.h.

1454 {
1455  p_LmCheckPolyRing1(p, r);
1456  unsigned long s = p_GetTotalDegree(p->exp[r->VarL_Offset[0]],
1457  r,
1458  r->ExpPerLong);
1459  for (unsigned i=r->VarL_Size-1; i!=0; i--)
1460  {
1461  s += p_GetTotalDegree(p->exp[r->VarL_Offset[i]], r,r->ExpPerLong);
1462  }
1463  return (long)s;
1464 }
static unsigned long p_GetTotalDegree(const unsigned long l, const ring r, const int number_of_exps)
Definition: p_polys.h:776

◆ p_Var()

int p_Var ( poly  mi,
const ring  r 
)

Definition at line 4540 of file p_polys.cc.

4541 {
4542  if (m==NULL) return 0;
4543  if (pNext(m)!=NULL) return 0;
4544  int i,e=0;
4545  for (i=rVar(r); i>0; i--)
4546  {
4547  int exp=p_GetExp(m,i,r);
4548  if (exp==1)
4549  {
4550  if (e==0) e=i;
4551  else return 0;
4552  }
4553  else if (exp!=0)
4554  {
4555  return 0;
4556  }
4557  }
4558  return e;
4559 }

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

Definition at line 3550 of file p_polys.cc.

3551 {
3552  poly h;
3553  int k;
3554 
3555  for(int i=len-1;i>=0;i--) p[i]=NULL;
3556  while (v!=NULL)
3557  {
3558  h=p_Head(v,r);
3559  k=__p_GetComp(h,r);
3560  p_SetComp(h,0,r);
3561  pNext(h)=p[k-1];p[k-1]=h;
3562  pIter(v);
3563  }
3564  for(int i=len-1;i>=0;i--)
3565  {
3566  if (p[i]!=NULL) p[i]=pReverse(p[i]);
3567  }
3568 }

◆ p_Vec2Polys()

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

Definition at line 3527 of file p_polys.cc.

3528 {
3529  poly h;
3530  int k;
3531 
3532  *len=p_MaxComp(v,r);
3533  if (*len==0) *len=1;
3534  *p=(poly*)omAlloc0((*len)*sizeof(poly));
3535  while (v!=NULL)
3536  {
3537  h=p_Head(v,r);
3538  k=__p_GetComp(h,r);
3539  p_SetComp(h,0,r);
3540  pNext(h)=(*p)[k-1];(*p)[k-1]=h;
3541  pIter(v);
3542  }
3543  for(int i=(*len-1);i>=0;i--)
3544  {
3545  if ((*p)[i]!=NULL) (*p)[i]=pReverse((*p)[i]);
3546  }
3547 }

◆ p_VectorHasUnit()

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

Definition at line 3302 of file p_polys.cc.

3303 {
3304  poly q=p,qq;
3305  int i,j=0;
3306 
3307  *len = 0;
3308  while (q!=NULL)
3309  {
3310  if (p_LmIsConstantComp(q,r))
3311  {
3312  i = __p_GetComp(q,r);
3313  qq = p;
3314  while ((qq != q) && (__p_GetComp(qq,r) != i)) pIter(qq);
3315  if (qq == q)
3316  {
3317  j = 0;
3318  while (qq!=NULL)
3319  {
3320  if (__p_GetComp(qq,r)==i) j++;
3321  pIter(qq);
3322  }
3323  if ((*len == 0) || (j<*len))
3324  {
3325  *len = j;
3326  *k = i;
3327  }
3328  }
3329  }
3330  pIter(q);
3331  }
3332 }

◆ p_VectorHasUnitB()

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

Definition at line 3279 of file p_polys.cc.

3280 {
3281  poly q=p,qq;
3282  int i;
3283 
3284  while (q!=NULL)
3285  {
3286  if (p_LmIsConstantComp(q,r))
3287  {
3288  i = __p_GetComp(q,r);
3289  qq = p;
3290  while ((qq != q) && (__p_GetComp(qq,r) != i)) pIter(qq);
3291  if (qq == q)
3292  {
3293  *k = i;
3294  return TRUE;
3295  }
3296  }
3297  pIter(q);
3298  }
3299  return FALSE;
3300 }

◆ p_WDegree()

long p_WDegree ( poly  p,
const ring  r 
)

Definition at line 706 of file p_polys.cc.

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

◆ p_Weight()

int p_Weight ( int  c,
const ring  r 
)

Definition at line 697 of file p_polys.cc.

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

◆ p_WFirstTotalDegree()

long p_WFirstTotalDegree ( poly  p,
ring  r 
)

Definition at line 588 of file p_polys.cc.

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

◆ p_Write() [1/2]

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

Definition at line 204 of file polys0.cc.

205 {
206  p_Write0(p, lmRing, tailRing);
207  PrintLn();
208 }
void p_Write0(poly p, ring lmRing, ring tailRing)
Definition: polys0.cc:194
void PrintLn()
Definition: reporter.cc:310

◆ p_Write() [2/2]

static void p_Write ( poly  p,
ring  p_ring 
)
inlinestatic

Definition at line 1194 of file p_polys.h.

1195 {
1196  p_Write(p, p_ring, p_ring);
1197 }

◆ p_Write0() [1/2]

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

Definition at line 194 of file polys0.cc.

195 {
196  char *s=p_String(p, lmRing, tailRing);
197  PrintS(s);
198  omFree(s);
199 }
char * p_String(poly p, ring lmRing, ring tailRing)
Definition: polys0.cc:184

◆ p_Write0() [2/2]

static void p_Write0 ( poly  p,
ring  p_ring 
)
inlinestatic

Definition at line 1198 of file p_polys.h.

1199 {
1200  p_Write0(p, p_ring, p_ring);
1201 }
void p_Write0(poly p, ring lmRing, ring tailRing)
Definition: polys0.cc:194

◆ p_wrp() [1/2]

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

Definition at line 235 of file polys0.cc.

236 {
237  poly r;
238 
239  if (p==NULL) PrintS("NULL");
240  else if (pNext(p)==NULL) p_Write0(p, lmRing);
241  else
242  {
243  r = pNext(pNext(p));
244  pNext(pNext(p)) = NULL;
245  p_Write0(p, tailRing);
246  if (r!=NULL)
247  {
248  PrintS("+...");
249  pNext(pNext(p)) = r;
250  }
251  }
252 }

◆ p_wrp() [2/2]

static void p_wrp ( poly  p,
ring  p_ring 
)
inlinestatic

Definition at line 1202 of file p_polys.h.

1203 {
1204  p_wrp(p, p_ring, p_ring);
1205 }
void p_wrp(poly p, ring lmRing, ring tailRing)
Definition: polys0.cc:235

◆ p_WTotaldegree()

long p_WTotaldegree ( poly  p,
const ring  r 
)

Definition at line 605 of file p_polys.cc.

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

◆ pEnlargeSet()

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

Definition at line 3633 of file p_polys.cc.

3634 {
3635  poly* h;
3636 
3637  if (*p==NULL)
3638  {
3639  if (increment==0) return;
3640  h=(poly*)omAlloc0(increment*sizeof(poly));
3641  }
3642  else
3643  {
3644  h=(poly*)omReallocSize((poly*)*p,l*sizeof(poly),(l+increment)*sizeof(poly));
3645  if (increment>0)
3646  {
3647  memset(&(h[l]),0,increment*sizeof(poly));
3648  }
3649  }
3650  *p=h;
3651 }
#define omReallocSize(addr, o_size, size)
Definition: omAllocDecl.h:220

◆ pHaveCommonMonoms()

BOOLEAN pHaveCommonMonoms ( poly  p,
poly  q 
)

Definition at line 175 of file pDebug.cc.

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

◆ pIsMonomOf()

BOOLEAN pIsMonomOf ( poly  p,
poly  m 
)

Definition at line 165 of file pDebug.cc.

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

◆ pLDeg0()

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

Definition at line 731 of file p_polys.cc.

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

◆ pLDeg0c()

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

Definition at line 762 of file p_polys.cc.

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

◆ pLDeg1()

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

Definition at line 833 of file p_polys.cc.

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

◆ pLDeg1_Deg()

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

Definition at line 902 of file p_polys.cc.

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

◆ pLDeg1_Totaldegree()

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

Definition at line 967 of file p_polys.cc.

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

◆ pLDeg1_WFirstTotalDegree()

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

Definition at line 1030 of file p_polys.cc.

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

◆ pLDeg1c()

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

Definition at line 869 of file p_polys.cc.

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

◆ pLDeg1c_Deg()

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

Definition at line 933 of file p_polys.cc.

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

◆ pLDeg1c_Totaldegree()

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

Definition at line 997 of file p_polys.cc.

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

◆ pLDeg1c_WFirstTotalDegree()

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

Definition at line 1060 of file p_polys.cc.

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

◆ pLDegb()

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

Definition at line 803 of file p_polys.cc.

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

◆ pLength()

static unsigned pLength ( poly  a)
inlinestatic

Definition at line 192 of file p_polys.h.

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

◆ pp_Jet()

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

Definition at line 4242 of file p_polys.cc.

4243 {
4244  poly r=NULL;
4245  poly t=NULL;
4246 
4247  while (p!=NULL)
4248  {
4249  if (p_Totaldegree(p,R)<=m)
4250  {
4251  if (r==NULL)
4252  r=p_Head(p,R);
4253  else
4254  if (t==NULL)
4255  {
4256  pNext(r)=p_Head(p,R);
4257  t=pNext(r);
4258  }
4259  else
4260  {
4261  pNext(t)=p_Head(p,R);
4262  pIter(t);
4263  }
4264  }
4265  pIter(p);
4266  }
4267  return r;
4268 }

◆ pp_JetW()

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

Definition at line 4287 of file p_polys.cc.

4288 {
4289  poly r=NULL;
4290  poly t=NULL;
4291  while (p!=NULL)
4292  {
4293  if (totaldegreeWecart_IV(p,R,w)<=m)
4294  {
4295  if (r==NULL)
4296  r=p_Head(p,R);
4297  else
4298  if (t==NULL)
4299  {
4300  pNext(r)=p_Head(p,R);
4301  t=pNext(r);
4302  }
4303  else
4304  {
4305  pNext(t)=p_Head(p,R);
4306  pIter(t);
4307  }
4308  }
4309  pIter(p);
4310  }
4311  return r;
4312 }

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

1027 {
1028  int shorter;
1029  return r->p_Procs->pp_Mult_Coeff_mm_DivSelect(p, m, shorter, r);
1030 }

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

1035 {
1036  int shorter;
1037  poly pp = r->p_Procs->pp_Mult_Coeff_mm_DivSelect(p, m, shorter, r);
1038  lp -= shorter;
1039  return pp;
1040 }

◆ pp_Mult_mm()

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

Definition at line 987 of file p_polys.h.

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

◆ pp_Mult_nn()

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

Definition at line 948 of file p_polys.h.

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

◆ pp_Mult_qq()

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

Definition at line 1093 of file p_polys.h.

1094 {
1095  if (p == NULL || q == NULL) return NULL;
1096 
1097  if (pNext(p) == NULL)
1098  {
1099 #ifdef HAVE_PLURAL
1100  if (rIsPluralRing(r))
1101  return nc_mm_Mult_pp(p, q, r);
1102 #endif
1103  return r->p_Procs->pp_Mult_mm(q, p, r);
1104  }
1105 
1106  if (pNext(q) == NULL)
1107  {
1108  return r->p_Procs->pp_Mult_mm(p, q, r);
1109  }
1110 
1111  poly qq = q;
1112  if (p == q)
1113  qq = p_Copy(q, r);
1114 
1115  poly res;
1116 #ifdef HAVE_PLURAL
1117  if (rIsPluralRing(r))
1118  res = _nc_pp_Mult_qq(p, qq, r);
1119  else
1120 #endif
1121  res = _p_Mult_q(p, qq, 1, r);
1122 
1123  if (qq != q)
1124  p_Delete(&qq, r);
1125  return res;
1126 }
static poly nc_mm_Mult_pp(const poly m, const poly p, const ring r)
Definition: nc.h:232
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 3586 of file p_polys.cc.

3587 {
3588  assume(old_FDeg != NULL && old_lDeg != NULL);
3589  r->pFDeg = old_FDeg;
3590  r->pLDeg = old_lDeg;
3591 }

◆ pReverse()

static poly pReverse ( poly  p)
inlinestatic

Definition at line 335 of file p_polys.h.

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

◆ pSetDegProcs()

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

Definition at line 3574 of file p_polys.cc.

3575 {
3576  assume(new_FDeg != NULL);
3577  r->pFDeg = new_FDeg;
3578 
3579  if (new_lDeg == NULL)
3580  new_lDeg = r->pLDegOrig;
3581 
3582  r->pLDeg = new_lDeg;
3583 }