tropicalStrategy.cc
Go to the documentation of this file.
1 #include <tropicalStrategy.h>
2 #include <adjustWeights.h>
3 #include <ppinitialReduction.h>
4 // #include <ttinitialReduction.h>
5 #include <tropical.h>
6 #include <std_wrapper.h>
7 #include <tropicalCurves.h>
8 
9 // for various commands in dim(ideal I, ring r):
10 #include <kernel/ideals.h>
12 #include <kernel/GBEngine/kstd1.h>
13 #include <Singular/ipshell.h> // for isPrime(int i)
14 
15 /***
16  * Computes the dimension of an ideal I in ring r
17  * Copied from jjDim in iparith.cc
18  **/
19 int dim(ideal I, ring r)
20 {
21  ring origin = currRing;
22  if (origin != r)
23  rChangeCurrRing(r);
24  int d;
26  {
27  int i = idPosConstant(I);
28  if ((i != -1) && (n_IsUnit(p_GetCoeff(I->m[i],currRing->cf),currRing->cf)))
29  return -1;
30  ideal vv = id_Head(I,currRing);
31  if (i != -1) pDelete(&vv->m[i]);
32  d = scDimInt(vv, currRing->qideal);
33  if (rField_is_Ring_Z(currRing) && (i==-1)) d++;
34  idDelete(&vv);
35  return d;
36  }
37  else
38  d = scDimInt(I,currRing->qideal);
39  if (origin != r)
40  rChangeCurrRing(origin);
41  return d;
42 }
43 
44 static void swapElements(ideal I, ideal J)
45 {
46  assume(idSize(I)==idSize(J));
47 
48  for (int i=idSize(I)-1; i>=0; i--)
49  {
50  poly cache = I->m[i];
51  I->m[i] = J->m[i];
52  J->m[i] = cache;
53  }
54 }
55 
56 static bool noExtraReduction(ideal I, ring r, number /*p*/)
57 {
58  int n = rVar(r);
59  gfan::ZVector allOnes(n);
60  for (int i=0; i<n; i++)
61  allOnes[i] = 1;
62  ring rShortcut = rCopy0(r);
63 
64  int* order = rShortcut->order;
65  int* block0 = rShortcut->block0;
66  int* block1 = rShortcut->block1;
67  int** wvhdl = rShortcut->wvhdl;
68 
69  int h = rBlocks(r);
70  rShortcut->order = (int*) omAlloc0((h+1)*sizeof(int));
71  rShortcut->block0 = (int*) omAlloc0((h+1)*sizeof(int));
72  rShortcut->block1 = (int*) omAlloc0((h+1)*sizeof(int));
73  rShortcut->wvhdl = (int**) omAlloc0((h+1)*sizeof(int*));
74  rShortcut->order[0] = ringorder_a;
75  rShortcut->block0[0] = 1;
76  rShortcut->block1[0] = n;
77  bool overflow;
78  rShortcut->wvhdl[0] = ZVectorToIntStar(allOnes,overflow);
79  for (int i=1; i<=h; i++)
80  {
81  rShortcut->order[i] = order[i-1];
82  rShortcut->block0[i] = block0[i-1];
83  rShortcut->block1[i] = block1[i-1];
84  rShortcut->wvhdl[i] = wvhdl[i-1];
85  }
86 
87  rComplete(rShortcut);
88  rTest(rShortcut);
89 
90  omFree(order);
91  omFree(block0);
92  omFree(block1);
93  omFree(wvhdl);
94 
95  int k = idSize(I);
96  ideal IShortcut = idInit(k);
97  nMapFunc intoShortcut = n_SetMap(r->cf,rShortcut->cf);
98  for (int i=0; i<k; i++)
99  IShortcut->m[i] = p_PermPoly(I->m[i],NULL,r,rShortcut,intoShortcut,NULL,0);
100 
101  ideal JShortcut = gfanlib_kStd_wrapper(IShortcut,rShortcut);
102 
103  ideal J = idInit(k);
104  nMapFunc outofShortcut = n_SetMap(rShortcut->cf,r->cf);
105  for (int i=0; i<k; i++)
106  J->m[i] = p_PermPoly(JShortcut->m[i],NULL,rShortcut,r,outofShortcut,NULL,0);
107 
108  swapElements(I,J);
109  id_Delete(&IShortcut,rShortcut);
110  id_Delete(&JShortcut,rShortcut);
111  rDelete(rShortcut);
112  id_Delete(&J,r);
113  return false;
114 }
115 
116 /**
117  * Initializes all relevant structures and information for the trivial valuation case,
118  * i.e. computing a tropical variety without any valuation.
119  */
121  const bool completelyHomogeneous,
122  const bool completeSpace):
123  originalRing(rCopy(r)),
124  originalIdeal(id_Copy(I,r)),
125  expectedDimension(dim(originalIdeal,originalRing)),
126  linealitySpace(homogeneitySpace(originalIdeal,originalRing)),
127  startingRing(rCopy(originalRing)),
128  startingIdeal(id_Copy(originalIdeal,originalRing)),
129  uniformizingParameter(NULL),
130  shortcutRing(NULL),
131  onlyLowerHalfSpace(false),
132  weightAdjustingAlgorithm1(nonvalued_adjustWeightForHomogeneity),
133  weightAdjustingAlgorithm2(nonvalued_adjustWeightUnderHomogeneity),
134  extraReductionAlgorithm(noExtraReduction)
135 {
137  if (!completelyHomogeneous)
138  {
141  }
142  if (!completeSpace)
143  onlyLowerHalfSpace = true;
144 }
145 
146 /**
147  * Given a polynomial ring r over the rational numbers and a weighted ordering,
148  * returns a polynomial ring s over the integers with one extra variable, which is weighted -1.
149  */
150 static ring constructStartingRing(ring r)
151 {
152  assume(rField_is_Q(r));
153 
154  ring s = rCopy0(r,FALSE,FALSE);
155  nKillChar(s->cf);
156  s->cf = nInitChar(n_Z,NULL);
157 
158  int n = rVar(s)+1;
159  s->N = n;
160  char** oldNames = s->names;
161  s->names = (char**) omAlloc((n+1)*sizeof(char**));
162  s->names[0] = omStrDup("t");
163  for (int i=1; i<n; i++)
164  s->names[i] = oldNames[i-1];
165  omFree(oldNames);
166 
167  s->order = (int*) omAlloc0(3*sizeof(int));
168  s->block0 = (int*) omAlloc0(3*sizeof(int));
169  s->block1 = (int*) omAlloc0(3*sizeof(int));
170  s->wvhdl = (int**) omAlloc0(3*sizeof(int**));
171  s->order[0] = ringorder_ws;
172  s->block0[0] = 1;
173  s->block1[0] = n;
174  s->wvhdl[0] = (int*) omAlloc(n*sizeof(int));
175  s->wvhdl[0][0] = 1;
176  if (r->order[0] == ringorder_dp)
177  {
178  for (int i=1; i<n; i++)
179  s->wvhdl[0][i] = -1;
180  }
181  else if (r->order[0] == ringorder_ds)
182  {
183  for (int i=1; i<n; i++)
184  s->wvhdl[0][i] = 1;
185  }
186  else if (r->order[0] == ringorder_ws)
187  {
188  for (int i=1; i<n; i++)
189  s->wvhdl[0][i] = r->wvhdl[0][i-1];
190  }
191  else
192  {
193  for (int i=1; i<n; i++)
194  s->wvhdl[0][i] = -r->wvhdl[0][i-1];
195  }
196  s->order[1] = ringorder_C;
197 
198  rComplete(s);
199  rTest(s);
200  return s;
201 }
202 
203 static ideal constructStartingIdeal(ideal originalIdeal, ring originalRing, number uniformizingParameter, ring startingRing)
204 {
205  // construct p-t
206  poly g = p_One(startingRing);
207  p_SetCoeff(g,uniformizingParameter,startingRing);
208  pNext(g) = p_One(startingRing);
209  p_SetExp(pNext(g),1,1,startingRing);
210  p_SetCoeff(pNext(g),n_Init(-1,startingRing->cf),startingRing);
211  p_Setm(pNext(g),startingRing);
212  ideal pt = idInit(1);
213  pt->m[0] = g;
214 
215  // map originalIdeal from originalRing into startingRing
216  int k = idSize(originalIdeal);
217  ideal J = idInit(k+1);
218  nMapFunc nMap = n_SetMap(originalRing->cf,startingRing->cf);
219  int n = rVar(originalRing);
220  int* shiftByOne = (int*) omAlloc((n+1)*sizeof(int));
221  for (int i=1; i<=n; i++)
222  shiftByOne[i]=i+1;
223  for (int i=0; i<k; i++)
224  J->m[i] = p_PermPoly(originalIdeal->m[i],shiftByOne,originalRing,startingRing,nMap,NULL,0);
225  omFreeSize(shiftByOne,(n+1)*sizeof(int));
226 
227  ring origin = currRing;
228  rChangeCurrRing(startingRing);
229  ideal startingIdeal = kNF(pt,startingRing->qideal,J); // mathematically redundant,
230  rChangeCurrRing(origin); // but helps with upcoming std computation
231  // ideal startingIdeal = J; J = NULL;
232  assume(startingIdeal->m[k]==NULL);
233  startingIdeal->m[k] = pt->m[0];
234  startingIdeal = gfanlib_kStd_wrapper(startingIdeal,startingRing);
235 
236  id_Delete(&J,startingRing);
237  pt->m[0] = NULL;
238  id_Delete(&pt,startingRing);
239  return startingIdeal;
240 }
241 
242 /***
243  * Initializes all relevant structures and information for the valued case,
244  * i.e. computing a tropical variety over the rational numbers with p-adic valuation
245  **/
247  originalRing(rCopy(s)),
248  originalIdeal(id_Copy(J,s)),
249  expectedDimension(dim(originalIdeal,originalRing)+1),
250  linealitySpace(gfan::ZCone()), // to come, see below
251  startingRing(NULL), // to come, see below
252  startingIdeal(NULL), // to come, see below
253  uniformizingParameter(NULL), // to come, see below
254  shortcutRing(NULL), // to come, see below
255  onlyLowerHalfSpace(true),
256  weightAdjustingAlgorithm1(valued_adjustWeightForHomogeneity),
257  weightAdjustingAlgorithm2(valued_adjustWeightUnderHomogeneity),
258  extraReductionAlgorithm(ppreduceInitially)
259 {
260  /* assume that the ground field of the originalRing is Q */
261  assume(rField_is_Q(s));
262 
263  /* replace Q with Z for the startingRing
264  * and add an extra variable for tracking the uniformizing parameter */
266 
267  /* map the uniformizing parameter into the new coefficient domain */
268  nMapFunc nMap = n_SetMap(originalRing->cf,startingRing->cf);
270 
271  /* map the input ideal into the new polynomial ring */
274 
276 
277  /* construct the shorcut ring */
279  nKillChar(shortcutRing->cf);
283 }
284 
286  originalRing(rCopy(currentStrategy.getOriginalRing())),
287  originalIdeal(id_Copy(currentStrategy.getOriginalIdeal(),currentStrategy.getOriginalRing())),
288  expectedDimension(currentStrategy.getExpectedDimension()),
289  linealitySpace(currentStrategy.getHomogeneitySpace()),
290  startingRing(rCopy(currentStrategy.getStartingRing())),
291  startingIdeal(id_Copy(currentStrategy.getStartingIdeal(),currentStrategy.getStartingRing())),
292  uniformizingParameter(NULL),
293  shortcutRing(NULL),
294  onlyLowerHalfSpace(currentStrategy.restrictToLowerHalfSpace()),
295  weightAdjustingAlgorithm1(currentStrategy.weightAdjustingAlgorithm1),
296  weightAdjustingAlgorithm2(currentStrategy.weightAdjustingAlgorithm2),
297  extraReductionAlgorithm(currentStrategy.extraReductionAlgorithm)
298 {
303  if (currentStrategy.getUniformizingParameter())
304  {
307  }
308  if (currentStrategy.getShortcutRing())
309  {
310  shortcutRing = rCopy(currentStrategy.getShortcutRing());
312  }
313 }
314 
316 {
323 
330 }
331 
333 {
334  originalRing = rCopy(currentStrategy.getOriginalRing());
335  originalIdeal = id_Copy(currentStrategy.getOriginalIdeal(),currentStrategy.getOriginalRing());
336  expectedDimension = currentStrategy.getExpectedDimension();
337  startingRing = rCopy(currentStrategy.getStartingRing());
338  startingIdeal = id_Copy(currentStrategy.getStartingIdeal(),currentStrategy.getStartingRing());
340  shortcutRing = rCopy(currentStrategy.getShortcutRing());
341  onlyLowerHalfSpace = currentStrategy.restrictToLowerHalfSpace();
345 
347  if (originalIdeal) id_Test(originalIdeal,originalRing);
349  if (startingIdeal) id_Test(startingIdeal,startingRing);
350  if (uniformizingParameter) n_Test(uniformizingParameter,startingRing->cf);
351  if (shortcutRing) rTest(shortcutRing);
352 
353  return *this;
354 }
355 
356 void tropicalStrategy::putUniformizingBinomialInFront(ideal I, const ring r, const number q) const
357 {
358  poly p = p_One(r);
359  p_SetCoeff(p,q,r);
360  poly t = p_One(r);
361  p_SetExp(t,1,1,r);
362  p_Setm(t,r);
363  poly pt = p_Add_q(p,p_Neg(t,r),r);
364 
365  int k = idSize(I);
366  int l;
367  for (l=0; l<k; l++)
368  {
369  if (p_EqualPolys(I->m[l],pt,r))
370  break;
371  }
372  p_Delete(&pt,r);
373 
374  if (l>1)
375  {
376  pt = I->m[l];
377  for (int i=l; i>0; i--)
378  I->m[l] = I->m[l-1];
379  I->m[0] = pt;
380  pt = NULL;
381  }
382  return;
383 }
384 
385 bool tropicalStrategy::reduce(ideal I, const ring r) const
386 {
387  rTest(r);
388  id_Test(I,r);
389 
390  nMapFunc identity = n_SetMap(startingRing->cf,r->cf);
391  number p = identity(uniformizingParameter,startingRing->cf,r->cf);
392  bool b = extraReductionAlgorithm(I,r,p);
393  // putUniformizingBinomialInFront(I,r,p);
394  n_Delete(&p,r->cf);
395 
396  return b;
397 }
398 
399 void tropicalStrategy::pReduce(ideal I, const ring r) const
400 {
401  rTest(r);
402  id_Test(I,r);
403 
404  if (isValuationTrivial())
405  return;
406 
407  nMapFunc identity = n_SetMap(startingRing->cf,r->cf);
408  number p = identity(uniformizingParameter,startingRing->cf,r->cf);
409  ::pReduce(I,p,r);
410  n_Delete(&p,r->cf);
411 
412  return;
413 }
414 
415 ring tropicalStrategy::getShortcutRingPrependingWeight(const ring r, const gfan::ZVector &v) const
416 {
417  ring rShortcut = rCopy0(r);
418 
419  // save old ordering
420  int* order = rShortcut->order;
421  int* block0 = rShortcut->block0;
422  int* block1 = rShortcut->block1;
423  int** wvhdl = rShortcut->wvhdl;
424 
425  // adjust weight and create new ordering
426  gfan::ZVector w = adjustWeightForHomogeneity(v);
427  int h = rBlocks(r); int n = rVar(r);
428  rShortcut->order = (int*) omAlloc0((h+1)*sizeof(int));
429  rShortcut->block0 = (int*) omAlloc0((h+1)*sizeof(int));
430  rShortcut->block1 = (int*) omAlloc0((h+1)*sizeof(int));
431  rShortcut->wvhdl = (int**) omAlloc0((h+1)*sizeof(int*));
432  rShortcut->order[0] = ringorder_a;
433  rShortcut->block0[0] = 1;
434  rShortcut->block1[0] = n;
435  bool overflow;
436  rShortcut->wvhdl[0] = ZVectorToIntStar(w,overflow);
437  for (int i=1; i<=h; i++)
438  {
439  rShortcut->order[i] = order[i-1];
440  rShortcut->block0[i] = block0[i-1];
441  rShortcut->block1[i] = block1[i-1];
442  rShortcut->wvhdl[i] = wvhdl[i-1];
443  }
444 
445  // if valuation non-trivial, change coefficient ring to residue field
446  if (isValuationNonTrivial())
447  {
448  nKillChar(rShortcut->cf);
449  rShortcut->cf = nCopyCoeff(shortcutRing->cf);
450  }
451  rComplete(rShortcut);
452  rTest(rShortcut);
453 
454  // delete old ordering
455  omFree(order);
456  omFree(block0);
457  omFree(block1);
458  omFree(wvhdl);
459 
460  return rShortcut;
461 }
462 
463 std::pair<poly,int> tropicalStrategy::checkInitialIdealForMonomial(const ideal I, const ring r, const gfan::ZVector &w) const
464 {
465  // quick check whether I already contains an ideal
466  int k = idSize(I);
467  for (int i=0; i<k; i++)
468  {
469  poly g = I->m[i];
470  if (pNext(g)==NULL && (isValuationTrivial() || n_IsOne(p_GetCoeff(g,r),r->cf)))
471  return std::pair<poly,int>(g,i);
472  }
473 
474  ring rShortcut;
475  ideal inIShortcut;
476  if (w.size()>0)
477  {
478  // if needed, prepend extra weight for homogeneity
479  // switch to residue field if valuation is non trivial
480  rShortcut = getShortcutRingPrependingWeight(r,w);
481 
482  // compute the initial ideal and map it into the constructed ring
483  // if switched to residue field, remove possibly 0 elements
484  ideal inI = initial(I,r,w);
485  inIShortcut = idInit(k);
486  nMapFunc intoShortcut = n_SetMap(r->cf,rShortcut->cf);
487  for (int i=0; i<k; i++)
488  inIShortcut->m[i] = p_PermPoly(inI->m[i],NULL,r,rShortcut,intoShortcut,NULL,0);
489  if (isValuationNonTrivial())
490  idSkipZeroes(inIShortcut);
491  id_Delete(&inI,r);
492  }
493  else
494  {
495  rShortcut = r;
496  inIShortcut = I;
497  }
498 
499  // check initial ideal for monomial and
500  // if it exsists, return a copy of the monomial in the input ring
501  poly p = checkForMonomialViaSuddenSaturation(inIShortcut,rShortcut);
502  poly monomial = NULL;
503  if (p!=NULL)
504  {
505  monomial=p_One(r);
506  for (int i=1; i<=rVar(r); i++)
507  p_SetExp(monomial,i,p_GetExp(p,i,rShortcut),r);
508  p_Setm(monomial,r);
509  p_Delete(&p,rShortcut);
510  }
511 
512 
513  if (w.size()>0)
514  {
515  // if needed, cleanup
516  id_Delete(&inIShortcut,rShortcut);
517  rDelete(rShortcut);
518  }
519  return std::pair<poly,int>(monomial,-1);
520 }
521 
523 {
524  ring rShortcut = rCopy0(r);
525  nKillChar(rShortcut->cf);
526  rShortcut->cf = nCopyCoeff(shortcutRing->cf);
527  rComplete(rShortcut);
528  rTest(rShortcut);
529  return rShortcut;
530 }
531 
532 ideal tropicalStrategy::computeWitness(const ideal inJ, const ideal inI, const ideal I, const ring r) const
533 {
534  // if the valuation is trivial and the ring and ideal have not been extended,
535  // then it is sufficient to return the difference between the elements of inJ
536  // and their normal forms with respect to I and r
537  if (isValuationTrivial())
538  return witness(inJ,I,r);
539  // if the valuation is non-trivial and the ring and ideal have been extended,
540  // then we can make a shortcut through the residue field
541  else
542  {
543  assume(idSize(inI)==idSize(I));
544  int uni = findPositionOfUniformizingBinomial(I,r);
545  assume(uni>=0);
546  /**
547  * change ground ring into finite field
548  * and map the data into it
549  */
550  ring rShortcut = copyAndChangeCoefficientRing(r);
551 
552  int k = idSize(inJ);
553  int l = idSize(I);
554  ideal inJShortcut = idInit(k);
555  ideal inIShortcut = idInit(l);
556  nMapFunc takingResidues = n_SetMap(r->cf,rShortcut->cf);
557  for (int i=0; i<k; i++)
558  inJShortcut->m[i] = p_PermPoly(inJ->m[i],NULL,r,rShortcut,takingResidues,NULL,0);
559  for (int j=0; j<l; j++)
560  inIShortcut->m[j] = p_PermPoly(inI->m[j],NULL,r,rShortcut,takingResidues,NULL,0);
561  id_Test(inJShortcut,rShortcut);
562  id_Test(inIShortcut,rShortcut);
563 
564  /**
565  * Compute a division with remainder over the finite field
566  * and map the result back to r
567  */
568  matrix QShortcut = divisionDiscardingRemainder(inJShortcut,inIShortcut,rShortcut);
569  matrix Q = mpNew(l,k);
570  nMapFunc takingRepresentatives = n_SetMap(rShortcut->cf,r->cf);
571  for (int ij=k*l-1; ij>=0; ij--)
572  Q->m[ij] = p_PermPoly(QShortcut->m[ij],NULL,rShortcut,r,takingRepresentatives,NULL,0);
573 
574  nMapFunc identity = n_SetMap(startingRing->cf,r->cf);
575  number p = identity(uniformizingParameter,startingRing->cf,r->cf);
576 
577  /**
578  * Compute the normal forms
579  */
580  ideal J = idInit(k);
581  for (int j=0; j<k; j++)
582  {
583  poly q0 = p_Copy(inJ->m[j],r);
584  for (int i=0; i<l; i++)
585  {
586  poly qij = p_Copy(MATELEM(Q,i+1,j+1),r);
587  poly inIi = p_Copy(inI->m[i],r);
588  q0 = p_Add_q(q0,p_Neg(p_Mult_q(qij,inIi,r),r),r);
589  }
590  q0 = p_Div_nn(q0,p,r);
591  poly q0g0 = p_Mult_q(q0,p_Copy(I->m[uni],r),r);
592  // q0 = NULL;
593  poly qigi = NULL;
594  for (int i=0; i<l; i++)
595  {
596  poly qij = p_Copy(MATELEM(Q,i+1,j+1),r);
597  // poly inIi = p_Copy(I->m[i],r);
598  poly Ii = p_Copy(I->m[i],r);
599  qigi = p_Add_q(qigi,p_Mult_q(qij,Ii,r),r);
600  }
601  J->m[j] = p_Add_q(q0g0,qigi,r);
602  }
603 
604  id_Delete(&inIShortcut,rShortcut);
605  id_Delete(&inJShortcut,rShortcut);
606  mp_Delete(&QShortcut,rShortcut);
607  rDelete(rShortcut);
608  mp_Delete(&Q,r);
609  n_Delete(&p,r->cf);
610  return J;
611  }
612 }
613 
615 {
616  // if valuation trivial, then compute std as usual
617  if (isValuationTrivial())
618  return gfanlib_kStd_wrapper(inI,r);
619 
620  // if valuation non-trivial, then uniformizing parameter is in ideal
621  // so switch to residue field first and compute standard basis over the residue field
622  ring rShortcut = copyAndChangeCoefficientRing(r);
623  nMapFunc takingResidues = n_SetMap(r->cf,rShortcut->cf);
624  int k = idSize(inI);
625  ideal inIShortcut = idInit(k);
626  for (int i=0; i<k; i++)
627  inIShortcut->m[i] = p_PermPoly(inI->m[i],NULL,r,rShortcut,takingResidues,NULL,0);
628  ideal inJShortcut = gfanlib_kStd_wrapper(inIShortcut,rShortcut);
629 
630  // and lift the result back to the ring with valuation
631  nMapFunc takingRepresentatives = n_SetMap(rShortcut->cf,r->cf);
632  k = idSize(inJShortcut);
633  ideal inJ = idInit(k+1);
634  inJ->m[0] = p_One(r);
635  nMapFunc identity = n_SetMap(startingRing->cf,r->cf);
636  p_SetCoeff(inJ->m[0],identity(uniformizingParameter,startingRing->cf,r->cf),r);
637  for (int i=0; i<k; i++)
638  inJ->m[i+1] = p_PermPoly(inJShortcut->m[i],NULL,rShortcut,r,takingRepresentatives,NULL,0);
639 
640  id_Delete(&inJShortcut,rShortcut);
641  id_Delete(&inIShortcut,rShortcut);
642  rDelete(rShortcut);
643  return inJ;
644 }
645 
646 ideal tropicalStrategy::computeLift(const ideal inJs, const ring s, const ideal inIr, const ideal Ir, const ring r) const
647 {
648  int k = idSize(inJs);
649  ideal inJr = idInit(k);
650  nMapFunc identitysr = n_SetMap(s->cf,r->cf);
651  for (int i=0; i<k; i++)
652  inJr->m[i] = p_PermPoly(inJs->m[i],NULL,s,r,identitysr,NULL,0);
653 
654  ideal Jr = computeWitness(inJr,inIr,Ir,r);
655  nMapFunc identityrs = n_SetMap(r->cf,s->cf);
656  ideal Js = idInit(k);
657  for (int i=0; i<k; i++)
658  Js->m[i] = p_PermPoly(Jr->m[i],NULL,r,s,identityrs,NULL,0);
659  return Js;
660 }
661 
662 static void deleteOrdering(ring r)
663 {
664  if (r->order != NULL)
665  {
666  int i=rBlocks(r);
667  assume(r->block0 != NULL && r->block1 != NULL && r->wvhdl != NULL);
668  /* delete order */
669  omFreeSize((ADDRESS)r->order,i*sizeof(int));
670  omFreeSize((ADDRESS)r->block0,i*sizeof(int));
671  omFreeSize((ADDRESS)r->block1,i*sizeof(int));
672  /* delete weights */
673  for (int j=0; j<i; j++)
674  if (r->wvhdl[j]!=NULL)
675  omFree(r->wvhdl[j]);
676  omFreeSize((ADDRESS)r->wvhdl,i*sizeof(int *));
677  }
678  else
679  assume(r->block0 == NULL && r->block1 == NULL && r->wvhdl == NULL);
680  return;
681 }
682 
683 ring tropicalStrategy::copyAndChangeOrderingWP(const ring r, const gfan::ZVector &w, const gfan::ZVector &v) const
684 {
685  // copy shortcutRing and change to desired ordering
686  bool ok;
687  ring s = rCopy0(r);
688  int n = rVar(s);
689  deleteOrdering(s);
690  gfan::ZVector wAdjusted = adjustWeightForHomogeneity(w);
691  gfan::ZVector vAdjusted = adjustWeightUnderHomogeneity(v,wAdjusted);
692  s->order = (int*) omAlloc0(5*sizeof(int));
693  s->block0 = (int*) omAlloc0(5*sizeof(int));
694  s->block1 = (int*) omAlloc0(5*sizeof(int));
695  s->wvhdl = (int**) omAlloc0(5*sizeof(int**));
696  s->order[0] = ringorder_a;
697  s->block0[0] = 1;
698  s->block1[0] = n;
699  s->wvhdl[0] = ZVectorToIntStar(wAdjusted,ok);
700  s->order[1] = ringorder_a;
701  s->block0[1] = 1;
702  s->block1[1] = n;
703  s->wvhdl[1] = ZVectorToIntStar(vAdjusted,ok);
704  s->order[2] = ringorder_lp;
705  s->block0[2] = 1;
706  s->block1[2] = n;
707  s->order[3] = ringorder_C;
708  rComplete(s);
709  rTest(s);
710 
711  return s;
712 }
713 
714 ring tropicalStrategy::copyAndChangeOrderingLS(const ring r, const gfan::ZVector &w, const gfan::ZVector &v) const
715 {
716  // copy shortcutRing and change to desired ordering
717  bool ok;
718  ring s = rCopy0(r);
719  int n = rVar(s);
720  deleteOrdering(s);
721  s->order = (int*) omAlloc0(5*sizeof(int));
722  s->block0 = (int*) omAlloc0(5*sizeof(int));
723  s->block1 = (int*) omAlloc0(5*sizeof(int));
724  s->wvhdl = (int**) omAlloc0(5*sizeof(int**));
725  s->order[0] = ringorder_a;
726  s->block0[0] = 1;
727  s->block1[0] = n;
728  s->wvhdl[0] = ZVectorToIntStar(w,ok);
729  s->order[1] = ringorder_a;
730  s->block0[1] = 1;
731  s->block1[1] = n;
732  s->wvhdl[1] = ZVectorToIntStar(v,ok);
733  s->order[2] = ringorder_lp;
734  s->block0[2] = 1;
735  s->block1[2] = n;
736  s->order[3] = ringorder_C;
737  rComplete(s);
738  rTest(s);
739 
740  return s;
741 }
742 
743 std::pair<ideal,ring> tropicalStrategy::computeFlip(const ideal Ir, const ring r,
744  const gfan::ZVector &interiorPoint,
745  const gfan::ZVector &facetNormal) const
746 {
747  assume(isValuationTrivial() || interiorPoint[0].sign()<0);
749 
750  // get a generating system of the initial ideal
751  // and compute a standard basis with respect to adjacent ordering
752  ideal inIr = initial(Ir,r,interiorPoint);
753  ring sAdjusted = copyAndChangeOrderingWP(r,interiorPoint,facetNormal);
754  nMapFunc identity = n_SetMap(r->cf,sAdjusted->cf);
755  int k = idSize(Ir);
756  ideal inIsAdjusted = idInit(k);
757  for (int i=0; i<k; i++)
758  inIsAdjusted->m[i] = p_PermPoly(inIr->m[i],NULL,r,sAdjusted,identity,NULL,0);
759  ideal inJsAdjusted = computeStdOfInitialIdeal(inIsAdjusted,sAdjusted);
760 
761  // find witnesses of the new standard basis elements of the initial ideal
762  // with the help of the old standard basis of the ideal
763  k = idSize(inJsAdjusted);
764  ideal inJr = idInit(k);
765  identity = n_SetMap(sAdjusted->cf,r->cf);
766  for (int i=0; i<k; i++)
767  inJr->m[i] = p_PermPoly(inJsAdjusted->m[i],NULL,sAdjusted,r,identity,NULL,0);
768 
769  ideal Jr = computeWitness(inJr,inIr,Ir,r);
770  ring s = copyAndChangeOrderingLS(r,interiorPoint,facetNormal);
771  identity = n_SetMap(r->cf,s->cf);
772  ideal Js = idInit(k);
773  for (int i=0; i<k; i++)
774  Js->m[i] = p_PermPoly(Jr->m[i],NULL,r,s,identity,NULL,0);
775 
776  // this->reduce(Jr,r);
777  // cleanup
778  id_Delete(&inIsAdjusted,sAdjusted);
779  id_Delete(&inJsAdjusted,sAdjusted);
780  rDelete(sAdjusted);
781  id_Delete(&inIr,r);
782  id_Delete(&Jr,r);
783  id_Delete(&inJr,r);
784 
786  return std::make_pair(Js,s);
787 }
788 
789 
791 {
792  // if the valuation is trivial,
793  // then there is no special condition the first generator has to fullfill
794  if (isValuationTrivial())
795  return true;
796 
797  // if the valuation is non-trivial then checks if the first generator is p-t
798  nMapFunc identity = n_SetMap(startingRing->cf,r->cf);
799  poly p = p_One(r);
800  p_SetCoeff(p,identity(uniformizingParameter,startingRing->cf,r->cf),r);
801  poly t = p_One(r);
802  p_SetExp(t,1,1,r);
803  p_Setm(t,r);
804  poly pt = p_Add_q(p,p_Neg(t,r),r);
805 
806  for (int i=0; i<idSize(I); i++)
807  {
808  if (p_EqualPolys(I->m[i],pt,r))
809  {
810  p_Delete(&pt,r);
811  return true;
812  }
813  }
814  p_Delete(&pt,r);
815  return false;
816 }
817 
819 {
821 
822  // if the valuation is non-trivial then checks if the first generator is p-t
823  nMapFunc identity = n_SetMap(startingRing->cf,r->cf);
824  poly p = p_One(r);
825  p_SetCoeff(p,identity(uniformizingParameter,startingRing->cf,r->cf),r);
826  poly t = p_One(r);
827  p_SetExp(t,1,1,r);
828  p_Setm(t,r);
829  poly pt = p_Add_q(p,p_Neg(t,r),r);
830 
831  for (int i=0; i<idSize(I); i++)
832  {
833  if (p_EqualPolys(I->m[i],pt,r))
834  {
835  p_Delete(&pt,r);
836  return i;
837  }
838  }
839  p_Delete(&pt,r);
840  return -1;
841 }
842 
843 bool tropicalStrategy::checkForUniformizingParameter(const ideal inI, const ring r) const
844 {
845  // if the valuation is trivial,
846  // then there is no special condition the first generator has to fullfill
847  if (isValuationTrivial())
848  return true;
849 
850  // if the valuation is non-trivial then checks if the first generator is p
851  if (inI->m[0]==NULL)
852  return false;
853  nMapFunc identity = n_SetMap(startingRing->cf,r->cf);
854  poly p = p_One(r);
855  p_SetCoeff(p,identity(uniformizingParameter,startingRing->cf,r->cf),r);
856 
857  for (int i=0; i<idSize(inI); i++)
858  {
859  if (p_EqualPolys(inI->m[i],p,r))
860  {
861  p_Delete(&p,r);
862  return true;
863  }
864  }
865  p_Delete(&p,r);
866  return false;
867 }
868 
869 #ifndef NDEBUG
871  originalRing(NULL),
872  originalIdeal(NULL),
873  expectedDimension(NULL),
874  linealitySpace(gfan::ZCone()),
875  startingRing(NULL),
876  startingIdeal(NULL),
877  uniformizingParameter(NULL),
878  shortcutRing(NULL),
879  onlyLowerHalfSpace(false)
880 {
884 }
885 
886 tropicalStrategy tropicalStrategy::debugStrategy(const ideal startIdeal, number unifParameter, ring startRing)
887 {
888  tropicalStrategy debug;
889  debug.originalRing = rCopy(startRing);
890  debug.originalIdeal = id_Copy(startIdeal,startRing);
891  debug.startingRing = rCopy(startRing);
892  debug.startingIdeal = id_Copy(startIdeal,startRing);
893  debug.uniformizingParameter = n_Copy(unifParameter,startRing->cf);
894 
895  debug.shortcutRing = rCopy0(startRing);
896  nKillChar(debug.shortcutRing->cf);
897  debug.shortcutRing->cf = nInitChar(n_Zp,(void*)(long)IsPrime(n_Int(unifParameter,startRing->cf)));
898  rComplete(debug.shortcutRing);
899  rTest(debug.shortcutRing);
900 
901  debug.onlyLowerHalfSpace = true;
905 
906  return debug;
907 }
908 
910 {
911  leftv u = args;
912  if ((u!=NULL) && (u->Typ()==IDEAL_CMD))
913  {
914  leftv v = u->next;
915  if ((v!=NULL) && (v->Typ()==IDEAL_CMD))
916  {
917  leftv w = v->next;
918  if ((w!=NULL) && (w->Typ()==IDEAL_CMD))
919  {
920  leftv x = w->next;
921  if ((x!=NULL) && (x->Typ()==NUMBER_CMD))
922  {
923  omUpdateInfo();
924  Print("usedBytesBefore=%ld\n",om_Info.UsedBytes);
925 
926  ideal inJ = (ideal) u->CopyD();
927  ideal inI = (ideal) v->CopyD();
928  ideal I = (ideal) w->CopyD();
929  number p = (number) x->CopyD();
931  ideal J = debug.computeWitness(inJ,inI,I,currRing);
932  id_Delete(&inJ,currRing);
933  id_Delete(&inI,currRing);
934  id_Delete(&I,currRing);
935  n_Delete(&p,currRing->cf);
936  res->rtyp = IDEAL_CMD;
937  res->data = (char*) J;
938  return FALSE;
939  }
940  }
941  }
942  }
943  return TRUE;
944 }
945 
947 {
948  leftv u = args;
949  if ((u!=NULL) && (u->Typ()==IDEAL_CMD))
950  {
951  leftv v = u->next;
952  if ((v!=NULL) && (v->Typ()==NUMBER_CMD))
953  {
954  leftv w = v->next;
955  if ((w!=NULL) && (w->Typ()==BIGINTMAT_CMD))
956  {
957  leftv x = w->next;
958  if ((x!=NULL) && (x->Typ()==BIGINTMAT_CMD))
959  {
960  omUpdateInfo();
961  Print("usedBytesBefore=%ld\n",om_Info.UsedBytes);
962 
963  ideal I = (ideal) u->CopyD();
964  number p = (number) v->CopyD();
965  bigintmat* interiorPoint0 = (bigintmat*) w->CopyD();
966  bigintmat* facetNormal0 = (bigintmat*) x->CopyD();
968 
969  gfan::ZVector* interiorPoint = bigintmatToZVector(interiorPoint0);
970  gfan::ZVector* facetNormal = bigintmatToZVector(facetNormal0);
971  std::pair<ideal,ring> Js = debug.computeFlip(I,currRing,*interiorPoint,*facetNormal);
972  ideal J = Js.first;
973  ring s = Js.second;
974 
975  id_Delete(&J,s);
976  rDelete(s);
977 
978  id_Delete(&I,currRing);
979  n_Delete(&p,currRing->cf);
980  delete interiorPoint0;
981  delete facetNormal0;
982  delete interiorPoint;
983  delete facetNormal;
984 
985  res->rtyp = NONE;
986  res->data = NULL;
987  return FALSE;
988  }
989  }
990  }
991  }
992  WerrorS("computeFlipDebug: unexpected parameters");
993  return TRUE;
994 }
995 #endif
#define idPosConstant(I)
index of generator with leading term in ground ring (if any); otherwise -1
Definition: ideals.h:42
const const intvec const intvec const ring _currRing const const intvec const intvec const ring _currRing int
Definition: gb_hack.h:53
implementation of the class tropicalStrategy
ring getOriginalRing() const
returns the polynomial ring over the field with valuation
const CanonicalForm int s
Definition: facAbsFact.cc:55
int findPositionOfUniformizingBinomial(const ideal I, const ring r) const
matrix divisionDiscardingRemainder(const poly f, const ideal G, const ring r)
Computes a division discarding remainder of f with respect to G.
Definition: witness.cc:9
ideal getOriginalIdeal() const
returns the input ideal over the field with valuation
Class used for (list of) interpreter objects.
Definition: subexpr.h:83
poly kNF(ideal F, ideal Q, poly p, int syzComp, int lazyReduce)
Definition: kstd1.cc:2598
static FORCE_INLINE BOOLEAN n_IsUnit(number n, const coeffs r)
TRUE iff n has a multiplicative inverse in the given coeff field/ring r.
Definition: coeffs.h:519
gfan::ZCone homogeneitySpace(ideal I, ring r)
Definition: tropical.cc:19
bool isValuationNonTrivial() const
gfan::ZVector nonvalued_adjustWeightUnderHomogeneity(const gfan::ZVector &e, const gfan::ZVector &)
#define Print
Definition: emacs.cc:83
ideal computeWitness(const ideal inJ, const ideal inI, const ideal I, const ring r) const
suppose w a weight in maximal groebner cone of > suppose I (initially) reduced standard basis w...
#define FALSE
Definition: auxiliary.h:140
bool isOrderingLocalInT(const ring r)
return P p
Definition: myNF.cc:203
ideal id_Copy(ideal h1, const ring r)
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff 'n' represents the one element.
Definition: coeffs.h:468
Matrices of numbers.
Definition: bigintmat.h:32
bool ppreduceInitially(poly *hStar, const poly g, const ring r)
reduces h initially with respect to g, returns false if h was initially reduced in the first place...
#define id_Test(A, lR)
Definition: simpleideals.h:67
BOOLEAN computeFlipDebug(leftv res, leftv args)
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition: coeffs.h:537
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
{p < 2^31}
Definition: coeffs.h:29
const ideal
Definition: gb_hack.h:42
const CanonicalForm CFMap CFMap int &both_non_zero int n
Definition: cfEzgcd.cc:52
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:531
void id_Delete(ideal *h, ring r)
poly p_Div_nn(poly p, const number n, const ring r)
Definition: p_polys.cc:1480
void pReduce(ideal I, const ring r) const
bool reduce(ideal I, const ring r) const
reduces the generators of an ideal I so that the inequalities and equations of the Groebner cone can ...
#define TRUE
Definition: auxiliary.h:144
void * ADDRESS
Definition: auxiliary.h:161
static ideal constructStartingIdeal(ideal originalIdeal, ring originalRing, number uniformizingParameter, ring startingRing)
g
Definition: cfModGcd.cc:4031
bool onlyLowerHalfSpace
true if valuation non-trivial, false otherwise
int * ZVectorToIntStar(const gfan::ZVector &v, bool &overflow)
void WerrorS(const char *s)
Definition: feFopen.cc:23
int k
Definition: cfEzgcd.cc:93
#define Q
Definition: sirandom.c:25
static tropicalStrategy debugStrategy(const ideal startIdeal, number unifParameter, ring startRing)
ring getStartingRing() const
returns the polynomial ring over the valuation ring
BOOLEAN computeWitnessDebug(leftv res, leftv args)
int Typ()
Definition: subexpr.cc:949
#define omAlloc(size)
Definition: omAllocDecl.h:210
static number p_SetCoeff(poly p, number n, ring r)
Definition: p_polys.h:401
static void swapElements(ideal I, ideal J)
int getExpectedDimension() const
returns the expected Dimension of the polyhedral output
static ring constructStartingRing(ring r)
Given a polynomial ring r over the rational numbers and a weighted ordering, returns a polynomial rin...
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:811
ideal startingIdeal
preimage of the input ideal under the map that sends t to the uniformizing parameter ...
void * data
Definition: subexpr.h:89
~tropicalStrategy()
destructor
poly res
Definition: myNF.cc:322
ring copyAndChangeCoefficientRing(const ring r) const
poly initial(const poly p, const ring r, const gfan::ZVector w)
Returns the initial form of p with respect to w.
Definition: initial.cc:32
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
number getUniformizingParameter() const
returns the uniformizing parameter in the valuation ring
poly * m
Definition: matpol.h:19
static int rBlocks(ring r)
Definition: ring.h:507
const ring r
Definition: syzextra.cc:208
BOOLEAN linealitySpace(leftv res, leftv args)
Definition: bbcone.cc:859
ideal originalIdeal
input ideal, assumed to be a homogeneous prime ideal
static bool noExtraReduction(ideal I, ring r, number)
static FORCE_INLINE long n_Int(number &n, const coeffs r)
conversion of n to an int; 0 if not possible in Z/pZ: the representing int lying in (-p/2 ...
Definition: coeffs.h:546
poly p_One(const ring r)
Definition: p_polys.cc:1318
ring getShortcutRing() const
ideal computeStdOfInitialIdeal(const ideal inI, const ring r) const
given generators of the initial ideal, computes its standard basis
BOOLEAN rComplete(ring r, int force)
this needs to be called whenever a new ring is created: new fields in ring are created (like VarOffse...
Definition: ring.cc:3371
ring shortcutRing
polynomial ring over the residue field
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent : the integer VarOffset encodes:
Definition: p_polys.h:465
int j
Definition: myNF.cc:70
ideal gfanlib_kStd_wrapper(ideal I, ring r, tHomog h=testHomog)
Definition: std_wrapper.cc:5
#define omFree(addr)
Definition: omAllocDecl.h:261
polyrec * poly
Definition: hilb.h:10
omInfo_t om_Info
Definition: omStats.c:13
#define assume(x)
Definition: mod2.h:405
static void deleteOrdering(ring r)
ring rCopy0(const ring r, BOOLEAN copy_qideal, BOOLEAN copy_ordering)
Definition: ring.cc:1281
ideal getStartingIdeal() const
returns the input ideal
std::pair< ideal, ring > computeFlip(const ideal Ir, const ring r, const gfan::ZVector &interiorPoint, const gfan::ZVector &facetNormal) const
given an interior point of a groebner cone computes the groebner cone adjacent to it ...
int scDimInt(ideal S, ideal Q)
Definition: hdegree.cc:72
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:71
ring getShortcutRingPrependingWeight(const ring r, const gfan::ZVector &w) const
If valuation trivial, returns a copy of r with a positive weight prepended, such that any ideal homog...
#define n_Test(a, r)
BOOLEAN n_Test(number a, const coeffs r)
Definition: coeffs.h:918
#define rTest(r)
Definition: ring.h:769
return false
Definition: cfModGcd.cc:84
void idDelete(ideal *h, ring r=currRing)
delete an ideal
Definition: ideals.h:31
void putUniformizingBinomialInFront(ideal I, const ring r, const number q) const
poly checkForMonomialViaSuddenSaturation(const ideal I, const ring r)
only used if HAVE_RINGS is defined: ?
Definition: coeffs.h:41
int dim(ideal I, ring r)
ring copyAndChangeOrderingWP(const ring r, const gfan::ZVector &w, const gfan::ZVector &v) const
int IsPrime(int p)
Definition: ipshell.cc:633
int i
Definition: cfEzgcd.cc:123
static BOOLEAN rField_is_Q(const ring r)
Definition: ring.h:452
gfan::ZVector(* weightAdjustingAlgorithm2)(const gfan::ZVector &v, const gfan::ZVector &w)
A function such that: Given strictly positive weight w and weight v, returns a strictly positive weig...
void mp_Delete(matrix *a, const ring r)
Definition: matpol.cc:784
static FORCE_INLINE nMapFunc n_SetMap(const coeffs src, const coeffs dst)
set the mapping function pointers for translating numbers from src to dst
Definition: coeffs.h:718
void idSkipZeroes(ideal ide)
gfan::ZVector adjustWeightUnderHomogeneity(gfan::ZVector v, gfan::ZVector w) const
Given strictly positive weight w and weight v, returns a strictly positive weight u such that on an i...
BOOLEAN p_EqualPolys(poly p1, poly p2, const ring r)
Definition: p_polys.cc:4288
gfan::ZVector valued_adjustWeightUnderHomogeneity(const gfan::ZVector &e, const gfan::ZVector &w)
leftv next
Definition: subexpr.h:87
void rChangeCurrRing(ring r)
Definition: polys.cc:14
static BOOLEAN rField_is_Zp(const ring r)
Definition: ring.h:446
bool restrictToLowerHalfSpace() const
returns true, if valuation non-trivial, false otherwise
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:48
static FORCE_INLINE coeffs nCopyCoeff(const coeffs r)
"copy" coeffs, i.e. increment ref
Definition: coeffs.h:429
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:850
ideal idInit(int idsize, int rank)
Definition: simpleideals.cc:40
poly p_PermPoly(poly p, const int *perm, const ring oldRing, const ring dst, nMapFunc nMap, const int *par_perm, int OldPar)
Definition: p_polys.cc:3892
gfan::ZVector adjustWeightForHomogeneity(gfan::ZVector w) const
Given weight w, returns a strictly positive weight u such that an ideal satisfying the valuation-sepc...
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
number uniformizingParameter
uniformizing parameter in the valuation ring
ring rCopy(ring r)
Definition: ring.cc:1579
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent : VarOffset encodes the position in p->exp
Definition: p_polys.h:484
ring startingRing
polynomial ring over the valuation ring extended by one extra variable t
static BOOLEAN rField_is_Ring(const ring r)
Definition: ring.h:428
#define NULL
Definition: omList.c:10
poly witness(const poly m, const ideal I, const ideal inI, const ring r)
Let w be the uppermost weight vector in the matrix defining the ordering on r.
Definition: witness.cc:34
ring copyAndChangeOrderingLS(const ring r, const gfan::ZVector &w, const gfan::ZVector &v) const
bool(* extraReductionAlgorithm)(ideal I, ring r, number p)
A function that reduces the generators of an ideal I so that the inequalities and equations of the Gr...
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of 'n'
Definition: coeffs.h:451
void rDelete(ring r)
unconditionally deletes fields in r
Definition: ring.cc:448
bool checkForUniformizingBinomial(const ideal I, const ring r) const
if valuation non-trivial, checks whether the generating system contains p-t otherwise returns true ...
void omUpdateInfo()
Definition: omStats.c:24
static BOOLEAN rField_is_Ring_Z(const ring r)
Definition: ring.h:425
gfan::ZVector nonvalued_adjustWeightForHomogeneity(const gfan::ZVector &w)
gfan::ZVector valued_adjustWeightForHomogeneity(const gfan::ZVector &w)
std::pair< poly, int > checkInitialIdealForMonomial(const ideal I, const ring r, const gfan::ZVector &w=0) const
If given w, assuming w is in the Groebner cone of the ordering on r and I is a standard basis with re...
ideal id_Head(ideal h, const ring r)
const CanonicalForm & w
Definition: facAbsFact.cc:55
#define pDelete(p_ptr)
Definition: polys.h:157
int rtyp
Definition: subexpr.h:92
Variable x
Definition: cfModGcd.cc:4023
ideal computeLift(const ideal inJs, const ring s, const ideal inIr, const ideal Ir, const ring r) const
#define pNext(p)
Definition: monomials.h:43
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:436
#define p_GetCoeff(p, r)
Definition: monomials.h:57
static int idSize(const ideal id)
Count the effective size of an ideal (without the trailing allocated zero-elements) ...
Definition: ideals.h:46
static poly p_Neg(poly p, const ring r)
Definition: p_polys.h:1018
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:455
ring originalRing
polynomial ring over a field with valuation
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:884
static Poly * h
Definition: janet.cc:978
int BOOLEAN
Definition: auxiliary.h:131
const poly b
Definition: syzextra.cc:213
#define NONE
Definition: tok.h:170
tropicalStrategy & operator=(const tropicalStrategy &currentStrategy)
assignment operator
gfan::ZCone linealitySpace
the homogeneity space of the Grobner fan
void nKillChar(coeffs r)
undo all initialisations
Definition: numbers.cc:477
static poly p_Mult_q(poly p, poly q, const ring r)
Definition: p_polys.h:1025
void * CopyD(int t)
Definition: subexpr.cc:656
gfan::ZVector * bigintmatToZVector(const bigintmat &bim)
#define omAlloc0(size)
Definition: omAllocDecl.h:211
int l
Definition: cfEzgcd.cc:94
int expectedDimension
the expected Dimension of the polyhedral output, i.e.
int sign(const CanonicalForm &a)
bool checkForUniformizingParameter(const ideal inI, const ring r) const
if valuation non-trivial, checks whether the genearting system contains p otherwise returns true ...
gfan::ZVector(* weightAdjustingAlgorithm1)(const gfan::ZVector &w)
A function such that: Given weight w, returns a strictly positive weight u such that an ideal satisfy...
#define MATELEM(mat, i, j)
Definition: matpol.h:29
bool isValuationTrivial() const
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
Definition: numbers.cc:316
#define omStrDup(s)
Definition: omAllocDecl.h:263