36 if ((w==
NULL) || (*w==
NULL))
return w1;
37 int maxxx = (*w)->
length();
51 for (i=maxxx;i<maxxx+
IDELEMS(arg);i++)
53 if (arg->m[i-maxxx]!=
NULL)
58 (*w1)[
i]+=(**w)[
pGetComp(arg->m[i-maxxx])-1];
66 (**w)[i+1] = (*w1)[i+maxxx];
91 poly Unit1,Unit2,actWith;
92 int len,
i,
j,ModComp,
m,
k,
l;
105 while ((j>0) && (!syz->m[j-1])) j--;
114 for (l=k;l<j-1;l++) syz->m[l] = syz->m[l+1];
128 while ((j>0) && (syz->m[j-1]==
NULL)) j--;
132 while ((i<j) && (!existsUnit))
148 if ((len==0) ||((l>0) && (l<len)))
157 if (len>0) existsUnit =
TRUE;
169 for (k=i;k<j-1;k++) syz->m[k] = syz->m[k+1];
187 syz->m[
k] =
pSub(syz->m[k],
192 syz->m[l] = syz->m[l+1];
204 pDelete(&(mod->m[ModComp-1 - curr_syz_limit]));
205 for (k=ModComp-1 - curr_syz_limit;k<
IDELEMS(mod)-1;k++)
206 mod->m[k] = mod->m[k+1];
227 poly actWith=syz->m[elnum];
229 if (from<0) from = 0;
231 syz->m[elnum] =
NULL;
237 poly tmp=syz->m[from];
242 syz->m[from] =
pSub(tmp,
301 while ((index<length) && (res[index]!=
NULL))
304 if (res[index+1]!=
NULL)
310 for (i=0;i<
IDELEMS(reddeg0);i++)
312 if (reddeg0->m[i]!=
NULL)
317 (*have_del)[j-1] = 1;
325 j = to_del->length();
328 if ((*to_del)[j-1]==1)
344 if (res[index+1]!=
NULL)
351 if (to_del!=
NULL)
delete to_del;
365 if (syzIndex<1) syzIndex=1;
372 while ((syzIndex<length-1) && (res[syzIndex]!=
NULL) && (res[syzIndex+1]!=
NULL))
377 if (res[syzIndex]!=
NULL)
378 syMinStep(res[syzIndex-1],res[syzIndex]);
411 if (maxlength!=-1) *length = maxlength+1;
413 if ((wlength!=0) && (*length!=wlength))
416 wtmp[0]=(*weights)[0];
427 if (syz_ring != origR)
438 if ((weights!=
NULL) && (*weights!=
NULL)&& ((*weights)[0]!=
NULL))
442 WarnS(
"wrong weights given(1):"); (*weights)[0]->show();
PrintLn();
449 if ((weights==
NULL) || (*weights==
NULL) || ((*weights)[0]==
NULL))
460 if ((weights!=
NULL) && (*weights!=
NULL)&& ((*weights)[0]!=
NULL))
462 w =
ivCopy((*weights)[0]);
473 #endif // HAVE_PLURAL 485 setRegularity =
FALSE;
490 setRegularity =
FALSE;
494 while ((res[syzIndex]!=
NULL) && (!
idIs0(res[syzIndex])) &&
495 ((maxlength==-1) || (syzIndex<=maxlength)))
500 if (syzIndex+1==*length)
504 for (
j=0;
j<*length;
j++)
507 if (*weights!=
NULL) tempW[
j] = (*weights)[
j];
523 if (minim || (syzIndex!=0))
528 res[syzIndex] = temp;
545 completeMinim=(syzIndex!=maxlength) || (maxlength ==-1) || (hom!=
isHomog);
551 if ((minim)||(syzIndex>1))
552 syMinStep(res[syzIndex-1],res[syzIndex],!completeMinim,
NULL,hom);
572 (*weights)[syzIndex] =
new intvec(k);
575 if (res[syzIndex-1]->
m[i]!=
NULL)
580 += (*w)[
pGetComp(res[syzIndex-1]->
m[i])-1];
584 for (i=k;i<k+
IDELEMS(res[syzIndex]);i++)
586 if (res[syzIndex]->
m[i-k]!=
NULL)
588 +(*w)[
pGetComp(res[syzIndex]->
m[i-k])-1];
594 if ((syzIndex!=0) && (res[syzIndex]!=
NULL) && (
idIs0(res[syzIndex])))
596 if (w !=
NULL)
delete w;
602 for (i=1; i<=syzIndex; i++)
610 if (origR != syz_ring)
613 for (i=0; i<=syzIndex; i++)
628 const ideal idSaveCurrRingQuotient =
currRing->qideal;
691 currRing->qideal = idSaveCurrRingQuotient;
712 q = outp =
pHead(inp);
726 int i,
j,
k, subFromRank=0;
729 if (
idIs0(
id))
return 0;
736 while ((i>0) && (temp->m[i-1]==
NULL)) i--;
743 while ((j<i) && (temp->m[j]==
NULL)) j++;
749 else k = degrees[
pGetComp(temp->m[j])];
750 if (k>=index) tocancel[k-
index]++;
751 if ((k>=0) && (index==0)) subFromRank++;
759 while ((j<i) && (temp->m[j]==
NULL)) j++;
775 for (i=degrees->
length();i>0;i--)
776 deg[i-1] = (*degrees)[i-1]-rsmin;
779 for (i=tocancel->
length();i>0;i--)
780 (*tocancel)[i-1] = tocan[i-1];
798 int i,
j=0,
k=0,
l,rows,cols,mr;
799 int *temp1,*temp2,*temp3;
807 && ((res[cols-1]==
NULL)
808 || (
idIs0(res[cols-1]))))
816 result =
new intvec(1,1,1);
818 result =
new intvec(1,1,res[0]->rank);
835 Warn(
"betti-command: Input is not homogeneous!");
839 if (weights==
NULL) weights=
w;
842 while ((r0_len>0) && (res[0]->
m[r0_len-1]==
NULL)) r0_len--;
848 while ((i<length) && (res[i]!=
NULL))
853 temp1 = (
int*)
omAlloc0((
l+1)*
sizeof(int));
854 temp2 = (
int*)
omAlloc((
l+1)*
sizeof(int));
858 for (i=0;i<cols-1;i++)
861 memset(temp2,0,(
l+1)*
sizeof(
int));
862 for (j=0;j<
IDELEMS(res[i]);j++)
864 if (res[i]->
m[j]!=
NULL)
869 WerrorS(
"input not a resolvent");
875 if (temp2[j+1]-i>rows) rows = temp2[j+1]-
i;
876 if (temp2[j+1]-i<mr) mr = temp2[j+1]-
i;
887 for(j=0;j<weights->
length();j++)
889 if (rows <(*weights)[
j]+1) rows=(-mr)+(*weights)[
j]+1;
894 result =
new intvec(rows+1,cols,0);
897 for(j=0;j<weights->
length();j++)
899 IMATELEM((*result),(-mr)+(*weights)[j]+1,1) ++;
905 (*result)[(-mr)*cols] = rkl;
906 if ((!
idIs0(res[0])) && ((*result)[(-mr)*cols]==0))
907 (*result)[(-mr)*cols] = 1;
909 tocancel = (
int*)
omAlloc0((rows+1)*
sizeof(int));
910 memset(temp1,0,(
l+1)*
sizeof(
int));
913 memset(temp2,0,
l*
sizeof(
int));
917 memset(temp2,0,
l*
sizeof(
int));
923 for(j=0;j<=rows+mr;j++)
926 IMATELEM((*result),(-mr)+j+1,1) -= tocancel[
j];
929 for (i=0;i<cols-1;i++)
932 memset(temp2,0,
l*
sizeof(
int));
933 for (j=0;j<
IDELEMS(res[i]);j++)
935 if (res[i]->
m[j]!=
NULL)
940 IMATELEM((*result),temp2[j+1]-i-mr,i+2)++;
944 if (j<r0_len)
IMATELEM((*result),-mr,2)++;
950 for (j=mr;j<rows+mr;j++)
953 IMATELEM((*result),j+1-mr,i+2) -= tocancel[j+1];
955 if ((i<length-1) && (res[i+1]!=
NULL))
957 memset(tocancel,0,(rows+1)*
sizeof(
int));
962 IMATELEM((*result),j+1,i+2) -= tocancel[
j];
969 for (j=0;j<=rows;j++)
972 if ((
IMATELEM((*result),j+1,i+2)!=0) && (j>*regularity)) *regularity =
j;
981 if ((tomin) && (mr<0))
983 for (j=1;j<=rows+mr+1;j++)
985 for (
k=1;
k<=cols;
k++)
990 for (j=rows+mr+1;j<=rows+1;j++)
992 for (
k=1;
k<=cols;
k++)
1000 for (i=1;i<=result->
rows();i++)
1002 for(
l=1;
l<=result->
cols();
l++)
1010 for (i=0;i<exactresult->
rows();i++)
1012 for (j=0;j<exactresult->
cols();j++)
1017 if (row_shift!=
NULL) *row_shift = mr;
1040 if ((leng>=1) && (*(weights+1)!=
NULL))
1042 delete *(weights+1);
1060 int i,
j,
k,rsmin=0,rsmax=0,rs=0;
1066 for (i=1;i<length;i++)
1068 if (weights[i] !=
NULL)
1070 for (j=1;j<(weights[
i])->length();j++)
1072 if ((*(weights[i]))[
j]-i<rsmin) rsmin = (*(weights[i]))[j]-i;
1073 if ((*(weights[i]))[
j]-i>rsmax) rsmax = (*(weights[i]))[j]-i;
1078 while (weights[i] !=
NULL) i++;
1085 if (k>rsmax) rsmax =
k;
1086 if (k<rsmin) rsmin =
k;
1089 for (j=1;j<(weights[0])->length();j++)
1091 if ((*weights[0])[
j]>rsmax) rsmax = (*weights[0])[
j];
1092 if ((*weights[0])[
j]<rsmin) rsmin = (*weights[0])[
j];
1097 result =
new intvec(rs,i+2,0);
1098 tocancel =
new intvec(rs);
1100 if (
res[0]->rank==0)
1106 for (i=1;i<(weights[0])->length();i++)
1107 IMATELEM(*result,(*weights[0])[
i]+1-rsmin,1)++;
1110 while (weights[i]!=
NULL)
1112 for (j=1;j<(weights[
i])->length();j++)
1114 IMATELEM(*result,(*(weights[i]))[j]-i+1-rsmin,i+1)++;
1131 tocancel =
new intvec(1);
1133 while ((k>0) && (
idIs0(
res[k-1]))) k--;
1134 result =
new intvec(1,k+1,0);
1135 (*result)[0] =
res[0]->rank;
1136 for (i=0;i<length;i++)
1142 if (
res[i]->
m[j]!=
NULL) (*result)[i+1]++;
1152 syDetect(
res[i],i,rsmin,homog,weights[i],tocancel);
1155 for (j=0;j<rs-1;j++)
1157 IMATELEM((*result),j+1,i+1) -= (*tocancel)[
j];
1158 IMATELEM((*result),j+1,i+2) -= (*tocancel)[j+1];
1160 IMATELEM((*result),rs,i+1) -= (*tocancel)[rs-1];
1164 (*result)[i+1] -= (*tocancel)[0];
1165 (*result)[i+2] -= (*tocancel)[0];
1171 for(i=rsmin;i<=rsmax;i++)
1174 for(j=1;j<=result->
cols();j++)
#define TEST_OPT_NOTREGULARITY
void p_SetModDeg(intvec *w, ring r)
ideal SCAQuotient(const ring r)
resolvente syResolvente(ideal arg, int maxlength, int *length, intvec ***weights, BOOLEAN minim)
void resize(int new_length)
#define TEST_OPT_DEGBOUND
#define idDelete(H)
delete an ideal
Compatiblity layer for legacy polynomial operations (over currRing)
void syMinimizeResolvente(resolvente res, int length, int first)
BOOLEAN idTestHomModule(ideal m, ideal Q, intvec *w)
static int rGetCurrSyzLimit(const ring r)
#define omFreeSize(addr, size)
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
intvec * ivCopy(const intvec *o)
#define pLmDelete(p)
assume p != NULL, deletes Lm(p)->coef and Lm(p)
#define pVectorHasUnitB(p, k)
syStrategy syResolution(ideal arg, int maxlength, intvec *w, BOOLEAN minim)
#define rHasGlobalOrdering_currRing()
void WerrorS(const char *s)
static void syMinStep1(resolvente res, int length)
ideal idMinEmbedding(ideal arg, BOOLEAN inPlace, intvec **w)
#define pGetComp(p)
Component.
static BOOLEAN rField_has_simple_inverse(const ring r)
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
void id_Shift(ideal M, int s, const ring r)
#define pVectorHasUnit(p, k, l)
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
#define TEST_OPT_NO_SYZ_MINIM
static long pTotaldegree(poly p)
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
int rGetMaxSyzComp(int i, const ring r)
return the max-comonent wchich has syzIndex i Assume: i<= syzIndex_limit
bool ncExtensions(int iMask)
ring rAssure_SyzComp(const ring r, BOOLEAN complete)
static poly sypCopyConstant(poly inp)
static long p_FDeg(const poly p, const ring r)
static void syDeleteAbove1(ideal up, int k)
static int si_max(const int a, const int b)
#define pLmIsConstantComp(p)
like above, except that p must be != NULL
ideal kInterRedOld(ideal F, ideal Q)
void PrintS(const char *s)
static void syDeleteAbove(ideal up, int k)
#define pHead(p)
returns newly allocated copy of Lm(p), coef is copied, next=NULL, p might be NULL ...
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
static short scaFirstAltVar(ring r)
static int index(p_Length length, p_Ord ord)
void rSetSyzComp(int k, const ring r)
void rChangeCurrRing(ring r)
ideal idInit(int idsize, int rank)
initialise an ideal / module
static void syMinStep(ideal mod, ideal syz, BOOLEAN final=FALSE, ideal up=NULL, tHomog h=isNotHomog)
ideal id_Jet(ideal i, int d, const ring R)
static BOOLEAN rField_is_Ring(const ring r)
ideal id_KillSquares(const ideal id, const short iFirstAltVar, const short iLastAltVar, const ring r, const bool bSkipZeroes)
void rDelete(ring r)
unconditionally deletes fields in r
void pTakeOutComp(poly *p, long comp, poly *q, int *lq, const ring R=currRing)
Splits *p into two polys: *q which consists of all monoms with component == comp and *p of all other ...
static short scaLastAltVar(ring r)
static bool rIsSCA(const ring r)
void show(int mat=0, int spaces=0) const
void syGaussForOne(ideal syz, int elnum, int ModComp, int from, int till)
int syDetect(ideal id, int index, BOOLEAN homog, int *degrees, int *tocancel)
intvec * syBetti(resolvente res, int length, int *regularity, intvec *weights, BOOLEAN tomin, int *row_shift)
#define pDeleteComp(p, k)
ideal idSyzygies(ideal h1, tHomog h, intvec **w, BOOLEAN setSyzComp, BOOLEAN setRegularity, int *deg)
#define IMATELEM(M, I, J)
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
poly p_Cleardenom(poly p, const ring r)
void syKillEmptyEntres(resolvente res, int length)
#define SI_RESTORE_OPT1(A)
ideal idrCopyR_NoSort(ideal id, ring src_r, ring dest_r)
BOOLEAN idHomModule(ideal m, ideal Q, intvec **w)
static intvec * syPrepareModComp(ideal arg, intvec **w)
ideal syMinBase(ideal arg)
ideal idrMoveR_NoSort(ideal &id, ring src_r, ring dest_r)
#define pCopy(p)
return a copy of the poly