My Project
Functions | Variables
tropical.cc File Reference
#include "polys/monomials/p_polys.h"
#include "coeffs/coeffs.h"
#include "callgfanlib_conversion.h"
#include "bbcone.h"
#include "ppinitialReduction.h"
#include "containsMonomial.h"
#include "initial.h"
#include "witness.h"
#include "tropicalCurves.h"
#include "tropicalStrategy.h"
#include "startingCone.h"
#include "groebnerFan.h"
#include "groebnerComplex.h"
#include "tropicalVariety.h"

Go to the source code of this file.

Functions

gfan::ZCone homogeneitySpace (ideal I, ring r)
 
BOOLEAN homogeneitySpace (leftv res, leftv args)
 
gfan::ZCone lowerHomogeneitySpace (ideal I, ring r)
 
BOOLEAN lowerHomogeneitySpace (leftv res, leftv args)
 
gfan::ZCone groebnerCone (const ideal I, const ring r, const gfan::ZVector &w)
 
BOOLEAN groebnerCone (leftv res, leftv args)
 
gfan::ZCone maximalGroebnerCone (const ideal &I, const ring &r)
 
BOOLEAN maximalGroebnerCone (leftv res, leftv args)
 
BOOLEAN initial (leftv res, leftv args)
 
void tropical_setup (SModulFunctions *p)
 

Variables

VAR int tropicalVerboseLevel = 0
 

Function Documentation

◆ groebnerCone() [1/2]

gfan::ZCone groebnerCone ( const ideal  I,
const ring  r,
const gfan::ZVector &  w 
)

Definition at line 156 of file tropical.cc.

157{
158 int n = rVar(r);
159 poly g = NULL;
160 int* leadexpv = (int*) omAlloc((n+1)*sizeof(int));
161 int* tailexpv = (int*) omAlloc((n+1)*sizeof(int));
162 gfan::ZVector leadexpw = gfan::ZVector(n);
163 gfan::ZVector tailexpw = gfan::ZVector(n);
164
165 gfan::ZMatrix inequalities = gfan::ZMatrix(0,n);
166 for (int i=0; i<IDELEMS(I); i++)
167 {
168 g = (poly) I->m[i];
169 if (g!=NULL)
170 {
171 p_GetExpV(g,leadexpv,currRing);
172 leadexpw = intStar2ZVector(n, leadexpv);
173 pIter(g);
174 while (g!=NULL)
175 {
176 p_GetExpV(g,tailexpv,currRing);
177 tailexpw = intStar2ZVector(n, tailexpv);
178 inequalities.appendRow(leadexpw-tailexpw);
179 pIter(g);
180 }
181 }
182 }
183
184 ideal inI = initial(I,currRing,w);
185 gfan::ZMatrix equations = gfan::ZMatrix(0,n);
186 for (int i=0; i<IDELEMS(I); i++)
187 {
188 g = (poly) inI->m[i];
189 if (g!=NULL)
190 {
191 p_GetExpV(g,leadexpv,currRing);
192 leadexpw = intStar2ZVector(n, leadexpv);
193 pIter(g);
194 while (g!=NULL)
195 {
196 p_GetExpV(g,tailexpv,currRing);
197 tailexpw = intStar2ZVector(n, tailexpv);
198 equations.appendRow(leadexpw-tailexpw);
199 pIter(g);
200 }
201 }
202 }
203
204 omFreeSize(leadexpv,(n+1)*sizeof(int));
205 omFreeSize(tailexpv,(n+1)*sizeof(int));
206 id_Delete(&inI,currRing);
207 return gfan::ZCone(inequalities,equations);
208}
BOOLEAN equations(leftv res, leftv args)
Definition: bbcone.cc:577
BOOLEAN inequalities(leftv res, leftv args)
Definition: bbcone.cc:560
gfan::ZVector intStar2ZVector(const int d, const int *i)
int i
Definition: cfEzgcd.cc:132
g
Definition: cfModGcd.cc:4090
const CanonicalForm & w
Definition: facAbsFact.cc:51
if(!FE_OPT_NO_SHELL_FLAG)(void) system(sys)
#define pIter(p)
Definition: monomials.h:37
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
#define omAlloc(size)
Definition: omAllocDecl.h:210
#define NULL
Definition: omList.c:12
static void p_GetExpV(poly p, int *ev, const ring r)
Definition: p_polys.h:1518
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
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
#define IDELEMS(i)
Definition: simpleideals.h:23
BOOLEAN initial(leftv res, leftv args)
Definition: tropical.cc:373

◆ groebnerCone() [2/2]

BOOLEAN groebnerCone ( leftv  res,
leftv  args 
)

Definition at line 211 of file tropical.cc.

212{
213 leftv u = args;
214 if ((u != NULL) && (u->Typ() == POLY_CMD))
215 {
216 leftv v = u->next;
217 if ((v !=NULL) && ((v->Typ() == BIGINTMAT_CMD) || (v->Typ() == INTVEC_CMD)))
218 {
219 try
220 {
221 poly g = (poly) u->Data();
222 ideal I = idInit(1);
223 I->m[0] = g;
224 gfan::ZVector* weightVector;
225 if (v->Typ() == INTVEC_CMD)
226 {
227 intvec* w0 = (intvec*) v->Data();
229 w1->inpTranspose();
230 weightVector = bigintmatToZVector(*w1);
231 delete w1;
232 }
233 else
234 {
235 bigintmat* w1 = (bigintmat*) v->Data();
236 weightVector = bigintmatToZVector(*w1);
237 }
238 res->rtyp = coneID;
239 res->data = (void*) new gfan::ZCone(groebnerCone(I,currRing,*weightVector));
240 delete weightVector;
241 I->m[0] = NULL;
243 return FALSE;
244 }
245 catch (const std::exception& ex)
246 {
247 Werror("ERROR: %s",ex.what());
248 return TRUE;
249 }
250 }
251 }
252 if ((u != NULL) && (u->Typ() == IDEAL_CMD))
253 {
254 leftv v = u->next;
255 if ((v !=NULL) && ((v->Typ() == BIGINTMAT_CMD) || (v->Typ() == INTVEC_CMD)))
256 {
257 try
258 {
259 ideal I = (ideal) u->Data();
260 gfan::ZVector* weightVector;
261 if (v->Typ() == INTVEC_CMD)
262 {
263 intvec* w0 = (intvec*) v->Data();
265 w1->inpTranspose();
266 weightVector = bigintmatToZVector(*w1);
267 delete w1;
268 }
269 else
270 {
271 bigintmat* w1 = (bigintmat*) v->Data();
272 weightVector = bigintmatToZVector(*w1);
273 }
274 res->rtyp = coneID;
275 res->data = (void*) new gfan::ZCone(groebnerCone(I,currRing,*weightVector));
276 delete weightVector;
277 return FALSE;
278 }
279 catch (const std::exception& ex)
280 {
281 Werror("ERROR: %s",ex.what());
282 return TRUE;
283 }
284 }
285 }
286 WerrorS("groebnerCone: unexpected parameters");
287 return TRUE;
288}
#define TRUE
Definition: auxiliary.h:100
#define FALSE
Definition: auxiliary.h:96
VAR int coneID
Definition: bbcone.cc:25
bigintmat * iv2bim(intvec *b, const coeffs C)
Definition: bigintmat.cc:349
gfan::ZVector * bigintmatToZVector(const bigintmat &bim)
Matrices of numbers.
Definition: bigintmat.h:51
void inpTranspose()
transpose in place
Definition: bigintmat.cc:50
Definition: intvec.h:23
Class used for (list of) interpreter objects.
Definition: subexpr.h:83
int Typ()
Definition: subexpr.cc:1011
void * Data()
Definition: subexpr.cc:1154
leftv next
Definition: subexpr.h:86
CanonicalForm res
Definition: facAbsFact.cc:60
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:39
void WerrorS(const char *s)
Definition: feFopen.cc:24
@ IDEAL_CMD
Definition: grammar.cc:284
@ BIGINTMAT_CMD
Definition: grammar.cc:278
@ POLY_CMD
Definition: grammar.cc:289
VAR coeffs coeffs_BIGINT
Definition: ipid.cc:50
void Werror(const char *fmt,...)
Definition: reporter.cc:189
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:35
@ INTVEC_CMD
Definition: tok.h:101
gfan::ZCone groebnerCone(const ideal I, const ring r, const gfan::ZVector &w)
Definition: tropical.cc:156

◆ homogeneitySpace() [1/2]

gfan::ZCone homogeneitySpace ( ideal  I,
ring  r 
)

Definition at line 19 of file tropical.cc.

20{
21 int n = rVar(r);
22 poly g;
23 int* leadexpv = (int*) omAlloc((n+1)*sizeof(int));
24 int* tailexpv = (int*) omAlloc((n+1)*sizeof(int));
25 gfan::ZVector leadexpw = gfan::ZVector(n);
26 gfan::ZVector tailexpw = gfan::ZVector(n);
27 gfan::ZMatrix equations = gfan::ZMatrix(0,n);
28 for (int i=0; i<IDELEMS(I); i++)
29 {
30 g = (poly) I->m[i];
31 if (g)
32 {
33 p_GetExpV(g,leadexpv,r);
34 leadexpw = intStar2ZVector(n,leadexpv);
35 pIter(g);
36 while (g)
37 {
38 p_GetExpV(g,tailexpv,r);
39 tailexpw = intStar2ZVector(n,tailexpv);
40 equations.appendRow(leadexpw-tailexpw);
41 pIter(g);
42 }
43 }
44 }
45 omFreeSize(leadexpv,(n+1)*sizeof(int));
46 omFreeSize(tailexpv,(n+1)*sizeof(int));
47 return gfan::ZCone(gfan::ZMatrix(0, equations.getWidth()),equations);
48}

◆ homogeneitySpace() [2/2]

BOOLEAN homogeneitySpace ( leftv  res,
leftv  args 
)

Definition at line 51 of file tropical.cc.

52{
53 leftv u = args;
54 if ((u != NULL) && (u->Typ() == POLY_CMD))
55 {
56 leftv v = u->next;
57 if (v == NULL)
58 {
59 poly g = (poly) u->Data();
60 ideal I = idInit(1);
61 I->m[0] = g;
62 res->rtyp = coneID;
63 res->data = (void*) new gfan::ZCone(homogeneitySpace(I,currRing));
64 I->m[0] = NULL;
66 return FALSE;
67 }
68 }
69 if ((u != NULL) && (u->Typ() == IDEAL_CMD))
70 {
71 leftv v = u->next;
72 if (v == NULL)
73 {
74 ideal I = (ideal) u->Data();
75 res->rtyp = coneID;
76 res->data = (void*) new gfan::ZCone(homogeneitySpace(I,currRing));
77 return FALSE;
78 }
79 }
80 WerrorS("homogeneitySpace: unexpected parameters");
81 return TRUE;
82}
gfan::ZCone homogeneitySpace(ideal I, ring r)
Definition: tropical.cc:19

◆ initial()

BOOLEAN initial ( leftv  res,
leftv  args 
)

Definition at line 373 of file tropical.cc.

374{
375 leftv u = args;
376 if ((u != NULL) && (u->Typ() == POLY_CMD))
377 {
378 leftv v = u->next;
379 if ((v !=NULL) && ((v->Typ() == BIGINTMAT_CMD) || (v->Typ() == INTVEC_CMD)))
380 {
381 poly p = (poly) u->Data();
382 gfan::ZVector* weightVector;
383 if (v->Typ() == INTVEC_CMD)
384 {
385 intvec* w0 = (intvec*) v->Data();
387 w1->inpTranspose();
388 weightVector = bigintmatToZVector(*w1);
389 delete w1;
390 }
391 else
392 {
393 bigintmat* w1 = (bigintmat*) v->Data();
394 weightVector = bigintmatToZVector(*w1);
395 }
396 res->rtyp = POLY_CMD;
397 res->data = (void*) initial(p, currRing, *weightVector);
398 delete weightVector;
399 return FALSE;
400 }
401 }
402 if ((u != NULL) && (u->Typ() == IDEAL_CMD))
403 {
404 leftv v = u->next;
405 if ((v !=NULL) && ((v->Typ() == BIGINTMAT_CMD) || (v->Typ() == INTVEC_CMD)))
406 {
407 try
408 {
409 ideal I = (ideal) u->Data();
410 gfan::ZVector* weightVector;
411 if (v->Typ() == INTVEC_CMD)
412 {
413 intvec* w0 = (intvec*) v->Data();
415 w1->inpTranspose();
416 weightVector = bigintmatToZVector(*w1);
417 delete w1;
418 }
419 else
420 {
421 bigintmat* w1 = (bigintmat*) v->Data();
422 weightVector = bigintmatToZVector(*w1);
423 }
424 res->rtyp = IDEAL_CMD;
425 res->data = (void*) initial(I, currRing, *weightVector);
426 delete weightVector;
427 return FALSE;
428 }
429 catch (const std::exception& ex)
430 {
431 Werror("ERROR: %s",ex.what());
432 return TRUE;
433 }
434 }
435 }
436 WerrorS("initial: unexpected parameters");
437 return TRUE;
438}
int p
Definition: cfModGcd.cc:4078

◆ lowerHomogeneitySpace() [1/2]

gfan::ZCone lowerHomogeneitySpace ( ideal  I,
ring  r 
)

Definition at line 85 of file tropical.cc.

86{
87 int n = rVar(r);
88 poly g;
89 int* leadexpv = (int*) omAlloc((n+1)*sizeof(int));
90 int* tailexpv = (int*) omAlloc((n+1)*sizeof(int));
91 gfan::ZVector leadexpw = gfan::ZVector(n);
92 gfan::ZVector tailexpw = gfan::ZVector(n);
93 gfan::ZMatrix equations = gfan::ZMatrix(0,n);
94 for (int i=0; i<IDELEMS(I); i++)
95 {
96 g = (poly) I->m[i];
97 if (g)
98 {
99 p_GetExpV(g,leadexpv,r);
100 leadexpw = intStar2ZVector(n,leadexpv);
101 pIter(g);
102 while (g)
103 {
104 p_GetExpV(g,tailexpv,r);
105 tailexpw = intStar2ZVector(n,tailexpv);
106 equations.appendRow(leadexpw-tailexpw);
107 pIter(g);
108 }
109 }
110 }
111 gfan::ZMatrix inequalities = gfan::ZMatrix(0,n);
112 gfan::ZVector lowerHalfSpaceCondition = gfan::ZVector(n);
113 lowerHalfSpaceCondition[0] = -1;
114 inequalities.appendRow(lowerHalfSpaceCondition);
115
116 omFreeSize(leadexpv,(n+1)*sizeof(int));
117 omFreeSize(tailexpv,(n+1)*sizeof(int));
118 return gfan::ZCone(inequalities,equations);
119}

◆ lowerHomogeneitySpace() [2/2]

BOOLEAN lowerHomogeneitySpace ( leftv  res,
leftv  args 
)

Definition at line 122 of file tropical.cc.

123{
124 leftv u = args;
125 if ((u != NULL) && (u->Typ() == POLY_CMD))
126 {
127 leftv v = u->next;
128 if (v == NULL)
129 {
130 poly g = (poly) u->Data();
131 ideal I = idInit(1);
132 I->m[0] = g;
133 res->rtyp = coneID;
134 res->data = (void*) new gfan::ZCone(lowerHomogeneitySpace(I,currRing));
135 I->m[0] = NULL;
137 return FALSE;
138 }
139 }
140 if ((u != NULL) && (u->Typ() == IDEAL_CMD))
141 {
142 leftv v = u->next;
143 if (v == NULL)
144 {
145 ideal I = (ideal) u->Data();
146 res->rtyp = coneID;
147 res->data = (void*) new gfan::ZCone(lowerHomogeneitySpace(I,currRing));
148 return FALSE;
149 }
150 }
151 WerrorS("lowerHomogeneitySpace: unexpected parameters");
152 return TRUE;
153}
gfan::ZCone lowerHomogeneitySpace(ideal I, ring r)
Definition: tropical.cc:85

◆ maximalGroebnerCone() [1/2]

gfan::ZCone maximalGroebnerCone ( const ideal &  I,
const ring &  r 
)

Definition at line 291 of file tropical.cc.

292{
293 int n = rVar(r);
294 poly g = NULL;
295 int* leadexpv = (int*) omAlloc((n+1)*sizeof(int));
296 int* tailexpv = (int*) omAlloc((n+1)*sizeof(int));
297 gfan::ZVector leadexpw = gfan::ZVector(n);
298 gfan::ZVector tailexpw = gfan::ZVector(n);
299 gfan::ZMatrix inequalities = gfan::ZMatrix(0,n);
300 for (int i=0; i<IDELEMS(I); i++)
301 {
302 g = (poly) I->m[i];
303 if (g != NULL && pNext(g) != NULL)
304 {
305 p_GetExpV(g,leadexpv,r);
306 leadexpw = intStar2ZVector(n, leadexpv);
307 pIter(g);
308 while (g != NULL)
309 {
310 p_GetExpV(g,tailexpv,r);
311 tailexpw = intStar2ZVector(n, tailexpv);
312 inequalities.appendRow(leadexpw-tailexpw);
313 pIter(g);
314 }
315 }
316 }
317 omFreeSize(leadexpv,(n+1)*sizeof(int));
318 omFreeSize(tailexpv,(n+1)*sizeof(int));
319 return gfan::ZCone(inequalities,gfan::ZMatrix(0, inequalities.getWidth()));
320}
#define pNext(p)
Definition: monomials.h:36

◆ maximalGroebnerCone() [2/2]

BOOLEAN maximalGroebnerCone ( leftv  res,
leftv  args 
)

Definition at line 323 of file tropical.cc.

324{
325 leftv u = args;
326 if ((u != NULL) && (u->Typ() == POLY_CMD))
327 {
328 leftv v = u->next;
329 if (v == NULL)
330 {
331 try
332 {
333 poly g = (poly) u->Data();
334 ideal I = idInit(1);
335 I->m[0] = g;
336 res->rtyp = coneID;
337 res->data = (void*) new gfan::ZCone(maximalGroebnerCone(I,currRing));
338 I->m[0] = NULL;
340 return FALSE;
341 }
342 catch (const std::exception& ex)
343 {
344 Werror("ERROR: %s",ex.what());
345 return TRUE;
346 }
347 }
348 }
349 if ((u != NULL) && (u->Typ() == IDEAL_CMD))
350 {
351 leftv v = u->next;
352 if (v == NULL)
353 {
354 try
355 {
356 ideal I = (ideal) u->Data();
357 res->rtyp = coneID;
358 res->data = (void*) new gfan::ZCone(maximalGroebnerCone(I,currRing));
359 return FALSE;
360 }
361 catch (const std::exception& ex)
362 {
363 Werror("ERROR: %s",ex.what());
364 return TRUE;
365 }
366 }
367 }
368 WerrorS("maximalGroebnerCone: unexpected parameters");
369 return TRUE;
370}
gfan::ZCone maximalGroebnerCone(const ideal &I, const ring &r)
Definition: tropical.cc:291

◆ tropical_setup()

void tropical_setup ( SModulFunctions p)

Definition at line 441 of file tropical.cc.

442{
443 p->iiAddCproc("tropical.lib","groebnerCone",FALSE,groebnerCone);
444 p->iiAddCproc("tropical.lib","maximalGroebnerCone",FALSE,maximalGroebnerCone);
445 p->iiAddCproc("tropical.lib","homogeneitySpace",FALSE,homogeneitySpace);
446 // p->iiAddCproc("","lowerHomogeneitySpace",FALSE,lowerHomogeneitySpace);
447 p->iiAddCproc("tropical.lib","initial",FALSE,initial);
448 p->iiAddCproc("tropical.lib","tropicalVariety",FALSE,tropicalVariety);
449 p->iiAddCproc("tropical.lib","groebnerFan",FALSE,groebnerFan);
450 p->iiAddCproc("tropical.lib","groebnerComplex",FALSE,groebnerComplex);
451 // p->iiAddCproc("","ppreduceInitially",FALSE,ppreduceInitially);
452 // p->iiAddCproc("","ttreduceInitially",FALSE,ttreduceInitially);
453}
gfan::ZFan * groebnerComplex(const tropicalStrategy currentStrategy)
gfan::ZFan * groebnerFan(const tropicalStrategy currentStrategy)
Definition: groebnerFan.cc:28
BOOLEAN tropicalVariety(leftv res, leftv args)

Variable Documentation

◆ tropicalVerboseLevel

VAR int tropicalVerboseLevel = 0

Definition at line 17 of file tropical.cc.