My Project
kstdfac.cc
Go to the documentation of this file.
1/****************************************
2* Computer Algebra System SINGULAR *
3****************************************/
4/*
5* ABSTRACT - Kernel: factorizing alg. of Buchberger
6*/
7
8#include "kernel/mod2.h"
9#include "misc/options.h"
10#include "kernel/polys.h"
11#include "kernel/ideals.h"
15#include "polys/weight.h"
16#include "misc/intvec.h"
17#include "polys/clapsing.h"
18#include "kernel/ideals.h"
20
22/*3
23* copy o->T to n->T, assumes that n->S is already copied
24*/
25static void copyT (kStrategy o,kStrategy n)
26{
27 int i,j;
28 poly p;
29 TSet t=(TSet)omAlloc0(o->tmax*sizeof(TObject));
30 TObject** r = (TObject**)omAlloc0(o->tmax*sizeof(TObject*));
31
32 for (j=0; j<=o->tl; j++)
33 {
34 t[j] = o->T[j];
35 r[t[j].i_r] = &t[j];
36 p = o->T[j].p;
37 i = -1;
38 loop
39 {
40 i++;
41 if (i>o->sl)
42 {
43 t[j].p=pCopy(p);
44 break;
45 }
46 if (p == o->S[i])
47 {
48 t[j].p=n->S[i];
49 break;
50 }
51 }
52 t[j].t_p = NULL; // ?? or t[j].p ??
53 t[j].max_exp = NULL; // ?? or p_GetMaxExpP(t[j].t_p,o->tailRing); ??
54 t[j].pLength = pLength(p);
55 }
56 n->T=t;
57 n->R=r;
58}
59
60/*3
61* copy o->L to n->L, assumes that n->T,n->tail is already copied
62*/
63static void copyL (kStrategy o,kStrategy n)
64{
65 int i,j;
66 poly p;
67 LSet l=(LSet)omAlloc(o->Lmax*sizeof(LObject));
68
69 for (j=0; j<=o->Ll; j++)
70 {
71 l[j] = o->L[j];
72 // copy .p ----------------------------------------------
73 if (pNext(o->L[j].p)!=o->tail)
74 l[j].p=pCopy(o->L[j].p);
75 else
76 {
77 l[j].p=p_LmInit(o->L[j].p,currRing);
78 if (pGetCoeff(o->L[j].p)!=NULL) pSetCoeff0(l[j].p,nCopy(pGetCoeff(o->L[j].p)));
79 pNext(l[j].p)=n->tail;
80 }
81 // copy .lcm ----------------------------------------------
82 if (o->L[j].lcm!=NULL)
83 l[j].lcm=pLmInit(o->L[j].lcm);
84 else
85 l[j].lcm=NULL;
86 l[j].p1=NULL;
87 l[j].p2=NULL;
88 l[j].t_p = NULL;
89
90 // copy .p1 , i_r1----------------------------------------------
91 p = o->L[j].p1;
92 i = -1;
93 loop
94 {
95 if(p==NULL) break;
96 i++;
97 if(i>o->tl)
98 {
99 WarnS("poly p1 not found in T:");wrp(p);PrintLn();
100 l[j].p1=pCopy(p);
101 l[j].i_r1=-1;
102 break;
103 }
104 if (p == o->T[i].p)
105 {
106 l[j].p1=n->T[i].p;
107 l[j].i_r1=n->T[i].i_r;
108 break;
109 }
110 }
111
112 // copy .p2 , i_r2----------------------------------------------
113 p = o->L[j].p2;
114 i = -1;
115 loop
116 {
117 if(p==NULL) break;
118 i++;
119 if(i>o->tl)
120 {
121 WarnS("poly p2 not found in T:");wrp(p);PrintLn();
122 l[j].p2=pCopy(p);
123 l[j].i_r2=-1;
124 break;
125 }
126 if (p == o->T[i].p)
127 {
128 l[j].p2=n->T[i].p;
129 l[j].i_r2=n->T[i].i_r;
130 break;
131 }
132 }
133
134 // copy .ecart ---------------------------------------------
135 l[j].ecart=o->L[j].ecart;
136 // copy .length --------------------------------------------
137 l[j].length=o->L[j].length;
138 // copy .pLength -------------------------------------------
139 l[j].pLength=o->L[j].pLength;
140 // copy .sev -----------------------------------------------
141 l[j].sev=o->L[j].sev;
142 l[j].i_r = o->L[j].i_r;
143 //l[j].i_r1 = o->L[j].i_r1;
144 //l[j].i_r2 = o->L[j].i_r2;
145 }
146 n->L=l;
147}
148
150{
151 // int i;
152 kTest_TS(o);
154 s->next=NULL;
155 s->red=o->red;
156 s->initEcart=o->initEcart;
157 s->posInT=o->posInT;
158 s->posInL=o->posInL;
159 s->enterS=o->enterS;
160 s->initEcartPair=o->initEcartPair;
161 s->posInLOld=o->posInLOld;
162 s->enterOnePair=o->enterOnePair;
163 s->chainCrit=o->chainCrit;
164 s->Shdl=idCopy(o->Shdl);
165 s->S=s->Shdl->m;
166 s->tailRing = o->tailRing;
167 if (o->D!=NULL) s->D=idCopy(o->D);
168 else s->D=NULL;
169 s->ecartS=(int *)omAlloc(IDELEMS(o->Shdl)*sizeof(int));
170 memcpy(s->ecartS,o->ecartS,IDELEMS(o->Shdl)*sizeof(int));
171 s->sevS=(unsigned long *)omAlloc(IDELEMS(o->Shdl)*sizeof(unsigned long));
172 memcpy(s->sevS,o->sevS,IDELEMS(o->Shdl)*sizeof(unsigned long));
173 s->S_2_R=(int*)omAlloc(IDELEMS(o->Shdl)*sizeof(int));
174 memcpy(s->S_2_R,o->S_2_R,IDELEMS(o->Shdl)*sizeof(int));
175 s->sevT=(unsigned long *)omAlloc(o->tmax*sizeof(unsigned long));
176 memcpy(s->sevT,o->sevT,o->tmax*sizeof(unsigned long));
177 if(o->fromQ!=NULL)
178 {
179 s->fromQ=(int *)omAlloc(IDELEMS(o->Shdl)*sizeof(int));
180 memcpy(s->fromQ,o->fromQ,IDELEMS(o->Shdl)*sizeof(int));
181 }
182 else
183 s->fromQ=NULL;
184 copyT(o,s);//s->T=...
185 s->tail = pInit();
186 copyL(o,s);//s->L=...
187 s->B=initL();
188 s->kHEdge=pCopy(o->kHEdge);
189 s->kNoether=pCopy(o->kNoether);
190 if (o->NotUsedAxis!=NULL)
191 {
192 s->NotUsedAxis=(BOOLEAN *)omAlloc(currRing->N*sizeof(BOOLEAN));
193 memcpy(s->NotUsedAxis,o->NotUsedAxis,currRing->N*sizeof(BOOLEAN));
194 }
195 //s->P=s->L[s->Ll+1];
196 s->P.Init(o->tailRing);
197 s->update=o->update;
198 s->posInLOldFlag=o->posInLOldFlag;
199 s->kModW = o->kModW;
200// if (o->kModW!=NULL)
201// s->kModW=ivCopy(o->kModW);
202// else
203// s->kModW=NULL;
204 s->pairtest=NULL;
205 s->sl=o->sl;
206 s->mu=o->mu;
207 s->tl=o->tl;
208 s->tmax=o->tmax;
209 s->Ll=o->Ll;
210 s->Lmax=o->Lmax;
211 s->Bl=-1;
212 s->Bmax=setmaxL;
213 s->ak=o->ak;
214 s->syzComp=o->syzComp;
215 s->LazyPass=o->LazyPass;
216 s->LazyDegree=o->LazyDegree;
217 s->HCord=o->HCord;
218 s->lastAxis=o->lastAxis;
219 s->interpt=o->interpt;
220 s->homog=o->homog;
221 s->news=o->news;
222 s->newt=o->newt;
223 s->kHEdgeFound=o->kHEdgeFound;
224 s->honey=o->honey;
225 s->sugarCrit=o->sugarCrit;
226 s->Gebauer=o->Gebauer;
227 s->noTailReduction=o->noTailReduction;
228 s->fromT=o->fromT;
229 s->noetherSet=o->noetherSet;
230#ifdef HAVE_PLURAL
231 s->no_prod_crit=o->no_prod_crit;
232#endif
233 kTest_TS(s);
234 return s;
235}
236
237BOOLEAN k_factorize(poly p,ideal &rfac, ideal &fac_copy)
238{
239 int facdeg=currRing->pFDeg(p,currRing);
240 ideal fac=singclap_factorize(pCopy(p),NULL,1,currRing);
241 int fac_elems;
242 fac_elems=IDELEMS(fac);
243 rfac=fac;
244 fac_copy=idInit(fac_elems,1);
245
246 if ((fac_elems!=1)||(facdeg!=currRing->pFDeg(fac->m[0],currRing)))
247 {
248 if (TEST_OPT_DEBUG)
249 {
250 Print("%d factors:\n",fac_elems);
251 pWrite(p); PrintS(" ->\n");
252 int ii=fac_elems;
253 while(ii>0) { ii--;pWrite(fac->m[ii]); }
254 }
255 else if (TEST_OPT_PROT)
256 {
257 int ii=fac_elems;
258 if (ii>1)
259 {
260 while(ii>0) { PrintS("F"); ii--; }
261 }
262 }
263 return TRUE;
264 }
265 else
266 {
267 pDelete(&(fac->m[0]));
268 fac->m[0]=pCopy(p);
269 }
270 return FALSE;
271}
272
273static void completeReduceFac (kStrategy strat, ideal_list FL)
274{
275 int si;
276
277 strat->noTailReduction = FALSE;
278 if (TEST_OPT_PROT)
279 {
280 PrintLn();
281// if (timerv) writeTime("standard base computed:");
282 }
283 if (TEST_OPT_PROT)
284 {
285 Print("(S:%d)",strat->sl);mflush();
286 }
287 for (si=strat->sl; si>0; si--)
288 {
289 strat->S[si] = redtailBba(strat->S[si],si-1,strat);
291 {
292 strat->S[si]=p_Cleardenom(strat->S[si], currRing);
293 }
294 if (TEST_OPT_PROT)
295 {
296 PrintS("-");mflush();
297 }
298 int i;
299 if (strat->redTailChange)
300 {
301 for(i=strat->tl;i>=0;i--)
302 {
303 strat->initEcart(&strat->T[i]);
304 }
305 }
306 ideal fac;
307 ideal fac_copy;
308
309 if (!k_factorize(strat->S[si],fac,fac_copy))
310 {
311 idDelete(&fac);
312 idDelete(&fac_copy);
313 continue;
314 }
315
316 deleteInS(si,strat);
317
318 for(i=IDELEMS(fac)-1;i>=0;i--)
319 {
320 kStrategy n=strat;
321 if (i>=1)
322 {
323 n=kStratCopy(strat); // includes: memset(&n->P,0,sizeof(n->P));
324 n->next=strat->next;
325 strat->next=n;
326 }
327 else
328 {
329 n->P.Init(strat->tailRing);
330 }
331
332 n->P.p=fac->m[i];
333 //n->P.pLength=pLength(n->P.p); // by initEcart
334 n->initEcart(&n->P);
335 /* enter P.p into s and L */
336 int pos;
337 if (n->sl==-1) pos=0;
338 else pos=posInS(n,n->sl,n->P.p,n->P.ecart);
340 {
341 n->P.p = redtailBba(n->P.p,pos-1,n);
342 n->P.pCleardenom();
343 }
344 else
345 {
346 pNorm(n->P.p);
347 n->P.p = redtailBba(n->P.p,pos-1,n);
348 }
349 n->P.pLength=pLength(n->P.p);
350 if (TEST_OPT_DEBUG)
351 {
352 Print("new s(%d)->S:",n->nr);
353 pWrite(n->P.p);
354 }
355 enterpairs(n->P.p,n->sl,n->P.ecart,pos,n);
356 enterT(n->P,n);
357 n->enterS(n->P,pos,n, n->tl);
358
359 /* construct D */
360 if (IDELEMS(fac)>1)
361 {
362 if (n->D==NULL)
363 {
364 n->D=idCopy(fac_copy);
365 idSkipZeroes(n->D);
366 }
367 else
368 {
369 idTest(n->D);
370 ideal r=idAdd(n->D,fac_copy);
371 idDelete(&n->D);
372 n->D=r;
373 }
374 if (TEST_OPT_DEBUG)
375 {
376 Print("new s(%d)->D:\n",n->nr);
377 iiWriteMatrix((matrix)n->D,"D",1,currRing,0);
378 PrintLn();
379 }
380 }
381
382 fac_copy->m[i]=pCopy(fac->m[i]);
383 fac->m[i]=NULL;
384
385 /* check for empty sets */
386 if (n->D!=NULL)
387 {
388 int j=IDELEMS(n->D)-1;
389 while(j>=0)
390 {
391 if (n->D->m[j]!=NULL)
392 {
393 poly r=kNF(n->Shdl,NULL,n->D->m[j],0,KSTD_NF_LAZY | KSTD_NF_NONORM);
394 if (r==NULL)
395 {
396 if (TEST_OPT_DEBUG)
397 {
398 Print("empty set s(%d) because D[%d]:",n->nr,j);
399 pWrite(n->D->m[j]);
400 messageSets(n);
401 }
402 while (n->Ll >= 0) deleteInL(n->L,&n->Ll,n->Ll,n);
403 while (n->tl >= 0)
404 {
405 int i=n->sl;
406 while (i>=0)
407 {
408 if (n->S[i]==n->T[n->tl].p)
409 {
410 n->T[n->tl].p=NULL; n->S[i]=NULL;
411 break;
412 }
413 i--;
414 }
415 pDelete(&n->T[n->tl].p);
416 n->tl--;
417 }
418 memset(n->Shdl->m,0,IDELEMS(n->Shdl)*sizeof(poly));
419 n->sl=-1;
420 if (strat==n) si=-1;
421 break;
422 }
423 else
424 {
425 pDelete(&r);
426 }
427 }
428 j--;
429 }
430 }
431 /* check for empty sets */
432 {
433 ideal_list Lj=FL;
434 while (Lj!=NULL)
435 {
436 if ((n->sl>=0)&&(n->S[0]!=NULL))
437 {
438 ideal r=kNF(n->Shdl,NULL,Lj->d,0,KSTD_NF_LAZY | KSTD_NF_NONORM);
439 if (idIs0(r))
440 {
441 if (TEST_OPT_DEBUG)
442 {
443 Print("empty set because:L[%p]\n",(void *)Lj);
444 iiWriteMatrix((matrix)Lj->d,"L",1,currRing,0);
445 }
446 while (n->Ll >= 0) deleteInL(n->L,&n->Ll,n->Ll,n);
447 while (n->tl >= 0)
448 {
449 int i=n->sl;
450 while (i>=0)
451 {
452 if (n->S[i]==n->T[n->tl].p)
453 {
454 n->T[n->tl].p=NULL; n->S[i]=NULL;
455 break;
456 }
457 i--;
458 }
459 pDelete(&n->T[n->tl].p);
460 n->tl--;
461 }
462 memset(n->Shdl->m,0,IDELEMS(n->Shdl)*sizeof(poly));
463 n->sl=-1;
464 if (strat==n) si=-1;
465 idDelete(&r);
466 break;
467 }
468 idDelete(&r);
469 }
470 Lj=Lj->next;
471 }
472 }
473 } /* for */
474 for(i=0;i<IDELEMS(fac);i++) fac->m[i]=NULL;
475 idDelete(&fac);
476 idDelete(&fac_copy);
477 if ((strat->Ll>=0) && (strat->sl>=0)) break;
478 else si=strat->sl+1;
479 }
480}
481
482ideal bbafac (ideal /*F*/, ideal Q,intvec */*w*/,kStrategy strat, ideal_list FL)
483{
484 int olddeg,reduc=0;
485 int red_result = 1;
486 reduc = olddeg = 0;
487 /* compute------------------------------------------------------- */
488 if ((strat->Ll==-1) && (strat->sl>=0))
489 {
490 if (TEST_OPT_REDSB) completeReduceFac(strat,FL);
491 }
492 kTest_TS(strat);
493 while (strat->Ll >= 0)
494 {
495 if (TEST_OPT_DEBUG) messageSets(strat);
496 if (strat->Ll== 0) strat->interpt=TRUE;
498 && ((strat->honey
499 && (strat->L[strat->Ll].ecart+currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))
500 || ((!strat->honey) && (currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))))
501 {
502 /*
503 *stops computation if
504 * 24 IN test and the degree +ecart of L[strat->Ll] is bigger then
505 *a predefined number Kstd1_deg
506 */
507 while (strat->Ll >= 0) deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
508 break;
509 }
510 /* picks the last element from the lazyset L */
511 strat->P = strat->L[strat->Ll];
512 strat->Ll--;
513 if (pNext(strat->P.p) == strat->tail)
514 {
515 /* deletes the short spoly and computes */
516 pLmFree(strat->P.p);
517 /* the real one */
518 strat->P.p = ksOldCreateSpoly(strat->P.p1,
519 strat->P.p2,
520 strat->kNoether);
521 }
522 if (strat->honey)
523 {
524 if (TEST_OPT_PROT)
525 message(strat->P.ecart+currRing->pFDeg(strat->P.p,currRing),&olddeg,&reduc,strat, red_result);
526 }
527 else
528 {
529 if (TEST_OPT_PROT)
530 message(currRing->pFDeg(strat->P.p,currRing),&olddeg,&reduc,strat, red_result);
531 }
532 /* reduction of the element chosen from L */
533 kTest_TS(strat);
534 red_result = strat->red(&strat->P,strat);
535 if (strat->P.p != NULL)
536 {
537 /* statistic */
538 if (TEST_OPT_PROT) PrintS("s");
539 ideal fac;
540 ideal fac_copy;
541
542 if (!k_factorize(strat->P.p,fac,fac_copy))
543 {
545 {
546 strat->P.p = redtailBba(strat->P.p,strat->sl,strat);
547 if (strat->redTailChange) strat->P.pCleardenom();
548 }
549 else
550 {
551 pNorm(strat->P.p);
552 strat->P.p = redtailBba(strat->P.p,strat->sl,strat);
553 }
554 if (strat->redTailChange)
555 {
556 idDelete(&fac);
557 idDelete(&fac_copy);
558 if (!k_factorize(strat->P.p,fac,fac_copy))
559 {
560 pDelete(&(fac->m[0]));
561 fac->m[0]=strat->P.p;
562 strat->P.p=NULL;
563 }
564 else
565 {
566 pDelete(&strat->P.p);
567 }
568 }
569 }
570 kDeleteLcm(&strat->P);
571 int i;
572
573 for(i=IDELEMS(fac)-1;i>=0;i--)
574 {
575 int ii;
576 kStrategy n=strat;
577 if (i>=1)
578 {
579 n=kStratCopy(strat); // includes memset(&n->P,0,sizeof(n->P));
580 kTest_TS(n);
581 n->next=strat->next;
582 strat->next=n;
583 }
584 else
585 {
586 n->P.Init(strat->tailRing);
587 }
588
589 n->P.p=fac->m[i];
590 //n->P.pLength=pLength(n->P.p); // by initEcart
591 n->initEcart(&n->P);
592 kTest_TS(n);
593
594 /* enter P.p into s and L */
595 int pos;
596 if (n->sl==-1) pos=0;
597 else pos=posInS(n,n->sl,n->P.p,n->P.ecart);
598
599 // we have already reduced all elements from fac....
601 {
602 n->P.p = redtailBba(n->P.p,pos-1,n);
603 if (n->redTailChange)
604 {
605 n->P.pCleardenom();
606 n->P.pLength=pLength(n->P.p);
607 }
608 }
609 else
610 {
611 pNorm(n->P.p);
612 n->P.p = redtailBba(n->P.p,pos-1,n);
613 if (n->redTailChange)
614 {
615 n->P.pLength=pLength(n->P.p);
616 }
617 }
618 kTest_TS(n);
619
620 if (TEST_OPT_DEBUG)
621 {
622 PrintS("new s:");
623 wrp(n->P.p);
624 PrintLn();
625 }
626 enterpairs(n->P.p,n->sl,n->P.ecart,pos,n);
627 enterT(n->P,n);
628 n->enterS(n->P,pos,n, n->tl);
629 {
630 int i=n->Ll;
631 for(;i>=0;i--)
632 {
633 n->L[i].i_r1= -1;
634 for(ii=0; ii<=n->tl; ii++)
635 {
636 if (n->R[ii]->p==n->L[i].p1) { n->L[i].i_r1=ii;break; }
637 }
638 n->L[i].i_r2= -1;
639 for(ii=0; ii<=n->tl; ii++)
640 {
641 if (n->R[ii]->p==n->L[i].p2) { n->L[i].i_r2=ii;break; }
642 }
643 }
644 }
645 kTest_TS(n);
646 /* construct D */
647 if (IDELEMS(fac)>1)
648 {
649 if (n->D==NULL)
650 {
651 n->D=idCopy(fac_copy);
652 idSkipZeroes(n->D);
653 }
654 else
655 {
656 idTest(n->D);
657 ideal r=idAdd(n->D,fac_copy);
658 idDelete(&n->D);
659 n->D=r;
660 }
661 if (TEST_OPT_DEBUG)
662 {
663 PrintS("new D:\n");
664 iiWriteMatrix((matrix)n->D,"D",1,currRing,0);
665 PrintLn();
666 }
667 }
668
669 fac_copy->m[i]=pCopy(fac->m[i]);
670 fac->m[i]=NULL;
671
672 /* check for empty sets */
673 if (n->D!=NULL)
674 {
675 int j=IDELEMS(n->D)-1;
676 while(j>=0)
677 {
678 if (n->D->m[j]!=NULL)
679 {
680 poly r=kNF(n->Shdl,NULL,n->D->m[j],0,KSTD_NF_LAZY | KSTD_NF_NONORM);
681 if (r==NULL)
682 {
683 if (TEST_OPT_DEBUG)
684 {
685 Print("empty set s(%d) because: D[%d]:", n->nr,j);
686 pWrite(n->D->m[j]);
687 messageSets(n);
688 }
689 //if (n->Ll >=0) Print("Ll:%d|",n->Ll);
690 while (n->Ll >= 0) deleteInL(n->L,&n->Ll,n->Ll,n);
691 //if (n->tl >=0) Print("tl:%d|",n->tl);
692 while (n->tl >= 0)
693 {
694 int i=n->sl;
695 while (i>=0)
696 {
697 if (n->S[i]==n->T[n->tl].p)
698 {
699 n->T[n->tl].p=NULL; n->S[i]=NULL;
700 break;
701 }
702 i--;
703 }
704 pDelete(&n->T[n->tl].p);
705 n->tl--;
706 }
707 memset(n->Shdl->m,0,IDELEMS(n->Shdl)*sizeof(poly));
708 n->sl=-1;
709 break;
710 }
711 else
712 {
713 pDelete(&r);
714 }
715 }
716 j--;
717 }
718 }
719
720 /* check for empty sets */
721 {
722 ideal_list Lj=FL;
723 while (Lj!=NULL)
724 {
725 if ((n->sl>=0)&&(n->S[0]!=NULL))
726 {
727 ideal r=kNF(n->Shdl,NULL,Lj->d,0,KSTD_NF_LAZY | KSTD_NF_NONORM);
728 if (idIs0(r))
729 {
730 if (TEST_OPT_DEBUG)
731 {
732 #ifdef KDEBUG
733 Print("empty set s(%d) because:L[%d]\n",n->nr,Lj->nr);
734 #else
735 Print("empty set s(%d) because:\n",n->nr);
736 #endif
737 iiWriteMatrix((matrix)Lj->d,"L",1,currRing,0);
738 }
739 while (n->Ll >= 0) deleteInL(n->L,&n->Ll,n->Ll,n);
740 while (n->tl >= 0)
741 {
742 int i=n->sl;
743 while (i>=0)
744 {
745 if (n->S[i]==n->T[n->tl].p)
746 {
747 n->T[n->tl].p=NULL; n->S[i]=NULL;
748 break;
749 }
750 i--;
751 }
752 pDelete(&n->T[n->tl].p);
753 n->tl--;
754 }
755 memset(n->Shdl->m,0,IDELEMS(n->Shdl)*sizeof(poly));
756 n->sl=-1;
757 idDelete(&r);
758 break;
759 }
760 idDelete(&r);
761 }
762 Lj=Lj->next;
763 }
764 }
765 } /* for */
766 for(i=0;i<IDELEMS(fac);i++) fac->m[i]=NULL;
767 idDelete(&fac);
768 idDelete(&fac_copy);
769 }
770#ifdef KDEBUG
771 strat->P.lcm=NULL;
772#endif
773 kTest_TS(strat);
774 if ((strat->Ll==-1) && (strat->sl>=0))
775 {
776 if (TEST_OPT_REDSB) completeReduceFac(strat,FL);
777 }
778 kTest_TS(strat);
779 }
780#ifdef KDEBUG
781 if (TEST_OPT_DEBUG) messageSets(strat);
782#endif
783 /* complete reduction of the standard basis--------- */
784 /* release temp data-------------------------------- */
786 {
788 if (ecartWeights)
789 {
790 omFreeSize((ADDRESS)ecartWeights,((currRing->N)+1)*sizeof(short));
792 }
793 }
794 exitBuchMora(strat);
795 if (TEST_OPT_PROT) { PrintLn(); messageStat(0,strat); }
796 if (Q!=NULL) updateResult(strat->Shdl,Q,strat);
797 return (strat->Shdl);
798}
799
800ideal_list kStdfac(ideal F, ideal Q, tHomog h,intvec ** w,ideal D)
801{
802 ideal r;
803 BOOLEAN b=currRing->pLexOrder,toReset=FALSE;
804 BOOLEAN delete_w=(w==NULL);
805 kStrategy strat=new skStrategy;
806 kStrategy orgstrat=strat;
807 ideal_list L=NULL;
808
810 strat->LazyPass=20;
811 else
812 strat->LazyPass=2;
813 strat->LazyDegree = 1;
814 strat->ak = id_RankFreeModule(F,currRing);
815 if (h==testHomog)
816 {
817 if (strat->ak==0)
818 {
819 h = (tHomog)idHomIdeal(F,Q);
820 w=NULL;
821 }
822 else
823 h = (tHomog)idHomModule(F,Q,w);
824 }
825 if (h==isHomog)
826 {
827 if ((w!=NULL) && (*w!=NULL))
828 {
829 kModW = *w;
830 strat->kModW = *w;
831 strat->pOrigFDeg = currRing->pFDeg;
832 strat->pOrigLDeg = currRing->pLDeg;
834 toReset = TRUE;
835 }
836 currRing->pLexOrder = TRUE;
837 strat->LazyPass*=2;
838 }
839 strat->homog=h;
840 initBuchMoraCrit(strat); /*set Gebauer, honey, sugarCrit*/
841 initBuchMoraPos(strat);
842 initBba(strat);
843 initBuchMora(F, Q,strat);
844 if (D!=NULL)
845 {
846 strat->D=idCopy(D);
847 }
848// Ende der Initalisierung
849 while (strat!=NULL)
850 {
851 if (TEST_OPT_DEBUG)
852 PrintS("====================================\n");
853 if (w!=NULL)
854 r=bbafac(F,Q,*w,strat,L);
855 else
856 r=bbafac(F,Q,NULL,strat,L);
857#ifdef KDEBUG
858 int i;
859 for (i=0; i<IDELEMS(r); i++) pTest(r->m[i]);
860#endif
861 idSkipZeroes(r);
862 // Testausgabe:
863 //if (!idIs0(r))
864 //{
865 // PrintS("===================================================\n");
866 // iiWriteMatrix((matrix)r,"S",1,currRing,0);
867 // PrintS("\n===================================================\n");
868 //}
869 //else
870 //{
871 // PrintS("=========empty============================\n");
872 //}
873 if(!idIs0(r))
874 {
875 ideal_list LL=(ideal_list)omAlloc(sizeof(*LL));
876 LL->d=r;
877#ifndef SING_NDEBUG
878 LL->nr=strat->nr;
879#endif
880 LL->next=L;
881 L=LL;
882 }
883 strat=strat->next;
884 }
885 /* check for empty sets */
886 if (L!=NULL)
887 {
888 ideal_list Lj=L->next;
889 ideal_list Lj_prev=L;
890 while (Lj!=NULL)
891 {
892 ideal_list Li=L;
893 while(Li!=Lj)
894 {
895 ideal r=kNF(Lj->d,NULL,Li->d,0,KSTD_NF_LAZY | KSTD_NF_NONORM);
896 if (idIs0(r))
897 {
898#ifdef KDEBUG
899 if (TEST_OPT_DEBUG)
900 {
901 Print("empty set L[%p] because:L[%p]\n",(void*)Lj,(void*)Li);
902 }
903#endif
904 // delete L[j],
905 Li=L;
906 if (Lj_prev!=NULL)
907 {
908 Lj=Lj_prev;
909 if (Lj==L) Lj_prev=NULL;
910 else
911 {
912 Lj_prev=L;
913 while(Lj_prev->next!=Lj) Lj_prev=Lj_prev->next;
914 }
915 }
916 else Lj=NULL;
917 }
918 else
919 {
920 Li=Li->next;
921 }
922 idDelete (&r);
923 }
924 if (Lj!=NULL) Lj=Lj->next;
925 }
926 }
927// Ende: aufraeumen
928 if (toReset)
929 {
931 kModW = NULL;
932 }
933 currRing->pLexOrder = b;
934 delete(strat);
935 strat=orgstrat;
936 while (strat!=NULL)
937 {
938 orgstrat=strat->next;
939 delete(strat);
940 strat=orgstrat;
941 }
942 if ((delete_w)&&(w!=NULL)&&(*w!=NULL)) delete *w;
943 return L;
944}
#define NULL
Definition: auxiliary.h:104
int BOOLEAN
Definition: auxiliary.h:87
#define TRUE
Definition: auxiliary.h:100
#define FALSE
Definition: auxiliary.h:96
void * ADDRESS
Definition: auxiliary.h:119
int l
Definition: cfEzgcd.cc:100
int i
Definition: cfEzgcd.cc:132
int p
Definition: cfModGcd.cc:4080
CanonicalForm b
Definition: cfModGcd.cc:4105
ideal singclap_factorize(poly f, intvec **v, int with_exps, const ring r)
Definition: clapsing.cc:914
Definition: intvec.h:23
kStrategy next
Definition: kutil.h:278
intvec * kModW
Definition: kutil.h:338
int syzComp
Definition: kutil.h:357
int * S_2_R
Definition: kutil.h:345
ring tailRing
Definition: kutil.h:346
void(* chainCrit)(poly p, int ecart, kStrategy strat)
Definition: kutil.h:292
ideal D
Definition: kutil.h:305
char noTailReduction
Definition: kutil.h:382
char posInLOldFlag
Definition: kutil.h:386
int Ll
Definition: kutil.h:354
TSet T
Definition: kutil.h:327
char news
Definition: kutil.h:404
intset ecartS
Definition: kutil.h:310
char honey
Definition: kutil.h:381
polyset S
Definition: kutil.h:307
poly kNoether
Definition: kutil.h:331
BOOLEAN * NotUsedAxis
Definition: kutil.h:335
int ak
Definition: kutil.h:356
TObject ** R
Definition: kutil.h:343
poly kHEdge
Definition: kutil.h:330
int lastAxis
Definition: kutil.h:359
int tl
Definition: kutil.h:353
unsigned long * sevT
Definition: kutil.h:326
int nr
Definition: kutil.h:349
poly tail
Definition: kutil.h:337
char sugarCrit
Definition: kutil.h:381
int(* posInL)(const LSet set, const int length, LObject *L, const kStrategy strat)
Definition: kutil.h:285
ideal Shdl
Definition: kutil.h:304
pFDegProc pOrigFDeg
Definition: kutil.h:297
int tmax
Definition: kutil.h:353
int(* posInLOld)(const LSet Ls, const int Ll, LObject *Lo, const kStrategy strat)
Definition: kutil.h:289
void(* initEcartPair)(LObject *h, poly f, poly g, int ecartF, int ecartG)
Definition: kutil.h:288
char noetherSet
Definition: kutil.h:384
char Gebauer
Definition: kutil.h:382
intset fromQ
Definition: kutil.h:322
void(* enterS)(LObject &h, int pos, kStrategy strat, int atR)
Definition: kutil.h:287
char newt
Definition: kutil.h:405
int mu
Definition: kutil.h:351
char interpt
Definition: kutil.h:375
char redTailChange
Definition: kutil.h:403
char fromT
Definition: kutil.h:383
void(* initEcart)(TObject *L)
Definition: kutil.h:281
LObject P
Definition: kutil.h:303
int Lmax
Definition: kutil.h:354
int LazyPass
Definition: kutil.h:356
char no_prod_crit
Definition: kutil.h:398
void(* enterOnePair)(int i, poly p, int ecart, int isFromQ, kStrategy strat, int atR)
Definition: kutil.h:291
LSet L
Definition: kutil.h:328
int(* posInT)(const TSet T, const int tl, LObject &h)
Definition: kutil.h:282
int(* red)(LObject *L, kStrategy strat)
Definition: kutil.h:279
int sl
Definition: kutil.h:351
int LazyDegree
Definition: kutil.h:356
char kHEdgeFound
Definition: kutil.h:380
unsigned long * sevS
Definition: kutil.h:323
int HCord
Definition: kutil.h:358
char homog
Definition: kutil.h:376
pLDegProc pOrigLDeg
Definition: kutil.h:298
char update
Definition: kutil.h:385
#define Print
Definition: emacs.cc:80
#define WarnS
Definition: emacs.cc:78
const CanonicalForm int s
Definition: facAbsFact.cc:51
const CanonicalForm & w
Definition: facAbsFact.cc:51
int j
Definition: facHensel.cc:110
#define D(A)
Definition: gentable.cc:131
#define VAR
Definition: globaldefs.h:5
#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
static BOOLEAN idHomIdeal(ideal id, ideal Q=NULL)
Definition: ideals.h:91
ideal idCopy(ideal A)
Definition: ideals.h:60
ideal idAdd(ideal h1, ideal h2)
h1 + h2
Definition: ideals.h:68
STATIC_VAR Poly * h
Definition: janet.cc:971
STATIC_VAR jList * Q
Definition: janet.cc:30
KINLINE poly ksOldCreateSpoly(poly p1, poly p2, poly spNoether, ring r)
Definition: kInline.h:1162
KINLINE poly redtailBba(poly p, int pos, kStrategy strat, BOOLEAN normalize)
Definition: kInline.h:1180
long kModDeg(poly p, ring r)
Definition: kstd1.cc:2407
void initBba(kStrategy strat)
Definition: kstd1.cc:1670
VAR intvec * kModW
Definition: kstd1.cc:2405
poly kNF(ideal F, ideal Q, poly p, int syzComp, int lazyReduce)
Definition: kstd1.cc:3169
#define KSTD_NF_LAZY
Definition: kstd1.h:17
EXTERN_VAR int Kstd1_deg
Definition: kstd1.h:49
#define KSTD_NF_NONORM
Definition: kstd1.h:21
static void copyL(kStrategy o, kStrategy n)
Definition: kstdfac.cc:63
static void completeReduceFac(kStrategy strat, ideal_list FL)
Definition: kstdfac.cc:273
kStrategy kStratCopy(kStrategy o)
Definition: kstdfac.cc:149
ideal_list kStdfac(ideal F, ideal Q, tHomog h, intvec **w, ideal D)
Definition: kstdfac.cc:800
static void copyT(kStrategy o, kStrategy n)
Definition: kstdfac.cc:25
BOOLEAN k_factorize(poly p, ideal &rfac, ideal &fac_copy)
Definition: kstdfac.cc:237
ideal bbafac(ideal, ideal Q, intvec *, kStrategy strat, ideal_list FL)
Definition: kstdfac.cc:482
VAR int strat_nr
Definition: kstdfac.cc:21
void message(int i, int *reduc, int *olddeg, kStrategy strat, int red_result)
Definition: kutil.cc:7706
void initBuchMora(ideal F, ideal Q, kStrategy strat)
Definition: kutil.cc:9995
void enterT(LObject &p, kStrategy strat, int atT)
Definition: kutil.cc:9372
BOOLEAN kTest_TS(kStrategy strat)
Definition: kutil.cc:1071
void enterpairs(poly h, int k, int ecart, int pos, kStrategy strat, int atR)
Definition: kutil.cc:4525
void initBuchMoraPos(kStrategy strat)
Definition: kutil.cc:9822
void exitBuchMora(kStrategy strat)
Definition: kutil.cc:10079
int posInS(const kStrategy strat, const int length, const poly p, const int ecart_p)
Definition: kutil.cc:4701
void updateResult(ideal r, ideal Q, kStrategy strat)
Definition: kutil.cc:10320
void deleteInL(LSet set, int *length, int j, kStrategy strat)
Definition: kutil.cc:1244
void initBuchMoraCrit(kStrategy strat)
Definition: kutil.cc:9670
void messageSets(kStrategy strat)
Definition: kutil.cc:7779
void deleteInS(int i, kStrategy strat)
Definition: kutil.cc:1137
void messageStat(int hilbcount, kStrategy strat)
Definition: kutil.cc:7747
TObject * TSet
Definition: kutil.h:59
#define setmaxL
Definition: kutil.h:30
static LSet initL(int nr=setmaxL)
Definition: kutil.h:425
LObject * LSet
Definition: kutil.h:60
static void kDeleteLcm(LObject *P)
Definition: kutil.h:877
class sTObject TObject
Definition: kutil.h:57
class sLObject LObject
Definition: kutil.h:58
void iiWriteMatrix(matrix im, const char *n, int dim, const ring r, int spaces)
set spaces to zero by default
Definition: matpol.cc:834
#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 nCopy(n)
Definition: numbers.h:15
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
#define omAlloc(size)
Definition: omAllocDecl.h:210
#define omAlloc0(size)
Definition: omAllocDecl.h:211
#define TEST_OPT_WEIGHTM
Definition: options.h:121
#define TEST_OPT_INTSTRATEGY
Definition: options.h:110
#define TEST_OPT_REDSB
Definition: options.h:104
#define TEST_OPT_DEGBOUND
Definition: options.h:113
#define TEST_OPT_PROT
Definition: options.h:103
#define TEST_OPT_DEBUG
Definition: options.h:108
void pRestoreDegProcs(ring r, pFDegProc old_FDeg, pLDegProc old_lDeg)
Definition: p_polys.cc:3719
poly p_Cleardenom(poly p, const ring r)
Definition: p_polys.cc:2900
void pSetDegProcs(ring r, pFDegProc new_FDeg, pLDegProc new_lDeg)
Definition: p_polys.cc:3707
static poly p_LmInit(poly p, const ring r)
Definition: p_polys.h:1295
static unsigned pLength(poly a)
Definition: p_polys.h:191
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
Compatiblity layer for legacy polynomial operations (over currRing)
#define pTest(p)
Definition: polys.h:415
#define pDelete(p_ptr)
Definition: polys.h:186
#define pLmInit(p)
like pInit, except that expvector is initialized to that of p, p must be != NULL
Definition: polys.h:64
void wrp(poly p)
Definition: polys.h:310
static void pLmFree(poly p)
frees the space of the monomial m, assumes m != NULL coef is not freed, m is not advanced
Definition: polys.h:70
void pWrite(poly p)
Definition: polys.h:308
void pNorm(poly p, const ring R=currRing)
Definition: polys.h:363
#define pInit()
allocates a new monomial and initializes everything to 0
Definition: polys.h:61
#define pCopy(p)
return a copy of the poly
Definition: polys.h:185
void PrintS(const char *s)
Definition: reporter.cc:284
void PrintLn()
Definition: reporter.cc:310
#define mflush()
Definition: reporter.h:58
static BOOLEAN rField_has_simple_inverse(const ring r)
Definition: ring.h:550
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:35
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)
Definition: simpleideals.h:23
tHomog
Definition: structs.h:40
@ isHomog
Definition: structs.h:42
@ testHomog
Definition: structs.h:43
#define loop
Definition: structs.h:80
EXTERN_VAR short * ecartWeights
Definition: weight.h:12