My Project  UNKNOWN_GIT_VERSION
tropicalDebug.cc
Go to the documentation of this file.
1 #ifndef SING_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
callgfanlib_conversion.h
wvhdlEntryToZVector
gfan::ZVector wvhdlEntryToZVector(const int n, const int *wvhdl0)
Definition: callgfanlib_conversion.cc:102
rChangeCurrRing
void rChangeCurrRing(ring r)
Definition: polys.cc:15
std_wrapper.h
ringorder_ws
@ ringorder_ws
Definition: ring.h:87
simpleideals.h
sign
static int sign(int x)
Definition: ring.cc:3346
rTest
#define rTest(r)
Definition: ring.h:776
idIs0
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
Definition: simpleideals.cc:768
checkPolyhedralInput
bool checkPolyhedralInput(const gfan::ZCone zc, const gfan::ZVector p)
Definition: tropicalDebug.cc:117
w
const CanonicalForm & w
Definition: facAbsFact.cc:55
b
CanonicalForm b
Definition: cfModGcd.cc:4044
checkWeightVector
bool checkWeightVector(const ideal I, const ring r, const gfan::ZVector &weightVector, bool checkBorder)
Definition: tropicalDebug.cc:74
currRing
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
rVar
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:582
i
int i
Definition: cfEzgcd.cc:125
id_Delete
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
Definition: simpleideals.cc:114
p_PermPoly
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:4028
nMapFunc
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:73
tropical.h
gfanlib_kStd_wrapper
ideal gfanlib_kStd_wrapper(ideal I, ring r, tHomog h=testHomog)
Definition: std_wrapper.cc:6
checkOrderingAndCone
bool checkOrderingAndCone(const ring r, const gfan::ZCone zc)
Definition: tropicalDebug.cc:90
kNF
poly kNF(ideal F, ideal Q, poly p, int syzComp, int lazyReduce)
Definition: kstd1.cc:2822
ringorder_dp
@ ringorder_dp
Definition: ring.h:79
checkForNonPositiveEntries
bool checkForNonPositiveEntries(const gfan::ZVector &w)
Definition: tropicalDebug.cc:13
kstd1.h
checkPolynomialInput
bool checkPolynomialInput(const ideal I, const ring r)
Definition: tropicalDebug.cc:110
maximalGroebnerCone
gfan::ZCone maximalGroebnerCone(const ideal &I, const ring &r)
Definition: tropical.cc:291
idInit
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:37
NULL
#define NULL
Definition: omList.c:10
areIdealsEqual
bool areIdealsEqual(ideal I, ring r, ideal J, ring s)
Definition: tropicalDebug.cc:41
v
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
p
int p
Definition: cfModGcd.cc:4019
s
const CanonicalForm int s
Definition: facAbsFact.cc:55
n_SetMap
static FORCE_INLINE nMapFunc n_SetMap(const coeffs src, const coeffs dst)
set the mapping function pointers for translating numbers from src to dst
Definition: coeffs.h:721
IDELEMS
#define IDELEMS(i)
Definition: simpleideals.h:26
id_Test
#define id_Test(A, lR)
Definition: simpleideals.h:80
checkForNonPositiveLaterEntries
bool checkForNonPositiveLaterEntries(const gfan::ZVector &w)
Definition: tropicalDebug.cc:27