Changeset dffd154 in git


Ignore:
Timestamp:
Sep 20, 2014, 1:53:38 AM (9 years ago)
Author:
Yue Ren <ren@…>
Branches:
(u'spielwiese', 'f6c3dc58b0df4bd712574325fe76d0626174ad97')
Children:
4664b33f793e7e511d9722557720dd523ec89856
Parents:
b71400abefd0c9c66c0009063f40ddd5b1f1c4c7
git-author:
Yue Ren <ren@mathematik.uni-kl.de>2014-09-20 01:53:38+02:00
git-committer:
Yue Ren <ren@mathematik.uni-kl.de>2015-02-06 13:47:05+01:00
Message:
chg: status update 20.09.
Location:
Singular/dyn_modules/gfanlib
Files:
12 edited

Legend:

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

    rb71400a rdffd154  
    3131static bool checkOrderingAndCone(const ring r, const gfan::ZCone zc)
    3232{
     33  return true;
    3334  if (r)
    3435  {
     
    175176  }
    176177  omFreeSize(expv,(n+1)*sizeof(int));
    177   if (currentStrategy->restrictToLowerHalfSpace())
    178   {
    179     gfan::ZVector lowerHalfSpaceCondition = gfan::ZVector(n);
    180     lowerHalfSpaceCondition[0] = -1;
    181     inequalities.appendRow(lowerHalfSpaceCondition);
    182   }
     178  // if (currentStrategy->restrictToLowerHalfSpace())
     179  // {
     180  //   gfan::ZVector lowerHalfSpaceCondition = gfan::ZVector(n);
     181  //   lowerHalfSpaceCondition[0] = -1;
     182  //   inequalities.appendRow(lowerHalfSpaceCondition);
     183  // }
    183184
    184185  polyhedralCone = gfan::ZCone(inequalities,equations);
     
    238239  }
    239240  omFreeSize(expv,(n+1)*sizeof(int));
    240   if (currentStrategy->restrictToLowerHalfSpace())
    241   {
    242     gfan::ZVector lowerHalfSpaceCondition = gfan::ZVector(n);
    243     lowerHalfSpaceCondition[0] = -1;
    244     inequalities.appendRow(lowerHalfSpaceCondition);
    245   }
     241  // if (currentStrategy->restrictToLowerHalfSpace())
     242  // {
     243  //   gfan::ZVector lowerHalfSpaceCondition = gfan::ZVector(n);
     244  //   lowerHalfSpaceCondition[0] = -1;
     245  //   inequalities.appendRow(lowerHalfSpaceCondition);
     246  // }
    246247
    247248  polyhedralCone = gfan::ZCone(inequalities,equations);
     
    439440   *   to obtain an initial form with respect to interiorPoint+e*facetNormal,
    440441   *   for e>0 sufficiently small */
    441   std::pair<ideal,ring> flipped = currentStrategy->getFlip(polynomialIdeal,reducedPolynomialIdeal,polynomialRing,interiorPoint,facetNormal);
     442  std::pair<ideal,ring> flipped = currentStrategy->getFlip(reducedPolynomialIdeal,polynomialRing,interiorPoint,facetNormal);
    442443  assume(checkPolynomialInput(flipped.first,flipped.second));
    443444  groebnerCone flippedCone(flipped.first, flipped.second, interiorPoint, facetNormal, *currentStrategy);
  • Singular/dyn_modules/gfanlib/ppinitialReduction.cc

    rb71400a rdffd154  
    2929 * with respect to p-t
    3030 **/
    31 static bool pReduce(poly &g, const number p, const ring r)
     31bool pReduce(poly &g, const number p, const ring r)
    3232{
    3333  if (g==NULL)
     
    9292}
    9393
     94void ptNormalize(poly* gStar, const number p, const ring r)
     95{
     96  poly g = *gStar;
     97  if (g==NULL || n_DivBy(p_GetCoeff(g,r),p,r->cf))
     98    return;
     99  p_Test(g,r);
     100
     101  // create p-t
     102  poly pt = p_Init(r);
     103  p_SetCoeff(pt,n_Copy(p,r->cf),r);
     104
     105  pNext(pt) = p_Init(r);
     106  p_SetExp(pNext(pt),1,1,r);
     107  p_Setm(pNext(pt),r);
     108  p_SetCoeff(pNext(pt),n_Init(-1,r->cf),r);
     109
     110  // make g monic with the help of p-t
     111  number a,b;
     112  number gcd = n_ExtGcd(p_GetCoeff(g,r),p,&a,&b,r->cf);
     113  assume(n_IsUnit(gcd,r->cf));
     114  // now a*leadcoef(g)+b*p = gcd with gcd being a unit
     115  // so a*g+b*(p-t)*leadmonom(g) should have a unit as leading coefficient
     116  // but first check whether b is 0,
     117  // since p_Mult_nn doesn't allow 0 as number input
     118  if (n_IsZero(b,r->cf))
     119  {
     120    n_Delete(&a,r->cf);
     121    n_Delete(&b,r->cf);
     122    n_Delete(&gcd,r->cf);
     123    p_Delete(&pt,r);
     124    return;
     125  }
     126  poly m = p_Head(g,r);
     127  p_SetCoeff(m,n_Init(1,r->cf),r);
     128  g = p_Add_q(p_Mult_nn(g,a,r),p_Mult_nn(p_Mult_mm(pt,m,r),b,r),r);
     129  n_Delete(&a,r->cf);
     130  n_Delete(&b,r->cf);
     131  n_Delete(&gcd,r->cf);
     132  p_Delete(&m,r);
     133
     134  p_Test(g,r);
     135  return;
     136}
     137
     138void ptNormalize(ideal I, const number p, const ring r)
     139{
     140  for (int i=0; i<idSize(I); i++)
     141    ptNormalize(&(I->m[i]),p,r);
     142  return;
     143}
     144
    94145#ifndef NDEBUG
    95146BOOLEAN pppReduce(leftv res, leftv args)
     
    140191 * assumes that h and g are in pReduced form and homogeneous in x of the same degree
    141192 **/
    142 bool ppreduceInitially(poly &h, const poly g, const ring r)
    143 {
     193bool ppreduceInitially(poly* hStar, const poly g, const ring r)
     194{
     195  poly h = *hStar;
    144196  if (h==NULL || g==NULL)
    145197    return false;
     
    163215    h = p_Add_q(q1,q2,r);
    164216    p_Test(h,r);
     217    hStar = &h;
    165218    return true;
    166219  }
     
    183236      h = (poly) u->CopyD();
    184237      g = (poly) v->CopyD();
    185       (void)ppreduceInitially(h,g,currRing);
     238      (void)ppreduceInitially(&h,g,currRing);
    186239      p_Delete(&h,currRing);
    187240      p_Delete(&g,currRing);
     
    190243      h = (poly) u->CopyD();
    191244      g = (poly) v->CopyD();
    192       (void)ppreduceInitially(h,g,currRing);
     245      (void)ppreduceInitially(&h,g,currRing);
    193246      p_Delete(&g,currRing);
    194247      res->rtyp = POLY_CMD;
     
    233286  for (int i=0; i<m-1; i++)
    234287    for (int j=i+1; j<m; j++)
    235       if (ppreduceInitially(I->m[j], I->m[i], r) && pReduce(I->m[j],p,r)) return true;
     288      if (ppreduceInitially(&I->m[j], I->m[i], r) && pReduce(I->m[j],p,r)) return true;
    236289
    237290  /***
     
    240293  for (int i=0; i<m-1; i++)
    241294    for (int j=i+1; j<m; j++)
    242       if (ppreduceInitially(I->m[i], I->m[j],r) && pReduce(I->m[i],p,r)) return true;
     295      if (ppreduceInitially(&I->m[i], I->m[j],r) && pReduce(I->m[i],p,r)) return true;
    243296
    244297  /***
     
    309362   **/
    310363  for (int i=0; i<j; i++)
    311     if (ppreduceInitially(I->m[j], I->m[i], r) && pReduce(I->m[j],p,r)) return true;
     364    if (ppreduceInitially(&I->m[j], I->m[i], r) && pReduce(I->m[j],p,r)) return true;
    312365  for (int k=j+1; k<n; k++)
    313     if (ppreduceInitially(I->m[k], I->m[j], r) && pReduce(I->m[k],p,r)) return true;
     366    if (ppreduceInitially(&I->m[k], I->m[j], r) && pReduce(I->m[k],p,r)) return true;
    314367
    315368  /***
     
    319372  for (int i=0; i<j; i++)
    320373    for (int k=j; k<n; k++)
    321       if (ppreduceInitially(I->m[i], I->m[k], r) && pReduce(I->m[i],p,r)) return true;
     374      if (ppreduceInitially(&I->m[i], I->m[k], r) && pReduce(I->m[i],p,r)) return true;
    322375  for (int k=j+1; k<n; k++)
    323     if (ppreduceInitially(I->m[j], I->m[k], r) && pReduce(I->m[j],p,r)) return true;
     376    if (ppreduceInitially(&I->m[j], I->m[k], r) && pReduce(I->m[j],p,r)) return true;
    324377
    325378  /***
     
    376429 * assumes that the generators of G are homogeneous in x of lesser degree.
    377430 **/
    378 bool ppreduceInitially(ideal H, const number p, const ideal G, const ring r)
     431bool ppreduceInitially(ideal &H, const number p, const ideal G, const ring r)
    379432{
    380433  /***
     
    523576static std::vector<int> synchronize(const ideal I, const ideal Hi)
    524577{
    525   int k = idSize(Hi);
    526   int l = idSize(I);
     578  int k = idSize(I);
     579  int l = idSize(Hi);
    527580  std::vector<int> synch(k);
    528581  int j;
     
    532585    {
    533586      if (I->m[i]==Hi->m[j])
     587      {
    534588        synch[i] = j;
     589        break;
     590      }
    535591    }
    536592    if (j==l)
     
    544600  for (unsigned i=0; i<synch.size(); i++)
    545601    if (synch[i]>=0)
     602    {
    546603      I->m[i] = Hi->m[synch[i]];
     604      std::cout << i << " -> " << synch[i] << std::endl;
     605    }
     606}
     607
     608void z_Write(number p, ring r)
     609{
     610  poly g = p_One(r);
     611  p_SetCoeff(g,p,r);
     612  p_Write(g,r);
     613  return;
    547614}
    548615
     
    551618 * assumes that the generators of I are homogeneous in x and that p-t is in I.
    552619 */
    553 bool ppreduceInitially(ideal I, ring r, number p)
     620bool ppreduceInitially(ideal I, const ring r, const number p)
    554621{
    555622  assume(!n_IsUnit(p,r->cf));
     
    585652   *  and all lower components
    586653   **/
    587   std::vector<int> synch = synchronize(I,Hi);
     654  // std::vector<int> synch = synchronize(I,Hi);
    588655  if (ppreduceInitially(Hi,p,r)) return true;
    589   synchronize(I,Hi,synch);
     656  // synchronize(I,Hi,synch);
    590657  id_Test(Hi,r);
    591658  id_Test(I,r);
     
    625692        break;
    626693      }
     694      if (kH==l)
     695        break;
    627696      if (p_GetExp(G->m[kG],1,r)>p_GetExp(Hi->m[kH],1,r))
    628697        G->m[i] = G->m[kG++];
     
    631700    }
    632701    m += l; IDELEMS(GG) = m; GG->m = &G->m[n-m];
    633     std::vector<int> synch = synchronize(I,it->second);
     702    // std::vector<int> synch = synchronize(I,it->second);
    634703    if (ppreduceInitially(it->second,p,GG,r)) return true;
    635     synchronize(I,it->second,synch);
     704    // synchronize(I,it->second,synch);
    636705    idShallowDelete(&Hi); Hi = it->second;
    637706  }
    638707  idShallowDelete(&Hi);
    639708
     709  ptNormalize(I,p,r);
    640710  omFreeBin((ADDRESS)GG, sip_sideal_bin); idShallowDelete(&G);
    641711  return false;
  • Singular/dyn_modules/gfanlib/ppinitialReduction.h

    rb71400a rdffd154  
    1919BOOLEAN ppreduceInitially(leftv res, leftv args);
    2020
     21void z_Write(number p, ring r);
     22
    2123#endif
  • Singular/dyn_modules/gfanlib/singularWishlist.h

    rb71400a rdffd154  
    6969  }
    7070  return;
    71  }
     71}
    7272
    7373#endif
  • Singular/dyn_modules/gfanlib/startingCone.cc

    rb71400a rdffd154  
    336336{
    337337  ring r = currentStrategy.getStartingRing();
    338   const ideal I = currentStrategy.getStartingIdeal();
     338  ideal I = currentStrategy.getStartingIdeal();
     339  currentStrategy.reduce(I,r);
    339340  if (currentStrategy.isConstantCoefficientCase())
    340341  {
     
    389390    // copy the data, so that it be deleted when passed to the loop
    390391    // s <- r
    391     // inI <- I
     392    // inJ <- I
    392393    ring s = rCopy(r);
    393     int k = idSize(I); ideal inI = idInit(k);
     394    int k = idSize(I); ideal inJ = idInit(k);
    394395    nMapFunc identityMap = n_SetMap(r->cf,s->cf);
    395396    for (int i=0; i<k; i++)
    396       inI->m[i] = p_PermPoly(I->m[i],NULL,r,s,identityMap,NULL,0);
     397      inJ->m[i] = p_PermPoly(I->m[i],NULL,r,s,identityMap,NULL,0);
    397398
    398399    // and check whether the dimension of its homogeneity space
    399400    // equals the dimension of the tropical variety
    400     gfan::ZCone zc = linealitySpaceOfGroebnerFan(inI,s);
     401    gfan::ZCone zc = linealitySpaceOfGroebnerFan(inJ,s);
    401402    if (zc.dimension()==currentStrategy.getExpectedDimension())
    402403    { // this shouldn't happen as trivial cases should be caught beforehand
    403404      // this is the case that the tropical variety consists soely out of the lineality space
    404       groebnerCone startingCone(I,inI,s,currentStrategy);
    405       id_Delete(&inI,s);
     405      groebnerCone startingCone(I,inJ,s,currentStrategy);
     406      id_Delete(&inJ,s);
    406407      rDelete(s);
    407408      return startingCone;
     
    410411    // compute a point in the tropical variety outside the lineality space
    411412    // compute the initial ideal with respect to the weight
    412     std::pair<gfan::ZVector,groebnerCone> startingData = tropicalStartingDataViaGroebnerFan(inI,s,currentStrategy);
     413    std::pair<gfan::ZVector,groebnerCone> startingData = tropicalStartingDataViaGroebnerFan(inJ,s,currentStrategy);
    413414    gfan::ZVector startingPoint = startingData.first;
    414415    groebnerCone ambientMaximalCone = groebnerCone(startingData.second);
    415     id_Delete(&inI,s); rDelete(s);
    416     inI = ambientMaximalCone.getPolynomialIdeal();
     416    id_Delete(&inJ,s); rDelete(s);
     417    inJ = ambientMaximalCone.getPolynomialIdeal();
    417418    s = ambientMaximalCone.getPolynomialRing();
    418     inI = sloppyInitial(inI,s,startingPoint);
    419     zc = linealitySpaceOfGroebnerFan(inI,s);
     419    inJ = sloppyInitial(inJ,s,startingPoint);
     420    ideal inI = initial(I,r,startingPoint);
     421    zc = linealitySpaceOfGroebnerFan(inJ,s);
    420422
    421423    // and check whether the dimension of its homogeneity space
     
    424426    { // this case shouldn't happen as trivial cases should be caught beforehand
    425427      // this is the case that the tropical variety has a one-codimensional lineality space
    426       ideal J = lift(I,r,inI,s);
    427       groebnerCone startingCone(J,inI,s,currentStrategy);
    428       id_Delete(&inI,s);
     428      ideal J = lift(I,r,inJ,s);
     429      groebnerCone startingCone(J,inJ,s,currentStrategy);
     430      id_Delete(&inJ,s);
    429431      id_Delete(&J,s);
    430432      return startingCone;
    431433    }
    432434
    433     // from this point on, inI contains the uniformizing parameter,
     435    // from this point on, inJ contains the uniformizing parameter,
    434436    // hence it contains a monomial if and only if its residue over the residue field does.
    435437    // so we will switch to the residue field
     
    439441    rComplete(rShortcut);
    440442    rTest(rShortcut);
    441     k = idSize(inI);
    442     ideal inIShortcut = idInit(k);
     443    k = idSize(inJ);
     444    ideal inJShortcut = idInit(k);
    443445    nMapFunc takingResidues = n_SetMap(s->cf,rShortcut->cf);
    444446    for (int i=0; i<k; i++)
    445       inIShortcut->m[i] = p_PermPoly(inI->m[i],NULL,s,rShortcut,takingResidues,NULL,0);
    446     idSkipZeroes(inIShortcut);
    447     id_Delete(&inI,s);
    448 
    449     // we are interested in a maximal cone of the tropical variety of inIShortcut
     447      inJShortcut->m[i] = p_PermPoly(inJ->m[i],NULL,s,rShortcut,takingResidues,NULL,0);
     448    idSkipZeroes(inJShortcut);
     449    id_Delete(&inJ,s);
     450
     451    // we are interested in a maximal cone of the tropical variety of inJShortcut
    450452    // this basically equivalent to the case without valuation (or constant coefficient case)
    451453    // except that our ideal is still only homogeneous in the later variables,
    452454    // hence we set the optional parameter completelyHomogeneous as 'false'
    453     tropicalStrategy shortcutStrategy(inIShortcut,rShortcut,false);
     455    tropicalStrategy shortcutStrategy(inJShortcut,rShortcut,false);
    454456    groebnerCone startingConeShortcut = tropicalStartingCone(shortcutStrategy);
    455     id_Delete(&inIShortcut,rShortcut); rDelete(rShortcut);
    456 
    457     // now we need to obtain the initial of the residue of inI
     457    id_Delete(&inJShortcut,rShortcut); rDelete(rShortcut);
     458
     459    // now we need to obtain the initial of the residue of inJ
    458460    // with respect to a weight in the tropical cone,
    459     // and obtain the initial of inI with respect to the same weight
     461    // and obtain the initial of inJ with respect to the same weight
    460462    ring sShortcut = startingConeShortcut.getPolynomialRing();
    461     inIShortcut = startingConeShortcut.getPolynomialIdeal();
     463    inJShortcut = startingConeShortcut.getPolynomialIdeal();
    462464    gfan::ZCone zd = startingConeShortcut.getPolyhedralCone();
    463465    gfan::ZVector interiorPoint = startingConeShortcut.getInteriorPoint();
    464     inIShortcut = sloppyInitial(inIShortcut,sShortcut,interiorPoint);
     466    inJShortcut = sloppyInitial(inJShortcut,sShortcut,interiorPoint);
     467    inI = initial(inI,r,interiorPoint);
    465468
    466469    s = rCopy0(sShortcut); // s will be a ring over the valuation ring
     
    470473    rTest(s);
    471474
    472     k = idSize(inIShortcut); // inI will be overwritten with initial of inI
    473     inI = idInit(k+1);
    474     inI->m[0] = p_One(s);    // with respect to that weight
     475    k = idSize(inJShortcut); // inJ will be overwritten with initial of inJ
     476    inJ = idInit(k+1);
     477    inJ->m[0] = p_One(s);    // with respect to that weight
    475478    identityMap = n_SetMap(r->cf,s->cf); // first element will obviously be p
    476     p_SetCoeff(inI->m[0],identityMap(currentStrategy.getUniformizingParameter(),r->cf,s->cf),s);
     479    p_SetCoeff(inJ->m[0],identityMap(currentStrategy.getUniformizingParameter(),r->cf,s->cf),s);
    477480    nMapFunc findingRepresentatives = n_SetMap(sShortcut->cf,s->cf);
    478481    for (int i=0; i<k; i++)              // and then come the rest
    479       inI->m[i+1] = p_PermPoly(inIShortcut->m[i],NULL,sShortcut,s,findingRepresentatives,NULL,0);
    480 
    481     ideal J = lift(I,r,inI,s);
     482      inJ->m[i+1] = p_PermPoly(inJShortcut->m[i],NULL,sShortcut,s,findingRepresentatives,NULL,0);
     483
     484    ideal J = currentStrategy.computeLift(inJ,s,inI,I,r);
    482485    // currentStrategy.reduce(J,s);
    483     groebnerCone startingCone(J,inI,s,currentStrategy);
    484     id_Delete(&inI,s);
     486    groebnerCone startingCone(J,inJ,s,currentStrategy);
     487    id_Delete(&inJ,s);
    485488    id_Delete(&J,s);
    486489    rDelete(s);
     490    id_Delete(&inI,r);
    487491
    488492    assume(checkContainmentInTropicalVariety(startingCone));
  • Singular/dyn_modules/gfanlib/std_wrapper.h

    rb71400a rdffd154  
    22#define CALLGFANLIB_STD_WRAPPER_H
    33
    4 #include <kernel/GBEngine/kstd1.h>
    5 #include <kernel/polys.h>
     4#include <libpolys/polys/simpleideals.h>
     5#include <kernel/structs.h>
    66
    77ideal gfanlib_kStd_wrapper(ideal I, ring r, tHomog h=testHomog);
  • Singular/dyn_modules/gfanlib/tropicalStrategy.cc

    rb71400a rdffd154  
    99#include <kernel/ideals.h>
    1010#include <kernel/GBEngine/stairc.h>
     11#include <kernel/GBEngine/kstd1.h>
    1112#include <Singular/ipshell.h> // for isPrime(int i)
    1213
     
    4849 * Initializes all relevant structures and information for the trivial valuation case,
    4950 * i.e. computing a tropical variety without any valuation.
    50  *g
    5151 */
    5252tropicalStrategy::tropicalStrategy(const ideal I, const ring r,
     
    6767{
    6868  assume(rField_is_Q(r) || rField_is_Zp(r));
    69   startingIdeal = gfanlib_kStd_wrapper(startingIdeal,startingRing);
    7069  if (!completelyHomogeneous)
    7170  {
     
    127126  }
    128127  return rCopy(r);
     128}
     129
     130static ideal constructStartingIdeal(ideal originalIdeal, ring originalRing, number uniformizingParameter, ring startingRing)
     131{
     132  // construct p-t
     133  poly g = p_One(startingRing);
     134  p_SetCoeff(g,uniformizingParameter,startingRing);
     135  pNext(g) = p_One(startingRing);
     136  p_SetExp(pNext(g),1,1,startingRing);
     137  p_SetCoeff(pNext(g),n_Init(-1,startingRing->cf),startingRing);
     138  p_Setm(pNext(g),startingRing);
     139  ideal pt = idInit(1);
     140  pt->m[0] = g;
     141
     142  // map originalIdeal from originalRing into startingRing
     143  int k = idSize(originalIdeal);
     144  ideal J = idInit(k+1);
     145  nMapFunc nMap = n_SetMap(originalRing->cf,startingRing->cf);
     146  int n = rVar(originalRing);
     147  int* shiftByOne = (int*) omAlloc((n+1)*sizeof(int));
     148  for (int i=1; i<=n; i++)
     149    shiftByOne[i]=i+1;
     150  for (int i=0; i<k; i++)
     151    J->m[i] = p_PermPoly(originalIdeal->m[i],shiftByOne,originalRing,startingRing,nMap,NULL,0);
     152  omFreeSize(shiftByOne,(n+1)*sizeof(int));
     153
     154  ring origin = currRing;
     155  rChangeCurrRing(startingRing);
     156  ideal startingIdeal = kNF(pt,startingRing->qideal,J);
     157  rChangeCurrRing(origin);
     158  assume(startingIdeal->m[k]==NULL);
     159  startingIdeal->m[k] = pt->m[0];
     160  startingIdeal = gfanlib_kStd_wrapper(startingIdeal,startingRing);
     161
     162  id_Delete(&J,startingRing);
     163  pt->m[0] = NULL;
     164  id_Delete(&pt,startingRing);
     165  return startingIdeal;
    129166}
    130167
     
    149186  /* assume that the ground field of the originalRing is Q */
    150187  assume(rField_is_Q(s));
    151   originalRing = rCopy(s);
    152188
    153189  /* replace Q with Z for the startingRing
     
    160196
    161197  /* map the input ideal into the new polynomial ring */
    162   int k = idSize(J);
    163   startingIdeal = idInit(k+1);
    164   poly g = p_One(startingRing);
    165   p_SetCoeff(g,uniformizingParameter,startingRing);
    166   pNext(g) = p_One(startingRing);
    167   p_SetExp(pNext(g),1,1,startingRing);
    168   p_SetCoeff(pNext(g),n_Init(-1,startingRing->cf),startingRing);
    169   p_Setm(pNext(g),startingRing);
    170   startingIdeal->m[0] = g;
    171   int n = rVar(originalRing);
    172   int* shiftByOne = (int*) omAlloc((n+1)*sizeof(int));
    173   for (int i=1; i<=n; i++)
    174     shiftByOne[i]=i+1;
    175   for (int i=0; i<k; i++)
    176     startingIdeal->m[i+1] = p_PermPoly(J->m[i],shiftByOne,originalRing,startingRing,nMap,NULL,0);
    177   omFreeSize(shiftByOne,(n+1)*sizeof(int));
    178   startingIdeal = gfanlib_kStd_wrapper(startingIdeal,startingRing);
     198  startingIdeal = constructStartingIdeal(J,s,uniformizingParameter,startingRing);
    179199
    180200  linealitySpace = homogeneitySpace(startingIdeal,startingRing);
     
    529549}
    530550
     551ideal tropicalStrategy::computeLift(const ideal inJs, const ring s, const ideal inIr, const ideal Ir, const ring r) const
     552{
     553  int k = idSize(inJs);
     554  ideal inJr = idInit(k);
     555  nMapFunc identitysr = n_SetMap(s->cf,r->cf);
     556  for (int i=0; i<k; i++)
     557    inJr->m[i] = p_PermPoly(inJs->m[i],NULL,s,r,identitysr,NULL,0);
     558
     559  ideal Jr = getWitness(inJr,inIr,Ir,r);
     560  nMapFunc identityrs = n_SetMap(r->cf,s->cf);
     561  ideal Js = idInit(k);
     562  for (int i=0; i<k; i++)
     563    Js->m[i] = p_PermPoly(Jr->m[i],NULL,r,s,identityrs,NULL,0);
     564  return Js;
     565}
     566
    531567static void deleteOrdering(ring r)
    532568{
     
    610646}
    611647
    612 
    613 std::pair<ideal,ring> tropicalStrategy::getFlip(const ideal I, const ideal redI, const ring r,
     648std::pair<ideal,ring> tropicalStrategy::getFlip(const ideal Ir, const ring r,
    614649                                                const gfan::ZVector interiorPoint,
    615650                                                const gfan::ZVector facetNormal) const
    616651{
    617652  assume(isValuationTrivial() || interiorPoint[0].sign()<0);
    618   assume(checkForUniformizingBinomial(I,r));
     653  assume(checkForUniformizingBinomial(Ir,r));
    619654
    620655  // get a generating system of the initial ideal
    621656  // and compute a standard basis with respect to adjacent ordering
    622   ideal inIr = initial(redI,r,interiorPoint);
     657  ideal inIr = initial(Ir,r,interiorPoint);
    623658  ring sAdjusted = copyAndChangeOrderingWP(r,interiorPoint,facetNormal);
    624659  nMapFunc identity = n_SetMap(r->cf,sAdjusted->cf);
    625   int k = idSize(I); ideal inIsAdjusted = idInit(k);
     660  int k = idSize(Ir); ideal inIsAdjusted = idInit(k);
    626661  for (int i=0; i<k; i++)
    627662    inIsAdjusted->m[i] = p_PermPoly(inIr->m[i],NULL,r,sAdjusted,identity,NULL,0);
     
    636671    inJr->m[i] = p_PermPoly(inJsAdjusted->m[i],NULL,sAdjusted,r,identity,NULL,0);
    637672
    638   ideal Jr = getWitness(inJr,inIr,redI,r);
     673  ideal Jr = getWitness(inJr,inIr,Ir,r);
    639674  ring s = copyAndChangeOrderingLS(r,interiorPoint,facetNormal);
    640675  identity = n_SetMap(r->cf,s->cf);
  • Singular/dyn_modules/gfanlib/tropicalStrategy.h

    rb71400a rdffd154  
    4040  /**
    4141   * the expected Dimension of the polyhedral output,
    42    * i.e. the dimension of the ideal if trivial valuation
    43    * or the dimension of the ideal plus one if non-trivial valuation
     42   * i.e. the dimension of the ideal if valuation trivial
     43   * or the dimension of the ideal plus one if valuation non-trivial
    4444   * (as the output is supposed to be intersected with a hyperplane)
    4545   */
     
    302302  ideal getWitness(const ideal inJ, const ideal inI, const ideal I, const ring r) const;
    303303
     304  ideal computeLift(const ideal inJs, const ring s, const ideal inIr, const ideal Ir, const ring r) const;
     305
    304306  /**
    305307   * given generators of the initial ideal, computes its standard basis
     
    311313   * computes the groebner cone adjacent to it
    312314   */
    313   std::pair<ideal,ring> getFlip(const ideal I, const ideal redI, const ring r, const gfan::ZVector interiorPoint, const gfan::ZVector facetNormal) const;
     315  std::pair<ideal,ring> getFlip(const ideal Ir, const ring r, const gfan::ZVector interiorPoint, const gfan::ZVector facetNormal) const;
    314316};
    315317
  • Singular/dyn_modules/gfanlib/tropicalTraversal.cc

    rb71400a rdffd154  
    88  while(!workingList.empty())
    99  {
    10     // std::cout << "starting traversal" << std::endl;
     10    std::cout << "starting traversal" << std::endl;
    1111    const groebnerCone sigma=*(workingList.begin());
    1212    const groebnerCones neighbours = sigma.tropicalNeighbours();
     
    1818    tropicalVariety.insert(sigma);
    1919    workingList.erase(sigma);
    20     // std::cout << "tropicalVariety.size():" << tropicalVariety.size() << std::endl;
    21     // std::cout << "workingList.size():" << workingList.size() << std::endl;
     20    std::cout << "tropicalVariety.size():" << tropicalVariety.size() << std::endl;
     21    std::cout << "workingList.size():" << workingList.size() << std::endl;
    2222  }
    2323  return tropicalVariety;
  • Singular/dyn_modules/gfanlib/tropicalVariety.cc

    rb71400a rdffd154  
    11#include <callgfanlib_conversion.h>
     2#include <std_wrapper.h>
    23#include <bbfan.h>
    34#include <groebnerCone.h>
     
    3637    if (v==NULL)
    3738    {
     39      setOptionRedSB();
     40      if (!hasFlag(u,FLAG_STD))
     41        I = gfanlib_kStd_wrapper(I,currRing);
    3842      tropicalStrategy currentStrategy(I,currRing);
    39       setOptionRedSB();
    4043      gfan::ZFan* tropI = tropicalVariety(currentStrategy);
    41       undoSetOptionRedSB();
    4244      res->rtyp = fanID;
    4345      res->data = (char*) tropI;
     46      undoSetOptionRedSB();
    4447      return FALSE;
    4548    }
     
    4750    {
    4851      number p = (number) v->CopyD();
     52      if (!hasFlag(u,FLAG_STD))
     53        I = gfanlib_kStd_wrapper(I,currRing);
    4954      tropicalStrategy currentStrategy(I,p,currRing);
    5055      gfan::ZFan* tropI = tropicalVariety(currentStrategy);
  • Singular/dyn_modules/gfanlib/witness.cc

    rb71400a rdffd154  
    77#include <utility>
    88
    9 /***
    10  * Given f and G={g1,...,gk}, computes Q=(q1,...,qk) such that
    11  * f = q1*g1+...+qk*gk
    12  * is a determinate division with remainder with respect to the
    13  * ordering active in r.
    14  * Returns an error if this is not possible.
    15  **/
    169matrix divisionDiscardingRemainder(const poly f, const ideal G, const ring r)
    1710{
     
    2619}
    2720
    28 /**
    29  * Given F[0],...,F[l] and G[0],...,G[k],
    30  * computes Q[i,j] for i=0,..,k and j=0,...,l such that
    31  * F[j] = Q[0,j]*G[0]+...+Q[k,j]*G[k].
    32  */
    3321matrix divisionDiscardingRemainder(const ideal F, const ideal G, const ring r)
    3422{
     
    4432}
    4533
    46 #ifndef NDEBUG
    47 BOOLEAN dwr0(leftv res, leftv args)
    48 {
    49   leftv u = args;
    50   leftv v = u->next;
    51   poly f = (poly) u->CopyD();
    52   ideal G = (ideal) v->CopyD();
    53   omUpdateInfo();
    54   Print("usedBytesBefore=%ld\n",om_Info.UsedBytes);
    55   matrix Q = divisionDiscardingRemainder(f,G,currRing);
    56   p_Delete(&f,currRing);
    57   id_Delete(&G,currRing);
    58   res->rtyp = MATRIX_CMD;
    59   res->data = (char*) Q;
    60   return FALSE;
    61 }
    62 #endif
    63 
    64 /***
    65  * Let w be the uppermost weight vector in the matrix defining the ordering on r.
    66  * Let I be a Groebner basis of an ideal in r, inI its initial form with respect w.
    67  * Given an w-homogeneous element m of inI, computes a witness g of m in I,
    68  * i.e. g in I such that in_w(g)=m.
    69  **/
    7034poly witness(const poly m, const ideal I, const ideal inI, const ring r)
    7135{
     
    8650}
    8751
    88 #ifndef NDEBUG
    89 BOOLEAN witness0(leftv res, leftv args)
    90 {
    91   leftv u = args;
    92   leftv v = u->next;
    93   leftv w = v->next;
    94   poly m = (poly) u->CopyD();
    95   ideal G = (ideal) v->CopyD();
    96   ideal inG = (ideal) w->CopyD();
    97   omUpdateInfo();
    98   Print("usedBytesBefore=%ld\n",om_Info.UsedBytes);
    99   poly f = witness(m,G,inG,currRing);
    100   p_Delete(&m,currRing);
    101   id_Delete(&G,currRing);
    102   id_Delete(&inG,currRing);
    103   res->rtyp = POLY_CMD;
    104   res->data = (char*) f;
    105   return FALSE;
    106 }
    107 #endif
    108 
    109 /***
    110  * Let w be the uppermost weight vector in the matrix defining the ordering on r.
    111  * Let I be a Groebner basis of an ideal in r, inI its initial form with respect w.
    112  * Given an w-homogeneous element m of inI, computes a witness g of m in I,
    113  * i.e. g in I such that in_w(g)=m.
    114  **/
    11552ideal witness(const ideal inI, const ideal J, const ring r)
    11653{
     
    13269  return I;
    13370}
     71
     72#ifndef NDEBUG
     73BOOLEAN dwrDebug(leftv res, leftv args)
     74{
     75  leftv u = args;
     76  leftv v = u->next;
     77  ideal F = (ideal) u->CopyD();
     78  ideal G = (ideal) v->CopyD();
     79  omUpdateInfo();
     80  Print("usedBytesBefore=%ld\n",om_Info.UsedBytes);
     81  matrix Q = divisionDiscardingRemainder(F,G,currRing);
     82  id_Delete(&F,currRing);
     83  id_Delete(&G,currRing);
     84  res->rtyp = MATRIX_CMD;
     85  res->data = (char*) Q;
     86  return FALSE;
     87}
     88
     89BOOLEAN witnessDebug(leftv res, leftv args)
     90{
     91  leftv u = args;
     92  leftv v = u->next;
     93  ideal inI = (ideal) u->CopyD();
     94  ideal J = (ideal) v->CopyD();
     95  omUpdateInfo();
     96  Print("usedBytesBefore=%ld\n",om_Info.UsedBytes);
     97  ideal I = witness(inI,J,currRing);
     98  id_Delete(&inI,currRing);
     99  id_Delete(&J,currRing);
     100  res->rtyp = IDEAL_CMD;
     101  res->data = (char*) I;
     102  return FALSE;
     103}
     104#endif
  • Singular/dyn_modules/gfanlib/witness.h

    rb71400a rdffd154  
    55#include <libpolys/polys/simpleideals.h>
    66
     7/**
     8 * Computes a division discarding remainder of f with respect to G.
     9 * Given f a polynomial and G={g1,...,gk} a set of polynomials in r,
     10 * returns a matrix Q=(q1,...,qk) over r such that
     11 *   f = q1*g1+...+qk*gk+s
     12 * is a determinate division with remainder s.
     13 */
    714matrix divisionDiscardingRemainder(const poly f, const ideal G, const ring r);
     15
     16/**
     17 * Computes a division discarding remainder of F with respect to G.
     18 * Given F={f1,...,fl} and G={g1,...,gk} two sets of polynomials in r,
     19 * returns a matrix Q=(qij) i=1,..,k j=1,...,l over r such that
     20 *   fj = q1j*g1+...+qkj*gk+sj
     21 * is a determinate division with remainder sj for all j=1,...,l.
     22 */
    823matrix divisionDiscardingRemainder(const ideal F, const ideal G, const ring r);
     24
     25/**
     26 * Let w be the uppermost weight vector in the matrix defining the ordering on r.
     27 * Let I be a Groebner basis of an ideal in r, inI its initial form with respect w.
     28 * Given an w-homogeneous element m of inI, computes a witness g of m in I,
     29 * i.e. g in I such that in_w(g)=m.
     30 */
    931poly witness(const poly m, const ideal I, const ideal inI, const ring r);
     32
     33/**
     34 * Computes witnesses in J for inI
     35 * Given inI={h1,...,hl} and J={g1,...,gk} two sets of polynomials in r,
     36 * returns a set I={f1,...,fl} of <g1,...,gk> such that
     37 *   in_w(fj)=hj for all j=1,...,l,
     38 * where w denotes the uppoermost weight vector in the matrix defining the ordering on r.
     39 * Assumes that hj is an element of <in_w(g1),...,in_w(gk)>
     40 */
    1041ideal witness(const ideal inI, const ideal J, const ring r);
    1142
    1243#ifndef NDEBUG
    1344#include <Singular/ipid.h>
    14 
    15 BOOLEAN dwr0(leftv res, leftv args);
    16 BOOLEAN witness0(leftv res, leftv args);
     45BOOLEAN dwrDebug(leftv res, leftv args);
     46BOOLEAN witnessDebug(leftv res, leftv args);
    1747#endif
    1848
Note: See TracChangeset for help on using the changeset viewer.