simpleideals.cc
Go to the documentation of this file.
1 /****************************************
2 * Computer Algebra System SINGULAR *
3 ****************************************/
4 /*
5 * ABSTRACT - all basic methods to manipulate ideals
6 */
7 
8 
9 /* includes */
10 
11 
12 
13 #include <misc/auxiliary.h>
14 
15 #include <omalloc/omalloc.h>
16 
17 #include <misc/options.h>
18 #include <misc/intvec.h>
19 
20 // #include <coeffs/longrat.h>
21 #include "matpol.h"
22 
23 #include "monomials/p_polys.h"
24 #include "weight.h"
25 #include "sbuckets.h"
26 #include "clapsing.h"
27 
28 #include "simpleideals.h"
29 
31 
32 static poly * idpower;
33 /*collects the monomials in makemonoms, must be allocated befor*/
34 static int idpowerpoint;
35 /*index of the actual monomial in idpower*/
36 
37 /// initialise an ideal / module
38 ideal idInit(int idsize, int rank)
39 {
40  assume( idsize >= 0 && rank >= 0 );
41 
42  ideal hh = (ideal)omAllocBin(sip_sideal_bin);
43 
44  IDELEMS(hh) = idsize; // ncols
45  hh->nrows = 1; // ideal/module!
46 
47  hh->rank = rank; // ideal: 1, module: >= 0!
48 
49  if (idsize>0)
50  hh->m = (poly *)omAlloc0(idsize*sizeof(poly));
51  else
52  hh->m = NULL;
53 
54  return hh;
55 }
56 
57 #ifdef PDEBUG
58 // this is only for outputting an ideal within the debugger
59 // therefor it accept the otherwise illegal id==NULL
60 void idShow(const ideal id, const ring lmRing, const ring tailRing, const int debugPrint)
61 {
62  assume( debugPrint >= 0 );
63 
64  if( id == NULL )
65  PrintS("(NULL)");
66  else
67  {
68  Print("Module of rank %ld,real rank %ld and %d generators.\n",
69  id->rank,id_RankFreeModule(id, lmRing, tailRing),IDELEMS(id));
70 
71  int j = (id->ncols*id->nrows) - 1;
72  while ((j > 0) && (id->m[j]==NULL)) j--;
73  for (int i = 0; i <= j; i++)
74  {
75  Print("generator %d: ",i); p_wrp(id->m[i], lmRing, tailRing);PrintLn();
76  }
77  }
78 }
79 #endif
80 
81 /// index of generator with leading term in ground ring (if any);
82 /// otherwise -1
83 int id_PosConstant(ideal id, const ring r)
84 {
85  id_Test(id, r);
86  const int N = IDELEMS(id) - 1;
87  const poly * m = id->m + N;
88 
89  for (int k = N; k >= 0; --k, --m)
90  {
91  const poly p = *m;
92  if (p!=NULL)
93  if (p_LmIsConstantComp(p, r) == TRUE)
94  return k;
95  }
96 
97  return -1;
98 }
99 
100 /// initialise the maximal ideal (at 0)
101 ideal id_MaxIdeal (const ring r)
102 {
103  ideal hh = idInit(rVar(r), 1);
104  for (int l=rVar(r)-1; l>=0; l--)
105  {
106  hh->m[l] = p_One(r);
107  p_SetExp(hh->m[l],l+1,1,r);
108  p_Setm(hh->m[l],r);
109  }
110  id_Test(hh, r);
111  return hh;
112 }
113 
114 /// deletes an ideal/module/matrix
115 void id_Delete (ideal * h, ring r)
116 {
117  if (*h == NULL)
118  return;
119 
120  id_Test(*h, r);
121 
122  const int elems = (*h)->nrows * (*h)->ncols;
123 
124  if ( elems > 0 )
125  {
126  assume( (*h)->m != NULL );
127 
128  int j = elems;
129  do
130  {
131  j--;
132  poly pp=((*h)->m[j]);
133  if (pp!=NULL) p_Delete(&pp, r);
134  }
135  while (j>0);
136 
137  omFreeSize((ADDRESS)((*h)->m),sizeof(poly)*elems);
138  }
139 
141  *h=NULL;
142 }
143 
144 
145 /// Shallowdeletes an ideal/matrix
146 void id_ShallowDelete (ideal *h, ring r)
147 {
148  id_Test(*h, r);
149 
150  if (*h == NULL)
151  return;
152 
153  int j,elems;
154  elems=j=(*h)->nrows*(*h)->ncols;
155  if (j>0)
156  {
157  assume( (*h)->m != NULL );
158  do
159  {
160  p_ShallowDelete(&((*h)->m[--j]), r);
161  }
162  while (j>0);
163  omFreeSize((ADDRESS)((*h)->m),sizeof(poly)*elems);
164  }
166  *h=NULL;
167 }
168 
169 /// gives an ideal/module the minimal possible size
170 void idSkipZeroes (ideal ide)
171 {
172  assume (ide != NULL);
173 
174  int k;
175  int j = -1;
176  BOOLEAN change=FALSE;
177 
178  for (k=0; k<IDELEMS(ide); k++)
179  {
180  if (ide->m[k] != NULL)
181  {
182  j++;
183  if (change)
184  {
185  ide->m[j] = ide->m[k];
186  }
187  }
188  else
189  {
190  change=TRUE;
191  }
192  }
193  if (change)
194  {
195  if (j == -1)
196  j = 0;
197  else
198  {
199  for (k=j+1; k<IDELEMS(ide); k++)
200  ide->m[k] = NULL;
201  }
202  pEnlargeSet(&(ide->m),IDELEMS(ide),j+1-IDELEMS(ide));
203  IDELEMS(ide) = j+1;
204  }
205 }
206 
207 /// count non-zero elements
208 int idElem(const ideal F)
209 {
210  assume (F != NULL);
211 
212  int i=0;
213 
214  for(int j=IDELEMS(F)-1;j>=0;j--)
215  {
216  if ((F->m)[j]!=NULL) i++;
217  }
218  return i;
219 }
220 
221 /// copies the first k (>= 1) entries of the given ideal/module
222 /// and returns these as a new ideal/module
223 /// (Note that the copied entries may be zero.)
224 ideal id_CopyFirstK (const ideal ide, const int k,const ring r)
225 {
226  id_Test(ide, r);
227 
228  assume( ide != NULL );
229  assume( k <= IDELEMS(ide) );
230 
231  ideal newI = idInit(k, ide->rank);
232 
233  for (int i = 0; i < k; i++)
234  newI->m[i] = p_Copy(ide->m[i],r);
235 
236  return newI;
237 }
238 
239 /// ideal id = (id[i]), result is leadcoeff(id[i]) = 1
240 void id_Norm(ideal id, const ring r)
241 {
242  id_Test(id, r);
243  for (int i=IDELEMS(id)-1; i>=0; i--)
244  {
245  if (id->m[i] != NULL)
246  {
247  p_Norm(id->m[i],r);
248  }
249  }
250 }
251 
252 /// ideal id = (id[i]), c any unit
253 /// if id[i] = c*id[j] then id[j] is deleted for j > i
254 void id_DelMultiples(ideal id, const ring r)
255 {
256  id_Test(id, r);
257 
258  int i, j;
259  int k = IDELEMS(id)-1;
260  for (i=k; i>=0; i--)
261  {
262  if (id->m[i]!=NULL)
263  {
264  for (j=k; j>i; j--)
265  {
266  if (id->m[j]!=NULL)
267  {
268  if (rField_is_Ring(r))
269  {
270  /* if id[j] = c*id[i] then delete id[j].
271  In the below cases of a ground field, we
272  check whether id[i] = c*id[j] and, if so,
273  delete id[j] for historical reasons (so
274  that previous output does not change) */
275  if (p_ComparePolys(id->m[j], id->m[i],r)) p_Delete(&id->m[j],r);
276  }
277  else
278  {
279  if (p_ComparePolys(id->m[i], id->m[j],r)) p_Delete(&id->m[j],r);
280  }
281  }
282  }
283  }
284  }
285 }
286 
287 /// ideal id = (id[i])
288 /// if id[i] = id[j] then id[j] is deleted for j > i
289 void id_DelEquals(ideal id, const ring r)
290 {
291  id_Test(id, r);
292 
293  int i, j;
294  int k = IDELEMS(id)-1;
295  for (i=k; i>=0; i--)
296  {
297  if (id->m[i]!=NULL)
298  {
299  for (j=k; j>i; j--)
300  {
301  if ((id->m[j]!=NULL)
302  && (p_EqualPolys(id->m[i], id->m[j],r)))
303  {
304  p_Delete(&id->m[j],r);
305  }
306  }
307  }
308  }
309 }
310 
311 /// Delete id[j], if Lm(j) == Lm(i) and both LC(j), LC(i) are units and j > i
312 void id_DelLmEquals(ideal id, const ring r)
313 {
314  id_Test(id, r);
315 
316  int i, j;
317  int k = IDELEMS(id)-1;
318  for (i=k; i>=0; i--)
319  {
320  if (id->m[i] != NULL)
321  {
322  for (j=k; j>i; j--)
323  {
324  if ((id->m[j] != NULL)
325  && p_LmEqual(id->m[i], id->m[j],r)
326 #ifdef HAVE_RINGS
327  && n_IsUnit(pGetCoeff(id->m[i]),r->cf) && n_IsUnit(pGetCoeff(id->m[j]),r->cf)
328 #endif
329  )
330  {
331  p_Delete(&id->m[j],r);
332  }
333  }
334  }
335  }
336 }
337 
338 /// delete id[j], if LT(j) == coeff*mon*LT(i) and vice versa, i.e.,
339 /// delete id[i], if LT(i) == coeff*mon*LT(j)
340 void id_DelDiv(ideal id, const ring r)
341 {
342  id_Test(id, r);
343 
344  int i, j;
345  int k = IDELEMS(id)-1;
346  for (i=k; i>=0; i--)
347  {
348  if (id->m[i] != NULL)
349  {
350  for (j=k; j>i; j--)
351  {
352  if (id->m[j]!=NULL)
353  {
354 #ifdef HAVE_RINGS
355  if (rField_is_Ring(r))
356  {
357  if (p_DivisibleByRingCase(id->m[i], id->m[j],r))
358  {
359  p_Delete(&id->m[j],r);
360  }
361  else if (p_DivisibleByRingCase(id->m[j], id->m[i],r))
362  {
363  p_Delete(&id->m[i],r);
364  break;
365  }
366  }
367  else
368 #endif
369  {
370  /* the case of a coefficient field: */
371  if (p_DivisibleBy(id->m[i], id->m[j],r))
372  {
373  p_Delete(&id->m[j],r);
374  }
375  else if (p_DivisibleBy(id->m[j], id->m[i],r))
376  {
377  p_Delete(&id->m[i],r);
378  break;
379  }
380  }
381  }
382  }
383  }
384  }
385 }
386 
387 /// test if the ideal has only constant polynomials
388 /// NOTE: zero ideal/module is also constant
389 BOOLEAN id_IsConstant(ideal id, const ring r)
390 {
391  id_Test(id, r);
392 
393  for (int k = IDELEMS(id)-1; k>=0; k--)
394  {
395  if (!p_IsConstantPoly(id->m[k],r))
396  return FALSE;
397  }
398  return TRUE;
399 }
400 
401 /// copy an ideal
402 ideal id_Copy(ideal h1, const ring r)
403 {
404  id_Test(h1, r);
405 
406  ideal h2 = idInit(IDELEMS(h1), h1->rank);
407  for (int i=IDELEMS(h1)-1; i>=0; i--)
408  h2->m[i] = p_Copy(h1->m[i],r);
409  return h2;
410 }
411 
412 #ifdef PDEBUG
413 /// Internal verification for ideals/modules and dense matrices!
414 void id_DBTest(ideal h1, int level, const char *f,const int l, const ring r, const ring tailRing)
415 {
416  if (h1 != NULL)
417  {
418  // assume(IDELEMS(h1) > 0); for ideal/module, does not apply to matrix
419  omCheckAddrSize(h1,sizeof(*h1));
420 
421  assume( h1->ncols >= 0 );
422  assume( h1->nrows >= 0 ); // matrix case!
423 
424  assume( h1->rank >= 0 );
425 
426  const int n = (h1->ncols * h1->nrows);
427 
428  assume( !( n > 0 && h1->m == NULL) );
429 
430  if( h1->m != NULL && n > 0 )
431  omdebugAddrSize(h1->m, n * sizeof(poly));
432 
433  long new_rk = 0; // inlining id_RankFreeModule(h1, r, tailRing);
434 
435  /* to be able to test matrices: */
436  for (int i=n - 1; i >= 0; i--)
437  {
438  _pp_Test(h1->m[i], r, tailRing, level);
439  const long k = p_MaxComp(h1->m[i], r, tailRing);
440  if (k > new_rk) new_rk = k;
441  }
442 
443  // dense matrices only contain polynomials:
444  // h1->nrows == h1->rank > 1 && new_rk == 0!
445  assume( !( h1->nrows == h1->rank && h1->nrows > 1 && new_rk > 0 ) ); //
446 
447  if(new_rk > h1->rank)
448  {
449  dReportError("wrong rank %d (should be %d) in %s:%d\n",
450  h1->rank, new_rk, f,l);
451  omPrintAddrInfo(stderr, h1, " for ideal");
452  h1->rank = new_rk;
453  }
454  }
455  else
456  {
457  Print("error: ideal==NULL in %s:%d\n",f,l);
458  assume( h1 != NULL );
459  }
460 }
461 #endif
462 
463 /// for idSort: compare a and b revlex inclusive module comp.
464 static int p_Comp_RevLex(poly a, poly b,BOOLEAN nolex, const ring R)
465 {
466  if (b==NULL) return 1;
467  if (a==NULL) return -1;
468 
469  if (nolex)
470  {
471  int r=p_LtCmp(a,b,R);
472  return r;
473  #if 0
474  if (r!=0) return r;
475  number h=n_Sub(pGetCoeff(a),pGetCoeff(b),R->cf);
476  r = -1+n_IsZero(h,R->cf)+2*n_GreaterZero(h,R->cf); /* -1: <, 0:==, 1: > */
477  n_Delete(&h, R->cf);
478  return r;
479  #endif
480  }
481  int l=rVar(R);
482  while ((l>0) && (p_GetExp(a,l,R)==p_GetExp(b,l,R))) l--;
483  if (l==0)
484  {
485  if (p_GetComp(a,R)==p_GetComp(b,R))
486  {
487  number h=n_Sub(pGetCoeff(a),pGetCoeff(b),R->cf);
488  int r = -1+n_IsZero(h,R->cf)+2*n_GreaterZero(h,R->cf); /* -1: <, 0:==, 1: > */
489  n_Delete(&h,R->cf);
490  return r;
491  }
492  if (p_GetComp(a,R)>p_GetComp(b,R)) return 1;
493  }
494  else if (p_GetExp(a,l,R)>p_GetExp(b,l,R))
495  return 1;
496  return -1;
497 }
498 
499 // sorts the ideal w.r.t. the actual ringordering
500 // uses lex-ordering when nolex = FALSE
501 intvec *id_Sort(const ideal id, const BOOLEAN nolex, const ring r)
502 {
503  id_Test(id, r);
504 
505  intvec * result = new intvec(IDELEMS(id));
506  int i, j, actpos=0, newpos;
507  int diff, olddiff, lastcomp, newcomp;
508  BOOLEAN notFound;
509 
510  for (i=0;i<IDELEMS(id);i++)
511  {
512  if (id->m[i]!=NULL)
513  {
514  notFound = TRUE;
515  newpos = actpos / 2;
516  diff = (actpos+1) / 2;
517  diff = (diff+1) / 2;
518  lastcomp = p_Comp_RevLex(id->m[i],id->m[(*result)[newpos]],nolex,r);
519  if (lastcomp<0)
520  {
521  newpos -= diff;
522  }
523  else if (lastcomp>0)
524  {
525  newpos += diff;
526  }
527  else
528  {
529  notFound = FALSE;
530  }
531  //while ((newpos>=0) && (newpos<actpos) && (notFound))
532  while (notFound && (newpos>=0) && (newpos<actpos))
533  {
534  newcomp = p_Comp_RevLex(id->m[i],id->m[(*result)[newpos]],nolex,r);
535  olddiff = diff;
536  if (diff>1)
537  {
538  diff = (diff+1) / 2;
539  if ((newcomp==1)
540  && (actpos-newpos>1)
541  && (diff>1)
542  && (newpos+diff>=actpos))
543  {
544  diff = actpos-newpos-1;
545  }
546  else if ((newcomp==-1)
547  && (diff>1)
548  && (newpos<diff))
549  {
550  diff = newpos;
551  }
552  }
553  if (newcomp<0)
554  {
555  if ((olddiff==1) && (lastcomp>0))
556  notFound = FALSE;
557  else
558  newpos -= diff;
559  }
560  else if (newcomp>0)
561  {
562  if ((olddiff==1) && (lastcomp<0))
563  {
564  notFound = FALSE;
565  newpos++;
566  }
567  else
568  {
569  newpos += diff;
570  }
571  }
572  else
573  {
574  notFound = FALSE;
575  }
576  lastcomp = newcomp;
577  if (diff==0) notFound=FALSE; /*hs*/
578  }
579  if (newpos<0) newpos = 0;
580  if (newpos>actpos) newpos = actpos;
581  while ((newpos<actpos) && (p_Comp_RevLex(id->m[i],id->m[(*result)[newpos]],nolex,r)==0))
582  newpos++;
583  for (j=actpos;j>newpos;j--)
584  {
585  (*result)[j] = (*result)[j-1];
586  }
587  (*result)[newpos] = i;
588  actpos++;
589  }
590  }
591  for (j=0;j<actpos;j++) (*result)[j]++;
592  return result;
593 }
594 
595 /// concat the lists h1 and h2 without zeros
596 ideal id_SimpleAdd (ideal h1,ideal h2, const ring R)
597 {
598  id_Test(h1, R);
599  id_Test(h2, R);
600 
601  if ( idIs0(h1) )
602  {
603  ideal res=id_Copy(h2,R);
604  if (res->rank<h1->rank) res->rank=h1->rank;
605  return res;
606  }
607  if ( idIs0(h2) )
608  {
609  ideal res=id_Copy(h1,R);
610  if (res->rank<h2->rank) res->rank=h2->rank;
611  return res;
612  }
613 
614  int j = IDELEMS(h1)-1;
615  while ((j >= 0) && (h1->m[j] == NULL)) j--;
616 
617  int i = IDELEMS(h2)-1;
618  while ((i >= 0) && (h2->m[i] == NULL)) i--;
619 
620  const int r = si_max(h1->rank, h2->rank);
621 
622  ideal result = idInit(i+j+2,r);
623 
624  int l;
625 
626  for (l=j; l>=0; l--)
627  result->m[l] = p_Copy(h1->m[l],R);
628 
629  j = i+j+1;
630  for (l=i; l>=0; l--, j--)
631  result->m[j] = p_Copy(h2->m[l],R);
632 
633  return result;
634 }
635 
636 /// insert h2 into h1 (if h2 is not the zero polynomial)
637 /// return TRUE iff h2 was indeed inserted
638 BOOLEAN idInsertPoly (ideal h1, poly h2)
639 {
640  if (h2==NULL) return FALSE;
641  assume (h1 != NULL);
642 
643  int j = IDELEMS(h1) - 1;
644 
645  while ((j >= 0) && (h1->m[j] == NULL)) j--;
646  j++;
647  if (j==IDELEMS(h1))
648  {
649  pEnlargeSet(&(h1->m),IDELEMS(h1),16);
650  IDELEMS(h1)+=16;
651  }
652  h1->m[j]=h2;
653  return TRUE;
654 }
655 
656 /// insert p into I on position pos
657 BOOLEAN idInsertPolyOnPos (ideal I, poly p,int pos)
658 {
659  if (p==NULL) return FALSE;
660  assume (I != NULL);
661 
662  int j = IDELEMS(I) - 1;
663 
664  while ((j >= 0) && (I->m[j] == NULL)) j--;
665  j++;
666  if (j==IDELEMS(I))
667  {
668  pEnlargeSet(&(I->m),IDELEMS(I),IDELEMS(I)+1);
669  IDELEMS(I)+=1;
670  }
671  for(j = IDELEMS(I)-1;j>pos;j--)
672  I->m[j] = I->m[j-1];
673  I->m[pos]=p;
674  return TRUE;
675 }
676 
677 
678 /*! insert h2 into h1 depending on the two boolean parameters:
679  * - if zeroOk is true, then h2 will also be inserted when it is zero
680  * - if duplicateOk is true, then h2 will also be inserted when it is
681  * already present in h1
682  * return TRUE iff h2 was indeed inserted
683  */
684 BOOLEAN id_InsertPolyWithTests (ideal h1, const int validEntries,
685  const poly h2, const bool zeroOk, const bool duplicateOk, const ring r)
686 {
687  id_Test(h1, r);
688  p_Test(h2, r);
689 
690  if ((!zeroOk) && (h2 == NULL)) return FALSE;
691  if (!duplicateOk)
692  {
693  bool h2FoundInH1 = false;
694  int i = 0;
695  while ((i < validEntries) && (!h2FoundInH1))
696  {
697  h2FoundInH1 = p_EqualPolys(h1->m[i], h2,r);
698  i++;
699  }
700  if (h2FoundInH1) return FALSE;
701  }
702  if (validEntries == IDELEMS(h1))
703  {
704  pEnlargeSet(&(h1->m), IDELEMS(h1), 16);
705  IDELEMS(h1) += 16;
706  }
707  h1->m[validEntries] = h2;
708  return TRUE;
709 }
710 
711 /// h1 + h2
712 ideal id_Add (ideal h1,ideal h2, const ring r)
713 {
714  id_Test(h1, r);
715  id_Test(h2, r);
716 
717  ideal result = id_SimpleAdd(h1,h2,r);
719  return result;
720 }
721 
722 /// h1 * h2
723 /// one h_i must be an ideal (with at least one column)
724 /// the other h_i may be a module (with no columns at all)
725 ideal id_Mult (ideal h1,ideal h2, const ring R)
726 {
727  id_Test(h1, R);
728  id_Test(h2, R);
729 
730  int j = IDELEMS(h1);
731  while ((j > 0) && (h1->m[j-1] == NULL)) j--;
732 
733  int i = IDELEMS(h2);
734  while ((i > 0) && (h2->m[i-1] == NULL)) i--;
735 
736  j *= i;
737  int r = si_max( h2->rank, h1->rank );
738  if (j==0)
739  {
740  if ((IDELEMS(h1)>0) && (IDELEMS(h2)>0)) j=1;
741  return idInit(j, r);
742  }
743  ideal hh = idInit(j, r);
744 
745  int k = 0;
746  for (i=0; i<IDELEMS(h1); i++)
747  {
748  if (h1->m[i] != NULL)
749  {
750  for (j=0; j<IDELEMS(h2); j++)
751  {
752  if (h2->m[j] != NULL)
753  {
754  hh->m[k] = pp_Mult_qq(h1->m[i],h2->m[j],R);
755  k++;
756  }
757  }
758  }
759  }
760 
761  id_Compactify(hh,R);
762  return hh;
763 }
764 
765 /// returns true if h is the zero ideal
766 BOOLEAN idIs0 (ideal h)
767 {
768  assume (h != NULL); // will fail :(
769 // if (h == NULL) return TRUE;
770 
771  for( int i = IDELEMS(h)-1; i >= 0; i-- )
772  if(h->m[i] != NULL)
773  return FALSE;
774 
775  return TRUE;
776 
777 }
778 
779 /// return the maximal component number found in any polynomial in s
780 long id_RankFreeModule (ideal s, ring lmRing, ring tailRing)
781 {
783 
784  long j = 0;
785 
787  {
788  poly *p=s->m;
789  for (unsigned int l=IDELEMS(s); l > 0; --l, ++p)
790  if (*p != NULL)
791  {
792  pp_Test(*p, lmRing, tailRing);
793  const long k = p_MaxComp(*p, lmRing, tailRing);
794  if (k>j) j = k;
795  }
796  }
797 
798  return j; // return -1;
799 }
800 
801 /*2
802 *returns true if id is homogenous with respect to the aktual weights
803 */
804 BOOLEAN id_HomIdeal (ideal id, ideal Q, const ring r)
805 {
806  int i;
807  BOOLEAN b;
808  i = 0;
809  b = TRUE;
810  while ((i < IDELEMS(id)) && b)
811  {
812  b = p_IsHomogeneous(id->m[i],r);
813  i++;
814  }
815  if ((b) && (Q!=NULL) && (IDELEMS(Q)>0))
816  {
817  i=0;
818  while ((i < IDELEMS(Q)) && b)
819  {
820  b = p_IsHomogeneous(Q->m[i],r);
821  i++;
822  }
823  }
824  return b;
825 }
826 
827 /*2
828 *initialized a field with r numbers between beg and end for the
829 *procedure idNextChoise
830 */
831 void idInitChoise (int r,int beg,int end,BOOLEAN *endch,int * choise)
832 {
833  /*returns the first choise of r numbers between beg and end*/
834  int i;
835  for (i=0; i<r; i++)
836  {
837  choise[i] = 0;
838  }
839  if (r <= end-beg+1)
840  for (i=0; i<r; i++)
841  {
842  choise[i] = beg+i;
843  }
844  if (r > end-beg+1)
845  *endch = TRUE;
846  else
847  *endch = FALSE;
848 }
849 
850 /*2
851 *returns the next choise of r numbers between beg and end
852 */
853 void idGetNextChoise (int r,int end,BOOLEAN *endch,int * choise)
854 {
855  int i = r-1,j;
856  while ((i >= 0) && (choise[i] == end))
857  {
858  i--;
859  end--;
860  }
861  if (i == -1)
862  *endch = TRUE;
863  else
864  {
865  choise[i]++;
866  for (j=i+1; j<r; j++)
867  {
868  choise[j] = choise[i]+j-i;
869  }
870  *endch = FALSE;
871  }
872 }
873 
874 /*2
875 *takes the field choise of d numbers between beg and end, cancels the t-th
876 *entree and searches for the ordinal number of that d-1 dimensional field
877 * w.r.t. the algorithm of construction
878 */
879 int idGetNumberOfChoise(int t, int d, int begin, int end, int * choise)
880 {
881  int * localchoise,i,result=0;
882  BOOLEAN b=FALSE;
883 
884  if (d<=1) return 1;
885  localchoise=(int*)omAlloc((d-1)*sizeof(int));
886  idInitChoise(d-1,begin,end,&b,localchoise);
887  while (!b)
888  {
889  result++;
890  i = 0;
891  while ((i<t) && (localchoise[i]==choise[i])) i++;
892  if (i>=t)
893  {
894  i = t+1;
895  while ((i<d) && (localchoise[i-1]==choise[i])) i++;
896  if (i>=d)
897  {
898  omFreeSize((ADDRESS)localchoise,(d-1)*sizeof(int));
899  return result;
900  }
901  }
902  idGetNextChoise(d-1,end,&b,localchoise);
903  }
904  omFreeSize((ADDRESS)localchoise,(d-1)*sizeof(int));
905  return 0;
906 }
907 
908 /*2
909 *computes the binomial coefficient
910 */
911 int binom (int n,int r)
912 {
913  int i,result;
914 
915  if (r==0) return 1;
916  if (n-r<r) return binom(n,n-r);
917  result = n-r+1;
918  for (i=2;i<=r;i++)
919  {
920  result *= n-r+i;
921  if (result<0)
922  {
923  WarnS("overflow in binomials");
924  return 0;
925  }
926  result /= i;
927  }
928  return result;
929 }
930 
931 
932 /// the free module of rank i
933 ideal id_FreeModule (int i, const ring r)
934 {
935  assume(i >= 0);
936  ideal h = idInit(i, i);
937 
938  for (int j=0; j<i; j++)
939  {
940  h->m[j] = p_One(r);
941  p_SetComp(h->m[j],j+1,r);
942  p_SetmComp(h->m[j],r);
943  }
944 
945  return h;
946 }
947 
948 /*2
949 *computes recursively all monomials of a certain degree
950 *in every step the actvar-th entry in the exponential
951 *vector is incremented and the other variables are
952 *computed by recursive calls of makemonoms
953 *if the last variable is reached, the difference to the
954 *degree is computed directly
955 *vars is the number variables
956 *actvar is the actual variable to handle
957 *deg is the degree of the monomials to compute
958 *monomdeg is the actual degree of the monomial in consideration
959 */
960 static void makemonoms(int vars,int actvar,int deg,int monomdeg, const ring r)
961 {
962  poly p;
963  int i=0;
964 
965  if ((idpowerpoint == 0) && (actvar ==1))
966  {
968  monomdeg = 0;
969  }
970  while (i<=deg)
971  {
972  if (deg == monomdeg)
973  {
975  idpowerpoint++;
976  return;
977  }
978  if (actvar == vars)
979  {
980  p_SetExp(idpower[idpowerpoint],actvar,deg-monomdeg,r);
983  idpowerpoint++;
984  return;
985  }
986  else
987  {
989  makemonoms(vars,actvar+1,deg,monomdeg,r);
991  }
992  monomdeg++;
996  i++;
997  }
998 }
999 
1000 /*2
1001 *returns the deg-th power of the maximal ideal of 0
1002 */
1003 ideal id_MaxIdeal(int deg, const ring r)
1004 {
1005  if (deg < 0)
1006  {
1007  WarnS("maxideal: power must be non-negative");
1008  }
1009  if (deg < 1)
1010  {
1011  ideal I=idInit(1,1);
1012  I->m[0]=p_One(r);
1013  return I;
1014  }
1015  if (deg == 1)
1016  {
1017  return id_MaxIdeal(r);
1018  }
1019 
1020  int vars = rVar(r);
1021  int i = binom(vars+deg-1,deg);
1022  if (i<=0) return idInit(1,1);
1023  ideal id=idInit(i,1);
1024  idpower = id->m;
1025  idpowerpoint = 0;
1026  makemonoms(vars,1,deg,0,r);
1027  idpower = NULL;
1028  idpowerpoint = 0;
1029  return id;
1030 }
1031 
1032 static void id_NextPotence(ideal given, ideal result,
1033  int begin, int end, int deg, int restdeg, poly ap, const ring r)
1034 {
1035  poly p;
1036  int i;
1037 
1038  p = p_Power(p_Copy(given->m[begin],r),restdeg,r);
1039  i = result->nrows;
1040  result->m[i] = p_Mult_q(p_Copy(ap,r),p,r);
1041 //PrintS(".");
1042  (result->nrows)++;
1043  if (result->nrows >= IDELEMS(result))
1044  {
1045  pEnlargeSet(&(result->m),IDELEMS(result),16);
1046  IDELEMS(result) += 16;
1047  }
1048  if (begin == end) return;
1049  for (i=restdeg-1;i>0;i--)
1050  {
1051  p = p_Power(p_Copy(given->m[begin],r),i,r);
1052  p = p_Mult_q(p_Copy(ap,r),p,r);
1053  id_NextPotence(given, result, begin+1, end, deg, restdeg-i, p,r);
1054  p_Delete(&p,r);
1055  }
1056  id_NextPotence(given, result, begin+1, end, deg, restdeg, ap,r);
1057 }
1058 
1059 ideal id_Power(ideal given,int exp, const ring r)
1060 {
1061  ideal result,temp;
1062  poly p1;
1063  int i;
1064 
1065  if (idIs0(given)) return idInit(1,1);
1066  temp = id_Copy(given,r);
1067  idSkipZeroes(temp);
1068  i = binom(IDELEMS(temp)+exp-1,exp);
1069  result = idInit(i,1);
1070  result->nrows = 0;
1071 //Print("ideal contains %d elements\n",i);
1072  p1=p_One(r);
1073  id_NextPotence(temp,result,0,IDELEMS(temp)-1,exp,exp,p1,r);
1074  p_Delete(&p1,r);
1075  id_Delete(&temp,r);
1076  result->nrows = 1;
1079  return result;
1080 }
1081 
1082 /*2
1083 *skips all zeroes and double elements, searches also for units
1084 */
1085 void id_Compactify(ideal id, const ring r)
1086 {
1087  int i;
1088  BOOLEAN b=FALSE;
1089 
1090  i = IDELEMS(id)-1;
1091  while ((! b) && (i>=0))
1092  {
1093  b=p_IsUnit(id->m[i],r);
1094  i--;
1095  }
1096  if (b)
1097  {
1098  for(i=IDELEMS(id)-1;i>=0;i--) p_Delete(&id->m[i],r);
1099  id->m[0]=p_One(r);
1100  }
1101  else
1102  {
1103  id_DelMultiples(id,r);
1104  }
1105  idSkipZeroes(id);
1106 }
1107 
1108 /// returns the ideals of initial terms
1109 ideal id_Head(ideal h,const ring r)
1110 {
1111  ideal m = idInit(IDELEMS(h),h->rank);
1112 
1113  for (int i=IDELEMS(h)-1;i>=0; i--)
1114  if (h->m[i]!=NULL)
1115  m->m[i]=p_Head(h->m[i],r);
1116 
1117  return m;
1118 }
1119 
1120 ideal id_Homogen(ideal h, int varnum,const ring r)
1121 {
1122  ideal m = idInit(IDELEMS(h),h->rank);
1123  int i;
1124 
1125  for (i=IDELEMS(h)-1;i>=0; i--)
1126  {
1127  m->m[i]=p_Homogen(h->m[i],varnum,r);
1128  }
1129  return m;
1130 }
1131 
1132 /*------------------type conversions----------------*/
1133 ideal id_Vec2Ideal(poly vec, const ring R)
1134 {
1135  ideal result=idInit(1,1);
1136  omFree((ADDRESS)result->m);
1137  result->m=NULL; // remove later
1138  p_Vec2Polys(vec, &(result->m), &(IDELEMS(result)),R);
1139  return result;
1140 }
1141 
1142 
1143 // converts mat to module, destroys mat
1144 ideal id_Matrix2Module(matrix mat, const ring R)
1145 {
1146  int mc=MATCOLS(mat);
1147  int mr=MATROWS(mat);
1148  ideal result = idInit(mc,mr);
1149  int i,j,l;
1150  poly h;
1152 
1153  for(j=0;j<mc /*MATCOLS(mat)*/;j++) /* j is also index in result->m */
1154  {
1155  for (i=1;i<=mr /*MATROWS(mat)*/;i++)
1156  {
1157  h = MATELEM(mat,i,j+1);
1158  if (h!=NULL)
1159  {
1160  l=pLength(h);
1161  MATELEM(mat,i,j+1)=NULL;
1162  p_SetCompP(h,i, R);
1164  }
1165  }
1166  sBucketClearMerge(bucket, &(result->m[j]), &l);
1167  }
1169 
1170  // obachman: need to clean this up
1171  id_Delete((ideal*) &mat,R);
1172  return result;
1173 }
1174 
1175 /*2
1176 * converts a module into a matrix, destroyes the input
1177 */
1178 matrix id_Module2Matrix(ideal mod, const ring R)
1179 {
1180  matrix result = mpNew(mod->rank,IDELEMS(mod));
1181  long i; long cp;
1182  poly p,h;
1183 
1184  for(i=0;i<IDELEMS(mod);i++)
1185  {
1186  p=pReverse(mod->m[i]);
1187  mod->m[i]=NULL;
1188  while (p!=NULL)
1189  {
1190  h=p;
1191  pIter(p);
1192  pNext(h)=NULL;
1193  cp = si_max(1L,p_GetComp(h, R)); // if used for ideals too
1194  //cp = p_GetComp(h,R);
1195  p_SetComp(h,0,R);
1196  p_SetmComp(h,R);
1197 #ifdef TEST
1198  if (cp>mod->rank)
1199  {
1200  Print("## inv. rank %ld -> %ld\n",mod->rank,cp);
1201  int k,l,o=mod->rank;
1202  mod->rank=cp;
1203  matrix d=mpNew(mod->rank,IDELEMS(mod));
1204  for (l=1; l<=o; l++)
1205  {
1206  for (k=1; k<=IDELEMS(mod); k++)
1207  {
1208  MATELEM(d,l,k)=MATELEM(result,l,k);
1209  MATELEM(result,l,k)=NULL;
1210  }
1211  }
1212  id_Delete((ideal *)&result,R);
1213  result=d;
1214  }
1215 #endif
1216  MATELEM(result,cp,i+1) = p_Add_q(MATELEM(result,cp,i+1),h,R);
1217  }
1218  }
1219  // obachman 10/99: added the following line, otherwise memory leack!
1220  id_Delete(&mod,R);
1221  return result;
1222 }
1223 
1224 matrix id_Module2formatedMatrix(ideal mod,int rows, int cols, const ring R)
1225 {
1226  matrix result = mpNew(rows,cols);
1227  int i,cp,r=id_RankFreeModule(mod,R),c=IDELEMS(mod);
1228  poly p,h;
1229 
1230  if (r>rows) r = rows;
1231  if (c>cols) c = cols;
1232  for(i=0;i<c;i++)
1233  {
1234  p=pReverse(mod->m[i]);
1235  mod->m[i]=NULL;
1236  while (p!=NULL)
1237  {
1238  h=p;
1239  pIter(p);
1240  pNext(h)=NULL;
1241  cp = p_GetComp(h,R);
1242  if (cp<=r)
1243  {
1244  p_SetComp(h,0,R);
1245  p_SetmComp(h,R);
1246  MATELEM(result,cp,i+1) = p_Add_q(MATELEM(result,cp,i+1),h,R);
1247  }
1248  else
1249  p_Delete(&h,R);
1250  }
1251  }
1252  id_Delete(&mod,R);
1253  return result;
1254 }
1255 
1256 /*2
1257 * substitute the n-th variable by the monomial e in id
1258 * destroy id
1259 */
1260 ideal id_Subst(ideal id, int n, poly e, const ring r)
1261 {
1262  int k=MATROWS((matrix)id)*MATCOLS((matrix)id);
1263  ideal res=(ideal)mpNew(MATROWS((matrix)id),MATCOLS((matrix)id));
1264 
1265  res->rank = id->rank;
1266  for(k--;k>=0;k--)
1267  {
1268  res->m[k]=p_Subst(id->m[k],n,e,r);
1269  id->m[k]=NULL;
1270  }
1271  id_Delete(&id,r);
1272  return res;
1273 }
1274 
1275 BOOLEAN id_HomModule(ideal m, ideal Q, intvec **w, const ring R)
1276 {
1277  if (w!=NULL) *w=NULL;
1278  if ((Q!=NULL) && (!id_HomIdeal(Q,NULL,R))) return FALSE;
1279  if (idIs0(m))
1280  {
1281  if (w!=NULL) (*w)=new intvec(m->rank);
1282  return TRUE;
1283  }
1284 
1285  long cmax=1,order=0,ord,* diff,diffmin=32000;
1286  int *iscom;
1287  int i;
1288  poly p=NULL;
1289  pFDegProc d;
1290  if (R->pLexOrder && (R->order[0]==ringorder_lp))
1291  d=p_Totaldegree;
1292  else
1293  d=R->pFDeg;
1294  int length=IDELEMS(m);
1295  poly* P=m->m;
1296  poly* F=(poly*)omAlloc(length*sizeof(poly));
1297  for (i=length-1;i>=0;i--)
1298  {
1299  p=F[i]=P[i];
1300  cmax=si_max(cmax,p_MaxComp(p,R));
1301  }
1302  cmax++;
1303  diff = (long *)omAlloc0(cmax*sizeof(long));
1304  if (w!=NULL) *w=new intvec(cmax-1);
1305  iscom = (int *)omAlloc0(cmax*sizeof(int));
1306  i=0;
1307  while (i<=length)
1308  {
1309  if (i<length)
1310  {
1311  p=F[i];
1312  while ((p!=NULL) && (iscom[p_GetComp(p,R)]==0)) pIter(p);
1313  }
1314  if ((p==NULL) && (i<length))
1315  {
1316  i++;
1317  }
1318  else
1319  {
1320  if (p==NULL) /* && (i==length) */
1321  {
1322  i=0;
1323  while ((i<length) && (F[i]==NULL)) i++;
1324  if (i>=length) break;
1325  p = F[i];
1326  }
1327  //if (pLexOrder && (currRing->order[0]==ringorder_lp))
1328  // order=pTotaldegree(p);
1329  //else
1330  // order = p->order;
1331  // order = pFDeg(p,currRing);
1332  order = d(p,R) +diff[p_GetComp(p,R)];
1333  //order += diff[pGetComp(p)];
1334  p = F[i];
1335 //Print("Actual p=F[%d]: ",i);pWrite(p);
1336  F[i] = NULL;
1337  i=0;
1338  }
1339  while (p!=NULL)
1340  {
1341  if (R->pLexOrder && (R->order[0]==ringorder_lp))
1342  ord=p_Totaldegree(p,R);
1343  else
1344  // ord = p->order;
1345  ord = R->pFDeg(p,R);
1346  if (iscom[p_GetComp(p,R)]==0)
1347  {
1348  diff[p_GetComp(p,R)] = order-ord;
1349  iscom[p_GetComp(p,R)] = 1;
1350 /*
1351 *PrintS("new diff: ");
1352 *for (j=0;j<cmax;j++) Print("%d ",diff[j]);
1353 *PrintLn();
1354 *PrintS("new iscom: ");
1355 *for (j=0;j<cmax;j++) Print("%d ",iscom[j]);
1356 *PrintLn();
1357 *Print("new set %d, order %d, ord %d, diff %d\n",pGetComp(p),order,ord,diff[pGetComp(p)]);
1358 */
1359  }
1360  else
1361  {
1362 /*
1363 *PrintS("new diff: ");
1364 *for (j=0;j<cmax;j++) Print("%d ",diff[j]);
1365 *PrintLn();
1366 *Print("order %d, ord %d, diff %d\n",order,ord,diff[pGetComp(p)]);
1367 */
1368  if (order != (ord+diff[p_GetComp(p,R)]))
1369  {
1370  omFreeSize((ADDRESS) iscom,cmax*sizeof(int));
1371  omFreeSize((ADDRESS) diff,cmax*sizeof(long));
1372  omFreeSize((ADDRESS) F,length*sizeof(poly));
1373  delete *w;*w=NULL;
1374  return FALSE;
1375  }
1376  }
1377  pIter(p);
1378  }
1379  }
1380  omFreeSize((ADDRESS) iscom,cmax*sizeof(int));
1381  omFreeSize((ADDRESS) F,length*sizeof(poly));
1382  for (i=1;i<cmax;i++) (**w)[i-1]=(int)(diff[i]);
1383  for (i=1;i<cmax;i++)
1384  {
1385  if (diff[i]<diffmin) diffmin=diff[i];
1386  }
1387  if (w!=NULL)
1388  {
1389  for (i=1;i<cmax;i++)
1390  {
1391  (**w)[i-1]=(int)(diff[i]-diffmin);
1392  }
1393  }
1394  omFreeSize((ADDRESS) diff,cmax*sizeof(long));
1395  return TRUE;
1396 }
1397 
1398 ideal id_Jet(ideal i,int d, const ring R)
1399 {
1400  ideal r=idInit((i->nrows)*(i->ncols),i->rank);
1401  r->nrows = i-> nrows;
1402  r->ncols = i-> ncols;
1403  //r->rank = i-> rank;
1404 
1405  for(int k=(i->nrows)*(i->ncols)-1;k>=0; k--)
1406  r->m[k]=pp_Jet(i->m[k],d,R);
1407 
1408  return r;
1409 }
1410 
1411 ideal id_JetW(ideal i,int d, intvec * iv, const ring R)
1412 {
1413  ideal r=idInit(IDELEMS(i),i->rank);
1414  if (ecartWeights!=NULL)
1415  {
1416  WerrorS("cannot compute weighted jets now");
1417  }
1418  else
1419  {
1420  short *w=iv2array(iv,R);
1421  int k;
1422  for(k=0; k<IDELEMS(i); k++)
1423  {
1424  r->m[k]=pp_JetW(i->m[k],d,w,R);
1425  }
1426  omFreeSize((ADDRESS)w,(rVar(R)+1)*sizeof(short));
1427  }
1428  return r;
1429 }
1430 
1431 /*3
1432 * searches for the next unit in the components of the module arg and
1433 * returns the first one;
1434 */
1435 int id_ReadOutPivot(ideal arg,int* comp, const ring r)
1436 {
1437  if (idIs0(arg)) return -1;
1438  int i=0,j, generator=-1;
1439  int rk_arg=arg->rank; //idRankFreeModule(arg);
1440  int * componentIsUsed =(int *)omAlloc((rk_arg+1)*sizeof(int));
1441  poly p;
1442 
1443  while ((generator<0) && (i<IDELEMS(arg)))
1444  {
1445  memset(componentIsUsed,0,(rk_arg+1)*sizeof(int));
1446  p = arg->m[i];
1447  while (p!=NULL)
1448  {
1449  j = p_GetComp(p,r);
1450  if (componentIsUsed[j]==0)
1451  {
1452  if (p_LmIsConstantComp(p,r) &&
1453  (!rField_is_Ring(r) || n_IsUnit(pGetCoeff(p),r->cf)))
1454  {
1455  generator = i;
1456  componentIsUsed[j] = 1;
1457  }
1458  else
1459  {
1460  componentIsUsed[j] = -1;
1461  }
1462  }
1463  else if (componentIsUsed[j]>0)
1464  {
1465  (componentIsUsed[j])++;
1466  }
1467  pIter(p);
1468  }
1469  i++;
1470  }
1471  i = 0;
1472  *comp = -1;
1473  for (j=0;j<=rk_arg;j++)
1474  {
1475  if (componentIsUsed[j]>0)
1476  {
1477  if ((*comp==-1) || (componentIsUsed[j]<i))
1478  {
1479  *comp = j;
1480  i= componentIsUsed[j];
1481  }
1482  }
1483  }
1484  omFree(componentIsUsed);
1485  return generator;
1486 }
1487 
1488 #if 0
1489 static void idDeleteComp(ideal arg,int red_comp)
1490 {
1491  int i,j;
1492  poly p;
1493 
1494  for (i=IDELEMS(arg)-1;i>=0;i--)
1495  {
1496  p = arg->m[i];
1497  while (p!=NULL)
1498  {
1499  j = pGetComp(p);
1500  if (j>red_comp)
1501  {
1502  pSetComp(p,j-1);
1503  pSetm(p);
1504  }
1505  pIter(p);
1506  }
1507  }
1508  (arg->rank)--;
1509 }
1510 #endif
1511 
1512 intvec * id_QHomWeight(ideal id, const ring r)
1513 {
1514  poly head, tail;
1515  int k;
1516  int in=IDELEMS(id)-1, ready=0, all=0,
1517  coldim=rVar(r), rowmax=2*coldim;
1518  if (in<0) return NULL;
1519  intvec *imat=new intvec(rowmax+1,coldim,0);
1520 
1521  do
1522  {
1523  head = id->m[in--];
1524  if (head!=NULL)
1525  {
1526  tail = pNext(head);
1527  while (tail!=NULL)
1528  {
1529  all++;
1530  for (k=1;k<=coldim;k++)
1531  IMATELEM(*imat,all,k) = p_GetExpDiff(head,tail,k,r);
1532  if (all==rowmax)
1533  {
1534  ivTriangIntern(imat, ready, all);
1535  if (ready==coldim)
1536  {
1537  delete imat;
1538  return NULL;
1539  }
1540  }
1541  pIter(tail);
1542  }
1543  }
1544  } while (in>=0);
1545  if (all>ready)
1546  {
1547  ivTriangIntern(imat, ready, all);
1548  if (ready==coldim)
1549  {
1550  delete imat;
1551  return NULL;
1552  }
1553  }
1554  intvec *result = ivSolveKern(imat, ready);
1555  delete imat;
1556  return result;
1557 }
1558 
1559 BOOLEAN id_IsZeroDim(ideal I, const ring r)
1560 {
1561  BOOLEAN *UsedAxis=(BOOLEAN *)omAlloc0(rVar(r)*sizeof(BOOLEAN));
1562  int i,n;
1563  poly po;
1564  BOOLEAN res=TRUE;
1565  for(i=IDELEMS(I)-1;i>=0;i--)
1566  {
1567  po=I->m[i];
1568  if ((po!=NULL) &&((n=p_IsPurePower(po,r))!=0)) UsedAxis[n-1]=TRUE;
1569  }
1570  for(i=rVar(r)-1;i>=0;i--)
1571  {
1572  if(UsedAxis[i]==FALSE) {res=FALSE; break;} // not zero-dim.
1573  }
1574  omFreeSize(UsedAxis,rVar(r)*sizeof(BOOLEAN));
1575  return res;
1576 }
1577 
1578 void id_Normalize(ideal I,const ring r) /* for ideal/matrix */
1579 {
1580  if (rField_has_simple_inverse(r)) return; /* Z/p, GF(p,n), R, long R/C */
1581  int i;
1582  for(i=I->nrows*I->ncols-1;i>=0;i--)
1583  {
1584  p_Normalize(I->m[i],r);
1585  }
1586 }
1587 
1588 int id_MinDegW(ideal M,intvec *w, const ring r)
1589 {
1590  int d=-1;
1591  for(int i=0;i<IDELEMS(M);i++)
1592  {
1593  if (M->m[i]!=NULL)
1594  {
1595  int d0=p_MinDeg(M->m[i],w,r);
1596  if(-1<d0&&((d0<d)||(d==-1)))
1597  d=d0;
1598  }
1599  }
1600  return d;
1601 }
1602 
1603 // #include <kernel/clapsing.h>
1604 
1605 /*2
1606 * transpose a module
1607 */
1608 ideal id_Transp(ideal a, const ring rRing)
1609 {
1610  int r = a->rank, c = IDELEMS(a);
1611  ideal b = idInit(r,c);
1612 
1613  int i;
1614  for (i=c; i>0; i--)
1615  {
1616  poly p=a->m[i-1];
1617  while(p!=NULL)
1618  {
1619  poly h=p_Head(p, rRing);
1620  int co=p_GetComp(h, rRing)-1;
1621  p_SetComp(h, i, rRing);
1622  p_Setm(h, rRing);
1623  h->next=b->m[co];
1624  b->m[co]=h;
1625  pIter(p);
1626  }
1627  }
1628  for (i=IDELEMS(b)-1; i>=0; i--)
1629  {
1630  poly p=b->m[i];
1631  if(p!=NULL)
1632  {
1633  b->m[i]=p_SortMerge(p,rRing,TRUE);
1634  }
1635  }
1636  return b;
1637 }
1638 
1639 /*2
1640 * The following is needed to compute the image of certain map used in
1641 * the computation of cohomologies via BGG
1642 * let M = { w_1, ..., w_k }, k = size(M) == ncols(M), n = nvars(currRing).
1643 * assuming that nrows(M) <= m*n; the procedure computes:
1644 * transpose(M) * transpose( var(1) I_m | ... | var(n) I_m ) :== transpose(module{f_1, ... f_k}),
1645 * where f_i = \sum_{j=1}^{m} (w_i, v_j) gen(j), (w_i, v_j) is a `scalar` multiplication.
1646 * that is, if w_i = (a^1_1, ... a^1_m) | (a^2_1, ..., a^2_m) | ... | (a^n_1, ..., a^n_m) then
1647 
1648  (a^1_1, ... a^1_m) | (a^2_1, ..., a^2_m) | ... | (a^n_1, ..., a^n_m)
1649 * var_1 ... var_1 | var_2 ... var_2 | ... | var_n ... var(n)
1650 * gen_1 ... gen_m | gen_1 ... gen_m | ... | gen_1 ... gen_m
1651 + =>
1652  f_i =
1653 
1654  a^1_1 * var(1) * gen(1) + ... + a^1_m * var(1) * gen(m) +
1655  a^2_1 * var(2) * gen(1) + ... + a^2_m * var(2) * gen(m) +
1656  ...
1657  a^n_1 * var(n) * gen(1) + ... + a^n_m * var(n) * gen(m);
1658 
1659  NOTE: for every f_i we run only ONCE along w_i saving partial sums into a temporary array of polys of size m
1660 */
1661 ideal id_TensorModuleMult(const int m, const ideal M, const ring rRing)
1662 {
1663 // #ifdef DEBU
1664 // WarnS("tensorModuleMult!!!!");
1665 
1666  assume(m > 0);
1667  assume(M != NULL);
1668 
1669  const int n = rRing->N;
1670 
1671  assume(M->rank <= m * n);
1672 
1673  const int k = IDELEMS(M);
1674 
1675  ideal idTemp = idInit(k,m); // = {f_1, ..., f_k }
1676 
1677  for( int i = 0; i < k; i++ ) // for every w \in M
1678  {
1679  poly pTempSum = NULL;
1680 
1681  poly w = M->m[i];
1682 
1683  while(w != NULL) // for each term of w...
1684  {
1685  poly h = p_Head(w, rRing);
1686 
1687  const int gen = p_GetComp(h, rRing); // 1 ...
1688 
1689  assume(gen > 0);
1690  assume(gen <= n*m);
1691 
1692  // TODO: write a formula with %, / instead of while!
1693  /*
1694  int c = gen;
1695  int v = 1;
1696  while(c > m)
1697  {
1698  c -= m;
1699  v++;
1700  }
1701  */
1702 
1703  int cc = gen % m;
1704  if( cc == 0) cc = m;
1705  int vv = 1 + (gen - cc) / m;
1706 
1707 // assume( cc == c );
1708 // assume( vv == v );
1709 
1710  // 1<= c <= m
1711  assume( cc > 0 );
1712  assume( cc <= m );
1713 
1714  assume( vv > 0 );
1715  assume( vv <= n );
1716 
1717  assume( (cc + (vv-1)*m) == gen );
1718 
1719  p_IncrExp(h, vv, rRing); // h *= var(j) && // p_AddExp(h, vv, 1, rRing);
1720  p_SetComp(h, cc, rRing);
1721 
1722  p_Setm(h, rRing); // addjust degree after the previous steps!
1723 
1724  pTempSum = p_Add_q(pTempSum, h, rRing); // it is slow since h will be usually put to the back of pTempSum!!!
1725 
1726  pIter(w);
1727  }
1728 
1729  idTemp->m[i] = pTempSum;
1730  }
1731 
1732  // simplify idTemp???
1733 
1734  ideal idResult = id_Transp(idTemp, rRing);
1735 
1736  id_Delete(&idTemp, rRing);
1737 
1738  return(idResult);
1739 }
1740 
1741 ideal id_ChineseRemainder(ideal *xx, number *q, int rl, const ring r)
1742 {
1743  int cnt=0;int rw=0; int cl=0;
1744  int i,j;
1745  // find max. size of xx[.]:
1746  for(j=rl-1;j>=0;j--)
1747  {
1748  i=IDELEMS(xx[j])*xx[j]->nrows;
1749  if (i>cnt) cnt=i;
1750  if (xx[j]->nrows >rw) rw=xx[j]->nrows; // for lifting matrices
1751  if (xx[j]->ncols >cl) cl=xx[j]->ncols; // for lifting matrices
1752  }
1753  if (rw*cl !=cnt)
1754  {
1755  WerrorS("format mismatch in CRT");
1756  return NULL;
1757  }
1758  ideal result=idInit(cnt,xx[0]->rank);
1759  result->nrows=rw; // for lifting matrices
1760  result->ncols=cl; // for lifting matrices
1761  number *x=(number *)omAlloc(rl*sizeof(number));
1762  poly *p=(poly *)omAlloc(rl*sizeof(poly));
1763  CFArray inv_cache(rl);
1764  for(i=cnt-1;i>=0;i--)
1765  {
1766  for(j=rl-1;j>=0;j--)
1767  {
1768  if(i>=IDELEMS(xx[j])*xx[j]->nrows) // out of range of this ideal
1769  p[j]=NULL;
1770  else
1771  p[j]=xx[j]->m[i];
1772  }
1773  result->m[i]=p_ChineseRemainder(p,x,q,rl,inv_cache,r);
1774  for(j=rl-1;j>=0;j--)
1775  {
1776  if(i<IDELEMS(xx[j])*xx[j]->nrows) xx[j]->m[i]=p[j];
1777  }
1778  }
1779  omFreeSize(p,rl*sizeof(poly));
1780  omFreeSize(x,rl*sizeof(number));
1781  for(i=rl-1;i>=0;i--) id_Delete(&(xx[i]),r);
1782  omFreeSize(xx,rl*sizeof(ideal));
1783  return result;
1784 }
1785 
1786 void id_Shift(ideal M, int s, const ring r)
1787 {
1788 // id_Test( M, r );
1789 
1790 // assume( s >= 0 ); // negative is also possible // TODO: verify input ideal in such a case!?
1791 
1792  for(int i=IDELEMS(M)-1; i>=0;i--)
1793  p_Shift(&(M->m[i]),s,r);
1794 
1795  M->rank += s;
1796 
1797 // id_Test( M, r );
1798 }
static FORCE_INLINE number n_Sub(number a, number b, const coeffs r)
return the difference of &#39;a&#39; and &#39;b&#39;, i.e., a-b
Definition: coeffs.h:673
static poly p_SortMerge(poly p, const ring r, BOOLEAN revert=FALSE)
Definition: p_polys.h:1152
int id_PosConstant(ideal id, const ring r)
index of generator with leading term in ground ring (if any); otherwise -1
Definition: simpleideals.cc:83
#define omAllocBin(bin)
Definition: omAllocDecl.h:205
static int p_Comp_RevLex(poly a, poly b, BOOLEAN nolex, const ring R)
for idSort: compare a and b revlex inclusive module comp.
#define id_TestTail(A, lR, tR)
Definition: simpleideals.h:79
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
void id_Normalize(ideal I, const ring r)
normialize all polys in id
const CanonicalForm int s
Definition: facAbsFact.cc:55
void id_DelDiv(ideal id, const ring r)
delete id[j], if LT(j) == coeff*mon*LT(i) and vice versa, i.e., delete id[i], if LT(i) == coeff*mon*L...
ideal id_FreeModule(int i, const ring r)
the free module of rank i
BOOLEAN idInsertPoly(ideal h1, poly h2)
insert h2 into h1 (if h2 is not the zero polynomial) return TRUE iff h2 was indeed inserted ...
ideal id_Transp(ideal a, const ring rRing)
transpose a module
#define omCheckAddrSize(addr, size)
Definition: omAllocDecl.h:327
ideal id_Homogen(ideal h, int varnum, const ring r)
#define pSetm(p)
Definition: polys.h:253
static BOOLEAN p_LmIsConstantComp(const poly p, const ring r)
Definition: p_polys.h:932
static FORCE_INLINE BOOLEAN n_IsUnit(number n, const coeffs r)
TRUE iff n has a multiplicative inverse in the given coeff field/ring r.
Definition: coeffs.h:519
static gmp_float * diff
Definition: mpr_complex.cc:47
const poly a
Definition: syzextra.cc:212
int level(const CanonicalForm &f)
omBin_t * omBin
Definition: omStructs.h:12
void PrintLn()
Definition: reporter.cc:310
#define Print
Definition: emacs.cc:83
CF_NO_INLINE CanonicalForm mod(const CanonicalForm &, const CanonicalForm &)
Definition: cf_inline.cc:564
ideal id_Copy(ideal h1, const ring r)
copy an ideal
ideal id_Subst(ideal id, int n, poly e, const ring r)
BOOLEAN p_ComparePolys(poly p1, poly p2, const ring r)
returns TRUE if p1 is a skalar multiple of p2 assume p1 != NULL and p2 != NULL
Definition: p_polys.cc:4431
BEGIN_NAMESPACE_SINGULARXX const ring lmRing
Definition: DebugPrint.h:30
#define FALSE
Definition: auxiliary.h:94
poly p_Homogen(poly p, int varnum, const ring r)
Definition: p_polys.cc:3200
return P p
Definition: myNF.cc:203
short * iv2array(intvec *iv, const ring R)
Definition: weight.cc:208
void id_ShallowDelete(ideal *h, ring r)
Shallowdeletes an ideal/matrix.
BOOLEAN p_IsHomogeneous(poly p, const ring r)
Definition: p_polys.cc:3249
omBin sip_sideal_bin
Definition: simpleideals.cc:30
static long p_IncrExp(poly p, int v, ring r)
Definition: p_polys.h:586
int idGetNumberOfChoise(int t, int d, int begin, int end, int *choise)
int p_MinDeg(poly p, intvec *w, const ring R)
Definition: p_polys.cc:4303
#define id_Test(A, lR)
Definition: simpleideals.h:80
short * ecartWeights
Definition: weight0.c:28
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition: p_polys.h:242
ideal id_ChineseRemainder(ideal *xx, number *q, int rl, const ring r)
BOOLEAN id_HomModule(ideal m, ideal Q, intvec **w, const ring R)
#define p_GetComp(p, r)
Definition: monomials.h:72
BOOLEAN id_HomIdeal(ideal id, ideal Q, const ring r)
cl
Definition: cfModGcd.cc:4041
void id_DBTest(ideal h1, int level, const char *f, const int l, const ring r, const ring tailRing)
Internal verification for ideals/modules and dense matrices!
BEGIN_NAMESPACE_SINGULARXX const ring const ring tailRing
Definition: DebugPrint.h:30
void id_Norm(ideal id, const ring r)
ideal id = (id[i]), result is leadcoeff(id[i]) = 1
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
static BOOLEAN p_IsUnit(const poly p, const ring r)
Definition: p_polys.h:1903
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:583
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
intvec * id_QHomWeight(ideal id, const ring r)
#define TRUE
Definition: auxiliary.h:98
BOOLEAN id_IsConstant(ideal id, const ring r)
test if the ideal has only constant polynomials NOTE: zero ideal/module is also constant ...
BOOLEAN id_InsertPolyWithTests(ideal h1, const int validEntries, const poly h2, const bool zeroOk, const bool duplicateOk, const ring r)
insert h2 into h1 depending on the two boolean parameters:
static long p_Totaldegree(poly p, const ring r)
Definition: p_polys.h:1430
BOOLEAN _pp_Test(poly p, ring lmRing, ring tailRing, int level)
Definition: pDebug.cc:332
void * ADDRESS
Definition: auxiliary.h:115
BOOLEAN idInsertPolyOnPos(ideal I, poly p, int pos)
insert p into I on position pos
poly p_Subst(poly p, int n, poly e, const ring r)
Definition: p_polys.cc:3822
void WerrorS(const char *s)
Definition: feFopen.cc:24
int k
Definition: cfEzgcd.cc:93
void p_ShallowDelete(poly *p, const ring r)
ideal id_TensorModuleMult(const int m, const ideal M, const ring rRing)
void p_Norm(poly p1, const ring r)
Definition: p_polys.cc:3627
#define Q
Definition: sirandom.c:25
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
Definition: monomials.h:51
#define WarnS
Definition: emacs.cc:81
#define omAlloc(size)
Definition: omAllocDecl.h:210
ideal id_MaxIdeal(const ring r)
initialise the maximal ideal (at 0)
#define pGetComp(p)
Component.
Definition: polys.h:37
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:804
poly pp
Definition: myNF.cc:296
void idShow(const ideal id, const ring lmRing, const ring tailRing, const int debugPrint)
Definition: simpleideals.cc:60
ideal id_JetW(ideal i, int d, intvec *iv, const ring R)
static BOOLEAN rField_has_simple_inverse(const ring r)
Definition: ring.h:540
int comp(const CanonicalForm &A, const CanonicalForm &B)
compare polynomials
#define pIter(p)
Definition: monomials.h:44
poly pp_JetW(poly p, int m, short *w, const ring R)
Definition: p_polys.cc:4258
poly res
Definition: myNF.cc:322
static long p_GetExpDiff(poly p1, poly p2, int i, ring r)
Definition: p_polys.h:630
#define M
Definition: sirandom.c:24
void omPrintAddrInfo(FILE *fd, void *addr, const char *s)
Definition: omDebugCheck.c:445
poly * m
Definition: matpol.h:19
void id_Shift(ideal M, int s, const ring r)
static poly p_Head(poly p, const ring r)
Definition: p_polys.h:812
fq_nmod_poly_t * vec
Definition: facHensel.cc:103
const ring r
Definition: syzextra.cc:208
static void p_SetCompP(poly p, int i, ring r)
Definition: p_polys.h:249
static int idpowerpoint
Definition: simpleideals.cc:34
Definition: intvec.h:14
void id_DelMultiples(ideal id, const ring r)
ideal id = (id[i]), c any unit if id[i] = c*id[j] then id[j] is deleted for j > i ...
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
void id_DelLmEquals(ideal id, const ring r)
Delete id[j], if Lm(j) == Lm(i) and both LC(j), LC(i) are units and j > i.
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:49
poly p_One(const ring r)
Definition: p_polys.cc:1314
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:464
void sBucket_Merge_p(sBucket_pt bucket, poly p, int length)
Merges p into Spoly: assumes Bpoly and p have no common monoms destroys p!
Definition: sbuckets.cc:176
int j
Definition: myNF.cc:70
#define omFree(addr)
Definition: omAllocDecl.h:261
void ivTriangIntern(intvec *imat, int &ready, int &all)
Definition: intvec.cc:387
#define assume(x)
Definition: mod2.h:394
void sBucketDestroy(sBucket_pt *bucket)
Definition: sbuckets.cc:127
static poly pp_Mult_qq(poly p, poly q, const ring r)
Definition: p_polys.h:1070
int nrows
Definition: cf_linsys.cc:32
void p_Vec2Polys(poly v, poly **p, int *len, const ring r)
Definition: p_polys.cc:3521
#define pp_Test(p, lmRing, tailRing)
Definition: p_polys.h:162
sBucket_pt sBucketCreate(const ring r)
Definition: sbuckets.cc:120
const ring R
Definition: DebugPrint.cc:36
void id_DelEquals(ideal id, const ring r)
ideal id = (id[i]) if id[i] = id[j] then id[j] is deleted for j > i
intvec * id_Sort(const ideal id, const BOOLEAN nolex, const ring r)
sorts the ideal w.r.t. the actual ringordering uses lex-ordering when nolex = FALSE ...
ideal id_Power(ideal given, int exp, const ring r)
static BOOLEAN p_DivisibleBy(poly a, poly b, const ring r)
Definition: p_polys.h:1777
P bucket
Definition: myNF.cc:79
All the auxiliary stuff.
#define pSetComp(p, v)
Definition: polys.h:38
int m
Definition: cfEzgcd.cc:119
static int si_max(const int a, const int b)
Definition: auxiliary.h:120
FILE * f
Definition: checklibs.c:9
int i
Definition: cfEzgcd.cc:123
int binom(int n, int r)
void PrintS(const char *s)
Definition: reporter.cc:284
void sBucketClearMerge(sBucket_pt bucket, poly *p, int *length)
Definition: sbuckets.cc:232
void idGetNextChoise(int r, int end, BOOLEAN *endch, int *choise)
rRingOrder_t * order
Definition: ring.h:261
matrix id_Module2Matrix(ideal mod, const ring R)
static unsigned pLength(poly a)
Definition: p_polys.h:189
#define IDELEMS(i)
Definition: simpleideals.h:24
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the zero element.
Definition: coeffs.h:468
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
static poly pReverse(poly p)
Definition: p_polys.h:330
BOOLEAN p_EqualPolys(poly p1, poly p2, const ring r)
Definition: p_polys.cc:4367
#define p_Test(p, r)
Definition: p_polys.h:160
static void makemonoms(int vars, int actvar, int deg, int monomdeg, const ring r)
void p_Shift(poly *p, int i, const ring r)
shifts components of the vector p by i
Definition: p_polys.cc:4561
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:44
void p_Normalize(poly p, const ring r)
Definition: p_polys.cc:3680
#define rRing_has_Comp(r)
Definition: monomials.h:274
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:843
#define omGetSpecBin(size)
Definition: omBin.h:11
#define p_SetmComp
Definition: p_polys.h:239
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
#define p_LmEqual(p1, p2, r)
Definition: p_polys.h:1611
static void id_NextPotence(ideal given, ideal result, int begin, int end, int deg, int restdeg, poly ap, const ring r)
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:483
int p_IsPurePower(const poly p, const ring r)
return i, if head depends only on var(i)
Definition: p_polys.cc:1227
BOOLEAN p_DivisibleByRingCase(poly f, poly g, const ring r)
divisibility check over ground ring (which may contain zero divisors); TRUE iff LT(f) divides LT(g)...
Definition: p_polys.cc:1603
ideal id_Jet(ideal i, int d, const ring R)
The following sip_sideal structure has many different uses thoughout Singular. Basic use-cases for it...
Definition: simpleideals.h:18
#define MATCOLS(i)
Definition: matpol.h:28
static BOOLEAN rField_is_Ring(const ring r)
Definition: ring.h:477
#define NULL
Definition: omList.c:10
CanonicalForm head(const CanonicalForm &f)
matrix id_Module2formatedMatrix(ideal mod, int rows, int cols, const ring R)
void pEnlargeSet(poly **p, int l, int increment)
Definition: p_polys.cc:3602
void idInitChoise(int r, int beg, int end, BOOLEAN *endch, int *choise)
ideal id_Add(ideal h1, ideal h2, const ring r)
h1 + h2
long(* pFDegProc)(poly p, ring r)
Definition: ring.h:46
#define omdebugAddrSize(addr, size)
Definition: omAllocDecl.h:315
int int ncols
Definition: cf_linsys.cc:32
ideal id_Head(ideal h, const ring r)
returns the ideals of initial terms
static poly * idpower
Definition: simpleideals.cc:32
const CanonicalForm & w
Definition: facAbsFact.cc:55
static int p_LtCmp(poly p, poly q, const ring r)
Definition: p_polys.h:1501
poly p_ChineseRemainder(poly *xx, number *x, number *q, int rl, CFArray &inv_cache, const ring R)
Definition: p_polys.cc:94
Variable x
Definition: cfModGcd.cc:4023
static BOOLEAN p_IsConstantPoly(const poly p, const ring r)
Definition: p_polys.h:1890
#define pNext(p)
Definition: monomials.h:43
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:228
BOOLEAN id_IsZeroDim(ideal I, const ring r)
ideal id_CopyFirstK(const ideal ide, const int k, const ring r)
copies the first k (>= 1) entries of the given ideal/module and returns these as a new ideal/module (...
int idElem(const ideal F)
count non-zero elements
int dReportError(const char *fmt,...)
Definition: dError.cc:45
p exp[i]
Definition: DebugPrint.cc:39
int id_ReadOutPivot(ideal arg, int *comp, const ring r)
intvec * ivSolveKern(intvec *imat, int dimtr)
Definition: intvec.cc:425
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:459
void p_wrp(poly p, ring lmRing, ring tailRing)
Definition: polys0.cc:237
poly pp_Jet(poly p, int m, const ring R)
Definition: p_polys.cc:4213
static FORCE_INLINE BOOLEAN n_GreaterZero(number n, const coeffs r)
ordered fields: TRUE iff &#39;n&#39; is positive; in Z/pZ: TRUE iff 0 < m <= roundedBelow(p/2), where m is the long representing n in C: TRUE iff (Im(n) != 0 and Im(n) >= 0) or (Im(n) == 0 and Re(n) >= 0) in K(a)/<p(a)>: TRUE iff (n != 0 and (LC(n) > 0 or deg(n) > 0)) in K(t_1, ..., t_n): TRUE iff (LC(numerator(n) is a constant and > 0) or (LC(numerator(n) is not a constant) in Z/2^kZ: TRUE iff 0 < n <= 2^(k-1) in Z/mZ: TRUE iff the internal mpz is greater than zero in Z: TRUE iff n > 0
Definition: coeffs.h:498
#define MATROWS(i)
Definition: matpol.h:27
int id_MinDegW(ideal M, intvec *w, const ring r)
ideal id_Vec2Ideal(poly vec, const ring R)
kBucketDestroy & P
Definition: myNF.cc:191
polyrec * poly
Definition: hilb.h:10
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:877
#define omFreeBin(addr, bin)
Definition: omAllocDecl.h:259
static Poly * h
Definition: janet.cc:978
int BOOLEAN
Definition: auxiliary.h:85
#define IMATELEM(M, I, J)
Definition: intvec.h:77
const poly b
Definition: syzextra.cc:213
void id_Compactify(ideal id, const ring r)
ideal id_Matrix2Module(matrix mat, const ring R)
ideal id_SimpleAdd(ideal h1, ideal h2, const ring R)
concat the lists h1 and h2 without zeros
static poly p_Mult_q(poly p, poly q, const ring r)
Definition: p_polys.h:1020
poly p_Power(poly p, int i, const ring r)
Definition: p_polys.cc:2158
#define omAlloc0(size)
Definition: omAllocDecl.h:211
return result
Definition: facAbsBiFact.cc:76
int l
Definition: cfEzgcd.cc:94
static long p_MaxComp(poly p, ring lmRing, ring tailRing)
Definition: p_polys.h:287
#define MATELEM(mat, i, j)
Definition: matpol.h:29