My Project
Loading...
Searching...
No Matches
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
13bool 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
27bool 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
41bool 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
74bool 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
90bool 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
110bool 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
117bool checkPolyhedralInput(const gfan::ZCone zc, const gfan::ZVector p)
118{
119 return zc.containsRelatively(p);
120}
121
122#endif
gfan::ZVector wvhdlEntryToZVector(const int n, const int *wvhdl0)
int i
Definition: cfEzgcd.cc:132
int p
Definition: cfModGcd.cc:4078
CanonicalForm b
Definition: cfModGcd.cc:4103
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:697
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:73
const CanonicalForm int s
Definition: facAbsFact.cc:51
const CanonicalForm & w
Definition: facAbsFact.cc:51
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:39
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
poly kNF(ideal F, ideal Q, poly p, int syzComp, int lazyReduce)
Definition: kstd1.cc:3182
#define NULL
Definition: omList.c:12
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:4130
void rChangeCurrRing(ring r)
Definition: polys.cc:15
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
static int sign(int x)
Definition: ring.cc:3427
@ ringorder_dp
Definition: ring.h:78
@ ringorder_ws
Definition: ring.h:86
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:592
#define rTest(r)
Definition: ring.h:782
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:35
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
#define IDELEMS(i)
Definition: simpleideals.h:23
#define id_Test(A, lR)
Definition: simpleideals.h:87
ideal gfanlib_kStd_wrapper(ideal I, ring r, tHomog h=testHomog)
Definition: std_wrapper.cc:6
bool checkWeightVector(const ideal I, const ring r, const gfan::ZVector &weightVector, bool checkBorder)
bool checkPolyhedralInput(const gfan::ZCone zc, const gfan::ZVector p)
bool checkForNonPositiveEntries(const gfan::ZVector &w)
bool checkOrderingAndCone(const ring r, const gfan::ZCone zc)
bool checkPolynomialInput(const ideal I, const ring r)
bool areIdealsEqual(ideal I, ring r, ideal J, ring s)
bool checkForNonPositiveLaterEntries(const gfan::ZVector &w)
gfan::ZCone maximalGroebnerCone(const ideal &I, const ring &r)
Definition: tropical.cc:291