My Project
Loading...
Searching...
No Matches
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 229 of file tropicalStrategy.cc.

230{
231 // construct p-t
232 poly g = p_One(startingRing);
233 p_SetCoeff(g,uniformizingParameter,startingRing);
234 pNext(g) = p_One(startingRing);
235 p_SetExp(pNext(g),1,1,startingRing);
236 p_SetCoeff(pNext(g),n_Init(-1,startingRing->cf),startingRing);
237 p_Setm(pNext(g),startingRing);
238 ideal pt = idInit(1);
239 pt->m[0] = g;
240
241 // map originalIdeal from originalRing into startingRing
242 int k = IDELEMS(originalIdeal);
243 ideal J = idInit(k+1);
244 nMapFunc nMap = n_SetMap(originalRing->cf,startingRing->cf);
245 int n = rVar(originalRing);
246 int* shiftByOne = (int*) omAlloc((n+1)*sizeof(int));
247 for (int i=1; i<=n; i++)
248 shiftByOne[i]=i+1;
249 for (int i=0; i<k; i++)
250 {
251 if(originalIdeal->m[i]!=NULL)
252 {
253 J->m[i] = p_PermPoly(originalIdeal->m[i],shiftByOne,originalRing,startingRing,nMap,NULL,0);
254 }
255 }
256 omFreeSize(shiftByOne,(n+1)*sizeof(int));
257
258 ring origin = currRing;
259 rChangeCurrRing(startingRing);
260 ideal startingIdeal = kNF(pt,startingRing->qideal,J); // mathematically redundant,
261 rChangeCurrRing(origin); // but helps with upcoming std computation
262 // ideal startingIdeal = J; J = NULL;
263 assume(startingIdeal->m[k]==NULL);
264 startingIdeal->m[k] = pt->m[0];
265 startingIdeal = gfanlib_kStd_wrapper(startingIdeal,startingRing);
266
267 id_Delete(&J,startingRing);
268 pt->m[0] = NULL;
269 id_Delete(&pt,startingRing);
270 return startingIdeal;
271}
int i
Definition: cfEzgcd.cc:132
int k
Definition: cfEzgcd.cc:99
g
Definition: cfModGcd.cc:4090
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:697
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:535
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:73
poly kNF(ideal F, ideal Q, poly p, int syzComp, int lazyReduce)
Definition: kstd1.cc:3182
#define assume(x)
Definition: mod2.h:389
#define pNext(p)
Definition: monomials.h:36
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
#define omAlloc(size)
Definition: omAllocDecl.h:210
#define NULL
Definition: omList.c:12
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:4130
poly p_One(const ring r)
Definition: p_polys.cc:1313
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent @Note: VarOffset encodes the position in p->exp
Definition: p_polys.h:486
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:231
static number p_SetCoeff(poly p, number n, ring r)
Definition: p_polys.h:410
void rChangeCurrRing(ring r)
Definition: polys.cc:15
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:592
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:35
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
#define IDELEMS(i)
Definition: simpleideals.h:23
ideal gfanlib_kStd_wrapper(ideal I, ring r, tHomog h=testHomog)
Definition: std_wrapper.cc:6

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

169{
171
172 ring s = rCopy0(r,FALSE,FALSE);
173 nKillChar(s->cf);
174 s->cf = nInitChar(n_Z,NULL);
175
176 int n = rVar(s)+1;
177 s->N = n;
178 char** oldNames = s->names;
179 s->names = (char**) omAlloc((n+1)*sizeof(char**));
180 s->names[0] = omStrDup("t");
181 for (int i=1; i<n; i++)
182 s->names[i] = oldNames[i-1];
183 omFree(oldNames);
184
185 s->order = (rRingOrder_t*) omAlloc0(3*sizeof(rRingOrder_t));
186 s->block0 = (int*) omAlloc0(3*sizeof(int));
187 s->block1 = (int*) omAlloc0(3*sizeof(int));
188 s->wvhdl = (int**) omAlloc0(3*sizeof(int**));
189 s->order[0] = ringorder_ws;
190 s->block0[0] = 1;
191 s->block1[0] = n;
192 s->wvhdl[0] = (int*) omAlloc(n*sizeof(int));
193 s->wvhdl[0][0] = 1;
194 if (r->order[0] == ringorder_lp)
195 {
196 s->wvhdl[0][1] = 1;
197 }
198 else if (r->order[0] == ringorder_ls)
199 {
200 s->wvhdl[0][1] = -1;
201 }
202 else if (r->order[0] == ringorder_dp)
203 {
204 for (int i=1; i<n; i++)
205 s->wvhdl[0][i] = -1;
206 }
207 else if (r->order[0] == ringorder_ds)
208 {
209 for (int i=1; i<n; i++)
210 s->wvhdl[0][i] = 1;
211 }
212 else if (r->order[0] == ringorder_ws)
213 {
214 for (int i=1; i<n; i++)
215 s->wvhdl[0][i] = r->wvhdl[0][i-1];
216 }
217 else
218 {
219 for (int i=1; i<n; i++)
220 s->wvhdl[0][i] = -r->wvhdl[0][i-1];
221 }
222 s->order[1] = ringorder_C;
223
224 rComplete(s);
225 rTest(s);
226 return s;
227}
#define FALSE
Definition: auxiliary.h:96
@ n_Z
only used if HAVE_RINGS is defined
Definition: coeffs.h:43
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
Definition: numbers.cc:413
void nKillChar(coeffs r)
undo all initialisations
Definition: numbers.cc:568
const CanonicalForm int s
Definition: facAbsFact.cc:51
#define omStrDup(s)
Definition: omAllocDecl.h:263
#define omFree(addr)
Definition: omAllocDecl.h:261
#define omAlloc0(size)
Definition: omAllocDecl.h:211
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:3450
ring rCopy0(const ring r, BOOLEAN copy_qideal, BOOLEAN copy_ordering)
Definition: ring.cc:1421
rRingOrder_t
order stuff
Definition: ring.h:68
@ ringorder_lp
Definition: ring.h:77
@ ringorder_C
Definition: ring.h:73
@ ringorder_ds
Definition: ring.h:84
@ ringorder_dp
Definition: ring.h:78
@ ringorder_ws
Definition: ring.h:86
@ ringorder_ls
Definition: ring.h:83
static BOOLEAN rField_is_Q(const ring r)
Definition: ring.h:506
#define rTest(r)
Definition: ring.h:782

◆ 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_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}
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:512
int scDimInt(ideal S, ideal Q)
ideal dimension
Definition: hdegree.cc:78
#define idDelete(H)
delete an ideal
Definition: ideals.h:29
#define idPosConstant(I)
index of generator with leading term in ground ring (if any); otherwise -1
Definition: ideals.h:37
#define p_GetCoeff(p, r)
Definition: monomials.h:50
#define pDelete(p_ptr)
Definition: polys.h:186
static BOOLEAN rField_is_Z(const ring r)
Definition: ring.h:509
#define rField_is_Ring(R)
Definition: ring.h:485
ideal id_Head(ideal h, const ring r)
returns the ideals of initial terms

◆ 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 rRingOrder_t* 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 = (rRingOrder_t*) omAlloc0((h+2)*sizeof(rRingOrder_t));
79 rShortcut->block0 = (int*) omAlloc0((h+2)*sizeof(int));
80 rShortcut->block1 = (int*) omAlloc0((h+2)*sizeof(int));
81 rShortcut->wvhdl = (int**) omAlloc0((h+2)*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 //rShortcut->order[h+1] = (rRingOrder_t)0; -- done by omAlloc0
95 //rShortcut->block0[h+1] = 0;
96 //rShortcut->block1[h+1] = 0;
97 //rShortcut->wvhdl[h+1] = NULL;
98
99 rComplete(rShortcut);
100 rTest(rShortcut);
101
102 omFree(order);
103 omFree(block0);
104 omFree(block1);
105 omFree(wvhdl);
106
107 int k = IDELEMS(I);
108 ideal IShortcut = idInit(k);
109 nMapFunc intoShortcut = n_SetMap(r->cf,rShortcut->cf);
110 for (int i=0; i<k; i++)
111 {
112 if(I->m[i]!=NULL)
113 {
114 IShortcut->m[i] = p_PermPoly(I->m[i],NULL,r,rShortcut,intoShortcut,NULL,0);
115 }
116 }
117
118 ideal JShortcut = gfanlib_kStd_wrapper(IShortcut,rShortcut);
119
120 ideal J = idInit(k);
121 nMapFunc outofShortcut = n_SetMap(rShortcut->cf,r->cf);
122 for (int i=0; i<k; i++)
123 J->m[i] = p_PermPoly(JShortcut->m[i],NULL,rShortcut,r,outofShortcut,NULL,0);
124
125 assume(areIdealsEqual(J,r,I,r));
126 swapElements(I,J);
127 id_Delete(&IShortcut,rShortcut);
128 id_Delete(&JShortcut,rShortcut);
129 rDelete(rShortcut);
130 id_Delete(&J,r);
131 return false;
132}
int * ZVectorToIntStar(const gfan::ZVector &v, bool &overflow)
STATIC_VAR Poly * h
Definition: janet.cc:971
void rDelete(ring r)
unconditionally deletes fields in r
Definition: ring.cc:450
static int rBlocks(const ring r)
Definition: ring.h:568
@ ringorder_a
Definition: ring.h:70
bool areIdealsEqual(ideal I, ring r, ideal J, ring s)
static void swapElements(ideal I, ideal J)

◆ 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}