1 | #ifndef CALLGFANLIB_GROEBNERCONE_H |
---|
2 | #define CALLGFANLIB_GROEBNERCONE_H |
---|
3 | |
---|
4 | #include <kernel/polys.h> |
---|
5 | #include <Singular/ipid.h> |
---|
6 | |
---|
7 | #include <libpolys/polys/monomials/ring.h> |
---|
8 | #include <libpolys/polys/simpleideals.h> |
---|
9 | #include <kernel/ideals.h> |
---|
10 | #include <gfanlib/gfanlib.h> |
---|
11 | #include <set> |
---|
12 | |
---|
13 | #include <tropicalStrategy.h> |
---|
14 | |
---|
15 | /** \file |
---|
16 | * implementation of the class groebnerCone |
---|
17 | * |
---|
18 | * groebnerCone is a class that encapsulates relevant (possibly redundant) information about a groebnerCone. |
---|
19 | * Moreover, it contains implrementation of several highly non-trivial algorithms, such as computing its neighbours |
---|
20 | * in the Groebner fan or computing its neighbours in the tropical variety. |
---|
21 | */ |
---|
22 | |
---|
23 | class groebnerCone; |
---|
24 | struct groebnerCone_compare; |
---|
25 | typedef std::set<groebnerCone,groebnerCone_compare> groebnerCones; |
---|
26 | |
---|
27 | |
---|
28 | class groebnerCone |
---|
29 | { |
---|
30 | |
---|
31 | private: |
---|
32 | /** |
---|
33 | * ideal to which this Groebner cone belongs to |
---|
34 | */ |
---|
35 | ideal polynomialIdeal; |
---|
36 | /** |
---|
37 | * ring in which the ideal exists |
---|
38 | */ |
---|
39 | ring polynomialRing; |
---|
40 | gfan::ZCone polyhedralCone; |
---|
41 | gfan::ZVector interiorPoint; |
---|
42 | const tropicalStrategy* currentStrategy; |
---|
43 | |
---|
44 | public: |
---|
45 | groebnerCone(); |
---|
46 | groebnerCone(const ideal I, const ring r, const tropicalStrategy& currentCase); |
---|
47 | groebnerCone(const ideal I, const ring r, const gfan::ZVector& w, const tropicalStrategy& currentCase); |
---|
48 | groebnerCone(const ideal I, const ring r, const gfan::ZVector& u, const gfan::ZVector& w, const tropicalStrategy& currentCase); |
---|
49 | groebnerCone(const ideal I, const ideal inI, const ring r, const tropicalStrategy& currentCase); |
---|
50 | groebnerCone(const groebnerCone& sigma); |
---|
51 | ~groebnerCone(); |
---|
52 | groebnerCone& operator=(const groebnerCone& sigma); |
---|
53 | |
---|
54 | void deletePolynomialData() |
---|
55 | { |
---|
56 | assume ((!polynomialIdeal) || (polynomialIdeal && polynomialRing)); |
---|
57 | if (polynomialIdeal) id_Delete(&polynomialIdeal,polynomialRing); |
---|
58 | if (polynomialRing) rDelete(polynomialRing); |
---|
59 | polynomialIdeal = NULL; |
---|
60 | polynomialRing = NULL; |
---|
61 | } |
---|
62 | |
---|
63 | ideal getPolynomialIdeal() const { return polynomialIdeal; }; |
---|
64 | ring getPolynomialRing() const { return polynomialRing; }; |
---|
65 | gfan::ZCone getPolyhedralCone() const { return polyhedralCone; }; |
---|
66 | gfan::ZVector getInteriorPoint() const { return interiorPoint; }; |
---|
67 | const tropicalStrategy* getTropicalStrategy() const {return currentStrategy; }; |
---|
68 | friend struct groebnerCone_compare; |
---|
69 | |
---|
70 | /** |
---|
71 | * Returns true if Groebner cone contains w, false otherwise |
---|
72 | */ |
---|
73 | bool contains(const gfan::ZVector &w) const; |
---|
74 | |
---|
75 | /** |
---|
76 | * Returns a point in the tropical variety, if the groebnerCone contains one. |
---|
77 | * Returns an empty vector otherwise. |
---|
78 | */ |
---|
79 | gfan::ZVector tropicalPoint() const; |
---|
80 | |
---|
81 | /** |
---|
82 | * Given an interior point on the facet and the outer normal factor on the facet, |
---|
83 | * returns the adjacent groebnerCone sharing that facet |
---|
84 | */ |
---|
85 | groebnerCone flipCone(const gfan::ZVector &interiorPoint, const gfan::ZVector &facetNormal) const; |
---|
86 | |
---|
87 | /** |
---|
88 | * Returns a complete list of neighboring Groebner cones. |
---|
89 | */ |
---|
90 | groebnerCones groebnerNeighbours() const; |
---|
91 | |
---|
92 | /** |
---|
93 | * Returns a complete list of neighboring Groebner cones in the tropical variety. |
---|
94 | */ |
---|
95 | groebnerCones tropicalNeighbours() const; |
---|
96 | |
---|
97 | /** |
---|
98 | * Debug tools. |
---|
99 | */ |
---|
100 | #ifndef NDEBUG |
---|
101 | bool checkFlipConeInput(const gfan::ZVector interiorPoint, const gfan::ZVector facetNormal) const; |
---|
102 | bool pointsOutwards(const gfan::ZVector) const; |
---|
103 | #endif |
---|
104 | }; |
---|
105 | |
---|
106 | struct groebnerCone_compare |
---|
107 | { |
---|
108 | bool operator()(const groebnerCone &sigma, const groebnerCone &theta) const |
---|
109 | { |
---|
110 | const gfan::ZVector p1 = sigma.getInteriorPoint(); |
---|
111 | const gfan::ZVector p2 = theta.getInteriorPoint(); |
---|
112 | assume (p1.size() == p2.size()); |
---|
113 | return p1 < p2; |
---|
114 | } |
---|
115 | }; |
---|
116 | |
---|
117 | gfan::ZFan* toFanStar(groebnerCones setOfCones); |
---|
118 | |
---|
119 | #ifndef NDEBUG |
---|
120 | BOOLEAN flipConeDebug(leftv res, leftv args); |
---|
121 | BOOLEAN groebnerNeighboursDebug(leftv res, leftv args); |
---|
122 | BOOLEAN tropicalNeighboursDebug(leftv res, leftv args); |
---|
123 | #endif |
---|
124 | |
---|
125 | #endif |
---|