66 Print(
"Module of rank %ld,real rank %ld and %d generators.\n",
69 int j = (
id->ncols*
id->nrows) - 1;
70 while ((j > 0) && (
id->m[
j]==
NULL)) j--;
71 for (
int i = 0;
i <=
j;
i++)
85 const poly *
m =
id->m +
N;
87 for (
int k = N;
k >= 0; --
k, --
m)
107 for (l=0; l<
rVar(r); l++)
124 elems=j=(*h)->nrows*(*h)->ncols;
149 elems=j=(*h)->nrows*(*h)->ncols;
173 if (ide->m[k] !=
NULL)
178 ide->m[
j] = ide->m[
k];
192 for (k=j+1; k<
IDELEMS(ide); k++)
206 if ((F->m)[
j]!=
NULL) i++;
220 for (
int i = 0;
i <
k;
i++)
233 if (id->m[
i] !=
NULL)
312 if (id->m[i] !=
NULL)
316 if ((id->m[j] !=
NULL)
340 if (id->m[i] !=
NULL)
387 for (k =
IDELEMS(
id)-1; k>=0; k--)
412 for (i=
IDELEMS(h1)-1; i>=0; i--)
413 h2->m[i] =
p_Copy(h1->m[i],r);
430 for (i=(h1->ncols*h1->nrows)-1; i>=0; i--)
431 _pp_Test(h1->m[i], r, tailRing, level);
434 if(new_rk > h1->rank)
437 h1->rank, new_rk, f,l);
448 if (b==
NULL)
return 1;
449 if (a==
NULL)
return -1;
483 int i,
j, actpos=0, newpos;
484 int diff, olddiff, lastcomp, newcomp;
493 diff = (actpos+1) / 2;
495 lastcomp =
p_Comp_RevLex(id->m[i],id->m[(*result)[newpos]],nolex,r);
509 while (notFound && (newpos>=0) && (newpos<actpos))
511 newcomp =
p_Comp_RevLex(id->m[i],id->m[(*result)[newpos]],nolex,r);
519 && (newpos+diff>=actpos))
521 diff = actpos-newpos-1;
523 else if ((newcomp==-1)
532 if ((olddiff==1) && (lastcomp>0))
539 if ((olddiff==1) && (lastcomp<0))
554 if (diff==0) notFound=
FALSE;
556 if (newpos<0) newpos = 0;
557 if (newpos>actpos) newpos = actpos;
558 while ((newpos<actpos) && (
p_Comp_RevLex(id->m[i],id->m[(*result)[newpos]],nolex,r)==0))
560 for (j=actpos;j>newpos;j--)
562 (*result)[
j] = (*result)[j-1];
564 (*result)[newpos] =
i;
568 for (j=0;j<actpos;j++) (*result)[
j]++;
583 while ((j >= 0) && (h1->m[j] ==
NULL)) j--;
585 while ((i >= 0) && (h2->m[i] ==
NULL)) i--;
586 r =
si_max(h1->rank,h2->rank);
593 result->m[
l] =
p_Copy(h1->m[l],R);
596 for (l=i; l>=0; l--, r--)
598 result->m[
r] =
p_Copy(h2->m[l],R);
611 while ((j >= 0) && (h1->m[j] ==
NULL)) j--;
630 const poly h2,
const bool zeroOk,
const bool duplicateOk,
const ring
r)
632 if ((!zeroOk) && (h2 ==
NULL))
return FALSE;
635 bool h2FoundInH1 =
false;
637 while ((i < validEntries) && (!h2FoundInH1))
642 if (h2FoundInH1)
return FALSE;
644 if (validEntries ==
IDELEMS(h1))
649 h1->m[validEntries] = h2;
672 while ((j > 0) && (h1->m[j-1] ==
NULL)) j--;
674 while ((i > 0) && (h2->m[i-1] ==
NULL)) i--;
680 if (h1->rank<h2->rank)
688 if (h1->m[i] !=
NULL)
692 if (h2->m[j] !=
NULL)
715 while ((i >= 0) && (h->m[i] ==
NULL))
742 const long k =
p_MaxComp(*p, lmRing, tailRing);
822 while ((i >= 0) && (choise[i] == end))
832 for (j=i+1; j<
r; j++)
834 choise[
j] = choise[
i]+j-
i;
857 while ((i<t) && (localchoise[i]==choise[i])) i++;
861 while ((i<d) && (localchoise[i-1]==choise[i])) i++;
882 if (n-r<r)
return binom(n,n-r);
889 WarnS(
"overflow in binomials");
927 static void makemonoms(
int vars,
int actvar,
int deg,
int monomdeg,
const ring
r)
932 if ((idpowerpoint == 0) && (actvar ==1))
941 p_Setm(idpower[idpowerpoint],r);
947 p_SetExp(idpower[idpowerpoint],actvar,deg-monomdeg,r);
948 p_Setm(idpower[idpowerpoint],r);
949 p_Test(idpower[idpowerpoint],r);
955 p =
p_Copy(idpower[idpowerpoint],r);
960 p_SetExp(idpower[idpowerpoint],actvar,
p_GetExp(idpower[idpowerpoint],actvar,r)+1,r);
961 p_Setm(idpower[idpowerpoint],r);
962 p_Test(idpower[idpowerpoint],r);
974 WarnS(
"maxideal: power must be non-negative");
988 int i =
binom(vars+deg-1,deg);
989 if (i<=0)
return idInit(1,1);
1000 int begin,
int end,
int deg,
int restdeg,
poly ap,
const ring
r)
1010 if (result->nrows >=
IDELEMS(result))
1015 if (begin == end)
return;
1016 for (i=restdeg-1;i>0;i--)
1020 id_NextPotence(given, result, begin+1, end, deg, restdeg-i, p,r);
1058 while ((! b) && (i>=0))
1083 for (i=
IDELEMS(h)-1;i>=0; i--)
1095 for (i=
IDELEMS(h)-1;i>=0; i--)
1125 for (i=1;i<=mr ;i++)
1170 Print(
"## inv. rank %ld -> %ld\n",mod->rank,cp);
1171 int k,
l,o=mod->rank;
1174 for (l=1; l<=o; l++)
1176 for (k=1; k<=
IDELEMS(mod); k++)
1200 if (r>rows) r = rows;
1201 if (c>cols) c = cols;
1235 res->
rank =
id->rank;
1255 long cmax=1,
order=0,ord,*
diff,diffmin=32000;
1267 for (i=length-1;i>=0;i--)
1273 diff = (
long *)
omAlloc0(cmax*
sizeof(
long));
1275 iscom = (
int *)
omAlloc0(cmax*
sizeof(
int));
1284 if ((p==
NULL) && (i<length))
1293 while ((i<length) && (F[i]==
NULL)) i++;
1294 if (i>=length)
break;
1315 ord = R->pFDeg(p,R);
1352 for (i=1;i<cmax;i++) (**w)[i-1]=(
int)(diff[i]);
1353 for (i=1;i<cmax;i++)
1355 if (diff[i]<diffmin) diffmin=diff[
i];
1359 for (i=1;i<cmax;i++)
1361 (**w)[i-1]=(
int)(diff[i]-diffmin);
1371 r->nrows = i->
nrows;
1372 r->ncols = i->
ncols;
1375 for(k=(i->nrows)*(i->ncols)-1;k>=0; k--)
1387 WerrorS(
"cannot compute weighted jets now");
1408 if (
idIs0(arg))
return -1;
1409 int i=0,
j, generator=-1;
1410 int rk_arg=arg->rank;
1411 int * componentIsUsed =(
int *)
omAlloc((rk_arg+1)*
sizeof(
int));
1414 while ((generator<0) && (i<
IDELEMS(arg)))
1416 memset(componentIsUsed,0,(rk_arg+1)*
sizeof(
int));
1421 if (componentIsUsed[
j]==0)
1432 componentIsUsed[
j] = 1;
1436 componentIsUsed[
j] = -1;
1439 else if (componentIsUsed[
j]>0)
1441 (componentIsUsed[
j])++;
1449 for (
j=0;
j<=rk_arg;
j++)
1451 if (componentIsUsed[
j]>0)
1453 if ((*comp==-1) || (componentIsUsed[
j]<i))
1456 i= componentIsUsed[
j];
1465 static void idDeleteComp(
ideal arg,
int red_comp)
1470 for (i=
IDELEMS(arg)-1;i>=0;i--)
1492 int in=
IDELEMS(
id)-1, ready=0, all=0,
1493 coldim=
rVar(r), rowmax=2*coldim;
1494 if (in<0)
return NULL;
1506 for (k=1;k<=coldim;k++)
1546 for(i=
rVar(r)-1;i>=0;i--)
1558 for(i=I->nrows*I->ncols-1;i>=0;i--)
1572 if(-1<d0&&((d0<d)||(d==-1)))
1586 int r = a->rank, c =
IDELEMS(a);
1589 for (
int i=c; i>0; i--)
1598 b->m[co] =
p_Add_q(b->m[co], h, rRing);
1637 const int n = rRing->N;
1639 assume(M->rank <= m * n);
1645 for(
int i = 0; i <
k; i++ )
1672 if( cc == 0) cc =
m;
1673 int vv = 1 + (gen - cc) / m;
1685 assume( (cc + (vv-1)*m) == gen );
1692 pTempSum =
p_Add_q(pTempSum, h, rRing);
1697 idTemp->m[
i] = pTempSum;
1711 int cnt=
IDELEMS(xx[0])*xx[0]->nrows;
1713 result->nrows=xx[0]->nrows;
1714 result->ncols=xx[0]->ncols;
1716 number *
x=(number *)
omAlloc(rl*
sizeof(number));
1718 for(i=cnt-1;i>=0;i--)
1720 for(j=rl-1;j>=0;j--)
1725 for(j=rl-1;j>=0;j--)
1732 for(i=rl-1;i>=0;i--)
id_Delete(&(xx[i]),r);
1739 for(
int i=
IDELEMS(M)-1; i>=0;i--)
static FORCE_INLINE number n_Sub(number a, number b, const coeffs r)
return the difference of 'a' and 'b', i.e., a-b
int id_PosConstant(ideal id, const ring r)
index of generator with leading term in ground ring (if any); otherwise -1
const const intvec const intvec const ring _currRing const const intvec const intvec const ring _currRing int
static int p_Comp_RevLex(poly a, poly b, BOOLEAN nolex, const ring R)
3 for idSort: compare a and b revlex inclusive module comp.
void id_Normalize(ideal I, const ring r)
normialize all polys in id
const CanonicalForm int s
void id_DelDiv(ideal id, const ring r)
ideal id_FreeModule(int i, const ring r)
BOOLEAN idInsertPoly(ideal h1, poly h2)
ideal id_Transp(ideal a, const ring rRing)
void p_DebugPrint(poly p, const ring r)
#define omCheckAddrSize(addr, size)
ideal id_Homogen(ideal h, int varnum, const ring r)
static BOOLEAN p_LmIsConstantComp(const poly p, const ring r)
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.
ideal id_Copy(ideal h1, const ring r)
ideal id_Subst(ideal id, int n, poly e, const ring r)
BOOLEAN idIsModule(ideal id, ring r)
BOOLEAN p_ComparePolys(poly p1, poly p2, const ring r)
returns TRUE if p1 is a skalar multiple of p2 assume p1 != NULL and p2 != NULL
BEGIN_NAMESPACE_SINGULARXX const ring lmRing
ideal id_Mult(ideal h1, ideal h2, const ring r)
poly p_Homogen(poly p, int varnum, const ring r)
short * iv2array(intvec *iv, const ring R)
void id_ShallowDelete(ideal *h, ring r)
BOOLEAN p_IsHomogeneous(poly p, const ring r)
static long p_IncrExp(poly p, int v, ring r)
int idGetNumberOfChoise(int t, int d, int begin, int end, int *choise)
int p_MinDeg(poly p, intvec *w, const ring R)
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
ideal id_ChineseRemainder(ideal *xx, number *q, int rl, const ring r)
BOOLEAN id_HomModule(ideal m, ideal Q, intvec **w, const ring R)
BOOLEAN id_HomIdeal(ideal id, ideal Q, const ring r)
void id_DBTest(ideal h1, int level, const char *f, const int l, const ring r, const ring tailRing)
BEGIN_NAMESPACE_SINGULARXX const ring const ring tailRing
void id_Norm(ideal id, const ring r)
#define omFreeSize(addr, size)
static BOOLEAN p_IsUnit(const poly p, const ring r)
const CanonicalForm CFMap CFMap int &both_non_zero int n
static short rVar(const ring r)
#define rVar(r) (r->N)
void id_Delete(ideal *h, ring r)
intvec * id_QHomWeight(ideal id, const ring r)
BOOLEAN id_IsConstant(ideal id, const ring r)
BOOLEAN id_InsertPolyWithTests(ideal h1, const int validEntries, const poly h2, const bool zeroOk, const bool duplicateOk, const ring r)
insert h2 into h1 depending on the two boolean parameters:
static long p_Totaldegree(poly p, const ring r)
BOOLEAN _pp_Test(poly p, ring lmRing, ring tailRing, int level)
poly p_Subst(poly p, int n, poly e, const ring r)
void WerrorS(const char *s)
void p_ShallowDelete(poly *p, const ring r)
ideal id_TensorModuleMult(const int m, const ideal M, const ring rRing)
void p_Norm(poly p1, const ring r)
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
ideal id_MaxIdeal(const ring r)
#define pGetComp(p)
Component.
static int pLength(poly a)
static poly p_Copy(poly p, const ring r)
returns a copy of p
void idShow(const ideal id, const ring lmRing, const ring tailRing, const int debugPrint)
ideal id_JetW(ideal i, int d, intvec *iv, const ring R)
static BOOLEAN rField_has_simple_inverse(const ring r)
int comp(const CanonicalForm &A, const CanonicalForm &B)
compare polynomials
poly pp_JetW(poly p, int m, short *w, const ring R)
static long p_GetExpDiff(poly p1, poly p2, int i, ring r)
void omPrintAddrInfo(FILE *fd, void *addr, const char *s)
void id_Shift(ideal M, int s, const ring r)
static poly p_Head(poly p, const ring r)
static void p_SetCompP(poly p, int i, ring r)
void id_DelMultiples(ideal id, const ring r)
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
void id_DelLmEquals(ideal id, const ring r)
const CanonicalForm CFMap CFMap & N
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent : the integer VarOffset encodes:
void sBucket_Merge_p(sBucket_pt bucket, poly p, int length)
Merges p into Spoly: assumes Bpoly and p have no common monoms destroys p!
void ivTriangIntern(intvec *imat, int &ready, int &all)
void sBucketDestroy(sBucket_pt *bucket)
static poly pp_Mult_qq(poly p, poly q, const ring r)
void p_Vec2Polys(poly v, poly **p, int *len, const ring r)
#define pp_Test(p, lmRing, tailRing)
void id_DelEquals(ideal id, const ring r)
intvec * id_Sort(const ideal id, const BOOLEAN nolex, const ring r)
sorts the ideal w.r.t. the actual ringordering uses lex-ordering when nolex = FALSE ...
sBucket_pt sBucketCreate(ring r)
ideal id_Power(ideal given, int exp, const ring r)
static BOOLEAN p_DivisibleBy(poly a, poly b, const ring r)
static int p_LmCmp(poly p, poly q, const ring r)
poly p_ChineseRemainder(poly *xx, number *x, number *q, int rl, const ring R)
static int si_max(const int a, const int b)
void PrintS(const char *s)
void sBucketClearMerge(sBucket_pt bucket, poly *p, int *length)
void idGetNextChoise(int r, int end, BOOLEAN *endch, int *choise)
matrix id_Module2Matrix(ideal mod, const ring R)
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
void idSkipZeroes(ideal ide)
static poly pReverse(poly p)
BOOLEAN p_EqualPolys(poly p1, poly p2, const ring r)
static void makemonoms(int vars, int actvar, int deg, int monomdeg, const ring r)
void p_Shift(poly *p, int i, const ring r)
shifts components of the vector p by i
matrix mpNew(int r, int c)
create a r x c zero-matrix
void p_Normalize(poly p, const ring r)
#define rRing_has_Comp(r)
static void p_Delete(poly *p, const ring r)
#define omGetSpecBin(size)
ideal idInit(int idsize, int rank)
#define p_LmEqual(p1, p2, r)
static void id_NextPotence(ideal given, ideal result, int begin, int end, int deg, int restdeg, poly ap, 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 : VarOffset encodes the position in p->exp
int p_IsPurePower(const poly p, const ring r)
return i, if head depends only on var(i)
BOOLEAN p_DivisibleByRingCase(poly f, poly g, const ring r)
divisibility check over ground ring (which may contain zero divisors); TRUE iff LT(f) divides LT(g)...
ideal id_Jet(ideal i, int d, const ring R)
static BOOLEAN rField_is_Ring(const ring r)
matrix id_Module2formatedMatrix(ideal mod, int rows, int cols, const ring R)
void pEnlargeSet(poly **p, int l, int increment)
void idInitChoise(int r, int beg, int end, BOOLEAN *endch, int *choise)
ideal id_Add(ideal h1, ideal h2, const ring r)
long(* pFDegProc)(poly p, ring r)
#define omdebugAddrSize(addr, size)
ideal id_Head(ideal h, const ring r)
static BOOLEAN p_IsConstantPoly(const poly p, const ring r)
static void p_Setm(poly p, const ring r)
BOOLEAN id_IsZeroDim(ideal I, const ring r)
ideal id_CopyFirstK(const ideal ide, const int k, const ring r)
int idElem(const ideal F)
number of non-zero polys in F
int dReportError(const char *fmt,...)
int id_ReadOutPivot(ideal arg, int *comp, const ring r)
intvec * ivSolveKern(intvec *imat, int dimtr)
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
poly pp_Jet(poly p, int m, const ring R)
static FORCE_INLINE BOOLEAN n_GreaterZero(number n, const coeffs r)
ordered fields: TRUE iff 'n' is positive; in Z/pZ: TRUE iff 0 < m <= roundedBelow(p/2), where m is the long representing n in C: TRUE iff (Im(n) != 0 and Im(n) >= 0) or (Im(n) == 0 and Re(n) >= 0) in K(a)/
: TRUE iff (n != 0 and (LC(n) > 0 or deg(n) > 0)) in K(t_1, ..., t_n): TRUE iff (LC(numerator(n) is a constant and > 0) or (LC(numerator(n) is not a constant) in Z/2^kZ: TRUE iff 0 < n <= 2^(k-1) in Z/mZ: TRUE iff the internal mpz is greater than zero in Z: TRUE iff n > 0
int id_MinDegW(ideal M, intvec *w, const ring r)
ideal id_Vec2Ideal(poly vec, const ring R)
static poly p_Add_q(poly p, poly q, const ring r)
#define omFreeBin(addr, bin)
#define IMATELEM(M, I, J)
void id_Compactify(ideal id, const ring r)
ideal id_Matrix2Module(matrix mat, const ring R)
ideal id_SimpleAdd(ideal h1, ideal h2, const ring R)
static poly p_Mult_q(poly p, poly q, const ring r)
poly p_Power(poly p, int i, const ring r)
static long p_MaxComp(poly p, ring lmRing, ring tailRing)
#define MATELEM(mat, i, j)