Macros | Functions | Variables
pDebug.cc File Reference
#include <stdarg.h>
#include <stdio.h>
#include "misc/auxiliary.h"
#include "polys/monomials/ring.h"
#include "polys/monomials/p_polys.h"
#include "coeffs/coeffs.h"

Go to the source code of this file.

Macros

#define PDEBUG_CC
 

Functions

BOOLEAN dPolyReportError (poly p, ring r, const char *fmt,...)
 
BOOLEAN p_LmCheckIsFromRing (poly p, ring r)
 
BOOLEAN p_CheckIsFromRing (poly p, ring r)
 
BOOLEAN p_CheckPolyRing (poly p, ring r)
 
BOOLEAN p_LmCheckPolyRing (poly p, ring r)
 
BOOLEAN p_CheckRing (ring r)
 
BOOLEAN p_DebugLmDivisibleByNoComp (poly a, poly b, ring r)
 
BOOLEAN pIsMonomOf (poly p, poly m)
 
BOOLEAN pHaveCommonMonoms (poly p, poly q)
 
void p_Setm_General (poly p, ring r)
 
static poly p_DebugInit (poly p, ring src_ring, ring dest_ring)
 
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)
 
BOOLEAN pDebugLmShortDivisibleBy (poly p1, unsigned long sev_1, ring r_1, poly p2, unsigned long not_sev_2, ring r_2)
 
BOOLEAN pDebugLmShortDivisibleByNoComp (poly p1, unsigned long sev_1, ring r_1, poly p2, unsigned long not_sev_2, ring r_2)
 
void pPrintDivisbleByStat ()
 

Variables

STATIC_VAR BOOLEAN d_poly_error_reporting = FALSE
 
STATIC_VAR unsigned long pDivisibleBy_number = 1
 
STATIC_VAR unsigned long pDivisibleBy_FALSE = 1
 
STATIC_VAR unsigned long pDivisibleBy_ShortFalse = 1
 

Macro Definition Documentation

◆ PDEBUG_CC

#define PDEBUG_CC

Definition at line 12 of file pDebug.cc.

Function Documentation

◆ _p_LmTest()

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

Definition at line 321 of file pDebug.cc.

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

◆ _p_Test()

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

Definition at line 210 of file pDebug.cc.

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

◆ _pp_Test()

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

Definition at line 331 of file pDebug.cc.

332 {
333  if (PDEBUG > level) level = PDEBUG;
334  if (level < 0 || p == NULL) return TRUE;
335  if (pNext(p) == NULL || lmRing == tailRing) return _p_Test(p, lmRing, level);
336 
337  pFalseReturn(_p_LmTest(p, lmRing, level));
338  pFalseReturn(_p_Test(pNext(p), tailRing, level));
339 
340  // check that lm > Lm(tail)
341  if (level > 1)
342  {
343  poly lm = p;
344  poly tail = p_DebugInit(pNext(p), tailRing, lmRing);
345  poly pnext = pNext(lm);
346  pNext(lm) = tail;
347  BOOLEAN cmp = p_LmCmp(lm, tail, lmRing);
348  if (cmp != 1)
349  dPolyReportError(lm, lmRing, "wrong order: lm <= Lm(tail)");
350  p_LmFree(tail, lmRing);
351  pNext(lm) = pnext;
352  return (cmp == 1);
353  }
354  return TRUE;
355 }
int level(const CanonicalForm &f)
static poly p_DebugInit(poly p, ring src_ring, ring dest_ring)
Definition: pDebug.cc:193
#define TRUE
Definition: auxiliary.h:100
BOOLEAN dPolyReportError(poly p, ring r, const char *fmt,...)
Definition: pDebug.cc:42
static void p_LmFree(poly p, ring)
Definition: p_polys.h:682
BOOLEAN _p_LmTest(poly p, ring r, int level)
Definition: pDebug.cc:321
#define pFalseReturn(cond)
Definition: monomials.h:139
#define PDEBUG
Definition: auxiliary.h:186
static int p_LmCmp(poly p, poly q, const ring r)
Definition: p_polys.h:1500
#define NULL
Definition: omList.c:12
#define pNext(p)
Definition: monomials.h:36
BOOLEAN _p_Test(poly p, ring r, int level)
Definition: pDebug.cc:210
int p
Definition: cfModGcd.cc:4019
int BOOLEAN
Definition: auxiliary.h:87

◆ dPolyReportError()

BOOLEAN dPolyReportError ( poly  p,
ring  r,
const char *  fmt,
  ... 
)

Definition at line 42 of file pDebug.cc.

43 {
44  if (d_poly_error_reporting) return FALSE;
46  va_list ap;
47  va_start(ap, fmt);
48 
49  fprintf(stderr, "\n// ***dPolyReportError: ");
50  vfprintf(stderr, fmt, ap);
51  fprintf(stderr, "\n occurred at\n");
52  omPrintCurrentBackTraceMax(stderr, 8);
53  if (p != NULL)
54  {
55  fprintf(stderr, " occurred for poly: ");
56  p_wrp(p, r);
57  omPrintAddrInfo(stderr, p, " ");
58  }
59  dErrorBreak();
61  return FALSE;
62 }
#define FALSE
Definition: auxiliary.h:96
Definition: ap.h:39
#define TRUE
Definition: auxiliary.h:100
STATIC_VAR BOOLEAN d_poly_error_reporting
Definition: pDebug.cc:41
#define omPrintAddrInfo(A, B, C)
Definition: xalloc.h:314
#define NULL
Definition: omList.c:12
#define omPrintCurrentBackTraceMax(A, B)
Definition: xalloc.h:309
void p_wrp(poly p, ring lmRing, ring tailRing)
Definition: polys0.cc:373
int p
Definition: cfModGcd.cc:4019
void dErrorBreak()
Definition: dError.cc:139

◆ p_CheckIsFromRing()

BOOLEAN p_CheckIsFromRing ( poly  p,
ring  r 
)

Definition at line 100 of file pDebug.cc.

101 {
102  while (p!=NULL)
103  {
105  pIter(p);
106  }
107  return TRUE;
108 }
#define TRUE
Definition: auxiliary.h:100
#define pIter(p)
Definition: monomials.h:37
#define pFalseReturn(cond)
Definition: monomials.h:139
BOOLEAN p_LmCheckIsFromRing(poly p, ring r)
Definition: pDebug.cc:69
#define NULL
Definition: omList.c:12
int p
Definition: cfModGcd.cc:4019

◆ p_CheckPolyRing()

BOOLEAN p_CheckPolyRing ( poly  p,
ring  r 
)

Definition at line 110 of file pDebug.cc.

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

◆ p_CheckRing()

BOOLEAN p_CheckRing ( ring  r)

Definition at line 126 of file pDebug.cc.

127 {
128  #ifndef X_OMALLOC
129  pAssumeReturn(r != NULL && r->PolyBin != NULL);
130  #endif
131  return TRUE;
132 }
#define TRUE
Definition: auxiliary.h:100
#define pAssumeReturn(cond)
Definition: monomials.h:78
#define NULL
Definition: omList.c:12

◆ p_DebugInit()

static poly p_DebugInit ( poly  p,
ring  src_ring,
ring  dest_ring 
)
static

Definition at line 193 of file pDebug.cc.

194 {
195  poly d_p = p_Init(dest_ring);
196  int i;
197  assume(dest_ring->N == src_ring->N);
198 
199  for (i=1; i<= src_ring->N; i++)
200  {
201  p_SetExp(d_p, i, p_GetExp(p, i, src_ring), dest_ring);
202  }
203  if (rRing_has_Comp(dest_ring))
204  p_SetComp(d_p, p_GetComp(p, src_ring), dest_ring);
205 
206  p_Setm_General(d_p, dest_ring);
207  return d_p;
208 }
void p_Setm_General(poly p, ring r)
Definition: p_polys.cc:152
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition: p_polys.h:246
#define p_GetComp(p, r)
Definition: monomials.h:64
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent : the integer VarOffset encodes:
Definition: p_polys.h:468
#define assume(x)
Definition: mod2.h:390
int i
Definition: cfEzgcd.cc:125
#define rRing_has_Comp(r)
Definition: monomials.h:266
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent : VarOffset encodes the position in p->exp
Definition: p_polys.h:487
int p
Definition: cfModGcd.cc:4019
static poly p_Init(const ring r, omBin bin)
Definition: p_polys.h:1259

◆ p_DebugLmDivisibleByNoComp()

BOOLEAN p_DebugLmDivisibleByNoComp ( poly  a,
poly  b,
ring  r 
)

Definition at line 139 of file pDebug.cc.

140 {
141  int i=r->N;
142 
143  do
144  {
145  if (p_GetExp(a,i,r) > p_GetExp(b,i,r))
146  return FALSE;
147  i--;
148  }
149  while (i);
150 #ifdef HAVE_RINGS
151  return n_DivBy(pGetCoeff(b), pGetCoeff(a), r->cf);
152 #else
153  return TRUE;
154 #endif
155  }
#define FALSE
Definition: auxiliary.h:96
#define TRUE
Definition: auxiliary.h:100
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
CanonicalForm b
Definition: cfModGcd.cc:4044
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent : the integer VarOffset encodes:
Definition: p_polys.h:468
static FORCE_INLINE BOOLEAN n_DivBy(number a, number b, const coeffs r)
test whether &#39;a&#39; is divisible &#39;b&#39;; for r encoding a field: TRUE iff &#39;b&#39; does not represent zero in Z:...
Definition: coeffs.h:775
int i
Definition: cfEzgcd.cc:125

◆ p_LmCheckIsFromRing()

BOOLEAN p_LmCheckIsFromRing ( poly  p,
ring  r 
)

Definition at line 69 of file pDebug.cc.

70 {
71  if (p != NULL)
72  {
73  #if (OM_TRACK > 0) && defined(OM_TRACK_CUSTOM)
74  void* custom = omGetCustomOfAddr(p);
75  if (custom != NULL)
76  {
77  pPolyAssumeReturnMsg(custom == r ||
78  // be more sloppy for qrings
79  (r->qideal != NULL &&
80  omIsBinPageAddr(p) &&
81  omSizeWOfAddr(p)==omSizeWOfBin(r->PolyBin)) ||
82  rSamePolyRep((ring) custom, r),
83  "monomial not from specified ring",p,r);
84  return TRUE;
85  }
86  else
87  #endif
88  #ifndef X_OMALLOC
89  {
92  return TRUE;
93  }
94  return FALSE;
95  #endif
96  }
97  return TRUE;
98 }
#define FALSE
Definition: auxiliary.h:96
#define TRUE
Definition: auxiliary.h:100
#define _pPolyAssumeReturn(cond, p, r)
Definition: monomials.h:101
BOOLEAN rSamePolyRep(ring r1, ring r2)
returns TRUE, if r1 and r2 represents the monomials in the same way FALSE, otherwise this is an analo...
Definition: ring.cc:1712
#define NULL
Definition: omList.c:12
#define omSizeWOfAddr(P)
Definition: xalloc.h:258
#define omIsBinPageAddr(addr)
Definition: omBinPage.h:68
#define omSizeWOfBin(bin_ptr)
#define pPolyAssumeReturnMsg(cond, msg)
Definition: monomials.h:137
int p
Definition: cfModGcd.cc:4019

◆ p_LmCheckPolyRing()

BOOLEAN p_LmCheckPolyRing ( poly  p,
ring  r 
)

Definition at line 118 of file pDebug.cc.

119 {
120  #ifndef X_OMALLOC
121  pAssumeReturn(r != NULL && r->PolyBin != NULL);
122  #endif
123  pAssumeReturn(p != NULL);
124  return p_LmCheckIsFromRing(p, r);
125 }
#define pAssumeReturn(cond)
Definition: monomials.h:78
BOOLEAN p_LmCheckIsFromRing(poly p, ring r)
Definition: pDebug.cc:69
#define NULL
Definition: omList.c:12
int p
Definition: cfModGcd.cc:4019

◆ p_Setm_General()

void p_Setm_General ( poly  p,
ring  r 
)

!!!????? where?????

Definition at line 152 of file p_polys.cc.

153 {
154  p_LmCheckPolyRing(p, r);
155  int pos=0;
156  if (r->typ!=NULL)
157  {
158  loop
159  {
160  unsigned long ord=0;
161  sro_ord* o=&(r->typ[pos]);
162  switch(o->ord_typ)
163  {
164  case ro_dp:
165  {
166  int a,e;
167  a=o->data.dp.start;
168  e=o->data.dp.end;
169  for(int i=a;i<=e;i++) ord+=p_GetExp(p,i,r);
170  p->exp[o->data.dp.place]=ord;
171  break;
172  }
173  case ro_wp_neg:
175  // no break;
176  case ro_wp:
177  {
178  int a,e;
179  a=o->data.wp.start;
180  e=o->data.wp.end;
181  int *w=o->data.wp.weights;
182 #if 1
183  for(int i=a;i<=e;i++) ord+=((unsigned long)p_GetExp(p,i,r))*((unsigned long)w[i-a]);
184 #else
185  long ai;
186  int ei,wi;
187  for(int i=a;i<=e;i++)
188  {
189  ei=p_GetExp(p,i,r);
190  wi=w[i-a];
191  ai=ei*wi;
192  if (ai/ei!=wi) pSetm_error=TRUE;
193  ord+=ai;
194  if (ord<ai) pSetm_error=TRUE;
195  }
196 #endif
197  p->exp[o->data.wp.place]=ord;
198  break;
199  }
200  case ro_am:
201  {
202  ord = POLY_NEGWEIGHT_OFFSET;
203  const short a=o->data.am.start;
204  const short e=o->data.am.end;
205  const int * w=o->data.am.weights;
206 #if 1
207  for(short i=a; i<=e; i++, w++)
208  ord += ((*w) * p_GetExp(p,i,r));
209 #else
210  long ai;
211  int ei,wi;
212  for(short i=a;i<=e;i++)
213  {
214  ei=p_GetExp(p,i,r);
215  wi=w[i-a];
216  ai=ei*wi;
217  if (ai/ei!=wi) pSetm_error=TRUE;
218  ord += ai;
219  if (ord<ai) pSetm_error=TRUE;
220  }
221 #endif
222  const int c = p_GetComp(p,r);
223 
224  const short len_gen= o->data.am.len_gen;
225 
226  if ((c > 0) && (c <= len_gen))
227  {
228  assume( w == o->data.am.weights_m );
229  assume( w[0] == len_gen );
230  ord += w[c];
231  }
232 
233  p->exp[o->data.am.place] = ord;
234  break;
235  }
236  case ro_wp64:
237  {
238  int64 ord=0;
239  int a,e;
240  a=o->data.wp64.start;
241  e=o->data.wp64.end;
242  int64 *w=o->data.wp64.weights64;
243  int64 ei,wi,ai;
244  for(int i=a;i<=e;i++)
245  {
246  //Print("exp %d w %d \n",p_GetExp(p,i,r),(int)w[i-a]);
247  //ord+=((int64)p_GetExp(p,i,r))*w[i-a];
248  ei=(int64)p_GetExp(p,i,r);
249  wi=w[i-a];
250  ai=ei*wi;
251  if(ei!=0 && ai/ei!=wi)
252  {
254  #if SIZEOF_LONG == 4
255  Print("ai %lld, wi %lld\n",ai,wi);
256  #else
257  Print("ai %ld, wi %ld\n",ai,wi);
258  #endif
259  }
260  ord+=ai;
261  if (ord<ai)
262  {
264  #if SIZEOF_LONG == 4
265  Print("ai %lld, ord %lld\n",ai,ord);
266  #else
267  Print("ai %ld, ord %ld\n",ai,ord);
268  #endif
269  }
270  }
271  int64 mask=(int64)0x7fffffff;
272  long a_0=(long)(ord&mask); //2^31
273  long a_1=(long)(ord >>31 ); /*(ord/(mask+1));*/
274 
275  //Print("mask: %x, ord: %d, a_0: %d, a_1: %d\n"
276  //,(int)mask,(int)ord,(int)a_0,(int)a_1);
277  //Print("mask: %d",mask);
278 
279  p->exp[o->data.wp64.place]=a_1;
280  p->exp[o->data.wp64.place+1]=a_0;
281 // if(p_Setm_error) PrintS("***************************\n"
282 // "***************************\n"
283 // "**WARNING: overflow error**\n"
284 // "***************************\n"
285 // "***************************\n");
286  break;
287  }
288  case ro_cp:
289  {
290  int a,e;
291  a=o->data.cp.start;
292  e=o->data.cp.end;
293  int pl=o->data.cp.place;
294  for(int i=a;i<=e;i++) { p->exp[pl]=p_GetExp(p,i,r); pl++; }
295  break;
296  }
297  case ro_syzcomp:
298  {
299  long c=__p_GetComp(p,r);
300  long sc = c;
301  int* Components = (_componentsExternal ? _components :
302  o->data.syzcomp.Components);
303  long* ShiftedComponents = (_componentsExternal ? _componentsShifted:
304  o->data.syzcomp.ShiftedComponents);
305  if (ShiftedComponents != NULL)
306  {
307  assume(Components != NULL);
308  assume(c == 0 || Components[c] != 0);
309  sc = ShiftedComponents[Components[c]];
310  assume(c == 0 || sc != 0);
311  }
312  p->exp[o->data.syzcomp.place]=sc;
313  break;
314  }
315  case ro_syz:
316  {
317  const unsigned long c = __p_GetComp(p, r);
318  const short place = o->data.syz.place;
319  const int limit = o->data.syz.limit;
320 
321  if (c > (unsigned long)limit)
322  p->exp[place] = o->data.syz.curr_index;
323  else if (c > 0)
324  {
325  assume( (1 <= c) && (c <= (unsigned long)limit) );
326  p->exp[place]= o->data.syz.syz_index[c];
327  }
328  else
329  {
330  assume(c == 0);
331  p->exp[place]= 0;
332  }
333  break;
334  }
335  // Prefix for Induced Schreyer ordering
336  case ro_isTemp: // Do nothing?? (to be removed into suffix later on...?)
337  {
338  assume(p != NULL);
339 
340 #ifndef SING_NDEBUG
341 #if MYTEST
342  Print("p_Setm_General: ro_isTemp ord: pos: %d, p: ", pos); p_wrp(p, r);
343 #endif
344 #endif
345  int c = p_GetComp(p, r);
346 
347  assume( c >= 0 );
348 
349  // Let's simulate case ro_syz above....
350  // Should accumulate (by Suffix) and be a level indicator
351  const int* const pVarOffset = o->data.isTemp.pVarOffset;
352 
353  assume( pVarOffset != NULL );
354 
355  // TODO: Can this be done in the suffix???
356  for( int i = 1; i <= r->N; i++ ) // No v[0] here!!!
357  {
358  const int vo = pVarOffset[i];
359  if( vo != -1) // TODO: optimize: can be done once!
360  {
361  // Hans! Please don't break it again! p_SetExp(p, ..., r, vo) is correct:
362  p_SetExp(p, p_GetExp(p, i, r), r, vo); // copy put them verbatim
363  // Hans! Please don't break it again! p_GetExp(p, r, vo) is correct:
364  assume( p_GetExp(p, r, vo) == p_GetExp(p, i, r) ); // copy put them verbatim
365  }
366  }
367 #ifndef SING_NDEBUG
368  for( int i = 1; i <= r->N; i++ ) // No v[0] here!!!
369  {
370  const int vo = pVarOffset[i];
371  if( vo != -1) // TODO: optimize: can be done once!
372  {
373  // Hans! Please don't break it again! p_GetExp(p, r, vo) is correct:
374  assume( p_GetExp(p, r, vo) == p_GetExp(p, i, r) ); // copy put them verbatim
375  }
376  }
377 #if MYTEST
378 // if( p->exp[o->data.isTemp.start] > 0 )
379  PrintS("after Values: "); p_wrp(p, r);
380 #endif
381 #endif
382  break;
383  }
384 
385  // Suffix for Induced Schreyer ordering
386  case ro_is:
387  {
388 #ifndef SING_NDEBUG
389 #if MYTEST
390  Print("p_Setm_General: ro_is ord: pos: %d, p: ", pos); p_wrp(p, r);
391 #endif
392 #endif
393 
394  assume(p != NULL);
395 
396  int c = p_GetComp(p, r);
397 
398  assume( c >= 0 );
399  const ideal F = o->data.is.F;
400  const int limit = o->data.is.limit;
401  assume( limit >= 0 );
402  const int start = o->data.is.start;
403 
404  if( F != NULL && c > limit )
405  {
406 #ifndef SING_NDEBUG
407 #if MYTEST
408  Print("p_Setm_General: ro_is : in rSetm: pos: %d, c: %d > limit: %d\n", c, pos, limit);
409  PrintS("preComputed Values: ");
410  p_wrp(p, r);
411 #endif
412 #endif
413 // if( c > limit ) // BUG???
414  p->exp[start] = 1;
415 // else
416 // p->exp[start] = 0;
417 
418 
419  c -= limit;
420  assume( c > 0 );
421  c--;
422 
423  if( c >= IDELEMS(F) )
424  break;
425 
426  assume( c < IDELEMS(F) ); // What about others???
427 
428  const poly pp = F->m[c]; // get reference monomial!!!
429 
430  if(pp == NULL)
431  break;
432 
433  assume(pp != NULL);
434 
435 #ifndef SING_NDEBUG
436 #if MYTEST
437  Print("Respective F[c - %d: %d] pp: ", limit, c);
438  p_wrp(pp, r);
439 #endif
440 #endif
441 
442  const int end = o->data.is.end;
443  assume(start <= end);
444 
445 
446 // const int st = o->data.isTemp.start;
447 
448 #ifndef SING_NDEBUG
449 #if MYTEST
450  Print("p_Setm_General: is(-Temp-) :: c: %d, limit: %d, [st:%d] ===>>> %ld\n", c, limit, start, p->exp[start]);
451 #endif
452 #endif
453 
454  // p_ExpVectorAdd(p, pp, r);
455 
456  for( int i = start; i <= end; i++) // v[0] may be here...
457  p->exp[i] += pp->exp[i]; // !!!!!!!! ADD corresponding LT(F)
458 
459  // p_MemAddAdjust(p, ri);
460  if (r->NegWeightL_Offset != NULL)
461  {
462  for (int i=r->NegWeightL_Size-1; i>=0; i--)
463  {
464  const int _i = r->NegWeightL_Offset[i];
465  if( start <= _i && _i <= end )
466  p->exp[_i] -= POLY_NEGWEIGHT_OFFSET;
467  }
468  }
469 
470 
471 #ifndef SING_NDEBUG
472  const int* const pVarOffset = o->data.is.pVarOffset;
473 
474  assume( pVarOffset != NULL );
475 
476  for( int i = 1; i <= r->N; i++ ) // No v[0] here!!!
477  {
478  const int vo = pVarOffset[i];
479  if( vo != -1) // TODO: optimize: can be done once!
480  // Hans! Please don't break it again! p_GetExp(p/pp, r, vo) is correct:
481  assume( p_GetExp(p, r, vo) == (p_GetExp(p, i, r) + p_GetExp(pp, r, vo)) );
482  }
483  // TODO: how to check this for computed values???
484 #if MYTEST
485  PrintS("Computed Values: "); p_wrp(p, r);
486 #endif
487 #endif
488  } else
489  {
490  p->exp[start] = 0; //!!!!????? where?????
491 
492  const int* const pVarOffset = o->data.is.pVarOffset;
493 
494  // What about v[0] - component: it will be added later by
495  // suffix!!!
496  // TODO: Test it!
497  const int vo = pVarOffset[0];
498  if( vo != -1 )
499  p->exp[vo] = c; // initial component v[0]!
500 
501 #ifndef SING_NDEBUG
502 #if MYTEST
503  Print("ELSE p_Setm_General: ro_is :: c: %d <= limit: %d, vo: %d, exp: %d\n", c, limit, vo, p->exp[vo]);
504  p_wrp(p, r);
505 #endif
506 #endif
507  }
508 
509  break;
510  }
511  default:
512  dReportError("wrong ord in rSetm:%d\n",o->ord_typ);
513  return;
514  }
515  pos++;
516  if (pos == r->OrdSize) return;
517  }
518  }
519 }
#define __p_GetComp(p, r)
Definition: monomials.h:63
Definition: ring.h:60
#define POLY_NEGWEIGHT_OFFSET
Definition: monomials.h:236
#define Print
Definition: emacs.cc:80
Definition: ring.h:53
#define p_GetComp(p, r)
Definition: monomials.h:64
long int64
Definition: auxiliary.h:68
#define TRUE
Definition: auxiliary.h:100
VAR BOOLEAN pSetm_error
Definition: p_polys.cc:144
#define loop
Definition: structs.h:80
Definition: ring.h:58
Definition: ring.h:56
union sro_ord::@0 data
ro_typ ord_typ
Definition: ring.h:220
if(yy_init)
Definition: libparse.cc:1420
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent : the integer VarOffset encodes:
Definition: p_polys.h:468
#define assume(x)
Definition: mod2.h:390
CanonicalForm pp(const CanonicalForm &)
CanonicalForm pp ( const CanonicalForm & f )
Definition: cf_gcd.cc:248
Definition: ring.h:218
STATIC_VAR int _componentsExternal
Definition: p_polys.cc:142
int i
Definition: cfEzgcd.cc:125
void PrintS(const char *s)
Definition: reporter.cc:284
#define IDELEMS(i)
Definition: simpleideals.h:23
Definition: ring.h:61
Definition: ring.h:61
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent : VarOffset encodes the position in p->exp
Definition: p_polys.h:487
#define NULL
Definition: omList.c:12
STATIC_VAR long * _componentsShifted
Definition: p_polys.cc:141
BOOLEAN p_LmCheckPolyRing(poly p, ring r)
Definition: pDebug.cc:118
STATIC_VAR int * _components
Definition: p_polys.cc:140
const CanonicalForm & w
Definition: facAbsFact.cc:55
Definition: ring.h:55
Definition: ring.h:52
Definition: ring.h:54
int dReportError(const char *fmt,...)
Definition: dError.cc:43
void p_wrp(poly p, ring lmRing, ring tailRing)
Definition: polys0.cc:373
int p
Definition: cfModGcd.cc:4019

◆ pDebugLmShortDivisibleBy()

BOOLEAN pDebugLmShortDivisibleBy ( poly  p1,
unsigned long  sev_1,
ring  r_1,
poly  p2,
unsigned long  not_sev_2,
ring  r_2 
)

Definition at line 364 of file pDebug.cc.

366 {
367  _pPolyAssume(p_GetShortExpVector(p1, r_1) == sev_1, p1, r_1);
368  _pPolyAssume(p_GetShortExpVector(p2, r_2) == ~ not_sev_2, p2, r_2);
369 
371  BOOLEAN ret;
372  if (r_1 == r_2)
373  ret = p_LmDivisibleBy(p1, p2, r_1);
374  else
375  ret = p_LmDivisibleBy(p1, r_1, p2, r_2);
376 
377  if (! ret) pDivisibleBy_FALSE++;
378  if (sev_1 & not_sev_2)
379  {
381  if (ret)
382  dReportError("p1 divides p2, but sev's are wrong");
383  }
384  return ret;
385 }
STATIC_VAR unsigned long pDivisibleBy_ShortFalse
Definition: pDebug.cc:362
STATIC_VAR unsigned long pDivisibleBy_FALSE
Definition: pDebug.cc:361
STATIC_VAR unsigned long pDivisibleBy_number
Definition: pDebug.cc:360
static BOOLEAN p_LmDivisibleBy(poly a, poly b, const ring r)
Definition: p_polys.h:1823
#define _pPolyAssume(cond, p, r)
Definition: monomials.h:113
unsigned long p_GetShortExpVector(const poly p, const ring r)
Definition: p_polys.cc:4687
int dReportError(const char *fmt,...)
Definition: dError.cc:43
int BOOLEAN
Definition: auxiliary.h:87

◆ pDebugLmShortDivisibleByNoComp()

BOOLEAN pDebugLmShortDivisibleByNoComp ( poly  p1,
unsigned long  sev_1,
ring  r_1,
poly  p2,
unsigned long  not_sev_2,
ring  r_2 
)

Definition at line 387 of file pDebug.cc.

389 {
390 // _pPolyAssume((p_GetComp(p1, r_1) == p_GetComp(p2, r_2)) || (p_GetComp(p1, r_1) == 0));
391  _pPolyAssume(p_GetShortExpVector(p1, r_1) == sev_1, p1, r_1);
392  _pPolyAssume(p_GetShortExpVector(p2, r_2) == ~ not_sev_2, p2, r_2);
393 
395  BOOLEAN ret;
396  if (r_1 == r_2)
397  ret = p_LmDivisibleByNoComp(p1, p2, r_1);
398  else
399  ret = p_LmDivisibleByNoComp(p1, r_1, p2, r_2);
400 
401  if (! ret) pDivisibleBy_FALSE++;
402  if (sev_1 & not_sev_2)
403  {
405  if (ret)
406  dReportError("p1 divides p2, but sev's are wrong");
407  }
408  return ret;
409 }
static BOOLEAN p_LmDivisibleByNoComp(poly a, poly b, const ring r)
Definition: p_polys.h:1809
STATIC_VAR unsigned long pDivisibleBy_ShortFalse
Definition: pDebug.cc:362
STATIC_VAR unsigned long pDivisibleBy_FALSE
Definition: pDebug.cc:361
STATIC_VAR unsigned long pDivisibleBy_number
Definition: pDebug.cc:360
#define _pPolyAssume(cond, p, r)
Definition: monomials.h:113
unsigned long p_GetShortExpVector(const poly p, const ring r)
Definition: p_polys.cc:4687
int dReportError(const char *fmt,...)
Definition: dError.cc:43
int BOOLEAN
Definition: auxiliary.h:87

◆ pHaveCommonMonoms()

BOOLEAN pHaveCommonMonoms ( poly  p,
poly  q 
)

Definition at line 173 of file pDebug.cc.

174 {
175  while (p != NULL)
176  {
177  if (pIsMonomOf(q, p))
178  {
179  return TRUE;
180  }
181  pIter(p);
182  }
183  return FALSE;
184 }
#define FALSE
Definition: auxiliary.h:96
#define TRUE
Definition: auxiliary.h:100
#define pIter(p)
Definition: monomials.h:37
BOOLEAN pIsMonomOf(poly p, poly m)
Definition: pDebug.cc:163
#define NULL
Definition: omList.c:12
int p
Definition: cfModGcd.cc:4019

◆ pIsMonomOf()

BOOLEAN pIsMonomOf ( poly  p,
poly  m 
)

Definition at line 163 of file pDebug.cc.

164 {
165  if (m == NULL) return TRUE;
166  while (p != NULL)
167  {
168  if (p == m) return TRUE;
169  pIter(p);
170  }
171  return FALSE;
172 }
#define FALSE
Definition: auxiliary.h:96
#define TRUE
Definition: auxiliary.h:100
#define pIter(p)
Definition: monomials.h:37
int m
Definition: cfEzgcd.cc:121
#define NULL
Definition: omList.c:12
int p
Definition: cfModGcd.cc:4019

◆ pPrintDivisbleByStat()

void pPrintDivisbleByStat ( )

Definition at line 411 of file pDebug.cc.

412 {
413  Print("#Tests: %ld; #FALSE %ld(%ld); #SHORT %ld(%ld)\n",
415  pDivisibleBy_FALSE, (unsigned long) ((double)pDivisibleBy_FALSE*((double) 100)/(double)pDivisibleBy_number),
416  pDivisibleBy_ShortFalse, (unsigned long) ((double)pDivisibleBy_ShortFalse*((double)100)/(double)pDivisibleBy_FALSE));
417 }
#define Print
Definition: emacs.cc:80
STATIC_VAR unsigned long pDivisibleBy_ShortFalse
Definition: pDebug.cc:362
STATIC_VAR unsigned long pDivisibleBy_FALSE
Definition: pDebug.cc:361
STATIC_VAR unsigned long pDivisibleBy_number
Definition: pDebug.cc:360

Variable Documentation

◆ d_poly_error_reporting

STATIC_VAR BOOLEAN d_poly_error_reporting = FALSE

Definition at line 41 of file pDebug.cc.

◆ pDivisibleBy_FALSE

STATIC_VAR unsigned long pDivisibleBy_FALSE = 1

Definition at line 361 of file pDebug.cc.

◆ pDivisibleBy_number

STATIC_VAR unsigned long pDivisibleBy_number = 1

Definition at line 360 of file pDebug.cc.

◆ pDivisibleBy_ShortFalse

STATIC_VAR unsigned long pDivisibleBy_ShortFalse = 1

Definition at line 362 of file pDebug.cc.