Changeset 61335ab in git


Ignore:
Timestamp:
Sep 27, 2016, 3:07:11 PM (8 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'b4f17ed1d25f93d46dbe29e4b499baecc2fd51bb')
Children:
1a7f12281eef1d444ca75b01a111122c604a85f4
Parents:
4699031b427e5217a931823e41fd2d6624cc1d8b6aca64497b457e982197c5264a6b4e6147f9c757
git-author:
Hans Schoenemann <hannes@mathematik.uni-kl.de>2016-09-27 15:07:11+02:00
git-committer:
GitHub <noreply@github.com>2016-09-27 15:07:11+02:00
Message:
Merge pull request #790 from YueRen/tropicalStartingConeBug

Tropical starting cone bug
Files:
4 added
30 edited

Legend:

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

    r469903 r61335ab  
    11ACLOCAL_AMFLAGS = -I ../../m4
    22
    3 SOURCES = customstd.cc
     3SOURCES = customstd.h customstd.cc
    44
    55MY_CPPFLAGS = -I${srcdir} -I${top_srcdir} -I${top_builddir} \
  • Singular/dyn_modules/customstd/customstd.cc

    r469903 r61335ab  
    4242// routine that simplifies the new element by dividing it with the maximal possible
    4343// partially saturating the ideal with respect to all variables doing so
    44 static BOOLEAN sat_vars_sp(kStrategy strat)
     44BOOLEAN sat_vars_sp(kStrategy strat)
    4545{
    4646  BOOLEAN b = FALSE; // set b to TRUE, if spoly was changed,
     
    205205}
    206206
    207 // static BOOLEAN abortIfMonomial_sp(kStrategy strat)
    208 // {
    209 //   BOOLEAN b = FALSE; // set b to TRUE, if spoly was changed,
    210 //                      // let it remain FALSE otherwise
    211 //   if (strat->P.t_p==NULL)
    212 //   {
    213 //     poly p=strat->P.p;
    214 //     if (pNext(p)==NULL)
    215 //     {
    216 //       // if a term is contained in the ideal, abort std computation
    217 //       // and store the output in idealCache to be returned
    218 //       while ((strat->Ll >= 0))
    219 //         deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
    220 //       std::cout << "aborting!" << std::endl;
    221 //       return FALSE;
    222 //     }
    223 //   }
    224 //   else
    225 //   {
    226 //     poly p=strat->P.t_p;
    227 //     if (pNext(p)==NULL)
    228 //     {
    229 //       // if a term is contained in the ideal, abort std computation
    230 //       // and store the output in idealCache to be returned
    231 //       while ((strat->Ll >= 0))
    232 //         deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
    233 //       std::cout << "aborting!" << std::endl;
    234 //       return FALSE;
    235 //     }
    236 //   }
    237 //   return b; // return TRUE if sp was changed, FALSE if not
    238 // }
    239 // static BOOLEAN abortifmonomialstd(leftv res, leftv args)
    240 // {
    241 //   if (args!=NULL)
    242 //   {
    243 //     if ((args->Typ()==IDEAL_CMD) && (args->next==NULL))
    244 //     {
    245 //       ideal I=(ideal)args->Data();
    246 //       idealCache = NULL;
    247 //       I=kStd(I,currRing->qideal,testHomog,NULL,NULL,0,0,NULL,abortIfMonomial_sp);
    248 //       res->rtyp=IDEAL_CMD;
    249 //       if (idealCache)
    250 //         res->data=(char*)idealCache;
    251 //       else
    252 //       {
    253 //         idSkipZeroes(I);
    254 //         res->data=(char*)I;
    255 //       }
    256 //       return FALSE;
    257 //     }
    258 //   }
    259 //   WerrorS("abortifmonomialstd: unexpected parameters");
    260 //   return TRUE;
    261 // }
    262 
     207BOOLEAN abort_if_monomial_sp(kStrategy strat)
     208{
     209  BOOLEAN b = FALSE; // set b to TRUE, if spoly was changed,
     210                     // let it remain FALSE otherwise
     211  if (strat->P.t_p==NULL)
     212  {
     213    poly p=strat->P.p;
     214    if (pNext(p)==NULL)
     215    {
     216      while ((strat->Ll >= 0))
     217        deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
     218      return FALSE;
     219    }
     220  }
     221  else
     222  {
     223    poly p=strat->P.t_p;
     224    if (pNext(p)==NULL)
     225    {
     226      while ((strat->Ll >= 0))
     227        deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
     228      return FALSE;
     229    }
     230  }
     231  return b; // return TRUE if sp was changed, FALSE if not
     232}
     233
     234BOOLEAN monomialabortstd(leftv res, leftv args)
     235{
     236  if (args!=NULL)
     237  {
     238    if ((args->Typ()==IDEAL_CMD) && (args->next==NULL))
     239    {
     240      ideal I=(ideal)args->Data();
     241      I=kStd(I,currRing->qideal,testHomog,NULL,NULL,0,0,NULL,abort_if_monomial_sp);
     242      idSkipZeroes(I);
     243      res->rtyp=IDEAL_CMD;
     244      res->data=(char*)I;
     245      return FALSE;
     246    }
     247  }
     248  WerrorS("monomialabortstd: unexpected parameters");
     249  return TRUE;
     250}
    263251
    264252// static long wDeg(const poly p, const ring r)
     
    447435  p->iiAddCproc("customstd.so","satstd",FALSE,satstd);
    448436  // p->iiAddCproc("std_demo","satstdWithInitialCheck",FALSE,satstdWithInitialCheck);
    449   // p->iiAddCproc("std_demo","abortifmonomialstd",FALSE,abortifmonomialstd);
     437  p->iiAddCproc("std_demo","monomialabortstd",FALSE,monomialabortstd);
    450438  // PrintS("init of std_demo - type `listvar(Std_demo);` to its contents\n");
    451439  return (MAX_TOK);
  • Singular/dyn_modules/gfanlib/Makefile.am

    r469903 r61335ab  
    11ACLOCAL_AMFLAGS = -I ../../m4
    22
    3 SOURCES = singularWishlist.h 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 std_wrapper.cc std_wrapper.h tropicalVarietyOfPolynomials.h tropicalVarietyOfPolynomials.cc ppinitialReduction.cc ppinitialReduction.h containsMonomial.cc containsMonomial.h adjustWeights.cc adjustWeights.h tropicalStrategy.cc tropicalStrategy.h initial.cc initial.h witness.cc witness.h lift.cc lift.h flip.cc flip.h tropicalCurves.cc tropicalCurves.h groebnerCone.cc groebnerCone.h startingCone.cc startingCone.h tropicalTraversal.cc tropicalTraversal.h tropicalVarietyOfIdeals.cc tropicalVarietyOfIdeals.h tropicalVariety.cc tropicalVariety.h groebnerFan.cc groebnerFan.h groebnerComplex.cc groebnerComplex.h tropical.cc tropical.h gfanlib.cc
     3SOURCES = singularWishlist.cc singularWishlist.h 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 std_wrapper.cc std_wrapper.h tropicalDebug.h tropicalDebug.cc tropicalVarietyOfPolynomials.h tropicalVarietyOfPolynomials.cc ppinitialReduction.cc ppinitialReduction.h containsMonomial.cc containsMonomial.h adjustWeights.cc adjustWeights.h tropicalStrategy.cc tropicalStrategy.h initial.cc initial.h witness.cc witness.h lift.cc lift.h flip.cc flip.h tropicalCurves.cc tropicalCurves.h groebnerCone.cc groebnerCone.h startingCone.cc startingCone.h tropicalTraversal.cc tropicalTraversal.h tropicalVarietyOfIdeals.cc tropicalVarietyOfIdeals.h tropicalVariety.cc tropicalVariety.h groebnerFan.cc groebnerFan.h groebnerComplex.cc groebnerComplex.h tropical.cc tropical.h gfanlib.cc
    44
    55MY_CPPFLAGS = -I${srcdir} -I${top_srcdir} -I${top_builddir} \
  • Singular/dyn_modules/gfanlib/adjustWeights.cc

    r469903 r61335ab  
    1 #include <gfanlib/gfanlib_vector.h>
    21#include <kernel/mod2.h>
    32
     3#include <gfanlib/gfanlib_vector.h>
    44
    55#ifndef NDEBUG
    6 static bool checkForNonPositiveEntries(const gfan::ZVector &w)
    7 {
    8   for (unsigned i=0; i<w.size(); i++)
    9   {
    10     if (w[i].sign()<=0)
    11     {
    12       std::cout << "ERROR: non-positive weight in weight vector" << std::endl
    13                 << "weight: " << w << std::endl;
    14       return false;
    15     }
    16   }
    17   return true;
    18 }
    19 
    20 static bool checkForNonPositiveLaterEntries(const gfan::ZVector &w)
    21 {
    22   for (unsigned i=1; i<w.size(); i++)
    23   {
    24     if (w[i].sign()<=0)
    25     {
    26       std::cout << "ERROR: non-positive weight in weight vector later entries" << std::endl
    27                 << "weight: " << w << std::endl;
    28       return false;
    29     }
    30   }
    31   return true;
    32 }
     6#include <tropicalDebug.h>
    337#endif //NDEBUG
    348
  • Singular/dyn_modules/gfanlib/bbcone.cc

    r469903 r61335ab  
    16461646
    16471647      delete facet;
     1648      delete point;
     1649      if (v->Typ() == INTVEC_CMD)
     1650        delete point1;
     1651      return FALSE;
     1652    }
     1653  }
     1654  WerrorS("facetContaining: unexpected parameters");
     1655  return TRUE;
     1656}
     1657
     1658
     1659BOOLEAN faceContaining(leftv res, leftv args)
     1660{
     1661  gfan::initializeCddlibIfRequired();
     1662  leftv u = args;
     1663  if ((u != NULL) && (u->Typ() == coneID))
     1664  {
     1665    leftv v = u->next;
     1666    if ((v != NULL) && ((v->Typ() == BIGINTMAT_CMD) || (v->Typ() == INTVEC_CMD)))
     1667    {
     1668      gfan::ZCone* zc = (gfan::ZCone*) u->Data();
     1669
     1670      bigintmat* point1;
     1671      if (v->Typ() == INTVEC_CMD)
     1672      {
     1673        intvec* point0 = (intvec*) v->Data();
     1674        point1 = iv2bim(point0,coeffs_BIGINT)->transpose();
     1675      }
     1676      else
     1677        point1 = (bigintmat*) v->Data();
     1678      gfan::ZVector* point = bigintmatToZVector(*point1);
     1679
     1680      res->rtyp = coneID;
     1681      res->data = (void*) new gfan::ZCone(zc->faceContaining(*point));
     1682
    16481683      delete point;
    16491684      if (v->Typ() == INTVEC_CMD)
     
    19271962  p->iiAddCproc("","listOfFacets",FALSE,listOfFacets);
    19281963  p->iiAddCproc("","facetContaining",FALSE,facetContaining);
     1964  p->iiAddCproc("","faceContaining",FALSE,faceContaining);
    19291965  coneID=setBlackboxStuff(b,"cone");
    19301966}
  • Singular/dyn_modules/gfanlib/containsMonomial.cc

    r469903 r61335ab  
    1 #include <bbcone.h>
    21#include <kernel/polys.h>
    32#include <kernel/GBEngine/kstd1.h>
    43#include <polys/prCopy.h>
     4
     5#include <callgfanlib_conversion.h>
     6#include <bbcone.h>
     7#include <std_wrapper.h>
    58
    69poly checkForMonomialViaSuddenSaturation(const ideal I, const ring r)
     
    5053}
    5154
     55poly searchForMonomialViaStepwiseSaturation(const ideal I, const ring r, const gfan::ZVector w0)
     56{
     57  gfan::ZVector w = w0;
     58
     59  ring origin = currRing;
     60  if (currRing != r)
     61    rChangeCurrRing(r);
     62
     63  // copy ring including qideal but without ordering
     64  // set ordering to be wp(w)
     65  int n = rVar(r);
     66  ring rGraded = rCopy0(r,TRUE,FALSE);
     67  rGraded->order = (int*) omAlloc0(3*sizeof(int));
     68  rGraded->block0 = (int*) omAlloc0(3*sizeof(int));
     69  rGraded->block1 = (int*) omAlloc0(3*sizeof(int));
     70  rGraded->wvhdl = (int**) omAlloc0(3*sizeof(int**));
     71  rGraded->order[0] = ringorder_wp;
     72  rGraded->block0[0] = 1;
     73  rGraded->block1[0] = n;
     74  bool overflow;
     75  rGraded->wvhdl[0] = ZVectorToIntStar(w,overflow);
     76  rGraded->order[1] = ringorder_C;
     77  rComplete(rGraded);
     78  rTest(rGraded);
     79
     80  // map I into the new ring so that it becomes a graded ideal
     81  int k = IDELEMS(I);
     82  nMapFunc identity = n_SetMap(r->cf,rGraded->cf);
     83  ideal Jold = idInit(k);
     84  for (int i=0; i<k; i++)
     85    Jold->m[i] = p_PermPoly(I->m[i],NULL,r,rGraded,identity,NULL,0);
     86
     87  // compute std and check whether result contains a monomial,
     88  // wrap up computation if it does
     89  ideal Jnew = gfanlib_monomialabortStd_wrapper(Jold,rGraded);
     90  id_Delete(&Jold,rGraded);
     91  k = IDELEMS(Jnew);
     92  for (int i=0; i<k; i++)
     93  {
     94    poly g = Jnew->m[i];
     95    if (g!=NULL && pNext(g)==NULL && n_IsUnit(p_GetCoeff(g,r),r->cf))
     96    {
     97      poly monomial = p_One(r);
     98      for (int j=1; j<=rVar(r); j++)
     99        p_SetExp(monomial,j,p_GetExp(g,j,rGraded),r);
     100      p_Setm(monomial,r);
     101
     102      id_Delete(&Jnew,rGraded);
     103      rDelete(rGraded);
     104      if (currRing != origin)
     105        rChangeCurrRing(origin);
     106      return monomial;
     107    }
     108  }
     109
     110  // prepare permutation to cycle all variables
     111  int* cycleAllVariables = (int*) omAlloc0((n+1)*sizeof(int));
     112  for (int i=1; i<n; i++)
     113    cycleAllVariables[i]=i+1;
     114  cycleAllVariables[n]=1;
     115  // prepare storage of maximal powers that are being divided with
     116  int* maxPowers = (int*) omAlloc0((n+1)*sizeof(int));
     117
     118  for(int currentSaturationVariable=n-1; currentSaturationVariable>0; currentSaturationVariable--)
     119  {
     120    // divide out the maximal power in the last variable,
     121    // storing the maximum of all powers.
     122    for (int i=0; i<k; i++)
     123    {
     124      poly g = Jnew->m[i];
     125      int d = p_GetExp(g,n,rGraded);
     126      if (d>0)
     127      {
     128        for (; g!=NULL; pIter(g))
     129        {
     130          p_SubExp(g,n,d,rGraded);
     131          p_Setm(g,rGraded);
     132        }
     133        if (d>maxPowers[currentSaturationVariable+1])
     134          maxPowers[currentSaturationVariable+1]=d;
     135      }
     136    }
     137
     138    // cycle all variables, i.e. x_1->x_2, x_2->x_3, ..., x_n->x_1
     139    // so that a new variable is at the last position
     140    gfan::Integer cache = w[n-1];
     141    for (int i=n-1; i>0; i--)
     142      w[i] = w[i-1];
     143    w[0] = cache;
     144
     145    ring rGradedNew = rCopy0(r,TRUE,FALSE);
     146    rGradedNew->order = (int*) omAlloc0(3*sizeof(int));
     147    rGradedNew->block0 = (int*) omAlloc0(3*sizeof(int));
     148    rGradedNew->block1 = (int*) omAlloc0(3*sizeof(int));
     149    rGradedNew->wvhdl = (int**) omAlloc0(3*sizeof(int**));
     150    rGradedNew->order[0] = ringorder_wp;
     151    rGradedNew->block0[0] = 1;
     152    rGradedNew->block1[0] = n;
     153    bool overflow;
     154    rGradedNew->wvhdl[0] = ZVectorToIntStar(w,overflow);
     155    rGradedNew->order[1] = ringorder_C;
     156    rComplete(rGradedNew);
     157    rTest(rGradedNew);
     158
     159    identity = n_SetMap(rGraded->cf,rGradedNew->cf);
     160    Jold = idInit(k);
     161    for (int i=0; i<k; i++)
     162      Jold->m[i] = p_PermPoly(Jnew->m[i],cycleAllVariables,rGraded,rGradedNew,identity,NULL,0);
     163    id_Delete(&Jnew,rGraded);
     164    rDelete(rGraded);
     165
     166    rGraded = rGradedNew;
     167    rGradedNew = NULL;
     168
     169    // compute std and check whether result contains a monomial,
     170    // wrap up computation if it does
     171    // adjust for the powers already divided out of the ideal
     172    // and the shift of variables!
     173    Jnew = gfanlib_monomialabortStd_wrapper(Jold,rGraded);
     174    id_Delete(&Jold,rGraded);
     175
     176    k = IDELEMS(Jnew);
     177    for (int i=0; i<k; i++)
     178    {
     179      poly g = Jnew->m[i];
     180      if (g!=NULL && pNext(g)==NULL && n_IsUnit(p_GetCoeff(g,rGraded),rGraded->cf))
     181      {
     182        poly monomial = p_One(r);
     183        for (int j=1; j<=rVar(r); j++)
     184        {
     185          int jDeshifted = (j-currentSaturationVariable)%n;
     186          if (jDeshifted<=0) jDeshifted = jDeshifted+n;
     187          p_SetExp(monomial,j,p_GetExp(g,jDeshifted,rGraded)+maxPowers[j],r);
     188        }
     189        p_Setm(monomial,r);
     190
     191        id_Delete(&Jnew,rGraded);
     192        rDelete(rGraded);
     193        omFree(cycleAllVariables);
     194        omFree(maxPowers);
     195        if (currRing != origin)
     196          rChangeCurrRing(origin);
     197        return monomial;
     198      }
     199    }
     200  }
     201
     202  if (currRing != origin)
     203    rChangeCurrRing(origin);
     204
     205  id_Delete(&Jnew,rGraded);
     206  rDelete(rGraded);
     207  omFree(cycleAllVariables);
     208  omFree(maxPowers);
     209  return NULL;
     210}
    52211
    53212BOOLEAN checkForMonomial(leftv res, leftv args)
     
    73232}
    74233
    75 #if 0
    76 // /***
    77 //  * Creates an int* representing the transposition of the last two variables
    78 //  **/
    79 // static inline int* createPermutationVectorForSaturation(static const ring &r)
    80 // {
    81 //   int* w = (int*) omAlloc0((rVar(r)+1)*sizeof(int));
    82 //   for (int i=1; i<=rVar(r)-2; i++)
    83 //     w[i] = i;
    84 //   w[rVar(r)-1] = rVar(r);
    85 //   w[rVar(r)] = rVar(r)-1;
    86 // }
    87 
    88 
    89 /***
    90  * Creates an int* representing the permutation
    91  * 1 -> 1, ..., i-1 -> i-1, i -> n, i+1 -> n-1, ... , n -> i
    92  **/
    93 static inline int* createPermutationVectorForSaturation(const ring &r, const int i)
    94 {
    95   int* sigma = (int*) omAlloc0((rVar(r)+1)*sizeof(int));
    96   int j;
    97   for (j=1; j<i; j++)
    98     sigma[j] = j;
    99   for (; j<=rVar(r); j++)
    100     sigma[j] = rVar(r)-j+i;
    101   return(sigma);
    102 }
    103 
    104 
    105 /***
    106  * Changes the int* representing the permutation
    107  * 1 -> 1, ..., i -> i, i+1 -> n, i+2 -> n-1, ... , n -> i+1
    108  * to an int* representing the permutation
    109  * 1 -> 1, ..., i-1 -> i-1, i -> n, i+1 -> n-1, ... , n -> i
    110  **/
    111 static void changePermutationVectorForSaturation(int* sigma, const ring &r, const int i)
    112 {
    113   for (int j=i; j<rVar(r); j++)
    114     sigma[j] = rVar(r)-j+i;
    115   sigma[rVar(r)] = i;
    116 }
    117 
    118 
    119 /***
    120  * returns a ring in which the weights of the ring variables are permuted
    121  * if handed over a poly in which the variables are permuted, this is basically
    122  * as good as permuting the variables of the ring itself.
    123  **/
    124 static ring permuteWeighstOfRingVariables(const ring &r, const int* const sigma)
    125 {
    126   ring s = rCopy0(r);
    127   for (int j=0; j<rVar(r); j++)
    128   {
    129     s->wvhdl[0][j] = r->wvhdl[0][sigma[j+1]];
    130     s->wvhdl[1][j] = r->wvhdl[1][sigma[j+1]];
    131   }
    132   rComplete(s,1);
    133   rTest(s);
    134   return s;
    135 }
    136 
    137 
    138 /***
    139  * creates a ring s that is a copy of r except with ordering wp(w)
    140  **/
    141 static inline ring createInitialRingForSaturation(const ring &r, const gfan::ZVector &w, bool &ok)
    142 {
    143   assume(rVar(r) == (int) w.size());
    144 
    145   ring s = rCopy0(r); int i;
    146   for (i=0; s->order[i]; i++)
    147     omFreeSize(s->wvhdl[i],rVar(r)*sizeof(int));
    148   i++;
    149   omFreeSize(s->order,i*sizeof(int));
    150   s->order  = (int*) omAlloc0(3*sizeof(int));
    151   omFreeSize(s->block0,i*sizeof(int));
    152   s->block0 = (int*) omAlloc0(3*sizeof(int));
    153   omFreeSize(s->block1,i*sizeof(int));
    154   s->block1 = (int*) omAlloc0(3*sizeof(int));
    155   omFreeSize(s->wvhdl,i*sizeof(int*));
    156   s->wvhdl  = (int**) omAlloc0(3*sizeof(int*));
    157 
    158   s->order[0]  = ringorder_wp;
    159   s->block0[0] = 1;
    160   s->block1[0] = rVar(r);
    161   s->wvhdl[0]  = ZVectorToIntStar(w,ok);
    162   s->order[1]=ringorder_C;
    163 
    164   rComplete(s,1);
    165   rTest(s);
    166   return s;
    167 }
    168 
    169 
    170 /***
    171  * Given an weighted homogeneous ideal I with respect to weight w
    172  * that in standard basis form with respect to the ordering ws(-w),
    173  * derives the standard basis of I:<x_n>^\infty
    174  * and returns a long k such that I:<x_n>^\infty=I:<x_n>^k
    175  **/
    176 static long deriveStandardBasisOfSaturation(ideal &I, ring &r)
    177 {
    178   long k=0, l; poly current;
    179   for (int i=0; i<IDELEMS(I); i++)
    180   {
    181     current = I->m[i];
    182     l = p_GetExp(current,rVar(r),r);
    183     if (k<l) k=l;
    184     while (current)
    185     {
    186       p_SubExp(current,rVar(r),l,r); p_Setm(current,r);
    187       pIter(current);
    188     }
    189   }
    190   return k;
    191 }
    192 
    193 
    194 /***
    195  * Given a weighted homogeneous ideal I with respect to weight w
    196  * with constant first element,
    197  * returns NULL if I does not contain a monomial
    198  * otherwise returns the monomial contained in I
    199  **/
    200 poly checkForMonomialsViaStepwiseSaturation(const ideal &I, const gfan::ZVector &w)
    201 {
    202   // assume(rField_is_Ring_Z(currRing));
    203 
    204   // first we switch to the ground field currRing->cf / I->m[0]
    205   ring r = rCopy0(currRing);
    206   nKillChar(r->cf);
    207   r->cf = nInitChar(n_Zp,(void*)(long)n_Int(p_GetCoeff(I->m[0],currRing),currRing->cf));
    208   rComplete(r);
    209   rTest(r);
    210 
    211   ideal J = id_Copy(I, currRing); poly cache; number temp;
    212   for (int i=0; i<IDELEMS(I); i++)
    213   {
    214     cache = J->m[i];
    215     while (cache)
    216     {
    217       // TODO: temp = npMapGMP(p_GetCoeff(cache,currRing),currRing->cf,r->cf);
    218       p_SetCoeff(cache,temp,r); pIter(cache);
    219     }
    220   }
    221 
    222   J = kStd(J,NULL,isHomog,NULL);
    223 
    224   bool b = false;
    225   ring s = createInitialRingForSaturation(currRing, w, b);
    226   if (b)
    227   {
    228     WerrorS("containsMonomial: overflow in weight vector");
    229     return NULL;
    230   }
    231 
    232   return NULL;
    233 }
    234 #endif //0
     234BOOLEAN searchForMonomialViaStepwiseSaturation(leftv res, leftv args)
     235{
     236  leftv u = args;
     237  if ((u != NULL) && (u->Typ() == IDEAL_CMD))
     238  {
     239    leftv v = u->next;
     240    if ((v != NULL) && ((v->Typ() == BIGINTMAT_CMD) || (v->Typ() == INTVEC_CMD)))
     241    {
     242      ideal I = (ideal) u->Data();
     243      bigintmat* w0=NULL;
     244      if (v->Typ() == INTVEC_CMD)
     245      {
     246        intvec* w00 = (intvec*) v->Data();
     247        bigintmat* w0t = iv2bim(w00,coeffs_BIGINT);
     248        w0 = w0t->transpose();
     249        delete w0t;
     250      }
     251      else
     252        w0 = (bigintmat*) v->Data();
     253      gfan::ZVector* w = bigintmatToZVector(w0);
     254
     255      res->rtyp = POLY_CMD;
     256      res->data = (char*) searchForMonomialViaStepwiseSaturation(I,currRing,*w);
     257      delete w;
     258      if (v->Typ() == INTVEC_CMD)
     259        delete w0;
     260
     261      return FALSE;
     262    }
     263  }
     264  WerrorS("searchForMonomialViaStepwiseSaturation: unexpected parameters");
     265  return TRUE;
     266}
  • Singular/dyn_modules/gfanlib/containsMonomial.h

    r469903 r61335ab  
    77
    88poly checkForMonomialViaSuddenSaturation(const ideal I, const ring r);
     9poly searchForMonomialViaStepwiseSaturation(const ideal I, const ring r, const gfan::ZVector w);
    910BOOLEAN checkForMonomial(leftv res, leftv args);
     11BOOLEAN searchForMonomialViaStepwiseSaturation(leftv res, leftv args);
    1012
    1113#endif
  • Singular/dyn_modules/gfanlib/flip.cc

    r469903 r61335ab  
    33#include <gfanlib/gfanlib_vector.h>
    44#include <callgfanlib_conversion.h>
     5#include <singularWishlist.h>
    56#include <initial.h>
    67#include <lift.h>
    7 #include <tropicalStrategy.h>
    8 
    9 
    10 static void deleteOrdering(ring r)
    11 {
    12   if (r->order != NULL)
    13   {
    14     int i=rBlocks(r);
    15     assume(r->block0 != NULL && r->block1 != NULL && r->wvhdl != NULL);
    16     /* delete order */
    17     omFreeSize((ADDRESS)r->order,i*sizeof(int));
    18     omFreeSize((ADDRESS)r->block0,i*sizeof(int));
    19     omFreeSize((ADDRESS)r->block1,i*sizeof(int));
    20     /* delete weights */
    21     for (int j=0; j<i; j++)
    22       if (r->wvhdl[j]!=NULL)
    23         omFree(r->wvhdl[j]);
    24     omFreeSize((ADDRESS)r->wvhdl,i*sizeof(int *));
    25   }
    26   else
    27     assume(r->block0 == NULL && r->block1 == NULL && r->wvhdl == NULL);
    28   return;
    29 }
    308
    319/***
     
    4927  int n = rVar(sAdjusted);
    5028  deleteOrdering(sAdjusted);
    51   sAdjusted->order = (int*) omAlloc0(4*sizeof(int));
    52   sAdjusted->block0 = (int*) omAlloc0(4*sizeof(int));
    53   sAdjusted->block1 = (int*) omAlloc0(4*sizeof(int));
    54   sAdjusted->wvhdl = (int**) omAlloc0(4*sizeof(int**));
     29  sAdjusted->order = (int*) omAlloc0(5*sizeof(int));
     30  sAdjusted->block0 = (int*) omAlloc0(5*sizeof(int));
     31  sAdjusted->block1 = (int*) omAlloc0(5*sizeof(int));
     32  sAdjusted->wvhdl = (int**) omAlloc0(5*sizeof(int**));
    5533  sAdjusted->order[0] = ringorder_a;
    5634  sAdjusted->block0[0] = 1;
    5735  sAdjusted->block1[0] = n;
    5836  sAdjusted->wvhdl[0] = ZVectorToIntStar(adjustedInteriorPoint,ok);
    59   sAdjusted->order[1] = ringorder_wp;
     37  sAdjusted->order[1] = ringorder_a;
    6038  sAdjusted->block0[1] = 1;
    6139  sAdjusted->block1[1] = n;
    6240  sAdjusted->wvhdl[1] = ZVectorToIntStar(adjustedFacetNormal,ok);
    63   sAdjusted->order[2] = ringorder_C;
     41  sAdjusted->order[2] = ringorder_lp;
     42  sAdjusted->block0[2] = 1;
     43  sAdjusted->block1[2] = n;
     44  sAdjusted->wvhdl[2] = ZVectorToIntStar(adjustedFacetNormal,ok);
     45  sAdjusted->order[3] = ringorder_C;
    6446  rComplete(sAdjusted);
    6547  rTest(sAdjusted);
     
    10284  s->block1[1] = n;
    10385  s->wvhdl[1] = ZVectorToIntStar(facetNormal,ok);
    104   s->order[2] = ringorder_dp;
     86  s->order[2] = ringorder_lp;
    10587  s->block0[2] = 1;
    10688  s->block1[2] = n;
  • Singular/dyn_modules/gfanlib/groebnerCone.cc

    r469903 r61335ab  
    2121#include <tropicalCurves.h>
    2222#include <bbcone.h>
     23#include <tropicalDebug.h>
    2324
    2425#ifndef NDEBUG
    25 static bool checkPolynomialInput(const ideal I, const ring r)
    26 {
    27   if (r) rTest(r);
    28   if (I && r) id_Test(I,r);
    29   return ((!I) || (I && r));
    30 }
    31 
    32 static bool checkOrderingAndCone(const ring r, const gfan::ZCone zc)
    33 {
    34   return true;
    35   if (r)
    36   {
    37     int n = rVar(r); int* w = r->wvhdl[0];
    38     gfan::ZVector v = wvhdlEntryToZVector(n,w);
    39     if (r->order[0]==ringorder_ws)
    40       v = gfan::Integer((long)-1)*v;
    41     if (!zc.contains(v))
    42     {
    43       std::cout << "ERROR: weight of ordering not inside Groebner cone!" << std::endl
    44                 << "cone: " << std::endl
    45                 << toString(&zc)
    46                 << "weight: " << std::endl
    47                 << v << std::endl;
    48       return false;
    49     }
    50     return true;
    51   }
    52   return (zc.dimension()==0);
    53 }
    54 
    55 static bool checkPolyhedralInput(const gfan::ZCone zc, const gfan::ZVector p)
    56 {
    57   return zc.containsRelatively(p);
    58 }
    59 
    60 #if 0 /*unused*/
    61 static bool checkOrderingAndWeight(const ideal I, const ring r, const gfan::ZVector w, const tropicalStrategy& currentCase)
    62 {
    63   groebnerCone sigma(I,r,currentCase);
    64   gfan::ZCone zc = sigma.getPolyhedralCone();
    65   return zc.contains(w);
    66 }
    67 #endif
    68 
    6926bool groebnerCone::checkFlipConeInput(const gfan::ZVector interiorPoint, const gfan::ZVector facetNormal) const
    7027{
     
    238195  currentStrategy(&currentCase)
    239196{
     197  assume(checkWeightVector(I,r,u));
    240198  assume(checkPolynomialInput(I,r));
    241199  if (r) polynomialRing = rCopy(r);
     
    429387{
    430388  assume(this->checkFlipConeInput(interiorPoint,facetNormal));
     389  assume(checkWeightVector(polynomialIdeal,polynomialRing,interiorPoint));
    431390  /* Note: the polynomial ring created will have a weighted ordering with respect to interiorPoint
    432391   *   and with a weighted ordering with respect to facetNormal as tiebreaker.
     
    464423        continue;
    465424    }
    466     neighbours.insert(flipCone(interiorPoints[i],facetNormals[i]));
     425    neighbours.insert(flipCone(w,v));
    467426  }
    468427  return neighbours;
     
    520479    return new gfan::ZFan(gfan::ZFan(currRing->N));
    521480}
    522 
    523 
    524 #ifndef NDEBUG
    525 
    526 BOOLEAN flipConeDebug(leftv res, leftv args)
    527 {
    528   leftv u = args;
    529   if ((u!=NULL) && (u->Typ()==IDEAL_CMD))
    530   {
    531     leftv v = u->next;
    532     if ((v!=NULL) && (v->Typ()==NUMBER_CMD))
    533     {
    534       leftv w = v->next;
    535       if ((w!=NULL) && (w->Typ()==BIGINTMAT_CMD))
    536       {
    537         leftv x = w->next;
    538         if ((x!=NULL) && (x->Typ()==BIGINTMAT_CMD))
    539         {
    540           omUpdateInfo();
    541           Print("usedBytesBefore=%ld\n",om_Info.UsedBytes);
    542 
    543           ideal I = (ideal) u->CopyD();
    544           number p = (number) v->CopyD();
    545           bigintmat* interiorPoint0 = (bigintmat*) w->CopyD();
    546           bigintmat* facetNormal0 = (bigintmat*) x->CopyD();
    547           tropicalStrategy debug = tropicalStrategy::debugStrategy(I,p,currRing);
    548 
    549           gfan::ZVector* interiorPoint = bigintmatToZVector(interiorPoint0);
    550           gfan::ZVector* facetNormal = bigintmatToZVector(facetNormal0);
    551 
    552           groebnerCone sigma(I,currRing,debug);
    553           groebnerCone theta = sigma.flipCone(*interiorPoint,*facetNormal);
    554 
    555           id_Delete(&I,currRing);
    556           n_Delete(&p,currRing->cf);
    557           delete interiorPoint0;
    558           delete facetNormal0;
    559           delete interiorPoint;
    560           delete facetNormal;
    561 
    562           res->rtyp = NONE;
    563           res->data = NULL;
    564           return FALSE;
    565         }
    566       }
    567     }
    568   }
    569   WerrorS("computeFlipDebug: unexpected parameters");
    570   return TRUE;
    571 }
    572 
    573 BOOLEAN groebnerNeighboursDebug(leftv res, leftv args)
    574 {
    575   leftv u = args;
    576   if ((u!=NULL) && (u->Typ()==IDEAL_CMD))
    577   {
    578     leftv v = u->next;
    579     if ((v!=NULL) && (v->Typ()==NUMBER_CMD))
    580     {
    581       omUpdateInfo();
    582       Print("usedBytesBefore=%ld\n",om_Info.UsedBytes);
    583 
    584       ideal I = (ideal) u->CopyD();
    585       number p = (number) v->CopyD();
    586 
    587       tropicalStrategy debug = tropicalStrategy::debugStrategy(I,p,currRing);
    588       groebnerCone sigma(I,currRing,debug);
    589       groebnerCones neighbours = sigma.groebnerNeighbours();
    590 
    591       id_Delete(&I,currRing);
    592       n_Delete(&p,currRing->cf);
    593       res->rtyp = NONE;
    594       res->data = NULL;
    595       return FALSE;
    596     }
    597   }
    598   WerrorS("computeFlipDebug: unexpected parameters");
    599   return TRUE;
    600 }
    601 
    602 BOOLEAN tropicalNeighboursDebug(leftv res, leftv args)
    603 {
    604   leftv u = args;
    605   if ((u!=NULL) && (u->Typ()==IDEAL_CMD))
    606   {
    607     leftv v = u->next;
    608     if ((v!=NULL) && (v->Typ()==NUMBER_CMD))
    609     {
    610       omUpdateInfo();
    611       Print("usedBytesBefore=%ld\n",om_Info.UsedBytes);
    612 
    613       ideal I = (ideal) u->CopyD();
    614       number p = (number) v->CopyD();
    615 
    616       tropicalStrategy debug = tropicalStrategy::debugStrategy(I,p,currRing);
    617       groebnerCone sigma(I,currRing,debug);
    618       groebnerCones neighbours = sigma.groebnerNeighbours();
    619 
    620       id_Delete(&I,currRing);
    621       n_Delete(&p,currRing->cf);
    622       res->rtyp = NONE;
    623       res->data = NULL;
    624       return FALSE;
    625     }
    626   }
    627   WerrorS("computeFlipDebug: unexpected parameters");
    628   return TRUE;
    629 }
    630 #endif
  • Singular/dyn_modules/gfanlib/groebnerCone.h

    r469903 r61335ab  
    123123gfan::ZFan* toFanStar(groebnerCones setOfCones);
    124124
    125 #ifndef NDEBUG
    126 BOOLEAN flipConeDebug(leftv res, leftv args);
    127 BOOLEAN groebnerNeighboursDebug(leftv res, leftv args);
    128 BOOLEAN tropicalNeighboursDebug(leftv res, leftv args);
    129125#endif
    130 
    131 #endif
  • Singular/dyn_modules/gfanlib/initial.cc

    r469903 r61335ab  
    66#include <exception>
    77
    8 long wDeg(const poly p, const ring r, const gfan::ZVector w)
     8long wDeg(const poly p, const ring r, const gfan::ZVector &w)
    99{
    1010  long d=0;
     
    2121}
    2222
    23 gfan::ZVector WDeg(const poly p, const ring r, const gfan::ZVector w, const gfan::ZMatrix W)
     23gfan::ZVector WDeg(const poly p, const ring r, const gfan::ZVector &w, const gfan::ZMatrix &W)
    2424{
    2525  gfan::ZVector d = gfan::ZVector(W.getHeight()+1);
     
    3030}
    3131
    32 poly initial(const poly p, const ring r, const gfan::ZVector w)
     32poly initial(const poly p, const ring r, const gfan::ZVector &w)
    3333{
    3434  if (p==NULL)
     
    5858}
    5959
    60 ideal initial(const ideal I, const ring r, const gfan::ZVector w)
     60ideal initial(const ideal I, const ring r, const gfan::ZVector &w)
    6161{
    6262  int k = IDELEMS(I); ideal inI = idInit(k);
     
    6666}
    6767
    68 poly initial(const poly p, const ring r, const gfan::ZVector w, const gfan::ZMatrix W)
     68poly initial(const poly p, const ring r, const gfan::ZVector &w, const gfan::ZMatrix &W)
    6969{
    7070  if (p==NULL)
     
    9494}
    9595
    96 ideal initial(const ideal I, const ring r, const gfan::ZVector w, const gfan::ZMatrix W)
     96ideal initial(const ideal I, const ring r, const gfan::ZVector &w, const gfan::ZMatrix &W)
    9797{
    9898  int k = IDELEMS(I); ideal inI = idInit(k);
     
    102102}
    103103
    104 void initial(poly* pStar, const ring r, const gfan::ZVector w)
     104void initial(poly* pStar, const ring r, const gfan::ZVector &w)
    105105{
    106106  poly p = *pStar;
     
    141141}
    142142
    143 void initial(ideal* IStar, const ring r, const gfan::ZVector w)
     143void initial(ideal* IStar, const ring r, const gfan::ZVector &w)
    144144{
    145145  ideal I = *IStar;
     
    150150}
    151151
    152 void initial(poly* pStar, const ring r, const gfan::ZVector w, const gfan::ZMatrix W)
     152void initial(poly* pStar, const ring r, const gfan::ZVector &w, const gfan::ZMatrix &W)
    153153{
    154154  poly p = *pStar;
     
    189189}
    190190
    191 void initial(ideal* IStar, const ring r, const gfan::ZVector w, const gfan::ZMatrix W)
     191void initial(ideal* IStar, const ring r, const gfan::ZVector &w, const gfan::ZMatrix &W)
    192192{
    193193  ideal I = *IStar;
  • Singular/dyn_modules/gfanlib/initial.h

    r469903 r61335ab  
    1212 * Returns the weighted degree of the leading term of p with respect to w
    1313 */
    14 long wDeg(const poly p, const ring r, const gfan::ZVector w);
     14long wDeg(const poly p, const ring r, const gfan::ZVector &w);
    1515
    1616/**
     
    2020 * and the i+1st entry is the weighted degree with respect to the i-th row vector of W.
    2121 */
    22 gfan::ZVector WDeg(const poly p, const ring r, const gfan::ZVector w, const gfan::ZMatrix W);
     22gfan::ZVector WDeg(const poly p, const ring r, const gfan::ZVector &w, const gfan::ZMatrix &W);
    2323
    2424/**
    2525 * Returns the initial form of p with respect to w
    2626 */
    27 poly initial(const poly p, const ring r, const gfan::ZVector w);
     27poly initial(const poly p, const ring r, const gfan::ZVector &w);
    2828
    2929/**
    3030 * Returns the initial form of I with respect to w
    3131 */
    32 ideal initial(const ideal I, const ring r, const gfan::ZVector w);
     32ideal initial(const ideal I, const ring r, const gfan::ZVector &w);
    3333
    3434/**
    3535 * Returns the initial form of p with respect to w and W
    3636 */
    37 poly initial(const poly p, const ring r, const gfan::ZVector w, const gfan::ZMatrix W);
     37poly initial(const poly p, const ring r, const gfan::ZVector &w, const gfan::ZMatrix &W);
    3838
    3939/**
    4040 * Returns the initial form of I with respect to w and W
    4141 */
    42 ideal initial(const ideal I, const ring r, const gfan::ZVector w, const gfan::ZMatrix W);
     42ideal initial(const ideal I, const ring r, const gfan::ZVector &w, const gfan::ZMatrix &W);
    4343
    4444/**
    4545 * Stores the initial form of *pStar with respect to w in pStar
    4646 */
    47 void initial(poly* pStar, const ring r, const gfan::ZVector w);
     47void initial(poly* pStar, const ring r, const gfan::ZVector &w);
    4848
    4949/**
    5050 * Stores the initial form of *IStar with respect to w in IStar
    5151 */
    52 void initial(ideal* IStar, const ring r, const gfan::ZVector w);
     52void initial(ideal* IStar, const ring r, const gfan::ZVector &w);
    5353
    5454/**
    5555 * Stores the initial form of *pStar with respect to w and W in pStar
    5656 */
    57 void initial(poly* pStar, const ring r, const gfan::ZVector w, const gfan::ZMatrix W);
     57void initial(poly* pStar, const ring r, const gfan::ZVector &w, const gfan::ZMatrix &W);
    5858
    5959/**
    6060 * Stores the initial form of *IStar with respect to w and W in IStar
    6161 */
    62 void initial(ideal* IStar, const ring r, const gfan::ZVector w, const gfan::ZMatrix W);
     62void initial(ideal* IStar, const ring r, const gfan::ZVector &w, const gfan::ZMatrix &W);
    6363
    6464#endif
  • Singular/dyn_modules/gfanlib/lift.cc

    r469903 r61335ab  
     1#include <polys/monomials/p_polys.h>
     2
    13#include <witness.h>
    24
  • Singular/dyn_modules/gfanlib/ppinitialReduction.cc

    r469903 r61335ab  
    274274#endif //NDEBUG
    275275
    276 #ifndef NDEBUG
    277 BOOLEAN pReduceDebug(leftv res, leftv args)
    278 {
    279   leftv u = args;
    280   if ((u != NULL) && (u->Typ() == POLY_CMD))
    281   {
    282     poly g; number p = n_Init(3,currRing->cf);
    283     omUpdateInfo();
    284     Print("usedBytesBefore=%ld\n",om_Info.UsedBytes);
    285     g = (poly) u->CopyD();
    286     (void) pReduce(g,p,currRing);
    287     p_Delete(&g,currRing);
    288     omUpdateInfo();
    289     Print("usedBytesAfter=%ld\n",om_Info.UsedBytes);
    290     g = (poly) u->CopyD();
    291     (void) pReduce(g,p,currRing);
    292     n_Delete(&p,currRing->cf);
    293     res->rtyp = POLY_CMD;
    294     res->data = (char*) g;
    295     return FALSE;
    296   }
    297   return TRUE;
    298 }
    299 #endif //NDEBUG
    300 
    301276void pReduce(ideal &I, const number p, const ring r)
    302277{
     
    307282    {
    308283      number c = p_GetCoeff(I->m[i],r);
    309       if (!n_Equal(p,c,r->cf))
     284      if (!n_DivBy(p,c,r->cf))
    310285        pReduce(I->m[i],p,r);
    311286    }
     
    354329
    355330
    356 #ifndef NDEBUG
    357 BOOLEAN ppreduceInitially0(leftv res, leftv args)
    358 {
    359   leftv u = args;
    360   if ((u != NULL) && (u->Typ() == POLY_CMD))
    361   {
    362     leftv v = u->next;
    363     if ((v != NULL) && (v->Typ() == POLY_CMD))
    364     {
    365       poly g,h;
    366       omUpdateInfo();
    367       Print("usedBytesBefore=%ld\n",om_Info.UsedBytes);
    368       h = (poly) u->CopyD();
    369       g = (poly) v->CopyD();
    370       (void)ppreduceInitially(&h,g,currRing);
    371       p_Delete(&h,currRing);
    372       p_Delete(&g,currRing);
    373       omUpdateInfo();
    374       Print("usedBytesAfter=%ld\n",om_Info.UsedBytes);
    375       h = (poly) u->CopyD();
    376       g = (poly) v->CopyD();
    377       (void)ppreduceInitially(&h,g,currRing);
    378       p_Delete(&g,currRing);
    379       res->rtyp = POLY_CMD;
    380       res->data = (char*) h;
    381       return FALSE;
    382     }
    383   }
    384   return TRUE;
    385 }
    386 #endif //NDEBUG
    387 
    388 
    389331/***
    390332 * reduces I initially with respect to itself and with respect to p-t.
     
    436378  return false;
    437379}
    438 
    439 
    440 #ifndef NDEBUG
    441 BOOLEAN ppreduceInitially1(leftv res, leftv args)
    442 {
    443   leftv u = args;
    444   if ((u != NULL) && (u->Typ() == IDEAL_CMD))
    445   {
    446     leftv v = u->next;
    447     if ((v != NULL) && (v->Typ() == NUMBER_CMD))
    448     {
    449       ideal I; number p;
    450       omUpdateInfo();
    451       Print("usedBytesBefore=%ld\n",om_Info.UsedBytes);
    452       I = (ideal) u->CopyD();
    453       p = (number) v->CopyD();
    454       (void) ppreduceInitially(I,p,currRing);
    455       id_Delete(&I,currRing);
    456       n_Delete(&p,currRing->cf);
    457       omUpdateInfo();
    458       Print("usedBytesAfter=%ld\n",om_Info.UsedBytes);
    459       I = (ideal) u->CopyD();
    460       p = (number) v->CopyD();
    461       (void) ppreduceInitially(I,p,currRing);
    462       n_Delete(&p,currRing->cf);
    463       res->rtyp = IDEAL_CMD;
    464       res->data = (char*) I;
    465       return FALSE;
    466     }
    467   }
    468   return TRUE;
    469 }
    470 #endif //NDEBUG
    471380
    472381
     
    534443
    535444
    536 #ifndef NDEBUG
    537 BOOLEAN ppreduceInitially2(leftv res, leftv args)
    538 {
    539   leftv u = args;
    540   if ((u != NULL) && (u->Typ() == IDEAL_CMD))
    541   {
    542     leftv v = u->next;
    543     if ((v != NULL) && (v->Typ() == NUMBER_CMD))
    544     {
    545       leftv w = v->next;
    546       if ((w != NULL) && (w->Typ() == POLY_CMD))
    547       {
    548         ideal I; number p; poly g;
    549         omUpdateInfo();
    550         Print("usedBytesBefore=%ld\n",om_Info.UsedBytes);
    551         I = (ideal) u->CopyD();
    552         p = (number) v->CopyD();
    553         g = (poly) w->CopyD();
    554         (void) ppreduceInitially(I,p,g,currRing);
    555         id_Delete(&I,currRing);
    556         n_Delete(&p,currRing->cf);
    557         omUpdateInfo();
    558         Print("usedBytesAfter=%ld\n",om_Info.UsedBytes);
    559         I = (ideal) u->CopyD();
    560         p = (number) v->CopyD();
    561         g = (poly) w->CopyD();
    562         (void) ppreduceInitially(I,p,g,currRing);
    563         n_Delete(&p,currRing->cf);
    564         res->rtyp = IDEAL_CMD;
    565         res->data = (char*) I;
    566         return FALSE;
    567       }
    568     }
    569   }
    570   return TRUE;
    571 }
    572 #endif //NDEBUG
    573 
    574 
    575445static poly ppNext(poly p, int l)
    576446{
     
    736606
    737607
    738 #ifndef NDEBUG
    739 BOOLEAN ppreduceInitially3(leftv res, leftv args)
    740 {
    741   leftv u = args;
    742   if ((u != NULL) && (u->Typ() == IDEAL_CMD))
    743   {
    744     leftv v = u->next;
    745     if ((v != NULL) && (v->Typ() == NUMBER_CMD))
    746     {
    747       leftv w = v->next;
    748       if ((w != NULL) && (w->Typ() == IDEAL_CMD))
    749       {
    750         ideal H,G; number p;
    751         omUpdateInfo();
    752         Print("usedBytesBefore=%ld\n",om_Info.UsedBytes);
    753         H = (ideal) u->CopyD();
    754         p = (number) v->CopyD();
    755         G = (ideal) w->CopyD();
    756         (void) ppreduceInitially(H,p,G,currRing);
    757         n_Delete(&p,currRing->cf);
    758         id_Delete(&G,currRing);
    759         res->rtyp = IDEAL_CMD;
    760         res->data = (char*) H;
    761         return FALSE;
    762       }
    763     }
    764   }
    765   return TRUE;
    766 }
    767 #endif //NDEBUG
    768 
    769608/**
    770609 * reduces I initially with respect to itself.
     
    871710  return false;
    872711}
    873 
    874 
    875 #ifndef NDEBUG
    876 BOOLEAN reduceInitiallyDebug(leftv res, leftv args)
    877 {
    878   leftv u = args;
    879   if ((u != NULL) && (u->Typ() == IDEAL_CMD))
    880   {
    881     leftv v = u->next;
    882     if ((v != NULL) && (v->Typ() == NUMBER_CMD))
    883     {
    884       omUpdateInfo();
    885       Print("usedBytesBefore=%ld\n",om_Info.UsedBytes);
    886       ideal I = (ideal) u->CopyD();
    887       number p = (number) v->Data();
    888       (void) ppreduceInitially(I,currRing,p);
    889       res->rtyp = IDEAL_CMD;
    890       res->data = (char*) I;
    891       return FALSE;
    892     }
    893   }
    894   return TRUE;
    895 }
    896 #endif
    897712
    898713
  • Singular/dyn_modules/gfanlib/ppinitialReduction.h

    r469903 r61335ab  
    1414/* BOOLEAN ppreduceInitially(leftv res, leftv args); */
    1515
    16 #ifndef NDEBUG
    17 BOOLEAN pReduceDebug(leftv res, leftv args);
    18 BOOLEAN reduceInitiallyDebug(leftv res, leftv args);
    19 BOOLEAN ptNormalize(leftv res, leftv args);
    20 BOOLEAN ppreduceInitially3(leftv res, leftv args);
    2116#endif
    22 
    23 #endif
  • Singular/dyn_modules/gfanlib/singularWishlist.h

    r469903 r61335ab  
    33
    44#include <polys/monomials/p_polys.h>
    5 
    6 /* #ifndef NDEBUG */
    7 /* void z_Write(number p, ring r) */
    8 /* { */
    9 /*   poly g = p_One(r); */
    10 /*   p_SetCoeff(g,p,r); */
    11 /*   p_Write(g,r); */
    12 /*   return; */
    13 /* } */
    14 /* #endif */
     5#include <libpolys/polys/simpleideals.h>
    156
    167static inline BOOLEAN _p_LeadmonomDivisibleByNoComp(poly a, poly b, const ring r)
     
    8778}
    8879
     80inline void deleteOrdering(ring r)
     81{
     82  if (r->order != NULL)
     83  {
     84    int i=rBlocks(r);
     85    assume(r->block0 != NULL && r->block1 != NULL && r->wvhdl != NULL);
     86    /* delete order */
     87    omFreeSize((ADDRESS)r->order,i*sizeof(int));
     88    omFreeSize((ADDRESS)r->block0,i*sizeof(int));
     89    omFreeSize((ADDRESS)r->block1,i*sizeof(int));
     90    /* delete weights */
     91    for (int j=0; j<i; j++)
     92      if (r->wvhdl[j]!=NULL)
     93        omFree(r->wvhdl[j]);
     94    omFreeSize((ADDRESS)r->wvhdl,i*sizeof(int *));
     95  }
     96  else
     97    assume(r->block0 == NULL && r->block1 == NULL && r->wvhdl == NULL);
     98  return;
     99}
     100
     101
     102void z_Write(number p, ring r);
     103void id_Write(const ideal I, const ring r);
     104
     105
    89106#endif
  • Singular/dyn_modules/gfanlib/startingCone.cc

    r469903 r61335ab  
    11#include <callgfanlib_conversion.h>
     2#include <singularWishlist.h>
     3#include <tropicalDebug.h>
    24#include <containsMonomial.h>
    35#include <tropical.h>
     
    1113#include <tropicalVariety.h>
    1214#include <tropicalStrategy.h>
     15#include <std_wrapper.h>
    1316
    1417
     
    330333}
    331334
     335
     336ring createTraversalStartingRing(const ring s, const gfan::ZMatrix &startingPoints, const tropicalStrategy& currentStrategy)
     337{
     338  // copy r except qideal (which should be 0) and ordering
     339  ring s0 = rCopy0(s);
     340  int n = rVar(s);
     341  deleteOrdering(s0);
     342  bool ok;
     343
     344  // adjust weight and create new ordering
     345  int h = startingPoints.getHeight();
     346  s0->order = (int*) omAlloc0((h+3)*sizeof(int));
     347  s0->block0 = (int*) omAlloc0((h+3)*sizeof(int));
     348  s0->block1 = (int*) omAlloc0((h+3)*sizeof(int));
     349  s0->wvhdl = (int**) omAlloc0((h+3)*sizeof(int**));
     350  for (int i=0; i<h; i++)
     351  {
     352    s0->order[i] = ringorder_a;
     353    s0->block0[i] = 1;
     354    s0->block1[i] = n;
     355    s0->wvhdl[i] = ZVectorToIntStar(startingPoints[i],ok);
     356  }
     357  s0->order[h] = ringorder_lp;
     358  s0->block0[h] = 1;
     359  s0->block1[h] = n;
     360  s0->order[h+1] = ringorder_C;
     361
     362  rComplete(s0);
     363  rTest(s0);
     364
     365  return s0;
     366}
     367
     368
    332369/***
    333370 * Computes a starting cone in the tropical variety.
     
    359396    // equals the dimension of the tropical variety
    360397    gfan::ZCone zc = linealitySpaceOfGroebnerFan(inI,s);
    361     gfan::ZVector startingPoint; groebnerCone ambientMaximalCone;
     398    gfan::ZMatrix startingPoints(0,rVar(r));
     399    groebnerCone ambientMaximalCone;
    362400    if (zc.dimension()>=currentStrategy.getExpectedDimension())
    363401    {
     
    380418      // compute a point in the tropical variety outside the lineality space
    381419      std::pair<gfan::ZVector,groebnerCone> startingData = tropicalStartingDataViaGroebnerFan(inI,s,currentStrategy);
    382       startingPoint = startingData.first;
     420      gfan::ZVector startingPoint = startingData.first;
     421      startingPoints.appendRow(startingPoint);
    383422      ambientMaximalCone = groebnerCone(startingData.second);
    384423
     
    397436    // from this we can read of the inequalities and equations
    398437
     438    ring s0 = createTraversalStartingRing(s,startingPoints,currentStrategy);
     439    nMapFunc identity = n_SetMap(s->cf,s0->cf);
     440    k = IDELEMS(inI);
     441    ideal inI0 = idInit(k);
     442    for (int i=0; i<k; i++)
     443      inI0->m[i] = p_PermPoly(inI->m[i],NULL,s,s0,identity,NULL,0);
     444
     445    identity = n_SetMap(r->cf,s0->cf);
     446    k = IDELEMS(I);
     447    ideal I0 = idInit(k);
     448    for (int i=0; i<k; i++)
     449      I0->m[i] = p_PermPoly(I->m[i],NULL,r,s0,identity,NULL,0);
     450
     451
    399452    // but before doing so, we must lift the generating set of inI
    400453    // to a generating set of I
    401     ideal J = lift(I,r,inI,s); // todo: use computeLift from tropicalStrategy
    402     groebnerCone startingCone(J,inI,s,currentStrategy);
    403     id_Delete(&inI,s);
    404     id_Delete(&J,s);
     454    // ideal J0 = lift(I,r,inI0,s0); // todo: use computeLift from tropicalStrategy
     455    ideal J0 = gfanlib_kStd_wrapper(I0,s0);
     456    assume(areIdealsEqual(J0,s0,I,r));
     457    id_Delete(&I0,s0);
     458    groebnerCone startingCone(J0,inI0,s0,currentStrategy);
     459    id_Delete(&J0,s0);
     460    id_Delete(&inI0,s0);
     461    rDelete(s0);
    405462
    406463    // assume(checkContainmentInTropicalVariety(startingCone));
  • Singular/dyn_modules/gfanlib/std_wrapper.cc

    r469903 r61335ab  
     1#include <vector>
     2
    13#include <kernel/GBEngine/kstd1.h>
    24#include <kernel/polys.h>
    35#include <kernel/ideals.h>
     6
     7#include <Singular/dyn_modules/customstd/customstd.h>
    48
    59ideal gfanlib_kStd_wrapper(ideal I, ring r, tHomog h=testHomog)
     
    2024  return stdI;
    2125}
     26
     27ideal gfanlib_satStd_wrapper(ideal I, ring r, tHomog h=testHomog)
     28{
     29  ring origin = currRing;
     30  if (origin != r)
     31    rChangeCurrRing(r);
     32
     33  int n = rVar(currRing);
     34  satstdSaturatingVariables = std::vector<int>(n);
     35  for (int i=n-1; i>=0; i--)
     36    satstdSaturatingVariables[i] = i+1;
     37
     38  ideal stdI = kStd(I,currRing->qideal,h,NULL,NULL,0,0,NULL,sat_vars_sp);
     39  id_DelDiv(stdI,currRing);
     40  idSkipZeroes(stdI);
     41
     42  if (origin != r)
     43    rChangeCurrRing(origin);
     44
     45  return stdI;
     46}
     47
     48ideal gfanlib_monomialabortStd_wrapper(ideal I, ring r, tHomog h=testHomog)
     49{
     50  ring origin = currRing;
     51  if (origin != r)
     52    rChangeCurrRing(r);
     53
     54  ideal stdI = kStd(I,currRing->qideal,h,NULL,NULL,0,0,NULL,abort_if_monomial_sp);
     55  id_DelDiv(stdI,currRing);
     56  idSkipZeroes(stdI);
     57
     58  if (origin != r)
     59    rChangeCurrRing(origin);
     60
     61  return stdI;
     62}
  • Singular/dyn_modules/gfanlib/std_wrapper.h

    r469903 r61335ab  
    66
    77ideal gfanlib_kStd_wrapper(ideal I, ring r, tHomog h=testHomog);
     8ideal gfanlib_satStd_wrapper(ideal I, ring r, tHomog h=testHomog);
     9ideal gfanlib_monomialabortStd_wrapper(ideal I, ring r, tHomog h=testHomog);
    810
    911#endif
  • Singular/dyn_modules/gfanlib/tropical.cc

    r469903 r61335ab  
    303303    if (g != NULL && pNext(g) != NULL)
    304304    {
    305       pGetExpV(g,leadexpv);
     305      p_GetExpV(g,leadexpv,r);
    306306      leadexpw = intStar2ZVector(n, leadexpv);
    307307      pIter(g);
    308308      while (g != NULL)
    309309      {
    310         pGetExpV(g,tailexpv);
     310        p_GetExpV(g,tailexpv,r);
    311311        tailexpw = intStar2ZVector(n, tailexpv);
    312312        inequalities.appendRow(leadexpw-tailexpw);
     
    449449  p->iiAddCproc("","groebnerFan",FALSE,groebnerFan);
    450450  p->iiAddCproc("","groebnerComplex",FALSE,groebnerComplex);
    451 #ifndef NDEBUG
    452   // p->iiAddCproc("","tropicalNeighbours",FALSE,tropicalNeighbours);
    453   // p->iiAddCproc("","initial0",FALSE,initial0);
    454   p->iiAddCproc("","pReduceDebug",FALSE,pReduceDebug);
    455   // p->iiAddCproc("","ppreduceInitially0",FALSE,ppreduceInitially0);
    456   // p->iiAddCproc("","ppreduceInitially1",FALSE,ppreduceInitially1);
    457   // p->iiAddCproc("","ppreduceInitially2",FALSE,ppreduceInitially2);
    458   p->iiAddCproc("","ptNormalize",FALSE,ptNormalize);
    459   p->iiAddCproc("","ppreduceInitially3",FALSE,ppreduceInitially3);
    460   // p->iiAddCproc("","ppreduceInitially4",FALSE,ppreduceInitially4);
    461   // p->iiAddCproc("","ttpReduce",FALSE,ttpReduce);
    462   // p->iiAddCproc("","ttreduceInitially0",FALSE,ttreduceInitially0);
    463   // p->iiAddCproc("","ttreduceInitially1",FALSE,ttreduceInitially1);
    464   // p->iiAddCproc("","ttreduceInitially2",FALSE,ttreduceInitially2);
    465   // p->iiAddCproc("","ttreduceInitially3",FALSE,ttreduceInitially3);
    466   // p->iiAddCproc("","ttreduceInitially4",FALSE,ttreduceInitially4);
    467   // p->iiAddCproc("","checkForMonomial",FALSE,checkForMonomial);
    468   // p->iiAddCproc("","dwr0",FALSE,dwr0);
    469   // p->iiAddCproc("","witness0",FALSE,witness0);
    470   // p->iiAddCproc("","tropicalVariety00",FALSE,tropicalVariety00);
    471   // p->iiAddCproc("","tropicalVariety01",FALSE,tropicalVariety01);
    472   // p->iiAddCproc("","tropicalCurve0",FALSE,tropicalCurve0);
    473   // p->iiAddCproc("","tropicalCurve1",FALSE,tropicalCurve1);
    474   p->iiAddCproc("","reduceInitiallyDebug",FALSE,reduceInitiallyDebug);
    475   p->iiAddCproc("","computeWitnessDebug",FALSE,computeWitnessDebug);
    476   p->iiAddCproc("","computeFlipDebug",FALSE,computeFlipDebug);
    477   p->iiAddCproc("","flipConeDebug",FALSE,flipConeDebug);
    478   // p->iiAddCproc("","groebnerNeighboursDebug",FALSE,groebnerNeighboursDebug);
    479   // p->iiAddCproc("","tropicalNeighboursDebug",FALSE,tropicalNeighboursDebug);
    480   p->iiAddCproc("","tropicalStarDebug",FALSE,tropicalStarDebug);
    481   p->iiAddCproc("","tropicalStartingPoint",FALSE,tropicalStartingPoint);
    482   p->iiAddCproc("","positiveTropicalStartingPoint",FALSE,positiveTropicalStartingPoint);
    483   p->iiAddCproc("","nonNegativeTropicalStartingPoint",FALSE,nonNegativeTropicalStartingPoint);
    484   p->iiAddCproc("","negativeTropicalStartingPoint",FALSE,negativeTropicalStartingPoint);
    485   p->iiAddCproc("","nonPositiveTropicalStartingPoint",FALSE,nonPositiveTropicalStartingPoint);
    486   p->iiAddCproc("","tropicalStartingCone",FALSE,tropicalStartingCone);
    487 #endif //NDEBUG
    488451  // p->iiAddCproc("","ppreduceInitially",FALSE,ppreduceInitially);
    489452  // p->iiAddCproc("","ttreduceInitially",FALSE,ttreduceInitially);
  • Singular/dyn_modules/gfanlib/tropical.h

    r469903 r61335ab  
    88
    99
     10gfan::ZCone maximalGroebnerCone(const ideal &I, const ring &r);
    1011gfan::ZCone homogeneitySpace(ideal I, ring r);
    1112void tropical_setup(SModulFunctions* p);
  • Singular/dyn_modules/gfanlib/tropicalCurves.cc

    r469903 r61335ab  
    1111#include <tropicalCurves.h>
    1212#include <set>
    13 #ifndef NDEBUG
    14 #include <bbfan.h>
    15 #endif
    1613
    1714/***
     
    123120   * of the polynomials in the generating set */
    124121  ZConesSortedByDimension C = tropicalVarietySortedByDimension(inI->m[0],r,currentStrategy);
    125   for (int i=1; i<k; i++)
     122  int PayneOsserman = rVar(r)-1;
     123  for (int i=0; i<k; i++)
    126124  {
    127125    if(inI->m[i]!=NULL)
    128126    {
    129       C = intersect(C,tropicalVarietySortedByDimension(inI->m[i],r,currentStrategy),d);
     127      PayneOsserman--;
     128      C = intersect(C,tropicalVarietySortedByDimension(inI->m[i],r,currentStrategy),si_max(PayneOsserman,d));
    130129    }
    131130  }
     
    321320  return raysOfC;
    322321}
    323 
    324 
    325 /***
    326  * Computes the tropical curve of an x-homogeneous ideal I
    327  * which is weighted homogeneous with respect to weight w in ring r
    328  **/
    329 #ifndef NDEBUG
    330 BOOLEAN tropicalStarDebug(leftv res, leftv args)
    331 {
    332   leftv u = args;
    333   if ((u!=NULL) && (u->Typ()==IDEAL_CMD))
    334   {
    335     leftv v = u->next;
    336     if ((v!=NULL) && (v->Typ()==BIGINTMAT_CMD))
    337     {
    338       omUpdateInfo();
    339       Print("usedBytesBefore=%ld\n",om_Info.UsedBytes);
    340       ideal inI = (ideal) u->CopyD();
    341       bigintmat* u = (bigintmat*) v->CopyD();
    342       tropicalStrategy currentCase(inI,currRing);
    343       gfan::ZVector* v = bigintmatToZVector(u);
    344       ZConesSortedByDimension C = tropicalStar(inI,currRing,*v,&currentCase);
    345       id_Delete(&inI,currRing);
    346       delete u;
    347       delete v;
    348       res->rtyp = NONE;
    349       res->data = NULL;
    350       // res->rtyp = fanID;
    351       // res->data = (char*) toFanStar(C);
    352       return FALSE;
    353     }
    354   }
    355   WerrorS("tropicalStarDebug: unexpected parameters");
    356   return TRUE;
    357 }
    358 #endif
  • Singular/dyn_modules/gfanlib/tropicalCurves.h

    r469903 r61335ab  
    1313                                 const tropicalStrategy* currentStrategy);
    1414
    15 #ifndef NDEBUG
    16 BOOLEAN tropicalStarDebug(leftv res, leftv args);
    1715#endif
    18 
    19 #endif
  • Singular/dyn_modules/gfanlib/tropicalStrategy.cc

    r469903 r61335ab  
    11#include <tropicalStrategy.h>
     2#include <singularWishlist.h>
    23#include <adjustWeights.h>
    34#include <ppinitialReduction.h>
     
    67#include <std_wrapper.h>
    78#include <tropicalCurves.h>
     9#include <tropicalDebug.h>
     10#include <containsMonomial.h>
     11
    812
    913// for various commands in dim(ideal I, ring r):
     
    115119    J->m[i] = p_PermPoly(JShortcut->m[i],NULL,rShortcut,r,outofShortcut,NULL,0);
    116120
     121  assume(areIdealsEqual(J,r,I,r));
    117122  swapElements(I,J);
    118123  id_Delete(&IShortcut,rShortcut);
     
    521526  }
    522527
     528  gfan::ZCone C0 = homogeneitySpace(inIShortcut,rShortcut);
     529  gfan::ZCone pos = gfan::ZCone::positiveOrthant(C0.ambientDimension());
     530  gfan::ZCone C0pos = intersection(C0,pos);
     531  C0pos.canonicalize();
     532  gfan::ZVector wpos = C0pos.getRelativeInteriorPoint();
     533  assume(checkForNonPositiveEntries(wpos));
     534
    523535  // check initial ideal for monomial and
    524536  // if it exsists, return a copy of the monomial in the input ring
    525   poly p = checkForMonomialViaSuddenSaturation(inIShortcut,rShortcut);
     537  poly p = searchForMonomialViaStepwiseSaturation(inIShortcut,rShortcut,wpos);
    526538  poly monomial = NULL;
    527539  if (p!=NULL)
     
    684696}
    685697
    686 static void deleteOrdering(ring r)
    687 {
    688   if (r->order != NULL)
    689   {
    690     int i=rBlocks(r);
    691     assume(r->block0 != NULL && r->block1 != NULL && r->wvhdl != NULL);
    692     /* delete order */
    693     omFreeSize((ADDRESS)r->order,i*sizeof(int));
    694     omFreeSize((ADDRESS)r->block0,i*sizeof(int));
    695     omFreeSize((ADDRESS)r->block1,i*sizeof(int));
    696     /* delete weights */
    697     for (int j=0; j<i; j++)
    698       if (r->wvhdl[j]!=NULL)
    699         omFree(r->wvhdl[j]);
    700     omFreeSize((ADDRESS)r->wvhdl,i*sizeof(int *));
    701   }
    702   else
    703     assume(r->block0 == NULL && r->block1 == NULL && r->wvhdl == NULL);
    704   return;
    705 }
    706 
    707698ring tropicalStrategy::copyAndChangeOrderingWP(const ring r, const gfan::ZVector &w, const gfan::ZVector &v) const
    708699{
     
    771762  assume(isValuationTrivial() || interiorPoint[0].sign()<0);
    772763  assume(checkForUniformizingBinomial(Ir,r));
     764  assume(checkWeightVector(Ir,r,interiorPoint));
    773765
    774766  // get a generating system of the initial ideal
     
    798790    Js->m[i] = p_PermPoly(Jr->m[i],NULL,r,s,identity,NULL,0);
    799791
    800   // this->reduce(Jr,r);
     792  reduce(Js,s);
     793  assume(areIdealsEqual(Js,s,Ir,r));
     794  assume(isValuationTrivial() || isOrderingLocalInT(s));
     795  assume(checkWeightVector(Js,s,interiorPoint));
     796
    801797  // cleanup
    802798  id_Delete(&inIsAdjusted,sAdjusted);
     
    890886  return false;
    891887}
    892 
    893 #ifndef NDEBUG
    894 tropicalStrategy::tropicalStrategy():
    895   originalRing(NULL),
    896   originalIdeal(NULL),
    897   expectedDimension(NULL),
    898   linealitySpace(gfan::ZCone()),
    899   startingRing(NULL),
    900   startingIdeal(NULL),
    901   uniformizingParameter(NULL),
    902   shortcutRing(NULL),
    903   onlyLowerHalfSpace(false)
    904 {
    905   weightAdjustingAlgorithm1=NULL;
    906   weightAdjustingAlgorithm2=NULL;
    907   extraReductionAlgorithm=NULL;
    908 }
    909 
    910 tropicalStrategy tropicalStrategy::debugStrategy(const ideal startIdeal, number unifParameter, ring startRing)
    911 {
    912   tropicalStrategy debug;
    913   debug.originalRing = rCopy(startRing);
    914   debug.originalIdeal = id_Copy(startIdeal,startRing);
    915   debug.startingRing = rCopy(startRing);
    916   debug.startingIdeal = id_Copy(startIdeal,startRing);
    917   debug.uniformizingParameter = n_Copy(unifParameter,startRing->cf);
    918 
    919   debug.shortcutRing = rCopy0(startRing);
    920   nKillChar(debug.shortcutRing->cf);
    921   debug.shortcutRing->cf = nInitChar(n_Zp,(void*)(long)IsPrime(n_Int(unifParameter,startRing->cf)));
    922   rComplete(debug.shortcutRing);
    923   rTest(debug.shortcutRing);
    924 
    925   debug.onlyLowerHalfSpace = true;
    926   debug.weightAdjustingAlgorithm1 = valued_adjustWeightForHomogeneity;
    927   debug.weightAdjustingAlgorithm2 = valued_adjustWeightUnderHomogeneity;
    928   debug.extraReductionAlgorithm = ppreduceInitially;
    929 
    930   return debug;
    931 }
    932 
    933 BOOLEAN computeWitnessDebug(leftv res, leftv args)
    934 {
    935   leftv u = args;
    936   if ((u!=NULL) && (u->Typ()==IDEAL_CMD))
    937   {
    938     leftv v = u->next;
    939     if ((v!=NULL) && (v->Typ()==IDEAL_CMD))
    940     {
    941       leftv w = v->next;
    942       if ((w!=NULL) && (w->Typ()==IDEAL_CMD))
    943       {
    944         leftv x = w->next;
    945         if ((x!=NULL) && (x->Typ()==NUMBER_CMD))
    946         {
    947           omUpdateInfo();
    948           Print("usedBytesBefore=%ld\n",om_Info.UsedBytes);
    949 
    950           ideal inJ = (ideal) u->CopyD();
    951           ideal inI = (ideal) v->CopyD();
    952           ideal I = (ideal) w->CopyD();
    953           number p = (number) x->CopyD();
    954           tropicalStrategy debug = tropicalStrategy::debugStrategy(I,p,currRing);
    955           ideal J = debug.computeWitness(inJ,inI,I,currRing);
    956           id_Delete(&inJ,currRing);
    957           id_Delete(&inI,currRing);
    958           id_Delete(&I,currRing);
    959           n_Delete(&p,currRing->cf);
    960           res->rtyp = IDEAL_CMD;
    961           res->data = (char*) J;
    962           return FALSE;
    963         }
    964       }
    965     }
    966   }
    967   return TRUE;
    968 }
    969 
    970 BOOLEAN computeFlipDebug(leftv res, leftv args)
    971 {
    972   leftv u = args;
    973   if ((u!=NULL) && (u->Typ()==IDEAL_CMD))
    974   {
    975     leftv v = u->next;
    976     if ((v!=NULL) && (v->Typ()==NUMBER_CMD))
    977     {
    978       leftv w = v->next;
    979       if ((w!=NULL) && (w->Typ()==BIGINTMAT_CMD))
    980       {
    981         leftv x = w->next;
    982         if ((x!=NULL) && (x->Typ()==BIGINTMAT_CMD))
    983         {
    984           omUpdateInfo();
    985           Print("usedBytesBefore=%ld\n",om_Info.UsedBytes);
    986 
    987           ideal I = (ideal) u->CopyD();
    988           number p = (number) v->CopyD();
    989           bigintmat* interiorPoint0 = (bigintmat*) w->CopyD();
    990           bigintmat* facetNormal0 = (bigintmat*) x->CopyD();
    991           tropicalStrategy debug = tropicalStrategy::debugStrategy(I,p,currRing);
    992 
    993           gfan::ZVector* interiorPoint = bigintmatToZVector(interiorPoint0);
    994           gfan::ZVector* facetNormal = bigintmatToZVector(facetNormal0);
    995           std::pair<ideal,ring> Js = debug.computeFlip(I,currRing,*interiorPoint,*facetNormal);
    996           ideal J = Js.first;
    997           ring s = Js.second;
    998 
    999           id_Delete(&J,s);
    1000           rDelete(s);
    1001 
    1002           id_Delete(&I,currRing);
    1003           n_Delete(&p,currRing->cf);
    1004           delete interiorPoint0;
    1005           delete facetNormal0;
    1006           delete interiorPoint;
    1007           delete facetNormal;
    1008 
    1009           res->rtyp = NONE;
    1010           res->data = NULL;
    1011           return FALSE;
    1012         }
    1013       }
    1014     }
    1015   }
    1016   WerrorS("computeFlipDebug: unexpected parameters");
    1017   return TRUE;
    1018 }
    1019 #endif
  • Singular/dyn_modules/gfanlib/tropicalStrategy.h

    r469903 r61335ab  
    134134
    135135
    136 #ifndef NDEBUG
    137   tropicalStrategy();
    138   static tropicalStrategy debugStrategy(const ideal startIdeal, number unifParameter, ring startRing);
    139 #endif
    140 
    141136  /**
    142137   * destructor
     
    333328};
    334329
    335 #ifndef NDEBUG
    336 BOOLEAN computeWitnessDebug(leftv res, leftv args);
    337 BOOLEAN computeFlipDebug(leftv res, leftv args);
    338330#endif
    339 
    340 #endif
  • Singular/dyn_modules/gfanlib/tropicalTraversal.cc

    r469903 r61335ab  
    22#include <groebnerCone.h>
    33#include <tropicalCurves.h>
     4#include <std_wrapper.h>
    45
    56std::vector<bool> checkNecessaryTropicalFlips(const groebnerCones &tropicalVariety, const groebnerCones &workingList,
     
    2223      {
    2324        if (needToFlip[i] && sigma->contains(testVectors[i]))
     25        {
    2426          needToFlip[i] = false;
     27          break;
     28        }
    2529      }
    2630    }
     
    3438      {
    3539        if (needToFlip[i] && sigma->contains(testVectors[i]))
     40        {
    3641          needToFlip[i] = false;
     42          break;
     43        }
    3744      }
    3845    }
     
    7178      {
    7279        ideal inI = initial(sigma.getPolynomialIdeal(),sigma.getPolynomialRing(),interiorPoint);
    73         gfan::ZMatrix normalVectors = raysOfTropicalStar(inI,
     80        ideal inISTD = gfanlib_satStd_wrapper(inI,sigma.getPolynomialRing());
     81        id_Delete(&inI,sigma.getPolynomialRing());
     82        gfan::ZMatrix normalVectors = raysOfTropicalStar(inISTD,
    7483                                                         sigma.getPolynomialRing(),
    7584                                                         interiorPoint,
    7685                                                         sigma.getTropicalStrategy());
    77         id_Delete(&inI,sigma.getPolynomialRing());
     86        id_Delete(&inISTD,sigma.getPolynomialRing());
    7887
    7988        std::vector<bool> needToFlip = checkNecessaryTropicalFlips(tropicalVariety,workingList,interiorPoint,normalVectors);
  • Singular/dyn_modules/gfanlib/witness.cc

    r469903 r61335ab  
    33#include <polys/monomials/p_polys.h>
    44#include <callgfanlib_conversion.h>
     5#include <tropicalDebug.h>
    56#include <initial.h>
    67#include <tropicalStrategy.h>
    7 #include <utility>
    88
    99matrix divisionDiscardingRemainder(const poly f, const ideal G, const ring r)
     
    6767  }
    6868
     69  assume(areIdealsEqual(I,r,J,r));
     70
    6971  return I;
    7072}
    71 
    72 #ifndef NDEBUG
    73 BOOLEAN 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 
    89 BOOLEAN witnessDebug(leftv res, leftv args)
    90 {
    91   leftv u = args;
    92   if ((u != NULL) && (u->Typ() == IDEAL_CMD))
    93   {
    94     leftv v = u->next;
    95     if ((v!=NULL) && (v->Typ()==IDEAL_CMD))
    96     {
    97       omUpdateInfo();
    98       Print("usedBytesBefore=%ld\n",om_Info.UsedBytes);
    99       ideal inI = (ideal) u->CopyD();
    100       ideal J = (ideal) v->CopyD();
    101       ideal I = witness(inI,J,currRing);
    102       id_Delete(&inI,currRing);
    103       id_Delete(&J,currRing);
    104       res->rtyp = IDEAL_CMD;
    105       res->data = (char*) I;
    106       return FALSE;
    107     }
    108   }
    109   return TRUE;
    110 }
    111 #endif
  • Singular/dyn_modules/gfanlib/witness.h

    r469903 r61335ab  
    4141ideal witness(const ideal inI, const ideal J, const ring r);
    4242
    43 #ifndef NDEBUG
    44 #include <Singular/ipid.h>
    45 BOOLEAN dwrDebug(leftv res, leftv args);
    46 BOOLEAN witnessDebug(leftv res, leftv args);
    4743#endif
    48 
    49 #endif
  • Tst/Short/bug_newstruct.tst

    r469903 r61335ab  
    22tst_init();
    33
     4LIB"customstd.so";
    45LIB"gfanlib.so";
    56// newstruct stuff
  • gfanlib/gfanlib_zfan.cpp

    r469903 r61335ab  
    281281      return complex->getAmbientDimension()-complex->getMaxDim();
    282282    if(coneCollection)
     283    {
     284      if(coneCollection->isEmpty())
     285        return -1;
    283286      return coneCollection->getAmbientDimension()-coneCollection->getMaxDimension();
     287    }
    284288    assert(0);
    285289    return 0;
     
    290294      return complex->getMaxDim();
    291295    if(coneCollection)
     296    {
     297      if(coneCollection->isEmpty())
     298        return -1;
    292299      return coneCollection->getMaxDimension();
     300    }
    293301    assert(0);
    294302    return 0;
Note: See TracChangeset for help on using the changeset viewer.