37 assume( idsize >= 0 && rank >= 0 );
47 hh->m = (poly *)
omAlloc0(idsize*
sizeof(poly));
57void idShow(
const ideal
id,
const ring lmRing,
const ring tailRing,
const int debugPrint)
65 Print(
"Module of rank %ld,real rank %ld and %d generators.\n",
68 int j = (
id->ncols*
id->nrows) - 1;
69 while ((
j > 0) && (
id->m[
j]==
NULL))
j--;
70 for (
int i = 0;
i <=
j;
i++)
84 const poly *
m =
id->m +
N;
86 for (
int k =
N;
k >= 0; --
k, --
m)
111 ideal hh =
idInit(nvars, 1);
112 for (
int l=nvars-1;
l>=0;
l--)
130 const long elems = (long)(*h)->nrows * (
long)(*h)->ncols;
142 poly
pp=((*h)->m[
j]);
165 elems=
j=(*h)->nrows*(*h)->ncols;
190 for (
k=0;
k<idelems;
k++)
192 if (ide->m[
k] !=
NULL)
197 ide->m[
j] = ide->m[
k];
211 for (
k=
j+1;
k<idelems;
k++)
230 ideal newI =
idInit(
k, ide->rank);
232 for (
int i = 0;
i <
k;
i++)
244 if (id->m[
i] !=
NULL)
319 if (id->m[
i] !=
NULL)
323 if ((id->m[
j] !=
NULL)
341 long *sev=(
long*)
omAlloc0(kk*
sizeof(
long));
342 while(id->m[
k]==
NULL)
k--;
343 BOOLEAN only_lm=r->cf->has_simple_Alloc;
346 for (
int i=
k;
i>=0;
i--)
355 for (
int i=
k;
i>=0;
i--)
364 for (
int i=0;
i<
k;
i++)
366 if (id->m[
i] !=
NULL)
370 for (
int j=
i+1;
j<=
k;
j++)
390 for (
int i=0;
i<
k;
i++)
392 if (id->m[
i] !=
NULL)
396 for (
int j=
i+1;
j<=
k;
j++)
429 for (
i=
k-1;
i>=0;
i--)
431 if (id->m[
i] !=
NULL)
460 for (
i=
k-1;
i>=0;
i--)
462 if (id->m[
i] !=
NULL)
511void id_DBTest(ideal h1,
int level,
const char *
f,
const int l,
const ring r,
const ring tailRing)
523 const long n = ((long)h1->ncols * (
long)h1->nrows);
527 if( h1->m !=
NULL && n > 0 )
533 for (
long i=n - 1;
i >= 0;
i--)
537 if (
k > new_rk) new_rk =
k;
542 assume( !( h1->nrows == h1->rank && h1->nrows > 1 && new_rk > 0 ) );
544 if(new_rk > h1->rank)
547 h1->rank, new_rk,
f,
l);
554 Print(
"error: ideal==NULL in %s:%d\n",
f,
l);
574 const long n = ((long)h1->ncols * (
long)h1->nrows);
578 if( h1->m !=
NULL && n > 0 )
584 for (
long i=n - 1;
i >= 0;
i--)
590 if (
k > new_rk) new_rk =
k;
596 assume( !( h1->nrows == h1->rank && h1->nrows > 1 && new_rk > 0 ) );
598 if(new_rk > h1->rank)
601 h1->rank, new_rk,
f,
l);
608 Print(
"error: ideal==NULL in %s:%d\n",
f,
l);
617 if (
b==
NULL)
return 1;
618 if (a==
NULL)
return -1;
657 int i,
j, actpos=0, newpos;
658 int diff, olddiff, lastcomp, newcomp;
667 diff = (actpos+1) / 2;
683 while (notFound && (newpos>=0) && (newpos<actpos))
693 && (newpos+
diff>=actpos))
695 diff = actpos-newpos-1;
697 else if ((newcomp==-1)
706 if ((olddiff==1) && (lastcomp>0))
713 if ((olddiff==1) && (lastcomp<0))
730 if (newpos<0) newpos = 0;
731 if (newpos>actpos) newpos = actpos;
734 for (
j=actpos;
j>newpos;
j--)
736 (*result)[
j] = (*result)[
j-1];
738 (*result)[newpos] =
i;
755 if (
res->rank<h1->rank)
res->rank=h1->rank;
761 if (
res->rank<h2->rank)
res->rank=h2->rank;
766 while ((
j >= 0) && (h1->m[
j] ==
NULL))
j--;
769 while ((
i >= 0) && (h2->m[
i] ==
NULL))
i--;
771 const int r =
si_max(h1->rank, h2->rank);
781 for (
l=
i;
l>=0;
l--,
j--)
796 while ((
j >= 0) && (h1->m[
j] ==
NULL))
j--;
815 while ((
j >= 0) && (I->m[
j] ==
NULL))
j--;
836 const poly h2,
const bool zeroOk,
const bool duplicateOk,
const ring r)
841 if ((!zeroOk) && (h2 ==
NULL))
return FALSE;
844 bool h2FoundInH1 =
false;
846 while ((
i < validEntries) && (!h2FoundInH1))
851 if (h2FoundInH1)
return FALSE;
853 if (validEntries ==
IDELEMS(h1))
858 h1->m[validEntries] = h2;
863ideal
id_Add (ideal h1,ideal h2,
const ring r)
882 while ((
j > 0) && (h1->m[
j-1] ==
NULL))
j--;
885 while ((
i > 0) && (h2->m[
i-1] ==
NULL))
i--;
888 int r =
si_max( h2->rank, h1->rank );
899 if (h1->m[
i] !=
NULL)
903 if (h2->m[
j] !=
NULL)
1051 while ((
i >= 0) && (choise[
i] == end))
1061 for (
j=
i+1;
j<r;
j++)
1063 choise[
j] = choise[
i]+
j-
i;
1080 localchoise=(
int*)
omAlloc((d-1)*
sizeof(int));
1086 while ((
i<t) && (localchoise[
i]==choise[
i]))
i++;
1090 while ((
i<d) && (localchoise[
i-1]==choise[
i]))
i++;
1112 if (n-r<r)
return binom(n,n-r);
1121 WarnS(
"overflow in binomials");
1134 PrintS(
"In order to address bimodules, the command freeAlgebra should be used.");
1138 for (
int j=0;
j<
i;
j++)
1160static void makemonoms(
int vars,
int actvar,
int deg,
int monomdeg,
const ring r)
1172 if (deg == monomdeg)
1210 assume(deg <= r->
N/r->isLPring);
1222 for (
int j = 2;
j <= vars;
j++)
1224 for (
int i = 0;
i <
size;
i++)
1230 for (
int j = 1;
j <= vars;
j++)
1232 for (
int i = 0;
i <
size;
i++)
1267 vars = r->isLPring - r->LPncGenCount;
1270 for (
int j = 0;
j < deg;
j++)
1279 i =
binom(vars+deg-1,deg);
1301 int begin,
int end,
int deg,
int restdeg, poly
ap,
const ring r)
1316 if (begin == end)
return;
1317 for (
i=restdeg-1;
i>0;
i--)
1359 while ((!
b) && (
i>=0))
1381 if (r->cf->has_simple_Alloc)
1425 for(
unsigned j=0;
j<n ;
j++)
1498 Print(
"## inv. rank %ld -> %ld\n",
mod->rank,cp);
1499 int k,
l,o=
mod->rank;
1528 if (r>rows) r = rows;
1529 if (c>cols) c = cols;
1596 res->rank =
id->rank;
1616 long cmax=1,order=0,ord,*
diff,diffmin=32000;
1636 iscom = (
int *)
omAlloc0(cmax*
sizeof(
int));
1676 ord =
R->pFDeg(
p,
R);
1713 for (
i=1;
i<cmax;
i++) (**
w)[
i-1]=(int)(
diff[
i]);
1714 for (
i=1;
i<cmax;
i++)
1720 for (
i=1;
i<cmax;
i++)
1722 (**w)[
i-1]=(int)(
diff[
i]-diffmin);
1731 ideal r=
idInit((
i->nrows)*(
i->ncols),
i->rank);
1736 for(
long k=((
long)(
i->nrows))*((
long)(
i->ncols))-1;
k>=0;
k--)
1747 WerrorS(
"cannot compute weighted jets now");
1768 if (
idIs0(arg))
return -1;
1769 int i=0,
j, generator=-1;
1770 int rk_arg=arg->rank;
1771 int * componentIsUsed =(
int *)
omAlloc((rk_arg+1)*
sizeof(int));
1774 while ((generator<0) && (
i<
IDELEMS(arg)))
1776 memset(componentIsUsed,0,(rk_arg+1)*
sizeof(
int));
1781 if (componentIsUsed[
j]==0)
1787 componentIsUsed[
j] = 1;
1791 componentIsUsed[
j] = -1;
1794 else if (componentIsUsed[
j]>0)
1796 (componentIsUsed[
j])++;
1804 for (
j=0;
j<=rk_arg;
j++)
1806 if (componentIsUsed[
j]>0)
1808 if ((*
comp==-1) || (componentIsUsed[
j]<
i))
1811 i= componentIsUsed[
j];
1820static void idDeleteComp(ideal arg,
int red_comp)
1847 int in=
IDELEMS(
id)-1, ready=0, all=0,
1848 coldim=
rVar(r), rowmax=2*coldim;
1849 if (in<0)
return NULL;
1861 for (
k=1;
k<=coldim;
k++)
1913 for(
i=I->nrows*I->ncols-1;
i>=0;
i--)
1927 if(-1<d0&&((d0<d)||(d==-1)))
1941 int r = a->rank, c =
IDELEMS(a);
2000 const int n = rRing->N;
2008 for(
int i = 0;
i <
k;
i++ )
2010 poly pTempSum =
NULL;
2035 if( cc == 0) cc =
m;
2036 int vv = 1 + (gen - cc) /
m;
2048 assume( (cc + (vv-1)*
m) == gen );
2055 pTempSum =
p_Add_q(pTempSum,
h, rRing);
2060 idTemp->m[
i] = pTempSum;
2065 ideal idResult =
id_Transp(idTemp, rRing);
2074 int cnt=0;
int rw=0;
int cl=0;
2077 for(
j=rl-1;
j>=0;
j--)
2081 if (xx[
j]->
nrows >rw) rw=xx[
j]->nrows;
2086 WerrorS(
"format mismatch in CRT");
2092 number *
x=(number *)
omAlloc(rl*
sizeof(number));
2093 poly *
p=(poly *)
omAlloc(rl*
sizeof(poly));
2098 for(
i=cnt-1;
i>=0;
i--)
2100 for(
j=rl-1;
j>=0;
j--)
2108 for(
j=rl-1;
j>=0;
j--)
static int si_max(const int a, const int b)
const CanonicalForm CFMap CFMap & N
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.
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),...
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
static FORCE_INLINE number n_Sub(number a, number b, const coeffs r)
return the difference of 'a' and 'b', i.e., a-b
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
const CanonicalForm int s
int comp(const CanonicalForm &A, const CanonicalForm &B)
compare polynomials
void WerrorS(const char *s)
static BOOLEAN length(leftv result, leftv arg)
void ivTriangIntern(intvec *imat, int &ready, int &all)
intvec * ivSolveKern(intvec *imat, int dimtr)
#define IMATELEM(M, I, J)
poly p_ChineseRemainder(poly *xx, mpz_ptr *x, mpz_ptr *q, int rl, mpz_ptr *C, const ring R)
matrix mpNew(int r, int c)
create a r x c zero-matrix
#define MATELEM0(mat, i, j)
0-based access to matrix
int dReportError(const char *fmt,...)
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy
#define __p_GetComp(p, r)
#define rRing_has_Comp(r)
gmp_float exp(const gmp_float &a)
STATIC_VAR gmp_float * diff
#define omFreeSize(addr, size)
#define omdebugAddrSize(addr, size)
#define omCheckAddrSize(addr, size)
#define omFreeBin(addr, bin)
#define omFreeBinAddr(addr)
#define omGetSpecBin(size)
int p_IsPurePower(const poly p, const ring r)
return i, if head depends only on var(i)
poly pp_Jet(poly p, int m, const 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
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),...
poly p_Homogen(poly p, int varnum, const ring r)
poly p_Subst(poly p, int n, poly e, const ring r)
void p_Vec2Polys(poly v, poly **p, int *len, const ring r)
void p_Shift(poly *p, int i, const ring r)
shifts components of the vector p by i
poly p_Power(poly p, int i, const ring r)
void p_Normalize(poly p, const ring r)
void p_Norm(poly p1, const ring r)
int p_MinDeg(poly p, intvec *w, const ring R)
unsigned long p_GetShortExpVector(const poly p, const ring r)
BOOLEAN p_IsHomogeneousW(poly p, const intvec *w, const ring r)
void pEnlargeSet(poly **p, int l, int increment)
BOOLEAN p_IsHomogeneous(poly p, const ring r)
poly pp_JetW(poly p, int m, int *w, const ring R)
poly p_CopyPowerProduct0(const poly p, number n, const ring r)
like p_Head, but with coefficient n
BOOLEAN p_EqualPolys(poly p1, poly p2, const ring r)
static int pLength(poly a)
static long p_GetExpDiff(poly p1, poly p2, int i, ring r)
static poly p_Add_q(poly p, poly q, const ring r)
static poly p_Mult_q(poly p, poly q, const ring r)
#define p_LmEqual(p1, p2, r)
BOOLEAN _p_LmTest(poly p, ring r, int level)
void p_ShallowDelete(poly *p, const ring r)
static void p_SetCompP(poly p, int i, 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
#define pp_Test(p, lmRing, tailRing)
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
static long p_IncrExp(poly p, int v, ring r)
static void p_Setm(poly p, const ring r)
static poly p_SortMerge(poly p, const ring r, BOOLEAN revert=FALSE)
static poly pReverse(poly p)
static int p_LtCmp(poly p, poly q, const ring r)
static BOOLEAN p_LmIsConstantComp(const poly p, const ring r)
static poly p_Head(const poly p, const ring r)
copy the (leading) term of p
static BOOLEAN p_LmShortDivisibleBy(poly a, unsigned long sev_a, poly b, unsigned long not_sev_b, const ring r)
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_LmDivisibleBy(poly a, poly b, const ring r)
static long p_MaxComp(poly p, ring lmRing, ring tailRing)
static void p_Delete(poly *p, const ring r)
static poly pp_Mult_qq(poly p, poly q, const ring r)
static void p_LmFree(poly p, ring)
static BOOLEAN p_IsUnit(const poly p, const ring r)
static poly p_LmDeleteAndNext(poly p, 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)
BOOLEAN _pp_Test(poly p, ring lmRing, ring tailRing, int level)
static BOOLEAN p_IsConstantPoly(const poly p, const ring r)
void p_wrp(poly p, ring lmRing, ring tailRing)
#define pGetComp(p)
Component.
void PrintS(const char *s)
long(* pFDegProc)(poly p, ring r)
static short rVar(const ring r)
#define rVar(r) (r->N)
static BOOLEAN rField_has_simple_inverse(const ring r)
#define rField_is_Ring(R)
void sBucketClearMerge(sBucket_pt bucket, poly *p, int *length)
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 sBucketDestroy(sBucket_pt *bucket)
sBucket_pt sBucketCreate(const ring r)
void id_DBLmTest(ideal h1, int level, const char *f, const int l, const ring r)
Internal verification for ideals/modules and dense matrices!
ideal id_Add(ideal h1, ideal h2, const ring r)
h1 + h2
STATIC_VAR int idpowerpoint
ideal id_Vec2Ideal(poly vec, const ring R)
ideal idInit(int idsize, int rank)
initialise an ideal / module
int id_PosConstant(ideal id, const ring r)
index of generator with leading term in ground ring (if any); otherwise -1
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
void id_DBTest(ideal h1, int level, const char *f, const int l, const ring r, const ring tailRing)
Internal verification for ideals/modules and dense matrices!
poly id_Array2Vector(poly *m, unsigned n, const ring R)
for julia: convert an array of poly to vector
static void id_NextPotence(ideal given, ideal result, int begin, int end, int deg, int restdeg, poly ap, 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
intvec * id_QHomWeight(ideal id, const ring r)
void id_Norm(ideal id, const ring r)
ideal id = (id[i]), result is leadcoeff(id[i]) = 1
BOOLEAN id_HomIdeal(ideal id, ideal Q, const ring r)
STATIC_VAR poly * idpower
static void makemonoms(int vars, int actvar, int deg, int monomdeg, const ring r)
BOOLEAN id_HomModuleW(ideal id, ideal Q, const intvec *w, const intvec *module_w, const ring r)
void idGetNextChoise(int r, int end, BOOLEAN *endch, int *choise)
void id_Normalize(ideal I, const ring r)
normialize all polys in id
ideal id_Transp(ideal a, const ring rRing)
transpose a module
ideal id_FreeModule(int i, const ring r)
the free module of rank i
BOOLEAN id_IsZeroDim(ideal I, const ring r)
ideal id_Homogen(ideal h, int varnum, const ring r)
ideal id_Power(ideal given, int exp, const ring r)
matrix id_Module2Matrix(ideal mod, const ring R)
ideal id_Head(ideal h, const ring r)
returns the ideals of initial terms
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 id_IsConstant(ideal id, const ring r)
test if the ideal has only constant polynomials NOTE: zero ideal/module is also constant
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
BOOLEAN id_HomIdealW(ideal id, ideal Q, const intvec *w, const ring r)
ideal id_TensorModuleMult(const int m, const ideal M, const ring rRing)
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
BOOLEAN idInsertPolyOnPos(ideal I, poly p, int pos)
insert p into I on position pos
int id_ReadOutPivot(ideal arg, int *comp, const ring r)
ideal id_MaxIdeal(const ring r)
initialise the maximal ideal (at 0)
void id_DelDiv(ideal id, const ring r)
delete id[j], if LT(j) == coeff*mon*LT(i) and vice versa, i.e., delete id[i], if LT(i) == coeff*mon*L...
int id_MinDegW(ideal M, intvec *w, const ring r)
void id_DelMultiples(ideal id, const ring r)
ideal id = (id[i]), c any unit if id[i] = c*id[j] then id[j] is deleted for j > i
void id_ShallowDelete(ideal *h, ring r)
Shallowdeletes an ideal/matrix.
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:
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 id_CopyFirstK(const ideal ide, const int k, const ring r)
copies the first k (>= 1) entries of the given ideal/module and returns these as a new ideal/module (...
matrix id_Module2formatedMatrix(ideal mod, int rows, int cols, const ring R)
void idShow(const ideal id, const ring lmRing, const ring tailRing, const int debugPrint)
ideal id_Matrix2Module(matrix mat, const ring R)
converts mat to module, destroys mat
ideal id_ResizeModule(ideal mod, int rows, int cols, const ring R)
ideal id_Delete_Pos(const ideal I, const int p, const ring r)
static int p_Comp_RevLex(poly a, poly b, BOOLEAN nolex, const ring R)
for idSort: compare a and b revlex inclusive module comp.
void id_DelEquals(ideal id, const ring r)
ideal id = (id[i]) if id[i] = id[j] then id[j] is deleted for j > i
ideal id_Jet(const ideal i, int d, const ring R)
static void id_DelDiv_SEV(ideal id, int k, const ring r)
delete id[j], if LT(j) == coeff*mon*LT(i)
ideal id_SimpleAdd(ideal h1, ideal h2, const ring R)
concat the lists h1 and h2 without zeros
void id_DelLmEquals(ideal id, const ring r)
Delete id[j], if Lm(j) == Lm(i) and both LC(j), LC(i) are units and j > i.
ideal id_JetW(const ideal i, int d, intvec *iv, const ring R)
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
void id_Shift(ideal M, int s, const ring r)
int idGetNumberOfChoise(int t, int d, int begin, int end, int *choise)
void idInitChoise(int r, int beg, int end, BOOLEAN *endch, int *choise)
ideal id_ChineseRemainder(ideal *xx, number *q, int rl, const ring r)
static void lpmakemonoms(int vars, int deg, const ring r)
void id_Compactify(ideal id, const ring r)
BOOLEAN id_HomModule(ideal m, ideal Q, intvec **w, const ring R)
ideal id_Subst(ideal id, int n, poly e, const ring r)
The following sip_sideal structure has many different uses thoughout Singular. Basic use-cases for it...
int * iv2array(intvec *iv, const ring R)
EXTERN_VAR short * ecartWeights
#define omPrintAddrInfo(A, B, C)