hilb.cc
Go to the documentation of this file.
1 /****************************************
2 * Computer Algebra System SINGULAR *
3 ****************************************/
4 /*
5 * ABSTRACT - Hilbert series
6 */
7 
8 #include <kernel/mod2.h>
9 
10 #include <omalloc/omalloc.h>
11 #include <misc/auxiliary.h>
12 #include <misc/mylimits.h>
13 #include <misc/intvec.h>
14 
18 
19 #include <polys/monomials/ring.h>
21 #include <polys/simpleideals.h>
22 
23 
24 // #include <kernel/structs.h>
25 // #include <kernel/polys.h>
26 //ADICHANGES:
27 #include <kernel/ideals.h>
28 // #include <kernel/GBEngine/kstd1.h>
29 // #include<gmp.h>
30 // #include<vector>
31 
32 
33 static int **Qpol;
34 static int *Q0, *Ql;
35 static int hLength;
36 
37 
38 static int hMinModulweight(intvec *modulweight)
39 {
40  int i,j,k;
41 
42  if(modulweight==NULL) return 0;
43  j=(*modulweight)[0];
44  for(i=modulweight->rows()-1;i!=0;i--)
45  {
46  k=(*modulweight)[i];
47  if(k<j) j=k;
48  }
49  return j;
50 }
51 
52 static void hHilbEst(scfmon stc, int Nstc, varset var, int Nvar)
53 {
54  int i, j;
55  int x, y, z = 1;
56  int *p;
57  for (i = Nvar; i>0; i--)
58  {
59  x = 0;
60  for (j = 0; j < Nstc; j++)
61  {
62  y = stc[j][var[i]];
63  if (y > x)
64  x = y;
65  }
66  z += x;
67  j = i - 1;
68  if (z > Ql[j])
69  {
70  if (z>(MAX_INT_VAL)/2)
71  {
72  Werror("interal arrays too big");
73  return;
74  }
75  p = (int *)omAlloc((unsigned long)z * sizeof(int));
76  if (Ql[j]!=0)
77  {
78  if (j==0)
79  memcpy(p, Qpol[j], Ql[j] * sizeof(int));
80  omFreeSize((ADDRESS)Qpol[j], Ql[j] * sizeof(int));
81  }
82  if (j==0)
83  {
84  for (x = Ql[j]; x < z; x++)
85  p[x] = 0;
86  }
87  Ql[j] = z;
88  Qpol[j] = p;
89  }
90  }
91 }
92 
93 static int *hAddHilb(int Nv, int x, int *pol, int *lp)
94 {
95  int l = *lp, ln, i;
96  int *pon;
97  *lp = ln = l + x;
98  pon = Qpol[Nv];
99  memcpy(pon, pol, l * sizeof(int));
100  if (l > x)
101  {
102  for (i = x; i < l; i++)
103  pon[i] -= pol[i - x];
104  for (i = l; i < ln; i++)
105  pon[i] = -pol[i - x];
106  }
107  else
108  {
109  for (i = l; i < x; i++)
110  pon[i] = 0;
111  for (i = x; i < ln; i++)
112  pon[i] = -pol[i - x];
113  }
114  return pon;
115 }
116 
117 static void hLastHilb(scmon pure, int Nv, varset var, int *pol, int lp)
118 {
119  int l = lp, x, i, j;
120  int *p, *pl;
121  p = pol;
122  for (i = Nv; i>0; i--)
123  {
124  x = pure[var[i + 1]];
125  if (x!=0)
126  p = hAddHilb(i, x, p, &l);
127  }
128  pl = *Qpol;
129  j = Q0[Nv + 1];
130  for (i = 0; i < l; i++)
131  pl[i + j] += p[i];
132  x = pure[var[1]];
133  if (x!=0)
134  {
135  j += x;
136  for (i = 0; i < l; i++)
137  pl[i + j] -= p[i];
138  }
139  j += l;
140  if (j > hLength)
141  hLength = j;
142 }
143 
144 static void hHilbStep(scmon pure, scfmon stc, int Nstc, varset var,
145  int Nvar, int *pol, int Lpol)
146 {
147  int iv = Nvar -1, ln, a, a0, a1, b, i;
148  int x, x0;
149  scmon pn;
150  scfmon sn;
151  int *pon;
152  if (Nstc==0)
153  {
154  hLastHilb(pure, iv, var, pol, Lpol);
155  return;
156  }
157  x = a = 0;
158  pn = hGetpure(pure);
159  sn = hGetmem(Nstc, stc, stcmem[iv]);
160  hStepS(sn, Nstc, var, Nvar, &a, &x);
161  Q0[iv] = Q0[Nvar];
162  ln = Lpol;
163  pon = pol;
164  if (a == Nstc)
165  {
166  x = pure[var[Nvar]];
167  if (x!=0)
168  pon = hAddHilb(iv, x, pon, &ln);
169  hHilbStep(pn, sn, a, var, iv, pon, ln);
170  return;
171  }
172  else
173  {
174  pon = hAddHilb(iv, x, pon, &ln);
175  hHilbStep(pn, sn, a, var, iv, pon, ln);
176  }
177  b = a;
178  x0 = 0;
179  loop
180  {
181  Q0[iv] += (x - x0);
182  a0 = a;
183  x0 = x;
184  hStepS(sn, Nstc, var, Nvar, &a, &x);
185  hElimS(sn, &b, a0, a, var, iv);
186  a1 = a;
187  hPure(sn, a0, &a1, var, iv, pn, &i);
188  hLex2S(sn, b, a0, a1, var, iv, hwork);
189  b += (a1 - a0);
190  ln = Lpol;
191  if (a < Nstc)
192  {
193  pon = hAddHilb(iv, x - x0, pol, &ln);
194  hHilbStep(pn, sn, b, var, iv, pon, ln);
195  }
196  else
197  {
198  x = pure[var[Nvar]];
199  if (x!=0)
200  pon = hAddHilb(iv, x - x0, pol, &ln);
201  else
202  pon = pol;
203  hHilbStep(pn, sn, b, var, iv, pon, ln);
204  return;
205  }
206  }
207 }
208 
209 /*
210 *basic routines
211 */
212 static void hWDegree(intvec *wdegree)
213 {
214  int i, k;
215  int x;
216 
217  for (i=(currRing->N); i; i--)
218  {
219  x = (*wdegree)[i-1];
220  if (x != 1)
221  {
222  for (k=hNexist-1; k>=0; k--)
223  {
224  hexist[k][i] *= x;
225  }
226  }
227  }
228 }
229 // ---------------------------------- ADICHANGES ---------------------------------------------
230 //!!!!!!!!!!!!!!!!!!!!! Just for Monomial Ideals !!!!!!!!!!!!!!!!!!!!!!!!!!!!
231 
232 //returns the degree of the monomial
233 static int DegMon(poly p)
234 {
235  #if 1
236  int i,deg;
237  deg = 0;
238  for(i=1;i<=currRing->N;i++)
239  {
240  deg = deg + p_GetExp(p, i, currRing);
241  }
242  return(deg);
243  #else
244  return(p_Deg(p, currRing));
245  #endif
246 }
247 
248 //Tests if the ideal is sorted by degree
249 static bool idDegSortTest(ideal I)
250 {
251  if((I == NULL)||(idIs0(I)))
252  {
253  return(TRUE);
254  }
255  for(int i = 0; i<IDELEMS(I)-1; i++)
256  {
257  if(DegMon(I->m[i])>DegMon(I->m[i+1]))
258  {
259  idPrint(I);
260  Werror("Ideal is not deg sorted!!");
261  return(FALSE);
262  }
263  }
264  return(TRUE);
265 }
266 
267 //adds the new polynomial at the coresponding position
268 //and simplifies the ideal
269 static ideal SortByDeg_p(ideal I, poly p)
270 {
271  int i,j;
272  if((I == NULL) || (idIs0(I)))
273  {
274  ideal res = idInit(1,1);
275  res->m[0] = p;
276  return(res);
277  }
278  idSkipZeroes(I);
279  #if 1
280  for(i = 0; (i<IDELEMS(I)) && (DegMon(I->m[i])<=DegMon(p)); i++)
281  {
282  if(p_DivisibleBy( I->m[i],p, currRing))
283  {
284  return(I);
285  }
286  }
287  for(i = IDELEMS(I)-1; (i>=0) && (DegMon(I->m[i])>=DegMon(p)); i--)
288  {
289  if(p_DivisibleBy(p,I->m[i], currRing))
290  {
291  I->m[i] = NULL;
292  }
293  }
294  if(idIs0(I))
295  {
296  idSkipZeroes(I);
297  I->m[0] = p;
298  return(I);
299  }
300  #endif
301  idSkipZeroes(I);
302  //First I take the case when all generators have the same degree
303  if(DegMon(I->m[0]) == DegMon(I->m[IDELEMS(I)-1]))
304  {
305  if(DegMon(p)<DegMon(I->m[0]))
306  {
307  idInsertPoly(I,p);
308  idSkipZeroes(I);
309  for(i=IDELEMS(I)-1;i>=1; i--)
310  {
311  I->m[i] = I->m[i-1];
312  }
313  I->m[0] = p;
314  return(I);
315  }
316  if(DegMon(p)>=DegMon(I->m[IDELEMS(I)-1]))
317  {
318  idInsertPoly(I,p);
319  idSkipZeroes(I);
320  return(I);
321  }
322  }
323  if(DegMon(p)<=DegMon(I->m[0]))
324  {
325  idInsertPoly(I,p);
326  idSkipZeroes(I);
327  for(i=IDELEMS(I)-1;i>=1; i--)
328  {
329  I->m[i] = I->m[i-1];
330  }
331  I->m[0] = p;
332  return(I);
333  }
334  if(DegMon(p)>=DegMon(I->m[IDELEMS(I)-1]))
335  {
336  idInsertPoly(I,p);
337  idSkipZeroes(I);
338  return(I);
339  }
340  for(i = IDELEMS(I)-2; ;)
341  {
342  if(DegMon(p)==DegMon(I->m[i]))
343  {
344  idInsertPoly(I,p);
345  idSkipZeroes(I);
346  for(j = IDELEMS(I)-1; j>=i+1;j--)
347  {
348  I->m[j] = I->m[j-1];
349  }
350  I->m[i] = p;
351  return(I);
352  }
353  if(DegMon(p)>DegMon(I->m[i]))
354  {
355  idInsertPoly(I,p);
356  idSkipZeroes(I);
357  for(j = IDELEMS(I)-1; j>=i+2;j--)
358  {
359  I->m[j] = I->m[j-1];
360  }
361  I->m[i+1] = p;
362  return(I);
363  }
364  i--;
365  }
366 }
367 
368 //it sorts the ideal by the degrees
369 static ideal SortByDeg(ideal I)
370 {
371  if(idIs0(I))
372  {
373  return(I);
374  }
375  int i;
376  ideal res;
377  idSkipZeroes(I);
378  res = idInit(1,1);
379  res->m[0] = poly(0);
380  for(i = 0; i<=IDELEMS(I)-1;i++)
381  {
382  res = SortByDeg_p(res, I->m[i]);
383  }
384  idSkipZeroes(res);
385  //idDegSortTest(res);
386  return(res);
387 }
388 
389 //idQuot(I,p) for I monomial ideal, p a ideal with a single monomial.
390 ideal idQuotMon(ideal Iorig, ideal p)
391 {
392  if(idIs0(Iorig))
393  {
394  ideal res = idInit(1,1);
395  res->m[0] = poly(0);
396  return(res);
397  }
398  if(idIs0(p))
399  {
400  ideal res = idInit(1,1);
401  res->m[0] = pOne();
402  return(res);
403  }
404  ideal I = idCopy(Iorig);
405  ideal res = idInit(IDELEMS(I),1);
406  int i,j;
407  int dummy;
408  for(i = 0; i<IDELEMS(I); i++)
409  {
410  res->m[i] = p_Copy(I->m[i], currRing);
411  for(j = 1; (j<=currRing->N) ; j++)
412  {
413  dummy = p_GetExp(p->m[0], j, currRing);
414  if(dummy > 0)
415  {
416  if(p_GetExp(I->m[i], j, currRing) < dummy)
417  {
418  p_SetExp(res->m[i], j, 0, currRing);
419  }
420  else
421  {
422  p_SetExp(res->m[i], j, p_GetExp(I->m[i], j, currRing) - dummy, currRing);
423  }
424  }
425  }
426  p_Setm(res->m[i], currRing);
427  if(DegMon(res->m[i]) == DegMon(I->m[i]))
428  {
429  res->m[i] = NULL; // pDelete
430  }
431  else
432  {
433  I->m[i] = NULL; // pDelete
434  }
435  }
436  idSkipZeroes(res);
437  idSkipZeroes(I);
438  if(!idIs0(res))
439  {
440  for(i = 0; i<=IDELEMS(res)-1; i++)
441  {
442  I = SortByDeg_p(I,res->m[i]);
443  }
444  }
445  //idDegSortTest(I);
446  return(I);
447 }
448 
449 //id_Add for monomials
450 static ideal idAddMon(ideal I, ideal p)
451 {
452  #if 1
453  I = SortByDeg_p(I,p->m[0]);
454  #else
455  I = id_Add(I,p,currRing);
456  #endif
457  //idSkipZeroes(I);
458  return(I);
459 }
460 
461 //searches for a variable that is not yet used (assumes that the ideal is sqrfree)
462 static poly ChoosePVar (ideal I)
463 {
464  bool flag=TRUE;
465  int i,j;
466  poly res;
467  for(i=1;i<=currRing->N;i++)
468  {
469  flag=TRUE;
470  for(j=IDELEMS(I)-1;(j>=0)&&(flag);j--)
471  {
472  if(p_GetExp(I->m[j], i, currRing)>0)
473  {
474  flag=FALSE;
475  }
476  }
477 
478  if(flag == TRUE)
479  {
480  res = p_ISet(1, currRing);
481  p_SetExp(res, i, 1, currRing);
482  p_Setm(res,currRing);
483  return(res);
484  }
485  else
486  {
487  p_Delete(&res, currRing);
488  }
489  }
490  return(NULL); //i.e. it is the maximal ideal
491 }
492 
493 //choice XL: last entry divided by x (xy10z15 -> y9z14)
494 static poly ChoosePXL(ideal I)
495 {
496  int i,j,dummy=0;
497  poly m;
498  for(i = IDELEMS(I)-1; (i>=0) && (dummy == 0); i--)
499  {
500  for(j = 1; (j<=currRing->N) && (dummy == 0); j++)
501  {
502  if(p_GetExp(I->m[i],j, currRing)>1)
503  {
504  dummy = 1;
505  }
506  }
507  }
508  m = p_Copy(I->m[i+1],currRing);
509  for(j = 1; j<=currRing->N; j++)
510  {
511  dummy = p_GetExp(m,j,currRing);
512  if(dummy >= 1)
513  {
514  p_SetExp(m, j, dummy-1, currRing);
515  }
516  }
517  if(!p_IsOne(m, currRing))
518  {
519  p_Setm(m, currRing);
520  return(m);
521  }
522  m = ChoosePVar(I);
523  return(m);
524 }
525 
526 //choice XF: first entry divided by x (xy10z15 -> y9z14)
527 static poly ChoosePXF(ideal I)
528 {
529  int i,j,dummy=0;
530  poly m;
531  for(i =0 ; (i<=IDELEMS(I)-1) && (dummy == 0); i++)
532  {
533  for(j = 1; (j<=currRing->N) && (dummy == 0); j++)
534  {
535  if(p_GetExp(I->m[i],j, currRing)>1)
536  {
537  dummy = 1;
538  }
539  }
540  }
541  m = p_Copy(I->m[i-1],currRing);
542  for(j = 1; j<=currRing->N; j++)
543  {
544  dummy = p_GetExp(m,j,currRing);
545  if(dummy >= 1)
546  {
547  p_SetExp(m, j, dummy-1, currRing);
548  }
549  }
550  if(!p_IsOne(m, currRing))
551  {
552  p_Setm(m, currRing);
553  return(m);
554  }
555  m = ChoosePVar(I);
556  return(m);
557 }
558 
559 //choice OL: last entry the first power (xy10z15 -> xy9z15)
560 static poly ChoosePOL(ideal I)
561 {
562  int i,j,dummy;
563  poly m;
564  for(i = IDELEMS(I)-1;i>=0;i--)
565  {
566  m = p_Copy(I->m[i],currRing);
567  for(j=1;j<=currRing->N;j++)
568  {
569  dummy = p_GetExp(m,j,currRing);
570  if(dummy > 0)
571  {
572  p_SetExp(m,j,dummy-1,currRing);
573  p_Setm(m,currRing);
574  }
575  }
576  if(!p_IsOne(m, currRing))
577  {
578  return(m);
579  }
580  else
581  {
582  p_Delete(&m,currRing);
583  }
584  }
585  m = ChoosePVar(I);
586  return(m);
587 }
588 
589 //choice OF: first entry the first power (xy10z15 -> xy9z15)
590 static poly ChoosePOF(ideal I)
591 {
592  int i,j,dummy;
593  poly m;
594  for(i = 0 ;i<=IDELEMS(I)-1;i++)
595  {
596  m = p_Copy(I->m[i],currRing);
597  for(j=1;j<=currRing->N;j++)
598  {
599  dummy = p_GetExp(m,j,currRing);
600  if(dummy > 0)
601  {
602  p_SetExp(m,j,dummy-1,currRing);
603  p_Setm(m,currRing);
604  }
605  }
606  if(!p_IsOne(m, currRing))
607  {
608  return(m);
609  }
610  else
611  {
612  p_Delete(&m,currRing);
613  }
614  }
615  m = ChoosePVar(I);
616  return(m);
617 }
618 
619 //choice VL: last entry the first variable with power (xy10z15 -> y)
620 static poly ChoosePVL(ideal I)
621 {
622  int i,j,dummy;
623  bool flag = TRUE;
624  poly m = p_ISet(1,currRing);
625  for(i = IDELEMS(I)-1;(i>=0) && (flag);i--)
626  {
627  flag = TRUE;
628  for(j=1;(j<=currRing->N) && (flag);j++)
629  {
630  dummy = p_GetExp(I->m[i],j,currRing);
631  if(dummy >= 2)
632  {
633  p_SetExp(m,j,1,currRing);
634  p_Setm(m,currRing);
635  flag = FALSE;
636  }
637  }
638  if(!p_IsOne(m, currRing))
639  {
640  return(m);
641  }
642  }
643  m = ChoosePVar(I);
644  return(m);
645 }
646 
647 //choice VF: first entry the first variable with power (xy10z15 -> y)
648 static poly ChoosePVF(ideal I)
649 {
650  int i,j,dummy;
651  bool flag = TRUE;
652  poly m = p_ISet(1,currRing);
653  for(i = 0;(i<=IDELEMS(I)-1) && (flag);i++)
654  {
655  flag = TRUE;
656  for(j=1;(j<=currRing->N) && (flag);j++)
657  {
658  dummy = p_GetExp(I->m[i],j,currRing);
659  if(dummy >= 2)
660  {
661  p_SetExp(m,j,1,currRing);
662  p_Setm(m,currRing);
663  flag = FALSE;
664  }
665  }
666  if(!p_IsOne(m, currRing))
667  {
668  return(m);
669  }
670  }
671  m = ChoosePVar(I);
672  return(m);
673 }
674 
675 //choice JL: last entry just variable with power (xy10z15 -> y10)
676 static poly ChoosePJL(ideal I)
677 {
678  int i,j,dummy;
679  bool flag = TRUE;
680  poly m = p_ISet(1,currRing);
681  for(i = IDELEMS(I)-1;(i>=0) && (flag);i--)
682  {
683  flag = TRUE;
684  for(j=1;(j<=currRing->N) && (flag);j++)
685  {
686  dummy = p_GetExp(I->m[i],j,currRing);
687  if(dummy >= 2)
688  {
689  p_SetExp(m,j,dummy-1,currRing);
690  p_Setm(m,currRing);
691  flag = FALSE;
692  }
693  }
694  if(!p_IsOne(m, currRing))
695  {
696  return(m);
697  }
698  }
699  m = ChoosePVar(I);
700  return(m);
701 }
702 
703 //choice JF: last entry just variable with power -1 (xy10z15 -> y9)
704 static poly ChoosePJF(ideal I)
705 {
706  int i,j,dummy;
707  bool flag = TRUE;
708  poly m = p_ISet(1,currRing);
709  for(i = 0;(i<=IDELEMS(I)-1) && (flag);i++)
710  {
711  flag = TRUE;
712  for(j=1;(j<=currRing->N) && (flag);j++)
713  {
714  dummy = p_GetExp(I->m[i],j,currRing);
715  if(dummy >= 2)
716  {
717  p_SetExp(m,j,dummy-1,currRing);
718  p_Setm(m,currRing);
719  flag = FALSE;
720  }
721  }
722  if(!p_IsOne(m, currRing))
723  {
724  return(m);
725  }
726  }
727  m = ChoosePVar(I);
728  return(m);
729 }
730 
731 //chooses 1 \neq p \not\in S. This choice should be made optimal
732 static poly ChooseP(ideal I)
733 {
734  poly m;
735  // TEST TO SEE WHICH ONE IS BETTER
736  //m = ChoosePXL(I);
737  //m = ChoosePXF(I);
738  //m = ChoosePOL(I);
739  //m = ChoosePOF(I);
740  //m = ChoosePVL(I);
741  //m = ChoosePVF(I);
742  m = ChoosePJL(I);
743  //m = ChoosePJF(I);
744  return(m);
745 }
746 
747 ///searches for a monomial of degree d>=2 and divides it by a variable (result monomial of deg d-1)
748 static poly SearchP(ideal I)
749 {
750  int i,j,exp;
751  poly res;
752  if(DegMon(I->m[IDELEMS(I)-1])<=1)
753  {
754  res = ChoosePVar(I);
755  return(res);
756  }
757  i = IDELEMS(I)-1;
758  res = p_Copy(I->m[i], currRing);
759  for(j=1;j<=currRing->N;j++)
760  {
761  exp = p_GetExp(I->m[i], j, currRing);
762  if(exp > 0)
763  {
764  p_SetExp(res, j, exp - 1, currRing);
765  p_Setm(res,currRing);
766  break;
767  }
768  }
769  assume( j <= currRing->N );
770  return(res);
771 }
772 
773 //test if the ideal is of the form (x1, ..., xr)
774 static bool JustVar(ideal I)
775 {
776  #if 0
777  int i,j;
778  bool foundone;
779  for(i=0;i<=IDELEMS(I)-1;i++)
780  {
781  foundone = FALSE;
782  for(j = 1;j<=currRing->N;j++)
783  {
784  if(p_GetExp(I->m[i], j, currRing)>0)
785  {
786  if(foundone == TRUE)
787  {
788  return(FALSE);
789  }
790  foundone = TRUE;
791  }
792  }
793  }
794  return(TRUE);
795  #else
796  if(DegMon(I->m[IDELEMS(I)-1])>1)
797  {
798  return(FALSE);
799  }
800  return(TRUE);
801  #endif
802 }
803 
804 //computes the Euler Characteristic of the ideal
805 static void eulerchar (ideal I, int variables, mpz_ptr ec)
806 {
807  loop
808  {
809  mpz_t dummy;
810  if(JustVar(I) == TRUE)
811  {
812  if(IDELEMS(I) == variables)
813  {
814  mpz_init(dummy);
815  if((variables % 2) == 0)
816  {mpz_set_si(dummy, 1);}
817  else
818  {mpz_set_si(dummy, -1);}
819  mpz_add(ec, ec, dummy);
820  }
821  //mpz_clear(dummy);
822  return;
823  }
824  ideal p = idInit(1,1);
825  p->m[0] = SearchP(I);
826  //idPrint(I);
827  //idPrint(p);
828  //printf("\nNow get in idQuotMon\n");
829  ideal Ip = idQuotMon(I,p);
830  //idPrint(Ip);
831  //Ip = SortByDeg(Ip);
832  int i,howmanyvarinp = 0;
833  for(i = 1;i<=currRing->N;i++)
834  {
835  if(p_GetExp(p->m[0],i,currRing)>0)
836  {
837  howmanyvarinp++;
838  }
839  }
840  eulerchar(Ip, variables-howmanyvarinp, ec);
841  id_Delete(&Ip, currRing);
842  I = idAddMon(I,p);
843  }
844 }
845 
846 //tests if an ideal is Square Free, if no, returns the variable which appears at powers >1
847 static poly SqFree (ideal I)
848 {
849  int i,j;
850  bool flag=TRUE;
851  poly notsqrfree = NULL;
852  if(DegMon(I->m[IDELEMS(I)-1])<=1)
853  {
854  return(notsqrfree);
855  }
856  for(i=IDELEMS(I)-1;(i>=0)&&(flag);i--)
857  {
858  for(j=1;(j<=currRing->N)&&(flag);j++)
859  {
860  if(p_GetExp(I->m[i],j,currRing)>1)
861  {
862  flag=FALSE;
863  notsqrfree = p_ISet(1,currRing);
864  p_SetExp(notsqrfree,j,1,currRing);
865  }
866  }
867  }
868  if(notsqrfree != NULL)
869  {
870  p_Setm(notsqrfree,currRing);
871  }
872  return(notsqrfree);
873 }
874 
875 //checks if a polynomial is in I
876 static bool IsIn(poly p, ideal I)
877 {
878  //assumes that I is ordered by degree
879  if(idIs0(I))
880  {
881  if(p==poly(0))
882  {
883  return(TRUE);
884  }
885  else
886  {
887  return(FALSE);
888  }
889  }
890  if(p==poly(0))
891  {
892  return(FALSE);
893  }
894  int i,j;
895  bool flag;
896  for(i = 0;i<IDELEMS(I);i++)
897  {
898  flag = TRUE;
899  for(j = 1;(j<=currRing->N) &&(flag);j++)
900  {
901  if(p_GetExp(p, j, currRing)<p_GetExp(I->m[i], j, currRing))
902  {
903  flag = FALSE;
904  }
905  }
906  if(flag)
907  {
908  return(TRUE);
909  }
910  }
911  return(FALSE);
912 }
913 
914 //computes the lcm of min I, I monomial ideal
915 static poly LCMmon(ideal I)
916 {
917  if(idIs0(I))
918  {
919  return(NULL);
920  }
921  poly m;
922  int dummy,i,j;
923  m = p_ISet(1,currRing);
924  for(i=1;i<=currRing->N;i++)
925  {
926  dummy=0;
927  for(j=IDELEMS(I)-1;j>=0;j--)
928  {
929  if(p_GetExp(I->m[j],i,currRing) > dummy)
930  {
931  dummy = p_GetExp(I->m[j],i,currRing);
932  }
933  }
934  p_SetExp(m,i,dummy,currRing);
935  }
936  p_Setm(m,currRing);
937  return(m);
938 }
939 
940 //the Roune Slice Algorithm
941 void rouneslice(ideal I, ideal S, poly q, poly x, int &prune, int &moreprune, int &steps, int &NNN, mpz_ptr &hilbertcoef, int* &hilbpower)
942 {
943  loop
944  {
945  (steps)++;
946  int i,j;
947  int dummy;
948  poly m;
949  ideal p, koszsimp;
950  //----------- PRUNING OF S ---------------
951  //S SHOULD IN THIS POINT BE ORDERED BY DEGREE
952  for(i=IDELEMS(S)-1;i>=0;i--)
953  {
954  if(IsIn(S->m[i],I))
955  {
956  S->m[i]=NULL;
957  prune++;
958  }
959  }
960  idSkipZeroes(S);
961  //----------------------------------------
962  for(i=IDELEMS(I)-1;i>=0;i--)
963  {
964  m = p_Copy(I->m[i],currRing);
965  for(j=1;j<=currRing->N;j++)
966  {
967  dummy = p_GetExp(m,j,currRing);
968  if(dummy > 0)
969  {
970  p_SetExp(m,j,dummy-1,currRing);
971  }
972  }
973  p_Setm(m, currRing);
974  if(IsIn(m,S))
975  {
976  I->m[i]=NULL;
977  //printf("\n Deleted, since pi(m) is in S\n");pWrite(m);
978  }
979  }
980  idSkipZeroes(I);
981  //----------- MORE PRUNING OF S ------------
982  m = LCMmon(I);
983  if(m != NULL)
984  {
985  for(i=0;i<IDELEMS(S);i++)
986  {
987  if(!(p_DivisibleBy(S->m[i], m, currRing)))
988  {
989  S->m[i] = NULL;
990  j++;
991  moreprune++;
992  }
993  else
994  {
995  if(pLmEqual(S->m[i],m))
996  {
997  S->m[i] = NULL;
998  moreprune++;
999  }
1000  }
1001  }
1002  idSkipZeroes(S);
1003  }
1004  /*printf("\n---------------------------\n");
1005  printf("\n I\n");idPrint(I);
1006  printf("\n S\n");idPrint(S);
1007  printf("\n q\n");pWrite(q);
1008  getchar();*/
1009 
1010  if(idIs0(I))
1011  {
1012  id_Delete(&I, currRing);
1013  id_Delete(&S, currRing);
1014  p_Delete(&m, currRing);
1015  break;
1016  }
1017  m = LCMmon(I);
1018  if(!p_DivisibleBy(x,m, currRing))
1019  {
1020  //printf("\nx does not divide lcm(I)");
1021  //printf("\nEmpty set");pWrite(q);
1022  id_Delete(&I, currRing);
1023  id_Delete(&S, currRing);
1024  p_Delete(&m, currRing);
1025  break;
1026  }
1027  m = SqFree(I);
1028  if(m==NULL)
1029  {
1030  //printf("\n Corner: ");
1031  //pWrite(q);
1032  //printf("\n With the facets of the dual simplex:\n");
1033  //idPrint(I);
1034  mpz_t ec;
1035  mpz_init(ec);
1036  mpz_ptr ec_ptr = ec;
1037  eulerchar(I, currRing->N, ec_ptr);
1038  bool flag = FALSE;
1039  if(NNN==0)
1040  {
1041  hilbertcoef = (mpz_ptr)omAlloc((NNN+1)*sizeof(mpz_t));
1042  hilbpower = (int*)omAlloc((NNN+1)*sizeof(int));
1043  mpz_init( &hilbertcoef[NNN]);
1044  mpz_set( &hilbertcoef[NNN], ec);
1045  mpz_clear(ec);
1046  hilbpower[NNN] = DegMon(q);
1047  NNN++;
1048  }
1049  else
1050  {
1051  //I look if the power appears already
1052  for(i = 0;(i<NNN)&&(flag == FALSE)&&(DegMon(q)>=hilbpower[i]);i++)
1053  {
1054  if((hilbpower[i]) == (DegMon(q)))
1055  {
1056  flag = TRUE;
1057  mpz_add(&hilbertcoef[i],&hilbertcoef[i],ec_ptr);
1058  }
1059  }
1060  if(flag == FALSE)
1061  {
1062  hilbertcoef = (mpz_ptr)omRealloc(hilbertcoef, (NNN+1)*sizeof(mpz_t));
1063  hilbpower = (int*)omRealloc(hilbpower, (NNN+1)*sizeof(int));
1064  mpz_init(&hilbertcoef[NNN]);
1065  for(j = NNN; j>i; j--)
1066  {
1067  mpz_set(&hilbertcoef[j],&hilbertcoef[j-1]);
1068  hilbpower[j] = hilbpower[j-1];
1069  }
1070  mpz_set( &hilbertcoef[i], ec);
1071  mpz_clear(ec);
1072  hilbpower[i] = DegMon(q);
1073  NNN++;
1074  }
1075  }
1076  break;
1077  }
1078  m = ChooseP(I);
1079  p = idInit(1,1);
1080  p->m[0] = m;
1081  ideal Ip = idQuotMon(I,p);
1082  ideal Sp = idQuotMon(S,p);
1083  poly pq = pp_Mult_mm(q,m,currRing);
1084  rouneslice(Ip, Sp, pq, x, prune, moreprune, steps, NNN, hilbertcoef,hilbpower);
1085  //id_Delete(&Ip, currRing);
1086  //id_Delete(&Sp, currRing);
1087  S = idAddMon(S,p);
1088  p->m[0]=NULL;
1089  id_Delete(&p, currRing); // p->m[0] was also in S
1090  p_Delete(&pq,currRing);
1091  }
1092 }
1093 
1094 //it computes the first hilbert series by means of Roune Slice Algorithm
1095 void slicehilb(ideal I)
1096 {
1097  //printf("Adi changes are here: \n");
1098  int i, NNN = 0;
1099  int steps = 0, prune = 0, moreprune = 0;
1100  mpz_ptr hilbertcoef;
1101  int *hilbpower;
1102  ideal S = idInit(1,1);
1103  poly q = p_ISet(1,currRing);
1104  ideal X = idInit(1,1);
1105  X->m[0]=p_One(currRing);
1106  for(i=1;i<=currRing->N;i++)
1107  {
1108  p_SetExp(X->m[0],i,1,currRing);
1109  }
1110  p_Setm(X->m[0],currRing);
1111  I = id_Mult(I,X,currRing);
1112  I = SortByDeg(I);
1113  //printf("\n-------------RouneSlice--------------\n");
1114  rouneslice(I,S,q,X->m[0],prune, moreprune, steps, NNN, hilbertcoef, hilbpower);
1115  //printf("\nIn total Prune got rid of %i elements\n",prune);
1116  //printf("\nIn total More Prune got rid of %i elements\n",moreprune);
1117  //printf("\nSteps of rouneslice: %i\n\n", steps);
1118  mpz_t coefhilb;
1119  mpz_t dummy;
1120  mpz_init(coefhilb);
1121  mpz_init(dummy);
1122  printf("\n// %8d t^0",1);
1123  for(i = 0; i<NNN; i++)
1124  {
1125  if(mpz_sgn(&hilbertcoef[i])!=0)
1126  {
1127  gmp_printf("\n// %8Zd t^%d",&hilbertcoef[i],hilbpower[i]);
1128  }
1129  }
1130  omFreeSize(hilbertcoef, (NNN)*sizeof(mpz_t));
1131  omFreeSize(hilbpower, (NNN)*sizeof(int));
1132  //printf("\n-------------------------------------\n");
1133 }
1134 
1135 // -------------------------------- END OF CHANGES -------------------------------------------
1136 static intvec * hSeries(ideal S, intvec *modulweight,
1137  int /*notstc*/, intvec *wdegree, ideal Q, ring tailRing)
1138 {
1139 // id_TestTail(S, currRing, tailRing);
1140 
1141  intvec *work, *hseries1=NULL;
1142  int mc;
1143  int p0;
1144  int i, j, k, l, ii, mw;
1145  hexist = hInit(S, Q, &hNexist, tailRing);
1146  if (hNexist==0)
1147  {
1148  hseries1=new intvec(2);
1149  (*hseries1)[0]=1;
1150  (*hseries1)[1]=0;
1151  return hseries1;
1152  }
1153 
1154  #if 0
1155  if (wdegree == NULL)
1156  hWeight();
1157  else
1158  hWDegree(wdegree);
1159  #else
1160  if (wdegree != NULL) hWDegree(wdegree);
1161  #endif
1162 
1163  p0 = 1;
1164  hwork = (scfmon)omAlloc(hNexist * sizeof(scmon));
1165  hvar = (varset)omAlloc(((currRing->N) + 1) * sizeof(int));
1166  hpure = (scmon)omAlloc((1 + ((currRing->N) * (currRing->N))) * sizeof(int));
1167  stcmem = hCreate((currRing->N) - 1);
1168  Qpol = (int **)omAlloc(((currRing->N) + 1) * sizeof(int *));
1169  Ql = (int *)omAlloc0(((currRing->N) + 1) * sizeof(int));
1170  Q0 = (int *)omAlloc(((currRing->N) + 1) * sizeof(int));
1171  *Qpol = NULL;
1172  hLength = k = j = 0;
1173  mc = hisModule;
1174  if (mc!=0)
1175  {
1176  mw = hMinModulweight(modulweight);
1177  hstc = (scfmon)omAlloc(hNexist * sizeof(scmon));
1178  }
1179  else
1180  {
1181  mw = 0;
1182  hstc = hexist;
1183  hNstc = hNexist;
1184  }
1185  loop
1186  {
1187  if (mc!=0)
1188  {
1189  hComp(hexist, hNexist, mc, hstc, &hNstc);
1190  if (modulweight != NULL)
1191  j = (*modulweight)[mc-1]-mw;
1192  }
1193  if (hNstc!=0)
1194  {
1195  hNvar = (currRing->N);
1196  for (i = hNvar; i>=0; i--)
1197  hvar[i] = i;
1198  //if (notstc) // TODO: no mon divides another
1200  hSupp(hstc, hNstc, hvar, &hNvar);
1201  if (hNvar!=0)
1202  {
1203  if ((hNvar > 2) && (hNstc > 10))
1206  memset(hpure, 0, ((currRing->N) + 1) * sizeof(int));
1207  hPure(hstc, 0, &hNstc, hvar, hNvar, hpure, &hNpure);
1208  hLexS(hstc, hNstc, hvar, hNvar);
1209  Q0[hNvar] = 0;
1210  hHilbStep(hpure, hstc, hNstc, hvar, hNvar, &p0, 1);
1211  }
1212  }
1213  else
1214  {
1215  if(*Qpol!=NULL)
1216  (**Qpol)++;
1217  else
1218  {
1219  *Qpol = (int *)omAlloc(sizeof(int));
1220  hLength = *Ql = **Qpol = 1;
1221  }
1222  }
1223  if (*Qpol!=NULL)
1224  {
1225  i = hLength;
1226  while ((i > 0) && ((*Qpol)[i - 1] == 0))
1227  i--;
1228  if (i > 0)
1229  {
1230  l = i + j;
1231  if (l > k)
1232  {
1233  work = new intvec(l);
1234  for (ii=0; ii<k; ii++)
1235  (*work)[ii] = (*hseries1)[ii];
1236  if (hseries1 != NULL)
1237  delete hseries1;
1238  hseries1 = work;
1239  k = l;
1240  }
1241  while (i > 0)
1242  {
1243  (*hseries1)[i + j - 1] += (*Qpol)[i - 1];
1244  (*Qpol)[i - 1] = 0;
1245  i--;
1246  }
1247  }
1248  }
1249  mc--;
1250  if (mc <= 0)
1251  break;
1252  }
1253  if (k==0)
1254  {
1255  hseries1=new intvec(2);
1256  (*hseries1)[0]=0;
1257  (*hseries1)[1]=0;
1258  }
1259  else
1260  {
1261  l = k+1;
1262  while ((*hseries1)[l-2]==0) l--;
1263  if (l!=k)
1264  {
1265  work = new intvec(l);
1266  for (ii=l-2; ii>=0; ii--)
1267  (*work)[ii] = (*hseries1)[ii];
1268  delete hseries1;
1269  hseries1 = work;
1270  }
1271  (*hseries1)[l-1] = mw;
1272  }
1273  for (i = 0; i <= (currRing->N); i++)
1274  {
1275  if (Ql[i]!=0)
1276  omFreeSize((ADDRESS)Qpol[i], Ql[i] * sizeof(int));
1277  }
1278  omFreeSize((ADDRESS)Q0, ((currRing->N) + 1) * sizeof(int));
1279  omFreeSize((ADDRESS)Ql, ((currRing->N) + 1) * sizeof(int));
1280  omFreeSize((ADDRESS)Qpol, ((currRing->N) + 1) * sizeof(int *));
1281  hKill(stcmem, (currRing->N) - 1);
1282  omFreeSize((ADDRESS)hpure, (1 + ((currRing->N) * (currRing->N))) * sizeof(int));
1283  omFreeSize((ADDRESS)hvar, ((currRing->N) + 1) * sizeof(int));
1284  omFreeSize((ADDRESS)hwork, hNexist * sizeof(scmon));
1286  if (hisModule!=0)
1287  omFreeSize((ADDRESS)hstc, hNexist * sizeof(scmon));
1288  return hseries1;
1289 }
1290 
1291 
1292 intvec * hHstdSeries(ideal S, intvec *modulweight, intvec *wdegree, ideal Q, ring tailRing)
1293 {
1294  id_TestTail(S, currRing, tailRing);
1295  if (Q!=NULL) id_TestTail(Q, currRing, tailRing);
1296  return hSeries(S, modulweight, 0, wdegree, Q, tailRing);
1297 }
1298 
1299 intvec * hFirstSeries(ideal S, intvec *modulweight, ideal Q, intvec *wdegree, ring tailRing)
1300 {
1301  id_TestTail(S, currRing, tailRing);
1302  if (Q!= NULL) id_TestTail(Q, currRing, tailRing);
1303 
1304  return hSeries(S, modulweight, 1, wdegree, Q, tailRing);
1305 }
1306 
1308 {
1309  intvec *work, *hseries2;
1310  int i, j, k, s, t, l;
1311  if (hseries1 == NULL)
1312  return NULL;
1313  work = new intvec(hseries1);
1314  k = l = work->length()-1;
1315  s = 0;
1316  for (i = k-1; i >= 0; i--)
1317  s += (*work)[i];
1318  loop
1319  {
1320  if ((s != 0) || (k == 1))
1321  break;
1322  s = 0;
1323  t = (*work)[k-1];
1324  k--;
1325  for (i = k-1; i >= 0; i--)
1326  {
1327  j = (*work)[i];
1328  (*work)[i] = -t;
1329  s += t;
1330  t += j;
1331  }
1332  }
1333  hseries2 = new intvec(k+1);
1334  for (i = k-1; i >= 0; i--)
1335  (*hseries2)[i] = (*work)[i];
1336  (*hseries2)[k] = (*work)[l];
1337  delete work;
1338  return hseries2;
1339 }
1340 
1341 void hDegreeSeries(intvec *s1, intvec *s2, int *co, int *mu)
1342 {
1343  int m, i, j, k;
1344  *co = *mu = 0;
1345  if ((s1 == NULL) || (s2 == NULL))
1346  return;
1347  i = s1->length();
1348  j = s2->length();
1349  if (j > i)
1350  return;
1351  m = 0;
1352  for(k=j-2; k>=0; k--)
1353  m += (*s2)[k];
1354  *mu = m;
1355  *co = i - j;
1356 }
1357 
1358 static void hPrintHilb(intvec *hseries)
1359 {
1360  int i, j, l, k;
1361  if (hseries == NULL)
1362  return;
1363  l = hseries->length()-1;
1364  k = (*hseries)[l];
1365  for (i = 0; i < l; i++)
1366  {
1367  j = (*hseries)[i];
1368  if (j != 0)
1369  {
1370  Print("// %8d t^%d\n", j, i+k);
1371  }
1372  }
1373 }
1374 
1375 /*
1376 *caller
1377 */
1378 void hLookSeries(ideal S, intvec *modulweight, ideal Q, intvec *wdegree, ring tailRing)
1379 {
1380  id_TestTail(S, currRing, tailRing);
1381 
1382  intvec *hseries1 = hFirstSeries(S, modulweight, Q, wdegree, tailRing);
1383 
1384  hPrintHilb(hseries1);
1385 
1386  const int l = hseries1->length()-1;
1387 
1388  intvec *hseries2 = (l > 1) ? hSecondSeries(hseries1) : hseries1;
1389 
1390  int co, mu;
1391  hDegreeSeries(hseries1, hseries2, &co, &mu);
1392 
1393  PrintLn();
1394  hPrintHilb(hseries2);
1395  if ((l == 1) &&(mu == 0))
1396  scPrintDegree(rVar(currRing)+1, 0);
1397  else
1398  scPrintDegree(co, mu);
1399  if (l>1)
1400  delete hseries1;
1401  delete hseries2;
1402 }
1403 
1404 
1405 
ideal idQuotMon(ideal Iorig, ideal p)
Definition: hilb.cc:390
void rouneslice(ideal I, ideal S, poly q, poly x, int &prune, int &moreprune, int &steps, int &NNN, mpz_ptr &hilbertcoef, int *&hilbpower)
Definition: hilb.cc:941
#define id_TestTail(A, lR, tR)
Definition: simpleideals.h:79
static int variables
int hNstc
Definition: hutil.cc:22
const CanonicalForm int s
Definition: facAbsFact.cc:55
void hLexS(scfmon stc, int Nstc, varset var, int Nvar)
Definition: hutil.cc:512
const CanonicalForm int const CFList const Variable & y
Definition: facAbsFact.cc:57
const poly a
Definition: syzextra.cc:212
void PrintLn()
Definition: reporter.cc:322
static int hLength
Definition: hilb.cc:35
static poly ChoosePVar(ideal I)
Definition: hilb.cc:462
#define Print
Definition: emacs.cc:83
scfmon hwork
Definition: hutil.cc:19
void mu(int **points, int sizePoints)
scfmon hGetmem(int lm, scfmon old, monp monmem)
Definition: hutil.cc:1029
int hNexist
Definition: hutil.cc:22
int * varset
Definition: hutil.h:23
void hElimS(scfmon stc, int *e1, int a2, int e2, varset var, int Nvar)
Definition: hutil.cc:678
void scPrintDegree(int co, int mu)
Definition: hdegree.cc:808
static void hHilbStep(scmon pure, scfmon stc, int Nstc, varset var, int Nvar, int *pol, int Lpol)
Definition: hilb.cc:144
loop
Definition: myNF.cc:98
#define FALSE
Definition: auxiliary.h:140
return P p
Definition: myNF.cc:203
scmon hGetpure(scmon p)
Definition: hutil.cc:1058
void slicehilb(ideal I)
Definition: hilb.cc:1095
static void hLastHilb(scmon pure, int Nv, varset var, int *pol, int lp)
Definition: hilb.cc:117
scmon * scfmon
Definition: hutil.h:22
BEGIN_NAMESPACE_SINGULARXX const ring const ring tailRing
Definition: DebugPrint.h:30
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
scfmon hexist
Definition: hutil.cc:19
static int * Q0
Definition: hilb.cc:34
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:540
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
static poly ChoosePXL(ideal I)
Definition: hilb.cc:494
static poly ChoosePOF(ideal I)
Definition: hilb.cc:590
monf hCreate(int Nvar)
Definition: hutil.cc:1002
static bool JustVar(ideal I)
Definition: hilb.cc:774
int hNvar
Definition: hutil.cc:22
static bool IsIn(poly p, ideal I)
Definition: hilb.cc:876
static poly pp_Mult_mm(poly p, poly m, const ring r)
Definition: p_polys.h:962
#define TRUE
Definition: auxiliary.h:144
static ideal idAddMon(ideal I, ideal p)
Definition: hilb.cc:450
int length() const
Definition: intvec.h:86
void * ADDRESS
Definition: auxiliary.h:161
int hNpure
Definition: hutil.cc:22
void hDegreeSeries(intvec *s1, intvec *s2, int *co, int *mu)
Definition: hilb.cc:1341
scmon hpure
Definition: hutil.cc:20
int k
Definition: cfEzgcd.cc:93
#define Q
Definition: sirandom.c:25
static poly ChoosePVF(ideal I)
Definition: hilb.cc:648
#define omAlloc(size)
Definition: omAllocDecl.h:210
static poly LCMmon(ideal I)
Definition: hilb.cc:915
intvec * hHstdSeries(ideal S, intvec *modulweight, intvec *wdegree, ideal Q, ring tailRing)
Definition: hilb.cc:1292
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:811
void hDelete(scfmon ev, int ev_length)
Definition: hutil.cc:146
poly res
Definition: myNF.cc:322
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
#define idPrint(id)
Definition: ideals.h:62
long p_Deg(poly a, const ring r)
Definition: p_polys.cc:586
void hOrdSupp(scfmon stc, int Nstc, varset var, int Nvar)
Definition: hutil.cc:208
Definition: intvec.h:16
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:49
poly p_One(const ring r)
Definition: p_polys.cc:1318
void hKill(monf xmem, int Nvar)
Definition: hutil.cc:1016
Variable var
Definition: int_poly.h:77
varset hvar
Definition: hutil.cc:21
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent : the integer VarOffset encodes:
Definition: p_polys.h:465
int j
Definition: myNF.cc:70
#define assume(x)
Definition: mod2.h:405
static poly ChoosePJL(ideal I)
Definition: hilb.cc:676
static int * hAddHilb(int Nv, int x, int *pol, int *lp)
Definition: hilb.cc:93
static poly ChoosePXF(ideal I)
Definition: hilb.cc:527
static void hWDegree(intvec *wdegree)
Definition: hilb.cc:212
void hPure(scfmon stc, int a, int *Nstc, varset var, int Nvar, scmon pure, int *Npure)
Definition: hutil.cc:627
void hStaircase(scfmon stc, int *Nstc, varset var, int Nvar)
Definition: hutil.cc:319
const int MAX_INT_VAL
Definition: mylimits.h:12
static BOOLEAN p_DivisibleBy(poly a, poly b, const ring r)
Definition: p_polys.h:1685
BOOLEAN idInsertPoly(ideal h1, poly h2)
insert h2 into h1 (if h2 is not the zero polynomial) return TRUE iff h2 was indeed inserted ...
All the auxiliary stuff.
int m
Definition: cfEzgcd.cc:119
static intvec * hSeries(ideal S, intvec *modulweight, int, intvec *wdegree, ideal Q, ring tailRing)
Definition: hilb.cc:1136
int * scmon
Definition: hutil.h:21
static BOOLEAN p_IsOne(const poly p, const ring R)
either poly(1) or gen(k)?!
Definition: p_polys.h:1792
int i
Definition: cfEzgcd.cc:123
void hLex2S(scfmon rad, int e1, int a2, int e2, varset var, int Nvar, scfmon w)
Definition: hutil.cc:818
void prune(Variable &alpha)
Definition: variable.cc:261
#define pOne()
Definition: polys.h:286
static poly ChoosePVL(ideal I)
Definition: hilb.cc:620
#define IDELEMS(i)
Definition: simpleideals.h:24
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
ideal idCopy(ideal A)
Definition: ideals.h:76
static poly ChoosePJF(ideal I)
Definition: hilb.cc:704
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:850
ideal id_Mult(ideal h1, ideal h2, const ring R)
h1 * h2 one h_i must be an ideal (with at least one column) the other h_i may be a module (with no co...
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:38
static poly ChoosePOL(ideal I)
Definition: hilb.cc:560
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent : VarOffset encodes the position in p->exp
Definition: p_polys.h:484
static ideal SortByDeg(ideal I)
Definition: hilb.cc:369
#define NULL
Definition: omList.c:10
static int * Ql
Definition: hilb.cc:34
monf stcmem
Definition: hutil.cc:24
void hStepS(scfmon stc, int Nstc, varset var, int Nvar, int *a, int *x)
Definition: hutil.cc:955
ideal id_Add(ideal h1, ideal h2, const ring r)
h1 + h2
int rows() const
Definition: intvec.h:88
intvec * hSecondSeries(intvec *hseries1)
Definition: hilb.cc:1307
Variable x
Definition: cfModGcd.cc:4023
static int DegMon(poly p)
!!!!!!!!!!!!!!!!!!!! Just for Monomial Ideals !!!!!!!!!!!!!!!!!!!!!!!!!!!!
Definition: hilb.cc:233
static poly SearchP(ideal I)
searches for a monomial of degree d>=2 and divides it by a variable (result monomial of deg d-1) ...
Definition: hilb.cc:748
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:436
static ideal SortByDeg_p(ideal I, poly p)
Definition: hilb.cc:269
static poly ChooseP(ideal I)
Definition: hilb.cc:732
p exp[i]
Definition: DebugPrint.cc:39
int hisModule
Definition: hutil.cc:23
static bool idDegSortTest(ideal I)
Definition: hilb.cc:249
intvec * hFirstSeries(ideal S, intvec *modulweight, ideal Q, intvec *wdegree, ring tailRing)
Definition: hilb.cc:1299
void hLookSeries(ideal S, intvec *modulweight, ideal Q, intvec *wdegree, ring tailRing)
Definition: hilb.cc:1378
polyrec * poly
Definition: hilb.h:10
scfmon hstc
Definition: hutil.cc:19
static int hMinModulweight(intvec *modulweight)
Definition: hilb.cc:38
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
const poly b
Definition: syzextra.cc:213
#define omRealloc(addr, size)
Definition: omAllocDecl.h:225
void hComp(scfmon exist, int Nexist, int ak, scfmon stc, int *Nstc)
Definition: hutil.cc:160
static poly SqFree(ideal I)
Definition: hilb.cc:847
poly p_ISet(long i, const ring r)
returns the poly representing the integer i
Definition: p_polys.cc:1302
scfmon hInit(ideal S, ideal Q, int *Nexist, ring tailRing)
Definition: hutil.cc:34
void Werror(const char *fmt,...)
Definition: reporter.cc:199
#define pLmEqual(p1, p2)
Definition: polys.h:111
#define omAlloc0(size)
Definition: omAllocDecl.h:211
int l
Definition: cfEzgcd.cc:94
static int ** Qpol
Definition: hilb.cc:33
static void hHilbEst(scfmon stc, int Nstc, varset var, int Nvar)
Definition: hilb.cc:52
static void hPrintHilb(intvec *hseries)
Definition: hilb.cc:1358
void hSupp(scfmon stc, int Nstc, varset var, int *Nvar)
Definition: hutil.cc:180
static void eulerchar(ideal I, int variables, mpz_ptr ec)
Definition: hilb.cc:805