53 if(modulweight==
NULL)
return 0;
55 for(i=modulweight->
rows()-1;i!=0;i--)
68 for (i = Nvar; i>0; i--)
71 for (j = 0; j < Nstc; j++)
83 WerrorS(
"internal arrays too big");
86 p = (
int *)
omAlloc((
unsigned long)z *
sizeof(int));
90 memcpy(p,
Qpol[j],
Ql[j] *
sizeof(
int));
95 for (x =
Ql[j]; x < z; x++)
110 memcpy(pon, pol, l *
sizeof(
int));
113 for (i = x; i <
l; i++)
117 if ((t>=INT_MIN)&&(t<=INT_MAX)) pon[
i]=t;
120 for (i = l; i < ln; i++)
123 if ((t>=INT_MIN)&&(t<=INT_MAX)) pon[
i]=t;
129 for (i = l; i <
x; i++)
131 for (i = x; i < ln; i++)
132 pon[i] = -pol[i - x];
143 for (i = Nv; i>0; i--)
145 x = pure[var[i + 1]];
151 for (i = 0; i <
l; i++)
156 if ((t>=INT_MIN)&&(t<=INT_MAX)) pl[i+
j]=t;
163 for (i = 0; i <
l; i++)
168 if ((t>=INT_MIN)&&(t<=INT_MAX)) pl[i+
j]=t;
178 int Nvar,
int *pol,
int Lpol)
180 int iv = Nvar -1, ln, a, a0, a1,
b,
i;
193 hStepS(sn, Nstc, var, Nvar, &a, &x);
217 hStepS(sn, Nstc, var, Nvar, &a, &x);
218 hElimS(sn, &b, a0, a, var, iv);
220 hPure(sn, a0, &a1, var, iv, pn, &i);
226 pon =
hAddHilb(iv, x - x0, pol, &ln);
233 pon =
hAddHilb(iv, x - x0, pol, &ln);
267 static bool idDegSortTest(ideal I)
278 WerrorS(
"Ideal is not deg sorted!!");
365 for(j =
IDELEMS(I)-1; j>=i+1;j--)
376 for(j =
IDELEMS(I)-1; j>=i+2;j--)
398 for(i = 0; i<=
IDELEMS(I)-1;i++)
459 for(i = 0; i<=
IDELEMS(res)-1; i++)
487 for(j=
IDELEMS(I)-1;(j>=0)&&(flag);j--)
512 static poly ChoosePXL(ideal I)
516 for(i =
IDELEMS(I)-1; (i>=0) && (dummy == 0); i--)
518 for(j = 1; (j<=
currRing->N) && (dummy == 0); j++)
547 static poly ChoosePXF(ideal I)
551 for(i =0 ; (i<=
IDELEMS(I)-1) && (dummy == 0); i++)
553 for(j = 1; (j<=
currRing->N) && (dummy == 0); j++)
582 static poly ChoosePOL(ideal I)
614 static poly ChoosePOF(ideal I)
618 for(i = 0 ;i<=
IDELEMS(I)-1;i++)
646 static poly ChoosePVL(ideal I)
651 for(i =
IDELEMS(I)-1;(i>=0) && (flag);i--)
654 for(j=1;(j<=
currRing->N) && (flag);j++)
676 static poly ChoosePVF(ideal I)
681 for(i = 0;(i<=
IDELEMS(I)-1) && (flag);i++)
684 for(j=1;(j<=
currRing->N) && (flag);j++)
710 for(i =
IDELEMS(I)-1;(i>=0) && (flag);i--)
713 for(j=1;(j<=
currRing->N) && (flag);j++)
735 static poly ChoosePJF(ideal I)
740 for(i = 0;(i<=
IDELEMS(I)-1) && (flag);i++)
743 for(j=1;(j<=
currRing->N) && (flag);j++)
847 if((variables % 2) == 0)
848 mpz_set_ui(dummy, 1);
850 mpz_set_si(dummy, -1);
851 mpz_add(ec, ec, dummy);
864 int i,howmanyvarinp = 0;
872 eulerchar(Ip, variables-howmanyvarinp, ec);
884 poly notsqrfree =
NULL;
889 for(i=
IDELEMS(I)-1;(i>=0)&&(flag);i--)
891 for(j=1;(j<=
currRing->N)&&(flag);j++)
901 if(notsqrfree !=
NULL)
932 for(j = 1;(j<=
currRing->N) &&(flag);j++)
974 void rouneslice(ideal I, ideal S, poly q, poly
x,
int &
prune,
int &moreprune,
int &steps,
int &NNN, mpz_ptr &hilbertcoef,
int* &hilbpower)
1071 mpz_ptr ec_ptr = ec;
1076 hilbertcoef = (mpz_ptr)
omAlloc((NNN+1)*
sizeof(mpz_t));
1077 hilbpower = (
int*)
omAlloc((NNN+1)*
sizeof(int));
1078 mpz_init_set( &hilbertcoef[NNN], ec);
1085 for(i = 0;(i<NNN)&&(flag == FALSE)&&(p_Totaldegree(q,currRing)>=hilbpower[
i]);i++)
1090 mpz_add(&hilbertcoef[i],&hilbertcoef[i],ec_ptr);
1095 hilbertcoef = (mpz_ptr)
omRealloc(hilbertcoef, (NNN+1)*
sizeof(mpz_t));
1096 hilbpower = (
int*)
omRealloc(hilbpower, (NNN+1)*
sizeof(int));
1097 mpz_init(&hilbertcoef[NNN]);
1098 for(j = NNN; j>
i; j--)
1100 mpz_set(&hilbertcoef[j],&hilbertcoef[j-1]);
1101 hilbpower[
j] = hilbpower[j-1];
1103 mpz_set( &hilbertcoef[i], ec);
1121 rouneslice(Ip, Sp, pq, x, prune, moreprune, steps, NNN, hilbertcoef,hilbpower);
1134 int steps = 0,
prune = 0, moreprune = 0;
1135 mpz_ptr hilbertcoef;
1151 rouneslice(I,S,q,X->m[0],
prune, moreprune, steps, NNN, hilbertcoef, hilbpower);
1157 printf(
"\n// %8d t^0",1);
1158 for(i = 0; i<NNN; i++)
1160 if(mpz_sgn(&hilbertcoef[i])!=0)
1162 gmp_printf(
"\n// %8Zd t^%d",&hilbertcoef[i],hilbpower[i]);
1166 omFreeSize(hilbertcoef, (NNN)*
sizeof(mpz_t));
1173 int ,
intvec *wdegree, ideal
Q, ring tailRing)
1180 int i,
j,
k,
l, ii, mw;
1191 if (wdegree ==
NULL)
1226 if (modulweight !=
NULL)
1227 j = (*modulweight)[mc-1]-mw;
1232 for (i =
hNvar; i>=0; i--)
1262 while ((i > 0) && ((*Qpol)[i - 1] == 0))
1270 for (ii=0; ii<
k; ii++)
1271 (*work)[ii] = (*hseries1)[ii];
1272 if (hseries1 !=
NULL)
1279 (*hseries1)[i + j - 1] += (*Qpol)[i - 1];
1298 while ((*hseries1)[l-2]==0) l--;
1302 for (ii=l-2; ii>=0; ii--)
1303 (*work)[ii] = (*hseries1)[ii];
1307 (*hseries1)[l-1] = mw;
1309 for (i = 0; i <= (
currRing->N); i++)
1332 return hSeries(S, modulweight, 0, wdegree, Q, tailRing);
1340 intvec *hseries1=
hSeries(S, modulweight, 1, wdegree, Q, tailRing);
1350 if (hseries1 ==
NULL)
1352 work =
new intvec(hseries1);
1353 k = l = work->
length()-1;
1355 for (i = k-1; i >= 0; i--)
1359 if ((s != 0) || (k == 1))
1364 for (i = k-1; i >= 0; i--)
1372 hseries2 =
new intvec(k+1);
1373 for (i = k-1; i >= 0; i--)
1374 (*hseries2)[
i] = (*work)[
i];
1375 (*hseries2)[
k] = (*work)[
l];
1392 for(k=j-2; k>=0; k--)
1401 if (hseries ==
NULL)
1405 for (i = 0; i <
l; i++)
1410 Print(
"// %8d t^%d\n", j, i+k);
1427 const int l = hseries1->
length()-1;
1436 if ((l == 1) &&(mu == 0))
1464 while ((j >= 0) && (I->m[j] ==
NULL))
1493 if(JCount != ObCount)
1498 for(i = 0; i < JCount; i++)
1549 if(JCount != ObCount)
1559 for(i = 0; i< JCount; i++)
1583 int orbCount = idorb.size();
1609 for(i = 1;i < orbCount; i++)
1630 dtrp = trInd - degp;
1659 int OrbCount = idorb.size();
1666 for(i = 1; i < OrbCount; i++)
1691 int OrbCount = idorb.size();
1692 int dtr=0;
int IwCount, ObCount;
1697 for(i = 1; i < OrbCount; i++)
1720 for(i = 1; i < OrbCount; i++)
1733 for(i = 1; i < OrbCount; i++)
1788 for(k = ICount - 1; k >=1; k--)
1790 for(i = 0; i <
k; i++)
1812 poly smon =
p_One(r);
1816 int *e=(
int *)
omAlloc((r->N+1)*
sizeof(int));
1817 int *
s=(
int *)
omAlloc0((r->N+1)*
sizeof(int));
1820 for(j = 1; j <= cnt; j++)
1847 int *e = (
int *)
omAlloc((r->N+1)*
sizeof(int));
1848 int *
s=(
int *)
omAlloc0((r->N+1)*
sizeof(int));
1857 for(j = (cnt+1); j < (r->N+1); j++)
1872 static void TwordMap(poly
p, poly
w,
int lV,
int d, ideal Jwi,
bool &flag)
1888 for(i = 0;i <= d - 1; i++)
1933 static ideal
colonIdeal(ideal S, poly
w,
int lV, ideal Jwi,
int trunDegHs)
1948 if(trunDegHs !=0 && d >= trunDegHs)
1955 for(i = 0; i < SCount; i++)
1957 TwordMap(S->m[i], w, lV, d, Jwi, flag);
1984 PrintS(
"Hilbert Series:\n 0\n");
1987 int (*POS)(ideal, poly, std::vector<ideal>, std::vector<poly>, int, int);
1990 Print(
"\nTruncation degree = %d\n",trunDegHs);
1999 WerrorS(
"wrong input: it is not an infinitely gen. case");
2008 std::vector<ideal > idorb;
2009 std::vector< poly > polist;
2011 ideal orb_init =
idInit(1, 1);
2012 idorb.push_back(orb_init);
2016 std::vector< std::vector<int> > posMat;
2017 std::vector<int> posRow(lV,0);
2026 while(lpcnt < idorb.size())
2030 if(lpcnt >= 1 &&
idIs0(idorb[lpcnt]) ==
FALSE)
2047 for(is = 1; is <= lV; is++)
2068 ps = (*POS)(Jwi, wi, idorb, polist, trInd, trunDegHs);
2072 posRow[is-1] = idorb.size();
2074 idorb.push_back(Jwi);
2075 polist.push_back(wi);
2084 posMat.push_back(posRow);
2085 posRow.resize(lV,0);
2090 Print(
"\nlength of the Orbit = %d", lO);
2095 Print(
"words description of the Orbit: \n");
2096 for(is = 0; is < lO; is++)
2102 PrintS(
"\nmaximal degree, #(sum_j R(w,w_j))");
2104 for(is = 0; is < lO; is++)
2106 if(
idIs0(idorb[is]))
2117 for(is = idorb.size()-1; is >= 0; is--)
2121 for(is = polist.size()-1; is >= 0; is--)
2129 int adjMatrix[lO][lO];
2130 memset(adjMatrix, 0, lO*lO*
sizeof(
int));
2131 int rowCount, colCount;
2135 for(rowCount = 0; rowCount < lO; rowCount++)
2137 for(colCount = 0; colCount < lV; colCount++)
2139 tm = posMat[rowCount][colCount];
2140 adjMatrix[rowCount][tm] = adjMatrix[rowCount][tm] + 1;
2151 tt=(
char**)
omAlloc(
sizeof(
char*));
2157 tt=(
char**)
omalloc(lV*
sizeof(
char*));
2158 for(is = 0; is < lV; is++)
2160 tt[is] = (
char*)
omAlloc(7*
sizeof(
char));
2161 sprintf (tt[is],
"t%d", is+1);
2168 char** xx = (
char**)
omAlloc(
sizeof(
char*));
2181 for(rowCount = 0; rowCount < lO; rowCount++)
2183 for(colCount = 0; colCount < lO; colCount++)
2185 if(adjMatrix[rowCount][colCount] != 0)
2187 MATELEM(mR, rowCount + 1, colCount + 1) =
p_ISet(adjMatrix[rowCount][colCount], R);
2195 for(rowCount = 0; rowCount < lO; rowCount++)
2197 for(colCount = 0; colCount < lV; colCount++)
2202 MATELEM(mR, rowCount +1, posMat[rowCount][colCount]+1)=
p_Add_q(rc,
MATELEM(mR, rowCount +1, posMat[rowCount][colCount]+1), R);
2207 for(rowCount = 0; rowCount < lO; rowCount++)
2209 if(C[rowCount] != 0)
2223 PrintS(
"\nlinear system:\n");
2226 for(rowCount = 0; rowCount < lO; rowCount++)
2228 Print(
"H(%d) = ", rowCount+1);
2229 for(colCount = 0; colCount < lV; colCount++)
2234 Print(
"H(%d) + ", posMat[rowCount][colCount] + 1);
2236 Print(
" %d\n", C[rowCount] );
2238 PrintS(
"where H(1) represents the series corresp. to input ideal\n");
2239 PrintS(
"and i^th summand in the rhs of an eqn. is according\n");
2240 PrintS(
"to the right colon map corresp. to the i^th variable\n");
2244 for(rowCount = 0; rowCount < lO; rowCount++)
2246 Print(
"H(%d) = ", rowCount+1);
2247 for(colCount = 0; colCount < lV; colCount++)
2252 Print(
"H(%d) + ", posMat[rowCount][colCount] + 1);
2254 Print(
" %d\n", C[rowCount] );
2256 PrintS(
"where H(1) represents the series corresp. to input ideal\n");
2271 luDecomp(gMat, pMat, lMat, uMat, R);
2288 Print(
"Hilbert series:");
2297 for(is = lV-1; is >= 0; is--)
int status int void size_t count
ideal idQuotMon(ideal Iorig, ideal p)
void rouneslice(ideal I, ideal S, poly q, poly x, int &prune, int &moreprune, int &steps, int &NNN, mpz_ptr &hilbertcoef, int *&hilbpower)
#define id_TestTail(A, lR, tR)
const CanonicalForm int s
void hLexS(scfmon stc, int Nstc, varset var, int Nvar)
const CanonicalForm int const CFList const Variable & y
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...
static poly ChoosePVar(ideal I)
void mu(int **points, int sizePoints)
scfmon hGetmem(int lm, scfmon old, monp monmem)
void hElimS(scfmon stc, int *e1, int a2, int e2, varset var, int Nvar)
#define idDelete(H)
delete an ideal
gmp_float exp(const gmp_float &a)
void scPrintDegree(int co, int mu)
static void hHilbStep(scmon pure, scfmon stc, int Nstc, varset var, int Nvar, int *pol, int Lpol)
used for all transcendental extensions, i.e., the top-most extension in an extension tower is transce...
void HilbertSeries_OrbitData(ideal S, int lV, bool IG_CASE, bool mgrad, bool odp, int trunDegHs)
ideal id_Copy(ideal h1, const ring r)
copy an ideal
static int positionInOrbitTruncationCase(ideal I, poly w, std::vector< ideal > idorb, std::vector< poly > polist, int, int trunDegHs)
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
static void hLastHilb(scmon pure, int Nv, varset var, int *pol, int lp)
static ideal minimalMonomialGenSet(ideal I)
static void p_GetExpV(poly p, int *ev, const ring r)
#define omFreeSize(addr, size)
static void idAddMon(ideal I, ideal p)
static short rVar(const ring r)
#define rVar(r) (r->N)
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
static bool JustVar(ideal I)
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.
static bool IsIn(poly p, ideal I)
static poly pp_Mult_mm(poly p, poly m, const ring r)
static long p_Totaldegree(poly p, const ring r)
void hDegreeSeries(intvec *s1, intvec *s2, int *co, int *mu)
void WerrorS(const char *s)
static void TwordMap(poly p, poly w, int lV, int d, ideal Jwi, bool &flag)
#define pLmDivisibleBy(a, b)
like pDivisibleBy, except that it is assumed that a!=NULL, b!=NULL
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
static number p_SetCoeff(poly p, number n, ring r)
static poly LCMmon(ideal I)
intvec * hHstdSeries(ideal S, intvec *modulweight, intvec *wdegree, ideal Q, ring tailRing)
static void p_SetExpV(poly p, int *ev, const ring r)
static poly p_Copy(poly p, const ring r)
returns a copy of p
void prune(Variable &alpha)
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_NumberOfParameters(...)
void hDelete(scfmon ev, int ev_length)
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of 'a' and 'b', i.e., a*b
void luDecomp(const matrix aMat, matrix &pMat, matrix &lMat, matrix &uMat, const ring R)
LU-decomposition of a given (m x n)-matrix.
static poly p_Head(poly p, const ring r)
Coefficient rings, fields and other domains suitable for Singular polynomials.
void hOrdSupp(scfmon stc, int Nstc, varset var, int Nvar)
const CanonicalForm CFMap CFMap & N
void hKill(monf xmem, int Nvar)
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent : the integer VarOffset encodes:
static poly ChoosePJL(ideal I)
static int * hAddHilb(int Nv, int x, int *pol, int *lp)
The main handler for Singular numbers which are suitable for Singular polynomials.
static void hWDegree(intvec *wdegree)
void StringSetS(const char *st)
static int positionInOrbit_FG_Case(ideal I, poly, std::vector< ideal > idorb, std::vector< poly >, int, int)
void hPure(scfmon stc, int a, int *Nstc, varset var, int Nvar, scmon pure, int *Npure)
static int positionInOrbit_IG_Case(ideal I, poly w, std::vector< ideal > idorb, std::vector< poly > polist, int trInd, int trunDegHs)
void hStaircase(scfmon stc, int *Nstc, varset var, int Nvar)
void sortMonoIdeal_pCompare(ideal I)
static BOOLEAN p_DivisibleBy(poly a, poly b, const ring r)
BOOLEAN idInsertPoly(ideal h1, poly h2)
insert h2 into h1 (if h2 is not the zero polynomial) return TRUE iff h2 was indeed inserted ...
static int comapreMonoIdBases(ideal J, ideal Ob)
static intvec * hSeries(ideal S, intvec *modulweight, int, intvec *wdegree, ideal Q, ring tailRing)
struct for passing initialization parameters to naInitChar
int p_Compare(const poly a, const poly b, const ring R)
static BOOLEAN p_IsOne(const poly p, const ring R)
either poly(1) or gen(k)?!
void hLex2S(scfmon rad, int e1, int a2, int e2, varset var, int Nvar, scfmon w)
void PrintS(const char *s)
static void SortByDeg_p(ideal I, poly p)
!!!!!!!!!!!!!!!!!!!! Just for Monomial Ideals !!!!!!!!!!!!!!!!!!!!!!!!!!!!
static BOOLEAN p_LmDivisibleBy(poly a, poly b, const ring r)
void mp_Delete(matrix *a, const ring r)
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
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 int monCompare(const void *m, const void *n)
void rChangeCurrRing(ring r)
matrix mpNew(int r, int c)
create a r x c zero-matrix
static int CountOnIdUptoTruncationIndex(ideal I, int tr)
static void p_Delete(poly *p, const ring r)
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...
ideal idInit(int idsize, int rank)
initialise an ideal / module
#define p_LmEqual(p1, p2, r)
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent : VarOffset encodes the position in p->exp
ideal RightColonOperation(ideal S, poly w, int lV)
static ideal SortByDeg(ideal I)
void pEnlargeSet(poly **p, int l, int increment)
void hStepS(scfmon stc, int Nstc, varset var, int Nvar, int *a, int *x)
intvec * hSecondSeries(intvec *hseries1)
static poly shiftInMon(poly p, int i, int lV, const ring r)
ideal id_Head(ideal h, const ring r)
returns the ideals of initial terms
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
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 void p_Setm(poly p, const ring r)
static void pLmFree(poly p)
frees the space of the monomial m, assumes m != NULL coef is not freed, m is not advanced ...
poly p_MDivide(poly a, poly b, const ring r)
static poly ChooseP(ideal I)
intvec * hFirstSeries(ideal S, intvec *modulweight, ideal Q, intvec *wdegree, ring tailRing)
matrix mp_Sub(matrix a, matrix b, const ring R)
void hLookSeries(ideal S, intvec *modulweight, ideal Q, intvec *wdegree, ring tailRing)
static poly p_Add_q(poly p, poly q, const ring r)
static int hMinModulweight(intvec *modulweight)
static int comapreMonoIdBases_IG_Case(ideal J, int JCount, ideal Ob, int ObCount)
static ideal colonIdeal(ideal S, poly w, int lV, ideal Jwi, int trunDegHs)
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
#define omRealloc(addr, size)
void hComp(scfmon exist, int Nexist, int ak, scfmon stc, int *Nstc)
static poly SqFree(ideal I)
poly p_ISet(long i, const ring r)
returns the poly representing the integer i
scfmon hInit(ideal S, ideal Q, int *Nexist, ring tailRing)
static poly deleteInMon(poly w, int i, int lV, const ring r)
static void idInsertMonomial(ideal I, poly p)
static void hHilbEst(scfmon stc, int Nstc, varset var, int Nvar)
#define pCopy(p)
return a copy of the poly
#define MATELEM(mat, i, j)
1-based access to matrix
static void hPrintHilb(intvec *hseries)
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
void hSupp(scfmon stc, int Nstc, varset var, int *Nvar)
static void eulerchar(ideal I, int variables, mpz_ptr ec)