31 if ((w==
NULL) || (*w==
NULL))
return w1;
32 int maxxx = (*w)->
length();
46 for (i=maxxx;i<maxxx+
IDELEMS(arg);i++)
48 if (arg->m[i-maxxx]!=
NULL)
53 (*w1)[
i]+=(**w)[
pGetComp(arg->m[i-maxxx])-1];
61 (**w)[i+1] = (*w1)[i+maxxx];
85 poly Unit1,Unit2,actWith;
86 int len,
i,
j,ModComp,
m,
k,
l;
100 while ((j>0) && (!syz->m[j-1])) j--;
109 for (l=k;l<j-1;l++) syz->m[l] = syz->m[l+1];
125 while ((j>0) && (syz->m[j-1]==
NULL)) j--;
127 if (bHasGlobalOrdering)
129 while ((i<j) && (!existsUnit))
145 if ((len==0) ||((l>0) && (l<len)))
154 if (len>0) existsUnit =
TRUE;
166 for (k=i;k<j-1;k++) syz->m[k] = syz->m[k+1];
184 syz->m[
k] =
pSub(syz->m[k],
189 syz->m[l] = syz->m[l+1];
201 pDelete(&(mod->m[ModComp-1 - curr_syz_limit]));
202 for (k=ModComp-1 - curr_syz_limit;k<
IDELEMS(mod)-1;k++)
203 mod->m[k] = mod->m[k+1];
222 poly actWith=syz->m[elnum];
224 if (from<0) from = 0;
226 syz->m[elnum] =
NULL;
232 poly tmp=syz->m[from];
237 syz->m[from] =
pSub(tmp,
295 while ((index<length) && (res[index]!=
NULL))
298 if (res[index+1]!=
NULL)
304 for (i=0;i<
IDELEMS(reddeg0);i++)
306 if (reddeg0->m[i]!=
NULL)
311 (*have_del)[j-1] = 1;
319 j = to_del->length();
322 if ((*to_del)[j-1]==1)
338 if (res[index+1]!=
NULL)
345 if (to_del!=
NULL)
delete to_del;
352 if (to_del!=
NULL)
delete to_del;
360 if (syzIndex<1) syzIndex=1;
367 while ((syzIndex<length-1) && (res[syzIndex]!=
NULL) && (res[syzIndex+1]!=
NULL))
372 if (res[syzIndex]!=
NULL)
373 syMinStep(res[syzIndex-1],res[syzIndex]);
404 if (maxlength!=-1) *length = maxlength+1;
406 if ((wlength!=0) && (*length!=wlength))
409 wtmp[0]=(*weights)[0];
420 if (syz_ring != origR)
431 if ((weights!=
NULL) && (*weights!=
NULL)&& ((*weights)[0]!=
NULL))
435 WarnS(
"wrong weights given(1):"); (*weights)[0]->show();
PrintLn();
442 if ((weights==
NULL) || (*weights==
NULL) || ((*weights)[0]==
NULL))
453 if ((weights!=
NULL) && (*weights!=
NULL)&& ((*weights)[0]!=
NULL))
455 w =
ivCopy((*weights)[0]);
466 #endif // HAVE_PLURAL 478 setRegularity =
FALSE;
483 setRegularity =
FALSE;
487 while ((res[syzIndex]!=
NULL) && (!
idIs0(res[syzIndex])) &&
488 ((maxlength==-1) || (syzIndex<=maxlength)))
493 if (syzIndex+1==*length)
500 if (*weights!=
NULL) tempW[
j] = (*weights)[
j];
516 if (minim || (syzIndex!=0))
521 res[syzIndex] = temp;
535 completeMinim=(syzIndex!=maxlength) || (maxlength ==-1) || (hom!=
isHomog);
541 if ((minim)||(syzIndex>1))
542 syMinStep(res[syzIndex-1],res[syzIndex],!completeMinim,
NULL,hom);
562 (*weights)[syzIndex] =
new intvec(k);
565 if (res[syzIndex-1]->
m[i]!=
NULL)
570 += (*w)[
pGetComp(res[syzIndex-1]->
m[i])-1];
574 for (i=k;i<k+
IDELEMS(res[syzIndex]);i++)
576 if (res[syzIndex]->
m[i-k]!=
NULL)
578 +(*w)[
pGetComp(res[syzIndex]->
m[i-k])-1];
584 if ((syzIndex!=0) && (res[syzIndex]!=
NULL) && (
idIs0(res[syzIndex])))
586 if (w !=
NULL)
delete w;
592 for (i=1; i<=syzIndex; i++)
600 if (origR != syz_ring)
603 for (i=0; i<=syzIndex; i++)
617 const ideal idSaveCurrRingQuotient =
currRing->qideal;
670 currRing->qideal = idSaveCurrRingQuotient;
689 q = outp =
pHead(inp);
703 int i,
j,
k, subFromRank=0;
706 if (
idIs0(
id))
return 0;
713 while ((i>0) && (temp->m[i-1]==
NULL)) i--;
720 while ((j<i) && (temp->m[j]==
NULL)) j++;
726 else k = degrees[
pGetComp(temp->m[j])];
727 if (k>=index) tocancel[k-
index]++;
728 if ((k>=0) && (index==0)) subFromRank++;
736 while ((j<i) && (temp->m[j]==
NULL)) j++;
752 for (i=degrees->
length();i>0;i--)
753 deg[i-1] = (*degrees)[i-1]-rsmin;
756 for (i=tocancel->
length();i>0;i--)
757 (*tocancel)[i-1] = tocan[i-1];
775 int i,
j=0,
k=0,
l,rows,cols,mr;
776 int *temp1,*temp2,*temp3;
784 && ((res[cols-1]==
NULL)
785 || (
idIs0(res[cols-1]))))
793 result =
new intvec(1,1,1);
795 result =
new intvec(1,1,res[0]->rank);
812 WarnS(
"betti-command: Input is not homogeneous!");
816 if (weights==
NULL) weights=
w;
819 while ((r0_len>0) && (res[0]->
m[r0_len-1]==
NULL)) r0_len--;
825 while ((i<length) && (res[i]!=
NULL))
830 temp1 = (
int*)
omAlloc0((
l+1)*
sizeof(int));
831 temp2 = (
int*)
omAlloc((
l+1)*
sizeof(int));
835 for (i=0;i<cols-1;i++)
838 memset(temp2,0,(
l+1)*
sizeof(
int));
839 for (j=0;j<
IDELEMS(res[i]);j++)
841 if (res[i]->
m[j]!=
NULL)
848 WerrorS(
"input not a resolution");
854 if (temp2[j+1]-i>rows) rows = temp2[j+1]-
i;
855 if (temp2[j+1]-i<mr) mr = temp2[j+1]-
i;
866 for(j=0;j<weights->
length();j++)
868 if (rows <(*weights)[
j]+1) rows=(-mr)+(*weights)[
j]+1;
873 result =
new intvec(rows+1,cols,0);
876 for(j=0;j<weights->
length();j++)
878 IMATELEM((*result),(-mr)+(*weights)[j]+1,1) ++;
884 (*result)[(-mr)*cols] = rkl;
885 if ((!
idIs0(res[0])) && ((*result)[(-mr)*cols]==0))
886 (*result)[(-mr)*cols] = 1;
888 tocancel = (
int*)
omAlloc0((rows+1)*
sizeof(int));
889 memset(temp1,0,(
l+1)*
sizeof(
int));
892 memset(temp2,0,
l*
sizeof(
int));
896 memset(temp2,0,
l*
sizeof(
int));
902 for(j=0;j<=rows+mr;j++)
905 IMATELEM((*result),(-mr)+j+1,1) -= tocancel[
j];
908 for (i=0;i<cols-1;i++)
911 memset(temp2,0,
l*
sizeof(
int));
912 for (j=0;j<
IDELEMS(res[i]);j++)
914 if (res[i]->
m[j]!=
NULL)
919 IMATELEM((*result),temp2[j+1]-i-mr,i+2)++;
923 if (j<r0_len)
IMATELEM((*result),-mr,2)++;
929 for (j=mr;j<rows+mr;j++)
932 IMATELEM((*result),j+1-mr,i+2) -= tocancel[j+1];
934 if ((i<length-1) && (res[i+1]!=
NULL))
936 memset(tocancel,0,(rows+1)*
sizeof(
int));
941 IMATELEM((*result),j+1,i+2) -= tocancel[
j];
948 for (j=0;j<=rows;j++)
951 if ((
IMATELEM((*result),j+1,i+2)!=0) && (j>*regularity)) *regularity =
j;
960 if ((tomin) && (mr<0))
962 for (j=1;j<=rows+mr+1;j++)
964 for (
k=1;
k<=cols;
k++)
969 for (j=rows+mr+1;j<=rows+1;j++)
971 for (
k=1;
k<=cols;
k++)
979 for (i=1;i<=result->
rows();i++)
989 for (i=0;i<exactresult->
rows();i++)
991 for (j=0;j<exactresult->
cols();j++)
996 if (row_shift!=
NULL) *row_shift = mr;
1019 if ((leng>=1) && (*(weights+1)!=
NULL))
1021 delete *(weights+1);
1039 int i,
j,
k,rsmin=0,rsmax=0,rs=0;
1047 if (weights[i] !=
NULL)
1049 for (j=1;j<(weights[
i])->
length();j++)
1051 if ((*(weights[i]))[
j]-i<rsmin) rsmin = (*(weights[i]))[j]-i;
1052 if ((*(weights[i]))[
j]-i>rsmax) rsmax = (*(weights[i]))[j]-i;
1057 while (weights[i] !=
NULL) i++;
1064 if (k>rsmax) rsmax =
k;
1065 if (k<rsmin) rsmin =
k;
1068 for (j=1;j<(weights[0])->
length();j++)
1070 if ((*weights[0])[
j]>rsmax) rsmax = (*weights[0])[
j];
1071 if ((*weights[0])[
j]<rsmin) rsmin = (*weights[0])[
j];
1076 result =
new intvec(rs,i+2,0);
1077 tocancel =
new intvec(rs);
1079 if (
res[0]->rank==0)
1085 for (i=1;i<(weights[0])->
length();i++)
1086 IMATELEM(*result,(*weights[0])[
i]+1-rsmin,1)++;
1089 while (weights[i]!=
NULL)
1091 for (j=1;j<(weights[
i])->
length();j++)
1093 IMATELEM(*result,(*(weights[i]))[j]-i+1-rsmin,i+1)++;
1110 tocancel =
new intvec(1);
1112 while ((k>0) && (
idIs0(
res[k-1]))) k--;
1113 result =
new intvec(1,k+1,0);
1114 (*result)[0] =
res[0]->rank;
1121 if (
res[i]->
m[j]!=
NULL) (*result)[i+1]++;
1131 syDetect(
res[i],i,rsmin,homog,weights[i],tocancel);
1134 for (j=0;j<rs-1;j++)
1136 IMATELEM((*result),j+1,i+1) -= (*tocancel)[
j];
1137 IMATELEM((*result),j+1,i+2) -= (*tocancel)[j+1];
1139 IMATELEM((*result),rs,i+1) -= (*tocancel)[rs-1];
1143 (*result)[i+1] -= (*tocancel)[0];
1144 (*result)[i+2] -= (*tocancel)[0];
1150 for(i=rsmin;i<=rsmax;i++)
1153 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)
EXTERN_VAR omBin char_ptr_bin
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)
VAR 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)
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)
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