41 #define WITH_BUCKET //Use of buckets in EXPERIMENT3 (Product criterion)
42 #define WITH_SCHREYER_ORD
44 #define USE_CHAINCRIT0
46 #define USE_REGULARITY
67 for (
i=old_hilbs->
length()+deg-1;
i>=deg;
i--)
68 (*shifted_old_hilbs)[
i] = (*old_hilbs)[
i-deg];
70 (*old_hilb1)[
i] = (*old_hilbs)[
i]-(*shifted_old_hilbs)[
i];
72 (*old_hilb1)[
i] = -(*shifted_old_hilbs)[
i];
74 (*new_hilb1)[
i] = (*new_hilbs)[
i];
76 while ((
i<biggest_length) && isRegular)
78 isRegular = isRegular && ((*old_hilb1)[
i] == (*new_hilb1)[
i]);
85 delete shifted_old_hilbs;
99 Print(
"aktueller hoechster index ist: %d\n",(*syzstr->
Tl)[
i]);
100 Print(
"der %d-te modul ist:\n",
i);
102 PrintS(
"Seine Darstellung:\n");
113 ideal old_repr,
int old_tl, poly next_generator,
resolvente totake)
116 poly gen=
pCopy(next_generator),
p;
117 poly neg_gen=
pCopy(next_generator);
118 ideal current_ideal,current_repr;
120 poly w_gen=
pHead(next_generator);
125 neg_gen =
pNeg(neg_gen);
139 current_ideal = syzstr->
res[
index-1];
141 current_tl = (*syzstr->
Tl)[
index-1];
145 current_ideal = old_ideal;
146 current_repr = old_repr;
149 if (!
idIs0(current_ideal))
154 current_ideal->rank+current_tl);
156 current_ideal->rank);
162 while ((start>0) && (syzstr->
res[
index]->m[start-1]==
NULL)) start--;
176 current_ideal->rank+current_tl);
182 while ((start_ttk>0) && (totake[
index]->
m[start_ttk-1]==
NULL)) start_ttk--;
195 if (current_ideal->m[
i]!=
NULL)
215 totake[
index]->m[
i+start_ttk] =
225 (*syzstr->
Tl)[
index] += current_tl;
248 if (resPairs[
i].p1!=
NULL)
249 assume(resPairs[
i].p1==old_generators->m[resPairs[
i].ind1]);
250 if (resPairs[
i].p2!=
NULL)
251 assume(resPairs[
i].p2==old_generators->m[resPairs[
i].ind2]);
269 while ((syzIndex!=0) && (
res[syzIndex]==
NULL)) syzIndex--;
274 #ifdef USE_REGULARITY
281 p =
res[syzIndex]->m[
i];
293 PrintS(
"error in the resolvent\n");
309 int index,ideal new_generators,ideal new_repr,
int crit_comp)
311 if (
idIs0(new_generators))
return;
312 ideal old_generators=syzstr->
res[
index];
314 int i=0,
j,
k,kk,og_elem=0,og_idel=
IDELEMS(old_generators),
l=*l_pairs,jj,ll,j1;
322 while ((og_elem<og_idel) && (old_generators->m[og_elem]!=
NULL))
324 if ((
index>0) && (
pGetComp(old_generators->m[og_elem])<=crit_comp))
328 while ((
l>0) && ((*resPairs)[
l-1].
lcm==
NULL))
l--;
329 while ((
i<
IDELEMS(new_generators)) && (new_generators->m[
i]!=
NULL))
332 if (
IDELEMS(old_generators)==og_elem)
342 while ((
j<og_elem) && (old_generators->m[
j]!=
NULL) &&
344 while ((
j<og_elem) && (old_generators->m[
j]!=
NULL) &&
346 for (jj=og_elem;jj>
j;jj--)
348 old_generators->m[jj] = old_generators->m[jj-1];
349 old_repr->m[jj] = old_repr->m[jj-1];
351 old_generators->m[
j] = new_generators->m[
i];
352 new_generators->m[
i] =
NULL;
353 old_repr->m[
j] = new_repr->m[
i];
354 new_repr->m[
i] =
NULL;
356 for (jj=0;jj<*l_pairs;jj++)
360 if ((*resPairs)[jj].ind1>=
j) (*resPairs)[jj].ind1++;
361 if ((*resPairs)[jj].
ind2>=
j) (*resPairs)[jj].ind2++;
365 for (jj=og_ini;jj<og_elem;jj++)
370 pLcm(old_generators->m[jj],old_generators->m[
j],
p);
387 #ifdef USE_CHAINCRIT0
393 p2 =
pMDivide(prs[j1],old_generators->m[j1]);
398 while ((ti<
l) && (((*resPairs)[ti].ind1!=j1)|| ((*resPairs)[ti].
ind2!=jj))) ti++;
418 for (jj=og_ini;jj<og_elem;jj++)
425 for (ll=0;ll<*l_pairs;ll++)
427 temp[ll].p = (*resPairs)[ll].p;
428 temp[ll].p1 = (*resPairs)[ll].p1;
429 temp[ll].p2 = (*resPairs)[ll].p2;
430 temp[ll].syz = (*resPairs)[ll].syz;
431 temp[ll].lcm = (*resPairs)[ll].lcm;
432 temp[ll].ind1 = (*resPairs)[ll].ind1;
433 temp[ll].ind2 = (*resPairs)[ll].ind2;
434 temp[ll].syzind = (*resPairs)[ll].syzind;
435 temp[ll].order = (*resPairs)[ll].order;
436 temp[ll].isNotMinimal = (*resPairs)[ll].isNotMinimal;
445 tso.p1 = old_generators->m[jj];
446 tso.p2 = old_generators->m[
j];
450 tso.isNotMinimal =
NULL;
455 Print(
"erzeuge Paar im Modul %d,%d mit: \n",
index,tso.order);
516 int * gen_length,
int * secgen_length,
int * tored_length)
518 int i=
IDELEMS(red)-1,num_mon,num_tail;
522 while ((
i>0) && (red->m[
i-1]==
NULL))
i--;
529 num_tail = *tored_length-1;
565 *tored_length = num_mon+num_tail;
588 if ((
j>=
i) || (
p==
NULL))
break;
611 int * gen_length,
int* orp_l,
int * tored_l,
int * syzred_l)
613 int num_mon,num_tail,syz_l;
623 num_tail = *tored_l-1;
627 dummy = syRedSyzPair(syzstr,
index,gen_length,orp_l);
640 *tored_l = num_mon+num_tail;
653 ideal new_repr,
int * ogm_l,
int * orp_l)
655 SObject tso = resPairs[itso];
657 ideal old_generators=syzstr->
res[
index];
659 int og_idel=
IDELEMS(old_generators),ng_place=
IDELEMS(new_generators);
669 int syz_place=
IDELEMS(syzygies);
671 while ((syz_place>0) && (syzygies->m[syz_place-1]==
NULL)) syz_place--;
672 while ((ng_place>0) && (new_generators->m[ng_place-1]==
NULL)) ng_place--;
673 while ((og_idel>0) && (old_generators->m[og_idel-1]==
NULL)) og_idel--;
674 assume (tso.ind1<og_idel);
675 assume (tso.ind2<og_idel);
676 assume (tso.ind1!=tso.ind2);
677 assume (tso.p1 == old_generators->m[tso.ind1]);
678 assume (tso.p2 == old_generators->m[tso.ind2]);
679 tso.p1 = old_generators->m[tso.ind1];
680 tso.p2 = old_generators->m[tso.ind2];
681 if ((tso.p1!=
NULL) && (tso.p2!=
NULL))
689 toReplace = tso.ind1+1;
691 toReplace = tso.ind2+1;
695 if ((
index==0) && (old_generators->rank==1) &&
707 pp =
pCopy(old_repr->m[tso.ind2]);
717 pp =
pCopy(old_repr->m[tso.ind1]);
740 tso.syz =
pCopy(old_repr->m[tso.ind1]);
749 p =
pCopy(old_repr->m[tso.ind2]);
756 tso.syz =
pAdd(
p,tso.syz);
768 Print(
"reduziere Paar im Module %d mit: \n",
index);
776 if ((tso.p!=
NULL) && (!deleteP))
788 if (
j>=ng_place)
break;
844 PrintS(
"Shit happens!\n");
847 Print(
"erhalte Paar im Module %d mit: \n",
index);
855 pDelete(&old_generators->m[toReplace-1]);
856 pDelete(&old_repr->m[toReplace-1]);
857 for (
i=toReplace-1;
i<og_idel-1;
i++)
859 old_generators->m[
i] = old_generators->m[
i+1];
860 old_repr->m[
i] = old_repr->m[
i+1];
862 old_generators->m[og_idel-1] =
NULL;
863 old_repr->m[og_idel-1] =
NULL;
864 for (
i=itso+1;
i<
l;
i++)
868 if ((resPairs[
i].ind1==toReplace-1)||(resPairs[
i].
ind2==toReplace-1))
872 if (resPairs[
i].ind1>=toReplace)
873 (resPairs[
i].ind1)--;
874 if (resPairs[
i].
ind2>=toReplace)
875 (resPairs[
i].ind2)--;
885 if (ng_place>=
IDELEMS(new_generators))
899 new_generators->m[ng_place] = tso.p;
901 new_repr->m[ng_place] = tso.syz;
915 else if (
pGetComp(tso.syz)<=crit_comp)
921 if (syz_place>=
IDELEMS(syzygies))
926 syzygies->m[syz_place] = tso.syz;
928 pNorm(syzygies->m[syz_place]);
931 resPairs[itso] = tso;
940 ideal new_generators,ideal new_repr,
int crit_comp,
syStrategy syzstr,
944 int i,
j,actdeg=resPairs[0].order;
964 while (resPairs[
i].order==actdeg)
968 new_generators, new_repr,ogm_l,orp_l);
975 if (!
idIs0(new_generators))
977 else if (resPairs[0].
lcm==
NULL)
984 actdeg = resPairs[0].order;
1002 int index,
int next_comp)
1005 int l_pairs=2*og_idel;
1007 if ((
idIs0(new_generators)) || (new_generators->m[0]==
NULL))
1009 WerrorS(
"Hier ist was faul!\n");
1016 new_generators,new_repr,next_comp);
1017 if (
redPairs(resPairs,l_pairs,syzygies, new_generators,new_repr,
1018 next_comp,syzstr,
index))
break;
1028 int * g_l,
int * p_l,
int crit_comp)
1056 int index,ideal add_generators,ideal ,ideal ,
1057 ideal ,
int ,
int* first_new)
1059 int i=*first_new,
l=*l_pairs,
j,ll,j1,add_idel=
IDELEMS(add_generators);
1060 ideal
pairs=
idInit(add_idel,add_generators->rank);
1066 while ((
l>0) && ((*resPairs)[
l-1].
lcm==
NULL))
l--;
1067 while ((
i<add_idel) && (add_generators->m[
i]!=
NULL))
1074 pLcm(add_generators->m[
j],add_generators->m[
i],
p);
1091 #ifdef USE_CHAINCRIT
1097 p2 =
pMDivide(prs[j1],add_generators->m[j1]);
1102 while ((ti<
l) && (((*resPairs)[ti].ind1!=j1)|| ((*resPairs)[ti].
ind2!=
j))) ti++;
1129 for (ll=0;ll<*l_pairs;ll++)
1131 temp[ll].p = (*resPairs)[ll].p;
1132 temp[ll].p1 = (*resPairs)[ll].p1;
1133 temp[ll].p2 = (*resPairs)[ll].p2;
1134 temp[ll].syz = (*resPairs)[ll].syz;
1135 temp[ll].lcm = (*resPairs)[ll].lcm;
1136 temp[ll].ind1 = (*resPairs)[ll].ind1;
1137 temp[ll].ind2 = (*resPairs)[ll].ind2;
1138 temp[ll].syzind = (*resPairs)[ll].syzind;
1139 temp[ll].order = (*resPairs)[ll].order;
1140 temp[ll].isNotMinimal = (*resPairs)[ll].isNotMinimal;
1149 tso.p1 = add_generators->m[
j];
1150 tso.p2 = add_generators->m[
i];
1154 tso.isNotMinimal =
NULL;
1159 Print(
"erzeuge Paar im Modul %d,%d mit: \n",
index,tso.order);
1182 ideal new_generators, ideal new_repr,
int * next_place_add,
int ** g_l,
1186 syStrategy syzstr,
int ,ideal add_generators, ideal add_repr,
1187 ideal new_generators, ideal new_repr,
int * next_place_add,
int ** g_l,
1191 SObject tso = resPairs[itso];
1193 int ng_place=
IDELEMS(new_generators);
1201 assume (tso.ind1<*next_place_add);
1202 assume (tso.ind2<*next_place_add);
1203 assume (tso.ind1!=tso.ind2);
1204 assume (tso.p1 == add_generators->m[tso.ind1]);
1205 assume (tso.p2 == add_generators->m[tso.ind2]);
1206 tso.p1 = add_generators->m[tso.ind1];
1207 tso.p2 = add_generators->m[tso.ind2];
1208 if ((tso.p1!=
NULL) && (tso.p2!=
NULL))
1212 #ifdef USE_PROD_CRIT
1218 poly p1=
pCopy(tso.p1);
1219 poly p2=
pCopy(tso.p2);
1220 poly pp1,pp2,tp1,tp2;
1221 poly sp1=
pCopy(add_repr->m[tso.ind1]),sp2=
pCopy(add_repr->m[tso.ind2]);
1252 sp1 =
pMult(p2,sp1);
1253 sp2 =
pMult(p1,sp2);
1254 tso.p =
pSub(tp1,tp2);
1255 tso.syz =
pSub(sp1,sp2);
1263 tso.syz =
pCopy(add_repr->m[tso.ind1]);
1264 poly tt =
pMDivide(tso.lcm,tso.p1);
1272 p =
pCopy(add_repr->m[tso.ind2]);
1279 tso.syz =
pAdd(
p,tso.syz);
1283 Print(
"reduziere Paar im Module %d mit: \n",
index);
1298 if (
j>=*next_place_add)
break;
1318 PrintS(
"Shit happens!\n");
1321 Print(
"erhalte Paar im Module %d mit: \n",
index);
1339 if (*next_place_add>=
IDELEMS(add_generators))
1344 (
IDELEMS(add_generators)+16)*
sizeof(
int));
1345 IDELEMS(add_generators) += 16;
1349 add_generators->m[*next_place_add] = tso.p;
1350 add_repr->m[*next_place_add] = tso.syz;
1351 (*g_l)[*next_place_add] = tso.length;
1352 (*next_place_add)++;
1356 while ((ng_place>0) && (new_generators->m[ng_place-1]==
NULL) &&
1357 (new_repr->m[ng_place-1]==
NULL)) ng_place--;
1358 if (ng_place>=
IDELEMS(new_generators))
1361 IDELEMS(new_generators) += 16;
1365 new_generators->m[ng_place] = tso.p;
1366 new_repr->m[ng_place] = tso.syz;
1370 resPairs[itso] = tso;
1378 int index,ideal add_generators,ideal add_repr,ideal new_generators,
1379 ideal new_repr,
int crit_comp,
int * red_deg,
int * next_place_add,
int **g_l,
1388 while ((
i<l_pairs) && (resPairs[
i].order==*red_deg))
1395 new_generators, new_repr,next_place_add,g_l,deg_soc);
1402 *red_deg = resPairs[0].order;
1415 ideal new_generators, ideal new_repr, ideal add_generators,
1419 int i=0,
j,next_new_el;
1420 int idel_temp=
IDELEMS(temp_generators);
1422 int p_length,red_deg,l_pairs=
IDELEMS(add_generators);
1435 next_place_add =
IDELEMS(add_generators);
1436 while ((next_place_add>0) && (add_generators->m[next_place_add-1]==
NULL))
1439 next_new_el = next_place_add;
1441 while ((
i<idel_temp) && (temp_generators->m[
i]!=
NULL))
1444 #ifdef USE_REGULARITY
1449 while ((
i<idel_temp) && (temp_generators->m[
i]!=
NULL))
1458 while ((
i<idel_temp) && (
p_FDeg(temp_generators->m[
i],
currRing)==next_deg))
1460 next_p = temp_generators->m[
i];
1461 temp_generators->m[
i] =
NULL;
1462 next_p =
normalize(next_p,add_generators,syzstr,gen_length,&p_length,
1474 gen_length,secgen_length,&p_length);
1477 if (next_place_add>=
IDELEMS(add_generators))
1482 (
IDELEMS(add_generators)+16)*
sizeof(
int));
1483 IDELEMS(add_generators) += 16;
1486 add_generators->m[next_place_add] = next_p;
1503 #ifdef WITH_SCHREYER_ORD
1504 add_repr->m[next_place_add] =
pHead(add_generators->m[next_place_add]);
1506 add_repr->m[next_place_add] =
pOne();
1511 gen_length[next_place_add] = p_length;
1522 if ((next_place_add>next_new_el) || (next_deg<0))
1526 while (pairs_left && ((next_deg<0) || (red_deg<= next_deg)))
1529 add_repr,new_generators,new_repr,crit_comp,&next_new_el);
1531 add_repr,new_generators,new_repr,crit_comp,&red_deg,&next_place_add,&gen_length,
1548 ideal old_generators= syzstr->
res[
index];
1550 int i,
j=0,ii=
IDELEMS(old_generators)-1,dummy;
1557 if (old_generators->m[
i]!=
NULL)
1564 if (new_generators->m[
i]!=
NULL)
1573 if ((
j>=ii) || (
p==
NULL))
break;
1574 if ((old_generators->m[
j]!=
NULL) &&
1597 new_repr->m[
j] =
NULL;
1609 ideal temp_generators =
idInit(
IDELEMS(new_generators),new_generators->rank);
1611 ideal add_generators =
idInit(
IDELEMS(new_generators),new_generators->rank);
1614 int j,jj,
k,deg_p,idel_temp=
IDELEMS(temp_generators);
1619 if (new_generators->m[
j]!=
NULL)
1621 p = new_generators->m[
j];
1622 new_generators->m[
j] =
NULL;
1630 if (deg_p<min_deg) min_deg = deg_p;
1633 while ((
k<idel_temp) && (temp_generators->m[
k]!=
NULL) &&
1635 for (jj=idel_temp-1;jj>
k;jj--)
1637 temp_generators->m[jj] = temp_generators->m[jj-1];
1639 temp_generators->m[
k] =
p;
1644 add_generators,add_repr,syzstr,
index,next_comp,totake);
1648 while ((jj>0) && (add_generators->m[jj-1]==
NULL)) jj--;
1660 syzstr->
res[
index]->m[
j+
k] = add_generators->m[
k];
1662 add_generators->m[
k] =
NULL;
1663 add_repr->m[
k] =
NULL;
1699 int ng_idel=
IDELEMS(new_generators);
1700 ideal new_repr =
idInit(ng_idel, crit_comp+ng_idel);
1710 for (
i=0;
i<ng_idel;
i++)
1712 if (new_generators->m[
i]!=
NULL)
1732 #ifdef WITH_SCHREYER_ORD
1733 new_repr->m[
i] =
pHead(new_generators->m[
i]);
1735 new_repr->m[
i] =
pOne();
1744 PrintS(
"Add new generators:\n");
1746 PrintS(
"with representaions:\n");
1767 int crit_comp,t_comp,next_deg,old_tl;
1768 ideal temp=
NULL,old_ideal,old_repr;
1783 if (origR!=syzstr->
syRing)
1793 if (temp->m[0]!=
NULL)
1801 if (jj>maxdeg) maxdeg = jj;
1803 while (!
idIs0(temp))
1808 if (temp->m[
j]!=
NULL)
1818 temp1->m[
k] = temp->m[
j];
1829 #ifdef USE_REGULARITY
1830 int last_generator=
IDELEMS(temp)-1;
1831 while ((last_generator>=0) && (temp->m[last_generator]==
NULL))
1841 ideal temp_gens,old_std;
1843 if (rk_arg>1) syzstr->
res[0]->rank = rk_arg;
1849 if (temp->m[
i]!=
NULL)
1851 new_generators->m[0] =
kNF(syzstr->
res[0],
currRing->qideal,temp->m[
i]);
1853 pNorm(new_generators->m[0]);
1855 next_gen =
pCopy(new_generators->m[0]);
1857 if (!
idIs0(new_generators))
1866 old_tl = (*syzstr->
Tl)[0];
1869 t_comp = (*syzstr->
Tl)[
index];
1870 if (
index==0) crit_comp = t_comp;
1880 #ifdef USE_REGULARITY
1881 if ((
index==0) && (!isRegular) && (
i==last_generator))
1913 PrintS(
"\n not regular\n");
1924 new_generators = temp_gens;
1928 if (
idIs0(new_generators))
break;
1931 if (!
idIs0(new_generators))
1935 if (new_generators->m[
j]!=
NULL)
1938 new_generators->m[
j] =
NULL;
1956 Print(
"The %d-th syzygy-module is now:\n",
index);
1998 PrintS(
"Da ist was faul!!!\n");
1999 Print(
"Aber: Regularitaet %d, Grad %ld\n",
2019 if (origR!=syzstr->
syRing)