Changeset 551009 in git


Ignore:
Timestamp:
Feb 1, 2015, 2:29:36 PM (9 years ago)
Author:
Yue Ren <ren@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', '3a4bc649f1d0185cc9f8b122bd75f21f75ac9c9a')
Children:
670e639535c5bd70580255e59bdb06627c71b9f1
Parents:
ff48aac293b5ce716bc796167bee1af9044d6942
git-author:
Yue Ren <ren@mathematik.uni-kl.de>2015-02-01 14:29:36+01:00
git-committer:
Yue Ren <ren@mathematik.uni-kl.de>2015-02-06 13:47:06+01:00
Message:
new: tropicalTraversalMinimizingFlips
Location:
Singular/dyn_modules/gfanlib
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • Singular/dyn_modules/gfanlib/adjustWeights.cc

    rff48aa r551009  
    22#include <kernel/mod2.h>
    33
    4 static bool checkForNonPositiveEntries(const gfan::ZVector w)
     4static bool checkForNonPositiveEntries(const gfan::ZVector &w)
    55{
    66  for (unsigned i=0; i<w.size(); i++)
     
    1616}
    1717
    18 static bool checkForNonPositiveLaterEntries(const gfan::ZVector w)
     18static bool checkForNonPositiveLaterEntries(const gfan::ZVector &w)
    1919{
    2020  // if (w[0].sign()<0)
     
    4242 * if and only if it is homogeneous with respect to w.
    4343 **/
    44 gfan::ZVector nonvalued_adjustWeightForHomogeneity(const gfan::ZVector w)
     44gfan::ZVector nonvalued_adjustWeightForHomogeneity(const gfan::ZVector &w)
    4545{
    4646  /* find the smallest entry min of w */
     
    6060}
    6161
    62 gfan::ZVector valued_adjustWeightForHomogeneity(const gfan::ZVector w)
     62gfan::ZVector valued_adjustWeightForHomogeneity(const gfan::ZVector &w)
    6363{
    6464  /* find the biggest entry max of w
     
    8181 * w containing only positive weights
    8282 **/
    83 gfan::ZVector nonvalued_adjustWeightUnderHomogeneity(const gfan::ZVector e, const gfan::ZVector w)
     83gfan::ZVector nonvalued_adjustWeightUnderHomogeneity(const gfan::ZVector &e, const gfan::ZVector &w)
    8484{
    8585  assume(checkForNonPositiveEntries(w));
     
    107107}
    108108
    109 gfan::ZVector valued_adjustWeightUnderHomogeneity(const gfan::ZVector e, const gfan::ZVector w)
     109gfan::ZVector valued_adjustWeightUnderHomogeneity(const gfan::ZVector &e, const gfan::ZVector &w)
    110110{
    111111  // assume(checkForNonPositiveLaterEntries(w));
  • Singular/dyn_modules/gfanlib/adjustWeights.h

    rff48aa r551009  
    44#include <gfanlib/gfanlib_vector.h>
    55
    6 gfan::ZVector nonvalued_adjustWeightForHomogeneity(const gfan::ZVector w);
    7 gfan::ZVector valued_adjustWeightForHomogeneity(const gfan::ZVector w);
    8 gfan::ZVector nonvalued_adjustWeightUnderHomogeneity(const gfan::ZVector e, const gfan::ZVector w);
    9 gfan::ZVector valued_adjustWeightUnderHomogeneity(const gfan::ZVector e, const gfan::ZVector w);
     6gfan::ZVector nonvalued_adjustWeightForHomogeneity(const gfan::ZVector &w);
     7gfan::ZVector valued_adjustWeightForHomogeneity(const gfan::ZVector &w);
     8gfan::ZVector nonvalued_adjustWeightUnderHomogeneity(const gfan::ZVector &e, const gfan::ZVector &w);
     9gfan::ZVector valued_adjustWeightUnderHomogeneity(const gfan::ZVector &e, const gfan::ZVector &w);
    1010
    1111#endif
  • Singular/dyn_modules/gfanlib/bbcone.cc

    rff48aa r551009  
    16181618
    16191619
    1620 BOOLEAN memleaktest(leftv res, leftv args)
    1621 {
    1622   bigintmat* ineq = NULL;
    1623   if (args->Typ() == INTMAT_CMD)
    1624   {
    1625     intvec* ineq0 = (intvec*) args->Data();
    1626     ineq = iv2bim(ineq0,coeffs_BIGINT);
    1627   }
    1628   else
    1629     ineq = (bigintmat*) args->Data();
    1630   gfan::ZMatrix* zm = bigintmatToZMatrix(ineq);
    1631   gfan::ZCone* zc = new gfan::ZCone(*zm, gfan::ZMatrix(0, zm->getWidth()));
    1632   delete zm;
    1633   if (args->Typ() == INTMAT_CMD)
    1634     delete ineq;
    1635   res->rtyp = coneID;
    1636   res->data = (void*) zc;
    1637   return FALSE;
     1620/***
     1621 * Computes a relative interior point for each facet of zc
     1622 **/
     1623gfan::ZMatrix interiorPointsOfFacets(const gfan::ZCone zc)
     1624{
     1625  gfan::ZMatrix inequalities = zc.getFacets();
     1626  gfan::ZMatrix equations = zc.getImpliedEquations();
     1627  int r = inequalities.getHeight();
     1628  int c = inequalities.getWidth();
     1629
     1630  /* our cone has r facets, if r==0 return empty matrices */
     1631  gfan::ZMatrix relativeInteriorPoints = gfan::ZMatrix(0,c);
     1632  if (r==0) return relativeInteriorPoints;
     1633
     1634  /* next we iterate over each of the r facets,
     1635   * build the respective cone and add it to the list
     1636   * this is the i=0 case */
     1637  gfan::ZMatrix newInequalities = inequalities.submatrix(1,0,r,c);
     1638  gfan::ZMatrix newEquations = equations;
     1639  newEquations.appendRow(inequalities[0]);
     1640  gfan::ZCone facet = gfan::ZCone(newInequalities,newEquations);
     1641  relativeInteriorPoints.appendRow(facet.getRelativeInteriorPoint());
     1642
     1643  /* these are the cases i=1,...,r-2 */
     1644  for (int i=1; i<r-1; i++)
     1645  {
     1646    newInequalities = inequalities.submatrix(0,0,i,c);
     1647    newInequalities.append(inequalities.submatrix(i+1,0,r,c));
     1648    newEquations = equations;
     1649    newEquations.appendRow(inequalities[i]);
     1650    facet = gfan::ZCone(newInequalities,newEquations);
     1651    relativeInteriorPoints.appendRow(facet.getRelativeInteriorPoint());
     1652  }
     1653
     1654  /* this is the i=r-1 case */
     1655  newInequalities = inequalities.submatrix(0,0,r-1,c);
     1656  newEquations = equations;
     1657  newEquations.appendRow(inequalities[r-1]);
     1658  facet = gfan::ZCone(newInequalities,newEquations);
     1659  relativeInteriorPoints.appendRow(facet.getRelativeInteriorPoint());
     1660
     1661  return relativeInteriorPoints;
    16381662}
    16391663
     
    16931717  p->iiAddCproc("","listOfFacets",FALSE,listOfFacets);
    16941718  p->iiAddCproc("","facetContaining",FALSE,facetContaining);
    1695   p->iiAddCproc("","memleaktest",FALSE,memleaktest);
    16961719  coneID=setBlackboxStuff(b,"cone");
    16971720}
  • Singular/dyn_modules/gfanlib/bbcone.h

    rff48aa r551009  
    2020gfan::ZVector randomPoint(const gfan::ZCone* zc);
    2121gfan::ZCone liftUp(const gfan::ZCone &zc);
     22gfan::ZMatrix interiorPointsOfFacets(const gfan::ZCone zc);
    2223
    2324#endif
  • Singular/dyn_modules/gfanlib/groebnerCone.cc

    rff48aa r551009  
    2222#include <bbcone.h>
    2323
     24#ifndef NDEBUG
    2425static bool checkPolynomialInput(const ideal I, const ring r)
    2526{
     
    5657  return zc.containsRelatively(p);
    5758}
     59
     60static bool checkOrderingAndWeight(const ideal I, const ring r, const gfan::ZVector w, const tropicalStrategy& currentCase)
     61{
     62  groebnerCone sigma(I,r,currentCase);
     63  gfan::ZCone zc = sigma.getPolyhedralCone();
     64  return zc.contains(w);
     65}
     66
     67bool groebnerCone::checkFlipConeInput(const gfan::ZVector interiorPoint, const gfan::ZVector facetNormal) const
     68{
     69  /* check first whether interiorPoint lies on the boundary of the cone */
     70  if (!polyhedralCone.contains(interiorPoint))
     71  {
     72    std::cout << "ERROR: interiorPoint is not contained in the Groebner cone!" << std::endl
     73              << "cone: " << std::endl
     74              << toString(&polyhedralCone)
     75              << "interiorPoint:" << std::endl
     76              << interiorPoint << std::endl;
     77    return false;
     78  }
     79  if (polyhedralCone.containsRelatively(interiorPoint))
     80  {
     81    std::cout << "ERROR: interiorPoint is contained in the interior of the maximal Groebner cone!" << std::endl
     82              << "cone: " << std::endl
     83              << toString(&polyhedralCone)
     84              << "interiorPoint:" << std::endl
     85              << interiorPoint << std::endl;
     86    return false;
     87  }
     88  gfan::ZCone hopefullyAFacet = polyhedralCone.faceContaining(interiorPoint);
     89  if (hopefullyAFacet.dimension()!=(polyhedralCone.dimension()-1))
     90  {
     91    std::cout << "ERROR: interiorPoint is not contained in the interior of a facet!" << std::endl
     92              << "cone: " << std::endl
     93              << toString(&polyhedralCone)
     94              << "interiorPoint:" << std::endl
     95              << interiorPoint << std::endl;
     96    return false;
     97  }
     98  /* check whether facet normal points outwards */
     99  gfan::ZCone dual = polyhedralCone.dualCone();
     100  if(dual.contains(facetNormal))
     101  {
     102    std::cout << "ERROR: facetNormal is not pointing outwards!" << std::endl
     103              << "cone: " << std::endl
     104              << toString(&polyhedralCone)
     105              << "facetNormal:" << std::endl
     106              << facetNormal << std::endl;
     107    return false;
     108  }
     109  return true;
     110}
     111#endif //NDEBUG
    58112
    59113groebnerCone::groebnerCone():
     
    116170  assume(checkOrderingAndCone(polynomialRing,polyhedralCone));
    117171  id_Delete(&redI,polynomialRing);
    118 }
    119 
    120 static bool checkOrderingAndWeight(const ideal I, const ring r, const gfan::ZVector w, const tropicalStrategy& currentCase)
    121 {
    122   groebnerCone sigma(I,r,currentCase);
    123   gfan::ZCone zc = sigma.getPolyhedralCone();
    124   return zc.contains(w);
    125172}
    126173
     
    334381}
    335382
     383/**
     384 * Returns true if Groebner cone contains w, false otherwise
     385 */
     386bool groebnerCone::contains(const gfan::ZVector &w) const
     387{
     388  return polyhedralCone.contains(w);
     389}
     390
    336391
    337392/***
     
    362417}
    363418
    364 bool groebnerCone::checkFlipConeInput(const gfan::ZVector interiorPoint, const gfan::ZVector facetNormal) const
    365 {
    366   /* check first whether interiorPoint lies on the boundary of the cone */
    367   if (!polyhedralCone.contains(interiorPoint))
    368   {
    369     std::cout << "ERROR: interiorPoint is not contained in the Groebner cone!" << std::endl
    370               << "cone: " << std::endl
    371               << toString(&polyhedralCone)
    372               << "interiorPoint:" << std::endl
    373               << interiorPoint << std::endl;
    374     return false;
    375   }
    376   if (polyhedralCone.containsRelatively(interiorPoint))
    377   {
    378     std::cout << "ERROR: interiorPoint is contained in the interior of the maximal Groebner cone!" << std::endl
    379               << "cone: " << std::endl
    380               << toString(&polyhedralCone)
    381               << "interiorPoint:" << std::endl
    382               << interiorPoint << std::endl;
    383     return false;
    384   }
    385   gfan::ZCone hopefullyAFacet = polyhedralCone.faceContaining(interiorPoint);
    386   if (hopefullyAFacet.dimension()!=(polyhedralCone.dimension()-1))
    387   {
    388     std::cout << "ERROR: interiorPoint is not contained in the interior of a facet!" << std::endl
    389               << "cone: " << std::endl
    390               << toString(&polyhedralCone)
    391               << "interiorPoint:" << std::endl
    392               << interiorPoint << std::endl;
    393     return false;
    394   }
    395   /* check whether facet normal points outwards */
    396   gfan::ZCone dual = polyhedralCone.dualCone();
    397   if(dual.contains(facetNormal))
    398   {
    399     std::cout << "ERROR: facetNormal is not pointing outwards!" << std::endl
    400               << "cone: " << std::endl
    401               << toString(&polyhedralCone)
    402               << "facetNormal:" << std::endl
    403               << facetNormal << std::endl;
    404     return false;
    405   }
    406   return true;
    407 }
    408 
    409419/**
    410420 * Given an interior point on the facet and the outer normal factor on the facet,
    411421 * returns the adjacent groebnerCone sharing that facet
    412422 */
    413 groebnerCone groebnerCone::flipCone(const gfan::ZVector interiorPoint, const gfan::ZVector facetNormal) const
     423groebnerCone groebnerCone::flipCone(const gfan::ZVector &interiorPoint, const gfan::ZVector &facetNormal) const
    414424{
    415425  assume(this->checkFlipConeInput(interiorPoint,facetNormal));
     
    508518
    509519
    510 /***
    511  * Computes a relative interior point for each facet of zc
    512  **/
    513 static gfan::ZMatrix interiorPointsOfFacets(const gfan::ZCone zc)
    514 {
    515   gfan::ZMatrix inequalities = zc.getFacets();
    516   gfan::ZMatrix equations = zc.getImpliedEquations();
    517   int r = inequalities.getHeight();
    518   int c = inequalities.getWidth();
    519 
    520   /* our cone has r facets, if r==0 return empty matrices */
    521   gfan::ZMatrix relativeInteriorPoints = gfan::ZMatrix(0,c);
    522   if (r==0) return relativeInteriorPoints;
    523 
    524   /* next we iterate over each of the r facets,
    525    * build the respective cone and add it to the list
    526    * this is the i=0 case */
    527   gfan::ZMatrix newInequalities = inequalities.submatrix(1,0,r,c);
    528   gfan::ZMatrix newEquations = equations;
    529   newEquations.appendRow(inequalities[0]);
    530   gfan::ZCone facet = gfan::ZCone(newInequalities,newEquations);
    531   relativeInteriorPoints.appendRow(facet.getRelativeInteriorPoint());
    532 
    533   /* these are the cases i=1,...,r-2 */
    534   for (int i=1; i<r-1; i++)
    535   {
    536     newInequalities = inequalities.submatrix(0,0,i,c);
    537     newInequalities.append(inequalities.submatrix(i+1,0,r,c));
    538     newEquations = equations;
    539     newEquations.appendRow(inequalities[i]);
    540     facet = gfan::ZCone(newInequalities,newEquations);
    541     relativeInteriorPoints.appendRow(facet.getRelativeInteriorPoint());
    542   }
    543 
    544   /* this is the i=r-1 case */
    545   newInequalities = inequalities.submatrix(0,0,r-1,c);
    546   newEquations = equations;
    547   newEquations.appendRow(inequalities[r-1]);
    548   facet = gfan::ZCone(newInequalities,newEquations);
    549   relativeInteriorPoints.appendRow(facet.getRelativeInteriorPoint());
    550 
    551   return relativeInteriorPoints;
    552 }
    553 
    554 
    555520bool groebnerCone::pointsOutwards(const gfan::ZVector w) const
    556521{
     
    572537    {
    573538      ideal initialIdeal = initial(polynomialIdeal,polynomialRing,interiorPoints[i]);
    574       gfan::ZMatrix ray = raysOfTropicalStar(initialIdeal,polynomialRing,interiorPoints[i],*currentStrategy);
     539      gfan::ZMatrix ray = raysOfTropicalStar(initialIdeal,polynomialRing,interiorPoints[i],currentStrategy);
    575540      for (int j=0; j<ray.getHeight(); j++)
    576541        if (pointsOutwards(ray[j]))
  • Singular/dyn_modules/gfanlib/groebnerCone.h

    rff48aa r551009  
    5252  groebnerCone& operator=(const groebnerCone& sigma);
    5353
    54   void deletePolynomialIdeal()
     54  void deletePolynomialData()
    5555  {
    5656    assume ((!polynomialIdeal) || (polynomialIdeal && polynomialRing));
    5757    if (polynomialIdeal) id_Delete(&polynomialIdeal,polynomialRing);
    58   }
    59 
    60   void deletePolynomialRing()
    61   {
    62     assume ((!polynomialIdeal) || (polynomialIdeal && polynomialRing));
    6358    if (polynomialRing) rDelete(polynomialRing);
    64     polynomialRing = NULL;
     59    polynomialIdeal = NULL;
    6560  }
    6661
     
    7065  gfan::ZVector getInteriorPoint() const { return interiorPoint; };
    7166  const tropicalStrategy* getTropicalStrategy() const {return currentStrategy; };
    72 
    7367  friend struct groebnerCone_compare;
    7468
    75   /***
     69  /**
     70   * Returns true if Groebner cone contains w, false otherwise
     71   */
     72  bool contains(const gfan::ZVector &w) const;
     73
     74  /**
    7675   * Returns a point in the tropical variety, if the groebnerCone contains one.
    7776   * Returns an empty vector otherwise.
    78    **/
     77   */
    7978  gfan::ZVector tropicalPoint() const;
    8079
    81   /***
     80  /**
    8281   * Given an interior point on the facet and the outer normal factor on the facet,
    8382   * returns the adjacent groebnerCone sharing that facet
    84    **/
     83   */
     84  groebnerCone flipCone(const gfan::ZVector &interiorPoint, const gfan::ZVector &facetNormal) const;
     85
     86  /**
     87   * Returns a complete list of neighboring Groebner cones.
     88   */
     89  groebnerCones groebnerNeighbours() const;
     90
     91  /**
     92   * Returns a complete list of neighboring Groebner cones in the tropical variety.
     93   */
     94  groebnerCones tropicalNeighbours() const;
     95
     96  /**
     97   * Debug tools.
     98   */
     99  #ifndef NDEBUG
    85100  bool checkFlipConeInput(const gfan::ZVector interiorPoint, const gfan::ZVector facetNormal) const;
    86101  bool pointsOutwards(const gfan::ZVector) const;
    87   groebnerCone flipCone(const gfan::ZVector interiorPoint, const gfan::ZVector facetNormal) const;
    88 
    89   /***
    90    * Returns a complete list of neighboring Groebner cones.
    91    **/
    92   groebnerCones groebnerNeighbours() const;
    93 
    94   /***
    95    * Returns a complete list of neighboring Groebner cones in the tropical variety.
    96    **/
    97   groebnerCones tropicalNeighbours() const;
     102  #endif
    98103};
    99104
  • Singular/dyn_modules/gfanlib/startingCone.cc

    rff48aa r551009  
    170170      tropicalStrategy currentStrategy(I,currRing);
    171171      poly g = I->m[0];
    172       std::set<gfan::ZCone> Tg = tropicalVariety(g,currRing,currentStrategy);
     172      std::set<gfan::ZCone> Tg = tropicalVariety(g,currRing,&currentStrategy);
    173173      for (std::set<gfan::ZCone>::iterator zc=Tg.begin(); zc!=Tg.end(); zc++)
    174174      {
     
    205205      tropicalStrategy currentStrategy(I,currRing);
    206206      poly g = I->m[0];
    207       std::set<gfan::ZCone> Tg = tropicalVariety(g,currRing,currentStrategy);
     207      std::set<gfan::ZCone> Tg = tropicalVariety(g,currRing,&currentStrategy);
    208208      for (std::set<gfan::ZCone>::iterator zc=Tg.begin(); zc!=Tg.end(); zc++)
    209209      {
     
    240240      tropicalStrategy currentStrategy(I,currRing);
    241241      poly g = I->m[0];
    242       std::set<gfan::ZCone> Tg = tropicalVariety(g,currRing,currentStrategy);
     242      std::set<gfan::ZCone> Tg = tropicalVariety(g,currRing,&currentStrategy);
    243243      for (std::set<gfan::ZCone>::iterator zc=Tg.begin(); zc!=Tg.end(); zc++)
    244244      {
     
    276276      tropicalStrategy currentStrategy(I,currRing);
    277277      poly g = I->m[0];
    278       std::set<gfan::ZCone> Tg = tropicalVariety(g,currRing,currentStrategy);
     278      std::set<gfan::ZCone> Tg = tropicalVariety(g,currRing,&currentStrategy);
    279279      for (std::set<gfan::ZCone>::iterator zc=Tg.begin(); zc!=Tg.end(); zc++)
    280280      {
     
    312312    {
    313313      poly g = I->m[0];
    314       std::set<gfan::ZCone> Tg = tropicalVariety(g,currRing,currentStrategy);
     314      std::set<gfan::ZCone> Tg = tropicalVariety(g,currRing,&currentStrategy);
    315315      if (Tg.empty())
    316316      {
  • Singular/dyn_modules/gfanlib/tropicalCurves.cc

    rff48aa r551009  
    5151 * and it lies in a Groebner cone of dimension at least rank(E)=dim(A).
    5252 **/
    53 static ring genericlyWeightedOrdering(const ring r, const gfan::ZVector u, const gfan::ZVector w,
    54                                       const gfan::ZMatrix W, const tropicalStrategy& currentStrategy)
     53static ring genericlyWeightedOrdering(const ring r, const gfan::ZVector &u, const gfan::ZVector &w,
     54                                      const gfan::ZMatrix &W, const tropicalStrategy* currentStrategy)
    5555{
    5656  int n = rVar(r);
     
    7474  s->block0[0] = 1;
    7575  s->block1[0] = n;
    76   gfan::ZVector uAdjusted = currentStrategy.adjustWeightForHomogeneity(u);
     76  gfan::ZVector uAdjusted = currentStrategy->adjustWeightForHomogeneity(u);
    7777  s->wvhdl[0] = ZVectorToIntStar(uAdjusted,overflow);
    7878  s->order[1] = ringorder_a;
    7979  s->block0[1] = 1;
    8080  s->block1[1] = n;
    81   gfan::ZVector wAdjusted = currentStrategy.adjustWeightUnderHomogeneity(w,uAdjusted);
     81  gfan::ZVector wAdjusted = currentStrategy->adjustWeightUnderHomogeneity(w,uAdjusted);
    8282  s->wvhdl[1] = ZVectorToIntStar(wAdjusted,overflow);
    8383  for (int j=0; j<h-1; j++)
     
    8686    s->block0[j+2] = 1;
    8787    s->block1[j+2] = n;
    88     wAdjusted = currentStrategy.adjustWeightUnderHomogeneity(W[j],uAdjusted);
     88    wAdjusted = currentStrategy->adjustWeightUnderHomogeneity(W[j],uAdjusted);
    8989    s->wvhdl[j+2] = ZVectorToIntStar(wAdjusted,overflow);
    9090  }
     
    9292  s->block0[h+1] = 1;
    9393  s->block1[h+1] = n;
    94   wAdjusted = currentStrategy.adjustWeightUnderHomogeneity(W[h-1],uAdjusted);
     94  wAdjusted = currentStrategy->adjustWeightUnderHomogeneity(W[h-1],uAdjusted);
    9595  s->wvhdl[h+1] = ZVectorToIntStar(wAdjusted,overflow);
    9696  s->order[h+2] = ringorder_C;
     
    111111 * the initial ideal inI with respect to it, computes the star of the tropical variety in u.
    112112 **/
    113 std::set<gfan::ZCone> tropicalStar(ideal inI, const ring r, const gfan::ZVector u,
    114                                    const tropicalStrategy currentStrategy)
     113std::set<gfan::ZCone> tropicalStar(ideal &inI, const ring &r, const gfan::ZVector &u,
     114                                   const tropicalStrategy* currentStrategy)
    115115{
    116116  int k = idSize(inI);
    117   int d = currentStrategy.getExpectedDimension();
     117  int d = currentStrategy->getExpectedDimension();
    118118
    119119  /* Compute the common refinement over all tropical varieties
     
    148148    ideal ininIs = initial(inIsSTD,s,w,W);
    149149
    150     poly mons = currentStrategy.checkInitialIdealForMonomial(ininIs,s,w);
     150    poly mons = currentStrategy->checkInitialIdealForMonomial(ininIs,s,w);
    151151    if (mons)
    152152    {
     
    176176      rDelete(s);
    177177
    178       gfan::ZVector wNeg = currentStrategy.negateWeight(w);
     178      gfan::ZVector wNeg = currentStrategy->negateWeight(w);
    179179      if (zc->contains(wNeg))
    180180      {
     
    188188        ininIs = initial(inIsSTD,s,wNeg,W);
    189189
    190         mons = currentStrategy.checkInitialIdealForMonomial(ininIs,s,wNeg);
     190        mons = currentStrategy->checkInitialIdealForMonomial(ininIs,s,wNeg);
    191191        if (mons)
    192192        {
     
    219219
    220220
    221 gfan::ZMatrix raysOfTropicalStar(ideal I, const ring r, const gfan::ZVector u, const tropicalStrategy& currentStrategy)
     221gfan::ZMatrix raysOfTropicalStar(ideal I, const ring r, const gfan::ZVector u, const tropicalStrategy* currentStrategy)
    222222{
    223223  std::set<gfan::ZCone> C = tropicalStar(I,r,u,currentStrategy);
     
    226226  // delete zf;
    227227  gfan::ZMatrix raysOfC(0,u.size());
    228   if (!currentStrategy.restrictToLowerHalfSpace())
     228  if (!currentStrategy->restrictToLowerHalfSpace())
    229229  {
    230230    for (std::set<gfan::ZCone>::iterator zc=C.begin(); zc!=C.end(); zc++)
     
    266266      tropicalStrategy currentCase(inI,currRing);
    267267      gfan::ZVector* v = bigintmatToZVector(u);
    268       std::set<gfan::ZCone> C = tropicalStar(inI,currRing,*v,currentCase);
     268      std::set<gfan::ZCone> C = tropicalStar(inI,currRing,*v,&currentCase);
    269269      id_Delete(&inI,currRing);
    270270      delete u;
  • Singular/dyn_modules/gfanlib/tropicalCurves.h

    rff48aa r551009  
    88
    99std::set<gfan::ZCone> tropicalStar(const ideal I, const ring r, const gfan::ZVector u,
    10                                    const tropicalStrategy& currentStrategy);
     10                                   const tropicalStrategy* currentStrategy);
    1111gfan::ZMatrix raysOfTropicalStar(ideal I, const ring r, const gfan::ZVector u,
    12                                  const tropicalStrategy& currentStrategy);
     12                                 const tropicalStrategy* currentStrategy);
    1313
    1414#ifndef NDEBUG
  • Singular/dyn_modules/gfanlib/tropicalStrategy.h

    rff48aa r551009  
    8585   * if and only if it is homogeneous with respect to u
    8686   */
    87   gfan::ZVector (*weightAdjustingAlgorithm1) (gfan::ZVector w);
     87  gfan::ZVector (*weightAdjustingAlgorithm1) (const gfan::ZVector &w);
    8888  /**
    8989   * A function such that:
     
    9292   * with respect to w the weights u and v coincide
    9393   */
    94   gfan::ZVector (*weightAdjustingAlgorithm2) (gfan::ZVector v, gfan::ZVector w);
     94  gfan::ZVector (*weightAdjustingAlgorithm2) (const gfan::ZVector &v, const gfan::ZVector &w);
    9595  /**
    9696   * A function that reduces the generators of an ideal I so that
     
    266266    {
    267267      wNeg[0]=w[0];
    268       for (int i=1; i<w.size(); i++)
     268      for (unsigned i=1; i<w.size(); i++)
    269269        wNeg[i]=w[i];
    270270    }
  • Singular/dyn_modules/gfanlib/tropicalTraversal.cc

    rff48aa r551009  
     1#include <bbcone.h>
    12#include <groebnerCone.h>
     3#include <tropicalCurves.h>
     4
     5std::vector<bool> checkNecessaryFlips(const groebnerCones &tropicalVariety, const groebnerCones &workingList,
     6                                      const gfan::ZVector &interiorPoint, const gfan::ZMatrix &normalVectors)
     7{
     8  int k = normalVectors.getHeight();
     9  std::vector<bool> needToFlip(k,true);
     10
     11  int n = normalVectors.getWidth();
     12  gfan::ZMatrix testVectors(k,n);
     13  gfan::ZVector bigInteriorPoint = 1000*interiorPoint;
     14  for (int i=0; i<k; i++)
     15    testVectors[i] = bigInteriorPoint+normalVectors[i];
     16
     17  for (groebnerCones::iterator sigma = tropicalVariety.begin(); sigma!=tropicalVariety.end(); sigma++)
     18  {
     19    if (sigma->contains(interiorPoint))
     20    {
     21      for (int i=0; i<k; i++)
     22      {
     23        if (needToFlip[i] && sigma->contains(testVectors[i]))
     24          needToFlip[i] = false;
     25      }
     26    }
     27  }
     28
     29  for (groebnerCones::iterator sigma = workingList.begin(); sigma!=workingList.end(); sigma++)
     30  {
     31    if (sigma->contains(interiorPoint))
     32    {
     33      for (int i=0; i<k; i++)
     34      {
     35        if (needToFlip[i] && sigma->contains(testVectors[i]))
     36          needToFlip[i] = false;
     37      }
     38    }
     39  }
     40
     41  return needToFlip;
     42}
     43
     44groebnerCones tropicalTraversalMinimizingFlips(const groebnerCone startingCone)
     45{
     46  groebnerCones tropicalVariety;
     47  groebnerCones workingList;
     48  workingList.insert(startingCone);
     49  const tropicalStrategy* currentStrategy=startingCone.getTropicalStrategy();
     50  while(!workingList.empty())
     51  {
     52    // std::cout << "starting traversal" << std::endl;
     53    /**
     54     * Pick an element the working list and compute interior points on its facets
     55     */
     56    groebnerCone sigma=*(workingList.begin());
     57    gfan::ZMatrix interiorPoints = interiorPointsOfFacets(sigma.getPolyhedralCone());
     58
     59    for (int i=0; i<interiorPoints.getHeight(); i++)
     60    {
     61      /**
     62       * For each interior point, compute the rays of the tropical star in that point
     63       */
     64      gfan::ZVector interiorPoint = interiorPoints[i];
     65      if (!(currentStrategy->restrictToLowerHalfSpace() && interiorPoint[0].sign()==0))
     66      {
     67        ideal inI = initial(sigma.getPolynomialIdeal(),sigma.getPolynomialRing(),interiorPoint);
     68        gfan::ZMatrix normalVectors = raysOfTropicalStar(inI,
     69                                                         sigma.getPolynomialRing(),
     70                                                         interiorPoint,
     71                                                         sigma.getTropicalStrategy());
     72        id_Delete(&inI,sigma.getPolynomialRing());
     73
     74        std::vector<bool> needToFlip = checkNecessaryFlips(tropicalVariety,workingList,interiorPoint,normalVectors);
     75        for (int j=0; j<normalVectors.getHeight(); j++)
     76        {
     77          if (needToFlip[j])
     78          {
     79            groebnerCone neighbour = sigma.flipCone(interiorPoint,normalVectors[j]);
     80            workingList.insert(neighbour);
     81          }
     82        }
     83      }
     84    }
     85
     86    sigma.deletePolynomialData();
     87    workingList.erase(sigma);
     88    tropicalVariety.insert(sigma);
     89    // std::cout << "tropicalVariety.size():" << tropicalVariety.size() << std::endl;
     90    // std::cout << "workingList.size():" << workingList.size() << std::endl;
     91  }
     92  return tropicalVariety;
     93}
    294
    395groebnerCones tropicalTraversal(const groebnerCone startingCone)
  • Singular/dyn_modules/gfanlib/tropicalTraversal.h

    rff48aa r551009  
    22#define TROPICAL_TRAVERSAL_H
    33
     4groebnerCones tropicalTraversalMinimizingFlips(const groebnerCone startingCone);
    45groebnerCones tropicalTraversal(const groebnerCone startingCone);
    56
  • Singular/dyn_modules/gfanlib/tropicalVariety.cc

    rff48aa r551009  
    5454      {
    5555        tropicalStrategy currentStrategy(I,currRing);
    56         std::set<gfan::ZCone> maxCones = tropicalVariety(g,currRing,currentStrategy);
     56        std::set<gfan::ZCone> maxCones = tropicalVariety(g,currRing,&currentStrategy);
    5757        // gfan::ZFan* zf = toZFan(maxCones);
    5858        // delete zf;
     
    7979        ring startingRing = currentStrategy.getStartingRing();
    8080        poly gStart = startingIdeal->m[0];
    81         std::set<gfan::ZCone> maxCones = tropicalVariety(gStart,startingRing,currentStrategy);
     81        std::set<gfan::ZCone> maxCones = tropicalVariety(gStart,startingRing,&currentStrategy);
    8282        res->rtyp = fanID;
    8383        res->data = (char*) toZFan(maxCones);
  • Singular/dyn_modules/gfanlib/tropicalVarietyOfIdeals.cc

    rff48aa r551009  
    66{
    77  groebnerCone startingCone = tropicalStartingCone(currentStrategy);
    8   groebnerCones tropicalVariety = tropicalTraversal(startingCone);
     8  groebnerCones tropicalVariety = tropicalTraversalMinimizingFlips(startingCone);
    99  return toFanStar(tropicalVariety);
    1010}
  • Singular/dyn_modules/gfanlib/tropicalVarietyOfPolynomials.cc

    rff48aa r551009  
    1818 * i.e. g is either 0 or a non-zero monomial.
    1919 **/
    20 std::set<gfan::ZCone> tropicalVariety(const poly g, const ring r, const tropicalStrategy &currentCase)
     20std::set<gfan::ZCone> tropicalVariety(const poly g, const ring r, const tropicalStrategy* currentCase)
    2121{
    2222  int n = rVar(r);
     
    4444        equation.appendRow(exponents[i]-exponents[j]);
    4545        gfan::ZMatrix inequalities = gfan::ZMatrix(0,n);
    46         if (currentCase.restrictToLowerHalfSpace())
     46        if (currentCase->restrictToLowerHalfSpace())
    4747          inequalities.appendRow(lowerHalfSpaceCondition);
    4848        for (int k=0; k<l; k++)
  • Singular/dyn_modules/gfanlib/tropicalVarietyOfPolynomials.h

    rff48aa r551009  
    1313#endif
    1414
    15 std::set<gfan::ZCone> tropicalVariety(const poly g, const ring r, const tropicalStrategy &currentCase);
     15std::set<gfan::ZCone> tropicalVariety(const poly g, const ring r, const tropicalStrategy* currentCase);
    1616
    1717#ifndef NDEBUG
Note: See TracChangeset for help on using the changeset viewer.