Functions
tropicalStrategy.cc File Reference
#include <tropicalStrategy.h>
#include <singularWishlist.h>
#include <adjustWeights.h>
#include <ppinitialReduction.h>
#include <tropical.h>
#include <std_wrapper.h>
#include <tropicalCurves.h>
#include <tropicalDebug.h>
#include <containsMonomial.h>
#include <kernel/ideals.h>
#include <kernel/combinatorics/stairc.h>
#include <kernel/GBEngine/kstd1.h>
#include <misc/prime.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)
 

Function Documentation

§ constructStartingIdeal()

static ideal constructStartingIdeal ( ideal  originalIdeal,
ring  originalRing,
number  uniformizingParameter,
ring  startingRing 
)
static

Definition at line 225 of file tropicalStrategy.cc.

226 {
227  // construct p-t
228  poly g = p_One(startingRing);
229  p_SetCoeff(g,uniformizingParameter,startingRing);
230  pNext(g) = p_One(startingRing);
231  p_SetExp(pNext(g),1,1,startingRing);
232  p_SetCoeff(pNext(g),n_Init(-1,startingRing->cf),startingRing);
233  p_Setm(pNext(g),startingRing);
234  ideal pt = idInit(1);
235  pt->m[0] = g;
236 
237  // map originalIdeal from originalRing into startingRing
238  int k = IDELEMS(originalIdeal);
239  ideal J = idInit(k+1);
240  nMapFunc nMap = n_SetMap(originalRing->cf,startingRing->cf);
241  int n = rVar(originalRing);
242  int* shiftByOne = (int*) omAlloc((n+1)*sizeof(int));
243  for (int i=1; i<=n; i++)
244  shiftByOne[i]=i+1;
245  for (int i=0; i<k; i++)
246  {
247  if(originalIdeal->m[i]!=NULL)
248  {
249  J->m[i] = p_PermPoly(originalIdeal->m[i],shiftByOne,originalRing,startingRing,nMap,NULL,0);
250  }
251  }
252  omFreeSize(shiftByOne,(n+1)*sizeof(int));
253 
254  ring origin = currRing;
255  rChangeCurrRing(startingRing);
256  ideal startingIdeal = kNF(pt,startingRing->qideal,J); // mathematically redundant,
257  rChangeCurrRing(origin); // but helps with upcoming std computation
258  // ideal startingIdeal = J; J = NULL;
259  assume(startingIdeal->m[k]==NULL);
260  startingIdeal->m[k] = pt->m[0];
261  startingIdeal = gfanlib_kStd_wrapper(startingIdeal,startingRing);
262 
263  id_Delete(&J,startingRing);
264  pt->m[0] = NULL;
265  id_Delete(&pt,startingRing);
266  return startingIdeal;
267 }
poly kNF(ideal F, ideal Q, poly p, int syzComp, int lazyReduce)
Definition: kstd1.cc:2971
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:542
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:583
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
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:407
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:10
poly p_PermPoly(poly p, const int *perm, const ring oldRing, const ring dst, nMapFunc nMap, const int *par_perm, int OldPar, BOOLEAN use_mult)
Definition: p_polys.cc:3938
poly p_One(const ring r)
Definition: p_polys.cc:1312
ideal gfanlib_kStd_wrapper(ideal I, ring r, tHomog h=testHomog)
Definition: std_wrapper.cc:6
#define assume(x)
Definition: mod2.h:394
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:73
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:24
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:725
void rChangeCurrRing(ring r)
Definition: polys.cc:12
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:38
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:483
#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:228
polyrec * poly
Definition: hilb.h:10

§ constructStartingRing()

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 164 of file tropicalStrategy.cc.

165 {
166  assume(rField_is_Q(r));
167 
168  ring s = rCopy0(r,FALSE,FALSE);
169  nKillChar(s->cf);
170  s->cf = nInitChar(n_Z,NULL);
171 
172  int n = rVar(s)+1;
173  s->N = n;
174  char** oldNames = s->names;
175  s->names = (char**) omAlloc((n+1)*sizeof(char**));
176  s->names[0] = omStrDup("t");
177  for (int i=1; i<n; i++)
178  s->names[i] = oldNames[i-1];
179  omFree(oldNames);
180 
181  s->order = (int*) omAlloc0(3*sizeof(int));
182  s->block0 = (int*) omAlloc0(3*sizeof(int));
183  s->block1 = (int*) omAlloc0(3*sizeof(int));
184  s->wvhdl = (int**) omAlloc0(3*sizeof(int**));
185  s->order[0] = ringorder_ws;
186  s->block0[0] = 1;
187  s->block1[0] = n;
188  s->wvhdl[0] = (int*) omAlloc(n*sizeof(int));
189  s->wvhdl[0][0] = 1;
190  if (r->order[0] == ringorder_lp)
191  {
192  s->wvhdl[0][1] = 1;
193  }
194  else if (r->order[0] == ringorder_ls)
195  {
196  s->wvhdl[0][1] = -1;
197  }
198  else if (r->order[0] == ringorder_dp)
199  {
200  for (int i=1; i<n; i++)
201  s->wvhdl[0][i] = -1;
202  }
203  else if (r->order[0] == ringorder_ds)
204  {
205  for (int i=1; i<n; i++)
206  s->wvhdl[0][i] = 1;
207  }
208  else if (r->order[0] == ringorder_ws)
209  {
210  for (int i=1; i<n; i++)
211  s->wvhdl[0][i] = r->wvhdl[0][i-1];
212  }
213  else
214  {
215  for (int i=1; i<n; i++)
216  s->wvhdl[0][i] = -r->wvhdl[0][i-1];
217  }
218  s->order[1] = ringorder_C;
219 
220  rComplete(s);
221  rTest(s);
222  return s;
223 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
#define FALSE
Definition: auxiliary.h:94
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:583
#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:3351
#define omFree(addr)
Definition: omAllocDecl.h:261
#define assume(x)
Definition: mod2.h:394
ring rCopy0(const ring r, BOOLEAN copy_qideal, BOOLEAN copy_ordering)
Definition: ring.cc:1321
#define rTest(r)
Definition: ring.h:778
only used if HAVE_RINGS is defined
Definition: coeffs.h:43
int i
Definition: cfEzgcd.cc:123
static BOOLEAN rField_is_Q(const ring r)
Definition: ring.h:501
#define NULL
Definition: omList.c:10
void nKillChar(coeffs r)
undo all initialisations
Definition: numbers.cc:496
#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:334
#define omStrDup(s)
Definition: omAllocDecl.h:263

§ dim()

int dim ( ideal  I,
ring  r 
)

Definition at line 23 of file tropicalStrategy.cc.

24 {
25  ring origin = currRing;
26  if (origin != r)
28  int d;
30  {
31  int i = idPosConstant(I);
32  if ((i != -1)
33  #ifdef HAVE_RINGS
34  && (n_IsUnit(p_GetCoeff(I->m[i],currRing->cf),currRing->cf))
35  #endif
36  )
37  return -1;
38  ideal vv = id_Head(I,currRing);
39  if (i != -1) pDelete(&vv->m[i]);
40  d = scDimInt(vv, currRing->qideal);
41  if (rField_is_Ring_Z(currRing) && (i==-1)) d++;
42  idDelete(&vv);
43  return d;
44  }
45  else
46  d = scDimInt(I,currRing->qideal);
47  if (origin != r)
48  rChangeCurrRing(origin);
49  return d;
50 }
#define idPosConstant(I)
index of generator with leading term in ground ring (if any); otherwise -1
Definition: ideals.h:37
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
#define idDelete(H)
delete an ideal
Definition: ideals.h:29
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:10
const ring r
Definition: syzextra.cc:208
int scDimInt(ideal S, ideal Q)
Definition: hdegree.cc:72
int i
Definition: cfEzgcd.cc:123
void rChangeCurrRing(ring r)
Definition: polys.cc:12
static BOOLEAN rField_is_Ring(const ring r)
Definition: ring.h:477
static BOOLEAN rField_is_Ring_Z(const ring r)
Definition: ring.h:474
ideal id_Head(ideal h, const ring r)
returns the ideals of initial terms
#define pDelete(p_ptr)
Definition: polys.h:169
#define p_GetCoeff(p, r)
Definition: monomials.h:57

§ noExtraReduction()

static bool noExtraReduction ( ideal  I,
ring  r,
number   
)
static

Definition at line 64 of file tropicalStrategy.cc.

65 {
66  int n = rVar(r);
67  gfan::ZVector allOnes(n);
68  for (int i=0; i<n; i++)
69  allOnes[i] = 1;
70  ring rShortcut = rCopy0(r);
71 
72  int* order = rShortcut->order;
73  int* block0 = rShortcut->block0;
74  int* block1 = rShortcut->block1;
75  int** wvhdl = rShortcut->wvhdl;
76 
77  int h = rBlocks(r);
78  rShortcut->order = (int*) omAlloc0((h+1)*sizeof(int));
79  rShortcut->block0 = (int*) omAlloc0((h+1)*sizeof(int));
80  rShortcut->block1 = (int*) omAlloc0((h+1)*sizeof(int));
81  rShortcut->wvhdl = (int**) omAlloc0((h+1)*sizeof(int*));
82  rShortcut->order[0] = ringorder_a;
83  rShortcut->block0[0] = 1;
84  rShortcut->block1[0] = n;
85  bool overflow;
86  rShortcut->wvhdl[0] = ZVectorToIntStar(allOnes,overflow);
87  for (int i=1; i<=h; i++)
88  {
89  rShortcut->order[i] = order[i-1];
90  rShortcut->block0[i] = block0[i-1];
91  rShortcut->block1[i] = block1[i-1];
92  rShortcut->wvhdl[i] = wvhdl[i-1];
93  }
94 
95  rComplete(rShortcut);
96  rTest(rShortcut);
97 
98  omFree(order);
99  omFree(block0);
100  omFree(block1);
101  omFree(wvhdl);
102 
103  int k = IDELEMS(I);
104  ideal IShortcut = idInit(k);
105  nMapFunc intoShortcut = n_SetMap(r->cf,rShortcut->cf);
106  for (int i=0; i<k; i++)
107  {
108  if(I->m[i]!=NULL)
109  {
110  IShortcut->m[i] = p_PermPoly(I->m[i],NULL,r,rShortcut,intoShortcut,NULL,0);
111  }
112  }
113 
114  ideal JShortcut = gfanlib_kStd_wrapper(IShortcut,rShortcut);
115 
116  ideal J = idInit(k);
117  nMapFunc outofShortcut = n_SetMap(rShortcut->cf,r->cf);
118  for (int i=0; i<k; i++)
119  J->m[i] = p_PermPoly(JShortcut->m[i],NULL,rShortcut,r,outofShortcut,NULL,0);
120 
121  assume(areIdealsEqual(J,r,I,r));
122  swapElements(I,J);
123  id_Delete(&IShortcut,rShortcut);
124  id_Delete(&JShortcut,rShortcut);
125  rDelete(rShortcut);
126  id_Delete(&J,r);
127  return false;
128 }
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:583
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
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:559
const ring r
Definition: syzextra.cc:208
poly p_PermPoly(poly p, const int *perm, const ring oldRing, const ring dst, nMapFunc nMap, const int *par_perm, int OldPar, BOOLEAN use_mult)
Definition: p_polys.cc:3938
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:3351
ideal gfanlib_kStd_wrapper(ideal I, ring r, tHomog h=testHomog)
Definition: std_wrapper.cc:6
#define omFree(addr)
Definition: omAllocDecl.h:261
#define assume(x)
Definition: mod2.h:394
ring rCopy0(const ring r, BOOLEAN copy_qideal, BOOLEAN copy_ordering)
Definition: ring.cc:1321
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:73
bool areIdealsEqual(ideal I, ring r, ideal J, ring s)
#define rTest(r)
Definition: ring.h:778
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:24
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:725
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:38
#define NULL
Definition: omList.c:10
void rDelete(ring r)
unconditionally deletes fields in r
Definition: ring.cc:448
static Poly * h
Definition: janet.cc:978
#define omAlloc0(size)
Definition: omAllocDecl.h:211

§ swapElements()

static void swapElements ( ideal  I,
ideal  J 
)
static

Definition at line 52 of file tropicalStrategy.cc.

53 {
54  assume(IDELEMS(I)==IDELEMS(J));
55 
56  for (int i=IDELEMS(I)-1; i>=0; i--)
57  {
58  poly cache = I->m[i];
59  I->m[i] = J->m[i];
60  J->m[i] = cache;
61  }
62 }
#define assume(x)
Definition: mod2.h:394
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:24
polyrec * poly
Definition: hilb.h:10