tropicalDebug.cc
Go to the documentation of this file.
1 #ifndef NDEBUG
2 
5 
6 #include <gfanlib/gfanlib.h>
7 
8 #include <std_wrapper.h>
10 #include <tropical.h>
11 
12 
13 bool checkForNonPositiveEntries(const gfan::ZVector &w)
14 {
15  for (unsigned i=0; i<w.size(); i++)
16  {
17  if (w[i].sign()<=0)
18  {
19  std::cout << "ERROR: non-positive weight in weight vector" << std::endl
20  << "weight: " << w << std::endl;
21  return false;
22  }
23  }
24  return true;
25 }
26 
27 bool checkForNonPositiveLaterEntries(const gfan::ZVector &w)
28 {
29  for (unsigned i=1; i<w.size(); i++)
30  {
31  if (w[i].sign()<=0)
32  {
33  std::cout << "ERROR: non-positive weight in weight vector later entries" << std::endl
34  << "weight: " << w << std::endl;
35  return false;
36  }
37  }
38  return true;
39 }
40 
41 bool areIdealsEqual(ideal I, ring r, ideal J, ring s)
42 {
43  ideal Is = idInit(IDELEMS(I));
44  nMapFunc identity = n_SetMap(r->cf,s->cf);
45  for (int i=0; i<IDELEMS(I); i++)
46  Is->m[i] = p_PermPoly(I->m[i],NULL,r,s,identity,NULL,0);
47 
48  ring origin = currRing;
49  if (origin!=s)
51  ideal stdI = gfanlib_kStd_wrapper(Is,s);
52  ideal stdJ = gfanlib_kStd_wrapper(J,s);
53  ideal NF1 = kNF(stdI,s->qideal,stdJ);
54  ideal NF2 = kNF(stdJ,s->qideal,stdI);
55  if (origin!=s)
56  rChangeCurrRing(origin);
57 
58  bool b = true;
59  if (NF1 != NULL)
60  b = b && idIs0(NF1);
61  if (NF2 != NULL)
62  b = b && idIs0(NF2);
63  if (!b)
64  std::cout << "ERROR: input ideals not equal!" << std::endl;
65 
66  id_Delete(&stdI,s);
67  id_Delete(&stdJ,s);
68  id_Delete(&NF1,s);
69  id_Delete(&NF2,s);
70  return (b);
71 }
72 
73 
74 bool checkWeightVector(const ideal I, const ring r, const gfan::ZVector &weightVector, bool checkBorder)
75 {
76  gfan::ZCone cI = maximalGroebnerCone(I,r);
77  if (!cI.contains(weightVector))
78  {
79  std::cout << "ERROR: weight vector not inside maximal Gröbner cone" << std::endl;
80  return false;
81  }
82  if (checkBorder && cI.containsRelatively(weightVector))
83  {
84  std::cout << "ERROR: weight vector in the relative interior of maximal Gröbner cone" << std::endl;
85  return false;
86  }
87  return true;
88 }
89 
90 bool checkOrderingAndCone(const ring r, const gfan::ZCone zc)
91 {
92  if (r)
93  {
94  if (r->order[0]==ringorder_dp)
95  return true;
96  int n = rVar(r);
97  int* w = r->wvhdl[0];
98  gfan::ZVector v = wvhdlEntryToZVector(n,w);
99  if (r->order[0]==ringorder_ws)
100  v = gfan::Integer((long)-1)*v;
101  if (!zc.contains(v))
102  {
103  std::cout << "ERROR: weight of ordering not inside Groebner cone!" << std::endl;
104  return false;
105  }
106  }
107  return true;
108 }
109 
110 bool checkPolynomialInput(const ideal I, const ring r)
111 {
112  if (r) rTest(r);
113  if (I && r) id_Test(I,r);
114  return ((!I) || (I && r));
115 }
116 
117 bool checkPolyhedralInput(const gfan::ZCone zc, const gfan::ZVector p)
118 {
119  return zc.containsRelatively(p);
120 }
121 
122 #endif
bool checkForNonPositiveEntries(const gfan::ZVector &w)
const CanonicalForm int s
Definition: facAbsFact.cc:55
bool checkOrderingAndCone(const ring r, const gfan::ZCone zc)
poly kNF(ideal F, ideal Q, poly p, int syzComp, int lazyReduce)
Definition: kstd1.cc:2971
bool checkPolynomialInput(const ideal I, const ring r)
return P p
Definition: myNF.cc:203
#define id_Test(A, lR)
Definition: simpleideals.h:80
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:583
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
gfan::ZVector wvhdlEntryToZVector(const int n, const int *wvhdl0)
gfan::ZCone maximalGroebnerCone(const ideal &I, const ring &r)
Definition: tropical.cc:291
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:10
const ring r
Definition: syzextra.cc:208
bool checkPolyhedralInput(const gfan::ZCone zc, const gfan::ZVector p)
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:3985
ideal gfanlib_kStd_wrapper(ideal I, ring r, tHomog h=testHomog)
Definition: std_wrapper.cc:6
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:73
bool areIdealsEqual(ideal I, ring r, ideal J, ring s)
#define rTest(r)
Definition: ring.h:777
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:24
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:725
void rChangeCurrRing(ring r)
Definition: polys.cc:12
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:38
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
#define NULL
Definition: omList.c:10
const CanonicalForm & w
Definition: facAbsFact.cc:55
bool checkWeightVector(const ideal I, const ring r, const gfan::ZVector &weightVector, bool checkBorder)
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
const poly b
Definition: syzextra.cc:213
static int sign(int x)
Definition: ring.cc:3342
bool checkForNonPositiveLaterEntries(const gfan::ZVector &w)