My Project
Loading...
Searching...
No Matches
syz1.cc
Go to the documentation of this file.
1/****************************************
2* Computer Algebra System SINGULAR *
3****************************************/
4/*
5* ABSTRACT: resolutions
6*/
7
8#include "kernel/mod2.h"
9
10#include "misc/mylimits.h"
11
12#include "misc/options.h"
13#include "misc/intvec.h"
14#include "coeffs/numbers.h"
15
17#include "polys/kbuckets.h"
18#include "polys/prCopy.h"
19
20#include "kernel/polys.h"
21
25#include "kernel/ideals.h"
26#include "kernel/GBEngine/syz.h"
27
28extern void p_Setm_Syz(poly p, ring r,
29 int* Components, long* ShiftedComponents);
30
31/*--------------static variables------------------------*/
32/*---points to the real components, shifted of the actual module-*/
35
36
37/*---counts number of applications of GM-criteria-------*/
38//static int crit;
39//static int euler;
40
41/*3
42* deletes all entres of a pair
43*/
44void syDeletePair(SObject * so)
45{
46 pDelete(&(*so).p);
47 pDelete(&(*so).lcm);
48 pDelete(&(*so).syz);
49 (*so).p1 = NULL;
50 (*so).p2 = NULL;
51 (*so).ind1 = 0;
52 (*so).ind2 = 0;
53 (*so).syzind = -1;
54 (*so).order = 0;
55 (*so).isNotMinimal = NULL;
56 (*so).length = -1;
57 (*so).reference = -1;
58}
59
60/*3
61* initializes all entres of a pair
62*/
63void syInitializePair(SObject * so)
64{
65 (*so).p = NULL;
66 (*so).lcm = NULL;
67 (*so).syz = NULL;
68 (*so).p1 = NULL;
69 (*so).p2 = NULL;
70 (*so).ind1 = 0;
71 (*so).ind2 = 0;
72 (*so).syzind = -1;
73 (*so).order = 0;
74 (*so).isNotMinimal = NULL;
75 (*so).length = -1;
76 (*so).reference = -1;
77}
78
79/*3
80* puts all entres of a pair to another
81*/
82void syCopyPair(SObject * argso, SObject * imso)
83{
84 *imso=*argso;
85 (*argso).p = NULL;
86 (*argso).p1 = NULL;
87 (*argso).p2 = NULL;
88 (*argso).lcm = NULL;
89 (*argso).syz = NULL;
90 (*argso).ind1 = 0;
91 (*argso).ind2 = 0;
92 (*argso).syzind = -1;
93 (*argso).order = 0;
94 (*argso).isNotMinimal = NULL;
95 (*argso).length = -1;
96 (*argso).reference = -1;
97}
98
99/*3
100* deletes empty objects from a pair set beginning with
101* pair first
102* assumes a pair to be empty if .lcm does so
103*/
104void syCompactifyPairSet(SSet sPairs, int sPlength, int first)
105{
106 int k=first,kk=0;
107
108 while (k+kk<sPlength)
109 {
110 if (sPairs[k+kk].lcm!=NULL)
111 {
112 if (kk>0) syCopyPair(&sPairs[k+kk],&sPairs[k]);
113 k++;
114 }
115 else
116 {
117 kk++;
118 }
119 }
120 while (k<sPlength)
121 {
122 syInitializePair(&sPairs[k]);
123 k++;
124 }
125}
126
127/*3
128* deletes empty objects from a pair set beginning with
129* pair first
130* assumes a pair to be empty if .lcm does so
131*/
132void syCompactify1(SSet sPairs, int* sPlength, int first)
133{
134 int k=first,kk=0;
135
136 while (k+kk<*sPlength)
137 {
138 if (sPairs[k+kk].lcm!=NULL)
139 {
140 if (kk>0) syCopyPair(&sPairs[k+kk],&sPairs[k]);
141 k++;
142 }
143 else
144 {
145 kk++;
146 }
147 }
148 while (k<*sPlength)
149 {
150 syInitializePair(&sPairs[k]);
151 k++;
152 }
153 *sPlength -= kk;
154}
155
156/*3
157* replaces comp1dpc during homogeneous syzygy-computations
158* compares with components of currcomponents instead of the
159* exp[0]
160*/
161
162#if 0
163// unused
164#ifdef PDEBUG
165static int syzcomp2dpc_test(poly p1, poly p2)
166{
167 long c1, c2, cc1, cc2, ccc1, ccc2, ec1, ec2;
168 c1 = pGetComp(p1);
169 c2 = pGetComp(p2);
170 cc1 = currcomponents[c1];
171 cc2 = currcomponents[c2];
172 ccc1 = currShiftedComponents[cc1];
173 ccc2 = currShiftedComponents[cc2];
174 ec1 = p1->exp[currRing->typ[1].data.syzcomp.place];
175 ec2 = p2->exp[currRing->typ[1].data.syzcomp.place];
176
177 if (ec1 != ccc1)
178 {
179 Warn("Shifted comp of p1 out of sync. should %d, is %d", ccc1, ec1);
180 //mmDBInfoBlock(p1);
181 }
182 if (ec2 != ccc2)
183 {
184 Warn("Shifted comp of p2 out of sync. should %d, is %d", ccc2, ec2);
185 //mmDBInfoBlock(p2);
186 }
187
188 if (c1 == c2)
189 {
190 assume(ccc1 == ccc2);
191 }
192 else if (cc1 > cc2)
193 {
194 assume(ccc1 > ccc2);
195 }
196 else
197 {
198 assume (cc1 < cc2);
199 assume (ccc1 < ccc2);
200 }
201 int o1=pGetOrder(p1), o2=pGetOrder(p2);
202 if (o1 > o2) return 1;
203 if (o1 < o2) return -1;
204
205 //if (o1>0)
206 {
207 int i = (currRing->N);
208 while ((i>1) && (pGetExp(p1,i)==pGetExp(p2,i)))
209 i--;
210 //(*orderingdepth)[(currRing->N)-i]++;
211 if (i>1)
212 {
213 if (pGetExp(p1,i) < pGetExp(p2,i)) return 1;
214 return -1;
215 }
216 }
217 o1=pGetComp(p1);
218 o2=pGetComp(p2);
219 if (o1==o2/*pGetComp(p1)==pGetComp(p2)*/) return 0;
220 if (currcomponents[o1]>currcomponents[o2]) return 1;
221 return -1;
222}
223#endif // PDEBUG
224#endif
225
226poly syRedtail (poly p, syStrategy syzstr, int index)
227{
228 poly h, hn;
229 int j,pos;
230 ideal redWith=syzstr->orderedRes[index];
231
232 h = p;
233 hn = pNext(h);
234 while(hn != NULL)
235 {
236 j = syzstr->Firstelem[index-1][pGetComp(hn)]-1;
237 if (j>=0)
238 {
239 pos = j+syzstr->Howmuch[index-1][pGetComp(hn)];
240 while (j < pos)
241 {
242 if (pLmDivisibleByNoComp(redWith->m[j], hn))
243 {
244 //hn = sySPolyRed(hn,redWith->m[j]);
245 hn = ksOldSpolyRed(redWith->m[j],hn);
246 if (hn == NULL)
247 {
248 pNext(h) = NULL;
249 return p;
250 }
251 j = syzstr->Firstelem[index-1][pGetComp(hn)]-1;
252 pos = j+syzstr->Howmuch[index-1][pGetComp(hn)];
253 }
254 else
255 {
256 j++;
257 }
258 }
259 }
260 h = pNext(h) = hn;
261 hn = pNext(h);
262 }
263 return p;
264}
265
266
267/*3
268* local procedure for of syInitRes for the module case
269*/
270static int syChMin(intvec * iv)
271{
272 int i,j=-1,r=-1;
273
274 for (i=iv->length()-1;i>=0;i--)
275 {
276 if ((*iv)[i]>=0)
277 {
278 if ((j<0) || ((*iv)[i]<j))
279 {
280 j = (*iv)[i];
281 r = i;
282 }
283 }
284 }
285 return r;
286}
287
288/*3
289* initialize the resolution and puts in the argument as
290* zeroth entre, length must be > 0
291* assumes that the basering is degree-compatible
292*/
293SRes syInitRes(ideal arg,int * length, intvec * Tl, intvec * cw)
294{
295 if (idIs0(arg)) return NULL;
296 SRes resPairs = (SRes)omAlloc0(*length*sizeof(SSet));
297 resPairs[0] = (SSet)omAlloc0(IDELEMS(arg)*sizeof(SObject));
298 intvec * iv=NULL;
299 int i,j;
300
301 if (id_RankFreeModule(arg,currRing)==0)
302 {
303 iv = idSort(arg);
304 for (i=0;i<IDELEMS(arg);i++)
305 {
306 (resPairs[0])[i].syz = /*pCopy*/(arg->m[(*iv)[i]-1]);
307 arg->m[(*iv)[i]-1] = NULL;
308 (resPairs[0])[i].order = pTotaldegree((resPairs[0])[i].syz);
309 }
310 }
311 else
312 {
313 iv = new intvec(IDELEMS(arg),1,-1);
314 for (i=0;i<IDELEMS(arg);i++)
315 {
316 (*iv)[i] = pTotaldegree(arg->m[i])+(*cw)[pGetComp(arg->m[i])-1];
317 }
318 for (i=0;i<IDELEMS(arg);i++)
319 {
320 j = syChMin(iv);
321 if (j<0) break;
322 (resPairs[0])[i].syz = arg->m[j];
323 arg->m[j] = NULL;
324 (resPairs[0])[i].order = (*iv)[j];
325 (*iv)[j] = -1;
326 }
327 }
328 if (iv!=NULL) delete iv;
329 (*Tl)[0] = IDELEMS(arg);
330 return resPairs;
331}
332
333// rearrange shifted components
334static long syReorderShiftedComponents(long * sc, size_t n)
335{
336 long holes = 0;
337 size_t i;
338 long new_comps = 0, new_space, max;
339
340 // count number of holes
341 for (i=1; i<n; i++)
342 {
343 if (sc[i-1] + 1 < sc[i]) holes++;
344 }
345
346 if (LONG_MAX - SYZ_SHIFT_BASE <= sc[n-1])
347 {
348 // need new components
349 new_comps = (((long) 1) << SYZ_SHIFT_MAX_NEW_COMP_ESTIMATE) - 1;
350 max = LONG_MAX;
351 }
352 else
353 {
354 max = sc[n-1] + SYZ_SHIFT_BASE;
355 }
356
357 // no we arrange things such that
358 // (n - holes) + holes*new_space + new_comps*SYZ_SHIFT_BASE= LONG_MAX
359 new_space = (max - n + holes - new_comps*SYZ_SHIFT_BASE) / holes;
360
361 assume(new_space < SYZ_SHIFT_BASE && new_space >= 4);
362
363 long* tc = ( long*) omAlloc(n*sizeof(long));
364 tc[0] = sc[0];
365 // rearrange things
366 for (i=1; i<n; i++)
367 {
368 if (sc[i-1] + 1 < sc[i])
369 {
370 tc[i] = tc[i-1] + new_space;
371 }
372 else
373 {
374 tc[i] = tc[i-1] + 1;
375 }
376 assume(tc[i] > tc[i-1]);
377 }
378
379 assume(LONG_MAX - SYZ_SHIFT_BASE > tc[n-1]);
380#ifndef SING_NDEBUG
381 for (i=1; i<n; i++)
382 {
383 assume(tc[i] >= 0);
384 assume(tc[i-1] + 1 <= tc[i]);
385 }
386#endif
387
388 memcpy(sc, tc, n*sizeof(long));
389 omFreeSize(tc, n*sizeof(long));
390 return new_space;
391}
392
393// this make a Setm on p
394static void pResetSetm(poly p)
395{
396#ifdef PDEBUG
397 poly q = p;
398#endif
399 while (p!= NULL)
400 {
401 pSetm(p);
402 pIter(p);
403 }
404#ifdef PDEBUG
405 pTest(q);
406#endif
407}
408
409void syResetShiftedComponents(syStrategy syzstr, int index,int hilb)
410{
411 assume(index > 0);
412 int i;
413 if (syzstr->res[index] != NULL)
414 {
415 long * prev_s;
416 int* prev_c;
417 int p_length;
418 rGetSComps(&prev_c, &prev_s, &p_length, currRing);
423 IDELEMS(syzstr->res[index-1]), currRing);
424 if (hilb==0)
425 {
426 ideal id = syzstr->res[index];
427 for (i=0; i<IDELEMS(id); i++)
428 {
429 pResetSetm(id->m[i]);
430 }
431 }
432 else if (hilb==1)
433 {
434 assume (index>1);
435 assume (syzstr->resPairs[index-1]!=NULL);
436 SSet Pairs=syzstr->resPairs[index-1];
437 SSet Pairs1=syzstr->resPairs[index];
438 int till=(*syzstr->Tl)[index-1];
439 for (i=0;i<till;i++)
440 {
441 if (Pairs[i].syz!=NULL)
442 pResetSetm(Pairs[i].syz);
443 }
444 till=(*syzstr->Tl)[index];
445 for (i=0;i<till;i++)
446 {
447 if (Pairs1[i].p!=NULL)
448 pResetSetm(Pairs1[i].p);
449 }
450 }
451 currcomponents = prev_c;
452 currShiftedComponents = prev_s;
453 rChangeSComps(prev_c, prev_s, p_length, currRing);
454 }
455}
456
457/*3
458* determines the place of a polynomial in the right ordered resolution
459* set the vectors of truecomponents
460*/
461static BOOLEAN syOrder(poly p,syStrategy syzstr,int index,
462 int realcomp)
463{
464 int i=IDELEMS(syzstr->res[index-1])+1,j=0,k,tc,orc,ie=realcomp-1;
465 int *trind1=syzstr->truecomponents[index-1];
466 int *trind=syzstr->truecomponents[index];
467 long *shind=syzstr->ShiftedComponents[index];
468 int *bc=syzstr->backcomponents[index];
469 int *F1=syzstr->Firstelem[index-1];
470 int *H1=syzstr->Howmuch[index-1];
471 polyset o_r=syzstr->orderedRes[index]->m;
472 BOOLEAN ret = FALSE;
473
474 // if != 0, then new element can go into same component
475 // i.e., we do not need to leave space in shifted components
476 long same_comp = 0;
477
478 if (p==NULL) return FALSE;
479 if (realcomp==0) realcomp=1;
480
481 if (index>1)
482 tc = trind1[pGetComp(p)]-1;
483 else
484 tc = pGetComp(p)-1;
485 loop //while ((j<ie) && (trind1[orc]<=tc+1))
486 {
487 if (j>=ie)
488 break;
489 else
490 {
491 orc = pGetComp(o_r[j]);
492 if (trind1[orc]>tc+1) break;
493 else if (trind1[orc] == tc+1)
494 {
495 same_comp = 1;
496 }
497 else
498 {
499 assume(same_comp == 0);
500 }
501 j += H1[orc];
502 }
503 }
504 if (j>ie)
505 {
506 WerrorS("orderedRes to small");
507 return FALSE;
508 }
509 ie++;
510 if (j == (ie -1))
511 {
512 // new element is the last in ordered module
513 if (same_comp == 0)
514 same_comp = SYZ_SHIFT_BASE;
515
516 // test whether we have enough space for new shifted component
517 if ((LONG_MAX - same_comp) <= shind[ie-1])
518 {
519 long new_space = syReorderShiftedComponents(shind, ie);
520 assume((LONG_MAX - same_comp) > shind[ie-1]);
521 ret = TRUE;
522 if (TEST_OPT_PROT) Print("(T%ld)", new_space);
523 }
524
525 // yes, then set new shifted component
526 assume(ie == 1 || shind[ie-1] > 0);
527 shind[ie] = shind[ie-1] + same_comp;
528 }
529 else
530 {
531 // new element must come in between
532 // i.e. at place j+1
533 long prev, next;
534
535 // test whether new component can get shifted value
536 prev = shind[j];
537 next = shind[j+1];
538 assume(next > prev);
539 if ((same_comp && prev + 2 >= next) || (!same_comp && next - prev < 4))
540 {
541 long new_space = syReorderShiftedComponents(shind, ie);
542 prev = shind[j];
543 next = shind[j+1];
544 assume((same_comp && prev + 2 < next) || (!same_comp && next - prev >= 4));
545 ret = TRUE;
546 if (TEST_OPT_PROT) Print("(B%ld)", new_space);
547 }
548
549 // make room for insertion of j+1 shifted component
550 for (k=ie; k > j+1; k--) shind[k] = shind[k-1];
551
552 if (same_comp)
553 {
554 // can simply add one
555 shind[j+1] = prev + 1;
556 assume(shind[j+1] + 1 < shind[j+2]);
557 }
558 else
559 {
560 // need to leave more breathing room - i.e. value goes in
561 // between
562 shind[j+1] = prev + ((next - prev) >> 1);
563 assume (shind[j] + 1 < shind[j+1] && shind[j+1] + 1 < shind[j+2]);
564 }
565 }
566
567 if (o_r[j]!=NULL)
568 {
569 for (k=ie-1;k>j;k--)
570 {
571 o_r[k] = o_r[k-1];
572 bc[k] = bc[k-1];
573 }
574 }
575 o_r[j] = p;
576 bc[j] = realcomp-1;
577 (H1[pGetComp(p)])++;
578 for (k=0;k<i;k++)
579 {
580 if (F1[k]>j)
581 (F1[k])++;
582 }
583 if (F1[pGetComp(p)]==0)
584 F1[pGetComp(p)]=j+1;
585 for (k=0;k<IDELEMS((syzstr->res)[index]);k++)
586 {
587 if (trind[k]>j)
588 trind[k] += 1;
589 }
590 for (k=IDELEMS((syzstr->res)[index])-1;k>realcomp;k--)
591 trind[k] = trind[k-1];
592 trind[realcomp] = j+1;
593 return ret;
594}
595
596//#define OLD_PAIR_ORDER
597#ifdef OLD_PAIR_ORDER
598static intvec* syLinStrat(SSet nextPairs, syStrategy syzstr,
599 int howmuch, int index)
600{
601 int i=howmuch-1,i1=0,l,ll;
602 int ** Fin=syzstr->Firstelem;
603 int ** Hin=syzstr->Howmuch;
604 int ** bin=syzstr->backcomponents;
605 ideal o_r=syzstr->orderedRes[index+1];
606 intvec *result=new intvec(howmuch+1);
607 BOOLEAN isDivisible;
608 SObject tso;
609
610 while (i>=0)
611 {
612 tso = nextPairs[i];
613 isDivisible = FALSE;
614 if (syzstr->res[index+1]!=NULL)
615 {
616 l = Fin[index][pGetComp(tso.lcm)]-1;
617 if (l>=0)
618 {
619 ll = l+Hin[index][pGetComp(tso.lcm)];
620 while ((l<ll) && (!isDivisible))
621 {
622 if (o_r->m[l]!=NULL)
623 {
624 isDivisible = isDivisible ||
625 pLmDivisibleByNoComp(o_r->m[l],tso.lcm);
626 }
627 l++;
628 }
629 }
630 }
631 if (isDivisible)
632 {
633 syDeletePair(&nextPairs[i]);
634 //crit++;
635 }
636 else
637 {
638 nextPairs[i].p =
639 //sySPoly(tso.p1, tso.p2,tso.lcm);
640 spSpolyCreate(tso.p2, tso.p1,NULL,spSpolyLoop_General);
641 (*result)[i1] = i+1;
642 i1++;
643 }
644 i--;
645 }
646 return result;
647}
648#else
649static intvec* syLinStrat(SSet nextPairs, syStrategy syzstr,
650 int howmuch, int index)
651{
652 int i=howmuch-1,i1=0,i2,i3,l,ll;
653 int ** Fin=syzstr->Firstelem;
654 int ** Hin=syzstr->Howmuch;
655 ideal o_r=syzstr->orderedRes[index+1];
656 intvec *result=new intvec(howmuch+1);
657 intvec *spl=new intvec(howmuch,1,-1);
658 BOOLEAN isDivisible;
659 SObject tso;
660
661 while (i>=0)
662 {
663 tso = nextPairs[i];
664 isDivisible = FALSE;
665 if (syzstr->res[index+1]!=NULL)
666 {
667 l = Fin[index][pGetComp(tso.lcm)]-1;
668 if (l>=0)
669 {
670 ll = l+Hin[index][pGetComp(tso.lcm)];
671 while ((l<ll) && (!isDivisible))
672 {
673 if (o_r->m[l]!=NULL)
674 {
675 isDivisible = isDivisible ||
676 pLmDivisibleByNoComp(o_r->m[l],tso.lcm);
677 }
678 l++;
679 }
680 }
681 }
682 if (isDivisible)
683 {
684 syDeletePair(&nextPairs[i]);
685 //crit++;
686 }
687 else
688 {
689 pTest(tso.p2);
690 pTest(tso.p1);
691 nextPairs[i].p =
692 ksOldCreateSpoly(tso.p2, tso.p1,NULL);
693 (*spl)[i] = pLength(nextPairs[i].p);
694 }
695 i--;
696 }
697 i3 = 0;
698 loop
699 {
700 i2 = -1;
701 for (i1=0;i1<howmuch;i1++)
702 {
703 if (i2==-1)
704 {
705 if ((*spl)[i1]!=-1)
706 {
707 i2 = i1;
708 }
709 }
710 else
711 {
712 if (((*spl)[i1]>=0) && ((*spl)[i1]<(*spl)[i2]))
713 {
714 i2 = i1;
715 }
716 }
717 }
718 if (i2>=0)
719 {
720 (*result)[i3] = i2+1;
721 (*spl)[i2] = -1;
722 i3++;
723 }
724 else
725 {
726 break;
727 }
728 }
729 delete spl;
730 return result;
731}
732#endif
733
735{
736 pEnlargeSet(&(syzstr->res[index]->m),IDELEMS(syzstr->res[index]),16);
738 (IDELEMS(syzstr->res[index])+1)*sizeof(int),
739 (IDELEMS(syzstr->res[index])+17)*sizeof(int));
740 syzstr->ShiftedComponents[index]
742 (IDELEMS(syzstr->res[index])+1)*sizeof(long),
743 (IDELEMS(syzstr->res[index])+17)*sizeof(long));
745 (IDELEMS(syzstr->res[index])+1)*sizeof(int),
746 (IDELEMS(syzstr->res[index])+17)*sizeof(int));
747 syzstr->Howmuch[index]=(int*)omRealloc0Size((ADDRESS)syzstr->Howmuch[index],
748 (IDELEMS(syzstr->res[index])+1)*sizeof(int),
749 (IDELEMS(syzstr->res[index])+17)*sizeof(int));
750 syzstr->Firstelem[index]=(int*)omRealloc0Size((ADDRESS)syzstr->Firstelem[index],
751 (IDELEMS(syzstr->res[index])+1)*sizeof(int),
752 (IDELEMS(syzstr->res[index])+17)*sizeof(int));
753 syzstr->elemLength[index]=(int*)omRealloc0Size((ADDRESS)syzstr->elemLength[index],
754 (IDELEMS(syzstr->res[index])+1)*sizeof(int),
755 (IDELEMS(syzstr->res[index])+17)*sizeof(int));
756 syzstr->sev[index]=(unsigned long*)omRealloc0Size((ADDRESS)syzstr->sev[index],
757 (IDELEMS(syzstr->res[index])+1)*sizeof(unsigned long),
758 (IDELEMS(syzstr->res[index])+17)*sizeof(unsigned long));
759 IDELEMS(syzstr->res[index]) += 16;
760 pEnlargeSet(&(syzstr->orderedRes[index]->m),IDELEMS(syzstr->orderedRes[index]),16);
761 IDELEMS(syzstr->orderedRes[index]) += 16;
762}
763/*3
764* reduces all pairs of degree deg in the module index
765* put the reduced generators to the resolvente which contains
766* the truncated kStd
767*/
768static void syRedNextPairs(SSet nextPairs, syStrategy syzstr,
769 int howmuch, int index)
770{
771 int i,j,k=IDELEMS(syzstr->res[index]);
772 int ks=IDELEMS(syzstr->res[index+1]);
773 int * Fin=syzstr->Firstelem[index-1];
774 int * Hin=syzstr->Howmuch[index-1];
775 int * bin=syzstr->backcomponents[index];
776 int * elL=syzstr->elemLength[index];
777 number coefgcd;
778 polyset redset=syzstr->orderedRes[index]->m;
779 poly p=NULL,q;
780 intvec *spl1;
781 SObject tso;
782 long * ShiftedComponents = syzstr->ShiftedComponents[index];
783 int* Components = syzstr->truecomponents[index];
784 assume(Components != NULL && ShiftedComponents != NULL);
785 BOOLEAN need_reset;
786
787 if ((nextPairs==NULL) || (howmuch==0)) return;
788 while ((k>0) && (syzstr->res[index]->m[k-1]==NULL)) k--;
789 while ((ks>0) && (syzstr->res[index+1]->m[ks-1]==NULL)) ks--;
790 spl1 = syLinStrat(nextPairs,syzstr,howmuch,index);
791 i=0;
792 while ((*spl1)[i]>0)
793 {
794 need_reset = FALSE;
795 tso = nextPairs[(*spl1)[i]-1];
796 if ((tso.p1!=NULL) && (tso.p2!=NULL))
797 {
798 nNormalize(pGetCoeff(tso.p1));
799 nNormalize(pGetCoeff(tso.p2));
800 coefgcd =
801 n_SubringGcd(pGetCoeff(tso.p1),pGetCoeff(tso.p2),currRing->cf);
802 tso.syz = pHead(tso.lcm);
803 p = tso.syz;
804 pSetCoeff(p,nDiv(pGetCoeff(tso.p1),coefgcd));
806 pSetComp(p,tso.ind2+1);
807 p_Setm_Syz(p, currRing, Components, ShiftedComponents); // actueller index
808 pNext(p) = pHead(tso.lcm);
809 pIter(p);
810 pSetComp(p,tso.ind1+1);
811 p_Setm_Syz(p, currRing, Components, ShiftedComponents); // actueller index
812 pSetCoeff(p,nDiv(pGetCoeff(tso.p2),coefgcd));
813 nDelete(&coefgcd);
814 if (tso.p != NULL)
815 {
816 kBucketInit(syzstr->bucket,tso.p,-1);
817 q = kBucketGetLm(syzstr->bucket);
818 j = Fin[pGetComp(q)]-1;
819 int pos = j+Hin[pGetComp(q)];
820 loop
821 {
822 if (j<0) break;
823 if (pLmDivisibleByNoComp(redset[j],q))
824 {
825 pNext(p) = pHead(q);
826 pIter(p);
827 pSetComp(p,bin[j]+1);
828 p_Setm_Syz(p, currRing, Components, ShiftedComponents); // actueller index
829//if (pLength(redset[j])!=syzstr->elemLength[index][bin[j]])
830//Print("Halt");
831//if (pLength(redset[j])!=syzstr->elemLength[index][bin[j]])
832//Print("Halt");
834 number up = kBucketPolyRed(syzstr->bucket,redset[j],elL[bin[j]],
835 NULL);
836 // Thomas: Check whether you need number here
837 nDelete(&up);
838 q = kBucketGetLm(syzstr->bucket);
839 if (q==NULL) break;
840 j = Fin[pGetComp(q)]-1;
841 pos = j+Hin[pGetComp(q)];
842 }
843 else
844 {
845 j++;
846 if (j==pos) break;
847 }
848 }
849 int lb;
850 kBucketClear(syzstr->bucket,&tso.p,&lb);
851 }
852 if (tso.p != NULL)
853 {
854 if (TEST_OPT_PROT) PrintS("g");
855 if (k==IDELEMS((syzstr->res)[index]))
856 {
857 syEnlargeFields(syzstr,index);
858 bin=syzstr->backcomponents[index];
859 elL=syzstr->elemLength[index];
860 redset=syzstr->orderedRes[index]->m;
861 Components = syzstr->truecomponents[index];
862 ShiftedComponents = syzstr->ShiftedComponents[index];
863 }
864 pNext(p) = pHead(tso.p);
865 pIter(p);
866
867 assume(p!= NULL);
868 k++;
869 syzstr->res[index]->m[k-1] = tso.p;
870 syzstr->elemLength[index][k-1] = pLength(tso.p);
871 pNorm(syzstr->res[index]->m[k-1]);
872 need_reset = syOrder(syzstr->res[index]->m[k-1],syzstr,index,k);
873 pSetComp(p,k); // actueller index
874 p_Setm_Syz(p, currRing, Components, ShiftedComponents);
876
877 tso.isNotMinimal = p;
878 tso.p = NULL;
879 }
880 else
881 {
882 if (TEST_OPT_PROT) PrintS(".");
883 //if (index % 2==0)
884 //euler++;
885 //else
886 //euler--;
887 }
888 if (ks==IDELEMS(syzstr->res[index+1]))
889 {
890 syEnlargeFields(syzstr,index+1);
891 }
892 syzstr->res[index+1]->m[ks] = tso.syz;
893 syzstr->elemLength[index+1][ks] = pLength(tso.syz);
894 pNorm(syzstr->res[index+1]->m[ks]);
895 tso.syz =NULL;
896 tso.syzind = ks;
897 if (need_reset)
899 if (syOrder(syzstr->res[index+1]->m[ks],syzstr,index+1,ks+1))
901 ks++;
902 p = NULL;
903 nextPairs[(*spl1)[i]-1] = tso;
904 }
905 i++;
906 }
907 delete spl1;
908}
909
910/*3
911* reduces the generators of the module index in degree deg
912* (which are actual syzygies of the module index-1)
913* wrt. the ideal generated by elements of lower degrees
914*/
915static void syRedGenerOfCurrDeg(syStrategy syzstr, int deg, int index)
916{
917 ideal res=syzstr->res[index];
918 int i=0,j,k=IDELEMS(res);
919 SSet sPairs=syzstr->resPairs[index-1];
920
921 while ((k>0) && (res->m[k-1]==NULL)) k--;
922 while ((i<(*syzstr->Tl)[index-1]) && (((sPairs)[i].syz==NULL) ||
923 ((sPairs)[i].order<deg)))
924 i++;
925 if ((i>=(*syzstr->Tl)[index-1]) || ((sPairs)[i].order>deg)) return;
926 while ((i<(*syzstr->Tl)[index-1]) && (((sPairs)[i].syz==NULL) ||
927 ((sPairs)[i].order==deg)))
928 {
929 if ((sPairs)[i].syz!=NULL)
930 {
931 j = k-1;
932 while ((j>=0) && (res->m[j]!=NULL) &&
933 ((sPairs)[i].syz!=NULL))
934 {
935 if (pLmDivisibleBy(res->m[j],(sPairs)[i].syz))
936 {
937 (sPairs)[i].syz =
938 ksOldSpolyRed(res->m[j],(sPairs)[i].syz);
939 //sySPolyRed((sPairs)[i].syz,res->m[j]);
940 j = k-1;
941 }
942 else
943 {
944 j--;
945 }
946 }
947 if ((sPairs)[i].syz != NULL)
948 {
949 if (k==IDELEMS(res))
950 {
951 syEnlargeFields(syzstr,index);
952 res=syzstr->res[index];
953 }
954 if (TEST_OPT_DEBUG)
955 {
956 if ((sPairs)[i].isNotMinimal==NULL)
957 {
958 PrintLn();
959 PrintS("minimal generator: ");pWrite((syzstr->resPairs[index-1])[i].syz);
960 PrintS("comes from: ");pWrite((syzstr->resPairs[index-1])[i].p1);
961 PrintS("and: ");pWrite((syzstr->resPairs[index-1])[i].p2);
962 }
963 }
964 //res->m[k] = (sPairs)[i].syz;
965 res->m[k] = syRedtail((sPairs)[i].syz,syzstr,index);
966 (sPairs)[i].syzind = k;
967 syzstr->elemLength[index][k] = pLength((sPairs)[i].syz);
968 pNorm(res->m[k]);
969 // (sPairs)[i].syz = NULL;
970 k++;
971 if (syOrder(res->m[k-1],syzstr,index,k))
973 //euler++;
974 }
975 else
976 (sPairs)[i].syzind = -1;
977 }
978 i++;
979 }
980}
981
982/*3
983* puts a pair into the right place in resPairs
984*/
985void syEnterPair(SSet sPairs, SObject * so, int * sPlength,int /*index*/)
986{
987 int ll,k,no=(*so).order,sP=*sPlength,i;
988
989 if ((sP==0) || (sPairs[sP-1].order<=no))
990 ll = sP;
991 else if (sP==1)
992 ll = 0;
993 else
994 {
995 int an=0,en=sP-1;
996 loop
997 {
998 if (an>=en-1)
999 {
1000 if ((sPairs[an].order<=no) && (sPairs[an+1].order>no))
1001 {
1002 ll = an+1;
1003 break;
1004 }
1005 else if ((sPairs[en].order<=no) && (sPairs[en+1].order>no))
1006 {
1007 ll = en+1;
1008 break;
1009 }
1010 else if (sPairs[an].order>no)
1011 {
1012 ll = an;
1013 break;
1014 }
1015 else
1016 {
1017 PrintS("Hier ist was faul!\n");
1018 ll=0; /*avoid compiler warning*/
1019 break;
1020 }
1021 }
1022 i=(an+en) / 2;
1023 if (sPairs[i].order <= no)
1024 an=i;
1025 else
1026 en=i;
1027 }
1028 }
1029 for (k=(*sPlength);k>ll;k--)
1030 {
1031 syCopyPair(&sPairs[k-1],&sPairs[k]);
1032 }
1033 syCopyPair(so,&sPairs[ll]);
1034 (*sPlength)++;
1035}
1036void syEnterPair(syStrategy syzstr, SObject * so, int * sPlength,int index)
1037{
1038 int ll;
1039
1040 if (*sPlength>=(*syzstr->Tl)[index])
1041 {
1042 SSet temp = (SSet)omAlloc0(((*syzstr->Tl)[index]+16)*sizeof(SObject));
1043 for (ll=0;ll<(*syzstr->Tl)[index];ll++)
1044 {
1045 temp[ll].p = (syzstr->resPairs[index])[ll].p;
1046 temp[ll].p1 = (syzstr->resPairs[index])[ll].p1;
1047 temp[ll].p2 = (syzstr->resPairs[index])[ll].p2;
1048 temp[ll].syz = (syzstr->resPairs[index])[ll].syz;
1049 temp[ll].lcm = (syzstr->resPairs[index])[ll].lcm;
1050 temp[ll].ind1 = (syzstr->resPairs[index])[ll].ind1;
1051 temp[ll].ind2 = (syzstr->resPairs[index])[ll].ind2;
1052 temp[ll].syzind = (syzstr->resPairs[index])[ll].syzind;
1053 temp[ll].order = (syzstr->resPairs[index])[ll].order;
1054 temp[ll].isNotMinimal = (syzstr->resPairs[index])[ll].isNotMinimal;
1055 temp[ll].length = (syzstr->resPairs[index])[ll].length;
1056 temp[ll].reference = (syzstr->resPairs[index])[ll].reference;
1057 }
1058 if (syzstr->resPairs[index] != NULL) // OB: ?????
1059 omFreeSize((ADDRESS)syzstr->resPairs[index],(*syzstr->Tl)[index]*sizeof(SObject));
1060 (*syzstr->Tl)[index] += 16;
1061 syzstr->resPairs[index] = temp;
1062 }
1063 syEnterPair(syzstr->resPairs[index],so,sPlength,index);
1064}
1065
1066/*3
1067* computes pairs from the new elements (beginning with the element newEl)
1068* in the module index
1069*/
1070static void syCreateNewPairs(syStrategy syzstr, int index, int newEl)
1071{
1072 SSet temp;
1073 SObject tso;
1074 int i,ii,j,k=IDELEMS(syzstr->res[index]),l=(*syzstr->Tl)[index],ll;
1075 int first,pos,jj,j1;
1076 int * bci=syzstr->backcomponents[index];
1077 poly p,q;
1078 polyset rs=syzstr->res[index]->m,nPm;
1079
1080
1081 while ((k>0) && (rs[k-1]==NULL)) k--;
1082 if (newEl>=k) return;
1083
1084 long * ShiftedComponents = syzstr->ShiftedComponents[index];
1085 int* Components = syzstr->truecomponents[index];
1086
1087 ideal nP=idInit(k,syzstr->res[index]->rank);
1088 nPm=nP->m;
1089 while ((l>0) && ((syzstr->resPairs[index])[l-1].p1==NULL)) l--;
1090 for (j=newEl;j<k;j++)
1091 {
1092 q = rs[j];
1093 first = syzstr->Firstelem[index-1][pGetComp(q)]-1;
1094 pos = first+syzstr->Howmuch[index-1][pGetComp(q)];
1095 for (i=first;i<pos;i++)
1096 {
1097 jj = bci[i];
1098 if (jj>=j) break;
1099 p = pOne();
1100 pLcm(rs[jj],q,p);
1101 pSetComp(p,j+1);
1102 p_Setm_Syz(p, currRing, Components, ShiftedComponents);
1103 ii = first;
1104 loop
1105 {
1106 j1 = bci[ii];
1107 if (nPm[j1]!=NULL)
1108 {
1109 if (pLmDivisibleByNoComp(nPm[j1],p))
1110 {
1111 pDelete(&p);
1112 break;
1113 }
1114 else if (pLmDivisibleByNoComp(p,nPm[j1]))
1115 {
1116 pDelete(&(nPm[j1]));
1117 //break;
1118 }
1119 }
1120 ii++;
1121 if (ii>=pos) break;
1122 }
1123 if (p!=NULL)
1124 {
1125 nPm[jj] = p;
1126 }
1127 }
1128 for (i=first;i<pos;i++)
1129 {
1130 ii = bci[i];
1131 if (nPm[ii]!=NULL)
1132 {
1133 if (l>=(*syzstr->Tl)[index])
1134 {
1135 temp = (SSet)omAlloc0(((*syzstr->Tl)[index]+16)*sizeof(SObject));
1136 for (ll=0;ll<(*syzstr->Tl)[index];ll++)
1137 {
1138 temp[ll].p = (syzstr->resPairs[index])[ll].p;
1139 temp[ll].p1 = (syzstr->resPairs[index])[ll].p1;
1140 temp[ll].p2 = (syzstr->resPairs[index])[ll].p2;
1141 temp[ll].syz = (syzstr->resPairs[index])[ll].syz;
1142 temp[ll].lcm = (syzstr->resPairs[index])[ll].lcm;
1143 temp[ll].ind1 = (syzstr->resPairs[index])[ll].ind1;
1144 temp[ll].ind2 = (syzstr->resPairs[index])[ll].ind2;
1145 temp[ll].syzind = (syzstr->resPairs[index])[ll].syzind;
1146 temp[ll].order = (syzstr->resPairs[index])[ll].order;
1147 temp[ll].isNotMinimal = (syzstr->resPairs[index])[ll].isNotMinimal;
1148 }
1149 if (syzstr->resPairs[index] != NULL) // OB: ????
1150 omFreeSize((ADDRESS)syzstr->resPairs[index],(*syzstr->Tl)[index]*sizeof(SObject));
1151 (*syzstr->Tl)[index] += 16;
1152 syzstr->resPairs[index] = temp;
1153 }
1154 tso.lcm = p = nPm[ii];
1155 nPm[ii] = NULL;
1156 tso.order = pTotaldegree(p);
1157 if ((syzstr->cw!=NULL) && (index>0) && (pGetComp(q)>0))
1158 {
1159 int ii=index-1,jj=pGetComp(q);
1160 while (ii>0)
1161 {
1162 jj = pGetComp(syzstr->res[ii]->m[jj-1]);
1163 ii--;
1164 }
1165 tso.order += (*syzstr->cw)[jj-1];
1166 }
1167 tso.p1 = rs[ii];
1168 tso.p2 = q;
1169 tso.ind1 = ii;
1170 tso.ind2 = j;
1171 tso.syzind = -1;
1172 tso.isNotMinimal = NULL;
1173 tso.p = NULL;
1174 tso.syz = NULL;
1175 syEnterPair(syzstr->resPairs[index],&tso,&l,index);
1176 }
1177 }
1178 }
1179 idDelete(&nP);
1180}
1181
1183 int *howmuch, int * actdeg, int an, int en)
1184{
1185 int newdeg=*actdeg,newindex=-1,i,t,sldeg;
1186 SSet result;
1187 SRes resPairs=syzstr->resPairs;
1188
1189 if (an>syzstr->length) return NULL;
1190 if (en>syzstr->length) en=syzstr->length;
1191 while (*index<en)
1192 {
1193 if (resPairs[*index]!=NULL)
1194 {
1195 sldeg = (*actdeg)+*index;
1196 i = 0;
1197 if (*index!=0)
1198 {
1199 while ((i<(*syzstr->Tl)[*index]))
1200 {
1201 if ((resPairs[*index])[i].lcm!=NULL)
1202 {
1203 if ((resPairs[*index])[i].order == sldeg)
1204 {
1205 result = &(resPairs[*index])[i];
1206 *howmuch =1;
1207 i++;
1208 while ((i<(*syzstr->Tl)[*index]) && ((resPairs[*index])[i].lcm!=NULL)
1209 && ((resPairs[*index])[i].order == sldeg))
1210 {
1211 i++;
1212 (*howmuch)++;
1213 }
1214 return result;
1215 }
1216 }
1217 i++;
1218 }
1219 }
1220 else
1221 {
1222 while ((i<(*syzstr->Tl)[*index]))
1223 {
1224 if ((resPairs[*index])[i].syz!=NULL)
1225 {
1226 if ((resPairs[*index])[i].order == sldeg)
1227 {
1228 result = &(resPairs[*index])[i];
1229 (*howmuch) =1;
1230 i++;
1231 while ((i<(*syzstr->Tl)[*index]) && ((resPairs[*index])[i].syz!=NULL)
1232 && ((resPairs[*index])[i].order == *actdeg))
1233 {
1234 i++;
1235 (*howmuch)++;
1236 }
1237 return result;
1238 }
1239 }
1240 i++;
1241 }
1242 }
1243 }
1244 (*index)++;
1245 }
1246 *index = an;
1247 //if (TEST_OPT_PROT) Print("(Euler:%d)",euler);
1248 while (*index<en)
1249 {
1250 if (resPairs[*index]!=NULL)
1251 {
1252 i = 0;
1253 while ((i<(*syzstr->Tl)[*index]))
1254 {
1255 t = *actdeg+*index;
1256 if (((resPairs[*index])[i].lcm!=NULL) ||
1257 ((resPairs[*index])[i].syz!=NULL))
1258 {
1259 if ((resPairs[*index])[i].order > t)
1260 t = (resPairs[*index])[i].order;
1261 }
1262 if ((t>*actdeg+*index) && ((newdeg==*actdeg) || (t<newdeg+*index)))
1263 {
1264 newdeg = t-*index;
1265 newindex = *index;
1266 break;
1267 }
1268 i++;
1269 }
1270 }
1271 (*index)++;
1272 }
1273 if (newdeg>*actdeg)
1274 {
1275 *actdeg = newdeg;
1276 *index = newindex;
1277 return syChosePairsPutIn(syzstr,index,howmuch,actdeg,an,en);
1278 }
1279 else return NULL;
1280}
1281
1282/*3
1283* FOR THE HOMOGENEOUS CASE ONLY!
1284* looks through the pair set and the given module for
1285* remaining pairs or generators to consider
1286* returns a pointer to the first pair and the number of them in the given module
1287* works with slanted degree (i.e. deg=realdeg-index)
1288*/
1289SSet syChosePairs(syStrategy syzstr, int *index, int *howmuch, int * actdeg)
1290{
1291 return syChosePairsPutIn(syzstr,index,howmuch,actdeg,0,syzstr->length);
1292}
1293
1294#if 0
1295// unused
1296/*3
1297* FOR THE INHOMOGENEOUS CASE ONLY!
1298* looks through the pair set and the given module for
1299* remaining pairs or generators to consider
1300* returns a pointer to the first pair and the number of them in the given module
1301* works with slanted degree (i.e. deg=realdeg-index)
1302* looks first through the 0 and 1 module then through the other
1303*/
1304static SSet syChosePairsIH(syStrategy syzstr, int *index,
1305 int *howmuch, int * actdeg, int mindeg)
1306{
1308
1309 result = syChosePairsPutIn(syzstr,index,howmuch,actdeg,0,2);
1310 if (result == NULL)
1311 {
1312 *actdeg = mindeg;
1313 result = syChosePairsPutIn(syzstr,index,howmuch,actdeg,2,syzstr->length);
1314 }
1315 return result;
1316}
1317#endif
1318
1319/*3
1320* looks through the pair set and the given module for
1321* remaining pairs or generators to consider
1322* returns a pointer to the first pair and the number of them in the given module
1323* works deg by deg
1324*/
1325/*
1326*static SSet syChosePairs1(SRes resPairs,intvec * Tl, int *index, int *howmuch,
1327* int length,int * actdeg)
1328*{
1329* int newdeg=*actdeg,newindex=-1,i,t;
1330* SSet result;
1331*
1332* while (*index>=0)
1333* {
1334* if (resPairs[*index]!=NULL)
1335* {
1336* i = 0;
1337* if (*index!=0)
1338* {
1339* while ((i<(*Tl)[*index]))
1340* {
1341* if ((resPairs[*index])[i].lcm!=NULL)
1342* {
1343* if (pGetOrder((resPairs[*index])[i].lcm) == *actdeg)
1344* {
1345* result = &(resPairs[*index])[i];
1346* *howmuch =1;
1347* i++;
1348* while ((i<(*Tl)[*index]) && ((resPairs[*index])[i].lcm!=NULL)
1349* && (pGetOrder((resPairs[*index])[i].lcm) == *actdeg))
1350* {
1351* i++;
1352* (*howmuch)++;
1353* }
1354* return result;
1355* }
1356* }
1357* i++;
1358* }
1359* }
1360* else
1361* {
1362* while ((i<(*Tl)[*index]))
1363* {
1364* if ((resPairs[*index])[i].syz!=NULL)
1365* {
1366* if ((resPairs[*index])[i].order == *actdeg)
1367* {
1368* result = &(resPairs[*index])[i];
1369* (*howmuch) =1;
1370* i++;
1371* while ((i<(*Tl)[*index]) && ((resPairs[*index])[i].syz!=NULL)
1372* && ((resPairs[*index])[i].order == *actdeg))
1373* {
1374* i++;
1375* (*howmuch)++;
1376* }
1377* return result;
1378* }
1379* }
1380* i++;
1381* }
1382* }
1383* }
1384* (*index)--;
1385* }
1386* *index = length-1;
1387* while (*index>=0)
1388* {
1389* if (resPairs[*index]!=NULL)
1390* {
1391* i = 0;
1392* while ((i<(*Tl)[*index]))
1393* {
1394* t = *actdeg;
1395* if ((resPairs[*index])[i].lcm!=NULL)
1396* {
1397* if (pGetOrder((resPairs[*index])[i].lcm) > *actdeg)
1398* t = pGetOrder((resPairs[*index])[i].lcm);
1399* }
1400* else if ((resPairs[*index])[i].syz!=NULL)
1401* {
1402* if ((resPairs[*index])[i].order > *actdeg)
1403* t = (resPairs[*index])[i].order;
1404* }
1405* if ((t>*actdeg) && ((newdeg==*actdeg) || (t<newdeg)))
1406* {
1407* newdeg = t;
1408* newindex = *index;
1409* break;
1410* }
1411* i++;
1412* }
1413* }
1414* (*index)--;
1415* }
1416* if (newdeg>*actdeg)
1417* {
1418* *actdeg = newdeg;
1419* *index = newindex;
1420* return syChosePairs1(resPairs,Tl,index,howmuch,length,actdeg);
1421* }
1422* else return NULL;
1423*}
1424*/
1425#if 0 /* only debugging */
1426/*3
1427* statistics of the resolution
1428*/
1429static void syStatistics(resolvente res,int length)
1430{
1431 int i,j=1,k;
1432 long deg = 0;
1433
1434 PrintLn();
1435 while ((j<length) && (res[j]!=NULL))
1436 {
1437 Print("In module %d: \n",j);
1438 k = 0;
1439 while ((k<IDELEMS(res[j])) && (res[j]->m[k]!=NULL))
1440 {
1441 i = 1;
1442 deg = pGetOrder(res[j]->m[k]);
1443 k++;
1444 while ((k<IDELEMS(res[j])) && (res[j]->m[k]!=NULL) &&
1445 (pGetOrder(res[j]->m[k])==deg))
1446 {
1447 i++;
1448 k++;
1449 }
1450 Print("%d elements of degree %ld\n",i,deg);
1451 }
1452 j++;
1453 }
1454}
1455#endif
1456
1457/*3
1458* initialize a module
1459*/
1460int syInitSyzMod(syStrategy syzstr, int index, int init)
1461{
1462 int result;
1463
1464 if (syzstr->res[index]==NULL)
1465 {
1466 syzstr->res[index] = idInit(init-1,1);
1467 syzstr->truecomponents[index] = (int*)omAlloc0(init*sizeof(int));
1468 syzstr->ShiftedComponents[index] = (long*)omAlloc0(init*sizeof(long));
1469 if (index==0)
1470 {
1471 for (int i=0;i<init;i++)
1472 {
1473 syzstr->truecomponents[0][i] = i;
1474 syzstr->ShiftedComponents[0][i] = (i)*SYZ_SHIFT_BASE;
1475 }
1476 }
1477 syzstr->backcomponents[index] = (int*)omAlloc0(init*sizeof(int));
1478 syzstr->Howmuch[index] = (int*)omAlloc0(init*sizeof(int));
1479 syzstr->Firstelem[index] = (int*)omAlloc0(init*sizeof(int));
1480 syzstr->elemLength[index] = (int*)omAlloc0(init*sizeof(int));
1481 syzstr->orderedRes[index] = idInit(init-1,1);
1482 syzstr->sev[index] = (unsigned long*) omAlloc0(init*sizeof(unsigned long));
1483 result = 0;
1484 }
1485 else
1486 {
1487 result = IDELEMS(syzstr->res[index]);
1488 while ((result>0) && (syzstr->res[index]->m[result-1]==NULL)) result--;
1489 }
1490 return result;
1491}
1492
1493/*3
1494* deletes a resolution
1495*/
1496void syKillComputation(syStrategy syzstr, ring r)
1497{
1498 if (syzstr->references>0)
1499 {
1500 (syzstr->references)--;
1501 }
1502 else
1503 {
1504 int i,j;
1505 if (syzstr->minres!=NULL)
1506 {
1507 for (i=0;i<syzstr->length;i++)
1508 {
1509 if (syzstr->minres[i]!=NULL)
1510 {
1511 id_Delete(&(syzstr->minres[i]),r);
1512 }
1513 }
1514 omFreeSize((ADDRESS)syzstr->minres,(syzstr->length+1)*sizeof(ideal));
1515 }
1516 if (syzstr->fullres!=NULL)
1517 {
1518 for (i=0;i<syzstr->length;i++)
1519 {
1520 if (syzstr->fullres[i]!=NULL)
1521 {
1522 id_Delete(&(syzstr->fullres[i]),r);
1523 }
1524 }
1525 omFreeSize((ADDRESS)syzstr->fullres,(syzstr->length+1)*sizeof(ideal));
1526 }
1527 if (syzstr->weights!=NULL)
1528 {
1529 for (i=0;i<syzstr->length;i++)
1530 {
1531 if (syzstr->weights[i]!=NULL)
1532 {
1533 delete syzstr->weights[i];
1534 }
1535 }
1536 omFreeSize((ADDRESS)syzstr->weights,syzstr->length*sizeof(intvec*));
1537 }
1538
1539 ring sr=syzstr->syRing;
1540 if (sr==NULL) sr=r;
1541
1542 if (syzstr->resPairs!=NULL)
1543 {
1544 for (i=0;i<syzstr->length;i++)
1545 {
1546 for (j=0;j<(*syzstr->Tl)[i];j++)
1547 {
1548 if ((syzstr->resPairs[i])[j].lcm!=NULL)
1549 p_Delete(&((syzstr->resPairs[i])[j].lcm),sr);
1550 if ((i>0) && ((syzstr->resPairs[i])[j].syz!=NULL))
1551 p_Delete(&((syzstr->resPairs[i])[j].syz),sr);
1552 }
1553 if (syzstr->orderedRes[i]!=NULL)
1554 {
1555 for (j=0;j<IDELEMS(syzstr->orderedRes[i]);j++)
1556 {
1557 syzstr->orderedRes[i]->m[j] = NULL;
1558 }
1559 id_Delete(&(syzstr->orderedRes[i]),sr);
1560 }
1561 if (syzstr->truecomponents[i]!=NULL)
1562 {
1563 omFreeSize((ADDRESS)syzstr->truecomponents[i],(IDELEMS(syzstr->res[i])+1)*sizeof(int));
1564 syzstr->truecomponents[i]=NULL;
1565 omFreeSize((ADDRESS)syzstr->ShiftedComponents[i],(IDELEMS(syzstr->res[i])+1)*sizeof(long));
1566 syzstr->ShiftedComponents[i]=NULL;
1567 }
1568 if (syzstr->backcomponents[i]!=NULL)
1569 {
1570 omFreeSize((ADDRESS)syzstr->backcomponents[i],(IDELEMS(syzstr->res[i])+1)*sizeof(int));
1571 syzstr->backcomponents[i]=NULL;
1572 }
1573 if (syzstr->Howmuch[i]!=NULL)
1574 {
1575 omFreeSize((ADDRESS)syzstr->Howmuch[i],(IDELEMS(syzstr->res[i])+1)*sizeof(int));
1576 syzstr->Howmuch[i]=NULL;
1577 }
1578 if (syzstr->Firstelem[i]!=NULL)
1579 {
1580 omFreeSize((ADDRESS)syzstr->Firstelem[i],(IDELEMS(syzstr->res[i])+1)*sizeof(int));
1581 syzstr->Firstelem[i]=NULL;
1582 }
1583 if (syzstr->elemLength[i]!=NULL)
1584 {
1585 omFreeSize((ADDRESS)syzstr->elemLength[i],(IDELEMS(syzstr->res[i])+1)*sizeof(int));
1586 syzstr->elemLength[i]=NULL;
1587 }
1588 if (syzstr->res[i]!=NULL)
1589 {
1590 for (j=0;j<IDELEMS(syzstr->res[i]);j++)
1591 {
1592 if (syzstr->res[i]->m[j]!=NULL)
1593 p_Delete(&(syzstr->res[i]->m[j]),sr);
1594 }
1595 }
1596 if ((syzstr->hilb_coeffs!=NULL)
1597 && (syzstr->hilb_coeffs[i]!=NULL))
1598 delete syzstr->hilb_coeffs[i];
1599 if (syzstr->sev[i] != NULL)
1600 omFreeSize((ADDRESS)syzstr->sev[i], (IDELEMS(syzstr->res[i])+1)*sizeof(unsigned long));
1601 id_Delete(&(syzstr->res[i]),sr);
1602 if (syzstr->resPairs[i] != NULL) // OB: ????
1603 omFreeSize((ADDRESS)syzstr->resPairs[i],(*syzstr->Tl)[i]*sizeof(SObject));
1604 }
1605 omFreeSize((ADDRESS)syzstr->resPairs,syzstr->length*sizeof(SObject*));
1606 omFreeSize((ADDRESS)syzstr->res,(syzstr->length+1)*sizeof(ideal));
1607 omFreeSize((ADDRESS)syzstr->orderedRes,(syzstr->length+1)*sizeof(ideal));
1608 omFreeSize((ADDRESS)syzstr->elemLength,(syzstr->length+1)*sizeof(int*));
1609 omFreeSize((ADDRESS)syzstr->truecomponents,(syzstr->length+1)*sizeof(int*));
1610 omFreeSize((ADDRESS)syzstr->ShiftedComponents,(syzstr->length+1)*sizeof(long*));
1611 if (syzstr->sev != NULL)
1612 omFreeSize(((ADDRESS)syzstr->sev), (syzstr->length+1)*sizeof(unsigned long*));
1613 omFreeSize((ADDRESS)syzstr->backcomponents,(syzstr->length+1)*sizeof(int*));
1614 omFreeSize((ADDRESS)syzstr->Howmuch,(syzstr->length+1)*sizeof(int*));
1615 omFreeSize((ADDRESS)syzstr->Firstelem,(syzstr->length+1)*sizeof(int*));
1616 if (syzstr->hilb_coeffs!=NULL)
1617 omFreeSize((ADDRESS)syzstr->hilb_coeffs,(syzstr->length+1)*sizeof(intvec*));
1618 }
1619 if (syzstr->cw!=NULL)
1620 delete syzstr->cw;
1621 if (syzstr->betti!=NULL)
1622 delete syzstr->betti;
1623 if (syzstr->resolution!=NULL)
1624 delete syzstr->resolution;
1625 if (syzstr->Tl!=NULL)
1626 delete syzstr->Tl;
1627 if ((syzstr->syRing != NULL) && (syzstr->syRing != r))
1628 {
1629 if(syzstr->syRing->typ[1].ord_typ == ro_syzcomp)
1630 rChangeSComps(NULL, NULL, 0, syzstr->syRing);
1631
1632 rDelete(syzstr->syRing);
1633 }
1634 omFreeSize((ADDRESS)syzstr, sizeof(ssyStrategy));
1635 }
1636}
1637
1638/*2
1639* divides out the weight monomials (given by the Schreyer-ordering)
1640* from the LaScala-resolution
1641*/
1643 syStrategy syzstr,BOOLEAN toCopy,resolvente totake)
1644{
1645 int i,j,l;
1646 polyset ri1;
1647 resolvente fullres;
1648 ring origR=syzstr->syRing;
1649 fullres = (resolvente)omAlloc0((length+1)*sizeof(ideal));
1650 if (totake==NULL)
1651 totake = res;
1652 for (i=length-1;i>0;i--)
1653 {
1654 if (res[i]!=NULL)
1655 {
1656 if (i>1)
1657 {
1658 j = IDELEMS(res[i-1]);
1659 while ((j>0) && (res[i-1]->m[j-1]==NULL)) j--;
1660 fullres[i-1] = idInit(IDELEMS(res[i]),j);
1661 ri1 = totake[i-1]->m;
1662 for (j=IDELEMS(res[i])-1;j>=0;j--)
1663 {
1665 poly p = res[i]->m[j];
1666 while (p!=NULL)
1667 {
1668 poly tq;
1669 if (toCopy)
1670 {
1671 if (origR!=NULL)
1672 tq = prHeadR(p,origR, currRing);
1673 else
1674 tq = pHead(p);
1675 pIter(p);
1676 }
1677 else
1678 {
1679 res[i]->m[j] = NULL;
1680 if (origR!=NULL)
1681 {
1682 poly pp=p;
1683 pIter(p);
1684 pNext(pp)=NULL;
1685 tq = prMoveR(pp, origR, currRing);
1686 }
1687 else
1688 {
1689 tq = p;
1690 pIter(p);
1691 pNext(tq) = NULL;
1692 }
1693 }
1694// pWrite(tq);
1695 pTest(tq);
1696 for (l=(currRing->N);l>0;l--)
1697 {
1698 if (origR!=NULL)
1699 pSubExp(tq,l, p_GetExp(ri1[pGetComp(tq)-1],l,origR));
1700 else
1701 pSubExp(tq,l, pGetExp(ri1[pGetComp(tq)-1],l));
1702 }
1703 pSetm(tq);
1704 pTest(tq);
1705 sBucket_Add_m(bucket,tq);
1706 }
1707 int l_dummy;
1708 sBucketClearMerge(bucket, &(fullres[i-1]->m[j]), &l_dummy);
1709 sBucketDestroy(&bucket);
1710 }
1711 }
1712 else
1713 {
1714 if (origR!=NULL)
1715 {
1716 fullres[i-1] = idInit(IDELEMS(res[i]),res[i]->rank);
1717 for (j=IDELEMS(res[i])-1;j>=0;j--)
1718 {
1719 if (toCopy)
1720 fullres[i-1]->m[j] = prCopyR(res[i]->m[j], origR, currRing);
1721 else
1722 {
1723 fullres[i-1]->m[j] = prMoveR(res[i]->m[j], origR, currRing);
1724 res[i]->m[j] = NULL;
1725 }
1726 }
1727 }
1728 else
1729 {
1730 if (toCopy)
1731 fullres[i-1] = idCopy(res[i]);
1732 else
1733 {
1734 fullres[i-1] = res[i];
1735 res[i] = NULL;
1736 }
1737 }
1738 for (j=IDELEMS(fullres[i-1])-1;j>=0;j--)
1739 fullres[i-1]->m[j] = pSortCompCorrect(fullres[i-1]->m[j]);
1740 }
1741 if (!toCopy)
1742 {
1743 if (res[i]!=NULL) idDelete(&res[i]);
1744 }
1745 }
1746 }
1747 if (!toCopy)
1748 omFreeSize((ADDRESS)res,(length+1)*sizeof(ideal));
1749 //syzstr->length = length;
1750 return fullres;
1751}
1752
1753/*3
1754* read out the Betti numbers from resolution
1755* (if not LaScala calls the traditional Betti procedure)
1756*/
1757intvec * syBettiOfComputation(syStrategy syzstr, BOOLEAN minim,int * row_shift,
1758 intvec* weights)
1759{
1760 int dummy;
1761 BOOLEAN std_weights=TRUE;
1762 if ((weights!=NULL)
1763 && (syzstr->betti!=NULL)
1764 && (syzstr->weights!=NULL) && (syzstr->weights[0]!=NULL))
1765 {
1766 int i;
1767 for(i=weights->length()-1; i>=0; i--)
1768 {
1769 //Print("test %d: %d - %d\n",i,(*weights)[i], (*(syzstr->weights[0]))[i]);
1770 if ((*weights)[i]!=(*(syzstr->weights[0]))[i])
1771 {
1772 std_weights=FALSE;
1773 break;
1774 }
1775 }
1776 }
1777 if ((syzstr->betti!=NULL)
1778 && (std_weights))
1779 {
1780 if (minim || (syzstr->resPairs!=NULL))
1781 return ivCopy(syzstr->betti);
1782 }
1783
1784 resolvente fullres = syzstr->fullres;
1785 resolvente minres = syzstr->minres;
1786 const int length = syzstr->length;
1787
1788 if ((fullres==NULL) && (minres==NULL))
1789 {
1790 if (syzstr->hilb_coeffs==NULL)
1791 { // LA SCALA
1792 fullres = syReorder(syzstr->res, length, syzstr);
1793 }
1794 else
1795 { // HRES
1796 minres = syReorder(syzstr->orderedRes, length, syzstr);
1797 syKillEmptyEntres(minres, length);
1798 }
1799 }
1800
1802
1803 if (fullres!=NULL)
1804 result = syBetti(fullres,length,&dummy,weights,minim,row_shift);
1805 else
1806 result = syBetti(minres,length,&dummy,weights,minim,row_shift);
1807
1808
1809 return result; /// Don't change the syzstr???
1810
1811 // TODO: cleanup these!
1812 if( fullres != NULL && syzstr->fullres == NULL )
1813 syzstr->fullres = fullres;
1814 if( minres != NULL && syzstr->minres == NULL )
1815 syzstr->minres = minres;
1816
1817 if ((result!=NULL)
1818 && ((minim) || (syzstr->resPairs!=NULL))
1819 && std_weights
1820 && (syzstr->betti==NULL))
1821 {
1822 syzstr->betti = ivCopy(result); // cache the result...
1823 }
1824
1825 return result;
1826}
1827
1828/*3
1829* computes the real length of the resolution
1830*/
1832{
1833 resolvente r=syzstr->res;
1834 if (r==NULL)
1835 r = syzstr->fullres;
1836 if (r==NULL)
1837 r = syzstr->minres;
1838 if (r==NULL)
1839 {
1840 WerrorS("No resolution found");
1841 return 0;
1842 }
1843 int i=syzstr->length;
1844 while ((i>0) && (r[i-1]==NULL)) i--;
1845 return i;
1846}
1847
1848/*3
1849* computes the cohomological dimension of res[1]
1850*/
1852{
1853 int i,l;
1854 if (syzstr->resPairs!=NULL)
1855 {
1856 SRes rP=syzstr->resPairs;
1857
1858 l = syzstr->length;
1859 while ((l>0) && (rP[l-1]==NULL)) l--;
1860 if (l==0) return -1;
1861 l--;
1862 while (l>=0)
1863 {
1864 i = 0;
1865 while ((i<(*syzstr->Tl)[l]) &&
1866 ((rP[l][i].lcm!=NULL) || (rP[l][i].syz!=NULL)) &&
1867 (rP[l][i].isNotMinimal!=NULL))
1868 {
1869 i++;
1870 }
1871 if ((i<(*syzstr->Tl)[l]) &&
1872 ((rP[l][i].lcm!=NULL) || (rP[l][i].syz!=NULL)) &&
1873 (rP[l][i].isNotMinimal==NULL))
1874 return l;
1875 l--;
1876 }
1877 return l;
1878 }
1879 else
1880 return sySize(syzstr);
1881}
1882
1883/*3
1884* copies the resolution (by increment the reference counter)
1885*/
1887{
1888 syStrategy result=syzstr;
1889 (result->references)++;
1890 return result;
1891}
1892
1893/*2
1894* local print procedure used in syPrint
1895*/
1896static void syPrintEmptySpaces(int i)
1897{
1898 if (i!=0)
1899 {
1900 PrintS(" ");
1902 }
1903}
1904
1905/*2
1906* local print procedure used in syPrint
1907*/
1908static void syPrintEmptySpaces1(int i)
1909{
1910 if (i!=0)
1911 {
1912 PrintS(" ");
1914 }
1915}
1916
1917/*2
1918* local print procedure used in syPrint
1919*/
1920static int syLengthInt(int i)
1921{
1922 int j=0;
1923
1924 if (i==0) return 1;
1925 while (i!=0)
1926 {
1927 j++;
1928 i = i/10;
1929 }
1930 return j;
1931}
1932
1933/*3
1934* prints the resolution as sequence of free modules
1935*/
1936void syPrint(syStrategy syzstr, const char *sn)
1937{
1938 if ( (syzstr->resPairs==NULL) &&
1939 (syzstr->fullres==NULL) &&
1940 (syzstr->minres==NULL) &&
1941 (syzstr->resolution == NULL) )
1942 {
1943 PrintS("No resolution defined\n");
1944 return;
1945 }
1946
1947 intvec* resolution = syzstr->resolution;
1948
1949 if (resolution==NULL)
1950 {
1951 if (syzstr->resPairs!=NULL)
1952 {
1953 resolution = new intvec(syzstr->length+1);
1954 SRes rP = syzstr->resPairs;
1955// assume(idRankFreeModule(syzstr->res[1], (syzstr->syRing != NULL ? syzstr->syRing : currRing))==syzstr->res[1]->rank);
1956 (*resolution)[0] = syzstr->res[1]->rank;
1957 int k=0;
1958 while ((k<syzstr->length) && (rP[k]!=NULL))
1959 {
1960 int j = 0;
1961 while ((j<(*syzstr->Tl)[k]) &&
1962 ((rP[k][j].lcm!=NULL) || (rP[k][j].syz!=NULL)))
1963 {
1964 if (rP[k][j].isNotMinimal==NULL)
1965 ((*resolution)[k+1])++;
1966 j++;
1967 }
1968 k++;
1969 }
1970 }
1971 else
1972 {
1973 resolution = new intvec(syzstr->length+2);
1974 resolvente rr;
1975 if (syzstr->minres!=NULL)
1976 rr = syzstr->minres;
1977 else
1978 rr = syzstr->fullres;
1979 (*resolution)[0]
1980 = si_max(1,(int)id_RankFreeModule(rr[0],
1981 (syzstr->syRing != NULL ? syzstr->syRing : currRing)));
1982 int k=0;
1983 while ((k<syzstr->length) && (rr[k]!=NULL))
1984 {
1985 (*resolution)[k+1] = idElem(rr[k]);
1986 k++;
1987 }
1988 }
1989 }
1990
1991 int sl=strlen(sn);
1993 int k = 0;
1994 loop
1995 {
1996 if ((k>=resolution->length()) || ((*resolution)[k]==0))
1997 break;
1998 Print("%d",(*resolution)[k]);
1999 syPrintEmptySpaces1(sl+5);
2000 k++;
2001 }
2002 PrintLn();
2003 k = 0;
2004 loop
2005 {
2006 if ((k>=resolution->length()) || ((*resolution)[k]==0))
2007 break;
2008 PrintS(sn);
2009 if (((k+1)>=resolution->length()) || ((*resolution)[(k+1)]==0))
2010 break;
2011 PrintS(" <-- ");
2012 syPrintEmptySpaces((*resolution)[k]);
2013 k++;
2014 }
2015 PrintS("\n\n");
2016 k = 0;
2017 loop
2018 {
2019 if ((k>=resolution->length()) || ((*resolution)[k]==0))
2020 break;
2021 Print("%d",k);
2022 syPrintEmptySpaces1(sl+5+syLengthInt((*resolution)[k])-
2023 syLengthInt(k));
2024 k++;
2025 }
2026 PrintLn();
2027 if (syzstr->minres==NULL)
2028 {
2029 PrintS("resolution not minimized yet\n");
2030 }
2031
2032 if (syzstr->resolution == NULL) syzstr->resolution = resolution;
2033}
2034
2035#if 0
2036// unused
2037/*2
2038* deleting all monomials the component of which correspond
2039* to non-minimal generators
2040*/
2041static poly syStripOut(poly p,intvec * toStrip)
2042{
2043 if (toStrip==NULL) return p;
2044 poly pp=p;
2045
2046 while ((pp!=NULL) && ((*toStrip)[pGetComp(pp)]!=0))
2047 pLmDelete(&pp);
2048 p = pp;
2049 if (pp!=NULL)
2050 {
2051 while (pNext(pp)!=NULL)
2052 {
2053 if ((*toStrip)[pGetComp(pNext(pp))]!=0)
2054 pLmDelete(&pNext(pp));
2055 else
2056 pIter(pp);
2057 }
2058 }
2059 return p;
2060}
2061#endif
2062
2063/*2
2064* copies only those monomials the component of which correspond
2065* to minimal generators
2066*/
2067static poly syStripOutCopy(poly p,intvec * toStrip)
2068{
2069 if (toStrip==NULL) return pCopy(p);
2070 poly result=NULL,pp;
2071
2072 while (p!=NULL)
2073 {
2074 if ((*toStrip)[pGetComp(p)]==0)
2075 {
2076 if (result==NULL)
2077 {
2078 result = pp = pHead(p);
2079 }
2080 else
2081 {
2082 pNext(pp) = pHead(p);
2083 pIter(pp);
2084 }
2085 }
2086 pIter(p);
2087 }
2088 return result;
2089}
2090
2091/*2
2092* minimizes toMin
2093*/
2094#if 0 /* unused */
2095static poly syMinimizeP(int toMin,syStrategy syzstr,intvec * ordn,int index,
2096 intvec * toStrip)
2097{
2098 int ii=0,i,j,tc;
2099 poly p,pp,q=NULL,tq,pisN;
2100 SSet sPairs=syzstr->resPairs[index];
2101 poly tempStripped=NULL;
2102
2103 //pp=pCopy(syzstr->res[index+1]->m[toMin]);
2104 pp = syStripOutCopy(syzstr->res[index+1]->m[toMin],toStrip);
2105 while ((ii<ordn->length()) && ((*ordn)[ii]!=-1) &&
2106 (sPairs[(*ordn)[ii]].syzind!=toMin))
2107 {
2108 ii++;
2109 }
2110 while (ii>=0)
2111 {
2112 i = (*ordn)[ii];
2113 if (sPairs[i].isNotMinimal!=NULL)
2114 {
2115 tempStripped =
2116 syStripOutCopy(syzstr->res[index+1]->m[sPairs[i].syzind],toStrip);
2117 pisN = sPairs[i].isNotMinimal;
2118 tc = pGetComp(pisN);
2119 p = pp;
2120 while (p!=NULL)
2121 {
2122 if (pGetComp(p)==(unsigned)tc)
2123 {
2124 tq = pInit();
2125 for(j=(currRing->N); j>0; j--)
2126 pSetExp(tq,j, pGetExp(p,j)-pGetExp(pisN,j));
2127 pSetComp(tq, 0);
2128 pSetCoeff0(tq,nDiv(pGetCoeff(p),pGetCoeff(pisN)));
2129 pGetCoeff(tq) = nInpNeg(pGetCoeff(tq));
2130 pSetm(tq);
2131 q = pAdd(q,pMult_mm(pCopy(tempStripped),tq));
2132 pDelete(&tq);
2133 }
2134 pIter(p);
2135 }
2136 if (q!=NULL)
2137 {
2138 pp = pAdd(pp,q);
2139 q = NULL;
2140 }
2141 pDelete(&tempStripped);
2142 }
2143 ii--;
2144 }
2145 return pp;
2146}
2147#endif
2148
2149/*2
2150* minimizes toMin
2151*/
2152static poly syMinimizeP1(int toMin,syStrategy syzstr,intvec * ordn,int index,
2153 intvec * toStrip)
2154{
2155 int ii=0,i,tc,lp,ltS=-1;
2156 poly p,mp=NULL,pp;
2157 SSet sPairs=syzstr->resPairs[index];
2158 poly tempStripped=NULL;
2159
2160 pp = syStripOutCopy(syzstr->res[index+1]->m[toMin],toStrip);
2161 kBucketInit(syzstr->bucket,pp,-1);
2162 while ((ii<ordn->length()) && ((*ordn)[ii]!=-1) &&
2163 (sPairs[(*ordn)[ii]].syzind!=toMin))
2164 {
2165 ii++;
2166 }
2167 while (ii>=0)
2168 {
2169 i = (*ordn)[ii];
2170 if (sPairs[i].isNotMinimal!=NULL)
2171 {
2172 tempStripped =
2173 syStripOutCopy(syzstr->res[index+1]->m[sPairs[i].syzind],toStrip);
2174 tc = pGetComp(sPairs[i].isNotMinimal);
2175 int lu;
2176 pTakeOutComp(&tempStripped,tc,&p,&lu);
2177 kBucketTakeOutComp(syzstr->bucket,tc,&mp,&lp);
2178 mp = pDivideM(mp,p);
2179 while (mp!=NULL)
2180 {
2181 p = pNext(mp);
2182 pNext(mp) = NULL;
2183 ltS = -1;
2184 kBucket_Minus_m_Mult_p(syzstr->bucket,mp,tempStripped,&ltS);
2185 pDelete(&mp);
2186 mp = p;
2187 }
2188 pDelete(&mp);
2189 pDelete(&tempStripped);
2190 }
2191 ii--;
2192 }
2193 kBucketClear(syzstr->bucket,&pp,&lp);
2194 return pp;
2195}
2196
2197/*2
2198* deletes empty components after minimization
2199*/
2201{
2202 int i,j,jj,k,rj;
2203 intvec * changes;
2204 poly p;
2205 ideal ri;
2206
2207 for (i=0;i<length;i++)
2208 {
2209 ri = res[i];
2210 if (ri!=NULL)
2211 {
2212 rj = IDELEMS(ri);
2213 changes = new intvec(rj+1,1,-1);
2214 while ((rj>0) && (ri->m[rj-1]==NULL)) rj--;
2215 j = k = 0;
2216 while (j+k<rj)
2217 {
2218 if (ri->m[j+k]!=NULL)
2219 {
2220 ri->m[j] = ri->m[j+k];
2221 (*changes)[j+k+1] = j+1;
2222 j++;
2223 }
2224 else
2225 {
2226 k++;
2227 }
2228 }
2229 for (jj=j;jj<rj;jj++)
2230 ri->m[jj] = NULL;
2231 if (res[i+1]!=NULL)
2232 {
2233 ri = res[i+1];
2234 for (j=IDELEMS(ri)-1;j>=0;j--)
2235 {
2236 p = ri->m[j];
2237 while (p!=NULL)
2238 {
2239 pSetComp(p,(*changes)[pGetComp(p)]);
2240 pSetm(p);
2241 pIter(p);
2242 }
2243 }
2244 }
2245 delete changes;
2246 }
2247 }
2248}
2249
2250/*2
2251* determines the components for minimization
2252*/
2253static intvec * syToStrip(syStrategy syzstr, int index)
2254{
2255 intvec * result=NULL;
2256
2257 if ((syzstr->resPairs[index-1]!=NULL) && (!idIs0(syzstr->res[index])))
2258 {
2259 result=new intvec(IDELEMS(syzstr->res[index])+1);
2260 for (int i=(*syzstr->Tl)[index-1]-1;i>=0;i--)
2261 {
2262 if (syzstr->resPairs[index-1][i].isNotMinimal!=NULL)
2263 {
2264 (*result)[syzstr->resPairs[index-1][i].syzind+1] = 1;
2265 }
2266 }
2267 }
2268 return result;
2269}
2270
2271/*2
2272* re-computes the order of pairs during the algorithm
2273* this ensures to proceed with a triangular matrix
2274*/
2275static intvec * syOrdPairs(SSet sPairs, int length)
2276{
2277 intvec * result=new intvec(length,1,-1);
2278 int i,j=0,k=-1,l,ii;
2279
2280 loop
2281 {
2282 l = -1;
2283 for(i=0;i<length;i++)
2284 {
2285 if (sPairs[i].syzind>k)
2286 {
2287 if (l==-1)
2288 {
2289 l = sPairs[i].syzind;
2290 ii = i;
2291 }
2292 else
2293 {
2294 if (sPairs[i].syzind<l)
2295 {
2296 l = sPairs[i].syzind;
2297 ii = i;
2298 }
2299 }
2300 }
2301 }
2302 if (l==-1) break;
2303 (*result)[j] = ii;
2304 j++;
2305 k = l;
2306 }
2307 return result;
2308}
2309
2310/*2
2311* minimizes the output of LaScala
2312*/
2314 BOOLEAN computeStd=FALSE)
2315{
2316 intvec * Strip, * ordn;
2317 resolvente tres=(resolvente)omAlloc0((syzstr->length+1)*sizeof(ideal));
2318 ring origR = currRing;
2319
2320//Print("Hier ");
2321 if (computeStd)
2322 {
2323 tres[0] = syzstr->res[1];
2324 syzstr->res[1] = idInit(IDELEMS(tres[0]),tres[0]->rank);
2325 return tres;
2326 }
2327 int i,l,index,i1;
2328 SSet sPairs;
2329
2330 assume(syzstr->syRing != NULL);
2331 rChangeCurrRing(syzstr->syRing);
2332//Print("laeufts ");
2333 syzstr->bucket = kBucketCreate(syzstr->syRing);
2334 for (index=syzstr->length-1;index>0;index--)
2335 {
2336 if (syzstr->resPairs[index]!=NULL)
2337 {
2338//Print("ideal %d: \n",index);
2342 IDELEMS(syzstr->res[index]), currRing);
2343 sPairs = syzstr->resPairs[index];
2344 Strip = syToStrip(syzstr,index);
2345 tres[index+1] = idInit(IDELEMS(syzstr->res[index+1]),syzstr->res[index+1]->rank);
2346 i1 = (*syzstr->Tl)[index];
2347//Print("i1= %d\n",i1);
2348 ordn = syOrdPairs(sPairs,i1);
2349 for (i=0;i<i1;i++)
2350 {
2351 if ((sPairs[i].isNotMinimal==NULL) && (sPairs[i].lcm!=NULL))
2352 {
2353 l = sPairs[i].syzind;
2354//Print("Minimiere Poly %d: ",l);pWrite(syzstr->res[index+1]->m[l]);
2355 tres[index+1]->m[l] =
2356 syMinimizeP1(l,syzstr,ordn,index,Strip);
2357 }
2358 }
2359 delete Strip;
2360 delete ordn;
2361 Strip = NULL;
2362 }
2363 }
2364 currcomponents = syzstr->truecomponents[0];
2367 IDELEMS(syzstr->res[0]), currRing);
2368 tres[1] = idInit(IDELEMS(syzstr->res[1]),syzstr->res[1]->rank);
2369 sPairs = syzstr->resPairs[0];
2370 for (i=(*syzstr->Tl)[0]-1;i>=0;i--)
2371 {
2372 if (sPairs[i].syzind>=0)
2373 {
2374 tres[1]->m[sPairs[i].syzind] = pCopy(syzstr->res[1]->m[sPairs[i].syzind]);
2375 }
2376 }
2377/*--- changes to the original ring------------------*/
2378 kBucketDestroy(&syzstr->bucket);
2379 if (syzstr->syRing != NULL)
2380 {
2381 rChangeCurrRing(origR);
2382 // Thomas: now make sure that all data which you need is pFetchCopied
2383 // maybe incorporate it into syReorder ??
2384 }
2385 tres = syReorder(tres,syzstr->length,syzstr,FALSE,syzstr->res);
2386 syKillEmptyEntres(tres,syzstr->length);
2387 idSkipZeroes(tres[0]);
2388 return tres;
2389}
2390
2391/*3
2392* minimizes any kind of resolution
2393*/
2395{
2396 if (syzstr->minres==NULL)
2397 {
2398 if (syzstr->resolution!=NULL)
2399 {
2400 // need to clear syzstr->resolution, as we are
2401 // now displaying the minres instead of fullres
2402 delete syzstr->resolution;
2403 syzstr->resolution=NULL;
2404 }
2405 if (syzstr->resPairs!=NULL)
2406 {
2407 if (syzstr->hilb_coeffs==NULL)
2408 {
2409 // La Scala Resolution
2410 syzstr->minres = syReadOutMinimalRes(syzstr);
2411 }
2412 else
2413 { // HRES
2414 syzstr->minres = syReorder(syzstr->orderedRes,syzstr->length,syzstr);
2415 }
2416 }
2417 else if (syzstr->fullres!=NULL)
2418 {
2419 syMinimizeResolvente(syzstr->fullres,syzstr->length,1);
2420 syzstr->minres = syzstr->fullres;
2421 syzstr->fullres = NULL;
2422 }
2423 }
2424 (syzstr->references)++;
2425 return syzstr;
2426}
2427
2428/*2
2429* implementation of LaScala's algorithm
2430* assumes that the given module is homogeneous
2431* works with slanted degree, uses syChosePairs
2432*/
2434{
2435 int i,j,actdeg=32000,index=0;
2436 int howmuch;
2437 ideal temp;
2438 SSet nextPairs;
2439 syStrategy syzstr=(syStrategy)omAlloc0(sizeof(ssyStrategy));
2440 ring origR = currRing;
2441
2442 if ((idIs0(arg)) ||
2443 ((id_RankFreeModule(arg,currRing)>0) && (!idHomModule(arg,NULL,&(syzstr->cw)))))
2444 {
2446 syzstr->length = 1;
2447 syzstr->minres[0] = idInit(1,arg->rank);
2448 return syzstr;
2449 }
2450
2451 //crit = 0;
2452 //euler = -1;
2453 syzstr->length = *length = (currRing->N)+2;
2454
2455 // Creare dp,S ring and change to it
2456 syzstr->syRing = rAssure_dp_S(origR);
2457 assume(syzstr->syRing != origR); // why?
2458 rChangeCurrRing(syzstr->syRing);
2459
2460 // set initial ShiftedComps
2461 currcomponents = (int*)omAlloc0((arg->rank+1)*sizeof(int));
2462 currShiftedComponents = (long*)omAlloc0((arg->rank+1)*sizeof(long));
2463 for (i=0;i<=arg->rank;i++)
2464 {
2466 currcomponents[i] = i;
2467 }
2469/*--- initializes the data structures---------------*/
2470 syzstr->Tl = new intvec(*length);
2471 temp = idInit(IDELEMS(arg),arg->rank);
2472 for (i=0;i<IDELEMS(arg);i++)
2473 {
2474 temp->m[i] = prCopyR( arg->m[i], origR, syzstr->syRing);
2475 if (temp->m[i]!=NULL)
2476 {
2477 j = pTotaldegree(temp->m[i]);
2478 if (j<actdeg) actdeg = j;
2479 }
2480 }
2481 idTest(temp);
2482 idSkipZeroes(temp);
2483 idTest(temp);
2484 syzstr->resPairs = syInitRes(temp,length,syzstr->Tl,syzstr->cw);
2485 omFreeSize((ADDRESS)currcomponents,(arg->rank+1)*sizeof(int));
2486 omFreeSize((ADDRESS)currShiftedComponents,(arg->rank+1)*sizeof(long));
2487 syzstr->res = (resolvente)omAlloc0((*length+1)*sizeof(ideal));
2488 syzstr->orderedRes = (resolvente)omAlloc0((*length+1)*sizeof(ideal));
2489 syzstr->elemLength = (int**)omAlloc0((*length+1)*sizeof(int*));
2490 syzstr->truecomponents = (int**)omAlloc0((*length+1)*sizeof(int*));
2491 syzstr->ShiftedComponents = (long**)omAlloc0((*length+1)*sizeof(long*));
2492 syzstr->backcomponents = (int**)omAlloc0((*length+1)*sizeof(int*));
2493 syzstr->Howmuch = (int**)omAlloc0((*length+1)*sizeof(int*));
2494 syzstr->Firstelem = (int**)omAlloc0((*length+1)*sizeof(int*));
2495 syzstr->sev = (unsigned long **) omAlloc0((*length+1)*sizeof(unsigned long *));
2496 syzstr->bucket = kBucketCreate(currRing);
2497 int len0=id_RankFreeModule(temp,currRing)+1;
2498
2499 nextPairs = syChosePairs(syzstr,&index,&howmuch,&actdeg);
2500 //if (TEST_OPT_PROT) Print("(%d,%d)",howmuch,index);
2501/*--- computes the resolution ----------------------*/
2502 while (nextPairs!=NULL)
2503 {
2504 if (TEST_OPT_PROT) Print("%d",actdeg);
2505 if (TEST_OPT_PROT) Print("(m%d)",index);
2506 if (index==0)
2507 i = syInitSyzMod(syzstr,index,len0);
2508 else
2509 i = syInitSyzMod(syzstr,index);
2510 currcomponents = syzstr->truecomponents[si_max(index-1,0)];
2513 IDELEMS(syzstr->res[si_max(index-1,0)]), currRing);
2514 j = syInitSyzMod(syzstr,index+1);
2515 if (index>0)
2516 {
2517 syRedNextPairs(nextPairs,syzstr,howmuch,index);
2518 syCompactifyPairSet(syzstr->resPairs[index],(*syzstr->Tl)[index],0);
2519 }
2520 else
2521 syRedGenerOfCurrDeg(syzstr,actdeg,index+1);
2522/*--- creates new pairs -----------------------------*/
2523 syCreateNewPairs(syzstr,index,i);
2524 if (index<(*length)-1)
2525 {
2526 syCreateNewPairs(syzstr,index+1,j);
2527 }
2528 index++;
2529 nextPairs = syChosePairs(syzstr,&index,&howmuch,&actdeg);
2530 //if (TEST_OPT_PROT) Print("(%d,%d)",howmuch,index);
2531 }
2532 if (temp!=NULL) idDelete(&temp);
2533 kBucketDestroy(&(syzstr->bucket));
2534
2535 if (origR != syzstr->syRing)
2536 rChangeCurrRing(origR);
2537
2538 if (TEST_OPT_PROT) PrintLn();
2539
2540 assume(syzstr->minres==NULL); assume(syzstr->fullres ==NULL);
2541 assume(syzstr->resPairs!=NULL); assume(syzstr->hilb_coeffs==NULL);
2542 assume(syzstr->res!=NULL);
2543
2545 syzstr->minres = syReadOutMinimalRes(syzstr);
2546 else
2547 syzstr->fullres = syReorder(syzstr->res, syzstr->length, syzstr); // buggy? (betti...?)
2548
2549 return syzstr;
2550}
2551
2552
2553
2554/*2
2555* more general implementation of LaScala's algorithm
2556* assumes that the given module is (quasi-)homogeneous
2557* works with slanted degree, uses syChosePairs
2558*/
2559syStrategy syLaScala(ideal arg, int& maxlength, intvec* weights)
2560{
2561 int i,j,actdeg=32000,index=0;
2562 int howmuch;
2563 ideal temp;
2564 SSet nextPairs;
2565 syStrategy syzstr=(syStrategy)omAlloc0(sizeof(ssyStrategy));
2566 ring origR = currRing;
2567
2568 if(weights!= NULL)
2569 syzstr->cw = new intvec(weights);
2570 else
2571 syzstr->cw = NULL;
2572
2573 if ((idIs0(arg)) ||
2574 ((id_RankFreeModule(arg,currRing)>0) && (!idTestHomModule(arg, NULL, syzstr->cw))))
2575 {
2577 syzstr->length = 1;
2578 syzstr->minres[0] = idInit(1,arg->rank);
2579 return syzstr;
2580 }
2581
2582
2583 //crit = 0;
2584 //euler = -1;
2585
2586 if( maxlength > 0 )
2587 syzstr->length = maxlength; // = (currRing->N)+2;
2588 else
2589 syzstr->length = maxlength = (currRing->N)+2;
2590
2591 // Creare dp,S ring and change to it
2592 syzstr->syRing = rAssure_dp_S(origR);
2593 assume(syzstr->syRing != origR);
2594 assume(syzstr->syRing->typ[1].ord_typ == ro_syzcomp);
2595 rChangeCurrRing(syzstr->syRing);
2596
2597 // set initial ShiftedComps
2598 currcomponents = (int*)omAlloc0((arg->rank+1)*sizeof(int));
2599 currShiftedComponents = (long*)omAlloc0((arg->rank+1)*sizeof(long));
2600 for (i=0;i<=arg->rank;i++)
2601 {
2603 currcomponents[i] = i;
2604 }
2606/*--- initializes the data structures---------------*/
2607 syzstr->Tl = new intvec(maxlength);
2608 temp = idInit(IDELEMS(arg),arg->rank);
2609 for (i=0;i<IDELEMS(arg);i++)
2610 {
2611 temp->m[i] = prCopyR( arg->m[i], origR, currRing);
2612 if (temp->m[i]!=NULL)
2613 {
2614 j = pTotaldegree(temp->m[i]);
2615 if (j<actdeg) actdeg = j;
2616 }
2617 }
2618 idTest(temp);
2619 idSkipZeroes(temp);
2620 idTest(temp);
2621 syzstr->resPairs = syInitRes(temp,&maxlength,syzstr->Tl,syzstr->cw);
2622 omFreeSize((ADDRESS)currcomponents,(arg->rank+1)*sizeof(int));
2623 omFreeSize((ADDRESS)currShiftedComponents,(arg->rank+1)*sizeof(long));
2624
2625 syzstr->res = (resolvente)omAlloc0((maxlength+1)*sizeof(ideal));
2626 syzstr->orderedRes = (resolvente)omAlloc0((maxlength+1)*sizeof(ideal));
2627 syzstr->elemLength = (int**)omAlloc0((maxlength+1)*sizeof(int*));
2628
2629 syzstr->truecomponents = (int**)omAlloc0((maxlength+1)*sizeof(int*));
2630 syzstr->ShiftedComponents = (long**)omAlloc0((maxlength+1)*sizeof(long*));
2631
2632 syzstr->backcomponents = (int**)omAlloc0((maxlength+1)*sizeof(int*));
2633 syzstr->Howmuch = (int**)omAlloc0((maxlength+1)*sizeof(int*));
2634 syzstr->Firstelem = (int**)omAlloc0((maxlength+1)*sizeof(int*));
2635 syzstr->sev = (unsigned long **) omAlloc0((maxlength+1)*sizeof(unsigned long *));
2636
2637 assume( syzstr->length == maxlength );
2638
2639 syzstr->bucket = kBucketCreate(currRing);
2640 int len0=id_RankFreeModule(temp,currRing)+1;
2641
2642 nextPairs = syChosePairs(syzstr,&index,&howmuch,&actdeg);
2643 //if (TEST_OPT_PROT) Print("(%d,%d)",howmuch,index);
2644/*--- computes the resolution ----------------------*/
2645 while (nextPairs!=NULL)
2646 {
2647 if (TEST_OPT_PROT) Print("%d",actdeg);
2648 if (TEST_OPT_PROT) Print("(m%d)",index);
2649 if (index==0)
2650 i = syInitSyzMod(syzstr,index,len0);
2651 else
2652 i = syInitSyzMod(syzstr,index);
2653 currcomponents = syzstr->truecomponents[si_max(index-1,0)];
2656 IDELEMS(syzstr->res[si_max(index-1,0)]), currRing);
2657 j = syInitSyzMod(syzstr,index+1);
2658 if (index>0)
2659 {
2660 syRedNextPairs(nextPairs,syzstr,howmuch,index);
2661 syCompactifyPairSet(syzstr->resPairs[index],(*syzstr->Tl)[index],0);
2662 }
2663 else
2664 syRedGenerOfCurrDeg(syzstr,actdeg,index+1);
2665/*--- creates new pairs -----------------------------*/
2666 syCreateNewPairs(syzstr,index,i);
2667 if (index<(maxlength-1))
2668 {
2669 syCreateNewPairs(syzstr,index+1,j);
2670 }
2671 index++;
2672 nextPairs = syChosePairs(syzstr,&index,&howmuch,&actdeg);
2673 //if (TEST_OPT_PROT) Print("(%d,%d)",howmuch,index);
2674 }
2675 if (temp!=NULL) idDelete(&temp);
2676 kBucketDestroy(&(syzstr->bucket));
2677 if (origR != syzstr->syRing)
2678 rChangeCurrRing(origR);
2679 if (TEST_OPT_PROT) PrintLn();
2680 return syzstr;
2681}
static int si_max(const int a, const int b)
Definition auxiliary.h:125
int BOOLEAN
Definition auxiliary.h:88
#define TRUE
Definition auxiliary.h:101
#define FALSE
Definition auxiliary.h:97
void * ADDRESS
Definition auxiliary.h:120
CanonicalForm FACTORY_PUBLIC pp(const CanonicalForm &)
CanonicalForm pp ( const CanonicalForm & f ).
Definition cf_gcd.cc:676
int l
Definition cfEzgcd.cc:100
int m
Definition cfEzgcd.cc:128
int i
Definition cfEzgcd.cc:132
int k
Definition cfEzgcd.cc:99
int p
Definition cfModGcd.cc:4086
int length() const
Definition intvec.h:95
static FORCE_INLINE number n_SubringGcd(number a, number b, const coeffs r)
Definition coeffs.h:669
#define Print
Definition emacs.cc:80
#define Warn
Definition emacs.cc:77
return result
CanonicalForm res
Definition facAbsFact.cc:60
int j
Definition facHensel.cc:110
static int max(int a, int b)
Definition fast_mult.cc:264
void WerrorS(const char *s)
Definition feFopen.cc:24
#define VAR
Definition globaldefs.h:5
BOOLEAN idTestHomModule(ideal m, ideal Q, intvec *w)
Definition ideals.cc:2125
#define idDelete(H)
delete an ideal
Definition ideals.h:29
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
static BOOLEAN idHomModule(ideal m, ideal Q, intvec **w)
Definition ideals.h:96
#define idTest(id)
Definition ideals.h:47
ideal idCopy(ideal A)
Definition ideals.h:60
ideal * resolvente
Definition ideals.h:18
static intvec * idSort(ideal id, BOOLEAN nolex=TRUE)
Definition ideals.h:188
static BOOLEAN length(leftv result, leftv arg)
Definition interval.cc:257
intvec * ivCopy(const intvec *o)
Definition intvec.h:146
STATIC_VAR Poly * h
Definition janet.cc:971
ListNode * next
Definition janet.h:31
KINLINE poly ksOldCreateSpoly(poly p1, poly p2, poly spNoether, ring r)
Definition kInline.h:1194
KINLINE poly ksOldSpolyRed(poly p1, poly p2, poly spNoether)
Definition kInline.h:1174
void kBucketClear(kBucket_pt bucket, poly *p, int *length)
Definition kbuckets.cc:521
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...
Definition kbuckets.cc:722
void kBucketTakeOutComp(kBucket_pt bucket, long comp, poly *r_p, int *l)
Definition kbuckets.cc:1032
void kBucketDestroy(kBucket_pt *bucket_pt)
Definition kbuckets.cc:216
void kBucketInit(kBucket_pt bucket, poly lm, int length)
Definition kbuckets.cc:493
kBucket_pt kBucketCreate(const ring bucket_ring)
Creation/Destruction of buckets.
Definition kbuckets.cc:209
number kBucketPolyRed(kBucket_pt bucket, poly p1, int l1, poly spNoether)
Definition kbuckets.cc:1071
const poly kBucketGetLm(kBucket_pt bucket)
Definition kbuckets.cc:506
poly p
Definition kbuckets.h:186
int lcm(unsigned long *l, unsigned long *a, unsigned long *b, unsigned long p, int dega, int degb)
Definition minpoly.cc:709
#define assume(x)
Definition mod2.h:389
#define pIter(p)
Definition monomials.h:37
#define pNext(p)
Definition monomials.h:36
#define pSetCoeff0(p, n)
Definition monomials.h:59
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy
Definition monomials.h:44
#define nDiv(a, b)
Definition numbers.h:32
#define nDelete(n)
Definition numbers.h:16
#define nInpNeg(n)
Definition numbers.h:21
#define nNormalize(n)
Definition numbers.h:30
#define omFreeSize(addr, size)
#define omAlloc(size)
#define omAlloc0Bin(bin)
#define omAlloc0(size)
#define omRealloc0Size(addr, o_size, size)
#define NULL
Definition omList.c:12
#define TEST_OPT_PROT
Definition options.h:105
#define TEST_OPT_DEBUG
Definition options.h:110
#define TEST_OPT_NO_SYZ_MINIM
Definition options.h:126
static int index(p_Length length, p_Ord ord)
void pEnlargeSet(poly **p, int l, int increment)
Definition p_polys.cc:3821
static int pLength(poly a)
Definition p_polys.h:190
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent @Note: the integer VarOffset encodes:
Definition p_polys.h:471
static void p_Delete(poly *p, const ring r)
Definition p_polys.h:903
void rChangeCurrRing(ring r)
Definition polys.cc:16
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition polys.cc:13
Compatibility layer for legacy polynomial operations (over currRing).
#define pAdd(p, q)
Definition polys.h:204
static long pTotaldegree(poly p)
Definition polys.h:283
#define pTest(p)
Definition polys.h:415
#define pDelete(p_ptr)
Definition polys.h:187
#define pHead(p)
returns newly allocated copy of Lm(p), coef is copied, next=NULL, p might be NULL
Definition polys.h:68
#define pSetm(p)
Definition polys.h:272
#define pGetComp(p)
Component.
Definition polys.h:38
#define pSetCoeff(p, n)
deletes old coeff before setting the new one
Definition polys.h:32
void pNorm(poly p)
Definition polys.h:363
#define pDivideM(a, b)
Definition polys.h:295
#define pSetComp(p, v)
Definition polys.h:39
#define pLmDelete(p)
assume p != NULL, deletes Lm(p)->coef and Lm(p)
Definition polys.h:77
#define pGetOrder(p)
Order.
Definition polys.h:35
#define pLmDivisibleBy(a, b)
like pDivisibleBy, except that it is assumed that a!=NULL, b!=NULL
Definition polys.h:141
void pWrite(poly p)
Definition polys.h:309
#define pGetExp(p, i)
Exponent.
Definition polys.h:42
#define pMult_mm(p, m)
Definition polys.h:203
#define pInit()
allocates a new monomial and initializes everything to 0
Definition polys.h:62
#define pSetExp(p, i, v)
Definition polys.h:43
#define pSubExp(p, i, v)
Definition polys.h:47
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 ...
Definition polys.h:339
#define pCopy(p)
return a copy of the poly
Definition polys.h:186
#define pOne()
Definition polys.h:316
poly * polyset
Definition polys.h:260
#define pSortCompCorrect(p)
Assume: If considered only as poly in any component of p (say, monomials of other components of p are...
Definition polys.h:228
#define pLcm(a, b, m)
Definition polys.h:296
#define pLmDivisibleByNoComp(a, b)
like pLmDivisibleBy, does not check components
Definition polys.h:143
poly prMoveR(poly &p, ring src_r, ring dest_r)
Definition prCopy.cc:90
poly prHeadR(poly p, ring src_r, ring dest_r, prCopyProc_t prproc)
Definition prCopy.cc:126
poly prCopyR(poly p, ring src_r, ring dest_r)
Definition prCopy.cc:34
void PrintS(const char *s)
Definition reporter.cc:288
void PrintLn()
Definition reporter.cc:314
void rGetSComps(int **currComponents, long **currShiftedComponents, int *length, ring r)
Definition ring.cc:4506
void rChangeSComps(int *currComponents, long *currShiftedComponents, int length, ring r)
Definition ring.cc:4497
void rDelete(ring r)
unconditionally deletes fields in r
Definition ring.cc:454
ring rAssure_dp_S(const ring r)
Definition ring.cc:5114
@ ro_syzcomp
Definition ring.h:60
void sBucketClearMerge(sBucket_pt bucket, poly *p, int *length)
Definition sbuckets.cc:237
void sBucketDestroy(sBucket_pt *bucket)
Definition sbuckets.cc:103
void sBucket_Add_m(sBucket_pt bucket, poly p)
Definition sbuckets.cc:173
sBucket_pt sBucketCreate(const ring r)
Definition sbuckets.cc:96
sBucket * sBucket_pt
Definition sbuckets.h:16
ideal idInit(int idsize, int rank)
initialise an ideal / module
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
#define IDELEMS(i)
static int idElem(const ideal F)
number of non-zero polys in F
EXTERN_VAR omBin char_ptr_bin
Definition structs.h:73
#define loop
Definition structs.h:71
static SSet syChosePairsPutIn(syStrategy syzstr, int *index, int *howmuch, int *actdeg, int an, int en)
Definition syz1.cc:1182
poly syRedtail(poly p, syStrategy syzstr, int index)
Definition syz1.cc:226
void syCopyPair(SObject *argso, SObject *imso)
Definition syz1.cc:82
void syPrint(syStrategy syzstr, const char *sn)
Definition syz1.cc:1936
void syEnterPair(SSet sPairs, SObject *so, int *sPlength, int)
Definition syz1.cc:985
void syKillComputation(syStrategy syzstr, ring r)
Definition syz1.cc:1496
SRes syInitRes(ideal arg, int *length, intvec *Tl, intvec *cw)
Definition syz1.cc:293
static void syCreateNewPairs(syStrategy syzstr, int index, int newEl)
Definition syz1.cc:1070
static poly syStripOutCopy(poly p, intvec *toStrip)
Definition syz1.cc:2067
intvec * syBettiOfComputation(syStrategy syzstr, BOOLEAN minim, int *row_shift, intvec *weights)
Definition syz1.cc:1757
static intvec * syOrdPairs(SSet sPairs, int length)
Definition syz1.cc:2275
static poly syMinimizeP1(int toMin, syStrategy syzstr, intvec *ordn, int index, intvec *toStrip)
Definition syz1.cc:2152
int syDim(syStrategy syzstr)
Definition syz1.cc:1851
syStrategy syMinimize(syStrategy syzstr)
Definition syz1.cc:2394
syStrategy syCopy(syStrategy syzstr)
Definition syz1.cc:1886
static long syReorderShiftedComponents(long *sc, size_t n)
Definition syz1.cc:334
void syCompactifyPairSet(SSet sPairs, int sPlength, int first)
Definition syz1.cc:104
int sySize(syStrategy syzstr)
Definition syz1.cc:1831
resolvente syReorder(resolvente res, int length, syStrategy syzstr, BOOLEAN toCopy, resolvente totake)
Definition syz1.cc:1642
static void syRedGenerOfCurrDeg(syStrategy syzstr, int deg, int index)
Definition syz1.cc:915
void syCompactify1(SSet sPairs, int *sPlength, int first)
Definition syz1.cc:132
int syInitSyzMod(syStrategy syzstr, int index, int init)
Definition syz1.cc:1460
void syKillEmptyEntres(resolvente res, int length)
Definition syz1.cc:2200
static int syLengthInt(int i)
Definition syz1.cc:1920
static void syPrintEmptySpaces1(int i)
Definition syz1.cc:1908
void syEnlargeFields(syStrategy syzstr, int index)
Definition syz1.cc:734
void p_Setm_Syz(poly p, ring r, int *Components, long *ShiftedComponents)
Definition p_polys.cc:530
static void pResetSetm(poly p)
Definition syz1.cc:394
void syInitializePair(SObject *so)
Definition syz1.cc:63
static intvec * syToStrip(syStrategy syzstr, int index)
Definition syz1.cc:2253
static int syChMin(intvec *iv)
Definition syz1.cc:270
static void syRedNextPairs(SSet nextPairs, syStrategy syzstr, int howmuch, int index)
Definition syz1.cc:768
static BOOLEAN syOrder(poly p, syStrategy syzstr, int index, int realcomp)
Definition syz1.cc:461
SSet syChosePairs(syStrategy syzstr, int *index, int *howmuch, int *actdeg)
Definition syz1.cc:1289
void syDeletePair(SObject *so)
Definition syz1.cc:44
static intvec * syLinStrat(SSet nextPairs, syStrategy syzstr, int howmuch, int index)
Definition syz1.cc:649
syStrategy syLaScala(ideal arg, int &maxlength, intvec *weights)
Definition syz1.cc:2559
static resolvente syReadOutMinimalRes(syStrategy syzstr, BOOLEAN computeStd=FALSE)
Definition syz1.cc:2313
void syResetShiftedComponents(syStrategy syzstr, int index, int hilb)
Definition syz1.cc:409
syStrategy syLaScala3(ideal arg, int *length)
Definition syz1.cc:2433
static void syPrintEmptySpaces(int i)
Definition syz1.cc:1896
intvec * syBetti(resolvente res, int length, int *regularity, intvec *weights, BOOLEAN tomin, int *row_shift)
Definition syz.cc:787
void syMinimizeResolvente(resolvente res, int length, int first)
Definition syz.cc:367
ring syRing
Definition syz.h:56
intvec ** hilb_coeffs
Definition syz.h:46
#define SYZ_SHIFT_BASE
Definition syz.h:18
resolvente minres
Definition syz.h:58
intvec * betti
Definition syz.h:53
EXTERN_VAR long * currShiftedComponents
Definition syz.h:118
short references
Definition syz.h:63
EXTERN_VAR int * currcomponents
Definition syz.h:117
intvec * cw
Definition syz.h:52
resolvente res
Definition syz.h:47
int ** backcomponents
Definition syz.h:41
resolvente fullres
Definition syz.h:57
intvec ** weights
Definition syz.h:45
intvec * Tl
Definition syz.h:50
ssyStrategy * syStrategy
Definition syz.h:36
resolvente orderedRes
Definition syz.h:48
intvec * resolution
Definition syz.h:51
int ** truecomponents
Definition syz.h:39
#define SYZ_SHIFT_MAX_NEW_COMP_ESTIMATE
Definition syz.h:15
int length
Definition syz.h:60
int ** Firstelem
Definition syz.h:43
int ** elemLength
Definition syz.h:44
unsigned long ** sev
Definition syz.h:59
SRes resPairs
Definition syz.h:49
kBucket_pt bucket
Definition syz.h:54
SSet * SRes
Definition syz.h:33
long ** ShiftedComponents
Definition syz.h:40
SObject * SSet
Definition syz.h:32
int ** Howmuch
Definition syz.h:42
int F1(int a1, int &r1)
F1.