Loading...
Searching...
No Matches
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.
static ideal | constructStartingIdeal (ideal originalIdeal, ring originalRing, number uniformizingParameter, ring startingRing)

## Function Documentation

## constructStartingIdeal()

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

static

Definition at line 227 of file tropicalStrategy.cc.

{
// construct p-t
poly g = p_One(startingRing);
p_SetCoeff(g,uniformizingParameter,startingRing);
pNext(g) = p_One(startingRing);
p_SetExp(pNext(g),1,1,startingRing);
p_SetCoeff(pNext(g),n_Init(-1,startingRing->cf),startingRing);
p_Setm(pNext(g),startingRing);
ideal pt = idInit(1);
pt->m[0] = g;
// map originalIdeal from originalRing into startingRing
int k = IDELEMS(originalIdeal);
ideal J = idInit(k+1);
nMapFunc nMap = n_SetMap(originalRing->cf,startingRing->cf);
int n = rVar(originalRing);
int* shiftByOne = (int*) omAlloc((n+1)*sizeof(int));
for (int i=1; i<=n; i++)
shiftByOne[i]=i+1;
for (int i=0; i<k; i++)
{
if(originalIdeal->m[i]!=NULL)
{
J->m[i] = p_PermPoly(originalIdeal->m[i],shiftByOne,originalRing,startingRing,nMap,NULL,0);
}
}
omFreeSize(shiftByOne,(n+1)*sizeof(int));
ring origin = currRing;
rChangeCurrRing(startingRing);
ideal startingIdeal = kNF(pt,startingRing->qideal,J); // mathematically redundant,
rChangeCurrRing(origin); // but helps with upcoming std computation
// ideal startingIdeal = J; J = NULL;
assume(startingIdeal->m[k]==NULL);
startingIdeal->m[k] = pt->m[0];
startingIdeal = gfanlib_kStd_wrapper(startingIdeal,startingRing);
id_Delete(&J,startingRing);
pt->m[0] = NULL;
id_Delete(&pt,startingRing);
return startingIdeal;
}
i
int i
Definition cfEzgcd.cc:132
k
int k
Definition cfEzgcd.cc:99
g
g
Definition cfModGcd.cc:4098
n_SetMap
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:703
n_Init
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:541
nMapFunc
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition coeffs.h:80
kNF
poly kNF(ideal F, ideal Q, poly p, int syzComp, int lazyReduce)
Definition kstd1.cc:3229
assume
#define assume(x)
Definition mod2.h:389
pNext
#define pNext(p)
Definition monomials.h:36
omFreeSize
#define omFreeSize(addr, size)
Definition omAllocDecl.h:260
omAlloc
#define omAlloc(size)
Definition omAllocDecl.h:210
NULL
#define NULL
Definition omList.c:12
p_PermPoly
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:4256
p_One
poly p_One(const ring r)
Definition p_polys.cc:1314
p_SetExp
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:490
p_Setm
static void p_Setm(poly p, const ring r)
Definition p_polys.h:235
p_SetCoeff
static number p_SetCoeff(poly p, number n, ring r)
Definition p_polys.h:414
rChangeCurrRing
void rChangeCurrRing(ring r)
Definition polys.cc:16
currRing
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition polys.cc:13
rVar
static short rVar(const ring r)
define rVar(r) (r->N)
Definition ring.h:598
idInit
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition simpleideals.cc:35
id_Delete
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
Definition simpleideals.cc:123
IDELEMS
#define IDELEMS(i)
Definition simpleideals.h:23
gfanlib_kStd_wrapper
ideal gfanlib_kStd_wrapper(ideal I, ring r, tHomog h=testHomog)
Definition std_wrapper.cc:6

## constructStartingRing()

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

{
assume(rField_is_Q(r));
ring s = rCopy0(r,FALSE,FALSE);
nKillChar(s->cf);
s->cf = nInitChar(n_Z,NULL);
int n = rVar(s)+1;
s->N = n;
char** oldNames = s->names;
s->names = (char**) omAlloc((n+1)*sizeof(char**));
s->names[0] = omStrDup("t");
for (int i=1; i<n; i++)
s->names[i] = oldNames[i-1];
omFree(oldNames);
s->order = (rRingOrder_t*) omAlloc0(3*sizeof(rRingOrder_t));
s->block0 = (int*) omAlloc0(3*sizeof(int));
s->block1 = (int*) omAlloc0(3*sizeof(int));
s->wvhdl = (int**) omAlloc0(3*sizeof(int**));
s->order[0] = ringorder_ws;
s->block0[0] = 1;
s->block1[0] = n;
s->wvhdl[0] = (int*) omAlloc(n*sizeof(int));
s->wvhdl[0][0] = 1;
if (r->order[0] == ringorder_lp)
{
s->wvhdl[0][1] = 1;
}
else if (r->order[0] == ringorder_ls)
{
s->wvhdl[0][1] = -1;
}
else if (r->order[0] == ringorder_dp)
{
for (int i=1; i<n; i++)
s->wvhdl[0][i] = -1;
}
else if (r->order[0] == ringorder_ds)
{
for (int i=1; i<n; i++)
s->wvhdl[0][i] = 1;
}
else if (r->order[0] == ringorder_ws)
{
for (int i=1; i<n; i++)
s->wvhdl[0][i] = r->wvhdl[0][i-1];
}
else
{
for (int i=1; i<n; i++)
s->wvhdl[0][i] = -r->wvhdl[0][i-1];
}
s->order[1] = ringorder_C;
rComplete(s);
rTest(s);
return s;
}
FALSE
#define FALSE
Definition auxiliary.h:97
n_Z
@ n_Z
only used if HAVE_RINGS is defined
Definition coeffs.h:43
nInitChar
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
Definition numbers.cc:412
nKillChar
void nKillChar(coeffs r)
undo all initialisations
Definition numbers.cc:563
s
const CanonicalForm int s
Definition facAbsFact.cc:51
omStrDup
#define omStrDup(s)
Definition omAllocDecl.h:263
omFree
#define omFree(addr)
Definition omAllocDecl.h:261
omAlloc0
#define omAlloc0(size)
Definition omAllocDecl.h:211
rComplete
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:3527
rCopy0
ring rCopy0(const ring r, BOOLEAN copy_qideal, BOOLEAN copy_ordering)
Definition ring.cc:1427
rRingOrder_t
rRingOrder_t
order stuff
Definition ring.h:69
ringorder_lp
@ ringorder_lp
Definition ring.h:78
ringorder_C
@ ringorder_C
Definition ring.h:74
ringorder_ds
@ ringorder_ds
Definition ring.h:86
ringorder_dp
@ ringorder_dp
Definition ring.h:79
ringorder_ws
@ ringorder_ws
Definition ring.h:88
ringorder_ls
@ ringorder_ls
degree, ip
Definition ring.h:85
rField_is_Q
static BOOLEAN rField_is_Q(const ring r)
Definition ring.h:512
rTest
#define rTest(r)
Definition ring.h:794

## dim()

int dim | ( | ideal | I,
|  | ring | r )

Definition at line 23 of file tropicalStrategy.cc.

{
ring origin = currRing;
if (origin != r)
rChangeCurrRing(r);
int d;
if (rField_is_Ring(currRing))
{
int i = idPosConstant(I);
if ((i != -1)
&& (n_IsUnit(p_GetCoeff(I->m[i],currRing->cf),currRing->cf))
)
return -1;
ideal vv = id_Head(I,currRing);
if (i != -1) pDelete(&vv->m[i]);
d = scDimInt(vv, currRing->qideal);
if (rField_is_Z(currRing) && (i==-1)) d++;
idDelete(&vv);
return d;
}
else
d = scDimInt(I,currRing->qideal);
if (origin != r)
rChangeCurrRing(origin);
return d;
}
n_IsUnit
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:521
scDimInt
int scDimInt(ideal S, ideal Q)
ideal dimension
Definition hdegree.cc:78
idDelete
#define idDelete(H)
delete an ideal
Definition ideals.h:29
idPosConstant
#define idPosConstant(I)
index of generator with leading term in ground ring (if any); otherwise -1
Definition ideals.h:37
p_GetCoeff
#define p_GetCoeff(p, r)
Definition monomials.h:50
pDelete
#define pDelete(p_ptr)
Definition polys.h:187
rField_is_Z
static BOOLEAN rField_is_Z(const ring r)
Definition ring.h:515
rField_is_Ring
#define rField_is_Ring(R)
Definition ring.h:491
id_Head
ideal id_Head(ideal h, const ring r)
returns the ideals of initial terms
Definition simpleideals.cc:1483

## noExtraReduction()

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

static

Definition at line 62 of file tropicalStrategy.cc.

{
int n = rVar(r);
gfan::ZVector allOnes(n);
for (int i=0; i<n; i++)
allOnes[i] = 1;
ring rShortcut = rCopy0(r);
rRingOrder_t* order = rShortcut->order;
int* block0 = rShortcut->block0;
int* block1 = rShortcut->block1;
int** wvhdl = rShortcut->wvhdl;
int h = rBlocks(r);
rShortcut->order = (rRingOrder_t*) omAlloc0((h+2)*sizeof(rRingOrder_t));
rShortcut->block0 = (int*) omAlloc0((h+2)*sizeof(int));
rShortcut->block1 = (int*) omAlloc0((h+2)*sizeof(int));
rShortcut->wvhdl = (int**) omAlloc0((h+2)*sizeof(int*));
rShortcut->order[0] = ringorder_a;
rShortcut->block0[0] = 1;
rShortcut->block1[0] = n;
bool overflow;
rShortcut->wvhdl[0] = ZVectorToIntStar(allOnes,overflow);
for (int i=1; i<=h; i++)
{
rShortcut->order[i] = order[i-1];
rShortcut->block0[i] = block0[i-1];
rShortcut->block1[i] = block1[i-1];
rShortcut->wvhdl[i] = wvhdl[i-1];
}
//rShortcut->order[h+1] = (rRingOrder_t)0; -- done by omAlloc0
//rShortcut->block0[h+1] = 0;
//rShortcut->block1[h+1] = 0;
//rShortcut->wvhdl[h+1] = NULL;
rComplete(rShortcut);
rTest(rShortcut);
omFree(order);
omFree(block0);
omFree(block1);
omFree(wvhdl);
int k = IDELEMS(I);
ideal IShortcut = idInit(k);
nMapFunc intoShortcut = n_SetMap(r->cf,rShortcut->cf);
for (int i=0; i<k; i++)
{
if(I->m[i]!=NULL)
{
IShortcut->m[i] = p_PermPoly(I->m[i],NULL,r,rShortcut,intoShortcut,NULL,0);
}
}
ideal JShortcut = gfanlib_kStd_wrapper(IShortcut,rShortcut);
ideal J = idInit(k);
nMapFunc outofShortcut = n_SetMap(rShortcut->cf,r->cf);
for (int i=0; i<k; i++)
J->m[i] = p_PermPoly(JShortcut->m[i],NULL,rShortcut,r,outofShortcut,NULL,0);
assume(areIdealsEqual(J,r,I,r));
swapElements(I,J);
id_Delete(&IShortcut,rShortcut);
id_Delete(&JShortcut,rShortcut);
rDelete(rShortcut);
id_Delete(&J,r);
return false;
}
ZVectorToIntStar
int * ZVectorToIntStar(const gfan::ZVector &v, bool &overflow)
Definition callgfanlib_conversion.cc:110
h
STATIC_VAR Poly * h
Definition janet.cc:971
rDelete
void rDelete(ring r)
unconditionally deletes fields in r
Definition ring.cc:454
rBlocks
static int rBlocks(const ring r)
Definition ring.h:574
ringorder_a
@ ringorder_a
Definition ring.h:71
areIdealsEqual
bool areIdealsEqual(ideal I, ring r, ideal J, ring s)
Definition tropicalDebug.cc:41
swapElements
static void swapElements(ideal I, ideal J)
Definition tropicalStrategy.cc:50

## swapElements()

void swapElements | ( | ideal | I,
|  | ideal | J )

static

Definition at line 50 of file tropicalStrategy.cc.

{
assume(IDELEMS(I)==IDELEMS(J));
for (int i=IDELEMS(I)-1; i>=0; i--)
{
poly cache = I->m[i];
I->m[i] = J->m[i];
J->m[i] = cache;
}
}