source: git/Singular/dyn_modules/gfanlib/groebnerCone.cc @ 598793

fieker-DuValspielwiese
Last change on this file since 598793 was 598793, checked in by Hans Schoenemann <hannes@…>, 9 years ago
unused functions for gfanlib
  • Property mode set to 100644
File size: 21.6 KB
Line 
1#include <utility>
2
3#include <kernel/GBEngine/kstd1.h>
4#include <kernel/ideals.h>
5#include <Singular/ipid.h>
6
7#include <polys/monomials/p_polys.h>
8#include <polys/monomials/ring.h>
9#include <polys/prCopy.h>
10
11#include <gfanlib/gfanlib.h>
12#include <gfanlib/gfanlib_matrix.h>
13
14#include <initial.h>
15#include <tropicalStrategy.h>
16#include <groebnerCone.h>
17#include <callgfanlib_conversion.h>
18#include <containsMonomial.h>
19#include <initial.h>
20// #include <flip.h>
21#include <tropicalCurves.h>
22#include <bbcone.h>
23
24#ifndef NDEBUG
25static 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
32static 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
55static bool checkPolyhedralInput(const gfan::ZCone zc, const gfan::ZVector p)
56{
57  return zc.containsRelatively(p);
58}
59
60#if 0 /*unused*/
61static 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
69bool groebnerCone::checkFlipConeInput(const gfan::ZVector interiorPoint, const gfan::ZVector facetNormal) const
70{
71  /* check first whether interiorPoint lies on the boundary of the cone */
72  if (!polyhedralCone.contains(interiorPoint))
73  {
74    std::cout << "ERROR: interiorPoint is not contained in the Groebner cone!" << std::endl
75              << "cone: " << std::endl
76              << toString(&polyhedralCone)
77              << "interiorPoint:" << std::endl
78              << interiorPoint << std::endl;
79    return false;
80  }
81  if (polyhedralCone.containsRelatively(interiorPoint))
82  {
83    std::cout << "ERROR: interiorPoint is contained in the interior of the maximal Groebner cone!" << std::endl
84              << "cone: " << std::endl
85              << toString(&polyhedralCone)
86              << "interiorPoint:" << std::endl
87              << interiorPoint << std::endl;
88    return false;
89  }
90  gfan::ZCone hopefullyAFacet = polyhedralCone.faceContaining(interiorPoint);
91  if (hopefullyAFacet.dimension()!=(polyhedralCone.dimension()-1))
92  {
93    std::cout << "ERROR: interiorPoint is not contained in the interior of a facet!" << std::endl
94              << "cone: " << std::endl
95              << toString(&polyhedralCone)
96              << "interiorPoint:" << std::endl
97              << interiorPoint << std::endl;
98    return false;
99  }
100  /* check whether facet normal points outwards */
101  gfan::ZCone dual = polyhedralCone.dualCone();
102  if(dual.containsRelatively(facetNormal))
103  {
104    std::cout << "ERROR: facetNormal is not pointing outwards!" << std::endl
105              << "cone: " << std::endl
106              << toString(&polyhedralCone)
107              << "facetNormal:" << std::endl
108              << facetNormal << std::endl;
109    return false;
110  }
111  return true;
112}
113#endif //NDEBUG
114
115groebnerCone::groebnerCone():
116  polynomialIdeal(NULL),
117  polynomialRing(NULL),
118  polyhedralCone(gfan::ZCone(0)),
119  interiorPoint(gfan::ZVector(0)),
120  currentStrategy(NULL)
121{
122}
123
124groebnerCone::groebnerCone(const ideal I, const ring r, const tropicalStrategy& currentCase):
125  polynomialIdeal(NULL),
126  polynomialRing(NULL),
127  currentStrategy(&currentCase)
128{
129  assume(checkPolynomialInput(I,r));
130  if (r) polynomialRing = rCopy(r);
131  if (I)
132  {
133    polynomialIdeal = id_Copy(I,r);
134    currentCase.pReduce(polynomialIdeal,polynomialRing);
135    currentCase.reduce(polynomialIdeal,polynomialRing);
136  }
137
138  int n = rVar(polynomialRing);
139  poly g = NULL;
140  int* leadexpv = (int*) omAlloc((n+1)*sizeof(int));
141  int* tailexpv = (int*) omAlloc((n+1)*sizeof(int));
142  gfan::ZVector leadexpw = gfan::ZVector(n);
143  gfan::ZVector tailexpw = gfan::ZVector(n);
144  gfan::ZMatrix inequalities = gfan::ZMatrix(0,n);
145  for (int i=0; i<idSize(polynomialIdeal); i++)
146  {
147    g = polynomialIdeal->m[i];
148    if (g)
149    {
150      p_GetExpV(g,leadexpv,r);
151      leadexpw = expvToZVector(n, leadexpv);
152      pIter(g);
153      while (g)
154      {
155        p_GetExpV(g,tailexpv,r);
156        tailexpw = expvToZVector(n, tailexpv);
157        inequalities.appendRow(leadexpw-tailexpw);
158        pIter(g);
159      }
160    }
161  }
162  omFreeSize(leadexpv,(n+1)*sizeof(int));
163  omFreeSize(tailexpv,(n+1)*sizeof(int));
164  // if (currentStrategy->restrictToLowerHalfSpace())
165  // {
166  //   gfan::ZVector lowerHalfSpaceCondition = gfan::ZVector(n);
167  //   lowerHalfSpaceCondition[0] = -1;
168  //   inequalities.appendRow(lowerHalfSpaceCondition);
169  // }
170
171  polyhedralCone = gfan::ZCone(inequalities,gfan::ZMatrix(0, inequalities.getWidth()));
172  polyhedralCone.canonicalize();
173  interiorPoint = polyhedralCone.getRelativeInteriorPoint();
174  assume(checkOrderingAndCone(polynomialRing,polyhedralCone));
175}
176
177groebnerCone::groebnerCone(const ideal I, const ring r, const gfan::ZVector& w, const tropicalStrategy& currentCase):
178  polynomialIdeal(NULL),
179  polynomialRing(NULL),
180  currentStrategy(&currentCase)
181{
182  assume(checkPolynomialInput(I,r));
183  if (r) polynomialRing = rCopy(r);
184  if (I)
185  {
186    polynomialIdeal = id_Copy(I,r);
187    currentCase.pReduce(polynomialIdeal,polynomialRing);
188    currentCase.reduce(polynomialIdeal,polynomialRing);
189  }
190
191  int n = rVar(polynomialRing);
192  gfan::ZMatrix inequalities = gfan::ZMatrix(0,n);
193  gfan::ZMatrix equations = gfan::ZMatrix(0,n);
194  int* expv = (int*) omAlloc((n+1)*sizeof(int));
195  for (int i=0; i<idSize(polynomialIdeal); i++)
196  {
197    poly g = polynomialIdeal->m[i];
198    if (g)
199    {
200      p_GetExpV(g,expv,polynomialRing);
201      gfan::ZVector leadexpv = intStar2ZVector(n,expv);
202      long d = wDeg(g,polynomialRing,w);
203      for (pIter(g); g; pIter(g))
204      {
205        p_GetExpV(g,expv,polynomialRing);
206        gfan::ZVector tailexpv = intStar2ZVector(n,expv);
207        if (wDeg(g,polynomialRing,w)==d)
208          equations.appendRow(leadexpv-tailexpv);
209        else
210        {
211          assume(wDeg(g,polynomialRing,w)<d);
212          inequalities.appendRow(leadexpv-tailexpv);
213        }
214      }
215    }
216  }
217  omFreeSize(expv,(n+1)*sizeof(int));
218  // if (currentStrategy->restrictToLowerHalfSpace())
219  // {
220  //   gfan::ZVector lowerHalfSpaceCondition = gfan::ZVector(n);
221  //   lowerHalfSpaceCondition[0] = -1;
222  //   inequalities.appendRow(lowerHalfSpaceCondition);
223  // }
224
225  polyhedralCone = gfan::ZCone(inequalities,equations);
226  polyhedralCone.canonicalize();
227  interiorPoint = polyhedralCone.getRelativeInteriorPoint();
228  assume(checkOrderingAndCone(polynomialRing,polyhedralCone));
229}
230
231/***
232 * Computes the groebner cone of I around u+e*w for e>0 sufficiently small.
233 * Assumes that this cone is a face of the maximal Groenbner cone given by the ordering of r.
234 **/
235groebnerCone::groebnerCone(const ideal I, const ring r, const gfan::ZVector& u, const gfan::ZVector& w, const tropicalStrategy& currentCase):
236  polynomialIdeal(NULL),
237  polynomialRing(NULL),
238  currentStrategy(&currentCase)
239{
240  assume(checkPolynomialInput(I,r));
241  if (r) polynomialRing = rCopy(r);
242  if (I)
243  {
244    polynomialIdeal = id_Copy(I,r);
245    currentCase.pReduce(polynomialIdeal,polynomialRing);
246    currentCase.reduce(polynomialIdeal,polynomialRing);
247  }
248
249  int n = rVar(polynomialRing);
250  gfan::ZMatrix inequalities = gfan::ZMatrix(0,n);
251  gfan::ZMatrix equations = gfan::ZMatrix(0,n);
252  int* expv = (int*) omAlloc((n+1)*sizeof(int));
253  for (int i=0; i<idSize(polynomialIdeal); i++)
254  {
255    poly g = polynomialIdeal->m[i];
256    if (g)
257    {
258      p_GetExpV(g,expv,polynomialRing);
259      gfan::ZVector leadexpv = intStar2ZVector(n,expv);
260      long d1 = wDeg(g,polynomialRing,u);
261      long d2 = wDeg(g,polynomialRing,w);
262      for (pIter(g); g; pIter(g))
263      {
264        p_GetExpV(g,expv,polynomialRing);
265        gfan::ZVector tailexpv = intStar2ZVector(n,expv);
266        if (wDeg(g,polynomialRing,u)==d1 && wDeg(g,polynomialRing,w)==d2)
267          equations.appendRow(leadexpv-tailexpv);
268        else
269        {
270          assume(wDeg(g,polynomialRing,u)<d1 || wDeg(g,polynomialRing,w)<d2);
271          inequalities.appendRow(leadexpv-tailexpv);
272        }
273      }
274    }
275  }
276  omFreeSize(expv,(n+1)*sizeof(int));
277  // if (currentStrategy->restrictToLowerHalfSpace())
278  // {
279  //   gfan::ZVector lowerHalfSpaceCondition = gfan::ZVector(n);
280  //   lowerHalfSpaceCondition[0] = -1;
281  //   inequalities.appendRow(lowerHalfSpaceCondition);
282  // }
283
284  polyhedralCone = gfan::ZCone(inequalities,equations);
285  polyhedralCone.canonicalize();
286  interiorPoint = polyhedralCone.getRelativeInteriorPoint();
287  assume(checkOrderingAndCone(polynomialRing,polyhedralCone));
288}
289
290
291groebnerCone::groebnerCone(const ideal I, const ideal inI, const ring r, const tropicalStrategy& currentCase):
292  polynomialIdeal(id_Copy(I,r)),
293  polynomialRing(rCopy(r)),
294  currentStrategy(&currentCase)
295{
296  assume(checkPolynomialInput(I,r));
297  assume(checkPolynomialInput(inI,r));
298
299  currentCase.pReduce(polynomialIdeal,polynomialRing);
300  currentCase.reduce(polynomialIdeal,polynomialRing);
301
302  int n = rVar(r);
303  gfan::ZMatrix equations = gfan::ZMatrix(0,n);
304  int* expv = (int*) omAlloc((n+1)*sizeof(int));
305  for (int i=0; i<idSize(inI); i++)
306  {
307    poly g = inI->m[i];
308    if (g)
309    {
310      p_GetExpV(g,expv,r);
311      gfan::ZVector leadexpv = intStar2ZVector(n,expv);
312      for (pIter(g); g; pIter(g))
313      {
314        p_GetExpV(g,expv,r);
315        gfan::ZVector tailexpv = intStar2ZVector(n,expv);
316        equations.appendRow(leadexpv-tailexpv);
317      }
318    }
319  }
320  gfan::ZMatrix inequalities = gfan::ZMatrix(0,n);
321  for (int i=0; i<idSize(polynomialIdeal); i++)
322  {
323    poly g = polynomialIdeal->m[i];
324    if (g)
325    {
326      p_GetExpV(g,expv,r);
327      gfan::ZVector leadexpv = intStar2ZVector(n,expv);
328      for (pIter(g); g; pIter(g))
329      {
330        p_GetExpV(g,expv,r);
331        gfan::ZVector tailexpv = intStar2ZVector(n,expv);
332        inequalities.appendRow(leadexpv-tailexpv);
333      }
334    }
335  }
336  omFreeSize(expv,(n+1)*sizeof(int));
337  if (currentStrategy->restrictToLowerHalfSpace())
338  {
339    gfan::ZVector lowerHalfSpaceCondition = gfan::ZVector(n);
340    lowerHalfSpaceCondition[0] = -1;
341    inequalities.appendRow(lowerHalfSpaceCondition);
342  }
343
344  polyhedralCone = gfan::ZCone(inequalities,equations);
345  polyhedralCone.canonicalize();
346  interiorPoint = polyhedralCone.getRelativeInteriorPoint();
347  assume(checkOrderingAndCone(polynomialRing,polyhedralCone));
348}
349
350groebnerCone::groebnerCone(const groebnerCone &sigma):
351  polynomialIdeal(NULL),
352  polynomialRing(NULL),
353  polyhedralCone(gfan::ZCone(sigma.getPolyhedralCone())),
354  interiorPoint(gfan::ZVector(sigma.getInteriorPoint())),
355  currentStrategy(sigma.getTropicalStrategy())
356{
357  assume(checkPolynomialInput(sigma.getPolynomialIdeal(),sigma.getPolynomialRing()));
358  assume(checkOrderingAndCone(sigma.getPolynomialRing(),sigma.getPolyhedralCone()));
359  assume(checkPolyhedralInput(sigma.getPolyhedralCone(),sigma.getInteriorPoint()));
360  if (sigma.getPolynomialIdeal()) polynomialIdeal = id_Copy(sigma.getPolynomialIdeal(),sigma.getPolynomialRing());
361  if (sigma.getPolynomialRing()) polynomialRing = rCopy(sigma.getPolynomialRing());
362}
363
364groebnerCone::~groebnerCone()
365{
366  assume(checkPolynomialInput(polynomialIdeal,polynomialRing));
367  assume(checkOrderingAndCone(polynomialRing,polyhedralCone));
368  assume(checkPolyhedralInput(polyhedralCone,interiorPoint));
369  if (polynomialIdeal) id_Delete(&polynomialIdeal,polynomialRing);
370  if (polynomialRing) rDelete(polynomialRing);
371}
372
373groebnerCone& groebnerCone::operator=(const groebnerCone& sigma)
374{
375  assume(checkPolynomialInput(sigma.getPolynomialIdeal(),sigma.getPolynomialRing()));
376  assume(checkOrderingAndCone(sigma.getPolynomialRing(),sigma.getPolyhedralCone()));
377  assume(checkPolyhedralInput(sigma.getPolyhedralCone(),sigma.getInteriorPoint()));
378  if (sigma.getPolynomialIdeal()) polynomialIdeal = id_Copy(sigma.getPolynomialIdeal(),sigma.getPolynomialRing());
379  if (sigma.getPolynomialRing()) polynomialRing = rCopy(sigma.getPolynomialRing());
380  polyhedralCone = sigma.getPolyhedralCone();
381  interiorPoint = sigma.getInteriorPoint();
382  currentStrategy = sigma.getTropicalStrategy();
383  return *this;
384}
385
386/**
387 * Returns true if Groebner cone contains w, false otherwise
388 */
389bool groebnerCone::contains(const gfan::ZVector &w) const
390{
391  return polyhedralCone.contains(w);
392}
393
394
395/***
396 * Returns a point in the tropical variety, if the groebnerCone contains one.
397 * Returns an empty vector otherwise.
398 **/
399gfan::ZVector groebnerCone::tropicalPoint() const
400{
401  assume(checkOrderingAndCone(polynomialRing,polyhedralCone));
402  ideal I = polynomialIdeal;
403  ring r = polynomialRing;
404
405  gfan::ZCone coneToCheck = polyhedralCone;
406  gfan::ZMatrix R = coneToCheck.extremeRays();
407  for (int i=0; i<R.getHeight(); i++)
408  {
409    assume(!currentStrategy->restrictToLowerHalfSpace() || R[i][0].sign()<=0);
410    if (currentStrategy->restrictToLowerHalfSpace() && R[i][0].sign()==0)
411      continue;
412    std::pair<poly,int> s = currentStrategy->checkInitialIdealForMonomial(I,r,R[i]);
413    if (s.first==NULL)
414    {
415      if (s.second<0)
416        // if monomial was initialized, delete it
417        p_Delete(&s.first,r);
418      return R[i];
419    }
420  }
421  return gfan::ZVector();
422}
423
424/**
425 * Given an interior point on the facet and the outer normal factor on the facet,
426 * returns the adjacent groebnerCone sharing that facet
427 */
428groebnerCone groebnerCone::flipCone(const gfan::ZVector &interiorPoint, const gfan::ZVector &facetNormal) const
429{
430  assume(this->checkFlipConeInput(interiorPoint,facetNormal));
431  /* Note: the polynomial ring created will have a weighted ordering with respect to interiorPoint
432   *   and with a weighted ordering with respect to facetNormal as tiebreaker.
433   *   Hence it is sufficient to compute the initial form with respect to facetNormal,
434   *   to obtain an initial form with respect to interiorPoint+e*facetNormal,
435   *   for e>0 sufficiently small */
436  std::pair<ideal,ring> flipped = currentStrategy->computeFlip(polynomialIdeal,polynomialRing,interiorPoint,facetNormal);
437  assume(checkPolynomialInput(flipped.first,flipped.second));
438  groebnerCone flippedCone(flipped.first, flipped.second, interiorPoint, facetNormal, *currentStrategy);
439  id_Delete(&flipped.first,flipped.second);
440  rDelete(flipped.second);
441  return flippedCone;
442}
443
444
445/***
446 * Computes a relative interior point and an outer normal vector for each facet of zc
447 **/
448static std::pair<gfan::ZMatrix,gfan::ZMatrix> interiorPointsAndNormalsOfFacets(const gfan::ZCone zc)
449{
450  gfan::ZMatrix inequalities = zc.getFacets();
451  gfan::ZMatrix equations = zc.getImpliedEquations();
452  int r = inequalities.getHeight();
453  int c = inequalities.getWidth();
454
455  /* our cone has r facets, if r==0 return empty matrices */
456  gfan::ZMatrix relativeInteriorPoints = gfan::ZMatrix(0,c);
457  gfan::ZMatrix outerFacetNormals = gfan::ZMatrix(0,c);
458  if (r==0)
459    return std::make_pair(relativeInteriorPoints,outerFacetNormals);
460
461  /* next we iterate over each of the r facets,
462   * build the respective cone and add it to the list
463   * this is the i=0 case */
464  gfan::ZMatrix newInequalities = inequalities.submatrix(1,0,r,c);
465  gfan::ZMatrix newEquations = equations;
466  newEquations.appendRow(inequalities[0]);
467  gfan::ZCone facet = gfan::ZCone(newInequalities,newEquations);
468  relativeInteriorPoints.appendRow(facet.getRelativeInteriorPoint());
469  assume(zc.contains(relativeInteriorPoints[0]) && !zc.containsRelatively(relativeInteriorPoints[0]));
470  outerFacetNormals.appendRow(-inequalities[0]);
471
472  /* these are the cases i=1,...,r-2 */
473  for (int i=1; i<r-1; i++)
474  {
475    newInequalities = inequalities.submatrix(0,0,i,c);
476    newInequalities.append(inequalities.submatrix(i+1,0,r,c));
477    newEquations = equations;
478    newEquations.appendRow(inequalities[i]);
479    facet = gfan::ZCone(newInequalities,newEquations);
480    relativeInteriorPoints.appendRow(facet.getRelativeInteriorPoint());
481    assume(zc.contains(relativeInteriorPoints[i]) && !zc.containsRelatively(relativeInteriorPoints[i]));
482    outerFacetNormals.appendRow(-inequalities[i]);
483  }
484
485  /* this is the i=r-1 case */
486  newInequalities = inequalities.submatrix(0,0,r-1,c);
487  newEquations = equations;
488  newEquations.appendRow(inequalities[r-1]);
489  facet = gfan::ZCone(newInequalities,newEquations);
490  relativeInteriorPoints.appendRow(facet.getRelativeInteriorPoint());
491  assume(zc.contains(relativeInteriorPoints[r-1]) && !zc.containsRelatively(relativeInteriorPoints[r-1]));
492  outerFacetNormals.appendRow(-inequalities[r-1]);
493
494  return std::make_pair(relativeInteriorPoints,outerFacetNormals);
495}
496
497
498/***
499 * Returns a complete list of neighboring Groebner cones.
500 **/
501groebnerCones groebnerCone::groebnerNeighbours() const
502{
503  std::pair<gfan::ZMatrix, gfan::ZMatrix> facetsData = interiorPointsAndNormalsOfFacets(polyhedralCone);
504
505  gfan::ZMatrix interiorPoints = facetsData.first;
506  gfan::ZMatrix facetNormals = facetsData.second;
507
508  groebnerCones neighbours;
509  for (int i=0; i<interiorPoints.getHeight(); i++)
510  {
511    gfan::ZVector w = interiorPoints[i];
512    gfan::ZVector v = facetNormals[i];
513    if (currentStrategy->restrictToLowerHalfSpace())
514    {
515      assume(w[0].sign()<=0);
516      if (w[0].sign()==0 && v[0].sign()>0)
517        continue;
518    }
519    neighbours.insert(flipCone(interiorPoints[i],facetNormals[i]));
520  }
521  return neighbours;
522}
523
524
525bool groebnerCone::pointsOutwards(const gfan::ZVector w) const
526{
527  gfan::ZCone dual = polyhedralCone.dualCone();
528  return (!dual.contains(w));
529}
530
531
532/***
533 * Returns a complete list of neighboring Groebner cones in the tropical variety.
534 **/
535groebnerCones groebnerCone::tropicalNeighbours() const
536{
537  gfan::ZMatrix interiorPoints = interiorPointsOfFacets(polyhedralCone);
538  groebnerCones neighbours;
539  for (int i=0; i<interiorPoints.getHeight(); i++)
540  {
541    if (!(currentStrategy->restrictToLowerHalfSpace() && interiorPoints[i][0].sign()==0))
542    {
543      ideal initialIdeal = initial(polynomialIdeal,polynomialRing,interiorPoints[i]);
544      gfan::ZMatrix ray = raysOfTropicalStar(initialIdeal,polynomialRing,interiorPoints[i],currentStrategy);
545      for (int j=0; j<ray.getHeight(); j++)
546        if (pointsOutwards(ray[j]))
547        {
548          groebnerCone neighbour = flipCone(interiorPoints[i],ray[j]);
549          neighbours.insert(neighbour);
550        }
551      id_Delete(&initialIdeal,polynomialRing);
552    }
553  }
554  return neighbours;
555}
556
557
558gfan::ZFan* toFanStar(groebnerCones setOfCones)
559{
560  if (setOfCones.size() > 0)
561  {
562    groebnerCones::iterator sigma = setOfCones.begin();
563    gfan::ZFan* zf = new gfan::ZFan(sigma->getPolyhedralCone().ambientDimension());
564    for (; sigma!=setOfCones.end(); sigma++)
565    {
566      gfan::ZCone zc = sigma->getPolyhedralCone();
567      assume(isCompatible(zf,&zc));
568      zf->insert(zc);
569    }
570    return zf;
571  }
572  else
573    return new gfan::ZFan(gfan::ZFan::fullFan(currRing->N));
574}
575
576
577#ifndef NDEBUG
578
579BOOLEAN flipConeDebug(leftv res, leftv args)
580{
581  leftv u = args;
582  if ((u!=NULL) && (u->Typ()==IDEAL_CMD))
583  {
584    leftv v = u->next;
585    if ((v!=NULL) && (v->Typ()==NUMBER_CMD))
586    {
587      leftv w = v->next;
588      if ((w!=NULL) && (w->Typ()==BIGINTMAT_CMD))
589      {
590        leftv x = w->next;
591        if ((x!=NULL) && (x->Typ()==BIGINTMAT_CMD))
592        {
593          omUpdateInfo();
594          Print("usedBytesBefore=%ld\n",om_Info.UsedBytes);
595
596          ideal I = (ideal) u->CopyD();
597          number p = (number) v->CopyD();
598          bigintmat* interiorPoint0 = (bigintmat*) w->CopyD();
599          bigintmat* facetNormal0 = (bigintmat*) x->CopyD();
600          tropicalStrategy debug = tropicalStrategy::debugStrategy(I,p,currRing);
601
602          gfan::ZVector* interiorPoint = bigintmatToZVector(interiorPoint0);
603          gfan::ZVector* facetNormal = bigintmatToZVector(facetNormal0);
604
605          groebnerCone sigma(I,currRing,debug);
606          groebnerCone theta = sigma.flipCone(*interiorPoint,*facetNormal);
607
608          id_Delete(&I,currRing);
609          n_Delete(&p,currRing->cf);
610          delete interiorPoint0;
611          delete facetNormal0;
612          delete interiorPoint;
613          delete facetNormal;
614
615          res->rtyp = NONE;
616          res->data = NULL;
617          return FALSE;
618        }
619      }
620    }
621  }
622  WerrorS("computeFlipDebug: unexpected parameters");
623  return TRUE;
624}
625
626BOOLEAN groebnerNeighboursDebug(leftv res, leftv args)
627{
628  leftv u = args;
629  if ((u!=NULL) && (u->Typ()==IDEAL_CMD))
630  {
631    leftv v = u->next;
632    if ((v!=NULL) && (v->Typ()==NUMBER_CMD))
633    {
634      omUpdateInfo();
635      Print("usedBytesBefore=%ld\n",om_Info.UsedBytes);
636
637      ideal I = (ideal) u->CopyD();
638      number p = (number) v->CopyD();
639
640      tropicalStrategy debug = tropicalStrategy::debugStrategy(I,p,currRing);
641      groebnerCone sigma(I,currRing,debug);
642      groebnerCones neighbours = sigma.groebnerNeighbours();
643
644      id_Delete(&I,currRing);
645      n_Delete(&p,currRing->cf);
646      res->rtyp = NONE;
647      res->data = NULL;
648      return FALSE;
649    }
650  }
651  WerrorS("computeFlipDebug: unexpected parameters");
652  return TRUE;
653}
654
655BOOLEAN tropicalNeighboursDebug(leftv res, leftv args)
656{
657  leftv u = args;
658  if ((u!=NULL) && (u->Typ()==IDEAL_CMD))
659  {
660    leftv v = u->next;
661    if ((v!=NULL) && (v->Typ()==NUMBER_CMD))
662    {
663      omUpdateInfo();
664      Print("usedBytesBefore=%ld\n",om_Info.UsedBytes);
665
666      ideal I = (ideal) u->CopyD();
667      number p = (number) v->CopyD();
668
669      tropicalStrategy debug = tropicalStrategy::debugStrategy(I,p,currRing);
670      groebnerCone sigma(I,currRing,debug);
671      groebnerCones neighbours = sigma.groebnerNeighbours();
672
673      id_Delete(&I,currRing);
674      n_Delete(&p,currRing->cf);
675      res->rtyp = NONE;
676      res->data = NULL;
677      return FALSE;
678    }
679  }
680  WerrorS("computeFlipDebug: unexpected parameters");
681  return TRUE;
682}
683#endif
Note: See TracBrowser for help on using the repository browser.