Loading...
Searching...
No Matches
tropicalCurves.cc File Reference
`#include "gfanlib/gfanlib_matrix.h"`
`#include "gfanlib/gfanlib_zcone.h"`
`#include "polys/monomials/p_polys.h"`
`#include "callgfanlib_conversion.h"`
`#include "std_wrapper.h"`
`#include "containsMonomial.h"`
`#include "initial.h"`
`#include "witness.h"`
`#include "tropicalStrategy.h"`
`#include "tropicalVarietyOfPolynomials.h"`
`#include "tropicalCurves.h"`

Go to the source code of this file.

## Functions

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 | tropicalStar (ideal inI, 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

## genericlyWeightedOrdering()

ring genericlyWeightedOrdering | ( | const ring | r,
|  | const gfan::ZVector & | u,
|  | const gfan::ZVector & | w,
|  | const gfan::ZMatrix & | W,
|  | const tropicalStrategy * | currentStrategy )

static

Definition at line 49 of file tropicalCurves.cc.

{
int n = rVar(r);
int h = W.getHeight();
/* create a copy s of r and delete its ordering */
ring s = rCopy0(r,FALSE,FALSE);
s->order = (rRingOrder_t*) omAlloc0((h+4)*sizeof(rRingOrder_t));
s->block0 = (int*) omAlloc0((h+4)*sizeof(int));
s->block1 = (int*) omAlloc0((h+4)*sizeof(int));
s->wvhdl = (int**) omAlloc0((h+4)*sizeof(int*));
/* construct a new ordering as describe above */
bool overflow = false;
s->order[0] = ringorder_a;
s->block0[0] = 1;
s->block1[0] = n;
gfan::ZVector uAdjusted = currentStrategy->adjustWeightForHomogeneity(u);
s->wvhdl[0] = ZVectorToIntStar(uAdjusted,overflow);
s->order[1] = ringorder_a;
s->block0[1] = 1;
s->block1[1] = n;
gfan::ZVector wAdjusted = currentStrategy->adjustWeightUnderHomogeneity(w,uAdjusted);
s->wvhdl[1] = ZVectorToIntStar(wAdjusted,overflow);
for (int j=0; j<h-1; j++)
{
s->order[j+2] = ringorder_a;
s->block0[j+2] = 1;
s->block1[j+2] = n;
wAdjusted = currentStrategy->adjustWeightUnderHomogeneity(W[j],uAdjusted);
s->wvhdl[j+2] = ZVectorToIntStar(wAdjusted,overflow);
}
s->order[h+1] = ringorder_wp;
s->block0[h+1] = 1;
s->block1[h+1] = n;
wAdjusted = currentStrategy->adjustWeightUnderHomogeneity(W[h-1],uAdjusted);
s->wvhdl[h+1] = ZVectorToIntStar(wAdjusted,overflow);
s->order[h+2] = ringorder_C;
if (overflow)
{
WerrorS("genericlyWeightedOrdering: overflow in weight vector");
throw 0; // weightOverflow;
}
/* complete the ring and return it */
rComplete(s);
rTest(s);
return s;
}
FALSE
#define FALSE
Definition auxiliary.h:97
ZVectorToIntStar
int * ZVectorToIntStar(const gfan::ZVector &v, bool &overflow)
Definition callgfanlib_conversion.cc:110
tropicalStrategy::adjustWeightUnderHomogeneity
gfan::ZVector adjustWeightUnderHomogeneity(gfan::ZVector v, gfan::ZVector w) const
Given strictly positive weight w and weight v, returns a strictly positive weight u such that on an i...
Definition tropicalStrategy.h:258
tropicalStrategy::adjustWeightForHomogeneity
gfan::ZVector adjustWeightForHomogeneity(gfan::ZVector w) const
Given weight w, returns a strictly positive weight u such that an ideal satisfying the valuation-sepc...
Definition tropicalStrategy.h:248
s
const CanonicalForm int s
Definition facAbsFact.cc:51
w
const CanonicalForm & w
Definition facAbsFact.cc:51
j
int j
Definition facHensel.cc:110
WerrorS
void WerrorS(const char *s)
Definition feFopen.cc:24
h
STATIC_VAR Poly * h
Definition janet.cc:971
omAlloc0
#define omAlloc0(size)
Definition omAllocDecl.h:211
rComplete
BOOLEAN rComplete(ring r, int force)
this needs to be called whenever a new ring is created: new fields in ring are created (like VarOffse...
Definition ring.cc:3527
rCopy0
ring rCopy0(const ring r, BOOLEAN copy_qideal, BOOLEAN copy_ordering)
Definition ring.cc:1427
rRingOrder_t
rRingOrder_t
order stuff
Definition ring.h:69
ringorder_a
@ ringorder_a
Definition ring.h:71
ringorder_C
@ ringorder_C
Definition ring.h:74
ringorder_wp
@ ringorder_wp
Definition ring.h:82
rVar
static short rVar(const ring r)
define rVar(r) (r->N)
Definition ring.h:598
rTest
#define rTest(r)
Definition ring.h:794

## intersect()

ZConesSortedByDimension intersect | ( | const ZConesSortedByDimension & | setA,
|  | const ZConesSortedByDimension & | setB,
|  | int | d = 0 )

static

Definition at line 18 of file tropicalCurves.cc.

{
if (setA.empty())
return setB;
if (setB.empty())
return setA;
ZConesSortedByDimension setAB;
for (ZConesSortedByDimension::iterator coneOfA=setA.begin(); coneOfA!=setA.end(); coneOfA++)
{
for (ZConesSortedByDimension::iterator coneOfB=setB.begin(); coneOfB!=setB.end(); coneOfB++)
{
gfan::ZCone coneOfIntersection = gfan::intersection(*coneOfA,*coneOfB);
if (coneOfIntersection.dimension()>=d)
{
coneOfIntersection.canonicalize();
setAB.insert(coneOfIntersection);
}
}
}
return setAB;
}
ZConesSortedByDimension
std::set< gfan::ZCone, ZConeCompareDimensionFirst > ZConesSortedByDimension
Definition tropicalVarietyOfPolynomials.h:27

## raysOfTropicalStar()

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

Definition at line 243 of file tropicalCurves.cc.

{
ZConesSortedByDimension C = tropicalStar(I,r,u,currentStrategy);
// gfan::ZFan* zf = toFanStar(C);
// std::cout << zf->toString();
// delete zf;
gfan::ZMatrix raysOfC(0,u.size());
if (!currentStrategy->restrictToLowerHalfSpace())
{
for (ZConesSortedByDimension::iterator zc=C.begin(); zc!=C.end(); zc++)
{
assume(zc->dimensionOfLinealitySpace()+1 >= zc->dimension());
if (zc->dimensionOfLinealitySpace()+1 >= zc->dimension())
raysOfC.appendRow(zc->getRelativeInteriorPoint());
else
{
gfan::ZVector interiorPoint = zc->getRelativeInteriorPoint();
if (!currentStrategy->homogeneitySpaceContains(interiorPoint))
{
raysOfC.appendRow(interiorPoint);
raysOfC.appendRow(currentStrategy->negateWeight(interiorPoint));
}
else
{
gfan::ZMatrix zm = zc->generatorsOfLinealitySpace();
for (int i=0; i<zm.getHeight(); i++)
{
gfan::ZVector point = zm[i];
if (currentStrategy->homogeneitySpaceContains(point))
{
raysOfC.appendRow(point);
raysOfC.appendRow(currentStrategy->negateWeight(point));
break;
}
}
}
}
}
}
else
{
for (ZConesSortedByDimension::iterator zc=C.begin(); zc!=C.end(); zc++)
{
assume(zc->dimensionOfLinealitySpace()+2 >= zc->dimension());
if (zc->dimensionOfLinealitySpace()+2 == zc->dimension())
raysOfC.appendRow(zc->getRelativeInteriorPoint());
else
{
gfan::ZVector interiorPoint = zc->getRelativeInteriorPoint();
if (!currentStrategy->homogeneitySpaceContains(interiorPoint))
{
raysOfC.appendRow(interiorPoint);
raysOfC.appendRow(currentStrategy->negateWeight(interiorPoint));
}
else
{
gfan::ZMatrix zm = zc->generatorsOfLinealitySpace();
for (int i=0; i<zm.getHeight(); i++)
{
gfan::ZVector point = zm[i];
if (currentStrategy->homogeneitySpaceContains(point))
{
raysOfC.appendRow(point);
raysOfC.appendRow(currentStrategy->negateWeight(point));
break;
}
}
}
}
}
}
return raysOfC;
}
i
int i
Definition cfEzgcd.cc:132
tropicalStrategy::homogeneitySpaceContains
bool homogeneitySpaceContains(const gfan::ZVector &v) const
returns true, if v is contained in the homogeneity space; false otherwise
Definition tropicalStrategy.h:230
tropicalStrategy::negateWeight
gfan::ZVector negateWeight(const gfan::ZVector &w) const
Definition tropicalStrategy.h:263
tropicalStrategy::restrictToLowerHalfSpace
bool restrictToLowerHalfSpace() const
returns true, if valuation non-trivial, false otherwise
Definition tropicalStrategy.h:238
assume
#define assume(x)
Definition mod2.h:389
tropicalStar
ZConesSortedByDimension tropicalStar(ideal inI, const ring r, const gfan::ZVector &u, const tropicalStrategy *currentStrategy)
Definition tropicalCurves.cc:107

## tropicalStar()

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

Definition at line 107 of file tropicalCurves.cc.

{
int k = IDELEMS(inI);
int d = currentStrategy->getExpectedDimension();
/* Compute the common refinement over all tropical varieties
* of the polynomials in the generating set */
ZConesSortedByDimension C = tropicalVarietySortedByDimension(inI->m[0],r,currentStrategy);
int PayneOsserman = rVar(r)-1;
for (int i=0; i<k; i++)
{
if(inI->m[i]!=NULL)
{
PayneOsserman--;
C = intersect(C,tropicalVarietySortedByDimension(inI->m[i],r,currentStrategy),si_max(PayneOsserman,d));
}
}
/* Cycle through all maximal cones of the refinement.
* Pick a monomial ordering corresponding to a generic weight vector in it
* and check if the initial ideal is monomial free, generic meaning
* that it lies in a maximal Groebner cone in the maximal cone of the refinement.
* If the initial ideal is not monomial free, compute a witness for the monomial
* and compute the common refinement with its tropical variety.
* If all initial ideals are monomial free, then we have our tropical curve */
// gfan::ZFan* zf = toFanStar(C);
// std::cout << zf->toString(2+4+8+128) << std::endl;
// delete zf;
for (std::set<gfan::ZCone>::iterator zc=C.begin(); zc!=C.end();)
{
gfan::ZVector w = zc->getRelativeInteriorPoint();
gfan::ZMatrix W = zc->generatorsOfSpan();
// std::cout << zc->extremeRays() << std::endl;
ring s = genericlyWeightedOrdering(r,u,w,W,currentStrategy);
nMapFunc identity = n_SetMap(r->cf,s->cf);
ideal inIs = idInit(k);
for (int j=0; j<k; j++)
inIs->m[j] = p_PermPoly(inI->m[j],NULL,r,s,identity,NULL,0);
ideal inIsSTD = gfanlib_kStd_wrapper(inIs,s,isHomog);
id_Delete(&inIs,s);
ideal ininIs = initial(inIsSTD,s,w,W);
std::pair<poly,int> mons = currentStrategy->checkInitialIdealForMonomial(ininIs,s);
if (mons.first!=NULL)
{
poly gs;
if (mons.second>=0)
// cheap way out, ininIsSTD already contains a monomial in its generators
gs = inIsSTD->m[mons.second];
else
// compute witness
gs = witness(mons.first,inIsSTD,ininIs,s);
C = intersect(C,tropicalVarietySortedByDimension(gs,s,currentStrategy),d);
nMapFunc mMap = n_SetMap(s->cf,r->cf);
poly gr = p_PermPoly(gs,NULL,s,r,mMap,NULL,0);
idInsertPoly(inI,gr);
k++;
if (mons.second<0)
{
// if necessary, cleanup mons and gs
p_Delete(&mons.first,s);
p_Delete(&gs,s);
}
// cleanup rest, reset zc
id_Delete(&inIsSTD,s);
id_Delete(&ininIs,s);
rDelete(s);
zc = C.begin();
}
else
{
// cleanup remaining data of first stage
id_Delete(&inIsSTD,s);
id_Delete(&ininIs,s);
rDelete(s);
gfan::ZVector wNeg = currentStrategy->negateWeight(w);
if (zc->contains(wNeg))
{
s = genericlyWeightedOrdering(r,u,wNeg,W,currentStrategy);
identity = n_SetMap(r->cf,s->cf);
inIs = idInit(k);
for (int j=0; j<k; j++)
inIs->m[j] = p_PermPoly(inI->m[j],NULL,r,s,identity,NULL,0);
inIsSTD = gfanlib_kStd_wrapper(inIs,s,isHomog);
id_Delete(&inIs,s);
ininIs = initial(inIsSTD,s,wNeg,W);
mons = currentStrategy->checkInitialIdealForMonomial(ininIs,s);
if (mons.first!=NULL)
{
poly gs;
if (mons.second>=0)
// cheap way out, ininIsSTD already contains a monomial in its generators
gs = inIsSTD->m[mons.second];
else
// compute witness
gs = witness(mons.first,inIsSTD,ininIs,s);
C = intersect(C,tropicalVarietySortedByDimension(gs,s,currentStrategy),d);
nMapFunc mMap = n_SetMap(s->cf,r->cf);
poly gr = p_PermPoly(gs,NULL,s,r,mMap,NULL,0);
idInsertPoly(inI,gr);
k++;
if (mons.second<0)
{
// if necessary, cleanup mons and gs
p_Delete(&mons.first,s);
p_Delete(&gs,s);
}
// reset zc
zc = C.begin();
}
else
zc++;
// cleanup remaining data of second stage
id_Delete(&inIsSTD,s);
id_Delete(&ininIs,s);
rDelete(s);
}
else
zc++;
}
}
return C;
}
si_max
static int si_max(const int a, const int b)
Definition auxiliary.h:125
k
int k
Definition cfEzgcd.cc:99
tropicalStrategy::getExpectedDimension
int getExpectedDimension() const
returns the expected Dimension of the polyhedral output
Definition tropicalStrategy.h:199
tropicalStrategy::checkInitialIdealForMonomial
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...
Definition tropicalStrategy.cc:494
n_SetMap
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:703
nMapFunc
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition coeffs.h:80
idInsertPoly
BOOLEAN idInsertPoly(ideal h1, poly h2)
insert h2 into h1 (if h2 is not the zero polynomial) return TRUE iff h2 was indeed inserted
Definition simpleideals.cc:832
initial
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
NULL
#define NULL
Definition omList.c:12
p_PermPoly
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:4256
p_Delete
static void p_Delete(poly *p, const ring r)
Definition p_polys.h:903
rDelete
void rDelete(ring r)
unconditionally deletes fields in r
Definition ring.cc:454
idInit
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition simpleideals.cc:35
id_Delete
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
Definition simpleideals.cc:123
IDELEMS
#define IDELEMS(i)
Definition simpleideals.h:23
gfanlib_kStd_wrapper
ideal gfanlib_kStd_wrapper(ideal I, ring r, tHomog h=testHomog)
Definition std_wrapper.cc:6
isHomog
@ isHomog
Definition structs.h:33
intersect
static ZConesSortedByDimension intersect(const ZConesSortedByDimension &setA, const ZConesSortedByDimension &setB, int d=0)
Definition tropicalCurves.cc:18
genericlyWeightedOrdering
static ring genericlyWeightedOrdering(const ring r, const gfan::ZVector &u, const gfan::ZVector &w, const gfan::ZMatrix &W, const tropicalStrategy *currentStrategy)
Definition tropicalCurves.cc:49
tropicalVarietySortedByDimension
ZConesSortedByDimension tropicalVarietySortedByDimension(const poly g, const ring r, const tropicalStrategy *currentCase)
Definition tropicalVarietyOfPolynomials.cc:62
witness
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