23int dim(ideal I, ring r)
39 if (rField_is_Z(
currRing) && (
i==-1)) d++;
65 gfan::ZVector allOnes(n);
66 for (
int i=0;
i<n;
i++)
68 ring rShortcut =
rCopy0(r);
71 int* block0 = rShortcut->block0;
72 int* block1 = rShortcut->block1;
73 int** wvhdl = rShortcut->wvhdl;
77 rShortcut->block0 = (
int*)
omAlloc0((
h+2)*
sizeof(
int));
78 rShortcut->block1 = (
int*)
omAlloc0((
h+2)*
sizeof(
int));
79 rShortcut->wvhdl = (
int**)
omAlloc0((
h+2)*
sizeof(
int*));
81 rShortcut->block0[0] = 1;
82 rShortcut->block1[0] = n;
85 for (
int i=1;
i<=
h;
i++)
87 rShortcut->order[
i] = order[
i-1];
88 rShortcut->block0[
i] = block0[
i-1];
89 rShortcut->block1[
i] = block1[
i-1];
90 rShortcut->wvhdl[
i] = wvhdl[
i-1];
107 nMapFunc intoShortcut = n_SetMap(r->cf,rShortcut->cf);
108 for (
int i=0;
i<
k;
i++)
119 nMapFunc outofShortcut = n_SetMap(rShortcut->cf,r->cf);
120 for (
int i=0;
i<
k;
i++)
137 const bool completelyHomogeneous,
138 const bool completeSpace):
152 assume(rField_is_Q(r) || rField_is_Zp(r) || rField_is_Z(r));
153 if (!completelyHomogeneous)
176 char** oldNames =
s->names;
177 s->names = (
char**)
omAlloc((n+1)*
sizeof(
char**));
179 for (
int i=1;
i<n;
i++)
180 s->names[
i] = oldNames[
i-1];
184 s->block0 = (
int*)
omAlloc0(3*
sizeof(
int));
185 s->block1 = (
int*)
omAlloc0(3*
sizeof(
int));
186 s->wvhdl = (
int**)
omAlloc0(3*
sizeof(
int**));
190 s->wvhdl[0] = (
int*)
omAlloc(n*
sizeof(
int));
202 for (
int i=1;
i<n;
i++)
207 for (
int i=1;
i<n;
i++)
212 for (
int i=1;
i<n;
i++)
213 s->wvhdl[0][
i] = r->wvhdl[0][
i-1];
217 for (
int i=1;
i<n;
i++)
218 s->wvhdl[0][
i] = -r->wvhdl[0][
i-1];
227static ideal
constructStartingIdeal(ideal originalIdeal, ring originalRing, number uniformizingParameter, ring startingRing)
230 poly
g =
p_One(startingRing);
231 p_SetCoeff(
g,uniformizingParameter,startingRing);
233 p_SetExp(
pNext(
g),1,1,startingRing);
234 p_SetCoeff(
pNext(
g),n_Init(-1,startingRing->cf),startingRing);
235 p_Setm(
pNext(
g),startingRing);
242 nMapFunc nMap = n_SetMap(originalRing->cf,startingRing->cf);
243 int n = rVar(originalRing);
244 int* shiftByOne = (
int*)
omAlloc((n+1)*
sizeof(
int));
245 for (
int i=1;
i<=n;
i++)
247 for (
int i=0;
i<
k;
i++)
249 if(originalIdeal->m[
i]!=
NULL)
251 J->m[
i] =
p_PermPoly(originalIdeal->m[
i],shiftByOne,originalRing,startingRing,nMap,
NULL,0);
258 ideal startingIdeal =
kNF(pt,startingRing->qideal,J);
262 startingIdeal->m[
k] = pt->m[0];
268 return startingIdeal;
273 return n_Init(n_Int(a,src),dst);
341 uniformizingParameter = n_Copy(currentStrategy.getUniformizingParameter(),startingRing->cf);
342 n_Test(uniformizingParameter,startingRing->cf);
346 shortcutRing = rCopy(currentStrategy.getShortcutRing());
399 poly pt = p_Add_q(
p,p_Neg(t,r),r);
413 for (
int i=
l;
i>0;
i--)
432 if (
p!=
NULL) n_Delete(&
p,r->cf);
459 int* block0 = rShortcut->block0;
460 int* block1 = rShortcut->block1;
461 int** wvhdl = rShortcut->wvhdl;
465 int h = rBlocks(r);
int n = rVar(r);
467 rShortcut->block0 = (
int*)
omAlloc0((
h+2)*
sizeof(
int));
468 rShortcut->block1 = (
int*)
omAlloc0((
h+2)*
sizeof(
int));
469 rShortcut->wvhdl = (
int**)
omAlloc0((
h+2)*
sizeof(
int*));
471 rShortcut->block0[0] = 1;
472 rShortcut->block1[0] = n;
475 for (
int i=1;
i<=
h;
i++)
477 rShortcut->order[
i] = order[
i-1];
478 rShortcut->block0[
i] = block0[
i-1];
479 rShortcut->block1[
i] = block1[
i-1];
480 rShortcut->wvhdl[
i] = wvhdl[
i-1];
505 for (
int i=0;
i<
k;
i++)
511 return std::pair<poly,int>(
g,
i);
526 nMapFunc intoShortcut = n_SetMap(r->cf,rShortcut->cf);
527 for (
int i=0;
i<
k;
i++)
540 gfan::ZCone pos = gfan::ZCone::positiveOrthant(C0.ambientDimension());
541 gfan::ZCone C0pos = intersection(C0,pos);
542 C0pos.canonicalize();
543 gfan::ZVector wpos = C0pos.getRelativeInteriorPoint();
549 poly monomial =
NULL;
553 for (
int i=1;
i<=rVar(r);
i++)
554 p_SetExp(monomial,
i,p_GetExp(
p,
i,rShortcut),r);
556 p_Delete(&
p,rShortcut);
566 return std::pair<poly,int>(monomial,-1);
603 nMapFunc takingResidues = n_SetMap(r->cf,rShortcut->cf);
604 for (
int i=0;
i<
k;
i++)
606 for (
int j=0;
j<
l;
j++)
608 id_Test(inJShortcut,rShortcut);
609 id_Test(inIShortcut,rShortcut);
617 nMapFunc takingRepresentatives = n_SetMap(rShortcut->cf,r->cf);
618 for (
int ij=
k*
l-1; ij>=0; ij--)
628 for (
int j=0;
j<
k;
j++)
630 poly q0 = p_Copy(inJ->m[
j],r);
631 for (
int i=0;
i<
l;
i++)
634 poly inIi = p_Copy(inI->m[
i],r);
635 q0 = p_Add_q(q0,p_Neg(p_Mult_q(qij,inIi,r),r),r);
638 poly q0g0 = p_Mult_q(q0,p_Copy(I->m[uni],r),r);
641 for (
int i=0;
i<
l;
i++)
645 poly Ii = p_Copy(I->m[
i],r);
646 qigi = p_Add_q(qigi,p_Mult_q(qij,Ii,r),r);
648 J->m[
j] = p_Add_q(q0g0,qigi,r);
670 nMapFunc takingResidues = n_SetMap(r->cf,rShortcut->cf);
673 for (
int i=0;
i<
k;
i++)
678 nMapFunc takingRepresentatives = n_SetMap(rShortcut->cf,r->cf);
681 inJ->m[0] =
p_One(r);
684 for (
int i=0;
i<
k;
i++)
697 nMapFunc identitysr = n_SetMap(
s->cf,r->cf);
698 for (
int i=0;
i<
k;
i++)
702 nMapFunc identityrs = n_SetMap(r->cf,
s->cf);
704 for (
int i=0;
i<
k;
i++)
718 s->block0 = (
int*)
omAlloc0(5*
sizeof(
int));
719 s->block1 = (
int*)
omAlloc0(5*
sizeof(
int));
720 s->wvhdl = (
int**)
omAlloc0(5*
sizeof(
int**));
746 s->block0 = (
int*)
omAlloc0(5*
sizeof(
int));
747 s->block1 = (
int*)
omAlloc0(5*
sizeof(
int));
748 s->wvhdl = (
int**)
omAlloc0(5*
sizeof(
int**));
768 const gfan::ZVector &interiorPoint,
769 const gfan::ZVector &facetNormal)
const
777 ideal inIr =
initial(Ir,r,interiorPoint);
779 nMapFunc identity = n_SetMap(r->cf,sAdjusted->cf);
781 ideal inIsAdjusted =
idInit(
k);
782 for (
int i=0;
i<
k;
i++)
790 identity = n_SetMap(sAdjusted->cf,r->cf);
791 for (
int i=0;
i<
k;
i++)
796 identity = n_SetMap(r->cf,
s->cf);
798 for (
int i=0;
i<
k;
i++)
815 return std::make_pair(Js,
s);
833 poly pt = p_Add_q(
p,p_Neg(t,r),r);
858 poly pt = p_Add_q(
p,p_Neg(t,r),r);
gfan::ZVector nonvalued_adjustWeightForHomogeneity(const gfan::ZVector &w)
gfan::ZVector nonvalued_adjustWeightUnderHomogeneity(const gfan::ZVector &e, const gfan::ZVector &)
gfan::ZVector valued_adjustWeightForHomogeneity(const gfan::ZVector &w)
gfan::ZVector valued_adjustWeightUnderHomogeneity(const gfan::ZVector &e, const gfan::ZVector &w)
int * ZVectorToIntStar(const gfan::ZVector &v, bool &overflow)
int expectedDimension
the expected Dimension of the polyhedral output, i.e.
bool isValuationTrivial() const
bool(*) extraReductionAlgorithm(ideal I, ring r, number p)
A function that reduces the generators of an ideal I so that the inequalities and equations of the Gr...
ideal getOriginalIdeal() const
returns the input ideal over the field with valuation
tropicalStrategy(const ideal I, const ring r, const bool completelyHomogeneous=true, const bool completeSpace=true)
Constructor for the trivial valuation case.
bool isValuationNonTrivial() const
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
tropicalStrategy & operator=(const tropicalStrategy ¤tStrategy)
assignment operator
ring copyAndChangeOrderingLS(const ring r, const gfan::ZVector &w, const gfan::ZVector &v) const
void putUniformizingBinomialInFront(ideal I, const ring r, const number q) const
gfan::ZVector adjustWeightUnderHomogeneity(gfan::ZVector v, gfan::ZVector w) const
Given strictly positive weight w and weight v, returns a strictly positive weight u such that on an i...
bool reduce(ideal I, const ring r) const
reduces the generators of an ideal I so that the inequalities and equations of the Groebner cone can ...
gfan::ZCone getHomogeneitySpace() const
returns the homogeneity space of the preimage ideal
bool onlyLowerHalfSpace
true if valuation non-trivial, false otherwise
gfan::ZCone linealitySpace
the homogeneity space of the Grobner fan
int getExpectedDimension() const
returns the expected Dimension of the polyhedral output
ring startingRing
polynomial ring over the valuation ring extended by one extra variable t
ideal originalIdeal
input ideal, assumed to be a homogeneous prime ideal
gfan::ZVector(*) weightAdjustingAlgorithm2(const gfan::ZVector &v, const gfan::ZVector &w)
A function such that: Given strictly positive weight w and weight v, returns a strictly positive weig...
void pReduce(ideal I, const ring r) const
~tropicalStrategy()
destructor
int findPositionOfUniformizingBinomial(const ideal I, const ring r) const
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....
ring shortcutRing
polynomial ring over the residue field
ring getStartingRing() const
returns the polynomial ring over the valuation ring
gfan::ZVector adjustWeightForHomogeneity(gfan::ZVector w) const
Given weight w, returns a strictly positive weight u such that an ideal satisfying the valuation-sepc...
gfan::ZVector(*) weightAdjustingAlgorithm1(const gfan::ZVector &w)
A function such that: Given weight w, returns a strictly positive weight u such that an ideal satisfy...
ring getShortcutRingPrependingWeight(const ring r, const gfan::ZVector &w) const
If valuation trivial, returns a copy of r with a positive weight prepended, such that any ideal homog...
number uniformizingParameter
uniformizing parameter in the valuation ring
ring copyAndChangeCoefficientRing(const ring r) const
ring copyAndChangeOrderingWP(const ring r, const gfan::ZVector &w, const gfan::ZVector &v) const
ideal computeLift(const ideal inJs, const ring s, const ideal inIr, const ideal Ir, const ring r) const
ideal startingIdeal
preimage of the input ideal under the map that sends t to the uniformizing parameter
bool checkForUniformizingParameter(const ideal inI, const ring r) const
if valuation non-trivial, checks whether the genearting system contains p otherwise returns true
ideal getStartingIdeal() const
returns the input ideal
bool restrictToLowerHalfSpace() const
returns true, if valuation non-trivial, false otherwise
ideal computeStdOfInitialIdeal(const ideal inI, const ring r) const
given generators of the initial ideal, computes its standard basis
ring getOriginalRing() const
returns the polynomial ring over the field with valuation
number getUniformizingParameter() const
returns the uniformizing parameter in the valuation ring
std::pair< poly, int > checkInitialIdealForMonomial(const ideal I, const ring r, const gfan::ZVector &w=0) const
If given w, assuming w is in the Groebner cone of the ordering on r and I is a standard basis with re...
bool checkForUniformizingBinomial(const ideal I, const ring r) const
if valuation non-trivial, checks whether the generating system contains p-t otherwise returns true
ring getShortcutRing() const
ring originalRing
polynomial ring over a field with valuation
#define n_Test(a, r)
BOOLEAN n_Test(number a, const coeffs r).
@ n_Z
only used if HAVE_RINGS is defined
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
number(*) nMapFunc(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
void nKillChar(coeffs r)
undo all initialisations
poly searchForMonomialViaStepwiseSaturation(const ideal I, const ring r, const gfan::ZVector w0)
const CanonicalForm int s
const Variable & v
< [in] a sqrfree bivariate poly
if(!FE_OPT_NO_SHELL_FLAG)
int scDimInt(ideal S, ideal Q)
ideal dimension
#define idDelete(H)
delete an ideal
ideal id_Copy(ideal h1, const ring r)
copy an ideal
#define idPosConstant(I)
index of generator with leading term in ground ring (if any); otherwise -1
poly initial(const poly p, const ring r, const gfan::ZVector &w)
Returns the initial form of p with respect to w.
poly kNF(ideal F, ideal Q, poly p, int syzComp, int lazyReduce)
void mp_Delete(matrix *a, const ring r)
matrix mpNew(int r, int c)
create a r x c zero-matrix
#define MATELEM(mat, i, j)
1-based access to matrix
The main handler for Singular numbers which are suitable for Singular polynomials.
#define omFreeSize(addr, size)
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)
poly p_Div_nn(poly p, const number n, const ring r)
BOOLEAN p_EqualPolys(poly p1, poly p2, const ring r)
void rChangeCurrRing(ring r)
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
bool isOrderingLocalInT(const ring r)
bool ppreduceInitially(poly *hStar, const poly g, const ring r)
reduces h initially with respect to g, returns false if h was initially reduced in the first place,...
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...
ring rCopy0(const ring r, BOOLEAN copy_qideal, BOOLEAN copy_ordering)
void rDelete(ring r)
unconditionally deletes fields in r
#define rField_is_Ring(R)
ideal idInit(int idsize, int rank)
initialise an ideal / module
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
ideal id_Head(ideal h, const ring r)
returns the ideals of initial terms
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
ideal gfanlib_kStd_wrapper(ideal I, ring r, tHomog h=testHomog)
bool checkWeightVector(const ideal I, const ring r, const gfan::ZVector &weightVector, bool checkBorder)
bool checkForNonPositiveEntries(const gfan::ZVector &w)
bool areIdealsEqual(ideal I, ring r, ideal J, ring s)
static bool noExtraReduction(ideal I, ring r, number)
static ideal constructStartingIdeal(ideal originalIdeal, ring originalRing, number uniformizingParameter, ring startingRing)
static ring constructStartingRing(ring r)
Given a polynomial ring r over the rational numbers and a weighted ordering, returns a polynomial rin...
static void swapElements(ideal I, ideal J)
static number nMap_dummy(number a, const coeffs src, const coeffs dst)
implementation of the class tropicalStrategy
gfan::ZCone homogeneitySpace(ideal I, ring r)
matrix divisionDiscardingRemainder(const poly f, const ideal G, const ring r)
Computes a division discarding remainder of f with respect to G.
poly witness(const poly m, const ideal I, const ideal inI, const ring r)
Let w be the uppermost weight vector in the matrix defining the ordering on r.