1 | #ifndef GFANLIB_TROPICALSTRATEGY_H |
---|
2 | #define GFANLIB_TROPICALSTRATEGY_H |
---|
3 | |
---|
4 | #include <gfanlib/gfanlib_vector.h> |
---|
5 | #include <gfanlib/gfanlib_zcone.h> |
---|
6 | #include <libpolys/polys/simpleideals.h> |
---|
7 | #include <set> |
---|
8 | |
---|
9 | /** \file |
---|
10 | * implementation of the class tropicalStrategy |
---|
11 | * |
---|
12 | * tropicalStrategy is a class that contains information relevant for |
---|
13 | * computing tropical varieties that is dependent on the valuation of the coefficient field. |
---|
14 | * It represents the mutable part of an overall framework that is capable of |
---|
15 | * computing tropical varieties both over coefficient fields without valuation and |
---|
16 | * with valuation (currently: only p-adic valuation over rational numbers) |
---|
17 | */ |
---|
18 | |
---|
19 | typedef gfan::ZVector (*wAdjAlg1)(gfan::ZVector); |
---|
20 | typedef gfan::ZVector (*wAdjAlg2)(gfan::ZVector,gfan::ZVector); |
---|
21 | typedef bool (*redAlg)(ideal,ring,number); |
---|
22 | |
---|
23 | class tropicalStrategy |
---|
24 | { |
---|
25 | private: |
---|
26 | /** |
---|
27 | * polynomial ring over a field with valuation |
---|
28 | */ |
---|
29 | ring originalRing; |
---|
30 | /** |
---|
31 | * input ideal, assumed to be a homogeneous prime ideal |
---|
32 | */ |
---|
33 | ideal originalIdeal; |
---|
34 | /** |
---|
35 | * dimension of the input ideal |
---|
36 | */ |
---|
37 | int dimensionOfIdeal; |
---|
38 | /** |
---|
39 | * the homogeneity space of the Grobner fan |
---|
40 | */ |
---|
41 | gfan::ZCone linealitySpace; |
---|
42 | /** |
---|
43 | * polynomial ring over the valuation ring extended by one extra variable t |
---|
44 | */ |
---|
45 | ring startingRing; |
---|
46 | /** |
---|
47 | * preimage of the input ideal under the map that sends t to the uniformizing parameter |
---|
48 | */ |
---|
49 | ideal startingIdeal; |
---|
50 | /** |
---|
51 | * uniformizing parameter in the valuation ring |
---|
52 | */ |
---|
53 | number uniformizingParameter; |
---|
54 | /** |
---|
55 | * polynomial ring over the residue field |
---|
56 | */ |
---|
57 | ring shortcutRing; |
---|
58 | |
---|
59 | /** |
---|
60 | * true if valuation non-trivial, false otherwise |
---|
61 | */ |
---|
62 | bool onlyLowerHalfSpace; |
---|
63 | |
---|
64 | /** |
---|
65 | * A function such that: |
---|
66 | * Given weight w, returns a strictly positive weight u such that an ideal satisfying |
---|
67 | * the valuation-sepcific homogeneity conditions is weighted homogeneous with respect to w |
---|
68 | * if and only if it is homogeneous with respect to u |
---|
69 | */ |
---|
70 | gfan::ZVector (*weightAdjustingAlgorithm1) (gfan::ZVector w); |
---|
71 | /** |
---|
72 | * A function such that: |
---|
73 | * Given strictly positive weight w and weight v, |
---|
74 | * returns a strictly positive weight u such that on an ideal that is weighted homogeneous |
---|
75 | * with respect to w the weights u and v coincide |
---|
76 | */ |
---|
77 | gfan::ZVector (*weightAdjustingAlgorithm2) (gfan::ZVector v, gfan::ZVector w); |
---|
78 | /** |
---|
79 | * A function that reduces the generators of an ideal I so that |
---|
80 | * the inequalities and equations of the Groebner cone can be read off. |
---|
81 | */ |
---|
82 | bool (*extraReductionAlgorithm) (ideal I, ring r, number p); |
---|
83 | |
---|
84 | public: |
---|
85 | |
---|
86 | /** |
---|
87 | * Constructor for the trivial valuation case |
---|
88 | */ |
---|
89 | tropicalStrategy(const ideal I, const ring r); |
---|
90 | /** |
---|
91 | * Constructor for the non-trivial valuation case |
---|
92 | * p is the uniformizing parameter of the valuation |
---|
93 | */ |
---|
94 | tropicalStrategy(const ideal J, const number p, const ring s); |
---|
95 | /** |
---|
96 | * copy constructor |
---|
97 | */ |
---|
98 | tropicalStrategy(const tropicalStrategy& currentStrategy); |
---|
99 | /** |
---|
100 | * destructor |
---|
101 | */ |
---|
102 | ~tropicalStrategy(); |
---|
103 | /** |
---|
104 | * assignment operator |
---|
105 | **/ |
---|
106 | tropicalStrategy& operator=(const tropicalStrategy& currentStrategy); |
---|
107 | |
---|
108 | |
---|
109 | /** |
---|
110 | * returns the polynomial ring over the field with valuation |
---|
111 | */ |
---|
112 | ring getOriginalRing() const |
---|
113 | { |
---|
114 | rTest(originalRing); |
---|
115 | return originalRing; |
---|
116 | } |
---|
117 | |
---|
118 | /** |
---|
119 | * returns the polynomial ring over the valuation ring |
---|
120 | */ |
---|
121 | ring getStartingRing() const |
---|
122 | { |
---|
123 | rTest(startingRing); |
---|
124 | return startingRing; |
---|
125 | } |
---|
126 | |
---|
127 | /** |
---|
128 | * returns the input ideal |
---|
129 | */ |
---|
130 | ideal getStartingIdeal() const |
---|
131 | { |
---|
132 | id_Test(startingIdeal,startingRing); |
---|
133 | return startingIdeal; |
---|
134 | } |
---|
135 | |
---|
136 | /** |
---|
137 | * returns the dimension of the input ideal |
---|
138 | */ |
---|
139 | int getDimensionOfIdeal() const |
---|
140 | { |
---|
141 | return dimensionOfIdeal; |
---|
142 | } |
---|
143 | |
---|
144 | /** |
---|
145 | * returns the uniformizing parameter in the valuation ring |
---|
146 | */ |
---|
147 | number getUniformizingParameter() const |
---|
148 | { |
---|
149 | return uniformizingParameter; |
---|
150 | } |
---|
151 | |
---|
152 | /** |
---|
153 | * returns the homogeneity space of the preimage ideal |
---|
154 | */ |
---|
155 | gfan::ZCone getHomogeneitySpace() const |
---|
156 | { |
---|
157 | return linealitySpace; |
---|
158 | } |
---|
159 | |
---|
160 | /** |
---|
161 | * returns the dimension of the homogeneity space |
---|
162 | */ |
---|
163 | int getDimensionOfHomogeneitySpace() const |
---|
164 | { |
---|
165 | return linealitySpace.dimension(); |
---|
166 | } |
---|
167 | |
---|
168 | /** |
---|
169 | * returns true, if valuation non-trivial, false otherwise |
---|
170 | */ |
---|
171 | bool restrictToLowerHalfSpace() const |
---|
172 | { |
---|
173 | return onlyLowerHalfSpace; |
---|
174 | } |
---|
175 | |
---|
176 | /** |
---|
177 | * Given weight w, returns a strictly positive weight u such that an ideal satisfying |
---|
178 | * the valuation-sepcific homogeneity conditions is weighted homogeneous with respect to w |
---|
179 | * if and only if it is homogeneous with respect to u |
---|
180 | */ |
---|
181 | gfan::ZVector adjustWeightForHomogeneity(gfan::ZVector w) const |
---|
182 | { |
---|
183 | return this->weightAdjustingAlgorithm1(w); |
---|
184 | } |
---|
185 | |
---|
186 | /** |
---|
187 | * Given strictly positive weight w and weight v, |
---|
188 | * returns a strictly positive weight u such that on an ideal that is weighted homogeneous |
---|
189 | * with respect to w the weights u and v coincide |
---|
190 | */ |
---|
191 | gfan::ZVector adjustWeightUnderHomogeneity(gfan::ZVector v, gfan::ZVector w) const |
---|
192 | { |
---|
193 | return this->weightAdjustingAlgorithm2(v,w); |
---|
194 | } |
---|
195 | |
---|
196 | /** |
---|
197 | * reduces the generators of an ideal I so that |
---|
198 | * the inequalities and equations of the Groebner cone can be read off. |
---|
199 | */ |
---|
200 | bool reduce(ideal I, ring r) const |
---|
201 | { |
---|
202 | rTest(r); id_Test(I,r); |
---|
203 | nMapFunc nMap = n_SetMap(startingRing->cf,r->cf); |
---|
204 | number p = nMap(uniformizingParameter,startingRing->cf,r->cf); |
---|
205 | bool b = this->extraReductionAlgorithm(I,r,p); |
---|
206 | n_Delete(&p,r->cf); |
---|
207 | return b; |
---|
208 | } |
---|
209 | |
---|
210 | /** |
---|
211 | * returns true, if I contains a monomial. |
---|
212 | * returns false otherwise. |
---|
213 | **/ |
---|
214 | bool containsMonomial(ideal I, ring r) const |
---|
215 | { |
---|
216 | ring rFinite = rCopy0(r); |
---|
217 | nKillChar(rFinite.coeffs()); |
---|
218 | rFinite->cf = |
---|
219 | } |
---|
220 | }; |
---|
221 | |
---|
222 | int dim(ideal I, ring r); |
---|
223 | |
---|
224 | #endif |
---|