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)
 
BOOLEAN tropicalStarDebug (leftv res, leftv args)
 

Function Documentation

§ raysOfTropicalStar()

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

Definition at line 250 of file tropicalCurves.cc.

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

§ tropicalStar()

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

Definition at line 116 of file tropicalCurves.cc.

118 {
119  int k = IDELEMS(inI);
120  int d = currentStrategy->getExpectedDimension();
121 
122  /* Compute the common refinement over all tropical varieties
123  * of the polynomials in the generating set */
124  ZConesSortedByDimension C = tropicalVarietySortedByDimension(inI->m[0],r,currentStrategy);
125  for (int i=1; i<k; i++)
126  {
127  if(inI->m[i]!=NULL)
128  {
129  C = intersect(C,tropicalVarietySortedByDimension(inI->m[i],r,currentStrategy),d);
130  }
131  }
132 
133  /* Cycle through all maximal cones of the refinement.
134  * Pick a monomial ordering corresponding to a generic weight vector in it
135  * and check if the initial ideal is monomial free, generic meaning
136  * that it lies in a maximal Groebner cone in the maximal cone of the refinement.
137  * If the initial ideal is not monomial free, compute a witness for the monomial
138  * and compute the common refinement with its tropical variety.
139  * If all initial ideals are monomial free, then we have our tropical curve */
140  // gfan::ZFan* zf = toFanStar(C);
141  // std::cout << zf->toString(2+4+8+128) << std::endl;
142  // delete zf;
143  for (std::set<gfan::ZCone>::iterator zc=C.begin(); zc!=C.end();)
144  {
145  gfan::ZVector w = zc->getRelativeInteriorPoint();
146  gfan::ZMatrix W = zc->generatorsOfSpan();
147  // std::cout << zc->extremeRays() << std::endl;
148 
149  ring s = genericlyWeightedOrdering(r,u,w,W,currentStrategy);
150  nMapFunc identity = n_SetMap(r->cf,s->cf);
151  ideal inIs = idInit(k);
152  for (int j=0; j<k; j++)
153  inIs->m[j] = p_PermPoly(inI->m[j],NULL,r,s,identity,NULL,0);
154 
155  ideal inIsSTD = gfanlib_kStd_wrapper(inIs,s,isHomog);
156  id_Delete(&inIs,s);
157  ideal ininIs = initial(inIsSTD,s,w,W);
158 
159  std::pair<poly,int> mons = currentStrategy->checkInitialIdealForMonomial(ininIs,s);
160 
161  if (mons.first!=NULL)
162  {
163  poly gs;
164  if (mons.second>=0)
165  // cheap way out, ininIsSTD already contains a monomial in its generators
166  gs = inIsSTD->m[mons.second];
167  else
168  // compute witness
169  gs = witness(mons.first,inIsSTD,ininIs,s);
170 
171  C = intersect(C,tropicalVarietySortedByDimension(gs,s,currentStrategy),d);
172  nMapFunc mMap = n_SetMap(s->cf,r->cf);
173  poly gr = p_PermPoly(gs,NULL,s,r,mMap,NULL,0);
174  idInsertPoly(inI,gr);
175  k++;
176 
177  if (mons.second<0)
178  {
179  // if necessary, cleanup mons and gs
180  p_Delete(&mons.first,s);
181  p_Delete(&gs,s);
182  }
183  // cleanup rest, reset zc
184  id_Delete(&inIsSTD,s);
185  id_Delete(&ininIs,s);
186  rDelete(s);
187  zc = C.begin();
188  }
189  else
190  {
191  // cleanup remaining data of first stage
192  id_Delete(&inIsSTD,s);
193  id_Delete(&ininIs,s);
194  rDelete(s);
195 
196  gfan::ZVector wNeg = currentStrategy->negateWeight(w);
197  if (zc->contains(wNeg))
198  {
199  s = genericlyWeightedOrdering(r,u,wNeg,W,currentStrategy);
200  identity = n_SetMap(r->cf,s->cf);
201  inIs = idInit(k);
202  for (int j=0; j<k; j++)
203  inIs->m[j] = p_PermPoly(inI->m[j],NULL,r,s,identity,NULL,0);
204 
205  inIsSTD = gfanlib_kStd_wrapper(inIs,s,isHomog);
206  id_Delete(&inIs,s);
207  ininIs = initial(inIsSTD,s,wNeg,W);
208 
209  mons = currentStrategy->checkInitialIdealForMonomial(ininIs,s);
210  if (mons.first!=NULL)
211  {
212  poly gs;
213  if (mons.second>=0)
214  // cheap way out, ininIsSTD already contains a monomial in its generators
215  gs = inIsSTD->m[mons.second];
216  else
217  // compute witness
218  gs = witness(mons.first,inIsSTD,ininIs,s);
219 
220  C = intersect(C,tropicalVarietySortedByDimension(gs,s,currentStrategy),d);
221  nMapFunc mMap = n_SetMap(s->cf,r->cf);
222  poly gr = p_PermPoly(gs,NULL,s,r,mMap,NULL,0);
223  idInsertPoly(inI,gr);
224  k++;
225 
226  if (mons.second<0)
227  {
228  // if necessary, cleanup mons and gs
229  p_Delete(&mons.first,s);
230  p_Delete(&gs,s);
231  }
232  // reset zc
233  zc = C.begin();
234  }
235  else
236  zc++;
237  // cleanup remaining data of second stage
238  id_Delete(&inIsSTD,s);
239  id_Delete(&ininIs,s);
240  rDelete(s);
241  }
242  else
243  zc++;
244  }
245  }
246  return C;
247 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
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)
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
int k
Definition: cfEzgcd.cc:93
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:32
const ring r
Definition: syzextra.cc:208
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:3939
std::set< gfan::ZCone, ZConeCompareDimensionFirst > ZConesSortedByDimension
int j
Definition: myNF.cc:70
ideal gfanlib_kStd_wrapper(ideal I, ring r, tHomog h=testHomog)
Definition: std_wrapper.cc:5
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:73
BOOLEAN idInsertPoly(ideal h1, poly h2)
insert h2 into h1 (if h2 is not the zero polynomial) return TRUE iff h2 was indeed inserted ...
static ZConesSortedByDimension intersect(const ZConesSortedByDimension &setA, const ZConesSortedByDimension &setB, int d=0)
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:24
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:725
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:843
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:38
gfan::ZVector negateWeight(const gfan::ZVector &w) const
#define NULL
Definition: omList.c:10
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
void rDelete(ring r)
unconditionally deletes fields in r
Definition: ring.cc:448
int getExpectedDimension() const
returns the expected Dimension of the polyhedral output
const CanonicalForm & w
Definition: facAbsFact.cc:55
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...
polyrec * poly
Definition: hilb.h:10

§ tropicalStarDebug()

BOOLEAN tropicalStarDebug ( leftv  res,
leftv  args 
)

Definition at line 330 of file tropicalCurves.cc.

331 {
332  leftv u = args;
333  if ((u!=NULL) && (u->Typ()==IDEAL_CMD))
334  {
335  leftv v = u->next;
336  if ((v!=NULL) && (v->Typ()==BIGINTMAT_CMD))
337  {
338  omUpdateInfo();
339  Print("usedBytesBefore=%ld\n",om_Info.UsedBytes);
340  ideal inI = (ideal) u->CopyD();
341  bigintmat* u = (bigintmat*) v->CopyD();
342  tropicalStrategy currentCase(inI,currRing);
343  gfan::ZVector* v = bigintmatToZVector(u);
344  ZConesSortedByDimension C = tropicalStar(inI,currRing,*v,&currentCase);
345  id_Delete(&inI,currRing);
346  delete u;
347  delete v;
348  res->rtyp = NONE;
349  res->data = NULL;
350  // res->rtyp = fanID;
351  // res->data = (char*) toFanStar(C);
352  return FALSE;
353  }
354  }
355  WerrorS("tropicalStarDebug: unexpected parameters");
356  return TRUE;
357 }
Class used for (list of) interpreter objects.
Definition: subexpr.h:84
#define Print
Definition: emacs.cc:83
#define FALSE
Definition: auxiliary.h:97
Matrices of numbers.
Definition: bigintmat.h:51
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
#define TRUE
Definition: auxiliary.h:101
void WerrorS(const char *s)
Definition: feFopen.cc:24
int Typ()
Definition: subexpr.cc:979
void * data
Definition: subexpr.h:90
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:10
std::set< gfan::ZCone, ZConeCompareDimensionFirst > ZConesSortedByDimension
omInfo_t om_Info
Definition: omStats.c:13
leftv next
Definition: subexpr.h:88
ZConesSortedByDimension tropicalStar(ideal inI, const ring r, const gfan::ZVector &u, const tropicalStrategy *currentStrategy)
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
#define NULL
Definition: omList.c:10
void omUpdateInfo()
Definition: omStats.c:24
int rtyp
Definition: subexpr.h:93
#define NONE
Definition: tok.h:216
void * CopyD(int t)
Definition: subexpr.cc:679
gfan::ZVector * bigintmatToZVector(const bigintmat &bim)