36 int syComponentOrder=
currRing->ComponentOrder;
38 while ((Fl!=0) && (oldF[Fl-1]==
NULL)) Fl--;
39 if (*modcomp!=
NULL)
delete modcomp;
40 *modcomp =
new intvec(rkF+2);
50 while ((k<Fl) && (
pGetComp(oldF[k]) !=
i)) k++;
54 while ((kk<Fl) && (F[kk]) && (
pLmCmp(oldF[k],F[kk])!=syComponentOrder))
58 for (kkk=j;kkk>kk;kkk--)
69 (**modcomp)[rkF+1] = Fl;
80 while (((k<wend) && (
pGetComp(F[k]) == i)) ||
84 if ((k<wend) && (
pGetComp(F[k]) == i) && (k!=j))
135 j = (*modcomp)[hncomp];
136 nxt = (*modcomp)[hncomp+1];
149 j = (*modcomp)[hncomp];
150 nxt = (*modcomp)[hncomp+1];
171 while ((Fl!=0) && (arg->m[Fl-1]==
NULL)) Fl--;
173 polyset F=arg->m,*Shdl=&(result->m);
176 int i,
j,
l,
k,totalToRed,ecartToRed,kk;
177 int bestEcart,totalmax,rkF,Sl=0,smax,
tmax,tl;
178 int *ecartS, *ecartT, *totalS,
191 ecartS=(
int*)
omAlloc(Fl*
sizeof(
int));
192 totalS=(
int*)
omAlloc(Fl*
sizeof(
int));
194 ecartT=(
int*)
omAlloc(2*Fl*
sizeof(
int));
195 totalT=(
int*)
omAlloc(2*Fl*
sizeof(
int));
202 if (arg->m[j] !=
NULL)
239 if (totalS[k]>totalmax) totalmax=totalS[
k];
240 for (kk=1;kk<=rkF;kk++)
242 for (k=0;k<=totalmax;k++)
246 if ((
pGetComp(S[l])==kk) && (totalS[l]==k))
249 totalT[
j] = totalS[
l];
250 ecartT[
j] = ecartS[
l];
260 totalS[
j] = totalT[
j];
261 ecartS[
j] = ecartT[
j];
267 (*newmodcomp)[j+1] = Sl;
269 int syComponentOrder=
currRing->ComponentOrder;
271 if (syComponentOrder==1)
279 while ((k<j) && (
pGetComp(S[k]) != i)) k++;
288 for (k=lini;k<wend;k++)
295 ecartT[
l] = ecartS[
l];
296 totalT[
l] = totalS[
l];
300 tempcomp =
ivCopy(*modcomp);
342 while ((l<tl) && (notFound))
345 int kkk = (**modcomp)[
pGetComp(toRed)+1];
346 while ((l<kkk) && (notFound))
349 if ((ecartT[l]<bestEcart) && (
pDivisibleBy(T[l],toRed)))
351 if (ecartT[l]<=ecartToRed) notFound =
FALSE;
353 bestEcart = ecartT[
l];
360 for(k=j;k<Fl;k++)
pDelete(&(pairs[k]));
370 WerrorS(
"ideal not a standard basis");
382 temp = (
int*)
omAlloc((tmax+16)*
sizeof(int));
383 for(l=0;l<
tmax;l++) temp[l]=totalT[l];
385 temp = (
int*)
omAlloc((tmax+16)*
sizeof(int));
386 for(l=0;l<
tmax;l++) temp[l]=ecartT[l];
391 for (l=tempcomp->
length()-1;l>comptR;l--)
393 if ((*tempcomp)[
l]>0)
397 while ((l<tl) && (comptR>
pGetComp(T[l]))) l++;
398 while ((l<tl) && (totalT[
l]<=totalToRed)) l++;
399 for (kk=tl;kk>
l;kk--)
402 totalT[kk]=totalT[kk-1];
403 ecartT[kk]=ecartT[kk-1];
408 totalT[
l] = totalToRed;
409 ecartT[
l] = ecartToRed;
433 while ((kk<smax) && (T[l] != S[kk])) kk++;
443 for(k=lini;k<wend;k++)
pDelete(&(pairs[k]));
445 (*newmodcomp)[Fl+1] = Sl;
455 *modcomp = newmodcomp;
510 while ((Fl!=0) && (arg->m[Fl-1]==
NULL)) Fl--;
512 int i,
j,
l,
k,kkk,Sl=0,syComponentOrder=
currRing->ComponentOrder;
513 int wend,lini,ltR,gencQ=0;
517 poly q,toRed,syz,lastmonom,multWith;
526 if (modcomp!=
NULL) (*modcomp)->show(0,0);
529 newmodcomp =
new intvec(Fl+2);
540 Flength = (
int*)
omAlloc0(Fl*
sizeof(
int));
547 (*newmodcomp)[j+1] = Sl;
554 if (syComponentOrder==1)
562 while ((k<j) && (
pGetComp(F[k]) != i)) k++;
567 for (k=lini;k<wend;k++)
581 syz =
pCopy(pairs[k]);
586 lastmonom =
pNext(syz);
588 lastmonom->coef = bn;
589 lastmonom->coef =
nInpNeg(lastmonom->coef);
596 syz->coef =
nInpNeg(syz->coef);
636 l = (**modcomp)[
pGetComp(toRed)+1]-1;
641 printf(
"toRed in Pair[%d, %d]:", j, k);
653 printf(
"toRed in Pair[%d, %d]:", j, k);
658 isNotReduced =
FALSE;
665 for(k=j;k<Fl;k++)
pDelete(&(pairs[k]));
674 WerrorS(
"ideal not a standard basis");
689 lastmonom->coef =
nDiv(lastmonom->coef,F[l]->coef);
721 (*newmodcomp)[j+2] = Sl;
722 (*Shdl)[Sl] =
syRedtail2(syz,*Shdl,newmodcomp);
723 (*newmodcomp)[j+2] = 0;
733 (*newmodcomp)[Fl+1] = Sl;
740 *modcomp = newmodcomp;
748 int syzIndex=length-1,
i,
j;
751 while ((syzIndex!=0) && (res[syzIndex]==
NULL)) syzIndex--;
752 while (syzIndex>=initial)
754 for(i=0;i<
IDELEMS(res[syzIndex]);i++)
756 p = res[syzIndex]->m[
i];
769 PrintS(
"error in the resolvent\n");
781 int syzIndex=length-1,
i,
j;
785 while ((syzIndex!=0) && (
res[syzIndex]==
NULL)) syzIndex--;
790 p =
res[syzIndex]->m[
i];
821 result =
pAdd(result, qq);
828 res[syzIndex]->m[
i] =
p;
838 if (i == 0)
return FALSE;
849 static void syPrintResolution(
resolvente res,
int start,
int length)
851 while ((start < length) && (
res[start]))
853 Print(
"Syz(%d): \n",start);
865 int i,syzIndex = 0,
j=0;
874 WerrorS(
"sres only implemented for modules with ordering ..,c or ..,C");
881 while ((!
idIs0(res[syzIndex])) && ((maxlength==-1) || (syzIndex<maxlength)))
885 if (syzIndex+1==*length)
889 for (
j=0;
j<*length;
j++) newres[
j] = res[
j];
923 for (i=0; i<
IDELEMS(res[1]); i++)
925 res[1]->m[
i] =
prMoveR( res[1]->
m[i], origR, syRing);
936 for (i=0; i<
IDELEMS(res[0]); i++)
938 res[0]->m[
i] =
prMoveR( res[0]->
m[i], origR, syRing);
962 while ((syzIndex < *length) && (!
idIs0(res[syzIndex])))
973 if ( origR!=syRing && syRing !=
NULL)
977 while ((syzIndex < *length) && (res[syzIndex]))
979 for (i=0;i<
IDELEMS(res[syzIndex]);i++)
981 if (res[syzIndex]->
m[i])
983 res[syzIndex]->m[
i] =
prMoveR( res[syzIndex]->
m[i], syRing, origR);
994 while ((syzIndex < *length) && (res[syzIndex]))
996 for (i=0;i<
IDELEMS(res[syzIndex]);i++)
998 if (res[syzIndex]->
m[i])
1009 for (i=0;i<
IDELEMS(res[1]);i++)
1012 res[1]->m[
i] =
pSort(res[1]->
m[i]);
1019 if (modcomp!=
NULL)
delete modcomp;
1020 if (w!=
NULL)
delete w;
1034 for (
int i=rl -1;
i>=0;
i--)
1042 for (
int i=0;
i<rl;
i++)
1068 if ((rl>maxlength) && (result->
fullres[rl-1]!=
NULL))
BOOLEAN rHasLocalOrMixedOrdering(const ring r)
void syReOrderResolventFB(resolvente res, int length, int initial)
#define pSetmComp(p)
TODO:
void kBucketClear(kBucket_pt bucket, poly *p, int *length)
resolvente sySchreyerResolvente(ideal arg, int maxlength, int *length, BOOLEAN isMonomial, BOOLEAN)
poly kNF(ideal F, ideal Q, poly p, int syzComp, int lazyReduce)
void kBucketInit(kBucket_pt bucket, poly lm, int length)
#define idDelete(H)
delete an ideal
template CanonicalForm tmax(const CanonicalForm &, const CanonicalForm &)
static poly syRedtail2(poly p, polyset redWith, intvec *modcomp)
Compatiblity layer for legacy polynomial operations (over currRing)
number kBucketPolyRed(kBucket_pt bucket, poly p1, int l1, poly spNoether)
syStrategy sySchreyer(ideal arg, int maxlength)
#define pLmCmp(p, q)
returns 0|1|-1 if p=q|p>q|p<q w.r.t monomial ordering
poly prMoveR(poly &p, ring src_r, ring dest_r)
#define omFreeSize(addr, size)
const poly kBucketGetLm(kBucket_pt bucket)
int ksCheckCoeff(number *a, number *b)
intvec * ivCopy(const intvec *o)
KINLINE poly ksOldCreateSpoly(poly p1, poly p2, poly spNoether, ring r)
#define pCmp(p1, p2)
pCmp: args may be NULL returns: (p2==NULL ? 1 : (p1 == NULL ? -1 : p_LmCmp(p1, p2))) ...
void WerrorS(const char *s)
static ideal sySchreyersSyzygiesFM(ideal arg, intvec **modcomp)
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
#define pGetComp(p)
Component.
static int pLength(poly a)
ring rAssure_SyzComp_CompLastBlock(const ring r, BOOLEAN)
makes sure that c/C ordering is last ordering and SyzIndex is first
poly initial(const poly p, const ring r, const gfan::ZVector w)
Returns the initial form of p with respect to w.
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
#define pGetExp(p, i)
Exponent.
void id_Shift(ideal M, int s, const ring r)
void kBucketDestroy(kBucket_pt *bucket_pt)
#define pSortCompCorrect(p)
Assume: If considerd only as poly in any component of p (say, monomials of other components of p are ...
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
#define pLmDivisibleByNoComp(a, b)
like pLmDivisibleBy, does not check components
int rGetMaxSyzComp(int i, const ring r)
return the max-comonent wchich has syzIndex i Assume: i<= syzIndex_limit
static void syInitSort(ideal arg, intvec **modcomp)
static long p_FDeg(const poly p, const ring r)
void PrintS(const char *s)
ring rAssure_CompLastBlock(ring r, BOOLEAN complete)
makes sure that c/C ordering is last ordering
static long p_LDeg(const poly p, int *l, const ring r)
#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
BOOLEAN syTestOrder(ideal M)
void rSetSyzComp(int k, const ring r)
poly sySpecNormalize(poly toNorm, ideal mW=NULL)
void rChangeCurrRing(ring r)
ideal idInit(int idsize, int rank)
initialise an ideal / module
#define pDivisibleBy(a, b)
returns TRUE, if leading monom of a divides leading monom of b i.e., if there exists a expvector c > ...
void pEnlargeSet(poly **p, int l, int increment)
BOOLEAN rHasGlobalOrdering(const ring r)
void rDelete(ring r)
unconditionally deletes fields in r
void pNorm(poly p, const ring R=currRing)
static void syCreatePairs(polyset F, int lini, int wend, int k, int j, int i, polyset pairs, int regularPairs=0, ideal mW=NULL)
KINLINE poly ksOldSpolyRed(poly p1, poly p2, poly spNoether)
#define pDeleteComp(p, k)
kBucket_pt kBucketCreate(const ring bucket_ring)
Creation/Destruction of buckets.
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
BOOLEAN rRing_has_CompLastBlock(ring r)
BOOLEAN idHomModule(ideal m, ideal Q, intvec **w)
#define pCopy(p)
return a copy of the poly
static ideal sySchreyersSyzygiesFB(ideal arg, intvec **modcomp, ideal mW, BOOLEAN redTail=TRUE)