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

Go to the source code of this file.

Macros

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

Functions

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

Macro Definition Documentation

◆ __p_Mult_nn

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

Definition at line 973 of file p_polys.h.

◆ __pp_Mult_nn

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

Definition at line 1004 of file p_polys.h.

◆ _p_LmCmpAction

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

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

◆ p_LmEqual

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

Definition at line 1725 of file p_polys.h.

◆ p_LmTest

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

Definition at line 163 of file p_polys.h.

◆ p_SetmComp

#define p_SetmComp   p_Setm

Definition at line 246 of file p_polys.h.

◆ p_Test

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

Definition at line 162 of file p_polys.h.

◆ pDivAssume

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

Definition at line 1284 of file p_polys.h.

◆ pIfThen

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

Definition at line 156 of file p_polys.h.

◆ pp_Test

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

Definition at line 164 of file p_polys.h.

Function Documentation

◆ _p_LmDivisibleBy() [1/2]

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

Definition at line 1877 of file p_polys.h.

1878{
1879 if (p_GetComp(a, r_a) == 0 || p_GetComp(a,r_a) == p_GetComp(b,r_b))
1880 return _p_LmDivisibleByNoComp(a, r_a, b, r_b);
1881 return FALSE;
1882}
#define FALSE
Definition: auxiliary.h:96
CanonicalForm b
Definition: cfModGcd.cc:4102
#define p_GetComp(p, r)
Definition: monomials.h:64
static BOOLEAN _p_LmDivisibleByNoComp(poly a, poly b, const ring r)
return: FALSE, if there exists i, such that a->exp[i] > b->exp[i] TRUE, otherwise (1) Consider long v...
Definition: p_polys.h:1767

◆ _p_LmDivisibleBy() [2/2]

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

Definition at line 1871 of file p_polys.h.

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

◆ _p_LmDivisibleByNoComp() [1/2]

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

Definition at line 1816 of file p_polys.h.

1817{
1818 int i=r_a->N;
1819 pAssume1(r_a->N == r_b->N);
1820
1821 do
1822 {
1823 if (p_GetExp(a,i,r_a) > p_GetExp(b,i,r_b))
1824 return FALSE;
1825 i--;
1826 }
1827 while (i);
1828/*#ifdef HAVE_RINGS
1829 return n_DivBy(p_GetCoeff(b, r_b), p_GetCoeff(a, r_a), r_a->cf);
1830#else
1831*/
1832 return TRUE;
1833//#endif
1834}
#define TRUE
Definition: auxiliary.h:100
int i
Definition: cfEzgcd.cc:132
#define pAssume1(cond)
Definition: monomials.h:171
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent @Note: the integer VarOffset encodes:
Definition: p_polys.h:471

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

1768{
1769 int i=r->VarL_Size - 1;
1770 unsigned long divmask = r->divmask;
1771 unsigned long la, lb;
1772
1773 if (r->VarL_LowIndex >= 0)
1774 {
1775 i += r->VarL_LowIndex;
1776 do
1777 {
1778 la = a->exp[i];
1779 lb = b->exp[i];
1780 if ((la > lb) ||
1781 (((la & divmask) ^ (lb & divmask)) != ((lb - la) & divmask)))
1782 {
1784 return FALSE;
1785 }
1786 i--;
1787 }
1788 while (i>=r->VarL_LowIndex);
1789 }
1790 else
1791 {
1792 do
1793 {
1794 la = a->exp[r->VarL_Offset[i]];
1795 lb = b->exp[r->VarL_Offset[i]];
1796 if ((la > lb) ||
1797 (((la & divmask) ^ (lb & divmask)) != ((lb - la) & divmask)))
1798 {
1800 return FALSE;
1801 }
1802 i--;
1803 }
1804 while (i>=0);
1805 }
1806/*#ifdef HAVE_RINGS
1807 pDivAssume(p_DebugLmDivisibleByNoComp(a, b, r) == n_DivBy(p_GetCoeff(b, r), p_GetCoeff(a, r), r->cf));
1808 return (!rField_is_Ring(r)) || n_DivBy(p_GetCoeff(b, r), p_GetCoeff(a, r), r->cf);
1809#else
1810*/
1812 return TRUE;
1813//#endif
1814}
BOOLEAN p_DebugLmDivisibleByNoComp(poly a, poly b, ring r)
Definition: pDebug.cc:141
#define pDivAssume(x)
Definition: p_polys.h:1284

◆ _p_LmDivisibleByNoCompPart()

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

Definition at line 1837 of file p_polys.h.

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

◆ _p_LmDivisibleByPart()

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

Definition at line 1856 of file p_polys.h.

1857{
1858 if (p_GetComp(a, r_a) == 0 || p_GetComp(a,r_a) == p_GetComp(b,r_b))
1859 return _p_LmDivisibleByNoCompPart(a, r_a, b, r_b,start,end);
1860 return FALSE;
1861}
static BOOLEAN _p_LmDivisibleByNoCompPart(poly a, const ring r_a, poly b, const ring r_b, const int start, const int end)
Definition: p_polys.h:1837

◆ _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:87
int level(const CanonicalForm &f)
#define pNext(p)
Definition: monomials.h:36
#define NULL
Definition: omList.c:12
BOOLEAN _p_Test(poly p, ring r, int level)
Definition: pDebug.cc: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, !rIsPluralRing(r)

Definition at line 313 of file p_Mult_q.cc.

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

◆ _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:170
#define n_Test(a, r)
BOOLEAN n_Test(number a, const coeffs r)
Definition: coeffs.h:712
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
Definition: coeffs.h:464
static FORCE_INLINE int n_GetChar(const coeffs r)
Return the characteristic of the coeff. domain.
Definition: coeffs.h:444
#define pFalseReturn(cond)
Definition: monomials.h:139
#define pIter(p)
Definition: monomials.h:37
#define _pPolyAssumeReturnMsg(cond, msg, p, r)
Definition: monomials.h:124
#define omSizeWOfBin(bin_ptr)
@ omError_NoError
Definition: omError.h:18
#define omTestList(ptr, level)
Definition: omList.h:81
static poly p_DebugInit(poly p, ring src_ring, ring dest_ring)
Definition: pDebug.cc:195
BOOLEAN dPolyReportError(poly p, ring r, const char *fmt,...)
Definition: pDebug.cc:42
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:4642
static int p_LmCmp(poly p, poly q, const ring r)
Definition: p_polys.h:1582
static void p_LmFree(poly p, ring)
Definition: p_polys.h:685
@ ro_syzcomp
Definition: ring.h:59
union sro_ord::@1 data
Definition: ring.h:219
#define omTestBinAddrSize(A, B, C)
Definition: xalloc.h:272

◆ _pp_Test()

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

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

4144{
4145#if 0
4146 PrintS("\nSource Ring: \n");
4147 rWrite(src);
4148
4149 if(0)
4150 {
4151 number zz = n_Copy(z, src->cf);
4152 PrintS("z: "); n_Write(zz, src);
4153 n_Delete(&zz, src->cf);
4154 }
4155
4156 PrintS("\nDestination Ring: \n");
4157 rWrite(dst);
4158
4159 /*Print("\nOldPar: %d\n", OldPar);
4160 for( int i = 1; i <= OldPar; i++ )
4161 {
4162 Print("par(%d) -> par/var (%d)\n", i, par_perm[i-1]);
4163 }*/
4164#endif
4165 if( z == NULL )
4166 return NULL;
4167
4168 const coeffs srcCf = src->cf;
4169 assume( srcCf != NULL );
4170
4171 assume( !nCoeff_is_GF(srcCf) );
4172 assume( src->cf->extRing!=NULL );
4173
4174 poly zz = NULL;
4175
4176 const ring srcExtRing = srcCf->extRing;
4177 assume( srcExtRing != NULL );
4178
4179 const coeffs dstCf = dst->cf;
4180 assume( dstCf != NULL );
4181
4182 if( nCoeff_is_algExt(srcCf) ) // nCoeff_is_GF(srcCf)?
4183 {
4184 zz = (poly) z;
4185 if( zz == NULL ) return NULL;
4186 }
4187 else if (nCoeff_is_transExt(srcCf))
4188 {
4189 assume( !IS0(z) );
4190
4191 zz = NUM((fraction)z);
4192 p_Test (zz, srcExtRing);
4193
4194 if( zz == NULL ) return NULL;
4195 if( !DENIS1((fraction)z) )
4196 {
4197 if (!p_IsConstant(DEN((fraction)z),srcExtRing))
4198 WarnS("Not defined: Cannot map a rational fraction and make a polynomial out of it! Ignoring the denominator.");
4199 }
4200 }
4201 else
4202 {
4203 assume (FALSE);
4204 WerrorS("Number permutation is not implemented for this data yet!");
4205 return NULL;
4206 }
4207
4208 assume( zz != NULL );
4209 p_Test (zz, srcExtRing);
4210
4211 nMapFunc nMap = n_SetMap(srcExtRing->cf, dstCf);
4212
4213 assume( nMap != NULL );
4214
4215 poly qq;
4216 if ((par_perm == NULL) && (rPar(dst) != 0 && rVar (srcExtRing) > 0))
4217 {
4218 int* perm;
4219 perm=(int *)omAlloc0((rVar(srcExtRing)+1)*sizeof(int));
4220 for(int i=si_min(rVar(srcExtRing),rPar(dst));i>0;i--)
4221 perm[i]=-i;
4222 qq = p_PermPoly(zz, perm, srcExtRing, dst, nMap, NULL, rVar(srcExtRing)-1);
4223 omFreeSize ((ADDRESS)perm, (rVar(srcExtRing)+1)*sizeof(int));
4224 }
4225 else
4226 qq = p_PermPoly(zz, par_perm-1, srcExtRing, dst, nMap, NULL, rVar (srcExtRing)-1);
4227
4228 if(nCoeff_is_transExt(srcCf)
4229 && (!DENIS1((fraction)z))
4230 && p_IsConstant(DEN((fraction)z),srcExtRing))
4231 {
4232 number n=nMap(pGetCoeff(DEN((fraction)z)),srcExtRing->cf, dstCf);
4233 qq=p_Div_nn(qq,n,dst);
4234 n_Delete(&n,dstCf);
4235 p_Normalize(qq,dst);
4236 }
4237 p_Test (qq, dst);
4238
4239 return qq;
4240}
void * ADDRESS
Definition: auxiliary.h:119
static int si_min(const int a, const int b)
Definition: auxiliary.h:125
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of 'n'
Definition: coeffs.h:451
static FORCE_INLINE BOOLEAN nCoeff_is_GF(const coeffs r)
Definition: coeffs.h:839
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:700
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:455
static FORCE_INLINE void n_Write(number n, const coeffs r, const BOOLEAN bShortOut=TRUE)
Definition: coeffs.h:591
static FORCE_INLINE BOOLEAN nCoeff_is_algExt(const coeffs r)
TRUE iff r represents an algebraic extension field.
Definition: coeffs.h:910
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:73
static FORCE_INLINE BOOLEAN nCoeff_is_transExt(const coeffs r)
TRUE iff r represents a transcendental extension field.
Definition: coeffs.h:918
#define WarnS
Definition: emacs.cc:78
void WerrorS(const char *s)
Definition: feFopen.cc:24
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy
Definition: monomials.h:44
The main handler for Singular numbers which are suitable for Singular polynomials.
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
#define omAlloc0(size)
Definition: omAllocDecl.h:211
poly p_PermPoly(poly p, const int *perm, const ring oldRing, const ring dst, nMapFunc nMap, const int *par_perm, int OldPar, BOOLEAN use_mult)
Definition: p_polys.cc:4246
poly p_Div_nn(poly p, const number n, const ring r)
Definition: p_polys.cc:1501
void p_Normalize(poly p, const ring r)
Definition: p_polys.cc:3929
static BOOLEAN p_IsConstant(const poly p, const ring r)
Definition: p_polys.h:2005
#define p_Test(p, r)
Definition: p_polys.h:162
#define NUM
Definition: readcf.cc:180
void PrintS(const char *s)
Definition: reporter.cc:284
void rWrite(ring r, BOOLEAN details)
Definition: ring.cc:226
static int rPar(const ring r)
(r->cf->P)
Definition: ring.h:600
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:593

◆ p_Add_q() [1/2]

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

Definition at line 938 of file p_polys.h.

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

◆ p_Add_q() [2/2]

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

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

Definition at line 948 of file p_polys.h.

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

◆ p_AddComp()

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

Definition at line 449 of file p_polys.h.

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

◆ p_AddExp()

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

Definition at line 608 of file p_polys.h.

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

◆ 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:78
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 88 of file p_polys.cc.

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

◆ p_Cleardenom()

poly p_Cleardenom ( poly  p,
const ring  r 
)

Definition at line 2910 of file p_polys.cc.

2911{
2912 if( p == NULL )
2913 return NULL;
2914
2915 assume( r != NULL );
2916 assume( r->cf != NULL );
2917 const coeffs C = r->cf;
2918
2919#if CLEARENUMERATORS
2920 if( 0 )
2921 {
2923 n_ClearDenominators(itr, C);
2924 n_ClearContent(itr, C); // divide out the content
2925 p_Test(p, r); n_Test(pGetCoeff(p), C);
2926 assume(n_GreaterZero(pGetCoeff(p), C)); // ??
2927// if(!n_GreaterZero(pGetCoeff(p),C)) p = p_Neg(p,r);
2928 return p;
2929 }
2930#endif
2931
2932 number d, h;
2933
2934 if (rField_is_Ring(r))
2935 {
2936 if(!n_GreaterZero(pGetCoeff(p),C)) p = p_Neg(p,r);
2937 return p;
2938 }
2939
2941 {
2942 if(!n_GreaterZero(pGetCoeff(p),C)) p = p_Neg(p,r);
2943 return p;
2944 }
2945
2946 assume(p != NULL);
2947
2948 if(pNext(p)==NULL)
2949 {
2950 if (!TEST_OPT_CONTENTSB)
2951 p_SetCoeff(p,n_Init(1,C),r);
2952 else if(!n_GreaterZero(pGetCoeff(p),C))
2953 p = p_Neg(p,r);
2954 return p;
2955 }
2956
2957 assume(pNext(p)!=NULL);
2958 poly start=p;
2959
2960#if 0 && CLEARENUMERATORS
2961//CF: does not seem to work that well..
2962
2963 if( nCoeff_is_Q(C) || nCoeff_is_Q_a(C) )
2964 {
2966 n_ClearDenominators(itr, C);
2967 n_ClearContent(itr, C); // divide out the content
2968 p_Test(p, r); n_Test(pGetCoeff(p), C);
2969 assume(n_GreaterZero(pGetCoeff(p), C)); // ??
2970// if(!n_GreaterZero(pGetCoeff(p),C)) p = p_Neg(p,r);
2971 return start;
2972 }
2973#endif
2974
2975 if(1)
2976 {
2977 // get lcm of all denominators ----------------------------------
2978 h = n_Init(1,C);
2979 while (p!=NULL)
2980 {
2983 n_Delete(&h,C);
2984 h=d;
2985 pIter(p);
2986 }
2987 /* h now contains the 1/lcm of all denominators */
2988 if(!n_IsOne(h,C))
2989 {
2990 // multiply by the lcm of all denominators
2991 p = start;
2992 while (p!=NULL)
2993 {
2994 d=n_Mult(h,pGetCoeff(p),C);
2995 n_Normalize(d,C);
2996 p_SetCoeff(p,d,r);
2997 pIter(p);
2998 }
2999 }
3000 n_Delete(&h,C);
3001 p=start;
3002
3003 p_ContentForGB(p,r);
3004#ifdef HAVE_RATGRING
3005 if (rIsRatGRing(r))
3006 {
3007 /* quick unit detection in the rational case is done in gr_nc_bba */
3008 p_ContentRat(p, r);
3009 start=p;
3010 }
3011#endif
3012 }
3013
3014 if(!n_GreaterZero(pGetCoeff(p),C)) p = p_Neg(p,r);
3015
3016 return start;
3017}
This is a polynomial enumerator for simple iteration over coefficients of polynomials.
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of 'a' and 'b', i.e., a*b
Definition: coeffs.h:636
static FORCE_INLINE number n_NormalizeHelper(number a, number b, const coeffs r)
assume that r is a quotient field (otherwise, return 1) for arguments (a1/a2,b1/b2) return (lcm(a1,...
Definition: coeffs.h:695
static FORCE_INLINE BOOLEAN n_GreaterZero(number n, const coeffs r)
ordered fields: TRUE iff 'n' is positive; in Z/pZ: TRUE iff 0 < m <= roundedBelow(p/2),...
Definition: coeffs.h:494
static FORCE_INLINE BOOLEAN nCoeff_is_Q(const coeffs r)
Definition: coeffs.h:806
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:935
static FORCE_INLINE BOOLEAN nCoeff_is_Q_a(const coeffs r)
Definition: coeffs.h:885
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:928
static FORCE_INLINE void n_Normalize(number &n, const coeffs r)
inplace-normalization of n; produces some canonical representation of n;
Definition: coeffs.h:578
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff 'n' represents the one element.
Definition: coeffs.h:468
#define TEST_OPT_INTSTRATEGY
Definition: options.h:110
#define TEST_OPT_CONTENTSB
Definition: options.h:127
void p_ContentRat(poly &ph, const ring r)
Definition: p_polys.cc:1740
void p_ContentForGB(poly ph, const ring r)
Definition: p_polys.cc:2420
static poly p_Neg(poly p, const ring r)
Definition: p_polys.h:1109
static BOOLEAN rIsRatGRing(const ring r)
Definition: ring.h:427
#define rField_is_Ring(R)
Definition: ring.h:486

◆ p_Cleardenom_n()

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

Definition at line 3019 of file p_polys.cc.

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

◆ p_Cmp()

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

Definition at line 1729 of file p_polys.h.

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

◆ p_CmpPolys()

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

Definition at line 1741 of file p_polys.h.

1742{
1743 if (p2==NULL)
1744 {
1745 if (p1==NULL) return 0;
1746 return 1;
1747 }
1748 if (p1==NULL)
1749 return -1;
1750 return p_ComparePolys(p1,p2,r);
1751}
BOOLEAN p_ComparePolys(poly p1, poly p2, const ring r)
returns TRUE if p1 is a skalar multiple of p2 assume p1 != NULL and p2 != NULL
Definition: p_polys.cc:4692

◆ p_Comp_k_n()

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

Definition at line 642 of file p_polys.h.

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

◆ p_Compare()

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

Definition at line 5023 of file p_polys.cc.

5024{
5025 int r=p_Cmp(a,b,R);
5026 if ((r==0)&&(a!=NULL))
5027 {
5028 number h=n_Sub(pGetCoeff(a),pGetCoeff(b),R->cf);
5029 /* compare lead coeffs */
5030 r = -1+n_IsZero(h,R->cf)+2*n_GreaterZero(h,R->cf); /* -1: <, 0:==, 1: > */
5031 n_Delete(&h,R->cf);
5032 }
5033 else if (a==NULL)
5034 {
5035 if (b==NULL)
5036 {
5037 /* compare 0, 0 */
5038 r=0;
5039 }
5040 else if(p_IsConstant(b,R))
5041 {
5042 /* compare 0, const */
5043 r = 1-2*n_GreaterZero(pGetCoeff(b),R->cf); /* -1: <, 1: > */
5044 }
5045 }
5046 else if (b==NULL)
5047 {
5048 if (p_IsConstant(a,R))
5049 {
5050 /* compare const, 0 */
5051 r = -1+2*n_GreaterZero(pGetCoeff(a),R->cf); /* -1: <, 1: > */
5052 }
5053 }
5054 return(r);
5055}
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:655
static int p_Cmp(poly p1, poly p2, ring r)
Definition: p_polys.h:1729

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

4693{
4694 number n,nn;
4695 pAssume(p1 != NULL && p2 != NULL);
4696
4697 if (!p_LmEqual(p1,p2,r)) //compare leading mons
4698 return FALSE;
4699 if ((pNext(p1)==NULL) && (pNext(p2)!=NULL))
4700 return FALSE;
4701 if ((pNext(p2)==NULL) && (pNext(p1)!=NULL))
4702 return FALSE;
4703 if (pLength(p1) != pLength(p2))
4704 return FALSE;
4705 #ifdef HAVE_RINGS
4706 if (rField_is_Ring(r))
4707 {
4708 if (!n_DivBy(pGetCoeff(p1), pGetCoeff(p2), r->cf)) return FALSE;
4709 }
4710 #endif
4711 n=n_Div(pGetCoeff(p1),pGetCoeff(p2),r->cf);
4712 while ((p1 != NULL) /*&& (p2 != NULL)*/)
4713 {
4714 if ( ! p_LmEqual(p1, p2,r))
4715 {
4716 n_Delete(&n, r->cf);
4717 return FALSE;
4718 }
4719 if (!n_Equal(pGetCoeff(p1), nn = n_Mult(pGetCoeff(p2),n, r->cf), r->cf))
4720 {
4721 n_Delete(&n, r->cf);
4722 n_Delete(&nn, r->cf);
4723 return FALSE;
4724 }
4725 n_Delete(&nn, r->cf);
4726 pIter(p1);
4727 pIter(p2);
4728 }
4729 n_Delete(&n, r->cf);
4730 return TRUE;
4731}
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:753
static FORCE_INLINE BOOLEAN n_Equal(number a, number b, const coeffs r)
TRUE iff 'a' and 'b' represent the same number; they may have different representations.
Definition: coeffs.h:460
#define pAssume(cond)
Definition: monomials.h:90
#define p_LmEqual(p1, p2, r)
Definition: p_polys.h:1725

◆ p_Content()

void p_Content ( poly  p,
const ring  r 
)

Definition at line 2291 of file p_polys.cc.

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

◆ p_Content_n()

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

Definition at line 2349 of file p_polys.cc.

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

◆ p_ContentForGB()

void p_ContentForGB ( poly  p,
const ring  r 
)

Definition at line 2420 of file p_polys.cc.

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

◆ p_ContentRat()

void p_ContentRat ( poly &  ph,
const ring  r 
)

Definition at line 1740 of file p_polys.cc.

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

◆ p_Copy() [1/2]

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

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

Definition at line 885 of file p_polys.h.

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

◆ p_Copy() [2/2]

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

returns a copy of p

Definition at line 848 of file p_polys.h.

849{
850 if (p!=NULL)
851 {
852 p_Test(p,r);
853 const poly pp = p_Copy_noCheck(p, r);
854 p_Test(pp,r);
855 return pp;
856 }
857 else
858 return NULL;
859}
CanonicalForm FACTORY_PUBLIC pp(const CanonicalForm &)
CanonicalForm pp ( const CanonicalForm & f )
Definition: cf_gcd.cc:676

◆ p_Copy_noCheck()

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

returns a copy of p (without any additional testing)

Definition at line 838 of file p_polys.h.

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

◆ p_CopyPowerProduct()

poly p_CopyPowerProduct ( const poly  p,
const ring  r 
)

like p_Head, but with coefficient 1

Definition at line 5107 of file p_polys.cc.

5108{
5109 if (p == NULL) return NULL;
5110 return p_CopyPowerProduct0(p,n_Init(1,r->cf),r);
5111}
poly p_CopyPowerProduct0(const poly p, number n, const ring r)
like p_Head, but with coefficient n
Definition: p_polys.cc:5095

◆ p_CopyPowerProduct0()

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

like p_Head, but with coefficient n

Definition at line 5095 of file p_polys.cc.

5096{
5098 poly np;
5099 omTypeAllocBin(poly, np, r->PolyBin);
5100 p_SetRingOfLm(np, r);
5101 memcpy(np->exp, p->exp, r->ExpL_Size*sizeof(long));
5102 pNext(np) = NULL;
5103 pSetCoeff0(np, n);
5104 return np;
5105}
#define p_LmCheckPolyRing1(p, r)
Definition: monomials.h:177
#define pSetCoeff0(p, n)
Definition: monomials.h:59
#define p_SetRingOfLm(p, r)
Definition: monomials.h:144
#define omTypeAllocBin(type, addr, bin)
Definition: omAllocDecl.h:203

◆ p_DecrExp()

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

Definition at line 600 of file p_polys.h.

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

◆ p_Deg()

long p_Deg ( poly  a,
const ring  r 
)

Definition at line 587 of file p_polys.cc.

588{
589 p_LmCheckPolyRing(a, r);
590// assume(p_GetOrder(a, r) == p_WTotaldegree(a, r)); // WRONG assume!
591 return p_GetOrder(a, r);
592}
BOOLEAN p_LmCheckPolyRing(poly p, ring r)
Definition: pDebug.cc:120
static long p_GetOrder(poly p, ring r)
Definition: p_polys.h:423

◆ p_DegW()

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

Definition at line 690 of file p_polys.cc.

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

◆ p_Delete() [1/2]

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

Definition at line 910 of file p_polys.h.

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

◆ p_Delete() [2/2]

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

Definition at line 903 of file p_polys.h.

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

◆ p_DeleteComp()

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

Definition at line 3660 of file p_polys.cc.

3661{
3662 poly q;
3663 long unsigned kk=k;
3664
3665 while ((*p!=NULL) && (__p_GetComp(*p,r)==kk)) p_LmDelete(p,r);
3666 if (*p==NULL) return;
3667 q = *p;
3668 if (__p_GetComp(q,r)>kk)
3669 {
3670 p_SubComp(q,1,r);
3671 p_SetmComp(q,r);
3672 }
3673 while (pNext(q)!=NULL)
3674 {
3675 if (__p_GetComp(pNext(q),r)==kk)
3676 p_LmDelete(&(pNext(q)),r);
3677 else
3678 {
3679 pIter(q);
3680 if (__p_GetComp(q,r)>kk)
3681 {
3682 p_SubComp(q,1,r);
3683 p_SetmComp(q,r);
3684 }
3685 }
3686 }
3687}
static unsigned long p_SubComp(poly p, unsigned long v, ring r)
Definition: p_polys.h:455
#define p_SetmComp
Definition: p_polys.h:246

◆ p_Diff()

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

Definition at line 1894 of file p_polys.cc.

1895{
1896 poly res, f, last;
1897 number t;
1898
1899 last = res = NULL;
1900 while (a!=NULL)
1901 {
1902 if (p_GetExp(a,k,r)!=0)
1903 {
1904 f = p_LmInit(a,r);
1905 t = n_Init(p_GetExp(a,k,r),r->cf);
1906 pSetCoeff0(f,n_Mult(t,pGetCoeff(a),r->cf));
1907 n_Delete(&t,r->cf);
1908 if (n_IsZero(pGetCoeff(f),r->cf))
1909 p_LmDelete(&f,r);
1910 else
1911 {
1912 p_DecrExp(f,k,r);
1913 p_Setm(f,r);
1914 if (res==NULL)
1915 {
1916 res=last=f;
1917 }
1918 else
1919 {
1920 pNext(last)=f;
1921 last=f;
1922 }
1923 }
1924 }
1925 pIter(a);
1926 }
1927 return res;
1928}
FILE * f
Definition: checklibs.c:9
STATIC_VAR poly last
Definition: hdegree.cc:1173
static poly p_LmInit(poly p, const ring r)
Definition: p_polys.h:1337
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:235
static long p_DecrExp(poly p, int v, ring r)
Definition: p_polys.h:600

◆ p_DiffOp()

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

Definition at line 1969 of file p_polys.cc.

1970{
1971 poly result=NULL;
1972 poly h;
1973 for(;a!=NULL;pIter(a))
1974 {
1975 for(h=b;h!=NULL;pIter(h))
1976 {
1977 result=p_Add_q(result,p_DiffOpM(a,h,multiply,r),r);
1978 }
1979 }
1980 return result;
1981}
return result
Definition: facAbsBiFact.cc:75
static poly p_DiffOpM(poly a, poly b, BOOLEAN multiply, const ring r)
Definition: p_polys.cc:1930

◆ p_Div_mm()

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

divide polynomial by monomial

Definition at line 1534 of file p_polys.cc.

1535{
1536 p_Test(p, r);
1537 p_Test(m, r);
1538 poly result = p;
1539 poly prev = NULL;
1540 number n=pGetCoeff(m);
1541 while (p!=NULL)
1542 {
1543 number nc = n_Div(pGetCoeff(p),n,r->cf);
1544 n_Normalize(nc,r->cf);
1545 if (!n_IsZero(nc,r->cf))
1546 {
1547 p_SetCoeff(p,nc,r);
1548 prev=p;
1549 p_ExpVectorSub(p,m,r);
1550 pIter(p);
1551 }
1552 else
1553 {
1554 if (prev==NULL)
1555 {
1556 p_LmDelete(&result,r);
1557 p=result;
1558 }
1559 else
1560 {
1561 p_LmDelete(&pNext(prev),r);
1562 p=pNext(prev);
1563 }
1564 }
1565 }
1566 p_Test(result,r);
1567 return(result);
1568}
int m
Definition: cfEzgcd.cc:128
static void p_ExpVectorSub(poly p1, poly p2, const ring r)
Definition: p_polys.h:1442

◆ p_Div_nn()

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

Definition at line 1501 of file p_polys.cc.

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

◆ p_DivideM()

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

Definition at line 1574 of file p_polys.cc.

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

◆ p_DivisibleBy() [1/2]

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

Definition at line 1915 of file p_polys.h.

1916{
1918 pIfThen1(a!=NULL, p_LmCheckPolyRing1(a, r_a));
1919 if (a != NULL) {
1920 return _p_LmDivisibleBy(a, r_a, b, r_b);
1921 }
1922 return FALSE;
1923}
#define pIfThen1(cond, check)
Definition: monomials.h:179
static BOOLEAN _p_LmDivisibleBy(poly a, poly b, const ring r)
Definition: p_polys.h:1871

◆ p_DivisibleBy() [2/2]

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

Definition at line 1906 of file p_polys.h.

1907{
1909 pIfThen1(a!=NULL, p_LmCheckPolyRing1(a, r));
1910
1911 if (a != NULL && (p_GetComp(a, r) == 0 || p_GetComp(a,r) == p_GetComp(b,r)))
1912 return _p_LmDivisibleByNoComp(a,b,r);
1913 return FALSE;
1914}

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

1639{
1640 int exponent;
1641 for(int i = (int)rVar(r); i>0; i--)
1642 {
1643 exponent = p_GetExp(g, i, r) - p_GetExp(f, i, r);
1644 if (exponent < 0) return FALSE;
1645 }
1646 return n_DivBy(pGetCoeff(g), pGetCoeff(f), r->cf);
1647}
g
Definition: cfModGcd.cc:4089
#define exponent

◆ p_EqualPolys() [1/2]

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

Definition at line 4628 of file p_polys.cc.

4629{
4630 while ((p1 != NULL) && (p2 != NULL))
4631 {
4632 if (! p_LmEqual(p1, p2,r))
4633 return FALSE;
4634 if (! n_Equal(p_GetCoeff(p1,r), p_GetCoeff(p2,r),r->cf ))
4635 return FALSE;
4636 pIter(p1);
4637 pIter(p2);
4638 }
4639 return (p1==p2);
4640}
#define p_GetCoeff(p, r)
Definition: monomials.h:50

◆ p_EqualPolys() [2/2]

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

same as the usual p_EqualPolys for polys belonging to equal rings

Definition at line 4666 of file p_polys.cc.

4667{
4668 assume( r1 == r2 || rSamePolyRep(r1, r2) ); // will be used in rEqual!
4669 assume( r1->cf == r2->cf );
4670
4671 while ((p1 != NULL) && (p2 != NULL))
4672 {
4673 // returns 1 if ExpVector(p)==ExpVector(q): does not compare numbers !!
4674 // #define p_LmEqual(p1, p2, r) p_ExpVectorEqual(p1, p2, r)
4675
4676 if (! p_ExpVectorEqual(p1, p2, r1, r2))
4677 return FALSE;
4678
4679 if (! n_Equal(p_GetCoeff(p1,r1), p_GetCoeff(p2,r2), r1->cf ))
4680 return FALSE;
4681
4682 pIter(p1);
4683 pIter(p2);
4684 }
4685 return (p1==p2);
4686}
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:1799

◆ p_ExpVectorAdd()

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

Definition at line 1413 of file p_polys.h.

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

◆ p_ExpVectorAddSub()

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

Definition at line 1458 of file p_polys.h.

1459{
1460 p_LmCheckPolyRing1(p1, r);
1461 p_LmCheckPolyRing1(p2, r);
1462 p_LmCheckPolyRing1(p3, r);
1463#if PDEBUG >= 1
1464 for (int i=1; i<=r->N; i++)
1465 pAssume1(p_GetExp(p1, i, r) + p_GetExp(p2, i, r) >= p_GetExp(p3, i, r));
1466 pAssume1(p_GetComp(p1, r) == 0 ||
1467 (p_GetComp(p2, r) - p_GetComp(p3, r) == 0) ||
1468 (p_GetComp(p1, r) == p_GetComp(p2, r) - p_GetComp(p3, r)));
1469#endif
1470
1471 p_MemAddSub_LengthGeneral(p1->exp, p2->exp, p3->exp, r->ExpL_Size);
1472 // no need to adjust in case of NegWeights
1473}
#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 1315 of file p_polys.h.

1316{
1317 p_LmCheckPolyRing1(d_p, r);
1318 p_LmCheckPolyRing1(s_p, r);
1319 memcpy(d_p->exp, s_p->exp, r->ExpL_Size*sizeof(long));
1320}

◆ p_ExpVectorDiff()

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

Definition at line 1476 of file p_polys.h.

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

◆ p_ExpVectorEqual()

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

Definition at line 1491 of file p_polys.h.

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

◆ p_ExpVectorSub()

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

Definition at line 1442 of file p_polys.h.

1443{
1444 p_LmCheckPolyRing1(p1, r);
1445 p_LmCheckPolyRing1(p2, r);
1446#if PDEBUG >= 1
1447 for (int i=1; i<=r->N; i++)
1448 pAssume1(p_GetExp(p1, i, r) >= p_GetExp(p2, i, r));
1449 pAssume1(p_GetComp(p1, r) == 0 || p_GetComp(p2, r) == 0 ||
1450 p_GetComp(p1, r) == p_GetComp(p2, r));
1451#endif
1452
1453 p_MemSub_LengthGeneral(p1->exp, p2->exp, r->ExpL_Size);
1455}
#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 1427 of file p_polys.h.

1428{
1429 p_LmCheckPolyRing1(p1, r);
1430 p_LmCheckPolyRing1(p2, r);
1431 p_LmCheckPolyRing1(pr, r);
1432#if PDEBUG >= 1
1433 for (int i=1; i<=r->N; i++)
1434 pAssume1((unsigned long) (p_GetExp(p1, i, r) + p_GetExp(p2, i, r)) <= r->bitmask);
1435 pAssume1(p_GetComp(p1, r) == 0 || p_GetComp(p2, r) == 0);
1436#endif
1437
1438 p_MemSum_LengthGeneral(pr->exp, p1->exp, p2->exp, r->ExpL_Size);
1440}
#define p_MemSum_LengthGeneral(r, s1, s2, length)
Definition: p_MemAdd.h:86

◆ p_Farey()

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

Definition at line 54 of file p_polys.cc.

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

◆ p_FDeg()

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

Definition at line 382 of file p_polys.h.

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

◆ p_GcdMon()

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

polynomial gcd for f=mon

Definition at line 5057 of file p_polys.cc.

5058{
5059 assume(f!=NULL);
5060 assume(g!=NULL);
5061 assume(pNext(f)==NULL);
5062 poly G=p_Head(f,r);
5063 poly h=g;
5064 int *mf=(int*)omAlloc((r->N+1)*sizeof(int));
5065 p_GetExpV(f,mf,r);
5066 int *mh=(int*)omAlloc((r->N+1)*sizeof(int));
5067 BOOLEAN const_mon;
5068 BOOLEAN one_coeff=n_IsOne(pGetCoeff(G),r->cf);
5069 loop
5070 {
5071 if (h==NULL) break;
5072 if(!one_coeff)
5073 {
5074 number n=n_SubringGcd(pGetCoeff(G),pGetCoeff(h),r->cf);
5075 one_coeff=n_IsOne(n,r->cf);
5076 p_SetCoeff(G,n,r);
5077 }
5078 p_GetExpV(h,mh,r);
5079 const_mon=TRUE;
5080 for(unsigned j=r->N;j!=0;j--)
5081 {
5082 if (mh[j]<mf[j]) mf[j]=mh[j];
5083 if (mf[j]>0) const_mon=FALSE;
5084 }
5085 if (one_coeff && const_mon) break;
5086 pIter(h);
5087 }
5088 mf[0]=0;
5089 p_SetExpV(G,mf,r); // included is p_SetComp, p_Setm
5090 omFreeSize(mf,(r->N+1)*sizeof(int));
5091 omFreeSize(mh,(r->N+1)*sizeof(int));
5092 return G;
5093}
STATIC_VAR TreeM * G
Definition: janet.cc:31
#define omAlloc(size)
Definition: omAllocDecl.h:210
static void p_SetExpV(poly p, int *ev, const ring r)
Definition: p_polys.h:1546
static void p_GetExpV(poly p, int *ev, const ring r)
Definition: p_polys.h:1522

◆ p_GetCoeffRat()

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

Definition at line 1718 of file p_polys.cc.

1719{
1720 poly q = pNext(p);
1721 poly res; // = p_Head(p,r);
1722 res = p_GetExp_k_n(p, ishift+1, r->N, r); // does pSetm internally
1723 p_SetCoeff(res,n_Copy(p_GetCoeff(p,r),r),r);
1724 poly s;
1725 long cmp = p_GetComp(p, r);
1726 while ( (q!= NULL) && (p_Comp_k_n(p, q, ishift+1, r)) && (p_GetComp(q, r) == cmp) )
1727 {
1728 s = p_GetExp_k_n(q, ishift+1, r->N, r);
1729 p_SetCoeff(s,n_Copy(p_GetCoeff(q,r),r),r);
1730 res = p_Add_q(res,s,r);
1731 q = pNext(q);
1732 }
1733 cmp = 0;
1734 p_SetCompP(res,cmp,r);
1735 return res;
1736}
const CanonicalForm int s
Definition: facAbsFact.cc:51
static int p_Comp_k_n(poly a, poly b, int k, ring r)
Definition: p_polys.h:642
static void p_SetCompP(poly p, int i, ring r)
Definition: p_polys.h:256

◆ p_GetExp() [1/3]

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

get v^th exponent for a monomial

Definition at line 574 of file p_polys.h.

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

◆ p_GetExp() [2/3]

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

Definition at line 557 of file p_polys.h.

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

◆ p_GetExp() [3/3]

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

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

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

Definition at line 471 of file p_polys.h.

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

◆ p_GetExp_k_n()

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

Definition at line 1374 of file p_polys.h.

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

◆ p_GetExpDiff()

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

Definition at line 637 of file p_polys.h.

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

◆ p_GetExpSum()

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

Definition at line 631 of file p_polys.h.

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

◆ p_GetExpV()

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

Definition at line 1522 of file p_polys.h.

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

◆ p_GetExpVL()

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

Definition at line 1531 of file p_polys.h.

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

◆ p_GetExpVLV()

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

Definition at line 1538 of file p_polys.h.

1539{
1541 for (unsigned j = r->N; j!=0; j--)
1542 ev[j-1] = p_GetExp(p, j, r);
1543 return (int64)p_GetComp(p,r);
1544}
long int64
Definition: auxiliary.h:68

◆ p_GetMaxExp() [1/2]

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

Definition at line 806 of file p_polys.h.

807{
808 return p_GetMaxExp(p_GetMaxExpL(p, r), r);
809}
static unsigned long p_GetMaxExp(const unsigned long l, const ring r)
Definition: p_polys.h:783
unsigned long p_GetMaxExpL(poly p, const ring r, unsigned long l_max=0)
return the maximal exponent of p in form of the maximal long var
Definition: p_polys.cc:1175

◆ p_GetMaxExp() [2/2]

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

Definition at line 783 of file p_polys.h.

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

◆ p_GetMaxExpL()

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

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

Definition at line 1175 of file p_polys.cc.

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

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

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

◆ p_GetOrder()

static long p_GetOrder ( poly  p,
ring  r 
)
inlinestatic

Definition at line 423 of file p_polys.h.

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

◆ p_GetSetmProc()

p_SetmProc p_GetSetmProc ( const ring  r)

Definition at line 560 of file p_polys.cc.

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

◆ p_GetShortExpVector() [1/2]

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

Definition at line 4897 of file p_polys.cc.

4898{
4899 assume(p != NULL);
4900 unsigned long ev = 0; // short exponent vector
4901 unsigned int n = BIT_SIZEOF_LONG / r->N; // number of bits per exp
4902 unsigned int m1; // highest bit which is filled with (n+1)
4903 unsigned int i=0;
4904 int j=1;
4905
4906 if (n == 0)
4907 {
4908 if (r->N <2*BIT_SIZEOF_LONG)
4909 {
4910 n=1;
4911 m1=0;
4912 }
4913 else
4914 {
4915 for (; j<=r->N; j++)
4916 {
4917 if (p_GetExp(p,j,r) > 0) i++;
4918 if (i == BIT_SIZEOF_LONG) break;
4919 }
4920 if (i>0)
4921 ev = ~(0UL) >> (BIT_SIZEOF_LONG - i);
4922 return ev;
4923 }
4924 }
4925 else
4926 {
4927 m1 = (n+1)*(BIT_SIZEOF_LONG - n*r->N);
4928 }
4929
4930 n++;
4931 while (i<m1)
4932 {
4933 ev |= GetBitFields(p_GetExp(p, j,r), i, n);
4934 i += n;
4935 j++;
4936 }
4937
4938 n--;
4939 while (i<BIT_SIZEOF_LONG)
4940 {
4941 ev |= GetBitFields(p_GetExp(p, j,r), i, n);
4942 i += n;
4943 j++;
4944 }
4945 return ev;
4946}
#define BIT_SIZEOF_LONG
Definition: auxiliary.h:80
static unsigned long GetBitFields(const long e, const unsigned int s, const unsigned int n)
Definition: p_polys.cc:4864

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

4951{
4952 assume(p != NULL);
4953 assume(pp != NULL);
4954
4955 unsigned long ev = 0; // short exponent vector
4956 unsigned int n = BIT_SIZEOF_LONG / r->N; // number of bits per exp
4957 unsigned int m1; // highest bit which is filled with (n+1)
4958 int j=1;
4959 unsigned long i = 0L;
4960
4961 if (n == 0)
4962 {
4963 if (r->N <2*BIT_SIZEOF_LONG)
4964 {
4965 n=1;
4966 m1=0;
4967 }
4968 else
4969 {
4970 for (; j<=r->N; j++)
4971 {
4972 if (p_GetExp(p,j,r) > 0 || p_GetExp(pp,j,r) > 0) i++;
4973 if (i == BIT_SIZEOF_LONG) break;
4974 }
4975 if (i>0)
4976 ev = ~(0UL) >> (BIT_SIZEOF_LONG - i);
4977 return ev;
4978 }
4979 }
4980 else
4981 {
4982 m1 = (n+1)*(BIT_SIZEOF_LONG - n*r->N);
4983 }
4984
4985 n++;
4986 while (i<m1)
4987 {
4988 ev |= GetBitFields(p_GetExp(p, j,r) + p_GetExp(pp, j,r), i, n);
4989 i += n;
4990 j++;
4991 }
4992
4993 n--;
4994 while (i<BIT_SIZEOF_LONG)
4995 {
4996 ev |= GetBitFields(p_GetExp(p, j,r) + p_GetExp(pp, j,r), i, n);
4997 i += n;
4998 j++;
4999 }
5000 return ev;
5001}

◆ p_GetTotalDegree()

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

Definition at line 812 of file p_polys.h.

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

◆ p_GetVariables()

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

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

Definition at line 1267 of file p_polys.cc.

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

◆ p_HasNotCF()

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

Definition at line 1329 of file p_polys.cc.

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

◆ p_HasNotCFRing()

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

Definition at line 1345 of file p_polys.cc.

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

◆ p_Head()

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

copy the (leading) term of p

Definition at line 862 of file p_polys.h.

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

◆ p_Head0()

poly p_Head0 ( const poly  p,
const ring  r 
)

like p_Head, but allow NULL coeff

Definition at line 5113 of file p_polys.cc.

5114{
5115 if (p==NULL) return NULL;
5116 if (pGetCoeff(p)==NULL) return p_CopyPowerProduct0(p,NULL,r);
5117 return p_Head(p,r);
5118}

◆ p_Homogen()

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

Definition at line 3335 of file p_polys.cc.

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

◆ p_IncrExp()

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

Definition at line 593 of file p_polys.h.

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

◆ p_Init() [1/2]

static poly p_Init ( const ring  r)
inlinestatic

Definition at line 1332 of file p_polys.h.

1333{
1334 return p_Init(r, r->PolyBin);
1335}

◆ p_Init() [2/2]

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

Definition at line 1322 of file p_polys.h.

1323{
1324 p_CheckRing1(r);
1325 pAssume1(bin != NULL && omSizeWOfBin(r->PolyBin) == omSizeWOfBin(bin));
1326 poly p;
1327 omTypeAlloc0Bin(poly, p, bin);
1329 p_SetRingOfLm(p, r);
1330 return p;
1331}
#define p_CheckRing1(r)
Definition: monomials.h:178
#define omTypeAlloc0Bin(type, addr, bin)
Definition: omAllocDecl.h:204

◆ p_InitContent()

number p_InitContent ( poly  ph,
const ring  r 
)

Definition at line 2700 of file p_polys.cc.

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

◆ p_IsConstant()

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

Definition at line 2005 of file p_polys.h.

2006{
2007 if (p == NULL) return TRUE;
2008 return (pNext(p)==NULL) && p_LmIsConstant(p, r);
2009}
static BOOLEAN p_LmIsConstant(const poly p, const ring r)
Definition: p_polys.h:1025

◆ p_IsConstantComp()

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

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

Definition at line 1999 of file p_polys.h.

2000{
2001 if (p == NULL) return TRUE;
2002 return (pNext(p)==NULL) && p_LmIsConstantComp(p, r);
2003}
static BOOLEAN p_LmIsConstantComp(const poly p, const ring r)
Definition: p_polys.h:1008

◆ p_IsConstantPoly()

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

Definition at line 2019 of file p_polys.h.

2020{
2021 p_Test(p, r);
2022 poly pp=p;
2023 while(pp!=NULL)
2024 {
2025 if (! p_LmIsConstantComp(pp, r))
2026 return FALSE;
2027 pIter(pp);
2028 }
2029 return TRUE;
2030}

◆ p_ISet()

poly p_ISet ( long  i,
const ring  r 
)

returns the poly representing the integer i

Definition at line 1297 of file p_polys.cc.

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

◆ p_IsHomogeneous()

BOOLEAN p_IsHomogeneous ( poly  p,
const ring  r 
)

Definition at line 3384 of file p_polys.cc.

3385{
3386 poly qp=p;
3387 int o;
3388
3389 if ((p == NULL) || (pNext(p) == NULL)) return TRUE;
3390 pFDegProc d;
3391 if (r->pLexOrder && (r->order[0]==ringorder_lp))
3392 d=p_Totaldegree;
3393 else
3394 d=r->pFDeg;
3395 o = d(p,r);
3396 do
3397 {
3398 if (d(qp,r) != o) return FALSE;
3399 pIter(qp);
3400 }
3401 while (qp != NULL);
3402 return TRUE;
3403}

◆ p_IsHomogeneousW() [1/2]

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

Definition at line 3425 of file p_polys.cc.

3426{
3427 poly qp=p;
3428 long o;
3429
3430 if ((p == NULL) || (pNext(p) == NULL)) return TRUE;
3431 pIter(qp);
3432 o = totaldegreeWecart_IV(p,r,w->ivGetVec())+(*module_w)[p_GetComp(p,r)];
3433 do
3434 {
3435 long oo=totaldegreeWecart_IV(qp,r,w->ivGetVec())+(*module_w)[p_GetComp(qp,r)];
3436 if (oo != o) return FALSE;
3437 pIter(qp);
3438 }
3439 while (qp != NULL);
3440 return TRUE;
3441}

◆ p_IsHomogeneousW() [2/2]

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

Definition at line 3408 of file p_polys.cc.

3409{
3410 poly qp=p;
3411 long o;
3412
3413 if ((p == NULL) || (pNext(p) == NULL)) return TRUE;
3414 pIter(qp);
3415 o = totaldegreeWecart_IV(p,r,w->ivGetVec());
3416 do
3417 {
3418 if (totaldegreeWecart_IV(qp,r,w->ivGetVec()) != o) return FALSE;
3419 pIter(qp);
3420 }
3421 while (qp != NULL);
3422 return TRUE;
3423}

◆ p_IsOne()

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

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

Definition at line 2012 of file p_polys.h.

2013{
2014 if (p == NULL) return FALSE; /* TODO check if 0 == 1 */
2015 p_Test(p, R);
2016 return (p_IsConstant(p, R) && n_IsOne(p_GetCoeff(p, R), R->cf));
2017}

◆ p_IsPurePower()

int p_IsPurePower ( const poly  p,
const ring  r 
)

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

Definition at line 1226 of file p_polys.cc.

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

◆ p_IsUnit()

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

Definition at line 2032 of file p_polys.h.

2033{
2034 if (p == NULL) return FALSE;
2035 if (rField_is_Ring(r))
2036 return (p_LmIsConstant(p, r) && n_IsUnit(pGetCoeff(p),r->cf));
2037 return p_LmIsConstant(p, r);
2038}
static FORCE_INLINE BOOLEAN n_IsUnit(number n, const coeffs r)
TRUE iff n has a multiplicative inverse in the given coeff field/ring r.
Definition: coeffs.h:515

◆ p_IsUnivariate()

int p_IsUnivariate ( poly  p,
const ring  r 
)

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

Definition at line 1247 of file p_polys.cc.

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

◆ p_Jet()

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

Definition at line 4502 of file p_polys.cc.

4503{
4504 while((p!=NULL) && (p_Totaldegree(p,R)>m)) p_LmDelete(&p,R);
4505 if (p==NULL) return NULL;
4506 poly r=p;
4507 while (pNext(p)!=NULL)
4508 {
4509 if (p_Totaldegree(pNext(p),R)>m)
4510 {
4511 p_LmDelete(&pNext(p),R);
4512 }
4513 else
4514 pIter(p);
4515 }
4516 return r;
4517}

◆ p_JetW()

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

Definition at line 4546 of file p_polys.cc.

4547{
4548 while((p!=NULL) && (totaldegreeWecart_IV(p,R,w)>m)) p_LmDelete(&p,R);
4549 if (p==NULL) return NULL;
4550 poly r=p;
4551 while (pNext(p)!=NULL)
4552 {
4554 {
4555 p_LmDelete(&pNext(p),R);
4556 }
4557 else
4558 pIter(p);
4559 }
4560 return r;
4561}

◆ p_Last()

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

Definition at line 4737 of file p_polys.cc.

4738{
4739 if (p == NULL)
4740 {
4741 l = 0;
4742 return NULL;
4743 }
4744 l = 1;
4745 poly a = p;
4746 if (! rIsSyzIndexRing(r))
4747 {
4748 poly next = pNext(a);
4749 while (next!=NULL)
4750 {
4751 a = next;
4752 next = pNext(a);
4753 l++;
4754 }
4755 }
4756 else
4757 {
4758 long unsigned curr_limit = rGetCurrSyzLimit(r);
4759 poly pp = a;
4760 while ((a=pNext(a))!=NULL)
4761 {
4762 if (__p_GetComp(a,r)<=curr_limit/*syzComp*/)
4763 l++;
4764 else break;
4765 pp = a;
4766 }
4767 a=pp;
4768 }
4769 return a;
4770}
ListNode * next
Definition: janet.h:31
static int rGetCurrSyzLimit(const ring r)
Definition: ring.h:724
static BOOLEAN rIsSyzIndexRing(const ring r)
Definition: ring.h:721

◆ p_Lcm() [1/2]

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

Definition at line 1660 of file p_polys.cc.

1661{
1662 poly m=p_Init(r);
1663 p_Lcm(a, b, m, r);
1664 p_Setm(m,r);
1665 return(m);
1666}
void p_Lcm(const poly a, const poly b, poly m, const ring r)
Definition: p_polys.cc:1651

◆ p_Lcm() [2/2]

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

Definition at line 1651 of file p_polys.cc.

1652{
1653 for (int i=r->N; i; --i)
1654 p_SetExp(m,i, si_max( p_GetExp(a,i,r), p_GetExp(b,i,r)),r);
1655
1656 p_SetComp(m, si_max(p_GetComp(a,r), p_GetComp(b,r)),r);
1657 /* Don't do a pSetm here, otherwise hres/lres chockes */
1658}
static int si_max(const int a, const int b)
Definition: auxiliary.h:124
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition: p_polys.h:249

◆ p_LcmRat()

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

Definition at line 1673 of file p_polys.cc.

1674{
1675 poly m = // p_One( r);
1676 p_Init(r);
1677
1678// const int (currRing->N) = r->N;
1679
1680 // for (int i = (currRing->N); i>=r->real_var_start; i--)
1681 for (int i = r->real_var_end; i>=r->real_var_start; i--)
1682 {
1683 const int lExpA = p_GetExp (a, i, r);
1684 const int lExpB = p_GetExp (b, i, r);
1685
1686 p_SetExp (m, i, si_max(lExpA, lExpB), r);
1687 }
1688
1689 p_SetComp (m, lCompM, r);
1690 p_Setm(m,r);
1691 n_New(&(p_GetCoeff(m, r)), r);
1692
1693 return(m);
1694};
#define n_New(n, r)
Definition: coeffs.h:440

◆ p_LDeg()

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

Definition at line 383 of file p_polys.h.

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

◆ p_LmCheckIsFromRing()

BOOLEAN p_LmCheckIsFromRing ( poly  p,
ring  r 
)

Definition at line 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 &&
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:137
#define _pPolyAssumeReturn(cond, p, r)
Definition: monomials.h:101
#define omIsBinPageAddr(addr)
Definition: omBinPage.h:68
#define omSizeWOfAddr(P)
Definition: xalloc.h:223

◆ p_LmCheckPolyRing()

BOOLEAN p_LmCheckPolyRing ( poly  p,
ring  r 
)

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

1583{
1585 p_LmCheckPolyRing1(q, r);
1586
1587 const unsigned long* _s1 = ((unsigned long*) p->exp);
1588 const unsigned long* _s2 = ((unsigned long*) q->exp);
1589 REGISTER unsigned long _v1;
1590 REGISTER unsigned long _v2;
1591 const unsigned long _l = r->CmpL_Size;
1592
1593 REGISTER unsigned long _i=0;
1594
1595 LengthGeneral_OrdGeneral_LoopTop:
1596 _v1 = _s1[_i];
1597 _v2 = _s2[_i];
1598 if (_v1 == _v2)
1599 {
1600 _i++;
1601 if (_i == _l) return 0;
1602 goto LengthGeneral_OrdGeneral_LoopTop;
1603 }
1604 const long* _ordsgn = (long*) r->ordsgn;
1605#if 1 /* two variants*/
1606 if (_v1 > _v2)
1607 {
1608 return _ordsgn[_i];
1609 }
1610 return -(_ordsgn[_i]);
1611#else
1612 if (_v1 > _v2)
1613 {
1614 if (_ordsgn[_i] == 1) return 1;
1615 return -1;
1616 }
1617 if (_ordsgn[_i] == 1) return -1;
1618 return 1;
1619#endif
1620}
if(!FE_OPT_NO_SHELL_FLAG)(void) system(sys)
#define REGISTER
Definition: omalloc.h:27

◆ p_LmDelete() [1/2]

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

Definition at line 745 of file p_polys.h.

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

◆ p_LmDelete() [2/2]

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

Definition at line 725 of file p_polys.h.

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

◆ p_LmDelete0()

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

Definition at line 735 of file p_polys.h.

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

◆ p_LmDeleteAndNext()

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

Definition at line 757 of file p_polys.h.

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

◆ p_LmDeleteAndNextRat()

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

Definition at line 1696 of file p_polys.cc.

1697{
1698 /* modifies p*/
1699 // Print("start: "); Print(" "); p_wrp(*p,r);
1700 p_LmCheckPolyRing2(*p, r);
1701 poly q = p_Head(*p,r);
1702 const long cmp = p_GetComp(*p, r);
1703 while ( ( (*p)!=NULL ) && ( p_Comp_k_n(*p, q, ishift+1, r) ) && (p_GetComp(*p, r) == cmp) )
1704 {
1705 p_LmDelete(p,r);
1706 // Print("while: ");p_wrp(*p,r);Print(" ");
1707 }
1708 // p_wrp(*p,r);Print(" ");
1709 // PrintS("end\n");
1710 p_LmDelete(&q,r);
1711}

◆ p_LmDivisibleBy() [1/2]

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

Definition at line 1924 of file p_polys.h.

1925{
1926 p_LmCheckPolyRing(a, r_a);
1927 p_LmCheckPolyRing(b, r_b);
1928 return _p_LmDivisibleBy(a, r_a, b, r_b);
1929}

◆ p_LmDivisibleBy() [2/2]

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

Definition at line 1897 of file p_polys.h.

1898{
1900 pIfThen1(a != NULL, p_LmCheckPolyRing1(b, r));
1901 if (p_GetComp(a, r) == 0 || p_GetComp(a,r) == p_GetComp(b,r))
1902 return _p_LmDivisibleByNoComp(a, b, r);
1903 return FALSE;
1904}

◆ p_LmDivisibleByNoComp() [1/2]

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

Definition at line 1890 of file p_polys.h.

1891{
1892 p_LmCheckPolyRing1(a, ra);
1893 p_LmCheckPolyRing1(b, rb);
1894 return _p_LmDivisibleByNoComp(a, ra, b, rb);
1895}

◆ p_LmDivisibleByNoComp() [2/2]

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

Definition at line 1883 of file p_polys.h.

1884{
1885 p_LmCheckPolyRing1(a, r);
1887 return _p_LmDivisibleByNoComp(a, b, r);
1888}

◆ p_LmDivisibleByPart()

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

Definition at line 1862 of file p_polys.h.

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

◆ p_LmExpVectorAddIsOk()

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

Definition at line 2040 of file p_polys.h.

2042{
2043 p_LmCheckPolyRing(p1, r);
2044 p_LmCheckPolyRing(p2, r);
2045 unsigned long l1, l2, divmask = r->divmask;
2046 int i;
2047
2048 for (i=0; i<r->VarL_Size; i++)
2049 {
2050 l1 = p1->exp[r->VarL_Offset[i]];
2051 l2 = p2->exp[r->VarL_Offset[i]];
2052 // do the divisiblity trick
2053 if ( (l1 > ULONG_MAX - l2) ||
2054 (((l1 & divmask) ^ (l2 & divmask)) != ((l1 + l2) & divmask)))
2055 return FALSE;
2056 }
2057 return TRUE;
2058}

◆ p_LmFree() [1/2]

static void p_LmFree ( poly *  p,
ring   
)
inlinestatic

Definition at line 698 of file p_polys.h.

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

◆ p_LmFree() [2/2]

static void p_LmFree ( poly  p,
ring   
)
inlinestatic

Definition at line 685 of file p_polys.h.

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

◆ p_LmFreeAndNext()

static poly p_LmFreeAndNext ( poly  p,
ring   
)
inlinestatic

Definition at line 713 of file p_polys.h.

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

◆ p_LmInit() [1/3]

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

Definition at line 1337 of file p_polys.h.

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

◆ p_LmInit() [2/3]

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

Definition at line 1365 of file p_polys.h.

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

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

1349{
1350 p_LmCheckPolyRing1(s_p, s_r);
1351 p_CheckRing(d_r);
1352 pAssume1(d_r->N <= s_r->N);
1353 poly d_p = p_Init(d_r, d_bin);
1354 for (unsigned i=d_r->N; i!=0; i--)
1355 {
1356 p_SetExp(d_p, i, p_GetExp(s_p, i,s_r), d_r);
1357 }
1358 if (rRing_has_Comp(d_r))
1359 {
1360 p_SetComp(d_p, p_GetComp(s_p,s_r), d_r);
1361 }
1362 p_Setm(d_p, d_r);
1363 return d_p;
1364}
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 1025 of file p_polys.h.

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

◆ p_LmIsConstantComp()

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

Definition at line 1008 of file p_polys.h.

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

◆ p_LmShallowCopyDelete()

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

Definition at line 1395 of file p_polys.h.

1396{
1398 pAssume1(omSizeWOfBin(bin) == omSizeWOfBin(r->PolyBin));
1399 poly new_p = p_New(r);
1400 memcpy(new_p->exp, p->exp, r->ExpL_Size*sizeof(long));
1401 pSetCoeff0(new_p, pGetCoeff(p));
1402 pNext(new_p) = pNext(p);
1404 return new_p;
1405}
static poly p_New(const ring, omBin bin)
Definition: p_polys.h:666

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

1973{
1974 p_LmCheckPolyRing1(a, r_a);
1975 p_LmCheckPolyRing1(b, r_b);
1976#ifndef PDIV_DEBUG
1977 _pPolyAssume2(p_GetShortExpVector(a, r_a) == sev_a, a, r_a);
1978 _pPolyAssume2(p_GetShortExpVector(b, r_b) == ~ not_sev_b, b, r_b);
1979
1980 if (sev_a & not_sev_b)
1981 {
1982 pAssume1(_p_LmDivisibleByNoComp(a, r_a, b, r_b) == FALSE);
1983 return FALSE;
1984 }
1985 return _p_LmDivisibleBy(a, r_a, b, r_b);
1986#else
1987 return pDebugLmShortDivisibleBy(a, sev_a, r_a, b, not_sev_b, r_b);
1988#endif
1989}
#define _pPolyAssume2(cond, p, r)
Definition: monomials.h:195
BOOLEAN pDebugLmShortDivisibleBy(poly p1, unsigned long sev_1, ring r_1, poly p2, unsigned long not_sev_2, ring r_2)
Definition: pDebug.cc:366
unsigned long p_GetShortExpVector(const poly a, const ring r)
Definition: p_polys.cc:4897

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

1933{
1934 p_LmCheckPolyRing1(a, r);
1936#ifndef PDIV_DEBUG
1937 _pPolyAssume2(p_GetShortExpVector(a, r) == sev_a, a, r);
1938 _pPolyAssume2(p_GetShortExpVector(b, r) == ~ not_sev_b, b, r);
1939
1940 if (sev_a & not_sev_b)
1941 {
1943 return FALSE;
1944 }
1945 return p_LmDivisibleBy(a, b, r);
1946#else
1947 return pDebugLmShortDivisibleBy(a, sev_a, r, b, not_sev_b, r);
1948#endif
1949}
static BOOLEAN p_LmDivisibleByNoComp(poly a, poly b, const ring r)
Definition: p_polys.h:1883
static BOOLEAN p_LmDivisibleBy(poly a, poly b, const ring r)
Definition: p_polys.h:1897

◆ p_LmShortDivisibleByNoComp()

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

Definition at line 1951 of file p_polys.h.

1953{
1954 p_LmCheckPolyRing1(a, r);
1956#ifndef PDIV_DEBUG
1957 _pPolyAssume2(p_GetShortExpVector(a, r) == sev_a, a, r);
1958 _pPolyAssume2(p_GetShortExpVector(b, r) == ~ not_sev_b, b, r);
1959
1960 if (sev_a & not_sev_b)
1961 {
1963 return FALSE;
1964 }
1965 return p_LmDivisibleByNoComp(a, b, r);
1966#else
1967 return pDebugLmShortDivisibleByNoComp(a, sev_a, r, b, not_sev_b, r);
1968#endif
1969}
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 4796 of file p_polys.cc.

4797{
4798 int k,l,lex;
4799
4800 if (p == NULL) return -1;
4801
4802 k = 32000;/*a very large dummy value*/
4803 while (p != NULL)
4804 {
4805 l = 1;
4806 lex = p_GetExp(p,l,r);
4807 while ((l < (rVar(r))) && (lex == 0))
4808 {
4809 l++;
4810 lex = p_GetExp(p,l,r);
4811 }
4812 l--;
4813 if (l < k) k = l;
4814 pIter(p);
4815 }
4816 return k;
4817}

◆ p_LtCmp()

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

Definition at line 1623 of file p_polys.h.

1624{
1625 int res = p_LmCmp(p,q,r);
1626 if(res == 0)
1627 {
1628 if(p_GetCoeff(p,r) == NULL || p_GetCoeff(q,r) == NULL)
1629 return res;
1630 number pc = n_Copy(p_GetCoeff(p,r),r->cf);
1631 number qc = n_Copy(p_GetCoeff(q,r),r->cf);
1632 if(!n_GreaterZero(pc,r->cf))
1633 pc = n_InpNeg(pc,r->cf);
1634 if(!n_GreaterZero(qc,r->cf))
1635 qc = n_InpNeg(qc,r->cf);
1636 if(n_Greater(pc,qc,r->cf))
1637 res = 1;
1638 else if(n_Greater(qc,pc,r->cf))
1639 res = -1;
1640 else if(n_Equal(pc,qc,r->cf))
1641 res = 0;
1642 n_Delete(&pc,r->cf);
1643 n_Delete(&qc,r->cf);
1644 }
1645 return res;
1646}
static FORCE_INLINE BOOLEAN n_Greater(number a, number b, const coeffs r)
ordered fields: TRUE iff 'a' is larger than 'b'; in Z/pZ: TRUE iff la > lb, where la and lb are the l...
Definition: coeffs.h:511

◆ p_LtCmpNoAbs()

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

Definition at line 1649 of file p_polys.h.

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

◆ p_LtCmpOrdSgnDiffM()

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

Definition at line 1671 of file p_polys.h.

1672{
1673 return(p_LtCmp(p,q,r) == r->OrdSgn);
1674}
static int p_LtCmp(poly p, poly q, const ring r)
Definition: p_polys.h:1623

◆ p_LtCmpOrdSgnDiffP()

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

Definition at line 1680 of file p_polys.h.

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

◆ p_LtCmpOrdSgnEqM()

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

Definition at line 1696 of file p_polys.h.

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

◆ p_LtCmpOrdSgnEqP()

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

Definition at line 1705 of file p_polys.h.

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

◆ p_MaxComp() [1/2]

static long p_MaxComp ( poly  p,
ring  lmRing 
)
inlinestatic

Definition at line 313 of file p_polys.h.

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

◆ p_MaxComp() [2/2]

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

Definition at line 294 of file p_polys.h.

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

◆ p_MaxExpPerVar()

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

max exponent of variable x_i in p

Definition at line 5119 of file p_polys.cc.

5120{
5121 int m=0;
5122 while(p!=NULL)
5123 {
5124 int mm=p_GetExp(p,i,r);
5125 if (mm>m) m=mm;
5126 pIter(p);
5127 }
5128 return m;
5129}

◆ p_MDivide()

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

Definition at line 1488 of file p_polys.cc.

1489{
1490 assume((p_GetComp(a,r)==p_GetComp(b,r)) || (p_GetComp(b,r)==0));
1491 int i;
1492 poly result = p_Init(r);
1493
1494 for(i=(int)r->N; i; i--)
1495 p_SetExp(result,i, p_GetExp(a,i,r)- p_GetExp(b,i,r),r);
1496 p_SetComp(result, p_GetComp(a,r) - p_GetComp(b,r),r);
1497 p_Setm(result,r);
1498 return result;
1499}

◆ p_MemAdd_NegWeightAdjust()

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

Definition at line 1294 of file p_polys.h.

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

◆ p_MemSub_NegWeightAdjust()

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

Definition at line 1304 of file p_polys.h.

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

◆ p_Merge_q()

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

Definition at line 1214 of file p_polys.h.

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

◆ p_MinComp() [1/2]

static long p_MinComp ( poly  p,
ring  lmRing 
)
inlinestatic

Definition at line 334 of file p_polys.h.

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

◆ p_MinComp() [2/2]

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

Definition at line 315 of file p_polys.h.

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

◆ p_MinDeg()

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

Definition at line 4564 of file p_polys.cc.

4565{
4566 if(p==NULL)
4567 return -1;
4568 int d=-1;
4569 while(p!=NULL)
4570 {
4571 int d0=0;
4572 for(int j=0;j<rVar(R);j++)
4573 if(w==NULL||j>=w->length())
4574 d0+=p_GetExp(p,j+1,R);
4575 else
4576 d0+=(*w)[j]*p_GetExp(p,j+1,R);
4577 if(d0<d||d==-1)
4578 d=d0;
4579 pIter(p);
4580 }
4581 return d;
4582}

◆ p_mInit()

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

Definition at line 1442 of file p_polys.cc.

1443{
1444 poly p;
1445 const char *s=p_Read(st,p,r);
1446 if (*s!='\0')
1447 {
1448 if ((s!=st)&&isdigit(st[0]))
1449 {
1451 }
1452 ok=FALSE;
1453 if (p!=NULL)
1454 {
1455 if (pGetCoeff(p)==NULL) p_LmFree(p,r);
1456 else p_LmDelete(p,r);
1457 }
1458 return NULL;
1459 }
1460 p_Test(p,r);
1461 ok=!errorreported;
1462 return p;
1463}
VAR short errorreported
Definition: feFopen.cc:23
const char * p_Read(const char *st, poly &rc, const ring r)
Definition: p_polys.cc:1370

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

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

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

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

◆ p_mm_Mult()

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

Definition at line 1063 of file p_polys.h.

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

◆ p_Mult_mm()

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

Definition at line 1053 of file p_polys.h.

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

◆ p_Mult_nn() [1/2]

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

Definition at line 975 of file p_polys.h.

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

◆ p_Mult_nn() [2/2]

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

Definition at line 960 of file p_polys.h.

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

◆ p_Mult_q()

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

Definition at line 1116 of file p_polys.h.

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

◆ p_MultExp()

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

Definition at line 623 of file p_polys.h.

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

◆ p_Neg()

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

Definition at line 1109 of file p_polys.h.

1110{
1111 return r->p_Procs->p_Neg(p, r);
1112}

◆ p_New() [1/2]

static poly p_New ( const  ring,
omBin  bin 
)
inlinestatic

Definition at line 666 of file p_polys.h.

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

◆ p_New() [2/2]

static poly p_New ( ring  r)
inlinestatic

Definition at line 677 of file p_polys.h.

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

◆ p_Norm()

void p_Norm ( poly  p1,
const ring  r 
)

Definition at line 3835 of file p_polys.cc.

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

◆ p_Normalize()

void p_Normalize ( poly  p,
const ring  r 
)

Definition at line 3929 of file p_polys.cc.

3930{
3931 const coeffs cf=r->cf;
3932 /* Z/p, GF(p,n), R, long R/C, Nemo rings */
3933 if (cf->cfNormalize==ndNormalize)
3934 return;
3935 while (p!=NULL)
3936 {
3937 // no test befor n_Normalize: n_Normalize should fix problems
3939 pIter(p);
3940 }
3941}
void ndNormalize(number &, const coeffs)
Definition: numbers.cc:190

◆ p_NSet()

poly p_NSet ( number  n,
const ring  r 
)

returns the poly representing the number n, destroys n

Definition at line 1469 of file p_polys.cc.

1470{
1471 if (n_IsZero(n,r->cf))
1472 {
1473 n_Delete(&n, r->cf);
1474 return NULL;
1475 }
1476 else
1477 {
1478 poly rc = p_Init(r);
1479 pSetCoeff0(rc,n);
1480 return rc;
1481 }
1482}

◆ p_One()

poly p_One ( const ring  r)

Definition at line 1313 of file p_polys.cc.

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

◆ p_OneComp()

BOOLEAN p_OneComp ( poly  p,
const ring  r 
)

return TRUE if all monoms have the same component

Definition at line 1208 of file p_polys.cc.

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

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

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

◆ p_Plus_mm_Mult_qq() [1/2]

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

Definition at line 1207 of file p_polys.h.

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

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

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

◆ p_PolyDiv()

poly p_PolyDiv ( poly &  p,
const poly  divisor,
const BOOLEAN  needResult,
const ring  r 
)

assumes that p and divisor are univariate polynomials in r, mentioning the same variable; assumes divisor != NULL; p may be NULL; assumes a global monomial ordering in r; performs polynomial division of p by divisor:

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

Definition at line 1866 of file p_polys.cc.

1867{
1868 assume(divisor != NULL);
1869 if (p == NULL) return NULL;
1870
1871 poly result = NULL;
1872 number divisorLC = p_GetCoeff(divisor, r);
1873 int divisorLE = p_GetExp(divisor, 1, r);
1874 while ((p != NULL) && (p_Deg(p, r) >= p_Deg(divisor, r)))
1875 {
1876 /* determine t = LT(p) / LT(divisor) */
1877 poly t = p_ISet(1, r);
1878 number c = n_Div(p_GetCoeff(p, r), divisorLC, r->cf);
1879 n_Normalize(c,r->cf);
1880 p_SetCoeff(t, c, r);
1881 int e = p_GetExp(p, 1, r) - divisorLE;
1882 p_SetExp(t, 1, e, r);
1883 p_Setm(t, r);
1884 if (needResult) result = p_Add_q(result, p_Copy(t, r), r);
1885 p = p_Add_q(p, p_Neg(p_Mult_q(t, p_Copy(divisor, r), r), r), r);
1886 }
1887 return result;
1888}
long p_Deg(poly a, const ring r)
Definition: p_polys.cc:587

◆ p_Power()

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

Definition at line 2193 of file p_polys.cc.

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

◆ p_ProjectiveUnique()

void p_ProjectiveUnique ( poly  p,
const ring  r 
)

Definition at line 3208 of file p_polys.cc.

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

◆ p_Read()

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

Definition at line 1370 of file p_polys.cc.

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

◆ p_Series()

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

Definition at line 4614 of file p_polys.cc.

4615{
4616 int *ww=iv2array(w,R);
4617 if(p!=NULL)
4618 {
4619 if(u==NULL)
4620 p=p_JetW(p,n,ww,R);
4621 else
4622 p=p_JetW(p_Mult_q(p,p_Invers(n-p_MinDeg(p,w,R),u,w,R),R),n,ww,R);
4623 }
4624 omFreeSize((ADDRESS)ww,(rVar(R)+1)*sizeof(int));
4625 return p;
4626}
static poly p_Invers(int n, poly u, intvec *w, const ring R)
Definition: p_polys.cc:4585
int p_MinDeg(poly p, intvec *w, const ring R)
Definition: p_polys.cc:4564
poly p_JetW(poly p, int m, int *w, const ring R)
Definition: p_polys.cc:4546
int * iv2array(intvec *iv, const ring R)
Definition: weight.cc:200

◆ p_SetCoeff()

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

Definition at line 414 of file p_polys.h.

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

◆ p_SetComp()

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

Definition at line 249 of file p_polys.h.

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

◆ p_SetCompP() [1/2]

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

Definition at line 283 of file p_polys.h.

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

◆ p_SetCompP() [2/2]

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

Definition at line 256 of file p_polys.h.

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

◆ p_SetExp() [1/3]

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

set v^th exponent for a monomial

Definition at line 584 of file p_polys.h.

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

◆ p_SetExp() [2/3]

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

Definition at line 564 of file p_polys.h.

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

◆ p_SetExp() [3/3]

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

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

See also
p_GetExp

Definition at line 490 of file p_polys.h.

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

◆ p_SetExpV()

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

Definition at line 1546 of file p_polys.h.

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

◆ p_SetExpVL()

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

Definition at line 1555 of file p_polys.h.

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

◆ p_SetExpVLV()

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

Definition at line 1566 of file p_polys.h.

1567{
1569 for (unsigned j = r->N; j!=0; j--)
1570 p_SetExp(p, j, ev[j-1], r);
1571 p_SetComp(p, comp,r);
1572
1573 p_Setm(p, r);
1574}
int comp(const CanonicalForm &A, const CanonicalForm &B)
compare polynomials

◆ p_Setm()

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

Definition at line 235 of file p_polys.h.

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

◆ p_SetModDeg()

void p_SetModDeg ( intvec w,
ring  r 
)

Definition at line 3789 of file p_polys.cc.

3790{
3791 if (w!=NULL)
3792 {
3793 r->pModW = w;
3794 pOldFDeg = r->pFDeg;
3795 pOldLDeg = r->pLDeg;
3796 pOldLexOrder = r->pLexOrder;
3798 r->pLexOrder = TRUE;
3799 }
3800 else
3801 {
3802 r->pModW = NULL;
3804 r->pLexOrder = pOldLexOrder;
3805 }
3806}
STATIC_VAR pLDegProc pOldLDeg
Definition: p_polys.cc:3777
void pRestoreDegProcs(ring r, pFDegProc old_FDeg, pLDegProc old_lDeg)
Definition: p_polys.cc:3765
STATIC_VAR BOOLEAN pOldLexOrder
Definition: p_polys.cc:3778
STATIC_VAR pFDegProc pOldFDeg
Definition: p_polys.cc:3776
void pSetDegProcs(ring r, pFDegProc new_FDeg, pLDegProc new_lDeg)
Definition: p_polys.cc:3753
static long pModDeg(poly p, ring r)
Definition: p_polys.cc:3780

◆ p_ShallowCopyDelete()

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

Definition at line 930 of file p_polys.h.

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

◆ p_ShallowDelete()

void p_ShallowDelete ( poly *  p,
const ring  r 
)

◆ p_Shift()

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

shifts components of the vector p by i

Definition at line 4822 of file p_polys.cc.

4823{
4824 poly qp1 = *p,qp2 = *p;/*working pointers*/
4825 int j = p_MaxComp(*p,r),k = p_MinComp(*p,r);
4826
4827 if (j+i < 0) return ;
4828 BOOLEAN toPoly= ((j == -i) && (j == k));
4829 while (qp1 != NULL)
4830 {
4831 if (toPoly || (__p_GetComp(qp1,r)+i > 0))
4832 {
4833 p_AddComp(qp1,i,r);
4834 p_SetmComp(qp1,r);
4835 qp2 = qp1;
4836 pIter(qp1);
4837 }
4838 else
4839 {
4840 if (qp2 == *p)
4841 {
4842 pIter(*p);
4843 p_LmDelete(&qp2,r);
4844 qp2 = *p;
4845 qp1 = *p;
4846 }
4847 else
4848 {
4849 qp2->next = qp1->next;
4850 if (qp1!=NULL) p_LmDelete(&qp1,r);
4851 qp1 = qp2->next;
4852 }
4853 }
4854 }
4855}
return
Definition: cfGcdAlgExt.cc:218
static unsigned long p_AddComp(poly p, unsigned long v, ring r)
Definition: p_polys.h:449

◆ p_SimpleContent()

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

Definition at line 2629 of file p_polys.cc.

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

◆ p_Size()

int p_Size ( poly  p,
const ring  r 
)

Definition at line 3318 of file p_polys.cc.

3319{
3320 int count = 0;
3321 if (r->cf->has_simple_Alloc)
3322 return pLength(p);
3323 while ( p != NULL )
3324 {
3325 count+= n_Size( pGetCoeff( p ), r->cf );
3326 pIter( p );
3327 }
3328 return count;
3329}
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 1221 of file p_polys.h.

1222{
1223 if (revert) p = pReverse(p);
1224 return sBucketSortAdd(p, r);
1225}
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 1231 of file p_polys.h.

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

◆ p_Split()

void p_Split ( poly  p,
poly *  r 
)

Definition at line 1320 of file p_polys.cc.

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

◆ p_String() [1/2]

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

Definition at line 322 of file polys0.cc.

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

◆ p_String() [2/2]

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

Definition at line 1242 of file p_polys.h.

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

◆ p_String0() [1/2]

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

print p according to ShortOut in lmRing & tailRing

Definition at line 223 of file polys0.cc.

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

◆ p_String0() [2/2]

static void p_String0 ( poly  p,
ring  p_ring 
)
inlinestatic

Definition at line 1246 of file p_polys.h.

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

◆ p_String0Long()

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

print p in a long way

print p in a long way

Definition at line 203 of file polys0.cc.

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

◆ p_String0Short()

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

print p in a short way, if possible

print p in a short way, if possible

Definition at line 184 of file polys0.cc.

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

◆ p_Sub()

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

Definition at line 1986 of file p_polys.cc.

1987{
1988 return p_Add_q(p1, p_Neg(p2,r),r);
1989}

◆ p_SubComp()

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

Definition at line 455 of file p_polys.h.

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

◆ p_SubExp()

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

Definition at line 615 of file p_polys.h.

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

◆ p_Subst()

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

Definition at line 4074 of file p_polys.cc.

4075{
4076#ifdef HAVE_SHIFTBBA
4077 // also don't even use p_Subst0 for Letterplace
4078 if (rIsLPRing(r))
4079 {
4080 poly subst = p_LPSubst(p, n, e, r);
4081 p_Delete(&p, r);
4082 return subst;
4083 }
4084#endif
4085
4086 if (e == NULL) return p_Subst0(p, n,r);
4087
4088 if (p_IsConstant(e,r))
4089 {
4090 if (n_IsOne(pGetCoeff(e),r->cf)) return p_Subst1(p,n,r);
4091 else return p_Subst2(p, n, pGetCoeff(e),r);
4092 }
4093
4094#ifdef HAVE_PLURAL
4095 if (rIsPluralRing(r))
4096 {
4097 return nc_pSubst(p,n,e,r);
4098 }
4099#endif
4100
4101 int exponent,i;
4102 poly h, res, m;
4103 int *me,*ee;
4104 number nu,nu1;
4105
4106 me=(int *)omAlloc((rVar(r)+1)*sizeof(int));
4107 ee=(int *)omAlloc((rVar(r)+1)*sizeof(int));
4108 if (e!=NULL) p_GetExpV(e,ee,r);
4109 res=NULL;
4110 h=p;
4111 while (h!=NULL)
4112 {
4113 if ((e!=NULL) || (p_GetExp(h,n,r)==0))
4114 {
4115 m=p_Head(h,r);
4116 p_GetExpV(m,me,r);
4117 exponent=me[n];
4118 me[n]=0;
4119 for(i=rVar(r);i>0;i--)
4120 me[i]+=exponent*ee[i];
4121 p_SetExpV(m,me,r);
4122 if (e!=NULL)
4123 {
4124 n_Power(pGetCoeff(e),exponent,&nu,r->cf);
4125 nu1=n_Mult(pGetCoeff(m),nu,r->cf);
4126 n_Delete(&nu,r->cf);
4127 p_SetCoeff(m,nu1,r);
4128 }
4129 res=p_Add_q(res,m,r);
4130 }
4131 p_LmDelete(&h,r);
4132 }
4133 omFreeSize((ADDRESS)me,(rVar(r)+1)*sizeof(int));
4134 omFreeSize((ADDRESS)ee,(rVar(r)+1)*sizeof(int));
4135 return res;
4136}
CanonicalForm subst(const CanonicalForm &f, const CFList &a, const CFList &b, const CanonicalForm &Rstar, bool isFunctionField)
poly nc_pSubst(poly p, int n, poly e, const ring r)
substitute the n-th variable by e in p destroy p e is not a constant
Definition: old.gring.cc:3203
static poly p_Subst0(poly p, int n, const ring r)
Definition: p_polys.cc:4049
static poly p_Subst1(poly p, int n, const ring r)
Definition: p_polys.cc:3981
static poly p_Subst2(poly p, int n, number e, const ring r)
Definition: p_polys.cc:4008
poly p_LPSubst(poly p, int n, poly e, const ring r)
Definition: shiftop.cc:912

◆ p_TakeOutComp() [1/2]

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

Definition at line 3551 of file p_polys.cc.

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

◆ p_TakeOutComp() [2/2]

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

Definition at line 3612 of file p_polys.cc.

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

◆ p_TakeOutComp1()

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

Definition at line 3500 of file p_polys.cc.

3501{
3502 poly q = *p;
3503
3504 if (q==NULL) return NULL;
3505
3506 poly qq=NULL,result = NULL;
3507 long unsigned kk=k;
3508 if (__p_GetComp(q,r)==kk)
3509 {
3510 result = q; /* *p */
3511 while ((q!=NULL) && (__p_GetComp(q,r)==kk))
3512 {
3513 p_SetComp(q,0,r);
3514 p_SetmComp(q,r);
3515 qq = q;
3516 pIter(q);
3517 }
3518 *p = q;
3519 pNext(qq) = NULL;
3520 }
3521 if (q==NULL) return result;
3522// if (pGetComp(q) > k) pGetComp(q)--;
3523 while (pNext(q)!=NULL)
3524 {
3525 if (__p_GetComp(pNext(q),r)==kk)
3526 {
3527 if (result==NULL)
3528 {
3529 result = pNext(q);
3530 qq = result;
3531 }
3532 else
3533 {
3534 pNext(qq) = pNext(q);
3535 pIter(qq);
3536 }
3537 pNext(q) = pNext(pNext(q));
3538 pNext(qq) =NULL;
3539 p_SetComp(qq,0,r);
3540 p_SetmComp(qq,r);
3541 }
3542 else
3543 {
3544 pIter(q);
3545// if (pGetComp(q) > k) pGetComp(q)--;
3546 }
3547 }
3548 return result;
3549}

◆ p_Totaldegree()

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

Definition at line 1509 of file p_polys.h.

1510{
1512 unsigned long s = p_GetTotalDegree(p->exp[r->VarL_Offset[0]],
1513 r,
1514 r->ExpPerLong);
1515 for (unsigned i=r->VarL_Size-1; i!=0; i--)
1516 {
1517 s += p_GetTotalDegree(p->exp[r->VarL_Offset[i]], r,r->ExpPerLong);
1518 }
1519 return (long)s;
1520}
static unsigned long p_GetTotalDegree(const unsigned long l, const ring r, const int number_of_exps)
Definition: p_polys.h:812

◆ p_Var()

int p_Var ( poly  mi,
const ring  r 
)

Definition at line 4772 of file p_polys.cc.

4773{
4774 if (m==NULL) return 0;
4775 if (pNext(m)!=NULL) return 0;
4776 int i,e=0;
4777 for (i=rVar(r); i>0; i--)
4778 {
4779 int exp=p_GetExp(m,i,r);
4780 if (exp==1)
4781 {
4782 if (e==0) e=i;
4783 else return 0;
4784 }
4785 else if (exp!=0)
4786 {
4787 return 0;
4788 }
4789 }
4790 return e;
4791}

◆ p_Vec2Array()

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

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

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

Definition at line 3711 of file p_polys.cc.

3712{
3713 poly h;
3714 int k;
3715
3716 for(int i=len-1;i>=0;i--) p[i]=NULL;
3717 while (v!=NULL)
3718 {
3719 h=p_Head(v,r);
3720 k=__p_GetComp(h,r);
3721 if (k>len) { Werror("wrong rank:%d, should be %d",len,k); }
3722 else
3723 {
3724 p_SetComp(h,0,r);
3725 p_Setm(h,r);
3726 pNext(h)=p[k-1];p[k-1]=h;
3727 }
3728 pIter(v);
3729 }
3730 for(int i=len-1;i>=0;i--)
3731 {
3732 if (p[i]!=NULL) p[i]=pReverse(p[i]);
3733 }
3734}

◆ p_Vec2Poly()

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

Definition at line 3689 of file p_polys.cc.

3690{
3691 poly h;
3692 poly res=NULL;
3693 long unsigned kk=k;
3694
3695 while (v!=NULL)
3696 {
3697 if (__p_GetComp(v,r)==kk)
3698 {
3699 h=p_Head(v,r);
3700 p_SetComp(h,0,r);
3701 pNext(h)=res;res=h;
3702 }
3703 pIter(v);
3704 }
3705 if (res!=NULL) res=pReverse(res);
3706 return res;
3707}

◆ p_Vec2Polys()

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

Definition at line 3741 of file p_polys.cc.

3742{
3743 *len=p_MaxComp(v,r);
3744 if (*len==0) *len=1;
3745 *p=(poly*)omAlloc((*len)*sizeof(poly));
3746 p_Vec2Array(v,*p,*len,r);
3747}
void p_Vec2Array(poly v, poly *p, int len, const ring r)
vector to already allocated array (len>=p_MaxComp(v,r))
Definition: p_polys.cc:3711

◆ p_VectorHasUnit()

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

Definition at line 3467 of file p_polys.cc.

3468{
3469 poly q=p,qq;
3470 int j=0;
3471 long unsigned i;
3472
3473 *len = 0;
3474 while (q!=NULL)
3475 {
3476 if (p_LmIsConstantComp(q,r))
3477 {
3478 i = __p_GetComp(q,r);
3479 qq = p;
3480 while ((qq != q) && (__p_GetComp(qq,r) != i)) pIter(qq);
3481 if (qq == q)
3482 {
3483 j = 0;
3484 while (qq!=NULL)
3485 {
3486 if (__p_GetComp(qq,r)==i) j++;
3487 pIter(qq);
3488 }
3489 if ((*len == 0) || (j<*len))
3490 {
3491 *len = j;
3492 *k = i;
3493 }
3494 }
3495 }
3496 pIter(q);
3497 }
3498}

◆ p_VectorHasUnitB()

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

Definition at line 3444 of file p_polys.cc.

3445{
3446 poly q=p,qq;
3447 long unsigned i;
3448
3449 while (q!=NULL)
3450 {
3451 if (p_LmIsConstantComp(q,r))
3452 {
3453 i = __p_GetComp(q,r);
3454 qq = p;
3455 while ((qq != q) && (__p_GetComp(qq,r) != i)) pIter(qq);
3456 if (qq == q)
3457 {
3458 *k = i;
3459 return TRUE;
3460 }
3461 }
3462 pIter(q);
3463 }
3464 return FALSE;
3465}

◆ p_WDegree()

long p_WDegree ( poly  p,
const ring  r 
)

Definition at line 714 of file p_polys.cc.

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

◆ p_Weight()

int p_Weight ( int  c,
const ring  r 
)

Definition at line 705 of file p_polys.cc.

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

◆ p_WFirstTotalDegree()

long p_WFirstTotalDegree ( poly  p,
ring  r 
)

Definition at line 596 of file p_polys.cc.

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

◆ p_Write() [1/2]

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

Definition at line 342 of file polys0.cc.

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

◆ p_Write() [2/2]

static void p_Write ( poly  p,
ring  p_ring 
)
inlinestatic

Definition at line 1250 of file p_polys.h.

1251{
1252 p_Write(p, p_ring, p_ring);
1253}

◆ p_Write0() [1/2]

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

Definition at line 332 of file polys0.cc.

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

◆ p_Write0() [2/2]

static void p_Write0 ( poly  p,
ring  p_ring 
)
inlinestatic

Definition at line 1254 of file p_polys.h.

1255{
1256 p_Write0(p, p_ring, p_ring);
1257}
void p_Write0(poly p, ring lmRing, ring tailRing)
Definition: polys0.cc:332

◆ p_wrp() [1/2]

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

Definition at line 373 of file polys0.cc.

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

◆ p_wrp() [2/2]

static void p_wrp ( poly  p,
ring  p_ring 
)
inlinestatic

Definition at line 1258 of file p_polys.h.

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

◆ p_WTotaldegree()

long p_WTotaldegree ( poly  p,
const ring  r 
)

Definition at line 613 of file p_polys.cc.

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

◆ pEnlargeSet()

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

Definition at line 3812 of file p_polys.cc.

3813{
3814 poly* h;
3815
3816 if (*p==NULL)
3817 {
3818 if (increment==0) return;
3819 h=(poly*)omAlloc0(increment*sizeof(poly));
3820 }
3821 else
3822 {
3823 h=(poly*)omReallocSize((poly*)*p,l*sizeof(poly),(l+increment)*sizeof(poly));
3824 if (increment>0)
3825 {
3826 memset(&(h[l]),0,increment*sizeof(poly));
3827 }
3828 }
3829 *p=h;
3830}
#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 739 of file p_polys.cc.

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

◆ pLDeg0c()

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

Definition at line 770 of file p_polys.cc.

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

◆ pLDeg1()

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

Definition at line 841 of file p_polys.cc.

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

◆ pLDeg1_Deg()

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

Definition at line 910 of file p_polys.cc.

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

◆ pLDeg1_Totaldegree()

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

Definition at line 975 of file p_polys.cc.

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

◆ pLDeg1_WFirstTotalDegree()

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

Definition at line 1038 of file p_polys.cc.

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

◆ pLDeg1c()

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

Definition at line 877 of file p_polys.cc.

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

◆ pLDeg1c_Deg()

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

Definition at line 941 of file p_polys.cc.

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

◆ pLDeg1c_Totaldegree()

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

Definition at line 1005 of file p_polys.cc.

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

◆ pLDeg1c_WFirstTotalDegree()

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

Definition at line 1068 of file p_polys.cc.

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

◆ pLDegb()

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

Definition at line 811 of file p_polys.cc.

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

◆ pLength()

static unsigned pLength ( poly  a)
inlinestatic

Definition at line 191 of file p_polys.h.

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

◆ pp_DivideM()

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

Definition at line 1629 of file p_polys.cc.

1630{
1631 if (a==NULL) { return NULL; }
1632 // TODO: better implementation without copying a,b
1633 return p_DivideM(p_Copy(a,r),p_Head(b,r),r);
1634}
poly p_DivideM(poly a, poly b, const ring r)
Definition: p_polys.cc:1574

◆ pp_Jet()

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

Definition at line 4474 of file p_polys.cc.

4475{
4476 poly r=NULL;
4477 poly t=NULL;
4478
4479 while (p!=NULL)
4480 {
4481 if (p_Totaldegree(p,R)<=m)
4482 {
4483 if (r==NULL)
4484 r=p_Head(p,R);
4485 else
4486 if (t==NULL)
4487 {
4488 pNext(r)=p_Head(p,R);
4489 t=pNext(r);
4490 }
4491 else
4492 {
4493 pNext(t)=p_Head(p,R);
4494 pIter(t);
4495 }
4496 }
4497 pIter(p);
4498 }
4499 return r;
4500}

◆ pp_JetW()

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

Definition at line 4519 of file p_polys.cc.

4520{
4521 poly r=NULL;
4522 poly t=NULL;
4523 while (p!=NULL)
4524 {
4525 if (totaldegreeWecart_IV(p,R,w)<=m)
4526 {
4527 if (r==NULL)
4528 r=p_Head(p,R);
4529 else
4530 if (t==NULL)
4531 {
4532 pNext(r)=p_Head(p,R);
4533 t=pNext(r);
4534 }
4535 else
4536 {
4537 pNext(t)=p_Head(p,R);
4538 pIter(t);
4539 }
4540 }
4541 pIter(p);
4542 }
4543 return r;
4544}

◆ pp_mm_Mult()

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

Definition at line 1043 of file p_polys.h.

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

◆ pp_Mult_Coeff_mm_DivSelect() [1/2]

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

Definition at line 1092 of file p_polys.h.

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

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

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

◆ pp_Mult_mm()

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

Definition at line 1033 of file p_polys.h.

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

◆ pp_Mult_nn()

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

Definition at line 994 of file p_polys.h.

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

◆ pp_Mult_qq()

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

Definition at line 1153 of file p_polys.h.

1154{
1155 if (p == NULL || q == NULL) return NULL;
1156
1157 if (pNext(p) == NULL)
1158 {
1159 return r->p_Procs->pp_mm_Mult(q, p, r);
1160 }
1161
1162 if (pNext(q) == NULL)
1163 {
1164 return r->p_Procs->pp_Mult_mm(p, q, r);
1165 }
1166
1167 poly qq = q;
1168 if (p == q)
1169 qq = p_Copy(q, r);
1170
1171 poly res;
1172#if defined(HAVE_PLURAL) || defined(HAVE_SHIFTBBA)
1173 if (rIsNCRing(r))
1174 res = _nc_pp_Mult_qq(p, qq, r);
1175 else
1176#endif
1177 res = _p_Mult_q(p, qq, 1, r);
1178
1179 if (qq != q)
1180 p_Delete(&qq, r);
1181 return res;
1182}
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 3765 of file p_polys.cc.

3766{
3767 assume(old_FDeg != NULL && old_lDeg != NULL);
3768 r->pFDeg = old_FDeg;
3769 r->pLDeg = old_lDeg;
3770}

◆ pReverse()

static poly pReverse ( poly  p)
inlinestatic

Definition at line 337 of file p_polys.h.

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

◆ pSetDegProcs()

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

Definition at line 3753 of file p_polys.cc.

3754{
3755 assume(new_FDeg != NULL);
3756 r->pFDeg = new_FDeg;
3757
3758 if (new_lDeg == NULL)
3759 new_lDeg = r->pLDegOrig;
3760
3761 r->pLDeg = new_lDeg;
3762}