46 #define poly_write(p) wrp(p);PrintLn() 50 #define USE_HEURISTIC2 56 static int cons_pairs;
57 static int crit_fails;
76 int r1,r2=0,rr,
l=(*syzstr->
Tl)[index];
89 while ((rr>=0) && ((syzstr->
resPairs[
index])[rr].order==actdeg)
96 ideal nP=
idInit(l,syzstr->
res[index]->rank);
121 while ((tcp!=
NULL) &&
122 ((tcp->first_poly!=
i)||(tcp->second_poly!=r1))) tcp = tcp->next;
157 Print(
"Hier: %d, %d\n",j,i);
164 tcp->second_poly =
i;
213 tso.lcm = p = nP->m[
i];
224 tso.order += (*syzstr->
cw)[jj-1];
231 tso.isNotMinimal = (
poly)1;
247 tso.syz =
pAdd(pp,tso.syz);
251 Print(
"erzeuge Paar im Modul %d,%d mit: \n",index,tso.order);
296 memset(&tso,0,
sizeof(tso));
297 int l=(*syzstr->
Tl)[index];
308 tso.order += (*syzstr->
cw)[jj-1];
315 tso.isNotMinimal =
NULL;
318 tso.syz =
pHead(syz);
321 tso.lcm =
pHead(tso.syz);
325 Print(
"erzeuge Halbpaar im Module %d,%d mit: \n",index,tso.order);
339 ideal o_r=syzstr->
res[index+1];
345 #ifndef USE_HEURISTIC2 348 (*result)[i1] = i1+1;
353 while ((ll>0) && (o_r->m[ll-1]==
NULL)) ll--;
359 while ((
l<ll) && (!isDivisible))
363 isDivisible = isDivisible ||
371 Print(
"streiche Paar im Modul %d,%d mit: \n",index,nextPairs[i].order);
379 if (*secondpairs==
NULL) *secondpairs =
new intvec(howmuch);
380 (**secondpairs)[i2] = i+1;
410 if (redWith==
NULL)
return toRed;
414 while ((j>0) && (redWith->m[j-1]==
NULL)) j--;
415 if ((toRed==
NULL) || (j==0))
return toRed;
433 if (toRed==
NULL)
break;
440 if ((
i>=j) || (q==
NULL))
break;
457 if (q!=
NULL)
PrintS(
"Hier ist was schief gelaufen!\n");
461 #ifdef USE_HEURISTIC1 475 (*tempV)[
i] = (*arg)[
i+ii];
486 (*result)[ii] = (*tempV)[ii];
498 int howmuch,
int index,
int actord,
int* toSub,
499 int *maxindex,
int *maxdeg)
504 int kres=(*syzstr->
Tl)[index];
512 #ifdef USE_HEURISTIC1 514 int there_are_superfluous=0;
520 if ((nextPairs==
NULL) || (howmuch==0))
return;
521 while ((k>0) && (syzstr->
res[index]->m[k-1]==
NULL)) k--;
522 while ((ks>0) && (syzstr->
res[index+1]->m[ks-1]==
NULL)) ks--;
523 while ((ks1>0) && (syzstr->
orderedRes[index+1]->m[ks1-1]==
NULL)) ks1--;
525 ((redset[kres-1].
p==
NULL) || (redset[kres-1].order>actord))) kres--;
526 while ((kres<(*syzstr->
Tl)[index]) &&
527 (redset[kres-1].order!=0) && (redset[kres-1].order<=actord)) kres++;
528 spl1 =
syLinStrat2(nextPairs,syzstr,howmuch,index,&spl3);
537 if (actord<temp1_hilb->length())
539 toGo = (*temp1_hilb)[actord];
541 Print(
"\nStze toGo im Modul %d und Grad %d auf: %d\n",1,actord-1,toGo);
548 if (actord<=(syzstr->
hilb_coeffs[index])->length())
552 Print(
"\nStze toGo im Modul %d und Grad %d auf: %d\n",index,actord-1,toGo);
557 (actord<=(syzstr->
hilb_coeffs[index+1])->length()))
561 Print(
"\nAddiere zu toGo aus Modul %d und Grad %d: %d\n",index+1,actord-1,(*syzstr->
hilb_coeffs[index+1])[actord-1]);
576 nextPairs[kk].p = nextPairs[kk].syz = nextPairs[kk].lcm =
NULL;
579 #ifdef USE_HEURISTIC2 591 if (spl1!=
NULL)
delete spl1;
595 if ((tso.p1!=
NULL) && (tso.p2!=
NULL))
603 PrintS(
"reduziere Paar mit: \n");
618 && ((redset[j].ind1!=tso.ind1) || (redset[j].ind2!=tso.ind2)))
632 redset[j].length,
NULL);
656 PrintS(
"erhalte Paar mit: \n");
664 Print(
" mit index %d, %d ",tso.ind1,tso.ind2);
687 syzstr->
res[index+1]->m[ks] =
syRed_Hilb(tso.syz,syzstr,index+1);
688 if (syzstr->
res[index+1]->m[ks]!=
NULL)
696 if (index+1>*maxindex) *maxindex = index+1;
697 if (actord-index>*maxdeg) *maxdeg = actord-
index;
705 #ifdef USE_HEURISTIC1 706 if (there_are_superfluous>=0)
713 if (tso.ind2==nextPairs[jj].ind2)
717 for (j2=j;j2<spl1->
length()-1;j2++)
719 (*spl1)[j2] = (*spl1)[j2+1];
729 if (there_are_superfluous==0) there_are_superfluous = 1;
733 Print(
"ist ueberfluessig in Mod %d",index);
741 tso.p = tso.syz = tso.lcm =
NULL;
751 Print(
"naechstes i ist: %d",i);
754 #ifdef USE_HEURISTIC1 755 if ((kk<0) && (there_are_superfluous>0))
759 spl1 = ivStrip(spl2);
763 there_are_superfluous = -1;
768 #ifdef USE_HEURISTIC2 769 if ((kk<0) && (toGo>0))
784 if (spl3!=
NULL)
delete spl3;
807 if (actord+1<temp_hilb->
length())
810 Print(
"\nSetze fuer Modul %d im Grad %d die Wert: \n",index+1,actord);
811 (temp_hilb)->
show(0,0);
814 for (
int j=k;
j>actord;
j--)
825 Print(
"\nSubtrahiere im Modul %d im Grad %d den Wert: %d\n",index,actord-1,toSub);
833 for (
int j=cont_hilb->
length()-1;
j>actord;
j--)
853 while ((
k>0) && (res->m[
k-1]==
NULL))
k--;
855 while ((i<(*syzstr->
Tl)[0]) && (((sPairs)[i].syz==
NULL) ||
856 ((sPairs)[i].order<deg)))
858 if ((i>=(*syzstr->
Tl)[0]) || ((sPairs)[i].order>deg))
return;
859 while ((i<(*syzstr->
Tl)[0]) && (((sPairs)[i].syz==
NULL) ||
860 ((sPairs)[i].order==deg)))
862 if ((sPairs)[i].syz!=
NULL)
865 PrintS(
"reduziere Erzeuger: \n");
868 (sPairs)[i].syz =
syRed_Hilb((sPairs)[
i].syz,syzstr,1);
870 PrintS(
"erhalte Erzeuger: \n");
874 if ((sPairs)[i].syz !=
NULL)
883 if ((sPairs)[i].isNotMinimal==
NULL)
885 PrintS(
"\nminimal generator: ");
891 res->m[
k] = (sPairs)[i].syz;
896 if (1>*maxindex) *maxindex = 1;
897 if (deg-1>*maxdeg) *maxdeg = deg-1;
915 (*syzstr->
betti)[0] = 1;
922 while ((k>0) && (toreor->m[k-1]==
NULL)) k--;
923 reor =
idInit(k,toreor->rank);
925 for (
int j=0;
j<
k;
j++)
928 reor->m[
j] = toreor->m[
j];
932 for (
int j=0;
j<togo;
j++)
937 while ((l<k) && (syzstr->
res[
i]->m[
j]!=reor->m[
l])) l++;
940 toreor->m[
m] = reor->m[
l];
960 int maxindex=0,maxdeg=0;
995 if (origR != syzstr->
syRing)
998 temp->m[
i] =
pCopy( arg->m[i]);
999 if (temp->m[i]!=
NULL)
1002 if (j<actdeg) actdeg =
j;
1019 syzstr->
sev = (
unsigned long **)
omAlloc0((*length+1)*
sizeof(
unsigned long*));
1024 while (nextPairs!=
NULL)
1027 Print(
"compute %d Paare im Module %d im Grad %d \n",howmuch,
index,actdeg+
index);
1048 Print(
"Bilde neue Paare in Modul %d!\n",
index);
1051 if (
index<(*length)-1)
1054 Print(
"Bilde neue Paare in Modul %d!\n",
index+1);
1063 PrintS(
"minimal resolution:\n");
1064 for (
int ti=1;ti<=*length;ti++)
1068 PrintS(
"full resolution:\n");
1069 for (
int ti=1;ti<=*length;ti++)
1075 Print(
"Criterion %d times applied\n",crit);
1076 Print(
"Criterion1 %d times applied\n",crit1);
1077 Print(
"%d superfluous pairs\n",spfl);
1078 Print(
"%d pairs considered\n",cons_pairs);
1079 Print(
"Criterion fails %d times\n",crit_fails);
1089 if (origR != syzstr->
syRing)
void kBucketClear(kBucket_pt bucket, poly *p, int *length)
void resize(int new_length)
int lcm(unsigned long *l, unsigned long *a, unsigned long *b, unsigned long p, int dega, int degb)
void kBucketInit(kBucket_pt bucket, poly lm, int length)
SRes syInitRes(ideal arg, int *length, intvec *Tl, intvec *cw=NULL)
poly prCopyR(poly p, ring src_r, ring dest_r)
#define idDelete(H)
delete an ideal
static void syOrder_Hilb(poly p, syStrategy syzstr, int index)
static int si_min(const int a, const int b)
Compatiblity layer for legacy polynomial operations (over currRing)
number kBucketPolyRed(kBucket_pt bucket, poly p1, int l1, poly spNoether)
void syCompactifyPairSet(SSet sPairs, int sPlength, int first)
static int show(unsigned long offset, char *close)
#define omFreeSize(addr, size)
const poly kBucketGetLm(kBucket_pt bucket)
KINLINE poly ksOldCreateSpoly(poly p1, poly p2, poly spNoether, ring r)
#define pLmDelete(p)
assume p != NULL, deletes Lm(p)->coef and Lm(p)
void sySPRedSyz(syStrategy syzstr, sSObject redWith, poly q=NULL)
SSet syChosePairs(syStrategy syzstr, int *index, int *howmuch, int *actdeg)
static void syReOrdResult_Hilb(syStrategy syzstr, int maxindex, int maxdeg)
long * currShiftedComponents
#define pLmDivisibleBy(a, b)
like pDivisibleBy, except that it is assumed that a!=NULL, b!=NULL
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.
intvec * hHstdSeries(ideal S, intvec *modulweight, intvec *wdegree, ideal Q, ring tailRing)
poly kBucketExtractLm(kBucket_pt bucket)
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
#define pGetExp(p, i)
Exponent.
static void syRedNextPairs_Hilb(SSet nextPairs, syStrategy syzstr, int howmuch, int index, int actord, int *toSub, int *maxindex, int *maxdeg)
void syEnterPair(syStrategy syzstr, SObject *so, int *sPlength, int index)
Coefficient rings, fields and other domains suitable for Singular polynomials.
void kBucketDestroy(kBucket_pt *bucket_pt)
int syInitSyzMod(syStrategy syzstr, int index, int init=17)
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
static long pTotaldegree(poly p)
ring rAssure_dp_C(const ring r)
static long p_FDeg(const poly p, const ring r)
void PrintS(const char *s)
static intvec * syLinStrat2(SSet nextPairs, syStrategy syzstr, int howmuch, int index, intvec **secondpairs)
static void syCreateNewPairs_Hilb(syStrategy syzstr, int index, int actdeg)
static poly syRed_Hilb(poly toRed, syStrategy syzstr, int index)
static unsigned pLength(poly a)
void kBucket_Minus_m_Mult_p(kBucket_pt bucket, poly m, poly p, int *l, poly spNoether)
Bpoly == Bpoly - m*p; where m is a monom Does not destroy p and m assume (*l <= 0 || pLength(p) == *l...
#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 int index(p_Length length, p_Ord ord)
void rChangeCurrRing(ring r)
ideal idInit(int idsize, int rank)
initialise an ideal / module
void syCompactify1(SSet sPairs, int *sPlength, int first)
long ** ShiftedComponents
void syEnlargeFields(syStrategy syzstr, int index)
void pNorm(poly p, const ring R=currRing)
void sySetNewHilb(syStrategy syzstr, int toSub, int index, int actord)
void show(int mat=0, int spaces=0) const
static FORCE_INLINE number n_SubringGcd(number a, number b, const coeffs r)
kBucket_pt kBucketCreate(const ring bucket_ring)
Creation/Destruction of buckets.
static void syRedGenerOfCurrDeg_Hilb(syStrategy syzstr, int deg, int *maxindex, int *maxdeg)
#define IMATELEM(M, I, J)
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
#define pSetCoeff(p, n)
deletes old coeff before setting the new one
void syDeletePair(SObject *so)
syStrategy syHilb(ideal arg, int *length)
#define pCopy(p)
return a copy of the poly
static void syHalfPair(poly syz, int newEl, syStrategy syzstr, int index)