Functions
tropicalStrategy.cc File Reference
#include <tropicalStrategy.h>
#include <adjustWeights.h>
#include <ppinitialReduction.h>
#include <tropical.h>
#include <std_wrapper.h>
#include <tropicalCurves.h>
#include <kernel/ideals.h>
#include <kernel/combinatorics/stairc.h>
#include <kernel/GBEngine/kstd1.h>
#include <Singular/ipshell.h>

Go to the source code of this file.

Functions

int dim (ideal I, ring r)
 
static void swapElements (ideal I, ideal J)
 
static bool noExtraReduction (ideal I, ring r, number)
 
static ring constructStartingRing (ring r)
 Given a polynomial ring r over the rational numbers and a weighted ordering, returns a polynomial ring s over the integers with one extra variable, which is weighted -1. More...
 
static ideal constructStartingIdeal (ideal originalIdeal, ring originalRing, number uniformizingParameter, ring startingRing)
 
static void deleteOrdering (ring r)
 
BOOLEAN computeWitnessDebug (leftv res, leftv args)
 
BOOLEAN computeFlipDebug (leftv res, leftv args)
 

Function Documentation

BOOLEAN computeFlipDebug ( leftv  res,
leftv  args 
)

Definition at line 946 of file tropicalStrategy.cc.

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 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
Class used for (list of) interpreter objects.
Definition: subexpr.h:83
#define Print
Definition: emacs.cc:83
#define FALSE
Definition: auxiliary.h:140
return P p
Definition: myNF.cc:203
Matrices of numbers.
Definition: bigintmat.h:32
const ideal
Definition: gb_hack.h:42
void id_Delete(ideal *h, ring r)
#define TRUE
Definition: auxiliary.h:144
void WerrorS(const char *s)
Definition: feFopen.cc:23
static tropicalStrategy debugStrategy(const ideal startIdeal, number unifParameter, ring startRing)
int Typ()
Definition: subexpr.cc:949
void * data
Definition: subexpr.h:89
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
omInfo_t om_Info
Definition: omStats.c:13
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 ...
leftv next
Definition: subexpr.h:87
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
#define NULL
Definition: omList.c:10
void rDelete(ring r)
unconditionally deletes fields in r
Definition: ring.cc:448
void omUpdateInfo()
Definition: omStats.c:24
const CanonicalForm & w
Definition: facAbsFact.cc:55
int rtyp
Definition: subexpr.h:92
Variable x
Definition: cfModGcd.cc:4023
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:455
#define NONE
Definition: tok.h:170
void * CopyD(int t)
Definition: subexpr.cc:656
gfan::ZVector * bigintmatToZVector(const bigintmat &bim)
BOOLEAN computeWitnessDebug ( leftv  res,
leftv  args 
)

Definition at line 909 of file tropicalStrategy.cc.

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 }
Class used for (list of) interpreter objects.
Definition: subexpr.h:83
#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
return P p
Definition: myNF.cc:203
const ideal
Definition: gb_hack.h:42
void id_Delete(ideal *h, ring r)
#define TRUE
Definition: auxiliary.h:144
static tropicalStrategy debugStrategy(const ideal startIdeal, number unifParameter, ring startRing)
int Typ()
Definition: subexpr.cc:949
void * data
Definition: subexpr.h:89
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
omInfo_t om_Info
Definition: omStats.c:13
leftv next
Definition: subexpr.h:87
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
#define NULL
Definition: omList.c:10
void omUpdateInfo()
Definition: omStats.c:24
const CanonicalForm & w
Definition: facAbsFact.cc:55
int rtyp
Definition: subexpr.h:92
Variable x
Definition: cfModGcd.cc:4023
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:455
void * CopyD(int t)
Definition: subexpr.cc:656
static ideal constructStartingIdeal ( ideal  originalIdeal,
ring  originalRing,
number  uniformizingParameter,
ring  startingRing 
)
static

Definition at line 203 of file tropicalStrategy.cc.

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 }
const const intvec const intvec const ring _currRing const const intvec const intvec const ring _currRing int
Definition: gb_hack.h:53
poly kNF(ideal F, ideal Q, poly p, int syzComp, int lazyReduce)
Definition: kstd1.cc:2598
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
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)
g
Definition: cfModGcd.cc:4031
int k
Definition: cfEzgcd.cc:93
#define omAlloc(size)
Definition: omAllocDecl.h:210
static number p_SetCoeff(poly p, number n, ring r)
Definition: p_polys.h:401
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
poly p_One(const ring r)
Definition: p_polys.cc:1318
ideal gfanlib_kStd_wrapper(ideal I, ring r, tHomog h=testHomog)
Definition: std_wrapper.cc:5
polyrec * poly
Definition: hilb.h:10
#define assume(x)
Definition: mod2.h:405
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:71
int i
Definition: cfEzgcd.cc:123
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 rChangeCurrRing(ring r)
Definition: polys.cc:14
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
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
#define NULL
Definition: omList.c:10
#define pNext(p)
Definition: monomials.h:43
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:436
static int idSize(const ideal id)
Count the effective size of an ideal (without the trailing allocated zero-elements) ...
Definition: ideals.h:46
static ring constructStartingRing ( ring  r)
static

Given a polynomial ring r over the rational numbers and a weighted ordering, returns a polynomial ring s over the integers with one extra variable, which is weighted -1.

Definition at line 150 of file tropicalStrategy.cc.

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 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
#define FALSE
Definition: auxiliary.h:140
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
#define omAlloc(size)
Definition: omAllocDecl.h:210
const ring r
Definition: syzextra.cc:208
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
#define omFree(addr)
Definition: omAllocDecl.h:261
#define assume(x)
Definition: mod2.h:405
ring rCopy0(const ring r, BOOLEAN copy_qideal, BOOLEAN copy_ordering)
Definition: ring.cc:1281
#define rTest(r)
Definition: ring.h:769
only used if HAVE_RINGS is defined: ?
Definition: coeffs.h:41
int i
Definition: cfEzgcd.cc:123
static BOOLEAN rField_is_Q(const ring r)
Definition: ring.h:452
#define NULL
Definition: omList.c:10
void nKillChar(coeffs r)
undo all initialisations
Definition: numbers.cc:477
#define omAlloc0(size)
Definition: omAllocDecl.h:211
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
static void deleteOrdering ( ring  r)
static

Definition at line 662 of file tropicalStrategy.cc.

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 }
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
void * ADDRESS
Definition: auxiliary.h:161
static int rBlocks(ring r)
Definition: ring.h:507
const ring r
Definition: syzextra.cc:208
int j
Definition: myNF.cc:70
#define omFree(addr)
Definition: omAllocDecl.h:261
#define assume(x)
Definition: mod2.h:405
int i
Definition: cfEzgcd.cc:123
#define NULL
Definition: omList.c:10
int dim ( ideal  I,
ring  r 
)

Definition at line 19 of file tropicalStrategy.cc.

20 {
21  ring origin = currRing;
22  if (origin != 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 }
#define idPosConstant(I)
index of generator with leading term in ground ring (if any); otherwise -1
Definition: ideals.h:42
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
const ideal
Definition: gb_hack.h:42
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
const ring r
Definition: syzextra.cc:208
int scDimInt(ideal S, ideal Q)
Definition: hdegree.cc:72
void idDelete(ideal *h, ring r=currRing)
delete an ideal
Definition: ideals.h:31
int i
Definition: cfEzgcd.cc:123
void rChangeCurrRing(ring r)
Definition: polys.cc:14
static BOOLEAN rField_is_Ring(const ring r)
Definition: ring.h:428
static BOOLEAN rField_is_Ring_Z(const ring r)
Definition: ring.h:425
ideal id_Head(ideal h, const ring r)
#define pDelete(p_ptr)
Definition: polys.h:157
#define p_GetCoeff(p, r)
Definition: monomials.h:57
static bool noExtraReduction ( ideal  I,
ring  r,
number   
)
static

Definition at line 56 of file tropicalStrategy.cc.

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 }
const const intvec const intvec const ring _currRing const const intvec const intvec const ring _currRing int
Definition: gb_hack.h:53
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)
int * ZVectorToIntStar(const gfan::ZVector &v, bool &overflow)
int k
Definition: cfEzgcd.cc:93
static void swapElements(ideal I, ideal J)
static int rBlocks(ring r)
Definition: ring.h:507
const ring r
Definition: syzextra.cc:208
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
ideal gfanlib_kStd_wrapper(ideal I, ring r, tHomog h=testHomog)
Definition: std_wrapper.cc:5
#define omFree(addr)
Definition: omAllocDecl.h:261
ring rCopy0(const ring r, BOOLEAN copy_qideal, BOOLEAN copy_ordering)
Definition: ring.cc:1281
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:71
#define rTest(r)
Definition: ring.h:769
int i
Definition: cfEzgcd.cc:123
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
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
#define NULL
Definition: omList.c:10
void rDelete(ring r)
unconditionally deletes fields in r
Definition: ring.cc:448
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 * h
Definition: janet.cc:978
#define omAlloc0(size)
Definition: omAllocDecl.h:211
static void swapElements ( ideal  I,
ideal  J 
)
static

Definition at line 44 of file tropicalStrategy.cc.

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 }
polyrec * poly
Definition: hilb.h:10
#define assume(x)
Definition: mod2.h:405
int i
Definition: cfEzgcd.cc:123
static int idSize(const ideal id)
Count the effective size of an ideal (without the trailing allocated zero-elements) ...
Definition: ideals.h:46