Changeset 9abcc6 in git


Ignore:
Timestamp:
Mar 12, 2014, 9:08:50 AM (10 years ago)
Author:
Yue Ren <ren@…>
Branches:
(u'spielwiese', '8e0ad00ce244dfd0756200662572aef8402f13d5')
Children:
7aa26b206f76709abff0bab4adaac2dfc4ddb4ef
Parents:
c890142d6921b9d30b396af149a3df2fbc57981a
git-author:
Yue Ren <ren@mathematik.uni-kl.de>2014-03-12 10:08:50+02:00
git-committer:
Yue Ren <ren@mathematik.uni-kl.de>2015-02-06 13:47:03+01:00
Message:
status updated 11.03.
Files:
5 added
12 edited

Legend:

Unmodified
Added
Removed
  • Singular/dyn_modules/gfanlib/Makefile.am

    rc89014 r9abcc6  
    11ACLOCAL_AMFLAGS = -I ../../m4
    22
    3 SOURCES = gfanlib_exceptions.h callgfanlib_conversion.cc callgfanlib_conversion.h bbcone.cc bbcone.h bbfan.cc bbfan.h bbpolytope.cc bbpolytope.h gfan.h gitfan.cc gitfan.h tropicalVarietyOfPolynomials.h tropicalVarietyOfPolynomials.cc ppinitialReduction.cc ppinitialReduction.h ttinitialReduction.cc ttinitialReduction.h containsMonomial.cc containsMonomial.h adjustWeights.cc adjustWeights.h tropicalStrategy.cc tropicalStrategy.h initial.cc initial.h witness.cc witness.h tropicalCurves.cc tropicalCurves.h groebnerCone.cc groebnerCone.h neighbours.cc neighbours.h startingCone.cc startingCone.h tropical.cc tropical.h gfanlib.cc
     3SOURCES = gfanlib_exceptions.h callgfanlib_conversion.cc callgfanlib_conversion.h bbcone.cc bbcone.h bbfan.cc bbfan.h bbpolytope.cc bbpolytope.h gfan.h gitfan.cc gitfan.h tropicalVarietyOfPolynomials.h tropicalVarietyOfPolynomials.cc ppinitialReduction.cc ppinitialReduction.h ttinitialReduction.cc ttinitialReduction.h containsMonomial.cc containsMonomial.h adjustWeights.cc adjustWeights.h tropicalStrategy.cc tropicalStrategy.h initial.cc initial.h witness.cc witness.h tropicalCurves.cc tropicalCurves.h groebnerCone.cc groebnerCone.h neighbours.cc neighbours.h startingCone.cc startingCone.h tropicalVarietyOfIdeals.cc tropicalVarietyOfIdeals.h tropicalVariety.cc tropicalVariety.h tropical.cc tropical.h gfanlib.cc
     4
    45
    56MY_CPPFLAGS =  -I${top_srcdir} -I${top_builddir} \
  • Singular/dyn_modules/gfanlib/bbfan.cc

    rc89014 r9abcc6  
    4040    std::string s = zf->toString(2+4+8+128);
    4141    return omStrDup(s.c_str());
     42// =======
     43//     std::stringstream s;
     44//     std::string raysAndCones = zf->toStringJustRaysAndMaximalCones();
     45//     s << raysAndCones;
     46//     if (zf->getDimension() >= 0) // <=> zf is not empty
     47//     {
     48//       assert(zf->numberOfConesOfDimension(zf->getDimension()-zf->getLinealityDimension(),0,0));
     49//       gfan::ZCone zc = zf->getCone(zf->getDimension()-zf->getLinealityDimension(),0,0,0);
     50//       gfan::ZMatrix genLinSpace = zc.generatorsOfLinealitySpace();
     51//       char* gens = toString(genLinSpace);
     52//       s << std::endl << "GENERATORS_LINEALITY_SPACE:" << std::endl;
     53//       s << gens;
     54//     }
     55//     std::string sstring = s.str();
     56//     return omStrDup(sstring.c_str());
     57// >>>>>>> status updated 11.03.
    4258  }
    4359}
     
    858874
    859875
    860 BOOLEAN tropicalVariety(leftv res, leftv args)
    861 {
    862   leftv u=args;
    863   if ((u != NULL) && (u->Typ() == POLY_CMD))
    864   {
    865     int n = rVar(currRing);
    866     gfan::ZFan* zf = new gfan::ZFan(n);
    867     int* expv1 = (int*)omAlloc((n+1)*sizeof(int));
    868     int* expv2 = (int*)omAlloc((n+1)*sizeof(int));
    869     int* expvr = (int*)omAlloc((n+1)*sizeof(int));
    870     gfan::ZVector expw1 = gfan::ZVector(n);
    871     gfan::ZVector expw2 = gfan::ZVector(n);
    872     gfan::ZVector expwr = gfan::ZVector(n);
    873     gfan::ZMatrix eq, ineq;
    874     for (poly s1=(poly)u->Data(); s1!=NULL; pIter(s1))
    875     {
    876       pGetExpV(s1,expv1);
    877       expw1 = intStar2ZVector(n,expv1);
    878       for (poly s2=pNext(s1); s2!=NULL; pIter(s2))
    879       {
    880         pGetExpV(s2,expv2);
    881         expw2 = intStar2ZVector(n,expv2);
    882         eq = gfan::ZMatrix(0,n);
    883         eq.appendRow(expw1-expw2);
    884         ineq = gfan::ZMatrix(0,n);
    885         for (poly r=(poly)u->Data(); r!=NULL; pIter(r))
    886         {
    887           pGetExpV(r,expvr);
    888           expwr = intStar2ZVector(n,expvr);
    889           if ((r!=s1) && (r!=s2))
    890           {
    891             ineq.appendRow(expw1-expwr);
    892           }
    893         }
    894         gfan::ZCone zc = gfan::ZCone(ineq,eq);
    895         zf->insert(zc);
    896       }
    897     }
    898     omFreeSize(expv1,(n+1)*sizeof(int));
    899     omFreeSize(expv2,(n+1)*sizeof(int));
    900     omFreeSize(expvr,(n+1)*sizeof(int));
    901     res->rtyp = fanID;
    902     res->data = (void*) zf;
    903     return FALSE;
    904   }
    905   WerrorS("tropicalVariety: unexpected parameters");
    906   return TRUE;
    907 }
     876// BOOLEAN tropicalVariety(leftv res, leftv args)
     877// {
     878//   leftv u=args;
     879//   if ((u != NULL) && (u->Typ() == POLY_CMD))
     880//   {
     881//     int n = rVar(currRing);
     882//     gfan::ZFan* zf = new gfan::ZFan(n);
     883//     int* expv1 = (int*)omAlloc((n+1)*sizeof(int));
     884//     int* expv2 = (int*)omAlloc((n+1)*sizeof(int));
     885//     int* expvr = (int*)omAlloc((n+1)*sizeof(int));
     886//     gfan::ZVector expw1 = gfan::ZVector(n);
     887//     gfan::ZVector expw2 = gfan::ZVector(n);
     888//     gfan::ZVector expwr = gfan::ZVector(n);
     889//     gfan::ZMatrix eq, ineq;
     890//     for (poly s1=(poly)u->Data(); s1!=NULL; pIter(s1))
     891//     {
     892//       pGetExpV(s1,expv1);
     893//       expw1 = intStar2ZVector(n,expv1);
     894//       for (poly s2=pNext(s1); s2!=NULL; pIter(s2))
     895//       {
     896//         pGetExpV(s2,expv2);
     897//         expw2 = intStar2ZVector(n,expv2);
     898//         eq = gfan::ZMatrix(0,n);
     899//         eq.appendRow(expw1-expw2);
     900//         ineq = gfan::ZMatrix(0,n);
     901//         for (poly r=(poly)u->Data(); r!=NULL; pIter(r))
     902//         {
     903//           pGetExpV(r,expvr);
     904//           expwr = intStar2ZVector(n,expvr);
     905//           if ((r!=s1) && (r!=s2))
     906//           {
     907//             ineq.appendRow(expw1-expwr);
     908//           }
     909//         }
     910//         gfan::ZCone zc = gfan::ZCone(ineq,eq);
     911//         zf->insert(zc);
     912//       }
     913//     }
     914//     omFreeSize(expv1,(n+1)*sizeof(int));
     915//     omFreeSize(expv2,(n+1)*sizeof(int));
     916//     omFreeSize(expvr,(n+1)*sizeof(int));
     917//     res->rtyp = fanID;
     918//     res->data = (void*) zf;
     919//     return FALSE;
     920//   }
     921//   WerrorS("tropicalVariety: unexpected parameters");
     922//   return TRUE;
     923// }
    908924
    909925gfan::ZFan commonRefinement(gfan::ZFan zf, gfan::ZFan zg)
     
    10381054  p->iiAddCproc("","fVector",FALSE,fVector);
    10391055  p->iiAddCproc("","containsInCollection",FALSE,containsInCollection);
    1040   p->iiAddCproc("","tropicalVariety",FALSE,tropicalVariety);
     1056  // p->iiAddCproc("","tropicalVariety",FALSE,tropicalVariety);
    10411057  p->iiAddCproc("","commonRefinement",FALSE,commonRefinement);
    10421058  // iiAddCproc("","grFan",FALSE,grFan);
  • Singular/dyn_modules/gfanlib/groebnerCone.cc

    rc89014 r9abcc6  
    1 #include <kernel/polys.h>
     1#include <kernel/kstd1.h>
     2#include <kernel/ideals.h>
    23#include <Singular/ipid.h>
    34
     5#include <libpolys/polys/monomials/p_polys.h>
    46#include <libpolys/polys/monomials/ring.h>
    5 #include <kernel/ideals.h>
     7#include <libpolys/polys/prCopy.h>
     8
    69#include <gfanlib/gfanlib.h>
    710
     
    9598}
    9699
    97 groebnerConeData::groebnerConeData():
    98   I(NULL),
    99   r(NULL),
    100   c(gfan::ZCone(0)),
    101   p(gfan::ZVector(0))
    102 {
    103 }
    104 
    105 groebnerConeData::groebnerConeData(const groebnerConeData &sigma):
    106   I(id_Copy(sigma.getIdeal(),sigma.getRing())),
    107   r(rCopy(sigma.getRing())),
    108   c(gfan::ZCone(sigma.getCone())),
    109   p(gfan::ZVector(sigma.getInteriorPoint()))
    110 {
    111 }
    112 
    113 groebnerConeData::groebnerConeData(const ideal &J, const ring &s, const gfan::ZCone &d, const gfan::ZVector &q):
    114   I(J),
    115   r(s),
    116   c(d),
    117   p(q)
    118 {
    119 }
    120 
    121 groebnerConeData::groebnerConeData(const ideal &J, const ring &s):
    122   I(J),
    123   r(s)
    124 {
    125 }
    126 
    127 groebnerConeData::~groebnerConeData()
    128 {
    129   id_Delete(&I,r);
    130   rDelete(r);
    131 }
    132 
    133 
    134 groebnerConeData maximalGroebnerConeData(ideal I, const ring r)
     100gfan::ZCone fullGroebnerCone(const ideal &I, const ring &r)
    135101{
    136102  int n = rVar(r);
     
    156122  omFreeSize(leadexpv,(n+1)*sizeof(int));
    157123  omFreeSize(tailexpv,(n+1)*sizeof(int));
     124  return gfan::ZCone(inequalities,gfan::ZMatrix(0, inequalities.getWidth()));
     125}
     126
     127groebnerConeData::groebnerConeData():
     128  I(NULL),
     129  r(NULL),
     130  c(gfan::ZCone(0)),
     131  p(gfan::ZVector(0))
     132{
     133}
     134
     135groebnerConeData::groebnerConeData(const groebnerConeData &sigma):
     136  I(id_Copy(sigma.getIdeal(),sigma.getRing())),
     137  r(rCopy(sigma.getRing())),
     138  c(gfan::ZCone(sigma.getCone())),
     139  p(gfan::ZVector(sigma.getInteriorPoint()))
     140{
     141}
     142
     143groebnerConeData::groebnerConeData(const ideal &J, const ring &s, const gfan::ZCone &d, const gfan::ZVector &q):
     144  I(J),
     145  r(s),
     146  c(d),
     147  p(q)
     148{
     149}
     150
     151groebnerConeData::~groebnerConeData()
     152{
     153  // if (I!=NULL) id_Delete(&I,r);
     154  // if (r!=NULL) rDelete(r);
     155}
     156
     157
     158groebnerConeData maximalGroebnerConeData(ideal I, const ring r)
     159{
     160  int n = rVar(r);
     161  poly g = NULL;
     162  int* leadexpv = (int*) omAlloc((n+1)*sizeof(int));
     163  int* tailexpv = (int*) omAlloc((n+1)*sizeof(int));
     164  gfan::ZVector leadexpw = gfan::ZVector(n);
     165  gfan::ZVector tailexpw = gfan::ZVector(n);
     166  gfan::ZMatrix inequalities = gfan::ZMatrix(0,n);
     167  for (int i=0; i<IDELEMS(I); i++)
     168  {
     169    g = (poly) I->m[i]; pGetExpV(g,leadexpv);
     170    leadexpw = intStar2ZVector(n, leadexpv);
     171    pIter(g);
     172    while (g != NULL)
     173    {
     174      pGetExpV(g,tailexpv);
     175      tailexpw = intStar2ZVector(n, tailexpv);
     176      inequalities.appendRow(leadexpw-tailexpw);
     177      pIter(g);
     178    }
     179  }
     180  omFreeSize(leadexpv,(n+1)*sizeof(int));
     181  omFreeSize(tailexpv,(n+1)*sizeof(int));
    158182  gfan::ZCone zc = gfan::ZCone(inequalities,gfan::ZMatrix(0, inequalities.getWidth()));
    159183  gfan::ZVector p = zc.getRelativeInteriorPoint();
    160184  return groebnerConeData(I,r,zc,p);
    161185}
     186
     187/***
     188 * Given a general ring r with any ordering, changes the ordering to wp(-w)
     189 **/
     190void changeOrderingTo_wp(ring r, const gfan::ZVector w)
     191{
     192  omFree(r->order);
     193  r->order  = (int*) omAlloc0(3*sizeof(int));
     194  omFree(r->block0);
     195  r->block0 = (int*) omAlloc0(3*sizeof(int));
     196  omFree(r->block1);
     197  r->block1 = (int*) omAlloc0(3*sizeof(int));
     198  for (int i=0; r->wvhdl[i]; i++) omFree(r->wvhdl[i]);
     199  omFree(r->wvhdl);
     200  r->wvhdl  = (int**) omAlloc0(3*sizeof(int*));
     201
     202  bool ok = false;
     203  r->order[0]  = ringorder_wp;
     204  r->block0[0] = 1;
     205  r->block1[0] = r->N;
     206  r->wvhdl[0]  = ZVectorToIntStar(w,ok);
     207  r->order[1]  = ringorder_C;
     208  rComplete(r,1);
     209}
     210
     211groebnerConeData::groebnerConeData(const ideal J, const ring s, const gfan::ZVector w)
     212{
     213  r = rCopy(s);
     214  changeOrderingTo_wp(r,w);
     215  rChangeCurrRing(r);
     216
     217  int k = idSize(J); I = idInit(k);
     218  nMapFunc identityMap = n_SetMap(s->cf,r->cf);
     219  for (int i=0; i<k; i++)
     220    I->m[i] = p_PermPoly(J->m[i],NULL,s,r,identityMap,NULL,0);
     221  intvec* nullVector = NULL;
     222  I = kStd(I,currQuotient,testHomog,&nullVector);
     223
     224  c = sloppyGroebnerCone(I,r,w);
     225  p = c.getRelativeInteriorPoint();
     226}
     227
     228groebnerConeData::groebnerConeData(const ideal J, const ring s, const gfan::ZCone d)
     229{
     230  c = d;
     231  p = d.getRelativeInteriorPoint();
     232
     233  r = rCopy(s);
     234  changeOrderingTo_wp(r,p);
     235  rChangeCurrRing(r);
     236
     237  int k = idSize(J); I = idInit(k);
     238  nMapFunc identityMap = n_SetMap(s->cf,r->cf);
     239  for (int i=0; i<k; i++)
     240    I->m[i] = p_PermPoly(J->m[i],NULL,s,r,identityMap,NULL,0);
     241  intvec* nullVector = NULL;
     242  I = kStd(I,currQuotient,testHomog,&nullVector);
     243}
     244
     245// /***
     246//  * Given a general ring r with any ordering, changes the ordering to a(v),ws(-w)
     247//  **/
     248// bool changetoAWSRing(ring r, const gfan::ZVector v, const gfan::ZVector w)
     249// {
     250//   omFree(r->order);
     251//   r->order  = (int*) omAlloc0(4*sizeof(int));
     252//   omFree(r->block0);
     253//   r->block0 = (int*) omAlloc0(4*sizeof(int));
     254//   omFree(r->block1);
     255//   r->block1 = (int*) omAlloc0(4*sizeof(int));
     256//   for (int i=0; r->wvhdl[i]; i++)
     257//   { omFree(r->wvhdl[i]); }
     258//   omFree(r->wvhdl);
     259//   r->wvhdl  = (int**) omAlloc0(4*sizeof(int*));
     260
     261//   bool ok = false;
     262//   r->order[0]  = ringorder_a;
     263//   r->block0[0] = 1;
     264//   r->block1[0] = r->N;
     265//   r->wvhdl[0]  = ZVectorToIntStar(v,ok);
     266//   r->order[1]  = ringorder_ws;
     267//   r->block0[1] = 1;
     268//   r->block1[1] = r->N;
     269//   r->wvhdl[1]  = ZVectorToIntStar(w,ok);
     270//   r->order[2]  = ringorder_C;
     271//   return ok;
     272// }
     273
     274// groebnerConeData::groebnerConeData(const ideal J, const ring s, const gfan::ZVector w)
     275// {
     276//   r = rCopy(s);
     277//   changeOrderingTo_wp(r,w);
     278//   rChangeCurrRing(r);
     279
     280//   int k = idSize(J); I = idInit(k);
     281//   nMapFunc identityMap = n_SetMap(s->cf,r->cf);
     282//   for (int i=0; i<k; i++)
     283//     I->m[i] = p_PermPoly(J->m[i],NULL,s,r,nMap,NULL,0);
     284//   intvec* nullVector = NULL;
     285//   I = kStd(I,currQuotient,testHomog,&nullVector);
     286
     287//   c = sloppyGroebnerCone(I,r,w);
     288//   p = c.getRelativeInteriorPoint();
     289// }
     290
     291gfan::ZFan* toFanStar(setOfGroebnerConeData setOfCones)
     292{
     293  if (setOfCones.size() > 0)
     294  {
     295    setOfGroebnerConeData::iterator cone = setOfCones.begin();
     296    gfan::ZFan* zf = new gfan::ZFan(cone->getCone().ambientDimension());
     297    for (; cone!=setOfCones.end(); cone++)
     298      zf->insert(cone->getCone());
     299    return zf;
     300  }
     301  else
     302    return new gfan::ZFan(gfan::ZFan::fullFan(currRing->N));
     303}
  • Singular/dyn_modules/gfanlib/groebnerCone.h

    rc89014 r9abcc6  
    88#include <libpolys/polys/simpleideals.h>
    99#include <kernel/ideals.h>
    10 #include <gfanlib/gfanlib_vector.h>
    11 #include <gfanlib/gfanlib_zcone.h>
     10#include <gfanlib/gfanlib.h>
    1211#include <set>
    1312
     13gfan::ZCone sloppyGroebnerCone(const poly g, const ring r, const gfan::ZVector w);
     14gfan::ZCone sloppyGroebnerCone(const ideal I, const ring r, const gfan::ZVector w);
    1415gfan::ZCone groebnerCone(const poly g, const ring r, const gfan::ZVector w);
    1516gfan::ZCone groebnerCone(const ideal I, const ring r, const gfan::ZVector w);
    16 
     17gfan::ZCone fullGroebnerCone(const ideal &I, const ring &r);
    1718
    1819class groebnerConeData
     
    3132  groebnerConeData(const groebnerConeData &sigma);
    3233  groebnerConeData(const ideal &J, const ring &s, const gfan::ZCone &d, const gfan::ZVector &q);
    33   groebnerConeData(const ideal &J, const ring &s);
     34  groebnerConeData(const ideal J, const ring s, const gfan::ZVector w);
     35  groebnerConeData(const ideal J, const ring s, const gfan::ZCone d);
    3436  ~groebnerConeData();
    3537
     
    5860typedef std::set<groebnerConeData,groebnerConeData_compare> setOfGroebnerConeData;
    5961
     62gfan::ZFan* toFanStar(setOfGroebnerConeData setOfCones);
     63
    6064#endif
  • Singular/dyn_modules/gfanlib/neighbours.cc

    rc89014 r9abcc6  
    2020  int r = inequalities.getHeight();
    2121  int c = inequalities.getWidth();
     22  if (r==0) return gfan::ZMatrix(0,c);
    2223
    2324  gfan::ZMatrix relativeInteriorPoints = gfan::ZMatrix(0,c);
     
    4445  newInequalities = inequalities.submatrix(0,0,r-1,c);
    4546  newEquations = equations;
    46   newEquations.appendRow(inequalities[r]);
     47  newEquations.appendRow(inequalities[r-1]);
    4748  facet = gfan::ZCone(newInequalities,newEquations);
    4849  relativeInteriorPoints.appendRow(facet.getRelativeInteriorPoint());
     
    6364  gfan::ZMatrix relativeInteriorPoints = gfan::ZMatrix(0,c);
    6465  gfan::ZMatrix outerFacetNormals = gfan::ZMatrix(0,c);
     66  if (r<=1)
     67    return std::make_pair(relativeInteriorPoints,outerFacetNormals);
    6568  // next we iterate over each of the r facets, build the respective cone and add it to the list
    6669  // this is the i=0 case
     
    97100setOfGroebnerConeData groebnerNeighbours(const groebnerConeData sigma, const tropicalStrategy currentCase)
    98101{
    99   bool (*red)(ideal I, ring r);
    100   red = currentCase.reduce;
     102  bool (*reduce)(ideal I, ring r);
     103  reduce = currentCase.reduce;
    101104
    102105  gfan::ZCone zc = sigma.getCone();
     
    108111  for (int i=0; i<interiorPoints.getHeight(); i++)
    109112  {
    110     std::pair<ideal,ring> flipped = flip(sigma.getIdeal(),sigma.getRing(),interiorPoints[i],facetNormals[i]);
     113    std::pair<ideal,ring> flipped = flip(sigma.getIdeal(),sigma.getRing(),interiorPoints[i],facetNormals[i],currentCase);
    111114    ideal I = flipped.first;
    112115    ring r = flipped.second;
    113     red(I,r);
    114     neighbours.insert(groebnerConeData(I,r));
     116    reduce(I,r);
     117    gfan::ZCone c = sloppyGroebnerCone(I,r,facetNormals[i]);
     118    gfan::ZVector p = c.getRelativeInteriorPoint();
     119    neighbours.insert(groebnerConeData(I,r,c,p));
    115120  }
    116121
     
    118123}
    119124
    120 setOfGroebnerConeData tropicalNeighbors(const groebnerConeData sigma, const tropicalStrategy currentCase)
     125setOfGroebnerConeData tropicalNeighbours(const groebnerConeData sigma, const tropicalStrategy currentCase)
    121126{
    122127  gfan::ZCone zc = sigma.getCone();
     
    138143    for (std::set<gfan::ZVector>::iterator ray = setOfRays.begin(); ray!=setOfRays.end(); ray++)
    139144    {
    140       std::pair<ideal,ring> flipped = flip(I,r,w,*ray);
     145      std::pair<ideal,ring> flipped = flip(I,r,w,*ray,currentCase);
    141146      ideal I = flipped.first;
    142147      ring r = flipped.second;
    143148      red(I,r);
    144       neighbours.insert(groebnerConeData(I,r));
     149      gfan::ZCone c = sloppyGroebnerCone(I,r,*ray);
     150      gfan::ZVector p = c.getRelativeInteriorPoint();
     151      neighbours.insert(groebnerConeData(I,r,c,p));
    145152    }
    146153  }
  • Singular/dyn_modules/gfanlib/neighbours.h

    rc89014 r9abcc6  
    66
    77setOfGroebnerConeData groebnerNeighbours(const groebnerConeData sigma, const tropicalStrategy currentCase);
     8setOfGroebnerConeData tropicalNeighbours(const groebnerConeData sigma, const tropicalStrategy currentCase);
    89BOOLEAN tropicalNeighbours(leftv res, leftv args);
    910
  • Singular/dyn_modules/gfanlib/startingCone.cc

    rc89014 r9abcc6  
    66#include <neighbours.h>
    77#include <tropicalStrategy.h>
    8 
    9 /***
    10  * Given a general ring r with any ordering,
    11  * changes the ordering to a(v),ws(-w)
    12  **/
    13 bool changetoAWSRing(ring r, gfan::ZVector v, gfan::ZVector w)
    14 {
    15   omFree(r->order);
    16   r->order  = (int*) omAlloc0(4*sizeof(int));
    17   omFree(r->block0);
    18   r->block0 = (int*) omAlloc0(4*sizeof(int));
    19   omFree(r->block1);
    20   r->block1 = (int*) omAlloc0(4*sizeof(int));
    21   for (int i=0; r->wvhdl[i]; i++)
    22   { omFree(r->wvhdl[i]); }
    23   omFree(r->wvhdl);
    24   r->wvhdl  = (int**) omAlloc0(4*sizeof(int*));
    25 
    26   bool ok = false;
    27   r->order[0]  = ringorder_a;
    28   r->block0[0] = 1;
    29   r->block1[0] = r->N;
    30   r->wvhdl[0]  = ZVectorToIntStar(v,ok);
    31   r->order[1]  = ringorder_ws;
    32   r->block0[1] = 1;
    33   r->block1[1] = r->N;
    34   r->wvhdl[1]  = ZVectorToIntStar(w,ok);
    35   r->order[2]  = ringorder_C;
    36   return ok;
    37 }
     8#include <tropicalCurves.h>
     9#include <bbcone.h>
     10#include <tropicalVariety.h>
    3811
    3912
    40 /***
    41  * Given a ring with ordering a(v'),ws(w'),
    42  * changes the weights to v,w
    43  **/
    44 bool changeAWSWeights(ring r, gfan::ZVector v, gfan::ZVector w)
    45 {
    46   omFree(r->wvhdl[0]);
    47   omFree(r->wvhdl[1]);
    48   bool ok = false;
    49   r->wvhdl[0]  = ZVectorToIntStar(v,ok);
    50   r->wvhdl[1]  = ZVectorToIntStar(w,ok);
    51   return ok;
    52 }
     13// /***
     14// * Given a ring with ordering a(v'),ws(w'),
     15// * changes the weights to v,w
     16// **/
     17// bool changeAWSWeights(ring r, gfan::ZVector v, gfan::ZVector w)
     18// {
     19//   omFree(r->wvhdl[0]);
     20//   omFree(r->wvhdl[1]);
     21//   bool ok = false;
     22//   r->wvhdl[0]  = ZVectorToIntStar(v,ok);
     23//   r->wvhdl[1]  = ZVectorToIntStar(w,ok);
     24//   return ok;
     25// }
    5326
    5427
     
    6740    if (s == NULL)
    6841    {
    69       // std::cout << "found no monomial in initial ideal!" << std::endl;
    7042      p_Delete(&s,r);
    7143      return R[i];
    72     }
    73     p_Delete(&s,r);
    74   }
    75   gfan::ZMatrix L = zc.generatorsOfLinealitySpace();
    76   for (int i=0; i<L.getHeight(); i++)
    77   {
    78     ideal inI = initial(I,r,L[i]);
    79     poly s = checkForMonomialViaSuddenSaturation(inI,r);
    80     id_Delete(&inI,r);
    81     if (s == NULL)
    82     {
    83       // std::cout << "found no monomial in initial ideal!" << std::endl;
    84       p_Delete(&s,r);
    85       return L[i];
    8644    }
    8745    p_Delete(&s,r);
     
    9351gfan::ZVector tropicalStartingPoint(const ideal I, const ring r, const tropicalStrategy currentCase)
    9452{
     53  bool (*red)(ideal I, ring r);
     54  red = currentCase.reduce; red(I,r);
     55
    9556  groebnerConeData sigma = maximalGroebnerConeData(id_Copy(I,r),rCopy(r));
    9657  gfan::ZVector startingPoint = findTropicalPoint(sigma);
    97   while (startingPoint.size()==0)
     58  if (startingPoint.size() > 0)
     59    return startingPoint;
     60  setOfGroebnerConeData groebnerFan;
     61  setOfGroebnerConeData workingList;
     62  workingList.insert(sigma);
     63
     64  while (!workingList.empty())
    9865  {
     66    sigma = *(workingList.begin());
    9967    setOfGroebnerConeData neighbours = groebnerNeighbours(sigma,currentCase);
    100     setOfGroebnerConeData::iterator tau = neighbours.begin();
    101     for (; tau!=neighbours.end(); tau++)
     68    for (setOfGroebnerConeData::iterator tau = neighbours.begin(); tau!=neighbours.end(); tau++)
    10269    {
    103       startingPoint = findTropicalPoint(*tau);
    104       if (startingPoint.size() > 0) break;
     70      if (groebnerFan.count(*tau) == 0)
     71      {
     72        if (workingList.count(*tau) == 0)
     73        {
     74          startingPoint = findTropicalPoint(*tau);
     75          if (startingPoint.size() > 0)
     76            return startingPoint;
     77        }
     78        workingList.insert(*tau);
     79      }
    10580    }
    106     tau = neighbours.begin();
    107     sigma = *tau;
     81    groebnerFan.insert(groebnerConeData(sigma));
     82    workingList.erase(sigma);
    10883  }
    10984  return startingPoint;
    11085}
    111 
    11286
    11387BOOLEAN tropicalStartingPoint0(leftv res, leftv args)
     
    133107}
    134108
     109gfan::ZCone tropicalStartingCone(const ideal I, const ring r, const tropicalStrategy currentCase)
     110{
     111  // groebnerConeData sigma = maximalGroebnerConeData(I,r);
     112  // gfan::ZCone zc = sigma.getCone();
     113  // if (zc.dimensionOfLinealitySpace == d)
     114  //   return zc.linealitySpace();
     115  // gfan::ZVector w = tropicalStartingPoint(I,r,currentCase);
     116  // ideal inI = initial(I,w,r);
     117  // gfan::ZCone zd =
    135118
    136 // gfan::ZCone* tropicalStartingCone(const ideal &I, ring r)
    137 // {
    138 //   gfan::ZVector* w = tropicalStartingPoint(I,r);
    139 //   return groebnerCone(I,r,w);
    140 // }
     119  gfan::ZVector w = tropicalStartingPoint(I,r,currentCase);
     120  if (w.size() == 0)
     121  {
     122    gfan::ZCone zc = fullGroebnerCone(I,r);
     123    return zc.linealitySpace();
     124  }
     125  ideal inI = initial(I,r,w);
     126  std::set<gfan::ZCone> T = tropicalCurve(inI,r,0,currentCase);
     127  return *T.begin();
     128}
     129
     130BOOLEAN tropicalStartingCone0(leftv res, leftv args)
     131{
     132  leftv u = args;
     133  ideal I = (ideal) u->CopyD();
     134  gfan::ZCone startingCone = tropicalStartingCone(I,currRing,nonValuedCase);
     135  id_Delete(&I, currRing);
     136  res->rtyp = coneID;
     137  res->data = (char*) new gfan::ZCone(startingCone);
     138  return FALSE;
     139}
     140
     141BOOLEAN tropicalStartingCone1(leftv res, leftv args)
     142{
     143  leftv u = args;
     144  ideal I = (ideal) u->CopyD();
     145  gfan::ZCone startingCone = tropicalStartingCone(I,currRing,valuedCase);
     146  id_Delete(&I, currRing);
     147  res->rtyp = coneID;
     148  res->data = (char*) new gfan::ZCone(startingCone);
     149  return FALSE;
     150}
  • Singular/dyn_modules/gfanlib/startingCone.h

    rc89014 r9abcc6  
    33
    44#include <groebnerCone.h>
    5 /* namespace tropical */
    6 /* { */
    7 
    8 /*   class facet */
    9 /*   { */
    10 /*     gfan::ZVector interiorPoint; */
    11 /*     gfan::ZVector facetNormal; */
    12 
    13 /*   public: */
    14 
    15 /*     facet(); */
    16 /*     facet(const facet &f); */
    17 /*     facet(const gfan::ZCone &c, const gfan::ZVector &v, const gfan::ZVector &w); */
    18 /*     ~facet(); */
    19 
    20 /*     gfan::ZCone getEta() { return this->eta; }; */
    21 /*     gfan::ZVector getInteriorPoint() { return this->interiorPoint; }; */
    22 /*     gfan::ZVector getFacetNormal() { return this->facetNormal; }; */
    23 
    24 /*     friend struct facet_compare; */
    25 /*   }; */
    26 
    27 /*   struct facet_compare */
    28 /*   { */
    29 /*     bool operator()(const facet &f, const facet &g) const */
    30 /*     { */
    31 /*       const gfan::ZVector v1 = f.interiorPoint; */
    32 /*       const gfan::ZVector v2 = g.interiorPoint; */
    33 /* #ifndef NDEBUG */
    34 /*       assume(v1.size() == v2.size()); */
    35 /* #endif */
    36 /*       return v1 < v2; */
    37 /*     } */
    38 /*   }; */
    39 
    40 /*   typedef std::set<facet,facet_compare> facets; */
    41 
    42 /*   void mergeFacets(facets &F, const facets &newFacets); */
    43 
    44 /* } */
     5#include <tropicalStrategy.h>
    456
    467gfan::ZVector containsTropicalPoint(const groebnerConeData sigma);
    478gfan::ZVector tropicalStartingPoint(ideal I, ring r);
     9gfan::ZCone tropicalStartingCone(const ideal I, const ring r, const tropicalStrategy currentCase);
    4810
    4911BOOLEAN tropicalStartingPoint0(leftv res, leftv args);
    5012BOOLEAN tropicalStartingPoint1(leftv res, leftv args);
    5113
     14BOOLEAN tropicalStartingCone0(leftv res, leftv args);
     15BOOLEAN tropicalStartingCone1(leftv res, leftv args);
     16
    5217#endif
  • Singular/dyn_modules/gfanlib/tropical.cc

    rc89014 r9abcc6  
    1414#include <tropicalStrategy.h>
    1515#include <startingCone.h>
     16#include <tropicalVariety.h>
    1617
    1718BOOLEAN homogeneitySpace(leftv res, leftv args)
     
    207208  p->iiAddCproc("","tropicalStartingPoint0",FALSE,tropicalStartingPoint0);
    208209  p->iiAddCproc("","tropicalStartingPoint1",FALSE,tropicalStartingPoint1);
     210  p->iiAddCproc("","tropicalStartingCone0",FALSE,tropicalStartingCone0);
     211  p->iiAddCproc("","tropicalStartingCone1",FALSE,tropicalStartingCone1);
     212  p->iiAddCproc("","tropicalVariety",FALSE,tropicalVariety);
    209213#endif //NDEBUG
    210214  p->iiAddCproc("","ppreduceInitially",FALSE,ppreduceInitially);
  • Singular/dyn_modules/gfanlib/tropicalCurves.cc

    rc89014 r9abcc6  
    8989
    9090/***
    91  * Computes the tropical curve of an x-homogeneous ideal I
    92  * which is weighted homogeneous with respect to weight w in ring r
     91 * Computes the tropical curve of an x-homogeneous ideal I in ring r
    9392 **/
    9493std::set<gfan::ZCone> tropicalCurve(const ideal I, const ring r, const int d,
  • Singular/dyn_modules/gfanlib/witness.cc

    rc89014 r9abcc6  
    44#include <callgfanlib_conversion.h>
    55#include <initial.h>
     6#include <tropicalStrategy.h>
    67#include <utility>
    78
     
    134135}
    135136
    136 std::pair<ideal,ring> flip(const ideal I, const ring r, const gfan::ZVector interiorPoint, const gfan::ZVector facetNormal)
     137std::pair<ideal,ring> flip(const ideal I, const ring r, const gfan::ZVector interiorPoint, const gfan::ZVector facetNormal, const tropicalStrategy currentCase)
    137138{
     139  gfan::ZVector (*adjustWeight0)(gfan::ZVector w);
     140  adjustWeight0 = currentCase.adjustWeightForHomogeneity;
     141  gfan::ZVector (*adjustWeight1)(gfan::ZVector v, gfan::ZVector w);
     142  adjustWeight1 = currentCase.adjustWeightUnderHomogeneity;
     143
     144  gfan::ZVector adjustedInteriorPoint = adjustWeight0(interiorPoint);
     145  gfan::ZVector adjustedFacetNormal = adjustWeight1(facetNormal,adjustedInteriorPoint);
     146
    138147  ring origin = currRing;
    139148  ideal inIr = initial(I,r,interiorPoint);
     
    143152  int n = rVar(s);
    144153  deleteOrdering(s);
    145   // for (i=0; s->order[i]; i++)
    146   //   omFree(s->wvhdl[i]);
    147   // i++; omFreeSize(s->order, i*sizeof(int));
    148   // omFreeSize(s->block0, i*sizeof(int));
    149   // omFreeSize(s->block1, i*sizeof(int));
    150   // omFreeSize(s->wvhdl, i*sizeof(int));
    151154  s->order = (int*) omAlloc0(4*sizeof(int));
    152155  s->block0 = (int*) omAlloc0(4*sizeof(int));
     
    156159  s->block0[0] = 1;
    157160  s->block1[0] = n;
    158   s->wvhdl[0] = ZVectorToIntStar(interiorPoint,ok);
     161  s->wvhdl[0] = ZVectorToIntStar(adjustedInteriorPoint,ok);
    159162  s->order[1] = ringorder_wp;
    160163  s->block0[1] = 1;
    161164  s->block1[1] = n;
    162   s->wvhdl[1] = ZVectorToIntStar(facetNormal,ok);
     165  s->wvhdl[1] = ZVectorToIntStar(adjustedFacetNormal,ok);
    163166  s->order[2] = ringorder_C;
    164167  rComplete(s,1);
  • Singular/dyn_modules/gfanlib/witness.h

    rc89014 r9abcc6  
    66#include <Singular/ipid.h>
    77#include <gfanlib/gfanlib_vector.h>
     8#include <tropicalStrategy.h>
    89
    910poly witness(const poly m, const ideal I, const ideal inI, const ring r);
    10 std::pair<ideal,ring> flip(const ideal I, const ring r, const gfan::ZVector interiorPoint, const gfan::ZVector facetNormal);
     11std::pair<ideal,ring> flip(const ideal I, const ring r, const gfan::ZVector interiorPoint, const gfan::ZVector facetNormal, const tropicalStrategy currentCase);
    1112
    1213#ifndef NDEBUG
Note: See TracChangeset for help on using the changeset viewer.