52 if(modulweight==
NULL)
return 0;
54 for(i=modulweight->
rows()-1;i!=0;i--)
67 for (i = Nvar; i>0; i--)
70 for (j = 0; j < Nstc; j++)
82 WerrorS(
"internal arrays too big");
85 p = (
int *)
omAlloc((
unsigned long)z *
sizeof(int));
89 memcpy(p,
Qpol[j],
Ql[j] *
sizeof(
int));
94 for (x =
Ql[j]; x < z; x++)
109 memcpy(pon, pol, l *
sizeof(
int));
112 for (i = x; i <
l; i++)
113 pon[i] -= pol[i - x];
114 for (i = l; i < ln; i++)
115 pon[i] = -pol[i - x];
119 for (i = l; i <
x; i++)
121 for (i = x; i < ln; i++)
122 pon[i] = -pol[i - x];
132 for (i = Nv; i>0; i--)
134 x = pure[var[i + 1]];
140 for (i = 0; i <
l; i++)
146 for (i = 0; i <
l; i++)
155 int Nvar,
int *pol,
int Lpol)
157 int iv = Nvar -1, ln,
a, a0, a1,
b,
i;
170 hStepS(sn, Nstc, var, Nvar, &a, &x);
194 hStepS(sn, Nstc, var, Nvar, &a, &x);
195 hElimS(sn, &b, a0, a, var, iv);
197 hPure(sn, a0, &a1, var, iv, pn, &i);
203 pon =
hAddHilb(iv, x - x0, pol, &ln);
210 pon =
hAddHilb(iv, x - x0, pol, &ln);
244 static bool idDegSortTest(ideal I)
255 WerrorS(
"Ideal is not deg sorted!!");
342 for(j =
IDELEMS(I)-1; j>=i+1;j--)
353 for(j =
IDELEMS(I)-1; j>=i+2;j--)
376 for(i = 0; i<=
IDELEMS(I)-1;i++)
436 for(i = 0; i<=
IDELEMS(res)-1; i++)
466 for(j=
IDELEMS(I)-1;(j>=0)&&(flag);j--)
491 static poly ChoosePXL(ideal I)
495 for(i =
IDELEMS(I)-1; (i>=0) && (dummy == 0); i--)
497 for(j = 1; (j<=
currRing->N) && (dummy == 0); j++)
526 static poly ChoosePXF(ideal I)
530 for(i =0 ; (i<=
IDELEMS(I)-1) && (dummy == 0); i++)
532 for(j = 1; (j<=
currRing->N) && (dummy == 0); j++)
561 static poly ChoosePOL(ideal I)
593 static poly ChoosePOF(ideal I)
597 for(i = 0 ;i<=
IDELEMS(I)-1;i++)
625 static poly ChoosePVL(ideal I)
630 for(i =
IDELEMS(I)-1;(i>=0) && (flag);i--)
633 for(j=1;(j<=
currRing->N) && (flag);j++)
655 static poly ChoosePVF(ideal I)
660 for(i = 0;(i<=
IDELEMS(I)-1) && (flag);i++)
663 for(j=1;(j<=
currRing->N) && (flag);j++)
689 for(i =
IDELEMS(I)-1;(i>=0) && (flag);i--)
692 for(j=1;(j<=
currRing->N) && (flag);j++)
713 static poly ChoosePJF(ideal I)
718 for(i = 0;(i<=
IDELEMS(I)-1) && (flag);i++)
721 for(j=1;(j<=
currRing->N) && (flag);j++)
825 if((variables % 2) == 0)
826 {mpz_set_si(dummy, 1);}
828 {mpz_set_si(dummy, -1);}
829 mpz_add(ec, ec, dummy);
842 int i,howmanyvarinp = 0;
850 eulerchar(Ip, variables-howmanyvarinp, ec);
866 for(i=
IDELEMS(I)-1;(i>=0)&&(flag);i--)
868 for(j=1;(j<=
currRing->N)&&(flag);j++)
878 if(notsqrfree !=
NULL)
909 for(j = 1;(j<=
currRing->N) &&(flag);j++)
951 void rouneslice(ideal I, ideal S,
poly q,
poly x,
int &
prune,
int &moreprune,
int &steps,
int &NNN, mpz_ptr &hilbertcoef,
int* &hilbpower)
1046 mpz_ptr ec_ptr = ec;
1051 hilbertcoef = (mpz_ptr)
omAlloc((NNN+1)*
sizeof(mpz_t));
1052 hilbpower = (
int*)
omAlloc((NNN+1)*
sizeof(int));
1053 mpz_init( &hilbertcoef[NNN]);
1054 mpz_set( &hilbertcoef[NNN], ec);
1062 for(i = 0;(i<NNN)&&(flag == FALSE)&&(p_Totaldegree(q,currRing)>=hilbpower[
i]);i++)
1067 mpz_add(&hilbertcoef[i],&hilbertcoef[i],ec_ptr);
1072 hilbertcoef = (mpz_ptr)
omRealloc(hilbertcoef, (NNN+1)*
sizeof(mpz_t));
1073 hilbpower = (
int*)
omRealloc(hilbpower, (NNN+1)*
sizeof(int));
1074 mpz_init(&hilbertcoef[NNN]);
1075 for(j = NNN; j>
i; j--)
1077 mpz_set(&hilbertcoef[j],&hilbertcoef[j-1]);
1078 hilbpower[
j] = hilbpower[j-1];
1080 mpz_set( &hilbertcoef[i], ec);
1094 rouneslice(Ip, Sp, pq, x, prune, moreprune, steps, NNN, hilbertcoef,hilbpower);
1109 int steps = 0,
prune = 0, moreprune = 0;
1110 mpz_ptr hilbertcoef;
1124 rouneslice(I,S,q,X->m[0],
prune, moreprune, steps, NNN, hilbertcoef, hilbpower);
1132 printf(
"\n// %8d t^0",1);
1133 for(i = 0; i<NNN; i++)
1135 if(mpz_sgn(&hilbertcoef[i])!=0)
1137 gmp_printf(
"\n// %8Zd t^%d",&hilbertcoef[i],hilbpower[i]);
1140 omFreeSize(hilbertcoef, (NNN)*
sizeof(mpz_t));
1154 int i,
j,
k,
l, ii, mw;
1165 if (wdegree ==
NULL)
1200 if (modulweight !=
NULL)
1201 j = (*modulweight)[mc-1]-mw;
1206 for (i =
hNvar; i>=0; i--)
1236 while ((i > 0) && ((*Qpol)[i - 1] == 0))
1244 for (ii=0; ii<
k; ii++)
1245 (*work)[ii] = (*hseries1)[ii];
1246 if (hseries1 !=
NULL)
1253 (*hseries1)[i + j - 1] += (*Qpol)[i - 1];
1272 while ((*hseries1)[l-2]==0) l--;
1276 for (ii=l-2; ii>=0; ii--)
1277 (*work)[ii] = (*hseries1)[ii];
1281 (*hseries1)[l-1] = mw;
1283 for (i = 0; i <= (
currRing->N); i++)
1306 return hSeries(S, modulweight, 0, wdegree, Q, tailRing);
1314 return hSeries(S, modulweight, 1, wdegree, Q, tailRing);
1320 int i,
j,
k,
s, t,
l;
1321 if (hseries1 ==
NULL)
1323 work =
new intvec(hseries1);
1324 k = l = work->
length()-1;
1326 for (i = k-1; i >= 0; i--)
1330 if ((s != 0) || (k == 1))
1335 for (i = k-1; i >= 0; i--)
1343 hseries2 =
new intvec(k+1);
1344 for (i = k-1; i >= 0; i--)
1345 (*hseries2)[
i] = (*work)[
i];
1346 (*hseries2)[
k] = (*work)[
l];
1362 for(k=j-2; k>=0; k--)
1371 if (hseries ==
NULL)
1375 for (i = 0; i <
l; i++)
1380 Print(
"// %8d t^%d\n", j, i+k);
1396 const int l = hseries1->
length()-1;
1405 if ((l == 1) &&(mu == 0))
1433 while ((j >= 0) && (I->m[j] ==
NULL))
1462 if(JCount != ObCount)
1467 for(i = 0; i < JCount; i++)
1521 if(JCount != ObCount)
1526 for(i = 0; i< JCount; i++)
1551 int orbCount = idorb.size();
1577 for(i = 1;i < orbCount; i++)
1598 dtrp = trInd - degp;
1628 int OrbCount = idorb.size();
1635 for(i = 1; i < OrbCount; i++)
1683 for(k = ICount - 1; k >=1; k--)
1685 for(i = 0; i <
k; i++)
1711 int *e=(
int *)
omAlloc((r->N+1)*
sizeof(int));
1712 int *
s=(
int *)
omAlloc0((r->N+1)*
sizeof(int));
1715 for(j = 1; j <= cnt; j++)
1742 int *e = (
int *)
omAlloc((r->N+1)*
sizeof(int));
1743 int *
s=(
int *)
omAlloc0((r->N+1)*
sizeof(int));
1752 for(j = (cnt+1); j < (r->N+1); j++)
1783 for(i = 0;i <= d - 1; i++)
1848 for(i = 0; i < SCount; i++)
1850 TwordMap(S->m[i], w, lV, d, Jwi, flag);
1876 int (*POS)(ideal,
poly, std::vector<ideal>, std::vector<poly>, int);
1881 WerrorS(
"wrong input:not the infinitely gen. case");
1892 std::vector<ideal > idorb;
1893 std::vector< poly > polist;
1895 ideal orb_init =
idInit(1, 1);
1896 idorb.push_back(orb_init);
1900 std::vector< std::vector<int> > posMat;
1901 std::vector<int> posRow(lV,0);
1910 while(lpcnt < idorb.size())
1930 for(is = 1; is <= lV; is++)
1949 ps = (*POS)(Jwi, wi, idorb, polist, trInd);
1953 posRow[is-1] = idorb.size();
1955 idorb.push_back(Jwi);
1956 polist.push_back(wi);
1965 posMat.push_back(posRow);
1966 posRow.resize(lV,0);
1971 Print(
"\nOrbit length = %d\n", lO);
1976 Print(
"Words description of the Orbit: \n");
1977 for(is = 0; is < lO; is++)
1985 for(is = idorb.size()-1; is >= 0; is--)
1989 for(is = polist.size()-1; is >= 0; is--)
1997 int adjMatrix[lO][lO];
1998 memset(adjMatrix, 0, lO*lO*
sizeof(
int));
1999 int rowCount, colCount;
2003 for(rowCount = 0; rowCount < lO; rowCount++)
2005 for(colCount = 0; colCount < lV; colCount++)
2007 tm = posMat[rowCount][colCount];
2008 adjMatrix[rowCount][tm] = adjMatrix[rowCount][tm] + 1;
2019 tt=(
char**)
omalloc(
sizeof(
char*));
2025 tt=(
char**)
omalloc(lV*
sizeof(
char*));
2026 for(is = 0; is < lV; is++)
2028 tt[is] = (
char*)
omalloc(7*
sizeof(
char));
2029 sprintf (tt[is],
"t(%d)", is+1);
2036 char** xx = (
char**)
omalloc(
sizeof(
char*));
2049 for(rowCount = 0; rowCount < lO; rowCount++)
2051 for(colCount = 0; colCount < lO; colCount++)
2053 if(adjMatrix[rowCount][colCount] != 0)
2055 MATELEM(mR, rowCount + 1, colCount + 1) =
p_ISet(adjMatrix[rowCount][colCount], R);
2063 for(rowCount = 0; rowCount < lO; rowCount++)
2065 for(colCount = 0; colCount < lV; colCount++)
2070 MATELEM(mR, rowCount +1, posMat[rowCount][colCount]+1)=
p_Add_q(rc,
MATELEM(mR, rowCount +1, posMat[rowCount][colCount]+1), R);
2075 for(rowCount = 0; rowCount < lO; rowCount++)
2077 if(C[rowCount] != 0)
2089 PrintS(
"\nlinear system:\n");
2092 for(rowCount = 0; rowCount < lO; rowCount++)
2094 Print(
"H(%d) = ", rowCount+1);
2095 for(colCount = 0; colCount < lV; colCount++)
2100 Print(
"H(%d) + ", posMat[rowCount][colCount] + 1);
2102 Print(
" %d\n", C[rowCount] );
2104 PrintS(
"where H(1) represents the series corresp. to input ideal\n");
2105 PrintS(
"and i^th summand in the rhs of an eqn. is according\n");
2106 PrintS(
"to the right colon map corresp. to the i^th variable\n");
2110 for(rowCount = 0; rowCount < lO; rowCount++)
2112 Print(
"H(%d) = ", rowCount+1);
2113 for(colCount = 0; colCount < lV; colCount++)
2118 Print(
"H(%d) + ", posMat[rowCount][colCount] + 1);
2120 Print(
" %d\n", C[rowCount] );
2122 PrintS(
"where H(1) represents the series corresp. to input ideal\n");
2130 luDecomp(gMat, pMat, lMat, uMat, R);
2145 Print(
"Hilbert series:");
2155 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 int positionInOrbit_FG_Case(ideal I, poly, std::vector< ideal > idorb, std::vector< poly >, int)
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
void scPrintDegree(int co, int mu)
static void hHilbStep(scmon pure, scfmon stc, int Nstc, varset var, int Nvar, int *pol, int Lpol)
static int isMonoIdBasesSame(ideal J, ideal Ob)
used for all transcendental extensions, i.e., the top-most extension in an extension tower is transce...
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)
BEGIN_NAMESPACE_SINGULARXX const ring const ring tailRing
static void p_GetExpV(poly p, int *ev, const ring r)
#define omFreeSize(addr, size)
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)
void HilbertSeries_OrbitData(ideal S, int lV, bool IG_CASE, bool mgrad, bool odp)
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 ideal idAddMon(ideal I, ideal p)
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 int positionInOrbit_IG_Case(ideal I, poly w, std::vector< ideal > idorb, std::vector< poly > polist, int trInd)
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
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
void luDecomp(const matrix aMat, matrix &pMat, matrix &lMat, matrix &uMat, const ring R)
LU-decomposition of a given (m x n)-matrix.
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)
void hPure(scfmon stc, int a, int *Nstc, varset var, int Nvar, scmon pure, int *Npure)
static ideal minimalMonomialsGenSet(ideal I)
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 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)
poly p_Divide(poly a, poly b, const ring r)
static int isMonoIdBasesSame_IG_Case(ideal J, int JCount, ideal Ob, int ObCount)
ring rDefault(const coeffs cf, int N, char **n, int ord_size, rRingOrder_t *ord, int *block0, int *block1, int **wvhdl)
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
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)
static ideal colonIdeal(ideal S, poly w, int lV, ideal Jwi)
static void idInsertMonomials(ideal I, poly p)
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
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)
ideal id_Add(ideal h1, ideal h2, const ring r)
h1 + h2
intvec * hSecondSeries(intvec *hseries1)
static poly shiftInMon(poly p, int i, int lV, const ring r)
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 ideal SortByDeg_p(ideal I, poly p)
!!!!!!!!!!!!!!!!!!!! Just for Monomial Ideals !!!!!!!!!!!!!!!!!!!!!!!!!!!!
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)
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 hHilbEst(scfmon stc, int Nstc, varset var, int Nvar)
#define pCopy(p)
return a copy of the poly
#define MATELEM(mat, i, j)
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)