1 | /**************************************** |
---|
2 | * Computer Algebra System SINGULAR * |
---|
3 | ****************************************/ |
---|
4 | /* |
---|
5 | * ABSTRACT: resolutions |
---|
6 | */ |
---|
7 | |
---|
8 | |
---|
9 | |
---|
10 | |
---|
11 | |
---|
12 | #include <kernel/mod2.h> |
---|
13 | |
---|
14 | #include <omalloc/omalloc.h> |
---|
15 | |
---|
16 | #include <misc/mylimits.h> |
---|
17 | #include <misc/options.h> |
---|
18 | #include <misc/intvec.h> |
---|
19 | //#include "cntrlc.h" |
---|
20 | |
---|
21 | #include <coeffs/coeffs.h> |
---|
22 | #include <coeffs/numbers.h> |
---|
23 | |
---|
24 | #include <polys/monomials/ring.h> |
---|
25 | #include <polys/kbuckets.h> |
---|
26 | #include <polys/prCopy.h> |
---|
27 | |
---|
28 | #include <kernel/polys.h> |
---|
29 | |
---|
30 | #include <kernel/GBEngine/kstd1.h> |
---|
31 | #include <kernel/GBEngine/kutil.h> |
---|
32 | #include <kernel/combinatorics/stairc.h> |
---|
33 | |
---|
34 | #include <kernel/GBEngine/syz.h> |
---|
35 | #include <kernel/ideals.h> |
---|
36 | |
---|
37 | |
---|
38 | |
---|
39 | |
---|
40 | |
---|
41 | //#define SHOW_PROT |
---|
42 | //#define SHOW_RED |
---|
43 | //#define SHOW_HILB |
---|
44 | //#define SHOW_RESULT |
---|
45 | //#define INVERT_PAIRS |
---|
46 | //#define SHOW_CRIT |
---|
47 | //#define SHOW_SPRFL |
---|
48 | #define USE_CHAINCRIT |
---|
49 | #define poly_write(p) wrp(p);PrintLn() |
---|
50 | /*--- some heuristics to optimize the pair sets---*/ |
---|
51 | /*--- chose only one (!!!) at the same time ------*/ |
---|
52 | //#define USE_HEURISTIC1 |
---|
53 | #define USE_HEURISTIC2 |
---|
54 | |
---|
55 | #ifdef SHOW_CRIT |
---|
56 | static int crit; |
---|
57 | static int crit1; |
---|
58 | static int spfl; |
---|
59 | static int cons_pairs; |
---|
60 | static int crit_fails; |
---|
61 | #endif |
---|
62 | typedef struct sopen_pairs open_pairs; |
---|
63 | typedef open_pairs* crit_pairs; |
---|
64 | struct sopen_pairs |
---|
65 | { |
---|
66 | crit_pairs next; |
---|
67 | int first_poly; |
---|
68 | int second_poly; |
---|
69 | }; |
---|
70 | /*3 |
---|
71 | * computes pairs from the new elements (beginning with the element newEl) |
---|
72 | * in the module index |
---|
73 | */ |
---|
74 | static void syCreateNewPairs_Hilb(syStrategy syzstr, int index, |
---|
75 | int actdeg) |
---|
76 | { |
---|
77 | SObject tso; |
---|
78 | poly toHandle,p,pp; |
---|
79 | int r1,r2=0,rr,l=(*syzstr->Tl)[index]; |
---|
80 | int i,j,r=0,ti; |
---|
81 | BOOLEAN toComp=FALSE; |
---|
82 | #ifdef USE_CHAINCRIT |
---|
83 | crit_pairs cp=NULL,tcp; |
---|
84 | #endif |
---|
85 | actdeg += index; |
---|
86 | |
---|
87 | while ((l>0) && ((syzstr->resPairs[index])[l-1].lcm==NULL)) l--; |
---|
88 | rr = l-1; |
---|
89 | while ((rr>=0) && (((syzstr->resPairs[index])[rr].p==NULL) || |
---|
90 | ((syzstr->resPairs[index])[rr].order>actdeg))) rr--; |
---|
91 | r2 = rr+1; |
---|
92 | while ((rr>=0) && ((syzstr->resPairs[index])[rr].order==actdeg) |
---|
93 | && ((syzstr->resPairs[index])[rr].syzind<0)) |
---|
94 | { |
---|
95 | rr--; |
---|
96 | r++; |
---|
97 | } |
---|
98 | if (r==0) return; |
---|
99 | ideal nP=idInit(l,syzstr->res[index]->rank); |
---|
100 | #ifdef INVERT_PAIRS |
---|
101 | r1 = rr+1; |
---|
102 | #else |
---|
103 | r1 = r2-1; |
---|
104 | #endif |
---|
105 | /*---------- there are new pairs ------------------------------*/ |
---|
106 | loop |
---|
107 | { |
---|
108 | /*--- chose first new elements --------------------------------*/ |
---|
109 | toComp = FALSE; |
---|
110 | toHandle = (syzstr->resPairs[index])[r1].p; |
---|
111 | if (toHandle!=NULL) |
---|
112 | { |
---|
113 | int tc=pGetComp(toHandle); |
---|
114 | (syzstr->resPairs[index])[r1].syzind = 0; |
---|
115 | for (i=0; i<r1;i++) |
---|
116 | { |
---|
117 | if (((syzstr->resPairs[index])[i].p!=NULL) && |
---|
118 | (pGetComp((syzstr->resPairs[index])[i].p)==(unsigned)tc)) |
---|
119 | { |
---|
120 | #ifdef USE_CHAINCRIT |
---|
121 | tcp = cp; |
---|
122 | if (tcp!=NULL) |
---|
123 | { |
---|
124 | while ((tcp!=NULL) && |
---|
125 | ((tcp->first_poly!=i)||(tcp->second_poly!=r1))) tcp = tcp->next; |
---|
126 | } |
---|
127 | if (tcp==NULL) |
---|
128 | { |
---|
129 | #endif |
---|
130 | p = pOne(); |
---|
131 | pLcm((syzstr->resPairs[index])[i].p,toHandle,p); |
---|
132 | pSetm(p); |
---|
133 | j = 0; |
---|
134 | while (j<i) |
---|
135 | { |
---|
136 | if (nP->m[j]!=NULL) |
---|
137 | { |
---|
138 | if (pLmDivisibleByNoComp(nP->m[j],p)) |
---|
139 | { |
---|
140 | pDelete(&p); |
---|
141 | /* p = NULL;*/ |
---|
142 | break; |
---|
143 | } |
---|
144 | else if (pLmDivisibleByNoComp(p,nP->m[j])) |
---|
145 | { |
---|
146 | pDelete(&(nP->m[j])); |
---|
147 | /* nP->m[j] = NULL;*/ |
---|
148 | } |
---|
149 | #ifdef USE_CHAINCRIT |
---|
150 | else |
---|
151 | { |
---|
152 | poly p1,p2; |
---|
153 | int ip= currRing->N; |
---|
154 | p1 = pDivide(p,(syzstr->resPairs[index])[i].p); |
---|
155 | p2 = pDivide(nP->m[j],(syzstr->resPairs[index])[j].p); |
---|
156 | while ((ip>0) && (pGetExp(p1,ip)*pGetExp(p2,ip)==0)) ip--; |
---|
157 | if (ip==0) |
---|
158 | { |
---|
159 | #ifdef SHOW_SPRFL |
---|
160 | Print("Hier: %d, %d\n",j,i); |
---|
161 | #endif |
---|
162 | if (i>rr) |
---|
163 | { |
---|
164 | tcp=(crit_pairs)omAlloc0(sizeof(sopen_pairs)); |
---|
165 | tcp->next = cp; |
---|
166 | tcp->first_poly = j; |
---|
167 | tcp->second_poly = i; |
---|
168 | cp = tcp; |
---|
169 | tcp = NULL; |
---|
170 | } |
---|
171 | else |
---|
172 | { |
---|
173 | ti=0; |
---|
174 | while ((ti<l) && (((syzstr->resPairs[index])[ti].ind1!=j)|| |
---|
175 | ((syzstr->resPairs[index])[ti].ind2!=i))) ti++; |
---|
176 | if (ti<l) |
---|
177 | { |
---|
178 | #ifdef SHOW_SPRFL |
---|
179 | Print("gefunden in Mod %d: ",index); poly_write((syzstr->resPairs[index])[ti].lcm); |
---|
180 | #endif |
---|
181 | syDeletePair(&(syzstr->resPairs[index])[ti]); |
---|
182 | #ifdef SHOW_CRIT |
---|
183 | crit1++; |
---|
184 | #endif |
---|
185 | toComp = TRUE; |
---|
186 | } |
---|
187 | } |
---|
188 | } |
---|
189 | pLmDelete(&p1); |
---|
190 | pLmDelete(&p2); |
---|
191 | } |
---|
192 | #endif |
---|
193 | } |
---|
194 | j++; |
---|
195 | } |
---|
196 | if (p!=NULL) |
---|
197 | { |
---|
198 | nP->m[i] = p; |
---|
199 | } |
---|
200 | #ifdef USE_CHAINCRIT |
---|
201 | } |
---|
202 | else |
---|
203 | { |
---|
204 | #ifdef SHOW_CRIT |
---|
205 | crit1++; |
---|
206 | #endif |
---|
207 | } |
---|
208 | #endif |
---|
209 | } |
---|
210 | } |
---|
211 | if (toComp) syCompactify1(syzstr->resPairs[index],&l,r1); |
---|
212 | for (i=0;i<r1;i++) |
---|
213 | { |
---|
214 | if (nP->m[i]!=NULL) |
---|
215 | { |
---|
216 | tso.lcm = p = nP->m[i]; |
---|
217 | nP->m[i] = NULL; |
---|
218 | tso.order = pTotaldegree(p); |
---|
219 | if ((syzstr->cw!=NULL) && (index>0) && (pGetComp(p)>0)) |
---|
220 | { |
---|
221 | int ii=index-1,jj=pGetComp(p); |
---|
222 | while (ii>0) |
---|
223 | { |
---|
224 | jj = pGetComp(syzstr->res[ii]->m[jj-1]); |
---|
225 | ii--; |
---|
226 | } |
---|
227 | tso.order += (*syzstr->cw)[jj-1]; |
---|
228 | } |
---|
229 | tso.p1 = (syzstr->resPairs[index])[i].p; |
---|
230 | tso.p2 = toHandle; |
---|
231 | tso.ind1 = i; |
---|
232 | tso.ind2 = r1; |
---|
233 | tso.syzind = -1; |
---|
234 | tso.isNotMinimal = (poly)1; |
---|
235 | tso.p = NULL; |
---|
236 | tso.length = -1; |
---|
237 | number coefgcd = |
---|
238 | n_SubringGcd(pGetCoeff(tso.p1),pGetCoeff(tso.p2),currRing->cf); |
---|
239 | tso.syz = pCopy((syzstr->resPairs[index])[i].syz); |
---|
240 | poly tt = pDivide(tso.lcm,tso.p1); |
---|
241 | pSetCoeff(tt,nDiv(pGetCoeff(tso.p1),coefgcd)); |
---|
242 | tso.syz = pMult_mm(tso.syz,tt); |
---|
243 | pLmDelete(&tt); |
---|
244 | coefgcd = nInpNeg(coefgcd); |
---|
245 | pp = pCopy((syzstr->resPairs[index])[r1].syz); |
---|
246 | tt = pDivide(tso.lcm,tso.p2); |
---|
247 | pSetCoeff(tt,nDiv(pGetCoeff(tso.p2),coefgcd)); |
---|
248 | pp = pMult_mm(pp,tt); |
---|
249 | pLmDelete(&tt); |
---|
250 | tso.syz = pAdd(pp,tso.syz); |
---|
251 | nDelete(&coefgcd); |
---|
252 | pSetComp(tso.lcm,pGetComp((syzstr->resPairs[index])[r1].syz)); |
---|
253 | #ifdef SHOW_PROT |
---|
254 | Print("erzeuge Paar im Modul %d,%d mit: \n",index,tso.order); |
---|
255 | PrintS("poly1: ");poly_write(tso.p1); |
---|
256 | PrintS("poly2: ");poly_write(tso.p2); |
---|
257 | PrintS("syz: ");poly_write(tso.syz); |
---|
258 | PrintS("sPoly: ");poly_write(tso.p); |
---|
259 | PrintLn(); |
---|
260 | #endif |
---|
261 | syEnterPair(syzstr,&tso,&l,index); |
---|
262 | } |
---|
263 | } |
---|
264 | } |
---|
265 | #ifdef INVERT_PAIRS |
---|
266 | r1++; |
---|
267 | if (r1>=r2) break; |
---|
268 | #else |
---|
269 | r1--; |
---|
270 | if (r1<=rr) break; |
---|
271 | #endif |
---|
272 | } |
---|
273 | idDelete(&nP); |
---|
274 | #ifdef USE_CHAINCRIT |
---|
275 | while (cp!=NULL) |
---|
276 | { |
---|
277 | tcp = cp; |
---|
278 | cp = cp->next; |
---|
279 | omFreeSize((ADDRESS)tcp,sizeof(sopen_pairs)); |
---|
280 | } |
---|
281 | #endif |
---|
282 | } |
---|
283 | |
---|
284 | /*3 |
---|
285 | * determines the place of a polynomial in the right ordered resolution |
---|
286 | * set the vectors of truecomponents |
---|
287 | */ |
---|
288 | static void syOrder_Hilb(poly p,syStrategy syzstr,int index) |
---|
289 | { |
---|
290 | int i=IDELEMS(syzstr->orderedRes[index]); |
---|
291 | |
---|
292 | while ((i>0) && (syzstr->orderedRes[index]->m[i-1]==NULL)) i--; |
---|
293 | syzstr->orderedRes[index]->m[i] = p; |
---|
294 | } |
---|
295 | |
---|
296 | static void syHalfPair(poly syz, int newEl, syStrategy syzstr, int index) |
---|
297 | { |
---|
298 | SObject tso; |
---|
299 | memset(&tso,0,sizeof(tso)); |
---|
300 | int l=(*syzstr->Tl)[index]; |
---|
301 | |
---|
302 | while ((l>0) && ((syzstr->resPairs[index])[l-1].syz==NULL)) l--; |
---|
303 | if ((syzstr->cw!=NULL) && (index>0) && (pGetComp(syz)>0)) |
---|
304 | { |
---|
305 | int ii=index-1,jj=pGetComp(syz); |
---|
306 | while (ii>0) |
---|
307 | { |
---|
308 | jj = pGetComp(syzstr->res[ii]->m[jj-1]); |
---|
309 | ii--; |
---|
310 | } |
---|
311 | tso.order += (*syzstr->cw)[jj-1]; |
---|
312 | } |
---|
313 | tso.p1 = NULL; |
---|
314 | tso.p2 = NULL; |
---|
315 | tso.ind1 = 0; |
---|
316 | tso.ind2 = 0; |
---|
317 | tso.syzind = -1; |
---|
318 | tso.isNotMinimal = NULL; |
---|
319 | tso.p = syz; |
---|
320 | tso.order = pTotaldegree(syz); |
---|
321 | tso.syz = pHead(syz); |
---|
322 | pSetComp(tso.syz,newEl+1); |
---|
323 | pSetm(tso.syz); |
---|
324 | tso.lcm = pHead(tso.syz); |
---|
325 | tso.length = pLength(syz); |
---|
326 | syOrder_Hilb(syz,syzstr,index); |
---|
327 | #ifdef SHOW_PROT |
---|
328 | Print("erzeuge Halbpaar im Module %d,%d mit: \n",index,tso.order); |
---|
329 | PrintS("syz: ");poly_write(tso.syz); |
---|
330 | PrintS("sPoly: ");poly_write(tso.p); |
---|
331 | PrintLn(); |
---|
332 | #endif |
---|
333 | syEnterPair(syzstr,&tso,&l,index); |
---|
334 | } |
---|
335 | /*3 |
---|
336 | * computes the order of pairs of same degree |
---|
337 | * must be monoton |
---|
338 | */ |
---|
339 | static intvec* syLinStrat2(SSet nextPairs, syStrategy syzstr, |
---|
340 | int howmuch, int index,intvec ** secondpairs) |
---|
341 | { |
---|
342 | ideal o_r=syzstr->res[index+1]; |
---|
343 | int i=0,i1=0,i2=0,l,ll=IDELEMS(o_r); |
---|
344 | intvec *result=new intvec(howmuch+1); |
---|
345 | BOOLEAN isDivisible; |
---|
346 | SObject tso; |
---|
347 | |
---|
348 | #ifndef USE_HEURISTIC2 |
---|
349 | while (i1<howmuch) |
---|
350 | { |
---|
351 | (*result)[i1] = i1+1; |
---|
352 | i1++; |
---|
353 | } |
---|
354 | return result; |
---|
355 | #else |
---|
356 | while ((ll>0) && (o_r->m[ll-1]==NULL)) ll--; |
---|
357 | while (i<howmuch) |
---|
358 | { |
---|
359 | tso = nextPairs[i]; |
---|
360 | isDivisible = FALSE; |
---|
361 | l = 0; |
---|
362 | while ((l<ll) && (!isDivisible)) |
---|
363 | { |
---|
364 | if (o_r->m[l]!=NULL) |
---|
365 | { |
---|
366 | isDivisible = isDivisible || |
---|
367 | pLmDivisibleBy(o_r->m[l],tso.lcm); |
---|
368 | } |
---|
369 | l++; |
---|
370 | } |
---|
371 | if (isDivisible) |
---|
372 | { |
---|
373 | #ifdef SHOW_PROT |
---|
374 | Print("streiche Paar im Modul %d,%d mit: \n",index,nextPairs[i].order); |
---|
375 | PrintS("poly1: ");poly_write(nextPairs[i].p1); |
---|
376 | PrintS("poly2: ");poly_write(nextPairs[i].p2); |
---|
377 | PrintS("syz: ");poly_write(nextPairs[i].syz); |
---|
378 | PrintS("sPoly: ");poly_write(nextPairs[i].p); |
---|
379 | PrintLn(); |
---|
380 | #endif |
---|
381 | //syDeletePair(&nextPairs[i]); |
---|
382 | if (*secondpairs==NULL) *secondpairs = new intvec(howmuch); |
---|
383 | (**secondpairs)[i2] = i+1; |
---|
384 | i2++; |
---|
385 | #ifdef SHOW_CRIT |
---|
386 | crit++; |
---|
387 | #endif |
---|
388 | } |
---|
389 | else |
---|
390 | { |
---|
391 | // nextPairs[i].p = sySPoly(tso.p1, tso.p2,tso.lcm); |
---|
392 | (*result)[i1] = i+1; |
---|
393 | i1++; |
---|
394 | } |
---|
395 | i++; |
---|
396 | } |
---|
397 | return result; |
---|
398 | #endif |
---|
399 | } |
---|
400 | |
---|
401 | inline void sySPRedSyz(syStrategy syzstr,sSObject redWith,poly q=NULL) |
---|
402 | { |
---|
403 | poly p=pDivide(q,redWith.p); |
---|
404 | pSetCoeff(p,nDiv(pGetCoeff(q),pGetCoeff(redWith.p))); |
---|
405 | int il=-1; |
---|
406 | kBucket_Minus_m_Mult_p(syzstr->syz_bucket,p,redWith.syz,&il,NULL); |
---|
407 | pLmDelete(&p); |
---|
408 | } |
---|
409 | |
---|
410 | static poly syRed_Hilb(poly toRed,syStrategy syzstr,int index) |
---|
411 | { |
---|
412 | ideal redWith=syzstr->res[index]; |
---|
413 | if (redWith==NULL) return toRed; |
---|
414 | int j=IDELEMS(redWith),i; |
---|
415 | poly q,result=NULL,resultp; |
---|
416 | |
---|
417 | while ((j>0) && (redWith->m[j-1]==NULL)) j--; |
---|
418 | if ((toRed==NULL) || (j==0)) return toRed; |
---|
419 | kBucketInit(syzstr->bucket,toRed,-1); |
---|
420 | q = kBucketGetLm(syzstr->bucket); |
---|
421 | loop |
---|
422 | { |
---|
423 | if (q==NULL) |
---|
424 | { |
---|
425 | break; |
---|
426 | } |
---|
427 | i = 0; |
---|
428 | loop |
---|
429 | { |
---|
430 | if (pLmDivisibleBy(redWith->m[i],q)) |
---|
431 | { |
---|
432 | number up = kBucketPolyRed(syzstr->bucket,redWith->m[i], |
---|
433 | pLength(redWith->m[i]), NULL); |
---|
434 | nDelete(&up); |
---|
435 | q = kBucketGetLm(syzstr->bucket); |
---|
436 | if (toRed==NULL) break; |
---|
437 | i = 0; |
---|
438 | } |
---|
439 | else |
---|
440 | { |
---|
441 | i++; |
---|
442 | } |
---|
443 | if ((i>=j) || (q==NULL)) break; |
---|
444 | } |
---|
445 | if (q!=NULL) |
---|
446 | { |
---|
447 | if (result==NULL) |
---|
448 | { |
---|
449 | resultp = result = kBucketExtractLm(syzstr->bucket); |
---|
450 | } |
---|
451 | else |
---|
452 | { |
---|
453 | pNext(resultp) = kBucketExtractLm(syzstr->bucket); |
---|
454 | pIter(resultp); |
---|
455 | } |
---|
456 | q = kBucketGetLm(syzstr->bucket); |
---|
457 | } |
---|
458 | } |
---|
459 | kBucketClear(syzstr->bucket,&q,&i); |
---|
460 | if (q!=NULL) PrintS("Hier ist was schief gelaufen!\n"); |
---|
461 | return result; |
---|
462 | } |
---|
463 | |
---|
464 | #ifdef USE_HEURISTIC1 |
---|
465 | intvec *ivStrip(intvec* arg) |
---|
466 | { |
---|
467 | int l=arg->rows()*arg->cols(),i=0,ii=0; |
---|
468 | intvec *tempV=new intvec(l); |
---|
469 | |
---|
470 | while (i+ii<l) |
---|
471 | { |
---|
472 | if ((*arg)[i+ii]==0) |
---|
473 | { |
---|
474 | ii++; |
---|
475 | } |
---|
476 | else |
---|
477 | { |
---|
478 | (*tempV)[i] = (*arg)[i+ii]; |
---|
479 | i++; |
---|
480 | } |
---|
481 | } |
---|
482 | if (i==0) |
---|
483 | { |
---|
484 | delete tempV; |
---|
485 | return NULL; |
---|
486 | } |
---|
487 | intvec * result=new intvec(i+1); |
---|
488 | for (ii=0;ii<i;ii++) |
---|
489 | (*result)[ii] = (*tempV)[ii]; |
---|
490 | delete tempV; |
---|
491 | return result; |
---|
492 | } |
---|
493 | #endif |
---|
494 | |
---|
495 | /*3 |
---|
496 | * reduces all pairs of degree deg in the module index |
---|
497 | * put the reduced generators to the resolvente which contains |
---|
498 | * the truncated kStd |
---|
499 | */ |
---|
500 | static void syRedNextPairs_Hilb(SSet nextPairs, syStrategy syzstr, |
---|
501 | int howmuch, int index,int actord,int* toSub, |
---|
502 | int *maxindex,int *maxdeg) |
---|
503 | { |
---|
504 | int i,j,k=IDELEMS(syzstr->res[index]); |
---|
505 | int ks=IDELEMS(syzstr->res[index+1]),kk; |
---|
506 | int ks1=IDELEMS(syzstr->orderedRes[index+1]); |
---|
507 | int kres=(*syzstr->Tl)[index]; |
---|
508 | int toGo=0; |
---|
509 | int il; |
---|
510 | SSet redset=syzstr->resPairs[index]; |
---|
511 | poly q; |
---|
512 | intvec *spl1; |
---|
513 | SObject tso; |
---|
514 | intvec *spl3=NULL; |
---|
515 | #ifdef USE_HEURISTIC1 |
---|
516 | intvec *spl2=new intvec(howmuch+1,howmuch+1,0); |
---|
517 | int there_are_superfluous=0; |
---|
518 | int step=1,jj,j1,j2; |
---|
519 | #endif |
---|
520 | assume((syzstr->truecomponents[index]) != NULL && (syzstr->ShiftedComponents[index]) != NULL); |
---|
521 | |
---|
522 | actord += index; |
---|
523 | if ((nextPairs==NULL) || (howmuch==0)) return; |
---|
524 | while ((k>0) && (syzstr->res[index]->m[k-1]==NULL)) k--; |
---|
525 | while ((ks>0) && (syzstr->res[index+1]->m[ks-1]==NULL)) ks--; |
---|
526 | while ((ks1>0) && (syzstr->orderedRes[index+1]->m[ks1-1]==NULL)) ks1--; |
---|
527 | while ((kres>0) && |
---|
528 | ((redset[kres-1].p==NULL) || (redset[kres-1].order>actord))) kres--; |
---|
529 | while ((kres<(*syzstr->Tl)[index]) && |
---|
530 | (redset[kres-1].order!=0) && (redset[kres-1].order<=actord)) kres++; |
---|
531 | spl1 = syLinStrat2(nextPairs,syzstr,howmuch,index,&spl3); |
---|
532 | #ifdef SHOW_PROT |
---|
533 | PrintS("spl1 ist hier: ");spl1->show(0,0); |
---|
534 | #endif |
---|
535 | i=0; |
---|
536 | kk = (*spl1)[i]-1; |
---|
537 | if (index==1) |
---|
538 | { |
---|
539 | intvec * temp1_hilb = hHstdSeries(syzstr->res[index],NULL,NULL,NULL); |
---|
540 | if (actord<temp1_hilb->length()) |
---|
541 | { |
---|
542 | toGo = (*temp1_hilb)[actord]; |
---|
543 | #ifdef SHOW_HILB |
---|
544 | Print("\nStze toGo im Modul %d und Grad %d auf: %d\n",1,actord-1,toGo); |
---|
545 | #endif |
---|
546 | } |
---|
547 | delete temp1_hilb; |
---|
548 | } |
---|
549 | else |
---|
550 | { |
---|
551 | if (actord<=(syzstr->hilb_coeffs[index])->length()) |
---|
552 | { |
---|
553 | toGo = (*syzstr->hilb_coeffs[index])[actord-1]; |
---|
554 | #ifdef SHOW_HILB |
---|
555 | Print("\nStze toGo im Modul %d und Grad %d auf: %d\n",index,actord-1,toGo); |
---|
556 | #endif |
---|
557 | } |
---|
558 | } |
---|
559 | if ((syzstr->hilb_coeffs[index+1]!=NULL) && |
---|
560 | (actord<=(syzstr->hilb_coeffs[index+1])->length())) |
---|
561 | { |
---|
562 | toGo += (*syzstr->hilb_coeffs[index+1])[actord-1]; |
---|
563 | #ifdef SHOW_HILB |
---|
564 | Print("\nAddiere zu toGo aus Modul %d und Grad %d: %d\n",index+1,actord-1,(*syzstr->hilb_coeffs[index+1])[actord-1]); |
---|
565 | #endif |
---|
566 | } |
---|
567 | #ifdef SHOW_HILB |
---|
568 | Print("<H%d>",toGo); |
---|
569 | #endif |
---|
570 | while (kk>=0) |
---|
571 | { |
---|
572 | if (toGo==0) |
---|
573 | { |
---|
574 | while (kk>=0) |
---|
575 | { |
---|
576 | pDelete(&nextPairs[kk].p); |
---|
577 | pDelete(&nextPairs[kk].syz); |
---|
578 | syDeletePair(&nextPairs[kk]); |
---|
579 | nextPairs[kk].p = nextPairs[kk].syz = nextPairs[kk].lcm = NULL; |
---|
580 | i++; |
---|
581 | kk = (*spl1)[i]-1; |
---|
582 | #ifdef USE_HEURISTIC2 |
---|
583 | if (kk<0) |
---|
584 | { |
---|
585 | i = 0; |
---|
586 | delete spl1; |
---|
587 | spl1 = spl3; |
---|
588 | spl3 = NULL; |
---|
589 | if (spl1!=NULL) |
---|
590 | kk = (*spl1)[i]-1; |
---|
591 | } |
---|
592 | #endif |
---|
593 | } |
---|
594 | if (spl1!=NULL) delete spl1; |
---|
595 | break; |
---|
596 | } |
---|
597 | tso = nextPairs[kk]; |
---|
598 | if ((tso.p1!=NULL) && (tso.p2!=NULL)) |
---|
599 | { |
---|
600 | #ifdef SHOW_CRIT |
---|
601 | cons_pairs++; |
---|
602 | #endif |
---|
603 | //tso.p = sySPoly(tso.p1, tso.p2,tso.lcm); |
---|
604 | tso.p = ksOldCreateSpoly(tso.p2, tso.p1); |
---|
605 | #ifdef SHOW_PROT |
---|
606 | PrintS("reduziere Paar mit: \n"); |
---|
607 | PrintS("poly1: ");poly_write(tso.p1); |
---|
608 | PrintS("poly2: ");poly_write(tso.p2); |
---|
609 | PrintS("syz: ");poly_write(tso.syz); |
---|
610 | PrintS("sPoly: ");poly_write(tso.p); |
---|
611 | #endif |
---|
612 | if (tso.p != NULL) |
---|
613 | { |
---|
614 | kBucketInit(syzstr->bucket,tso.p,-1); |
---|
615 | kBucketInit(syzstr->syz_bucket,tso.syz,-1); |
---|
616 | q = kBucketGetLm(syzstr->bucket); |
---|
617 | j = 0; |
---|
618 | while (j<kres) |
---|
619 | { |
---|
620 | if ((redset[j].p!=NULL) && (pLmDivisibleBy(redset[j].p,q)) |
---|
621 | && ((redset[j].ind1!=tso.ind1) || (redset[j].ind2!=tso.ind2))) |
---|
622 | { |
---|
623 | #ifdef SHOW_RED |
---|
624 | kBucketClear(syzstr->bucket,&tso.p,&tso.length); |
---|
625 | kBucketClear(syzstr->syz_bucket,&tso.syz,&il); |
---|
626 | PrintS("reduziere: ");poly_write(tso.p); |
---|
627 | PrintS("syz: ");poly_write(tso.syz); |
---|
628 | PrintS("mit: ");poly_write(redset[j].p); |
---|
629 | PrintS("syz: ");poly_write(redset[j].syz); |
---|
630 | kBucketInit(syzstr->bucket,tso.p,tso.length); |
---|
631 | kBucketInit(syzstr->syz_bucket,tso.syz,il); |
---|
632 | #endif |
---|
633 | sySPRedSyz(syzstr,redset[j],q); |
---|
634 | number up = kBucketPolyRed(syzstr->bucket,redset[j].p, |
---|
635 | redset[j].length, NULL); |
---|
636 | nDelete(&up); |
---|
637 | q = kBucketGetLm(syzstr->bucket); |
---|
638 | #ifdef SHOW_RED |
---|
639 | kBucketClear(syzstr->bucket,&tso.p,&tso.length); |
---|
640 | kBucketClear(syzstr->syz_bucket,&tso.syz,&il); |
---|
641 | PrintS("zu: ");poly_write(tso.p); |
---|
642 | PrintS("syz: ");poly_write(tso.syz); |
---|
643 | kBucketInit(syzstr->bucket,tso.p,tso.length); |
---|
644 | kBucketInit(syzstr->syz_bucket,tso.syz,il); |
---|
645 | PrintLn(); |
---|
646 | #endif |
---|
647 | if (q==NULL) break; |
---|
648 | j = 0; |
---|
649 | } |
---|
650 | else |
---|
651 | { |
---|
652 | j++; |
---|
653 | } |
---|
654 | } |
---|
655 | kBucketClear(syzstr->bucket,&tso.p,&tso.length); |
---|
656 | kBucketClear(syzstr->syz_bucket,&tso.syz,&il); |
---|
657 | } |
---|
658 | #ifdef SHOW_PROT |
---|
659 | PrintS("erhalte Paar mit: \n"); |
---|
660 | PrintS("syz: ");poly_write(tso.syz); |
---|
661 | PrintS("sPoly: ");poly_write(tso.p); |
---|
662 | PrintLn(); |
---|
663 | #endif |
---|
664 | #ifdef SHOW_SPRFL |
---|
665 | //PrintLn(); |
---|
666 | wrp(tso.lcm); |
---|
667 | Print(" mit index %d, %d ",tso.ind1,tso.ind2); |
---|
668 | #endif |
---|
669 | if (tso.p != NULL) |
---|
670 | { |
---|
671 | if (TEST_OPT_PROT) PrintS("g"); |
---|
672 | (*toSub)++; |
---|
673 | toGo--; |
---|
674 | if (!nIsOne(pGetCoeff(tso.p))) |
---|
675 | { |
---|
676 | number n=nInvers(pGetCoeff(tso.p)); |
---|
677 | pNorm(tso.p); |
---|
678 | pMult_nn(tso.syz,n); |
---|
679 | nDelete(&n); |
---|
680 | } |
---|
681 | if (k==IDELEMS((syzstr->res)[index])) |
---|
682 | syEnlargeFields(syzstr,index); |
---|
683 | syzstr->res[index]->m[k] = tso.p; |
---|
684 | k++; |
---|
685 | } |
---|
686 | else |
---|
687 | { |
---|
688 | if (ks==IDELEMS(syzstr->res[index+1])) |
---|
689 | syEnlargeFields(syzstr,index+1); |
---|
690 | syzstr->res[index+1]->m[ks] = syRed_Hilb(tso.syz,syzstr,index+1); |
---|
691 | if (syzstr->res[index+1]->m[ks]!=NULL) |
---|
692 | { |
---|
693 | if (TEST_OPT_PROT) PrintS("s"); |
---|
694 | toGo--; |
---|
695 | pNorm(syzstr->res[index+1]->m[ks]); |
---|
696 | syHalfPair(syzstr->res[index+1]->m[ks],ks1,syzstr,index+1); |
---|
697 | ks++; |
---|
698 | ks1++; |
---|
699 | if (index+1>*maxindex) *maxindex = index+1; |
---|
700 | if (actord-index>*maxdeg) *maxdeg = actord-index; |
---|
701 | } |
---|
702 | else |
---|
703 | { |
---|
704 | if (TEST_OPT_PROT) PrintS("-"); |
---|
705 | #ifdef SHOW_CRIT |
---|
706 | spfl++; |
---|
707 | #endif |
---|
708 | #ifdef USE_HEURISTIC1 |
---|
709 | if (there_are_superfluous>=0) |
---|
710 | { |
---|
711 | j = i+1; |
---|
712 | jj = (*spl1)[j]-1; |
---|
713 | j1 = 1; |
---|
714 | while (jj>=0) |
---|
715 | { |
---|
716 | if (tso.ind2==nextPairs[jj].ind2) |
---|
717 | { |
---|
718 | IMATELEM(*spl2,j1,step) = jj+1; |
---|
719 | j1++; |
---|
720 | for (j2=j;j2<spl1->length()-1;j2++) |
---|
721 | { |
---|
722 | (*spl1)[j2] = (*spl1)[j2+1]; |
---|
723 | } |
---|
724 | } |
---|
725 | else |
---|
726 | { |
---|
727 | j++; |
---|
728 | } |
---|
729 | jj = (*spl1)[j]-1; |
---|
730 | } |
---|
731 | step++; |
---|
732 | if (there_are_superfluous==0) there_are_superfluous = 1; |
---|
733 | } |
---|
734 | #endif |
---|
735 | #ifdef SHOW_SPRFL |
---|
736 | Print("ist ueberfluessig in Mod %d",index); |
---|
737 | //Print("\n ueberfluessig in Mod %d:",index); |
---|
738 | //wrp(tso.lcm); |
---|
739 | //PrintLn(); |
---|
740 | #endif |
---|
741 | } |
---|
742 | tso.syz = NULL; |
---|
743 | syDeletePair(&tso); |
---|
744 | tso.p = tso.syz = tso.lcm = NULL; |
---|
745 | } |
---|
746 | nextPairs[kk] = tso; |
---|
747 | } |
---|
748 | #ifdef SHOW_SPRFL |
---|
749 | PrintLn(); |
---|
750 | #endif |
---|
751 | i++; |
---|
752 | #ifdef SHOW_PROT |
---|
753 | PrintS("spl1 ist hier: ");spl1->show(0,0); |
---|
754 | Print("naechstes i ist: %d",i); |
---|
755 | #endif |
---|
756 | kk = (*spl1)[i]-1; |
---|
757 | #ifdef USE_HEURISTIC1 |
---|
758 | if ((kk<0) && (there_are_superfluous>0)) |
---|
759 | { |
---|
760 | i = 0; |
---|
761 | delete spl1; |
---|
762 | spl1 = ivStrip(spl2); |
---|
763 | delete spl2; |
---|
764 | if (spl1!=NULL) |
---|
765 | { |
---|
766 | there_are_superfluous = -1; |
---|
767 | kk = (*spl1)[i]-1; |
---|
768 | } |
---|
769 | } |
---|
770 | #endif |
---|
771 | #ifdef USE_HEURISTIC2 |
---|
772 | if ((kk<0) && (toGo>0)) |
---|
773 | { |
---|
774 | #ifdef SHOW_CRIT |
---|
775 | crit_fails++; |
---|
776 | #endif |
---|
777 | i = 0; |
---|
778 | delete spl1; |
---|
779 | spl1 = spl3; |
---|
780 | spl3 = NULL; |
---|
781 | if (spl1!=NULL) |
---|
782 | kk = (*spl1)[i]-1; |
---|
783 | } |
---|
784 | #endif |
---|
785 | } |
---|
786 | delete spl1; |
---|
787 | if (spl3!=NULL) delete spl3; |
---|
788 | } |
---|
789 | |
---|
790 | void sySetNewHilb(syStrategy syzstr, int toSub,int index,int actord) |
---|
791 | { |
---|
792 | int i; |
---|
793 | actord += index; |
---|
794 | intvec * temp_hilb = hHstdSeries(syzstr->res[index+1],NULL,NULL,NULL); |
---|
795 | intvec * cont_hilb = hHstdSeries(syzstr->res[index],NULL,NULL,NULL); |
---|
796 | if ((index+1<syzstr->length) && (syzstr->hilb_coeffs[index+1]==NULL)) |
---|
797 | { |
---|
798 | syzstr->hilb_coeffs[index+1] = new intvec(16*((actord/16)+1)); |
---|
799 | } |
---|
800 | else if (actord>=syzstr->hilb_coeffs[index+1]->length()) |
---|
801 | { |
---|
802 | intvec * ttt=new intvec(16*((actord/16)+1)); |
---|
803 | for (i=syzstr->hilb_coeffs[index+1]->length()-1;i>=0;i--) |
---|
804 | { |
---|
805 | (*ttt)[i] = (*(syzstr->hilb_coeffs[index+1]))[i]; |
---|
806 | } |
---|
807 | delete syzstr->hilb_coeffs[index+1]; |
---|
808 | syzstr->hilb_coeffs[index+1] = ttt; |
---|
809 | } |
---|
810 | if (actord+1<temp_hilb->length()) |
---|
811 | { |
---|
812 | #ifdef SHOW_HILB |
---|
813 | Print("\nSetze fuer Modul %d im Grad %d die Wert: \n",index+1,actord); |
---|
814 | (temp_hilb)->show(0,0); |
---|
815 | #endif |
---|
816 | int k=si_min(temp_hilb->length()-1,(syzstr->hilb_coeffs[index+1])->length()); |
---|
817 | for (int j=k;j>actord;j--) |
---|
818 | (*(syzstr->hilb_coeffs[index+1]))[j-1] = (*temp_hilb)[j]; |
---|
819 | } |
---|
820 | else |
---|
821 | { |
---|
822 | (*(syzstr->hilb_coeffs[index+1]))[actord] = 0; |
---|
823 | } |
---|
824 | delete temp_hilb; |
---|
825 | if ((index>1) && (actord<=syzstr->hilb_coeffs[index]->length())) |
---|
826 | { |
---|
827 | #ifdef SHOW_HILB |
---|
828 | Print("\nSubtrahiere im Modul %d im Grad %d den Wert: %d\n",index,actord-1,toSub); |
---|
829 | #endif |
---|
830 | (*syzstr->hilb_coeffs[index])[actord-1]-=toSub; |
---|
831 | } |
---|
832 | if (syzstr->hilb_coeffs[index]!=NULL) |
---|
833 | { |
---|
834 | if (cont_hilb->length()>syzstr->hilb_coeffs[index]->length()) |
---|
835 | syzstr->hilb_coeffs[index]->resize(cont_hilb->length()); |
---|
836 | for (int j=cont_hilb->length()-1;j>actord;j--) |
---|
837 | (*(syzstr->hilb_coeffs[index]))[j-1] = (*cont_hilb)[j]; |
---|
838 | } |
---|
839 | delete cont_hilb; |
---|
840 | #ifdef SHOW_HILB |
---|
841 | Print("<h,%d>",(*(syzstr->hilb_coeffs[index+1]))[actord]); |
---|
842 | #endif |
---|
843 | } |
---|
844 | |
---|
845 | /*3 |
---|
846 | * reduces the generators of the module index in degree deg |
---|
847 | * (which are actual syzygies of the module index-1) |
---|
848 | * wrt. the ideal generated by elements of lower degrees |
---|
849 | */ |
---|
850 | static void syRedGenerOfCurrDeg_Hilb(syStrategy syzstr, int deg,int *maxindex,int *maxdeg) |
---|
851 | { |
---|
852 | ideal res=syzstr->res[1]; |
---|
853 | int i=0,k=IDELEMS(res),k1=IDELEMS(syzstr->orderedRes[1]); |
---|
854 | SSet sPairs=syzstr->resPairs[0]; |
---|
855 | |
---|
856 | while ((k>0) && (res->m[k-1]==NULL)) k--; |
---|
857 | while ((k1>0) && (syzstr->orderedRes[1]->m[k1-1]==NULL)) k1--; |
---|
858 | while ((i<(*syzstr->Tl)[0]) && (((sPairs)[i].syz==NULL) || |
---|
859 | ((sPairs)[i].order<deg))) |
---|
860 | i++; |
---|
861 | if ((i>=(*syzstr->Tl)[0]) || ((sPairs)[i].order>deg)) return; |
---|
862 | while ((i<(*syzstr->Tl)[0]) && (((sPairs)[i].syz==NULL) || |
---|
863 | ((sPairs)[i].order==deg))) |
---|
864 | { |
---|
865 | if ((sPairs)[i].syz!=NULL) |
---|
866 | { |
---|
867 | #ifdef SHOW_PROT |
---|
868 | PrintS("reduziere Erzeuger: \n"); |
---|
869 | PrintS("syz: ");poly_write((sPairs)[i].syz); |
---|
870 | #endif |
---|
871 | (sPairs)[i].syz = syRed_Hilb((sPairs)[i].syz,syzstr,1); |
---|
872 | #ifdef SHOW_PROT |
---|
873 | PrintS("erhalte Erzeuger: \n"); |
---|
874 | PrintS("syz: ");poly_write((sPairs)[i].syz); |
---|
875 | PrintLn(); |
---|
876 | #endif |
---|
877 | if ((sPairs)[i].syz != NULL) |
---|
878 | { |
---|
879 | if (k==IDELEMS(res)) |
---|
880 | { |
---|
881 | syEnlargeFields(syzstr,1); |
---|
882 | res=syzstr->res[1]; |
---|
883 | } |
---|
884 | if (TEST_OPT_DEBUG) |
---|
885 | { |
---|
886 | if ((sPairs)[i].isNotMinimal==NULL) |
---|
887 | { |
---|
888 | PrintS("\nminimal generator: "); |
---|
889 | pWrite((syzstr->resPairs[0])[i].syz); |
---|
890 | PrintS("comes from: ");pWrite((syzstr->resPairs[0])[i].p1); |
---|
891 | PrintS("and: ");pWrite((syzstr->resPairs[0])[i].p2); |
---|
892 | } |
---|
893 | } |
---|
894 | res->m[k] = (sPairs)[i].syz; |
---|
895 | pNorm(res->m[k]); |
---|
896 | syHalfPair(res->m[k],k1,syzstr,1); |
---|
897 | k1++; |
---|
898 | k++; |
---|
899 | if (1>*maxindex) *maxindex = 1; |
---|
900 | if (deg-1>*maxdeg) *maxdeg = deg-1; |
---|
901 | } |
---|
902 | } |
---|
903 | i++; |
---|
904 | } |
---|
905 | } |
---|
906 | |
---|
907 | /*3 |
---|
908 | * reorders the result (stored in orderedRes) according |
---|
909 | * to the seqence given by res |
---|
910 | */ |
---|
911 | static void syReOrdResult_Hilb(syStrategy syzstr,int maxindex,int maxdeg) |
---|
912 | { |
---|
913 | ideal reor,toreor; |
---|
914 | int i,j,k,l,m,togo; |
---|
915 | syzstr->betti = new intvec(maxdeg,maxindex+1,0); |
---|
916 | (*syzstr->betti)[0] = 1; |
---|
917 | for (i=1;i<=syzstr->length;i++) |
---|
918 | { |
---|
919 | if (!idIs0(syzstr->orderedRes[i])) |
---|
920 | { |
---|
921 | toreor = syzstr->orderedRes[i]; |
---|
922 | k = IDELEMS(toreor); |
---|
923 | while ((k>0) && (toreor->m[k-1]==NULL)) k--; |
---|
924 | reor = idInit(k,toreor->rank); |
---|
925 | togo = IDELEMS(syzstr->res[i]); |
---|
926 | for (j=0;j<k;j++) |
---|
927 | { |
---|
928 | if (toreor->m[j]!=NULL) (IMATELEM(*syzstr->betti,p_FDeg(toreor->m[j],currRing)-i+1,i+1))++; |
---|
929 | reor->m[j] = toreor->m[j]; |
---|
930 | toreor->m[j] = NULL; |
---|
931 | } |
---|
932 | m = 0; |
---|
933 | for (j=0;j<togo;j++) |
---|
934 | { |
---|
935 | if (syzstr->res[i]->m[j]!=NULL) |
---|
936 | { |
---|
937 | l = 0; |
---|
938 | while ((l<k) && (syzstr->res[i]->m[j]!=reor->m[l])) l++; |
---|
939 | if (l<k) |
---|
940 | { |
---|
941 | toreor->m[m] = reor->m[l]; |
---|
942 | reor->m[l] = NULL; |
---|
943 | m++; |
---|
944 | } |
---|
945 | } |
---|
946 | } |
---|
947 | idDelete(&reor); |
---|
948 | } |
---|
949 | } |
---|
950 | } |
---|
951 | |
---|
952 | /*2 |
---|
953 | * the CoCoA-algorithm for free resolutions, using a formula |
---|
954 | * for remaining pairs based on Hilbert-functions |
---|
955 | */ |
---|
956 | syStrategy syHilb(ideal arg,int * length) |
---|
957 | { |
---|
958 | int i,j,actdeg=32000,index=0; |
---|
959 | int howmuch,toSub=0; |
---|
960 | int maxindex=0,maxdeg=0; |
---|
961 | ideal temp=NULL; |
---|
962 | SSet nextPairs; |
---|
963 | ring origR = currRing; |
---|
964 | syStrategy syzstr=(syStrategy)omAlloc0(sizeof(ssyStrategy)); |
---|
965 | |
---|
966 | if ((idIs0(arg)) || (id_RankFreeModule(arg,currRing)>0)) |
---|
967 | { |
---|
968 | syzstr->minres = (resolvente)omAllocBin(sip_sideal_bin); |
---|
969 | syzstr->length = 1; |
---|
970 | syzstr->minres[0] = idInit(1,arg->rank); |
---|
971 | return syzstr; |
---|
972 | } |
---|
973 | |
---|
974 | // Creare dp,S ring and change to it |
---|
975 | syzstr->syRing = rAssure_dp_C(origR); |
---|
976 | rChangeCurrRing(syzstr->syRing); |
---|
977 | |
---|
978 | // set initial ShiftedComps |
---|
979 | currcomponents = (int*)omAlloc0((arg->rank+1)*sizeof(int)); |
---|
980 | currShiftedComponents = (long*)omAlloc0((arg->rank+1)*sizeof(long)); |
---|
981 | |
---|
982 | /*--- initializes the data structures---------------*/ |
---|
983 | #ifdef SHOW_CRIT |
---|
984 | crit = 0; |
---|
985 | crit1 = 0; |
---|
986 | spfl = 0; |
---|
987 | cons_pairs = 0; |
---|
988 | crit_fails = 0; |
---|
989 | #endif |
---|
990 | syzstr->length = *length = currRing->N+2; |
---|
991 | syzstr->Tl = new intvec(*length+1); |
---|
992 | temp = idInit(IDELEMS(arg),arg->rank); |
---|
993 | for (i=0;i<IDELEMS(arg);i++) |
---|
994 | { |
---|
995 | if (origR != syzstr->syRing) |
---|
996 | temp->m[i] = prCopyR( arg->m[i], origR, syzstr->syRing); |
---|
997 | else |
---|
998 | temp->m[i] = pCopy( arg->m[i]); |
---|
999 | if (temp->m[i]!=NULL) |
---|
1000 | { |
---|
1001 | j = pTotaldegree(temp->m[i]); |
---|
1002 | if (j<actdeg) actdeg = j; |
---|
1003 | } |
---|
1004 | } |
---|
1005 | idTest(temp); |
---|
1006 | idSkipZeroes(temp); |
---|
1007 | syzstr->resPairs = syInitRes(temp,length,syzstr->Tl,syzstr->cw); |
---|
1008 | omFreeSize((ADDRESS)currcomponents,(arg->rank+1)*sizeof(int)); |
---|
1009 | omFreeSize((ADDRESS)currShiftedComponents,(arg->rank+1)*sizeof(int)); |
---|
1010 | syzstr->res = (resolvente)omAlloc0((*length+1)*sizeof(ideal)); |
---|
1011 | syzstr->orderedRes = (resolvente)omAlloc0((*length+1)*sizeof(ideal)); |
---|
1012 | syzstr->elemLength = (int**)omAlloc0((*length+1)*sizeof(int*)); |
---|
1013 | syzstr->truecomponents = (int**)omAlloc0((*length+1)*sizeof(int*)); |
---|
1014 | syzstr->backcomponents = (int**)omAlloc0((*length+1)*sizeof(int*)); |
---|
1015 | syzstr->ShiftedComponents = (long**)omAlloc0((*length+1)*sizeof(long*)); |
---|
1016 | syzstr->Howmuch = (int**)omAlloc0((*length+1)*sizeof(int*)); |
---|
1017 | syzstr->Firstelem = (int**)omAlloc0((*length+1)*sizeof(int*)); |
---|
1018 | syzstr->hilb_coeffs = (intvec**)omAlloc0((*length+1)*sizeof(intvec*)); |
---|
1019 | syzstr->sev = (unsigned long **)omAlloc0((*length+1)*sizeof(unsigned long*)); |
---|
1020 | syzstr->bucket = kBucketCreate(currRing); |
---|
1021 | syzstr->syz_bucket = kBucketCreate(currRing); |
---|
1022 | nextPairs = syChosePairs(syzstr,&index,&howmuch,&actdeg); |
---|
1023 | /*--- computes the resolution ----------------------*/ |
---|
1024 | while (nextPairs!=NULL) |
---|
1025 | { |
---|
1026 | #ifdef SHOW_PROT |
---|
1027 | Print("compute %d Paare im Module %d im Grad %d \n",howmuch,index,actdeg+index); |
---|
1028 | #endif |
---|
1029 | if (TEST_OPT_PROT) Print("%d",actdeg); |
---|
1030 | if (TEST_OPT_PROT) Print("(m%d)",index); |
---|
1031 | if (index==0) |
---|
1032 | i = syInitSyzMod(syzstr,index,id_RankFreeModule(arg, origR)+1); |
---|
1033 | else |
---|
1034 | i = syInitSyzMod(syzstr,index); |
---|
1035 | j = syInitSyzMod(syzstr,index+1); |
---|
1036 | if (index>0) |
---|
1037 | { |
---|
1038 | syRedNextPairs_Hilb(nextPairs,syzstr,howmuch,index,actdeg,&toSub,&maxindex,&maxdeg); |
---|
1039 | sySetNewHilb(syzstr,toSub,index,actdeg); |
---|
1040 | toSub = 0; |
---|
1041 | syCompactifyPairSet(syzstr->resPairs[index],(*syzstr->Tl)[index],0); |
---|
1042 | } |
---|
1043 | else |
---|
1044 | syRedGenerOfCurrDeg_Hilb(syzstr,actdeg,&maxindex,&maxdeg); |
---|
1045 | /*--- creates new pairs -----------------------------*/ |
---|
1046 | #ifdef SHOW_PROT |
---|
1047 | Print("Bilde neue Paare in Modul %d!\n",index); |
---|
1048 | #endif |
---|
1049 | syCreateNewPairs_Hilb(syzstr,index,actdeg); |
---|
1050 | if (index<(*length)-1) |
---|
1051 | { |
---|
1052 | #ifdef SHOW_PROT |
---|
1053 | Print("Bilde neue Paare in Modul %d!\n",index+1); |
---|
1054 | #endif |
---|
1055 | syCreateNewPairs_Hilb(syzstr,index+1,actdeg-1); |
---|
1056 | } |
---|
1057 | index++; |
---|
1058 | nextPairs = syChosePairs(syzstr,&index,&howmuch,&actdeg); |
---|
1059 | } |
---|
1060 | syReOrdResult_Hilb(syzstr,maxindex,maxdeg); |
---|
1061 | #ifdef SHOW_RESULT |
---|
1062 | PrintS("minimal resolution:\n"); |
---|
1063 | for (int ti=1;ti<=*length;ti++) |
---|
1064 | { |
---|
1065 | if (!idIs0(syzstr->orderedRes[ti])) idPrint(syzstr->orderedRes[ti]); |
---|
1066 | } |
---|
1067 | PrintS("full resolution:\n"); |
---|
1068 | for (int ti=1;ti<=*length;ti++) |
---|
1069 | { |
---|
1070 | if (!idIs0(syzstr->res[ti])) idPrint(syzstr->res[ti]); |
---|
1071 | } |
---|
1072 | #endif |
---|
1073 | #ifdef SHOW_CRIT |
---|
1074 | Print("Criterion %d times applied\n",crit); |
---|
1075 | Print("Criterion1 %d times applied\n",crit1); |
---|
1076 | Print("%d superfluous pairs\n",spfl); |
---|
1077 | Print("%d pairs considered\n",cons_pairs); |
---|
1078 | Print("Criterion fails %d times\n",crit_fails); |
---|
1079 | crit = 0; |
---|
1080 | crit1 = 0; |
---|
1081 | spfl = 0; |
---|
1082 | cons_pairs = 0; |
---|
1083 | crit_fails = 0; |
---|
1084 | #endif |
---|
1085 | if (temp!=NULL) idDelete(&temp); |
---|
1086 | kBucketDestroy(&(syzstr->bucket)); |
---|
1087 | kBucketDestroy(&(syzstr->syz_bucket)); |
---|
1088 | if (origR != syzstr->syRing) |
---|
1089 | rChangeCurrRing(origR); |
---|
1090 | else |
---|
1091 | currRing = origR; |
---|
1092 | if (TEST_OPT_PROT) PrintLn(); |
---|
1093 | return syzstr; |
---|
1094 | } |
---|