My Project
Loading...
Searching...
No Matches
Functions
tropicalCurves.h File Reference
#include "gfanlib/gfanlib_zcone.h"
#include "gfanlib/gfanlib_zfan.h"
#include "polys/monomials/p_polys.h"
#include "tropicalStrategy.h"
#include "tropicalVarietyOfPolynomials.h"

Go to the source code of this file.

Functions

ZConesSortedByDimension tropicalStar (const ideal I, const ring r, const gfan::ZVector &u, const tropicalStrategy *currentStrategy)
 
gfan::ZMatrix raysOfTropicalStar (ideal I, const ring r, const gfan::ZVector &u, const tropicalStrategy *currentStrategy)
 

Function Documentation

◆ raysOfTropicalStar()

gfan::ZMatrix raysOfTropicalStar ( ideal  I,
const ring  r,
const gfan::ZVector &  u,
const tropicalStrategy currentStrategy 
)

Definition at line 243 of file tropicalCurves.cc.

244{
245 ZConesSortedByDimension C = tropicalStar(I,r,u,currentStrategy);
246 // gfan::ZFan* zf = toFanStar(C);
247 // std::cout << zf->toString();
248 // delete zf;
249 gfan::ZMatrix raysOfC(0,u.size());
250 if (!currentStrategy->restrictToLowerHalfSpace())
251 {
252 for (ZConesSortedByDimension::iterator zc=C.begin(); zc!=C.end(); zc++)
253 {
254 assume(zc->dimensionOfLinealitySpace()+1 >= zc->dimension());
255 if (zc->dimensionOfLinealitySpace()+1 >= zc->dimension())
256 raysOfC.appendRow(zc->getRelativeInteriorPoint());
257 else
258 {
259 gfan::ZVector interiorPoint = zc->getRelativeInteriorPoint();
260 if (!currentStrategy->homogeneitySpaceContains(interiorPoint))
261 {
262 raysOfC.appendRow(interiorPoint);
263 raysOfC.appendRow(currentStrategy->negateWeight(interiorPoint));
264 }
265 else
266 {
267 gfan::ZMatrix zm = zc->generatorsOfLinealitySpace();
268 for (int i=0; i<zm.getHeight(); i++)
269 {
270 gfan::ZVector point = zm[i];
271 if (currentStrategy->homogeneitySpaceContains(point))
272 {
273 raysOfC.appendRow(point);
274 raysOfC.appendRow(currentStrategy->negateWeight(point));
275 break;
276 }
277 }
278 }
279 }
280 }
281 }
282 else
283 {
284 for (ZConesSortedByDimension::iterator zc=C.begin(); zc!=C.end(); zc++)
285 {
286 assume(zc->dimensionOfLinealitySpace()+2 >= zc->dimension());
287 if (zc->dimensionOfLinealitySpace()+2 == zc->dimension())
288 raysOfC.appendRow(zc->getRelativeInteriorPoint());
289 else
290 {
291 gfan::ZVector interiorPoint = zc->getRelativeInteriorPoint();
292 if (!currentStrategy->homogeneitySpaceContains(interiorPoint))
293 {
294 raysOfC.appendRow(interiorPoint);
295 raysOfC.appendRow(currentStrategy->negateWeight(interiorPoint));
296 }
297 else
298 {
299 gfan::ZMatrix zm = zc->generatorsOfLinealitySpace();
300 for (int i=0; i<zm.getHeight(); i++)
301 {
302 gfan::ZVector point = zm[i];
303 if (currentStrategy->homogeneitySpaceContains(point))
304 {
305 raysOfC.appendRow(point);
306 raysOfC.appendRow(currentStrategy->negateWeight(point));
307 break;
308 }
309 }
310 }
311 }
312 }
313 }
314 return raysOfC;
315}
int i
Definition: cfEzgcd.cc:132
bool homogeneitySpaceContains(const gfan::ZVector &v) const
returns true, if v is contained in the homogeneity space; false otherwise
gfan::ZVector negateWeight(const gfan::ZVector &w) const
bool restrictToLowerHalfSpace() const
returns true, if valuation non-trivial, false otherwise
#define assume(x)
Definition: mod2.h:389
ZConesSortedByDimension tropicalStar(ideal inI, const ring r, const gfan::ZVector &u, const tropicalStrategy *currentStrategy)
std::set< gfan::ZCone, ZConeCompareDimensionFirst > ZConesSortedByDimension

◆ tropicalStar()

ZConesSortedByDimension tropicalStar ( const ideal  I,
const ring  r,
const gfan::ZVector &  u,
const tropicalStrategy currentStrategy 
)

Definition at line 107 of file tropicalCurves.cc.

109{
110 int k = IDELEMS(inI);
111 int d = currentStrategy->getExpectedDimension();
112
113 /* Compute the common refinement over all tropical varieties
114 * of the polynomials in the generating set */
115 ZConesSortedByDimension C = tropicalVarietySortedByDimension(inI->m[0],r,currentStrategy);
116 int PayneOsserman = rVar(r)-1;
117 for (int i=0; i<k; i++)
118 {
119 if(inI->m[i]!=NULL)
120 {
121 PayneOsserman--;
122 C = intersect(C,tropicalVarietySortedByDimension(inI->m[i],r,currentStrategy),si_max(PayneOsserman,d));
123 }
124 }
125
126 /* Cycle through all maximal cones of the refinement.
127 * Pick a monomial ordering corresponding to a generic weight vector in it
128 * and check if the initial ideal is monomial free, generic meaning
129 * that it lies in a maximal Groebner cone in the maximal cone of the refinement.
130 * If the initial ideal is not monomial free, compute a witness for the monomial
131 * and compute the common refinement with its tropical variety.
132 * If all initial ideals are monomial free, then we have our tropical curve */
133 // gfan::ZFan* zf = toFanStar(C);
134 // std::cout << zf->toString(2+4+8+128) << std::endl;
135 // delete zf;
136 for (std::set<gfan::ZCone>::iterator zc=C.begin(); zc!=C.end();)
137 {
138 gfan::ZVector w = zc->getRelativeInteriorPoint();
139 gfan::ZMatrix W = zc->generatorsOfSpan();
140 // std::cout << zc->extremeRays() << std::endl;
141
142 ring s = genericlyWeightedOrdering(r,u,w,W,currentStrategy);
143 nMapFunc identity = n_SetMap(r->cf,s->cf);
144 ideal inIs = idInit(k);
145 for (int j=0; j<k; j++)
146 inIs->m[j] = p_PermPoly(inI->m[j],NULL,r,s,identity,NULL,0);
147
148 ideal inIsSTD = gfanlib_kStd_wrapper(inIs,s,isHomog);
149 id_Delete(&inIs,s);
150 ideal ininIs = initial(inIsSTD,s,w,W);
151
152 std::pair<poly,int> mons = currentStrategy->checkInitialIdealForMonomial(ininIs,s);
153
154 if (mons.first!=NULL)
155 {
156 poly gs;
157 if (mons.second>=0)
158 // cheap way out, ininIsSTD already contains a monomial in its generators
159 gs = inIsSTD->m[mons.second];
160 else
161 // compute witness
162 gs = witness(mons.first,inIsSTD,ininIs,s);
163
164 C = intersect(C,tropicalVarietySortedByDimension(gs,s,currentStrategy),d);
165 nMapFunc mMap = n_SetMap(s->cf,r->cf);
166 poly gr = p_PermPoly(gs,NULL,s,r,mMap,NULL,0);
167 idInsertPoly(inI,gr);
168 k++;
169
170 if (mons.second<0)
171 {
172 // if necessary, cleanup mons and gs
173 p_Delete(&mons.first,s);
174 p_Delete(&gs,s);
175 }
176 // cleanup rest, reset zc
177 id_Delete(&inIsSTD,s);
178 id_Delete(&ininIs,s);
179 rDelete(s);
180 zc = C.begin();
181 }
182 else
183 {
184 // cleanup remaining data of first stage
185 id_Delete(&inIsSTD,s);
186 id_Delete(&ininIs,s);
187 rDelete(s);
188
189 gfan::ZVector wNeg = currentStrategy->negateWeight(w);
190 if (zc->contains(wNeg))
191 {
192 s = genericlyWeightedOrdering(r,u,wNeg,W,currentStrategy);
193 identity = n_SetMap(r->cf,s->cf);
194 inIs = idInit(k);
195 for (int j=0; j<k; j++)
196 inIs->m[j] = p_PermPoly(inI->m[j],NULL,r,s,identity,NULL,0);
197
198 inIsSTD = gfanlib_kStd_wrapper(inIs,s,isHomog);
199 id_Delete(&inIs,s);
200 ininIs = initial(inIsSTD,s,wNeg,W);
201
202 mons = currentStrategy->checkInitialIdealForMonomial(ininIs,s);
203 if (mons.first!=NULL)
204 {
205 poly gs;
206 if (mons.second>=0)
207 // cheap way out, ininIsSTD already contains a monomial in its generators
208 gs = inIsSTD->m[mons.second];
209 else
210 // compute witness
211 gs = witness(mons.first,inIsSTD,ininIs,s);
212
213 C = intersect(C,tropicalVarietySortedByDimension(gs,s,currentStrategy),d);
214 nMapFunc mMap = n_SetMap(s->cf,r->cf);
215 poly gr = p_PermPoly(gs,NULL,s,r,mMap,NULL,0);
216 idInsertPoly(inI,gr);
217 k++;
218
219 if (mons.second<0)
220 {
221 // if necessary, cleanup mons and gs
222 p_Delete(&mons.first,s);
223 p_Delete(&gs,s);
224 }
225 // reset zc
226 zc = C.begin();
227 }
228 else
229 zc++;
230 // cleanup remaining data of second stage
231 id_Delete(&inIsSTD,s);
232 id_Delete(&ininIs,s);
233 rDelete(s);
234 }
235 else
236 zc++;
237 }
238 }
239 return C;
240}
static int si_max(const int a, const int b)
Definition: auxiliary.h:124
int k
Definition: cfEzgcd.cc:99
int getExpectedDimension() const
returns the expected Dimension of the polyhedral output
std::pair< poly, int > checkInitialIdealForMonomial(const ideal I, const ring r, const gfan::ZVector &w=0) const
If given w, assuming w is in the Groebner cone of the ordering on r and I is a standard basis with re...
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
int j
Definition: facHensel.cc:110
BOOLEAN idInsertPoly(ideal h1, poly h2)
insert h2 into h1 (if h2 is not the zero polynomial) return TRUE iff h2 was indeed inserted
poly initial(const poly p, const ring r, const gfan::ZVector &w)
Returns the initial form of p with respect to w.
Definition: initial.cc:30
#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
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:899
void rDelete(ring r)
unconditionally deletes fields in r
Definition: ring.cc:450
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:592
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
ideal gfanlib_kStd_wrapper(ideal I, ring r, tHomog h=testHomog)
Definition: std_wrapper.cc:6
@ isHomog
Definition: structs.h:37
static ZConesSortedByDimension intersect(const ZConesSortedByDimension &setA, const ZConesSortedByDimension &setB, int d=0)
static ring genericlyWeightedOrdering(const ring r, const gfan::ZVector &u, const gfan::ZVector &w, const gfan::ZMatrix &W, const tropicalStrategy *currentStrategy)
ZConesSortedByDimension tropicalVarietySortedByDimension(const poly g, const ring r, const tropicalStrategy *currentCase)
poly witness(const poly m, const ideal I, const ideal inI, const ring r)
Let w be the uppermost weight vector in the matrix defining the ordering on r.
Definition: witness.cc:34