22#define OVERFLOW_MAX LONG_MAX
23#define OVERFLOW_MIN LONG_MIN
25#define OVERFLOW_MAX (((int64)LONG_MAX)<<30)
26#define OVERFLOW_MIN (-OVERFLOW_MAX)
60 if(modulweight==
NULL)
return 0;
62 for(
i=modulweight->
rows()-1;
i!=0;
i--)
75 for (
i = Nvar;
i>0;
i--)
78 for (
j = 0;
j < Nstc;
j++)
90 WerrorS(
"internal arrays too big");
102 for (
x =
Ql[
j];
x < z;
x++)
117 memcpy(pon, pol,
l *
sizeof(
int64));
120 for (
i =
x;
i <
l;
i++)
122 #ifndef __SIZEOF_INT128__
130 __int128 t2=pol[
i -
x];
132 if ((t>=LONG_MIN)&&(t<=LONG_MAX)) pon[
i]=t;
136 for (
i =
l;
i < ln;
i++)
138 #ifndef __SIZEOF_INT128__
143 __int128 t= -pol[
i -
x];
144 if ((t>=LONG_MIN)&&(t<=LONG_MAX)) pon[
i]=t;
151 for (
i =
l;
i <
x;
i++)
153 for (
i =
x;
i < ln;
i++)
154 pon[
i] = -pol[
i -
x];
165 for (
i = Nv;
i>0;
i--)
167 x = pure[var[
i + 1]];
173 for (
i = 0;
i <
l;
i++)
175 #ifndef __SIZEOF_INT128__
185 if ((t>=LONG_MIN)&&(t<=LONG_MAX)) pl[
i+
j]=t;
193 for (
i = 0;
i <
l;
i++)
195 #ifndef __SIZEOF_INT128__
205 if ((t>=LONG_MIN)&&(t<=LONG_MAX)) pl[
i+
j]=t;
216 int Nvar,
int64 *pol,
int Lpol)
218 int iv = Nvar -1, ln, a, a0, a1,
b,
i;
231 hStepS(sn, Nstc, var, Nvar, &a, &
x);
255 hStepS(sn, Nstc, var, Nvar, &a, &
x);
256 hElimS(sn, &
b, a0, a, var, iv);
258 hPure(sn, a0, &a1, var, iv, pn, &
i);
305static bool idDegSortTest(ideal I)
316 WerrorS(
"Ideal is not deg sorted!!");
550static poly ChoosePXL(ideal I)
554 for(
i =
IDELEMS(I)-1; (
i>=0) && (dummy == 0);
i--)
585static poly ChoosePXF(ideal I)
589 for(
i =0 ; (
i<=
IDELEMS(I)-1) && (dummy == 0);
i++)
620static poly ChoosePOL(ideal I)
652static poly ChoosePOF(ideal I)
684static poly ChoosePVL(ideal I)
714static poly ChoosePVF(ideal I)
773static poly ChoosePJF(ideal I)
886 mpz_set_ui(dummy, 1);
888 mpz_set_si(dummy, -1);
889 mpz_add(ec, ec, dummy);
902 int i,howmanyvarinp = 0;
922 poly notsqrfree =
NULL;
939 if(notsqrfree !=
NULL)
1012void rouneslice(ideal I, ideal S, poly q, poly
x,
int &
prune,
int &moreprune,
int &steps,
int &NNN, mpz_ptr &hilbertcoef,
int* &hilbpower)
1109 mpz_ptr ec_ptr = ec;
1114 hilbertcoef = (mpz_ptr)
omAlloc((NNN+1)*
sizeof(mpz_t));
1115 hilbpower = (
int*)
omAlloc((NNN+1)*
sizeof(int));
1116 mpz_init_set( &hilbertcoef[NNN], ec);
1128 mpz_add(&hilbertcoef[
i],&hilbertcoef[
i],ec_ptr);
1133 hilbertcoef = (mpz_ptr)
omRealloc(hilbertcoef, (NNN+1)*
sizeof(mpz_t));
1134 hilbpower = (
int*)
omRealloc(hilbpower, (NNN+1)*
sizeof(int));
1135 mpz_init(&hilbertcoef[NNN]);
1136 for(
j = NNN;
j>
i;
j--)
1138 mpz_set(&hilbertcoef[
j],&hilbertcoef[
j-1]);
1139 hilbpower[
j] = hilbpower[
j-1];
1141 mpz_set( &hilbertcoef[
i], ec);
1159 rouneslice(Ip, Sp, pq,
x,
prune, moreprune, steps, NNN, hilbertcoef,hilbpower);
1172 int steps = 0,
prune = 0, moreprune = 0;
1173 mpz_ptr hilbertcoef;
1189 rouneslice(I,S,q,X->m[0],
prune, moreprune, steps, NNN, hilbertcoef, hilbpower);
1195 printf(
"\n// %8d t^0",1);
1196 for(
i = 0;
i<NNN;
i++)
1198 if(mpz_sgn(&hilbertcoef[
i])!=0)
1200 gmp_printf(
"\n// %8Zd t^%d",&hilbertcoef[
i],hilbpower[
i]);
1204 omFreeSize(hilbertcoef, (NNN)*
sizeof(mpz_t));
1211 int ,
intvec *wdegree, ideal
Q, ring tailRing)
1218 int i,
j,
k,
l, ii, mw;
1229 if (wdegree ==
NULL)
1264 if (modulweight !=
NULL)
1265 j = (*modulweight)[mc-1]-mw;
1300 while ((
i > 0) && ((*Qpol)[
i - 1] == 0))
1308 for (ii=0; ii<
k; ii++)
1309 (*work)[ii] = (*hseries1)[ii];
1310 if (hseries1 !=
NULL)
1317 (*hseries1)[
i +
j - 1] += (*Qpol)[
i - 1];
1336 while ((*hseries1)[
l-2]==0)
l--;
1340 for (ii=
l-2; ii>=0; ii--)
1341 (*work)[ii] = (*hseries1)[ii];
1345 (*hseries1)[
l-1] = mw;
1370 return hSeries(S, modulweight, 0, wdegree,
Q, tailRing);
1378 intvec *hseries1=
hSeries(S, modulweight, 1, wdegree,
Q, tailRing);
1388 if (hseries1 ==
NULL)
1390 work =
new intvec(hseries1);
1393 for (
i =
k-1;
i >= 0;
i--)
1397 if ((
s != 0) || (
k == 1))
1402 for (
i =
k-1;
i >= 0;
i--)
1411 for (
i =
k-1;
i >= 0;
i--)
1412 (*hseries2)[
i] = (*work)[
i];
1413 (*hseries2)[
k] = (*work)[
l];
1430 for(
k=
j-2;
k>=0;
k--)
1439 if (hseries ==
NULL)
1443 if ((modul_weight!=
NULL)&&(modul_weight->
compare(0)!=0))
1446 Print(
"module weights:%s\n",
s);
1449 for (
i = 0;
i <
l;
i++)
1471 const int l = hseries1->
length()-1;
1480 if ((
l == 1) &&(
mu == 0))
1508 while ((
j >= 0) && (I->m[
j] ==
NULL))
1537 if(JCount != ObCount)
1542 for(
i = 0;
i < JCount;
i++)
1593 if(JCount != ObCount)
1603 for(
i = 0;
i< JCount;
i++)
1627 int orbCount = idorb.size();
1653 for(
i = 1;
i < orbCount;
i++)
1674 dtrp = trInd - degp;
1703 int OrbCount = idorb.size();
1710 for(
i = 1;
i < OrbCount;
i++)
1735 int OrbCount = idorb.size();
1736 int dtr=0;
int IwCount, ObCount;
1741 for(
i = 1;
i < OrbCount;
i++)
1764 for(
i = 1;
i < OrbCount;
i++)
1777 for(
i = 1;
i < OrbCount;
i++)
1832 for(
k = ICount - 1;
k >=1;
k--)
1834 for(
i = 0;
i <
k;
i++)
1856 poly smon =
p_One(r);
1860 int *e=(
int *)
omAlloc((r->N+1)*
sizeof(int));
1861 int *
s=(
int *)
omAlloc0((r->N+1)*
sizeof(int));
1864 for(
j = 1;
j <= cnt;
j++)
1891 int *e = (
int *)
omAlloc((r->N+1)*
sizeof(int));
1892 int *
s=(
int *)
omAlloc0((r->N+1)*
sizeof(int));
1901 for(
j = (cnt+1);
j < (r->N+1);
j++)
1916static void TwordMap(poly
p, poly
w,
int lV,
int d, ideal Jwi,
bool &flag)
1932 for(
i = 0;
i <= d - 1;
i++)
1977static ideal
colonIdeal(ideal S, poly
w,
int lV, ideal Jwi,
int trunDegHs)
1992 if(trunDegHs !=0 && d >= trunDegHs)
1999 for(
i = 0;
i < SCount;
i++)
2035 PrintS(
"Hilbert Series:\n 0\n");
2038 int (*POS)(ideal, poly, std::vector<ideal>, std::vector<poly>, int, int);
2041 Print(
"\nTruncation degree = %d\n",trunDegHs);
2050 WerrorS(
"wrong input: it is not an infinitely gen. case");
2059 std::vector<ideal > idorb;
2060 std::vector< poly > polist;
2062 ideal orb_init =
idInit(1, 1);
2063 idorb.push_back(orb_init);
2067 std::vector< std::vector<int> > posMat;
2068 std::vector<int> posRow(lV,0);
2072 unsigned long lpcnt = 0;
2077 while(lpcnt < idorb.size())
2081 if(lpcnt >= 1 &&
idIs0(idorb[lpcnt]) ==
FALSE)
2098 for(is = 1; is <= lV; is++)
2119 ps = (*POS)(Jwi, wi, idorb, polist, trInd, trunDegHs);
2123 posRow[is-1] = idorb.size();
2125 idorb.push_back(Jwi);
2126 polist.push_back(wi);
2135 posMat.push_back(posRow);
2136 posRow.resize(lV,0);
2141 Print(
"\nlength of the Orbit = %d", lO);
2146 Print(
"words description of the Orbit: \n");
2147 for(is = 0; is < lO; is++)
2153 PrintS(
"\nmaximal degree, #(sum_j R(w,w_j))");
2155 for(is = 0; is < lO; is++)
2157 if(
idIs0(idorb[is]))
2168 for(is = idorb.size()-1; is >= 0; is--)
2172 for(is = polist.size()-1; is >= 0; is--)
2180 int adjMatrix[lO][lO];
2181 memset(adjMatrix, 0, lO*lO*
sizeof(
int));
2182 int rowCount, colCount;
2186 for(rowCount = 0; rowCount < lO; rowCount++)
2188 for(colCount = 0; colCount < lV; colCount++)
2190 tm = posMat[rowCount][colCount];
2191 adjMatrix[rowCount][tm] = adjMatrix[rowCount][tm] + 1;
2202 tt=(
char**)
omAlloc(
sizeof(
char*));
2208 tt=(
char**)
omalloc(lV*
sizeof(
char*));
2209 for(is = 0; is < lV; is++)
2211 tt[is] = (
char*)
omAlloc(7*
sizeof(
char));
2212 sprintf (tt[is],
"t%d", is+1);
2219 char** xx = (
char**)
omAlloc(
sizeof(
char*));
2232 for(rowCount = 0; rowCount < lO; rowCount++)
2234 for(colCount = 0; colCount < lO; colCount++)
2236 if(adjMatrix[rowCount][colCount] != 0)
2238 MATELEM(mR, rowCount + 1, colCount + 1) =
p_ISet(adjMatrix[rowCount][colCount],
R);
2246 for(rowCount = 0; rowCount < lO; rowCount++)
2248 for(colCount = 0; colCount < lV; colCount++)
2253 MATELEM(mR, rowCount +1, posMat[rowCount][colCount]+1)=
p_Add_q(rc,
MATELEM(mR, rowCount +1, posMat[rowCount][colCount]+1),
R);
2258 for(rowCount = 0; rowCount < lO; rowCount++)
2260 if(C[rowCount] != 0)
2274 PrintS(
"\nlinear system:\n");
2277 for(rowCount = 0; rowCount < lO; rowCount++)
2279 Print(
"H(%d) = ", rowCount+1);
2280 for(colCount = 0; colCount < lV; colCount++)
2285 Print(
"H(%d) + ", posMat[rowCount][colCount] + 1);
2287 Print(
" %d\n", C[rowCount] );
2289 PrintS(
"where H(1) represents the series corresp. to input ideal\n");
2290 PrintS(
"and i^th summand in the rhs of an eqn. is according\n");
2291 PrintS(
"to the right colon map corresp. to the i^th variable\n");
2295 for(rowCount = 0; rowCount < lO; rowCount++)
2297 Print(
"H(%d) = ", rowCount+1);
2298 for(colCount = 0; colCount < lV; colCount++)
2303 Print(
"H(%d) + ", posMat[rowCount][colCount] + 1);
2305 Print(
" %d\n", C[rowCount] );
2307 PrintS(
"where H(1) represents the series corresp. to input ideal\n");
2339 Print(
"Hilbert series:");
2348 for(is = lV-1; is >= 0; is--)
const CanonicalForm CFMap CFMap & N
void mu(int **points, int sizePoints)
int compare(const intvec *o) const
char * ivString(int not_mat=1, int spaces=0, int dim=2) const
Coefficient rings, fields and other domains suitable for Singular polynomials.
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of 'a' and 'b', i.e., a*b
static FORCE_INLINE number n_Param(const int iParameter, const coeffs r)
return the (iParameter^th) parameter as a NEW number NOTE: parameter numbering: 1....
@ n_transExt
used for all transcendental extensions, i.e., the top-most extension in an extension tower is transce...
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
const CanonicalForm int s
const CanonicalForm int const CFList const Variable & y
void WerrorS(const char *s)
void scPrintDegree(int co, int mu)
static void idInsertMonomial(ideal I, poly p)
static int comapreMonoIdBases_IG_Case(ideal J, int JCount, ideal Ob, int ObCount)
intvec * hHstdSeries(ideal S, intvec *modulweight, intvec *wdegree, ideal Q, ring tailRing)
static poly SqFree(ideal I)
static void idAddMon(ideal I, ideal p)
static int comapreMonoIdBases(ideal J, ideal Ob)
static void TwordMap(poly p, poly w, int lV, int d, ideal Jwi, bool &flag)
static poly ChooseP(ideal I)
static poly deleteInMon(poly w, int i, int lV, const ring r)
intvec * hSecondSeries(intvec *hseries1)
static void hLastHilb(scmon pure, int Nv, varset var, int64 *pol, int lp)
static int CountOnIdUptoTruncationIndex(ideal I, int tr)
static poly ChoosePJL(ideal I)
static int monCompare(const void *m, const void *n)
static void hHilbEst(scfmon stc, int Nstc, varset var, int Nvar)
static void hPrintHilb(intvec *hseries, intvec *modul_weight)
static int positionInOrbitTruncationCase(ideal I, poly w, std::vector< ideal > idorb, std::vector< poly > polist, int, int trunDegHs)
static poly LCMmon(ideal I)
void HilbertSeries_OrbitData(ideal S, int lV, bool IG_CASE, bool mgrad, bool odp, int trunDegHs)
void hLookSeries(ideal S, intvec *modulweight, ideal Q, intvec *wdegree, ring tailRing)
static ideal colonIdeal(ideal S, poly w, int lV, ideal Jwi, int trunDegHs)
static int hMinModulweight(intvec *modulweight)
static poly shiftInMon(poly p, int i, int lV, const ring r)
intvec * hFirstSeries(ideal S, intvec *modulweight, ideal Q, intvec *wdegree, ring tailRing)
static intvec * hSeries(ideal S, intvec *modulweight, int, intvec *wdegree, ideal Q, ring tailRing)
static poly ChoosePVar(ideal I)
static int positionInOrbit_FG_Case(ideal I, poly, std::vector< ideal > idorb, std::vector< poly >, int, int)
static ideal SortByDeg(ideal I)
static bool IsIn(poly p, ideal I)
static void eulerchar(ideal I, int variables, mpz_ptr ec)
ideal RightColonOperation(ideal S, poly w, int lV)
static void hHilbStep(scmon pure, scfmon stc, int Nstc, varset var, int Nvar, int64 *pol, int Lpol)
static void hWDegree(intvec *wdegree)
static int positionInOrbit_IG_Case(ideal I, poly w, std::vector< ideal > idorb, std::vector< poly > polist, int trInd, int)
void hDegreeSeries(intvec *s1, intvec *s2, int *co, int *mu)
static poly SearchP(ideal I)
searches for a monomial of degree d>=2 and divides it by a variable (result monomial of deg d-1)
static int64 * hAddHilb(int Nv, int x, int64 *pol, int *lp)
static ideal minimalMonomialGenSet(ideal I)
void sortMonoIdeal_pCompare(ideal I)
ideal idQuotMon(ideal Iorig, ideal p)
static void SortByDeg_p(ideal I, poly p)
!!!!!!!!!!!!!!!!!!!! Just for Monomial Ideals !!!!!!!!!!!!!!!!!!!!!!!!!!!!
static bool JustVar(ideal I)
void rouneslice(ideal I, ideal S, poly q, poly x, int &prune, int &moreprune, int &steps, int &NNN, mpz_ptr &hilbertcoef, int *&hilbpower)
void hComp(scfmon exist, int Nexist, int ak, scfmon stc, int *Nstc)
scfmon hInit(ideal S, ideal Q, int *Nexist, ring tailRing)
void hLex2S(scfmon rad, int e1, int a2, int e2, varset var, int Nvar, scfmon w)
void hKill(monf xmem, int Nvar)
void hElimS(scfmon stc, int *e1, int a2, int e2, varset var, int Nvar)
void hLexS(scfmon stc, int Nstc, varset var, int Nvar)
void hDelete(scfmon ev, int ev_length)
scfmon hGetmem(int lm, scfmon old, monp monmem)
void hPure(scfmon stc, int a, int *Nstc, varset var, int Nvar, scmon pure, int *Npure)
void hSupp(scfmon stc, int Nstc, varset var, int *Nvar)
void hStepS(scfmon stc, int Nstc, varset var, int Nvar, int *a, int *x)
void hStaircase(scfmon stc, int *Nstc, varset var, int Nvar)
void hOrdSupp(scfmon stc, int Nstc, varset var, int Nvar)
#define idDelete(H)
delete an ideal
BOOLEAN idInsertPoly(ideal h1, poly h2)
insert h2 into h1 (if h2 is not the zero polynomial) return TRUE iff h2 was indeed inserted
ideal id_Copy(ideal h1, const ring r)
copy an ideal
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
bool unitMatrix(const int n, matrix &unitMat, const ring R)
Creates a new matrix which is the (nxn) unit matrix, and returns true in case of success.
void luDecomp(const matrix aMat, matrix &pMat, matrix &lMat, matrix &uMat, const ring R)
LU-decomposition of a given (m x n)-matrix.
bool luSolveViaLUDecomp(const matrix pMat, const matrix lMat, const matrix uMat, const matrix bVec, matrix &xVec, matrix &H)
Solves the linear system A * x = b, where A is an (m x n)-matrix which is given by its LU-decompositi...
void mp_Delete(matrix *a, const ring r)
matrix mp_Sub(matrix a, matrix b, 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
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy
gmp_float exp(const gmp_float &a)
The main handler for Singular numbers which are suitable for Singular polynomials.
#define omFreeSize(addr, size)
#define omRealloc(addr, size)
poly p_ISet(long i, const ring r)
returns the poly representing the integer i
poly p_MDivide(poly a, poly b, const ring r)
int p_Compare(const poly a, const poly b, const ring R)
void pEnlargeSet(poly **p, int l, int increment)
static poly p_Add_q(poly p, poly q, const ring r)
#define p_LmEqual(p1, p2, r)
static void p_SetExpV(poly p, int *ev, const ring r)
static poly pp_Mult_mm(poly p, poly m, const ring r)
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
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
static void p_Setm(poly p, const ring r)
static number p_SetCoeff(poly p, number n, ring r)
static poly p_Head(const poly p, const ring r)
copy the (leading) term of p
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent @Note: the integer VarOffset encodes:
static BOOLEAN p_IsOne(const poly p, const ring R)
either poly(1) or gen(k)?!
static BOOLEAN p_LmDivisibleBy(poly a, poly b, const ring r)
static BOOLEAN p_DivisibleBy(poly a, poly b, const ring r)
static void p_Delete(poly *p, const ring r)
static void p_GetExpV(poly p, int *ev, const ring r)
static poly p_Copy(poly p, const ring r)
returns a copy of p
static long p_Totaldegree(poly p, const ring r)
void rChangeCurrRing(ring r)
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
#define pLmDivisibleBy(a, b)
like pDivisibleBy, except that it is assumed that a!=NULL, b!=NULL
static void pLmFree(poly p)
frees the space of the monomial m, assumes m != NULL coef is not freed, m is not advanced
#define pCopy(p)
return a copy of the poly
void StringSetS(const char *st)
void PrintS(const char *s)
ring rDefault(const coeffs cf, int N, char **n, int ord_size, rRingOrder_t *ord, int *block0, int *block1, int **wvhdl, unsigned long bitmask)
static short rVar(const ring r)
#define rVar(r) (r->N)
int status int void size_t count
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
ideal id_Mult(ideal h1, ideal h2, const ring R)
h1 * h2 one h_i must be an ideal (with at least one column) the other h_i may be a module (with no co...
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
#define id_TestTail(A, lR, tR)
struct for passing initialization parameters to naInitChar
void prune(Variable &alpha)