32 if ((w==
NULL) || (*w==
NULL))
return w1;
33 int maxxx = (*w)->
length();
47 for (i=maxxx;i<maxxx+
IDELEMS(arg);i++)
49 if (arg->m[i-maxxx]!=
NULL)
54 (*w1)[
i]+=(**w)[
pGetComp(arg->m[i-maxxx])-1];
62 (**w)[i+1] = (*w1)[i+maxxx];
86 poly Unit1,Unit2,actWith;
87 int len,
i,
j,ModComp,
m,
k,
l;
101 while ((j>0) && (!syz->m[j-1])) j--;
110 for (l=k;l<j-1;l++) syz->m[l] = syz->m[l+1];
126 while ((j>0) && (syz->m[j-1]==
NULL)) j--;
128 if (bHasGlobalOrdering)
130 while ((i<j) && (!existsUnit))
146 if ((len==0) ||((l>0) && (l<len)))
155 if (len>0) existsUnit =
TRUE;
167 for (k=i;k<j-1;k++) syz->m[k] = syz->m[k+1];
185 syz->m[
k] =
pSub(syz->m[k],
190 syz->m[l] = syz->m[l+1];
202 pDelete(&(mod->m[ModComp-1 - curr_syz_limit]));
203 for (k=ModComp-1 - curr_syz_limit;k<
IDELEMS(mod)-1;k++)
204 mod->m[k] = mod->m[k+1];
223 poly actWith=syz->m[elnum];
225 if (from<0) from = 0;
227 syz->m[elnum] =
NULL;
233 poly tmp=syz->m[from];
238 syz->m[from] =
pSub(tmp,
296 while ((index<length) && (res[index]!=
NULL))
299 if (res[index+1]!=
NULL)
305 for (i=0;i<
IDELEMS(reddeg0);i++)
307 if (reddeg0->m[i]!=
NULL)
312 (*have_del)[j-1] = 1;
320 j = to_del->length();
323 if ((*to_del)[j-1]==1)
339 if (res[index+1]!=
NULL)
346 if (to_del!=
NULL)
delete to_del;
353 if (to_del!=
NULL)
delete to_del;
361 if (syzIndex<1) syzIndex=1;
368 while ((syzIndex<length-1) && (res[syzIndex]!=
NULL) && (res[syzIndex+1]!=
NULL))
373 if (res[syzIndex]!=
NULL)
374 syMinStep(res[syzIndex-1],res[syzIndex]);
405 if (maxlength!=-1) *length = maxlength+1;
407 if ((wlength!=0) && (*length!=wlength))
410 wtmp[0]=(*weights)[0];
421 if (syz_ring != origR)
432 if ((weights!=
NULL) && (*weights!=
NULL)&& ((*weights)[0]!=
NULL))
436 WarnS(
"wrong weights given(1):"); (*weights)[0]->show();
PrintLn();
443 if ((weights==
NULL) || (*weights==
NULL) || ((*weights)[0]==
NULL))
454 if ((weights!=
NULL) && (*weights!=
NULL)&& ((*weights)[0]!=
NULL))
456 w =
ivCopy((*weights)[0]);
467 #endif // HAVE_PLURAL 479 setRegularity =
FALSE;
484 setRegularity =
FALSE;
488 while ((res[syzIndex]!=
NULL) && (!
idIs0(res[syzIndex])) &&
489 ((maxlength==-1) || (syzIndex<=maxlength)))
494 if (syzIndex+1==*length)
501 if (*weights!=
NULL) tempW[
j] = (*weights)[
j];
517 if (minim || (syzIndex!=0))
522 res[syzIndex] = temp;
536 completeMinim=(syzIndex!=maxlength) || (maxlength ==-1) || (hom!=
isHomog);
542 if ((minim)||(syzIndex>1))
543 syMinStep(res[syzIndex-1],res[syzIndex],!completeMinim,
NULL,hom);
563 (*weights)[syzIndex] =
new intvec(k);
566 if (res[syzIndex-1]->
m[i]!=
NULL)
571 += (*w)[
pGetComp(res[syzIndex-1]->
m[i])-1];
575 for (i=k;i<k+
IDELEMS(res[syzIndex]);i++)
577 if (res[syzIndex]->
m[i-k]!=
NULL)
579 +(*w)[
pGetComp(res[syzIndex]->
m[i-k])-1];
585 if ((syzIndex!=0) && (res[syzIndex]!=
NULL) && (
idIs0(res[syzIndex])))
587 if (w !=
NULL)
delete w;
593 for (i=1; i<=syzIndex; i++)
601 if (origR != syz_ring)
604 for (i=0; i<=syzIndex; i++)
618 const ideal idSaveCurrRingQuotient =
currRing->qideal;
671 currRing->qideal = idSaveCurrRingQuotient;
690 q = outp =
pHead(inp);
704 int i,
j,
k, subFromRank=0;
707 if (
idIs0(
id))
return 0;
714 while ((i>0) && (temp->m[i-1]==
NULL)) i--;
721 while ((j<i) && (temp->m[j]==
NULL)) j++;
727 else k = degrees[
pGetComp(temp->m[j])];
728 if (k>=index) tocancel[k-
index]++;
729 if ((k>=0) && (index==0)) subFromRank++;
737 while ((j<i) && (temp->m[j]==
NULL)) j++;
753 for (i=degrees->
length();i>0;i--)
754 deg[i-1] = (*degrees)[i-1]-rsmin;
757 for (i=tocancel->
length();i>0;i--)
758 (*tocancel)[i-1] = tocan[i-1];
776 int i,
j=0,
k=0,
l,rows,cols,mr;
777 int *temp1,*temp2,*temp3;
785 && ((res[cols-1]==
NULL)
786 || (
idIs0(res[cols-1]))))
794 result =
new intvec(1,1,1);
796 result =
new intvec(1,1,res[0]->rank);
813 WarnS(
"betti-command: Input is not homogeneous!");
817 if (weights==
NULL) weights=
w;
820 while ((r0_len>0) && (res[0]->
m[r0_len-1]==
NULL)) r0_len--;
826 while ((i<length) && (res[i]!=
NULL))
831 temp1 = (
int*)
omAlloc0((
l+1)*
sizeof(int));
832 temp2 = (
int*)
omAlloc((
l+1)*
sizeof(int));
836 for (i=0;i<cols-1;i++)
839 memset(temp2,0,(
l+1)*
sizeof(
int));
840 for (j=0;j<
IDELEMS(res[i]);j++)
842 if (res[i]->
m[j]!=
NULL)
849 WerrorS(
"input not a resolution");
855 if (temp2[j+1]-i>rows) rows = temp2[j+1]-
i;
856 if (temp2[j+1]-i<mr) mr = temp2[j+1]-
i;
867 for(j=0;j<weights->
length();j++)
869 if (rows <(*weights)[
j]+1) rows=(-mr)+(*weights)[
j]+1;
874 result =
new intvec(rows+1,cols,0);
877 for(j=0;j<weights->
length();j++)
879 IMATELEM((*result),(-mr)+(*weights)[j]+1,1) ++;
885 (*result)[(-mr)*cols] = rkl;
886 if ((!
idIs0(res[0])) && ((*result)[(-mr)*cols]==0))
887 (*result)[(-mr)*cols] = 1;
889 tocancel = (
int*)
omAlloc0((rows+1)*
sizeof(int));
890 memset(temp1,0,(
l+1)*
sizeof(
int));
893 memset(temp2,0,
l*
sizeof(
int));
897 memset(temp2,0,
l*
sizeof(
int));
903 for(j=0;j<=rows+mr;j++)
906 IMATELEM((*result),(-mr)+j+1,1) -= tocancel[
j];
909 for (i=0;i<cols-1;i++)
912 memset(temp2,0,
l*
sizeof(
int));
913 for (j=0;j<
IDELEMS(res[i]);j++)
915 if (res[i]->
m[j]!=
NULL)
920 IMATELEM((*result),temp2[j+1]-i-mr,i+2)++;
924 if (j<r0_len)
IMATELEM((*result),-mr,2)++;
930 for (j=mr;j<rows+mr;j++)
933 IMATELEM((*result),j+1-mr,i+2) -= tocancel[j+1];
935 if ((i<length-1) && (res[i+1]!=
NULL))
937 memset(tocancel,0,(rows+1)*
sizeof(
int));
942 IMATELEM((*result),j+1,i+2) -= tocancel[
j];
949 for (j=0;j<=rows;j++)
952 if ((
IMATELEM((*result),j+1,i+2)!=0) && (j>*regularity)) *regularity =
j;
961 if ((tomin) && (mr<0))
963 for (j=1;j<=rows+mr+1;j++)
965 for (
k=1;
k<=cols;
k++)
970 for (j=rows+mr+1;j<=rows+1;j++)
972 for (
k=1;
k<=cols;
k++)
980 for (i=1;i<=result->
rows();i++)
990 for (i=0;i<exactresult->
rows();i++)
992 for (j=0;j<exactresult->
cols();j++)
997 if (row_shift!=
NULL) *row_shift = mr;
1020 if ((leng>=1) && (*(weights+1)!=
NULL))
1022 delete *(weights+1);
1040 int i,
j,
k,rsmin=0,rsmax=0,rs=0;
1048 if (weights[i] !=
NULL)
1050 for (j=1;j<(weights[
i])->
length();j++)
1052 if ((*(weights[i]))[
j]-i<rsmin) rsmin = (*(weights[i]))[j]-i;
1053 if ((*(weights[i]))[
j]-i>rsmax) rsmax = (*(weights[i]))[j]-i;
1058 while (weights[i] !=
NULL) i++;
1065 if (k>rsmax) rsmax =
k;
1066 if (k<rsmin) rsmin =
k;
1069 for (j=1;j<(weights[0])->
length();j++)
1071 if ((*weights[0])[
j]>rsmax) rsmax = (*weights[0])[
j];
1072 if ((*weights[0])[
j]<rsmin) rsmin = (*weights[0])[
j];
1077 result =
new intvec(rs,i+2,0);
1078 tocancel =
new intvec(rs);
1080 if (
res[0]->rank==0)
1086 for (i=1;i<(weights[0])->
length();i++)
1087 IMATELEM(*result,(*weights[0])[
i]+1-rsmin,1)++;
1090 while (weights[i]!=
NULL)
1092 for (j=1;j<(weights[
i])->
length();j++)
1094 IMATELEM(*result,(*(weights[i]))[j]-i+1-rsmin,i+1)++;
1111 tocancel =
new intvec(1);
1113 while ((k>0) && (
idIs0(
res[k-1]))) k--;
1114 result =
new intvec(1,k+1,0);
1115 (*result)[0] =
res[0]->rank;
1122 if (
res[i]->
m[j]!=
NULL) (*result)[i+1]++;
1132 syDetect(
res[i],i,rsmin,homog,weights[i],tocancel);
1135 for (j=0;j<rs-1;j++)
1137 IMATELEM((*result),j+1,i+1) -= (*tocancel)[
j];
1138 IMATELEM((*result),j+1,i+2) -= (*tocancel)[j+1];
1140 IMATELEM((*result),rs,i+1) -= (*tocancel)[rs-1];
1144 (*result)[i+1] -= (*tocancel)[0];
1145 (*result)[i+2] -= (*tocancel)[0];
1151 for(i=rsmin;i<=rsmax;i++)
1154 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
static void syMinStep(ideal mod, ideal &syz, BOOLEAN final=FALSE, ideal up=NULL, tHomog h=isNotHomog)
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)
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)
static BOOLEAN idHomModule(ideal m, ideal Q, intvec **w)
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)
ideal id_Jet(const ideal i, int d, const ring R)
#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 idSyzygies(ideal h1, tHomog h, intvec **w, BOOLEAN setSyzComp, BOOLEAN setRegularity, int *deg, GbVariant alg)
ideal idInit(int idsize, int rank)
initialise an ideal / module
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)
BOOLEAN rHasGlobalOrdering(const ring r)
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 ...
void show(int mat=0, int spaces=0) const
static BOOLEAN length(leftv result, leftv arg)
static short scaLastAltVar(ring r)
static bool rIsSCA(const ring r)
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
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)
#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)
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