My Project  debian-1:4.1.1-p2+ds-4build2
ipshell.cc
Go to the documentation of this file.
1 /****************************************
2 * Computer Algebra System SINGULAR *
3 ****************************************/
4 /*
5 * ABSTRACT:
6 */
7 
8 #include "kernel/mod2.h"
9 
10 #include "omalloc/omalloc.h"
11 
12 #include "factory/factory.h"
13 
14 #include "misc/options.h"
15 #include "misc/mylimits.h"
16 #include "misc/intvec.h"
17 #include "misc/prime.h"
18 
19 #include "coeffs/numbers.h"
20 #include "coeffs/coeffs.h"
21 
22 #include "coeffs/rmodulon.h"
23 #include "coeffs/longrat.h"
24 
25 #include "polys/monomials/ring.h"
26 #include "polys/monomials/maps.h"
27 
28 #include "polys/prCopy.h"
29 #include "polys/matpol.h"
30 
31 #include "polys/weight.h"
32 #include "polys/clapsing.h"
33 
34 
37 
38 #include "kernel/polys.h"
39 #include "kernel/ideals.h"
40 
43 
44 #include "kernel/GBEngine/syz.h"
45 #include "kernel/GBEngine/kstd1.h"
46 #include "kernel/GBEngine/kutil.h" // denominator_list
47 
50 
51 #include "kernel/spectrum/semic.h"
52 #include "kernel/spectrum/splist.h"
54 
56 
57 #include "Singular/lists.h"
58 #include "Singular/attrib.h"
59 #include "Singular/ipconv.h"
60 #include "Singular/links/silink.h"
61 #include "Singular/ipshell.h"
62 #include "Singular/maps_ip.h"
63 #include "Singular/tok.h"
64 #include "Singular/ipid.h"
65 #include "Singular/subexpr.h"
66 #include "Singular/fevoices.h"
67 #include "Singular/sdb.h"
68 
69 #include <cmath>
70 #include <ctype.h>
71 
72 #include "kernel/maps/gen_maps.h"
73 
74 #ifdef SINGULAR_4_2
75 #include "Singular/number2.h"
76 #include "coeffs/bigintmat.h"
77 #endif
80 const char *lastreserved=NULL;
81 
83 
84 /*0 implementation*/
85 
86 const char * iiTwoOps(int t)
87 {
88  if (t<127)
89  {
90  static char ch[2];
91  switch (t)
92  {
93  case '&':
94  return "and";
95  case '|':
96  return "or";
97  default:
98  ch[0]=t;
99  ch[1]='\0';
100  return ch;
101  }
102  }
103  switch (t)
104  {
105  case COLONCOLON: return "::";
106  case DOTDOT: return "..";
107  //case PLUSEQUAL: return "+=";
108  //case MINUSEQUAL: return "-=";
109  case MINUSMINUS: return "--";
110  case PLUSPLUS: return "++";
111  case EQUAL_EQUAL: return "==";
112  case LE: return "<=";
113  case GE: return ">=";
114  case NOTEQUAL: return "<>";
115  default: return Tok2Cmdname(t);
116  }
117 }
118 
119 int iiOpsTwoChar(const char *s)
120 {
121 /* not handling: &&, ||, ** */
122  if (s[1]=='\0') return s[0];
123  else if (s[2]!='\0') return 0;
124  switch(s[0])
125  {
126  case '.': if (s[1]=='.') return DOTDOT;
127  else return 0;
128  case ':': if (s[1]==':') return COLONCOLON;
129  else return 0;
130  case '-': if (s[1]=='-') return MINUSMINUS;
131  else return 0;
132  case '+': if (s[1]=='+') return PLUSPLUS;
133  else return 0;
134  case '=': if (s[1]=='=') return EQUAL_EQUAL;
135  else return 0;
136  case '<': if (s[1]=='=') return LE;
137  else if (s[1]=='>') return NOTEQUAL;
138  else return 0;
139  case '>': if (s[1]=='=') return GE;
140  else return 0;
141  case '!': if (s[1]=='=') return NOTEQUAL;
142  else return 0;
143  }
144  return 0;
145 }
146 
147 static void list1(const char* s, idhdl h,BOOLEAN c, BOOLEAN fullname)
148 {
149  char buffer[22];
150  int l;
151  char buf2[128];
152 
153  if(fullname) sprintf(buf2, "%s::%s", "", IDID(h));
154  else sprintf(buf2, "%s", IDID(h));
155 
156  Print("%s%-30.30s [%d] ",s,buf2,IDLEV(h));
157  if (h == currRingHdl) PrintS("*");
158  PrintS(Tok2Cmdname((int)IDTYP(h)));
159 
160  ipListFlag(h);
161  switch(IDTYP(h))
162  {
163  case ALIAS_CMD: Print(" for %s",IDID((idhdl)IDDATA(h))); break;
164  case INT_CMD: Print(" %d",IDINT(h)); break;
165  case INTVEC_CMD:Print(" (%d)",IDINTVEC(h)->length()); break;
166  case INTMAT_CMD:Print(" %d x %d",IDINTVEC(h)->rows(),IDINTVEC(h)->cols());
167  break;
168  case POLY_CMD:
169  case VECTOR_CMD:if (c)
170  {
171  PrintS(" ");wrp(IDPOLY(h));
172  if(IDPOLY(h) != NULL)
173  {
174  Print(", %d monomial(s)",pLength(IDPOLY(h)));
175  }
176  }
177  break;
178  case MODUL_CMD: Print(", rk %d", (int)(IDIDEAL(h)->rank));
179  case IDEAL_CMD: Print(", %u generator(s)",
180  IDELEMS(IDIDEAL(h))); break;
181  case MAP_CMD:
182  Print(" from %s",IDMAP(h)->preimage); break;
183  case MATRIX_CMD:Print(" %u x %u"
184  ,MATROWS(IDMATRIX(h))
185  ,MATCOLS(IDMATRIX(h))
186  );
187  break;
188  case PACKAGE_CMD:
189  paPrint(IDID(h),IDPACKAGE(h));
190  break;
191  case PROC_CMD: if((IDPROC(h)->libname!=NULL)
192  && (strlen(IDPROC(h)->libname)>0))
193  Print(" from %s",IDPROC(h)->libname);
194  if(IDPROC(h)->language==LANG_C)
195  PrintS(" (C)");
196  if(IDPROC(h)->is_static)
197  PrintS(" (static)");
198  break;
199  case STRING_CMD:
200  {
201  char *s;
202  l=strlen(IDSTRING(h));
203  memset(buffer,0,22);
204  strncpy(buffer,IDSTRING(h),si_min(l,20));
205  if ((s=strchr(buffer,'\n'))!=NULL)
206  {
207  *s='\0';
208  }
209  PrintS(" ");
210  PrintS(buffer);
211  if((s!=NULL) ||(l>20))
212  {
213  Print("..., %d char(s)",l);
214  }
215  break;
216  }
217  case LIST_CMD: Print(", size: %d",IDLIST(h)->nr+1);
218  break;
219  case RING_CMD:
220  if ((IDRING(h)==currRing) && (currRingHdl!=h))
221  PrintS("(*)"); /* this is an alias to currRing */
222 #ifdef RDEBUG
224  Print(" <%lx>",(long)(IDRING(h)));
225 #endif
226  break;
227 #ifdef SINGULAR_4_2
228  case CNUMBER_CMD:
229  { number2 n=(number2)IDDATA(h);
230  Print(" (%s)",nCoeffName(n->cf));
231  break;
232  }
233  case CMATRIX_CMD:
234  { bigintmat *b=(bigintmat*)IDDATA(h);
235  Print(" %d x %d (%s)",
236  b->rows(),b->cols(),
237  nCoeffName(b->basecoeffs()));
238  break;
239  }
240 #endif
241  /*default: break;*/
242  }
243  PrintLn();
244 }
245 
247 {
248  BOOLEAN oldShortOut = FALSE;
249 
250  if (currRing != NULL)
251  {
252  oldShortOut = currRing->ShortOut;
253  currRing->ShortOut = 1;
254  }
255  int t=v->Typ();
256  Print("// %s %s ",v->Name(),Tok2Cmdname(t));
257  switch (t)
258  {
259  case MAP_CMD:Print(" from %s\n",((map)(v->Data()))->preimage); break;
260  case INTMAT_CMD: Print(" %d x %d\n",((intvec*)(v->Data()))->rows(),
261  ((intvec*)(v->Data()))->cols()); break;
262  case MATRIX_CMD:Print(" %u x %u\n" ,
263  MATROWS((matrix)(v->Data())),
264  MATCOLS((matrix)(v->Data())));break;
265  case MODUL_CMD: Print(", rk %d\n", (int)(((ideal)(v->Data()))->rank));break;
266  case LIST_CMD: Print(", size %d\n",((lists)(v->Data()))->nr+1); break;
267 
268  case PROC_CMD:
269  case RING_CMD:
270  case IDEAL_CMD: PrintLn(); break;
271 
272  //case INT_CMD:
273  //case STRING_CMD:
274  //case INTVEC_CMD:
275  //case POLY_CMD:
276  //case VECTOR_CMD:
277  //case PACKAGE_CMD:
278 
279  default:
280  break;
281  }
282  v->Print();
283  if (currRing != NULL)
284  currRing->ShortOut = oldShortOut;
285 }
286 
287 static void killlocals0(int v, idhdl * localhdl, const ring r)
288 {
289  idhdl h = *localhdl;
290  while (h!=NULL)
291  {
292  int vv;
293  //Print("consider %s, lev: %d:",IDID(h),IDLEV(h));
294  if ((vv=IDLEV(h))>0)
295  {
296  if (vv < v)
297  {
298  if (iiNoKeepRing)
299  {
300  //PrintS(" break\n");
301  return;
302  }
303  h = IDNEXT(h);
304  //PrintLn();
305  }
306  else //if (vv >= v)
307  {
308  idhdl nexth = IDNEXT(h);
309  killhdl2(h,localhdl,r);
310  h = nexth;
311  //PrintS("kill\n");
312  }
313  }
314  else
315  {
316  h = IDNEXT(h);
317  //PrintLn();
318  }
319  }
320 }
321 
322 void killlocals_rec(idhdl *root,int v, ring r)
323 {
324  idhdl h=*root;
325  while (h!=NULL)
326  {
327  if (IDLEV(h)>=v)
328  {
329 // Print("kill %s, lev %d for lev %d\n",IDID(h),IDLEV(h),v);
330  idhdl n=IDNEXT(h);
331  killhdl2(h,root,r);
332  h=n;
333  }
334  else if (IDTYP(h)==PACKAGE_CMD)
335  {
336  // Print("into pack %s, lev %d for lev %d\n",IDID(h),IDLEV(h),v);
337  if (IDPACKAGE(h)!=basePack)
338  killlocals_rec(&(IDRING(h)->idroot),v,r);
339  h=IDNEXT(h);
340  }
341  else if (IDTYP(h)==RING_CMD)
342  {
343  if ((IDRING(h)!=NULL) && (IDRING(h)->idroot!=NULL))
344  // we have to test IDRING(h)!=NULL: qring Q=groebner(...): killlocals
345  {
346  // Print("into ring %s, lev %d for lev %d\n",IDID(h),IDLEV(h),v);
347  killlocals_rec(&(IDRING(h)->idroot),v,IDRING(h));
348  }
349  h=IDNEXT(h);
350  }
351  else
352  {
353 // Print("skip %s lev %d for lev %d\n",IDID(h),IDLEV(h),v);
354  h=IDNEXT(h);
355  }
356  }
357 }
359 {
360  if (L==NULL) return FALSE;
361  BOOLEAN changed=FALSE;
362  int n=L->nr;
363  for(;n>=0;n--)
364  {
365  leftv h=&(L->m[n]);
366  void *d=h->data;
367  if ((h->rtyp==RING_CMD)
368  && (((ring)d)->idroot!=NULL))
369  {
370  if (d!=currRing) {changed=TRUE;rChangeCurrRing((ring)d);}
371  killlocals0(v,&(((ring)h->data)->idroot),(ring)h->data);
372  }
373  else if (h->rtyp==LIST_CMD)
374  changed|=killlocals_list(v,(lists)d);
375  }
376  return changed;
377 }
378 void killlocals(int v)
379 {
380  BOOLEAN changed=FALSE;
381  idhdl sh=currRingHdl;
382  ring cr=currRing;
383  if (sh!=NULL) changed=((IDLEV(sh)<v) || (IDRING(sh)->ref>0));
384  //if (changed) Print("currRing=%s(%x), lev=%d,ref=%d\n",IDID(sh),IDRING(sh),IDLEV(sh),IDRING(sh)->ref);
385 
386  killlocals_rec(&(basePack->idroot),v,currRing);
387 
389  {
390  int t=iiRETURNEXPR.Typ();
391  if (/*iiRETURNEXPR.Typ()*/ t==RING_CMD)
392  {
394  if (((ring)h->data)->idroot!=NULL)
395  killlocals0(v,&(((ring)h->data)->idroot),(ring)h->data);
396  }
397  else if (/*iiRETURNEXPR.Typ()*/ t==LIST_CMD)
398  {
400  changed |=killlocals_list(v,(lists)h->data);
401  }
402  }
403  if (changed)
404  {
406  if (currRingHdl==NULL)
407  currRing=NULL;
408  else if(cr!=currRing)
409  rChangeCurrRing(cr);
410  }
411 
412  if (myynest<=1) iiNoKeepRing=TRUE;
413  //Print("end killlocals >= %d\n",v);
414  //listall();
415 }
416 
417 void list_cmd(int typ, const char* what, const char *prefix,BOOLEAN iterate, BOOLEAN fullname)
418 {
419  package savePack=currPack;
420  idhdl h,start;
421  BOOLEAN all = typ<0;
422  BOOLEAN really_all=FALSE;
423 
424  if ( typ==0 )
425  {
426  if (strcmp(what,"all")==0)
427  {
428  if (currPack!=basePack)
429  list_cmd(-1,NULL,prefix,iterate,fullname); // list current package
430  really_all=TRUE;
431  h=basePack->idroot;
432  }
433  else
434  {
435  h = ggetid(what);
436  if (h!=NULL)
437  {
438  if (iterate) list1(prefix,h,TRUE,fullname);
439  if (IDTYP(h)==ALIAS_CMD) PrintS("A");
440  if ((IDTYP(h)==RING_CMD)
441  //|| (IDTYP(h)==PACKAGE_CMD)
442  )
443  {
444  h=IDRING(h)->idroot;
445  }
446  else if(IDTYP(h)==PACKAGE_CMD)
447  {
449  //Print("list_cmd:package\n");
450  all=TRUE;typ=PROC_CMD;fullname=TRUE;really_all=TRUE;
451  h=IDPACKAGE(h)->idroot;
452  }
453  else
454  {
455  currPack=savePack;
456  return;
457  }
458  }
459  else
460  {
461  Werror("%s is undefined",what);
462  currPack=savePack;
463  return;
464  }
465  }
466  all=TRUE;
467  }
468  else if (RingDependend(typ))
469  {
470  h = currRing->idroot;
471  }
472  else
473  h = IDROOT;
474  start=h;
475  while (h!=NULL)
476  {
477  if ((all
478  && (IDTYP(h)!=PROC_CMD)
479  &&(IDTYP(h)!=PACKAGE_CMD)
480  &&(IDTYP(h)!=CRING_CMD)
481  )
482  || (typ == IDTYP(h))
483  || ((IDTYP(h)==CRING_CMD) && (typ==RING_CMD))
484  )
485  {
486  list1(prefix,h,start==currRingHdl, fullname);
487  if ((IDTYP(h)==RING_CMD)
488  && (really_all || (all && (h==currRingHdl)))
489  && ((IDLEV(h)==0)||(IDLEV(h)==myynest)))
490  {
491  list_cmd(0,IDID(h),"// ",FALSE);
492  }
493  if (IDTYP(h)==PACKAGE_CMD && really_all)
494  {
495  package save_p=currPack;
497  list_cmd(0,IDID(h),"// ",FALSE);
498  currPack=save_p;
499  }
500  }
501  h = IDNEXT(h);
502  }
503  currPack=savePack;
504 }
505 
506 void test_cmd(int i)
507 {
508  int ii;
509 
510  if (i<0)
511  {
512  ii= -i;
513  if (ii < 32)
514  {
515  si_opt_1 &= ~Sy_bit(ii);
516  }
517  else if (ii < 64)
518  {
519  si_opt_2 &= ~Sy_bit(ii-32);
520  }
521  else
522  WerrorS("out of bounds\n");
523  }
524  else if (i<32)
525  {
526  ii=i;
527  if (Sy_bit(ii) & kOptions)
528  {
529  WarnS("Gerhard, use the option command");
530  si_opt_1 |= Sy_bit(ii);
531  }
532  else if (Sy_bit(ii) & validOpts)
533  si_opt_1 |= Sy_bit(ii);
534  }
535  else if (i<64)
536  {
537  ii=i-32;
538  si_opt_2 |= Sy_bit(ii);
539  }
540  else
541  WerrorS("out of bounds\n");
542 }
543 
545 {
546  int rc = 0;
547  while (v!=NULL)
548  {
549  switch (v->Typ())
550  {
551  case INT_CMD:
552  case POLY_CMD:
553  case VECTOR_CMD:
554  case NUMBER_CMD:
555  rc++;
556  break;
557  case INTVEC_CMD:
558  case INTMAT_CMD:
559  rc += ((intvec *)(v->Data()))->length();
560  break;
561  case MATRIX_CMD:
562  case IDEAL_CMD:
563  case MODUL_CMD:
564  {
565  matrix mm = (matrix)(v->Data());
566  rc += mm->rows() * mm->cols();
567  }
568  break;
569  case LIST_CMD:
570  rc+=((lists)v->Data())->nr+1;
571  break;
572  default:
573  rc++;
574  }
575  v = v->next;
576  }
577  return rc;
578 }
579 
581 {
582  sleftv vf;
583  if (iiConvert(v->Typ(),LINK_CMD,iiTestConvert(v->Typ(),LINK_CMD),v,&vf))
584  {
585  WerrorS("link expected");
586  return TRUE;
587  }
588  si_link l=(si_link)vf.Data();
589  if (vf.next == NULL)
590  {
591  WerrorS("write: need at least two arguments");
592  return TRUE;
593  }
594 
595  BOOLEAN b=slWrite(l,vf.next); /* iiConvert preserves next */
596  if (b)
597  {
598  const char *s;
599  if ((l!=NULL)&&(l->name!=NULL)) s=l->name;
600  else s=sNoName_fe;
601  Werror("cannot write to %s",s);
602  }
603  vf.CleanUp();
604  return b;
605 }
606 
607 leftv iiMap(map theMap, const char * what)
608 {
609  idhdl w,r;
610  leftv v;
611  int i;
612  nMapFunc nMap;
613 
614  r=IDROOT->get(theMap->preimage,myynest);
615  if ((currPack!=basePack)
616  &&((r==NULL) || ((r->typ != RING_CMD) )))
617  r=basePack->idroot->get(theMap->preimage,myynest);
618  if ((r==NULL) && (currRingHdl!=NULL)
619  && (strcmp(theMap->preimage,IDID(currRingHdl))==0))
620  {
621  r=currRingHdl;
622  }
623  if ((r!=NULL) && (r->typ == RING_CMD))
624  {
625  ring src_ring=IDRING(r);
626  if ((nMap=n_SetMap(src_ring->cf, currRing->cf))==NULL)
627  {
628  Werror("can not map from ground field of %s to current ground field",
629  theMap->preimage);
630  return NULL;
631  }
632  if (IDELEMS(theMap)<src_ring->N)
633  {
634  theMap->m=(polyset)omReallocSize((ADDRESS)theMap->m,
635  IDELEMS(theMap)*sizeof(poly),
636  (src_ring->N)*sizeof(poly));
637  for(i=IDELEMS(theMap);i<src_ring->N;i++)
638  theMap->m[i]=NULL;
639  IDELEMS(theMap)=src_ring->N;
640  }
641  if (what==NULL)
642  {
643  WerrorS("argument of a map must have a name");
644  }
645  else if ((w=src_ring->idroot->get(what,myynest))!=NULL)
646  {
647  char *save_r=NULL;
649  sleftv tmpW;
650  memset(&tmpW,0,sizeof(sleftv));
651  tmpW.rtyp=IDTYP(w);
652  if (tmpW.rtyp==MAP_CMD)
653  {
654  tmpW.rtyp=IDEAL_CMD;
655  save_r=IDMAP(w)->preimage;
656  IDMAP(w)->preimage=0;
657  }
658  tmpW.data=IDDATA(w);
659  // check overflow
660  BOOLEAN overflow=FALSE;
661  if ((tmpW.rtyp==IDEAL_CMD)
662  || (tmpW.rtyp==MODUL_CMD)
663  || (tmpW.rtyp==MAP_CMD))
664  {
665  ideal id=(ideal)tmpW.data;
666  long *degs=(long*)omAlloc(IDELEMS(id)*sizeof(long));
667  for(int i=IDELEMS(id)-1;i>=0;i--)
668  {
669  poly p=id->m[i];
670  if (p!=NULL) degs[i]=p_Totaldegree(p,src_ring);
671  else degs[i]=0;
672  }
673  for(int j=IDELEMS(theMap)-1;j>=0 && !overflow;j--)
674  {
675  if (theMap->m[j]!=NULL)
676  {
677  long deg_monexp=pTotaldegree(theMap->m[j]);
678 
679  for(int i=IDELEMS(id)-1;i>=0;i--)
680  {
681  poly p=id->m[i];
682  if ((p!=NULL) && (degs[i]!=0) &&
683  ((unsigned long)deg_monexp > (currRing->bitmask / ((unsigned long)degs[i])/2)))
684  {
685  overflow=TRUE;
686  break;
687  }
688  }
689  }
690  }
691  omFreeSize(degs,IDELEMS(id)*sizeof(long));
692  }
693  else if (tmpW.rtyp==POLY_CMD)
694  {
695  for(int j=IDELEMS(theMap)-1;j>=0 && !overflow;j--)
696  {
697  if (theMap->m[j]!=NULL)
698  {
699  long deg_monexp=pTotaldegree(theMap->m[j]);
700  poly p=(poly)tmpW.data;
701  long deg=0;
702  if ((p!=NULL) && ((deg=p_Totaldegree(p,src_ring))!=0) &&
703  ((unsigned long)deg_monexp > (currRing->bitmask / ((unsigned long)deg)/2)))
704  {
705  overflow=TRUE;
706  break;
707  }
708  }
709  }
710  }
711  if (overflow)
712  Warn("possible OVERFLOW in map, max exponent is %ld",currRing->bitmask/2);
713 #if 0
714  if (((tmpW.rtyp==IDEAL_CMD)||(tmpW.rtyp==MODUL_CMD)) && idIs0(IDIDEAL(w)))
715  {
716  v->rtyp=tmpW.rtyp;
717  v->data=idInit(IDELEMS(IDIDEAL(w)),IDIDEAL(w)->rank);
718  }
719  else
720 #endif
721  {
722  if ((tmpW.rtyp==IDEAL_CMD)
723  ||(tmpW.rtyp==MODUL_CMD)
724  ||(tmpW.rtyp==MATRIX_CMD)
725  ||(tmpW.rtyp==MAP_CMD))
726  {
727  v->rtyp=tmpW.rtyp;
728  char *tmp = theMap->preimage;
729  theMap->preimage=(char*)1L;
730  // map gets 1 as its rank (as an ideal)
731  v->data=maMapIdeal(IDIDEAL(w), src_ring, (ideal)theMap, currRing,nMap);
732  theMap->preimage=tmp; // map gets its preimage back
733  }
734  if (v->data==NULL) /*i.e. not IDEAL_CMD/MODUL_CMD/MATRIX_CMD/MAP */
735  {
736  if (maApplyFetch(MAP_CMD,theMap,v,&tmpW,src_ring,NULL,NULL,0,nMap))
737  {
738  Werror("cannot map %s(%d)",Tok2Cmdname(w->typ),w->typ);
740  if (save_r!=NULL) IDMAP(w)->preimage=save_r;
741  return NULL;
742  }
743  }
744  }
745  if (save_r!=NULL)
746  {
747  IDMAP(w)->preimage=save_r;
748  IDMAP((idhdl)v)->preimage=omStrDup(save_r);
749  v->rtyp=MAP_CMD;
750  }
751  return v;
752  }
753  else
754  {
755  Werror("%s undefined in %s",what,theMap->preimage);
756  }
757  }
758  else
759  {
760  Werror("cannot find preimage %s",theMap->preimage);
761  }
762  return NULL;
763 }
764 
765 #ifdef OLD_RES
766 void iiMakeResolv(resolvente r, int length, int rlen, char * name, int typ0,
767  intvec ** weights)
768 {
769  lists L=liMakeResolv(r,length,rlen,typ0,weights);
770  int i=0;
771  idhdl h;
772  char * s=(char *)omAlloc(strlen(name)+5);
773 
774  while (i<=L->nr)
775  {
776  sprintf(s,"%s(%d)",name,i+1);
777  if (i==0)
778  h=enterid(s,myynest,typ0,&(currRing->idroot), FALSE);
779  else
780  h=enterid(s,myynest,MODUL_CMD,&(currRing->idroot), FALSE);
781  if (h!=NULL)
782  {
783  h->data.uideal=(ideal)L->m[i].data;
784  h->attribute=L->m[i].attribute;
786  Print("//defining: %s as %d-th syzygy module\n",s,i+1);
787  }
788  else
789  {
790  idDelete((ideal *)&(L->m[i].data));
791  Warn("cannot define %s",s);
792  }
793  //L->m[i].data=NULL;
794  //L->m[i].rtyp=0;
795  //L->m[i].attribute=NULL;
796  i++;
797  }
798  omFreeSize((ADDRESS)L->m,(L->nr+1)*sizeof(sleftv));
800  omFreeSize((ADDRESS)s,strlen(name)+5);
801 }
802 #endif
803 
804 //resolvente iiFindRes(char * name, int * len, int *typ0)
805 //{
806 // char *s=(char *)omAlloc(strlen(name)+5);
807 // int i=-1;
808 // resolvente r;
809 // idhdl h;
810 //
811 // do
812 // {
813 // i++;
814 // sprintf(s,"%s(%d)",name,i+1);
815 // h=currRing->idroot->get(s,myynest);
816 // } while (h!=NULL);
817 // *len=i-1;
818 // if (*len<=0)
819 // {
820 // Werror("no objects %s(1),.. found",name);
821 // omFreeSize((ADDRESS)s,strlen(name)+5);
822 // return NULL;
823 // }
824 // r=(ideal *)omAlloc(/*(len+1)*/ i*sizeof(ideal));
825 // memset(r,0,(*len)*sizeof(ideal));
826 // i=-1;
827 // *typ0=MODUL_CMD;
828 // while (i<(*len))
829 // {
830 // i++;
831 // sprintf(s,"%s(%d)",name,i+1);
832 // h=currRing->idroot->get(s,myynest);
833 // if (h->typ != MODUL_CMD)
834 // {
835 // if ((i!=0) || (h->typ!=IDEAL_CMD))
836 // {
837 // Werror("%s is not of type module",s);
838 // omFreeSize((ADDRESS)r,(*len)*sizeof(ideal));
839 // omFreeSize((ADDRESS)s,strlen(name)+5);
840 // return NULL;
841 // }
842 // *typ0=IDEAL_CMD;
843 // }
844 // if ((i>0) && (idIs0(r[i-1])))
845 // {
846 // *len=i-1;
847 // break;
848 // }
849 // r[i]=IDIDEAL(h);
850 // }
851 // omFreeSize((ADDRESS)s,strlen(name)+5);
852 // return r;
853 //}
854 
856 {
857  int i;
858  resolvente res=(ideal *)omAlloc0((l+1)*sizeof(ideal));
859 
860  for (i=0; i<l; i++)
861  if (r[i]!=NULL) res[i]=idCopy(r[i]);
862  return res;
863 }
864 
866 {
867  int len=0;
868  int typ0;
869  lists L=(lists)v->Data();
870  intvec *weights=(intvec*)atGet(v,"isHomog",INTVEC_CMD);
871  int add_row_shift = 0;
872  if (weights==NULL)
873  weights=(intvec*)atGet(&(L->m[0]),"isHomog",INTVEC_CMD);
874  if (weights!=NULL) add_row_shift=weights->min_in();
875  resolvente rr=liFindRes(L,&len,&typ0);
876  if (rr==NULL) return TRUE;
877  resolvente r=iiCopyRes(rr,len);
878 
879  syMinimizeResolvente(r,len,0);
880  omFreeSize((ADDRESS)rr,len*sizeof(ideal));
881  len++;
882  res->data=(char *)liMakeResolv(r,len,-1,typ0,NULL,add_row_shift);
883  return FALSE;
884 }
885 
887 {
888  sleftv tmp;
889  memset(&tmp,0,sizeof(tmp));
890  tmp.rtyp=INT_CMD;
891  tmp.data=(void *)1;
892  if ((u->Typ()==IDEAL_CMD)
893  || (u->Typ()==MODUL_CMD))
894  return jjBETTI2_ID(res,u,&tmp);
895  else
896  return jjBETTI2(res,u,&tmp);
897 }
898 
900 {
902  l->Init(1);
903  l->m[0].rtyp=u->Typ();
904  l->m[0].data=u->Data();
905  attr *a=u->Attribute();
906  if (a!=NULL)
907  l->m[0].attribute=*a;
908  sleftv tmp2;
909  memset(&tmp2,0,sizeof(tmp2));
910  tmp2.rtyp=LIST_CMD;
911  tmp2.data=(void *)l;
912  BOOLEAN r=jjBETTI2(res,&tmp2,v);
913  l->m[0].data=NULL;
914  l->m[0].attribute=NULL;
915  l->m[0].rtyp=DEF_CMD;
916  l->Clean();
917  return r;
918 }
919 
921 {
922  resolvente r;
923  int len;
924  int reg,typ0;
925  lists l=(lists)u->Data();
926 
927  intvec *weights=NULL;
928  int add_row_shift=0;
929  intvec *ww=NULL;
930  if (l->nr>=0) ww=(intvec *)atGet(&(l->m[0]),"isHomog",INTVEC_CMD);
931  if (ww!=NULL)
932  {
933  weights=ivCopy(ww);
934  add_row_shift = ww->min_in();
935  (*weights) -= add_row_shift;
936  }
937  //Print("attr:%x\n",weights);
938 
939  r=liFindRes(l,&len,&typ0);
940  if (r==NULL) return TRUE;
941  intvec* res_im=syBetti(r,len,&reg,weights,(int)(long)v->Data());
942  res->data=(void*)res_im;
943  omFreeSize((ADDRESS)r,(len)*sizeof(ideal));
944  //Print("rowShift: %d ",add_row_shift);
945  for(int i=1;i<=res_im->rows();i++)
946  {
947  if (IMATELEM(*res_im,1,i)==0) { add_row_shift--; }
948  else break;
949  }
950  //Print(" %d\n",add_row_shift);
951  atSet(res,omStrDup("rowShift"),(void*)(long)add_row_shift,INT_CMD);
952  if (weights!=NULL) delete weights;
953  return FALSE;
954 }
955 
957 {
958  int len,reg,typ0;
959 
960  resolvente r=liFindRes(L,&len,&typ0);
961 
962  if (r==NULL)
963  return -2;
964  intvec *weights=NULL;
965  int add_row_shift=0;
966  intvec *ww=(intvec *)atGet(&(L->m[0]),"isHomog",INTVEC_CMD);
967  if (ww!=NULL)
968  {
969  weights=ivCopy(ww);
970  add_row_shift = ww->min_in();
971  (*weights) -= add_row_shift;
972  }
973  //Print("attr:%x\n",weights);
974 
975  intvec *dummy=syBetti(r,len,&reg,weights);
976  if (weights!=NULL) delete weights;
977  delete dummy;
978  omFreeSize((ADDRESS)r,len*sizeof(ideal));
979  return reg+1+add_row_shift;
980 }
981 
983 #define BREAK_LINE_LENGTH 80
984 void iiDebug()
985 {
986 #ifdef HAVE_SDB
987  sdb_flags=1;
988 #endif
989  Print("\n-- break point in %s --\n",VoiceName());
991  char * s;
993  s = (char *)omAlloc(BREAK_LINE_LENGTH+4);
994  loop
995  {
996  memset(s,0,80);
998  if (s[BREAK_LINE_LENGTH-1]!='\0')
999  {
1000  Print("line too long, max is %d chars\n",BREAK_LINE_LENGTH);
1001  }
1002  else
1003  break;
1004  }
1005  if (*s=='\n')
1006  {
1008  }
1009 #if MDEBUG
1010  else if(strncmp(s,"cont;",5)==0)
1011  {
1013  }
1014 #endif /* MDEBUG */
1015  else
1016  {
1017  strcat( s, "\n;~\n");
1019  }
1020 }
1021 
1022 lists scIndIndset(ideal S, BOOLEAN all, ideal Q)
1023 {
1024  int i;
1025  indset save;
1027 
1028  hexist = hInit(S, Q, &hNexist, currRing);
1029  if (hNexist == 0)
1030  {
1031  intvec *iv=new intvec(rVar(currRing));
1032  for(i=0; i<rVar(currRing); i++) (*iv)[i]=1;
1033  res->Init(1);
1034  res->m[0].rtyp=INTVEC_CMD;
1035  res->m[0].data=(intvec*)iv;
1036  return res;
1037  }
1038  else if (hisModule!=0)
1039  {
1040  res->Init(0);
1041  return res;
1042  }
1043  save = ISet = (indset)omAlloc0Bin(indlist_bin);
1044  hMu = 0;
1045  hwork = (scfmon)omAlloc(hNexist * sizeof(scmon));
1046  hvar = (varset)omAlloc((rVar(currRing) + 1) * sizeof(int));
1047  hpure = (scmon)omAlloc((1 + (rVar(currRing) * rVar(currRing))) * sizeof(long));
1048  hrad = hexist;
1049  hNrad = hNexist;
1050  radmem = hCreate(rVar(currRing) - 1);
1051  hCo = rVar(currRing) + 1;
1052  hNvar = rVar(currRing);
1053  hRadical(hrad, &hNrad, hNvar);
1054  hSupp(hrad, hNrad, hvar, &hNvar);
1055  if (hNvar)
1056  {
1057  hCo = hNvar;
1058  memset(hpure, 0, (rVar(currRing) + 1) * sizeof(long));
1059  hPure(hrad, 0, &hNrad, hvar, hNvar, hpure, &hNpure);
1060  hLexR(hrad, hNrad, hvar, hNvar);
1062  }
1063  if (hCo && (hCo < rVar(currRing)))
1064  {
1066  }
1067  if (hMu!=0)
1068  {
1069  ISet = save;
1070  hMu2 = 0;
1071  if (all && (hCo+1 < rVar(currRing)))
1072  {
1075  i=hMu+hMu2;
1076  res->Init(i);
1077  if (hMu2 == 0)
1078  {
1080  }
1081  }
1082  else
1083  {
1084  res->Init(hMu);
1085  }
1086  for (i=0;i<hMu;i++)
1087  {
1088  res->m[i].data = (void *)save->set;
1089  res->m[i].rtyp = INTVEC_CMD;
1090  ISet = save;
1091  save = save->nx;
1093  }
1094  omFreeBin((ADDRESS)save, indlist_bin);
1095  if (hMu2 != 0)
1096  {
1097  save = JSet;
1098  for (i=hMu;i<hMu+hMu2;i++)
1099  {
1100  res->m[i].data = (void *)save->set;
1101  res->m[i].rtyp = INTVEC_CMD;
1102  JSet = save;
1103  save = save->nx;
1105  }
1106  omFreeBin((ADDRESS)save, indlist_bin);
1107  }
1108  }
1109  else
1110  {
1111  res->Init(0);
1113  }
1114  hKill(radmem, rVar(currRing) - 1);
1115  omFreeSize((ADDRESS)hpure, (1 + (rVar(currRing) * rVar(currRing))) * sizeof(long));
1116  omFreeSize((ADDRESS)hvar, (rVar(currRing) + 1) * sizeof(int));
1117  omFreeSize((ADDRESS)hwork, hNexist * sizeof(scmon));
1119  return res;
1120 }
1121 
1122 int iiDeclCommand(leftv sy, leftv name, int lev,int t, idhdl* root,BOOLEAN isring, BOOLEAN init_b)
1123 {
1124  BOOLEAN res=FALSE;
1125  const char *id = name->name;
1126 
1127  memset(sy,0,sizeof(sleftv));
1128  if ((name->name==NULL)||(isdigit(name->name[0])))
1129  {
1130  WerrorS("object to declare is not a name");
1131  res=TRUE;
1132  }
1133  else
1134  {
1135  if (t==QRING_CMD) t=RING_CMD; // qring is always RING_CMD
1136 
1137  if (TEST_V_ALLWARN
1138  && (name->rtyp!=0)
1139  && (name->rtyp!=IDHDL)
1140  && (currRingHdl!=NULL) && (IDLEV(currRingHdl)==myynest))
1141  {
1142  Warn("`%s` is %s in %s:%d:%s",name->name,Tok2Cmdname(name->rtyp),
1144  }
1145  {
1146  sy->data = (char *)enterid(id,lev,t,root,init_b);
1147  }
1148  if (sy->data!=NULL)
1149  {
1150  sy->rtyp=IDHDL;
1151  currid=sy->name=IDID((idhdl)sy->data);
1152  // name->name=NULL; /* used in enterid */
1153  //sy->e = NULL;
1154  if (name->next!=NULL)
1155  {
1157  res=iiDeclCommand(sy->next,name->next,lev,t,root, isring);
1158  }
1159  }
1160  else res=TRUE;
1161  }
1162  name->CleanUp();
1163  return res;
1164 }
1165 
1167 {
1168  attr at=NULL;
1169  if (iiCurrProc!=NULL)
1170  at=iiCurrProc->attribute->get("default_arg");
1171  if (at==NULL)
1172  return FALSE;
1173  sleftv tmp;
1174  memset(&tmp,0,sizeof(sleftv));
1175  tmp.rtyp=at->atyp;
1176  tmp.data=at->CopyA();
1177  return iiAssign(p,&tmp);
1178 }
1180 {
1181  // must be inside a proc, as we simultae an proc_end at the end
1182  if (myynest==0)
1183  {
1184  WerrorS("branchTo can only occur in a proc");
1185  return TRUE;
1186  }
1187  // <string1...stringN>,<proc>
1188  // known: args!=NULL, l>=1
1189  int l=args->listLength();
1190  int ll=0;
1191  if (iiCurrArgs!=NULL) ll=iiCurrArgs->listLength();
1192  if (ll!=(l-1)) return FALSE;
1193  leftv h=args;
1194  // set up the table for type test:
1195  short *t=(short*)omAlloc(l*sizeof(short));
1196  t[0]=l-1;
1197  int b;
1198  int i;
1199  for(i=1;i<l;i++,h=h->next)
1200  {
1201  if (h->Typ()!=STRING_CMD)
1202  {
1203  omFree(t);
1204  Werror("arg %d is not a string",i);
1205  return TRUE;
1206  }
1207  int tt;
1208  b=IsCmd((char *)h->Data(),tt);
1209  if(b) t[i]=tt;
1210  else
1211  {
1212  omFree(t);
1213  Werror("arg %d is not a type name",i);
1214  return TRUE;
1215  }
1216  }
1217  if (h->Typ()!=PROC_CMD)
1218  {
1219  omFree(t);
1220  Werror("last(%d.) arg.(%s) is not a proc(but %s(%d)), nesting=%d",
1221  i,h->name,Tok2Cmdname(h->Typ()),h->Typ(),myynest);
1222  return TRUE;
1223  }
1224  b=iiCheckTypes(iiCurrArgs,t,0);
1225  omFree(t);
1226  if (b && (h->rtyp==IDHDL) && (h->e==NULL))
1227  {
1228  // get the proc:
1229  iiCurrProc=(idhdl)h->data;
1231  // already loaded ?
1232  if( pi->data.s.body==NULL )
1233  {
1235  if (pi->data.s.body==NULL) return TRUE;
1236  }
1237  // set currPackHdl/currPack
1238  if ((pi->pack!=NULL)&&(currPack!=pi->pack))
1239  {
1240  currPack=pi->pack;
1243  //Print("set pack=%s\n",IDID(currPackHdl));
1244  }
1245  // see iiAllStart:
1246  BITSET save1=si_opt_1;
1247  BITSET save2=si_opt_2;
1248  newBuffer( omStrDup(pi->data.s.body), BT_proc,
1249  pi, pi->data.s.body_lineno-(iiCurrArgs==NULL) );
1250  BOOLEAN err=yyparse();
1251  si_opt_1=save1;
1252  si_opt_2=save2;
1253  // now save the return-expr.
1255  memcpy(&sLastPrinted,&iiRETURNEXPR,sizeof(sleftv));
1256  iiRETURNEXPR.Init();
1257  // warning about args.:
1258  if (iiCurrArgs!=NULL)
1259  {
1260  if (err==0) Warn("too many arguments for %s",IDID(iiCurrProc));
1261  iiCurrArgs->CleanUp();
1263  iiCurrArgs=NULL;
1264  }
1265  // similate proc_end:
1266  // - leave input
1267  void myychangebuffer();
1268  myychangebuffer();
1269  // - set the current buffer to its end (this is a pointer in a buffer,
1270  // not a file ptr) "branchTo" is only valid in proc)
1272  // - kill local vars
1274  // - return
1275  newBuffer(omStrDup("\n;return(_);\n"),BT_execute);
1276  return (err!=0);
1277  }
1278  return FALSE;
1279 }
1281 {
1282  if (iiCurrArgs==NULL)
1283  {
1284  if (strcmp(p->name,"#")==0)
1285  return iiDefaultParameter(p);
1286  Werror("not enough arguments for proc %s",VoiceName());
1287  p->CleanUp();
1288  return TRUE;
1289  }
1290  leftv h=iiCurrArgs;
1291  leftv rest=h->next; /*iiCurrArgs is not NULL here*/
1292  BOOLEAN is_default_list=FALSE;
1293  if (strcmp(p->name,"#")==0)
1294  {
1295  is_default_list=TRUE;
1296  rest=NULL;
1297  }
1298  else
1299  {
1300  h->next=NULL;
1301  }
1302  BOOLEAN res=iiAssign(p,h);
1303  if (is_default_list)
1304  {
1305  iiCurrArgs=NULL;
1306  }
1307  else
1308  {
1309  iiCurrArgs=rest;
1310  }
1311  h->CleanUp();
1313  return res;
1314 }
1315 
1316 static BOOLEAN iiInternalExport (leftv v, int toLev)
1317 {
1318  idhdl h=(idhdl)v->data;
1319  //Print("iiInternalExport('%s',%d)%s\n", v->name, toLev,"");
1320  if (IDLEV(h)==0)
1321  {
1322  if (BVERBOSE(V_REDEFINE)) Warn("`%s` is already global",IDID(h));
1323  }
1324  else
1325  {
1326  h=IDROOT->get(v->name,toLev);
1327  idhdl *root=&IDROOT;
1328  if ((h==NULL)&&(currRing!=NULL))
1329  {
1330  h=currRing->idroot->get(v->name,toLev);
1331  root=&currRing->idroot;
1332  }
1333  BOOLEAN keepring=FALSE;
1334  if ((h!=NULL)&&(IDLEV(h)==toLev))
1335  {
1336  if (IDTYP(h)==v->Typ())
1337  {
1338  if ((IDTYP(h)==RING_CMD)
1339  && (v->Data()==IDDATA(h)))
1340  {
1341  IDRING(h)->ref++;
1342  keepring=TRUE;
1343  IDLEV(h)=toLev;
1344  //WarnS("keepring");
1345  return FALSE;
1346  }
1347  if (BVERBOSE(V_REDEFINE))
1348  {
1349  Warn("redefining %s (%s)",IDID(h),my_yylinebuf);
1350  }
1351  if (iiLocalRing[0]==IDRING(h) && (!keepring)) iiLocalRing[0]=NULL;
1352  killhdl2(h,root,currRing);
1353  }
1354  else
1355  {
1356  return TRUE;
1357  }
1358  }
1359  h=(idhdl)v->data;
1360  IDLEV(h)=toLev;
1361  if (keepring) IDRING(h)->ref--;
1363  //Print("export %s\n",IDID(h));
1364  }
1365  return FALSE;
1366 }
1367 
1368 BOOLEAN iiInternalExport (leftv v, int toLev, package rootpack)
1369 {
1370  idhdl h=(idhdl)v->data;
1371  if(h==NULL)
1372  {
1373  Warn("'%s': no such identifier\n", v->name);
1374  return FALSE;
1375  }
1376  package frompack=v->req_packhdl;
1377  if (frompack==NULL) frompack=currPack;
1378  if ((RingDependend(IDTYP(h)))
1379  || ((IDTYP(h)==LIST_CMD)
1380  && (lRingDependend(IDLIST(h)))
1381  )
1382  )
1383  {
1384  //Print("// ==> Ringdependent set nesting to 0\n");
1385  return (iiInternalExport(v, toLev));
1386  }
1387  else
1388  {
1389  IDLEV(h)=toLev;
1390  v->req_packhdl=rootpack;
1391  if (h==frompack->idroot)
1392  {
1393  frompack->idroot=h->next;
1394  }
1395  else
1396  {
1397  idhdl hh=frompack->idroot;
1398  while ((hh!=NULL) && (hh->next!=h))
1399  hh=hh->next;
1400  if ((hh!=NULL) && (hh->next==h))
1401  hh->next=h->next;
1402  else
1403  {
1404  Werror("`%s` not found",v->Name());
1405  return TRUE;
1406  }
1407  }
1408  h->next=rootpack->idroot;
1409  rootpack->idroot=h;
1410  }
1411  return FALSE;
1412 }
1413 
1414 BOOLEAN iiExport (leftv v, int toLev)
1415 {
1416  BOOLEAN nok=FALSE;
1417  leftv r=v;
1418  while (v!=NULL)
1419  {
1420  if ((v->name==NULL)||(v->rtyp==0)||(v->e!=NULL))
1421  {
1422  Werror("cannot export:%s of internal type %d",v->name,v->rtyp);
1423  nok=TRUE;
1424  }
1425  else
1426  {
1427  if(iiInternalExport(v, toLev))
1428  {
1429  r->CleanUp();
1430  return TRUE;
1431  }
1432  }
1433  v=v->next;
1434  }
1435  r->CleanUp();
1436  return nok;
1437 }
1438 
1439 /*assume root!=idroot*/
1440 BOOLEAN iiExport (leftv v, int toLev, package pack)
1441 {
1442 // if ((pack==basePack)&&(pack!=currPack))
1443 // { Warn("'exportto' to Top is depreciated in >>%s<<",my_yylinebuf);}
1444  BOOLEAN nok=FALSE;
1445  leftv rv=v;
1446  while (v!=NULL)
1447  {
1448  if ((v->name==NULL)||(v->rtyp==0)||(v->e!=NULL)
1449  )
1450  {
1451  Werror("cannot export:%s of internal type %d",v->name,v->rtyp);
1452  nok=TRUE;
1453  }
1454  else
1455  {
1456  idhdl old=pack->idroot->get( v->name,toLev);
1457  if (old!=NULL)
1458  {
1459  if ((pack==currPack) && (old==(idhdl)v->data))
1460  {
1461  if (BVERBOSE(V_REDEFINE)) Warn("`%s` is already global",IDID(old));
1462  break;
1463  }
1464  else if (IDTYP(old)==v->Typ())
1465  {
1466  if (BVERBOSE(V_REDEFINE))
1467  {
1468  Warn("redefining %s (%s)",IDID(old),my_yylinebuf);
1469  }
1470  v->name=omStrDup(v->name);
1471  killhdl2(old,&(pack->idroot),currRing);
1472  }
1473  else
1474  {
1475  rv->CleanUp();
1476  return TRUE;
1477  }
1478  }
1479  //Print("iiExport: pack=%s\n",IDID(root));
1480  if(iiInternalExport(v, toLev, pack))
1481  {
1482  rv->CleanUp();
1483  return TRUE;
1484  }
1485  }
1486  v=v->next;
1487  }
1488  rv->CleanUp();
1489  return nok;
1490 }
1491 
1493 {
1494  if (currRing==NULL)
1495  {
1496  #ifdef SIQ
1497  if (siq<=0)
1498  {
1499  #endif
1500  if (RingDependend(i))
1501  {
1502  WerrorS("no ring active");
1503  return TRUE;
1504  }
1505  #ifdef SIQ
1506  }
1507  #endif
1508  }
1509  return FALSE;
1510 }
1511 
1512 poly iiHighCorner(ideal I, int ak)
1513 {
1514  int i;
1515  if(!idIsZeroDim(I)) return NULL; // not zero-dim.
1516  poly po=NULL;
1518  {
1519  scComputeHC(I,currRing->qideal,ak,po);
1520  if (po!=NULL)
1521  {
1522  pGetCoeff(po)=nInit(1);
1523  for (i=rVar(currRing); i>0; i--)
1524  {
1525  if (pGetExp(po, i) > 0) pDecrExp(po,i);
1526  }
1527  pSetComp(po,ak);
1528  pSetm(po);
1529  }
1530  }
1531  else
1532  po=pOne();
1533  return po;
1534 }
1535 
1537 {
1538  if (p!=basePack)
1539  {
1540  idhdl t=basePack->idroot;
1541  while ((t!=NULL) && (IDTYP(t)!=PACKAGE_CMD) && (IDPACKAGE(t)!=p)) t=t->next;
1542  if (t==NULL)
1543  {
1544  WarnS("package not found\n");
1545  p=basePack;
1546  }
1547  }
1548 }
1549 
1550 idhdl rDefault(const char *s)
1551 {
1552  idhdl tmp=NULL;
1553 
1554  if (s!=NULL) tmp = enterid(s, myynest, RING_CMD, &IDROOT);
1555  if (tmp==NULL) return NULL;
1556 
1557 // if ((currRing->ppNoether)!=NULL) pDelete(&(currRing->ppNoether));
1559  {
1561  memset(&sLastPrinted,0,sizeof(sleftv));
1562  }
1563 
1564  ring r = IDRING(tmp) = (ring) omAlloc0Bin(sip_sring_bin);
1565 
1566  r->cf = nInitChar(n_Zp, (void*)32003); // r->cf->ch = 32003;
1567  r->N = 3;
1568  /*r->P = 0; Alloc0 in idhdl::set, ipid.cc*/
1569  /*names*/
1570  r->names = (char **) omAlloc0(3 * sizeof(char_ptr));
1571  r->names[0] = omStrDup("x");
1572  r->names[1] = omStrDup("y");
1573  r->names[2] = omStrDup("z");
1574  /*weights: entries for 3 blocks: NULL*/
1575  r->wvhdl = (int **)omAlloc0(3 * sizeof(int_ptr));
1576  /*order: dp,C,0*/
1577  r->order = (rRingOrder_t *) omAlloc(3 * sizeof(rRingOrder_t *));
1578  r->block0 = (int *)omAlloc0(3 * sizeof(int *));
1579  r->block1 = (int *)omAlloc0(3 * sizeof(int *));
1580  /* ringorder dp for the first block: var 1..3 */
1581  r->order[0] = ringorder_dp;
1582  r->block0[0] = 1;
1583  r->block1[0] = 3;
1584  /* ringorder C for the second block: no vars */
1585  r->order[1] = ringorder_C;
1586  /* the last block: everything is 0 */
1587  r->order[2] = (rRingOrder_t)0;
1588 
1589  /* complete ring intializations */
1590  rComplete(r);
1591  rSetHdl(tmp);
1592  return currRingHdl;
1593 }
1594 
1596 {
1598  if (h!=NULL) return h;
1599  if (IDROOT!=basePack->idroot) h=rSimpleFindHdl(r,basePack->idroot,n);
1600  if (h!=NULL) return h;
1602  while(p!=NULL)
1603  {
1604  if ((p->cPack!=basePack)
1605  && (p->cPack!=currPack))
1606  h=rSimpleFindHdl(r,p->cPack->idroot,n);
1607  if (h!=NULL) return h;
1608  p=p->next;
1609  }
1610  idhdl tmp=basePack->idroot;
1611  while (tmp!=NULL)
1612  {
1613  if (IDTYP(tmp)==PACKAGE_CMD)
1614  h=rSimpleFindHdl(r,IDPACKAGE(tmp)->idroot,n);
1615  if (h!=NULL) return h;
1616  tmp=IDNEXT(tmp);
1617  }
1618  return NULL;
1619 }
1620 
1621 void rDecomposeCF(leftv h,const ring r,const ring R)
1622 {
1624  L->Init(4);
1625  h->rtyp=LIST_CMD;
1626  h->data=(void *)L;
1627  // 0: char/ cf - ring
1628  // 1: list (var)
1629  // 2: list (ord)
1630  // 3: qideal
1631  // ----------------------------------------
1632  // 0: char/ cf - ring
1633  L->m[0].rtyp=INT_CMD;
1634  L->m[0].data=(void *)(long)r->cf->ch;
1635  // ----------------------------------------
1636  // 1: list (var)
1638  LL->Init(r->N);
1639  int i;
1640  for(i=0; i<r->N; i++)
1641  {
1642  LL->m[i].rtyp=STRING_CMD;
1643  LL->m[i].data=(void *)omStrDup(r->names[i]);
1644  }
1645  L->m[1].rtyp=LIST_CMD;
1646  L->m[1].data=(void *)LL;
1647  // ----------------------------------------
1648  // 2: list (ord)
1650  i=rBlocks(r)-1;
1651  LL->Init(i);
1652  i--;
1653  lists LLL;
1654  for(; i>=0; i--)
1655  {
1656  intvec *iv;
1657  int j;
1658  LL->m[i].rtyp=LIST_CMD;
1660  LLL->Init(2);
1661  LLL->m[0].rtyp=STRING_CMD;
1662  LLL->m[0].data=(void *)omStrDup(rSimpleOrdStr(r->order[i]));
1663  if (r->block1[i]-r->block0[i] >=0 )
1664  {
1665  j=r->block1[i]-r->block0[i];
1666  if(r->order[i]==ringorder_M) j=(j+1)*(j+1)-1;
1667  iv=new intvec(j+1);
1668  if ((r->wvhdl!=NULL) && (r->wvhdl[i]!=NULL))
1669  {
1670  for(;j>=0; j--) (*iv)[j]=r->wvhdl[i][j];
1671  }
1672  else switch (r->order[i])
1673  {
1674  case ringorder_dp:
1675  case ringorder_Dp:
1676  case ringorder_ds:
1677  case ringorder_Ds:
1678  case ringorder_lp:
1679  for(;j>=0; j--) (*iv)[j]=1;
1680  break;
1681  default: /* do nothing */;
1682  }
1683  }
1684  else
1685  {
1686  iv=new intvec(1);
1687  }
1688  LLL->m[1].rtyp=INTVEC_CMD;
1689  LLL->m[1].data=(void *)iv;
1690  LL->m[i].data=(void *)LLL;
1691  }
1692  L->m[2].rtyp=LIST_CMD;
1693  L->m[2].data=(void *)LL;
1694  // ----------------------------------------
1695  // 3: qideal
1696  L->m[3].rtyp=IDEAL_CMD;
1697  if (nCoeff_is_transExt(R->cf))
1698  L->m[3].data=(void *)idInit(1,1);
1699  else
1700  {
1701  ideal q=idInit(IDELEMS(r->qideal));
1702  q->m[0]=p_Init(R);
1703  pSetCoeff0(q->m[0],(number)(r->qideal->m[0]));
1704  L->m[3].data=(void *)q;
1705 // I->m[0] = pNSet(R->minpoly);
1706  }
1707  // ----------------------------------------
1708 }
1709 static void rDecomposeC_41(leftv h,const coeffs C)
1710 /* field is R or C */
1711 {
1713  if (nCoeff_is_long_C(C)) L->Init(3);
1714  else L->Init(2);
1715  h->rtyp=LIST_CMD;
1716  h->data=(void *)L;
1717  // 0: char/ cf - ring
1718  // 1: list (var)
1719  // 2: list (ord)
1720  // ----------------------------------------
1721  // 0: char/ cf - ring
1722  L->m[0].rtyp=INT_CMD;
1723  L->m[0].data=(void *)0;
1724  // ----------------------------------------
1725  // 1:
1727  LL->Init(2);
1728  LL->m[0].rtyp=INT_CMD;
1729  LL->m[0].data=(void *)(long)si_max(C->float_len,SHORT_REAL_LENGTH/2);
1730  LL->m[1].rtyp=INT_CMD;
1731  LL->m[1].data=(void *)(long)si_max(C->float_len2,SHORT_REAL_LENGTH);
1732  L->m[1].rtyp=LIST_CMD;
1733  L->m[1].data=(void *)LL;
1734  // ----------------------------------------
1735  // 2: list (par)
1736  if (nCoeff_is_long_C(C))
1737  {
1738  L->m[2].rtyp=STRING_CMD;
1739  L->m[2].data=(void *)omStrDup(*n_ParameterNames(C));
1740  }
1741  // ----------------------------------------
1742 }
1743 static void rDecomposeC(leftv h,const ring R)
1744 /* field is R or C */
1745 {
1747  if (rField_is_long_C(R)) L->Init(3);
1748  else L->Init(2);
1749  h->rtyp=LIST_CMD;
1750  h->data=(void *)L;
1751  // 0: char/ cf - ring
1752  // 1: list (var)
1753  // 2: list (ord)
1754  // ----------------------------------------
1755  // 0: char/ cf - ring
1756  L->m[0].rtyp=INT_CMD;
1757  L->m[0].data=(void *)0;
1758  // ----------------------------------------
1759  // 1:
1761  LL->Init(2);
1762  LL->m[0].rtyp=INT_CMD;
1763  LL->m[0].data=(void *)(long)si_max(R->cf->float_len,SHORT_REAL_LENGTH/2);
1764  LL->m[1].rtyp=INT_CMD;
1765  LL->m[1].data=(void *)(long)si_max(R->cf->float_len2,SHORT_REAL_LENGTH);
1766  L->m[1].rtyp=LIST_CMD;
1767  L->m[1].data=(void *)LL;
1768  // ----------------------------------------
1769  // 2: list (par)
1770  if (rField_is_long_C(R))
1771  {
1772  L->m[2].rtyp=STRING_CMD;
1773  L->m[2].data=(void *)omStrDup(*rParameter(R));
1774  }
1775  // ----------------------------------------
1776 }
1777 
1778 #ifdef HAVE_RINGS
1780 /* field is R or C */
1781 {
1783  if (nCoeff_is_Ring(C)) L->Init(1);
1784  else L->Init(2);
1785  h->rtyp=LIST_CMD;
1786  h->data=(void *)L;
1787  // 0: char/ cf - ring
1788  // 1: list (module)
1789  // ----------------------------------------
1790  // 0: char/ cf - ring
1791  L->m[0].rtyp=STRING_CMD;
1792  L->m[0].data=(void *)omStrDup("integer");
1793  // ----------------------------------------
1794  // 1: modulo
1795  if (nCoeff_is_Ring_Z(C)) return;
1797  LL->Init(2);
1798  LL->m[0].rtyp=BIGINT_CMD;
1799  LL->m[0].data=nlMapGMP((number) C->modBase, C, coeffs_BIGINT);
1800  LL->m[1].rtyp=INT_CMD;
1801  LL->m[1].data=(void *) C->modExponent;
1802  L->m[1].rtyp=LIST_CMD;
1803  L->m[1].data=(void *)LL;
1804 }
1805 #endif
1806 
1807 void rDecomposeRing(leftv h,const ring R)
1808 /* field is R or C */
1809 {
1810 #ifdef HAVE_RINGS
1812  if (rField_is_Ring_Z(R)) L->Init(1);
1813  else L->Init(2);
1814  h->rtyp=LIST_CMD;
1815  h->data=(void *)L;
1816  // 0: char/ cf - ring
1817  // 1: list (module)
1818  // ----------------------------------------
1819  // 0: char/ cf - ring
1820  L->m[0].rtyp=STRING_CMD;
1821  L->m[0].data=(void *)omStrDup("integer");
1822  // ----------------------------------------
1823  // 1: module
1824  if (rField_is_Ring_Z(R)) return;
1826  LL->Init(2);
1827  LL->m[0].rtyp=BIGINT_CMD;
1828  LL->m[0].data=nlMapGMP((number) R->cf->modBase, R->cf, R->cf); // TODO: what is this?? // extern number nlMapGMP(number from, const coeffs src, const coeffs dst); // FIXME: replace with n_InitMPZ(R->cf->modBase, coeffs_BIGINT); ?
1829  LL->m[1].rtyp=INT_CMD;
1830  LL->m[1].data=(void *) R->cf->modExponent;
1831  L->m[1].rtyp=LIST_CMD;
1832  L->m[1].data=(void *)LL;
1833 #else
1834  WerrorS("rDecomposeRing");
1835 #endif
1836 }
1837 
1838 
1840 {
1841  assume( C != NULL );
1842 
1843  // sanity check: require currRing==r for rings with polynomial data
1844  if ( nCoeff_is_algExt(C) && (C != currRing->cf))
1845  {
1846  WerrorS("ring with polynomial data must be the base ring or compatible");
1847  return TRUE;
1848  }
1849  if (nCoeff_is_numeric(C))
1850  {
1851  rDecomposeC_41(res,C);
1852  }
1853 #ifdef HAVE_RINGS
1854  else if (nCoeff_is_Ring(C))
1855  {
1857  }
1858 #endif
1859  else if ( C->extRing!=NULL )// nCoeff_is_algExt(r->cf))
1860  {
1861  rDecomposeCF(res, C->extRing, currRing);
1862  }
1863  else if(nCoeff_is_GF(C))
1864  {
1866  Lc->Init(4);
1867  // char:
1868  Lc->m[0].rtyp=INT_CMD;
1869  Lc->m[0].data=(void*)(long)C->m_nfCharQ;
1870  // var:
1872  Lv->Init(1);
1873  Lv->m[0].rtyp=STRING_CMD;
1874  Lv->m[0].data=(void *)omStrDup(*n_ParameterNames(C));
1875  Lc->m[1].rtyp=LIST_CMD;
1876  Lc->m[1].data=(void*)Lv;
1877  // ord:
1879  Lo->Init(1);
1881  Loo->Init(2);
1882  Loo->m[0].rtyp=STRING_CMD;
1883  Loo->m[0].data=(void *)omStrDup(rSimpleOrdStr(ringorder_lp));
1884 
1885  intvec *iv=new intvec(1); (*iv)[0]=1;
1886  Loo->m[1].rtyp=INTVEC_CMD;
1887  Loo->m[1].data=(void *)iv;
1888 
1889  Lo->m[0].rtyp=LIST_CMD;
1890  Lo->m[0].data=(void*)Loo;
1891 
1892  Lc->m[2].rtyp=LIST_CMD;
1893  Lc->m[2].data=(void*)Lo;
1894  // q-ideal:
1895  Lc->m[3].rtyp=IDEAL_CMD;
1896  Lc->m[3].data=(void *)idInit(1,1);
1897  // ----------------------
1898  res->rtyp=LIST_CMD;
1899  res->data=(void*)Lc;
1900  }
1901  else
1902  {
1903  res->rtyp=INT_CMD;
1904  res->data=(void *)(long)C->ch;
1905  }
1906  // ----------------------------------------
1907  return FALSE;
1908 }
1909 
1911 {
1912  assume( r != NULL );
1913  const coeffs C = r->cf;
1914  assume( C != NULL );
1915 
1916  // sanity check: require currRing==r for rings with polynomial data
1917  if ( (r!=currRing) && (
1918  (r->qideal != NULL)
1919 #ifdef HAVE_PLURAL
1920  || (rIsPluralRing(r))
1921 #endif
1922  )
1923  )
1924  {
1925  WerrorS("ring with polynomial data must be the base ring or compatible");
1926  return NULL;
1927  }
1928  // 0: char/ cf - ring
1929  // 1: list (var)
1930  // 2: list (ord)
1931  // 3: qideal
1932  // possibly:
1933  // 4: C
1934  // 5: D
1936  if (rIsPluralRing(r))
1937  L->Init(6);
1938  else
1939  L->Init(4);
1940  // ----------------------------------------
1941  // 0: char/ cf - ring
1942  L->m[0].rtyp=CRING_CMD;
1943  L->m[0].data=(char*)r->cf; r->cf->ref++;
1944  // ----------------------------------------
1945  // 1: list (var)
1947  LL->Init(r->N);
1948  int i;
1949  for(i=0; i<r->N; i++)
1950  {
1951  LL->m[i].rtyp=STRING_CMD;
1952  LL->m[i].data=(void *)omStrDup(r->names[i]);
1953  }
1954  L->m[1].rtyp=LIST_CMD;
1955  L->m[1].data=(void *)LL;
1956  // ----------------------------------------
1957  // 2: list (ord)
1959  i=rBlocks(r)-1;
1960  LL->Init(i);
1961  i--;
1962  lists LLL;
1963  for(; i>=0; i--)
1964  {
1965  intvec *iv;
1966  int j;
1967  LL->m[i].rtyp=LIST_CMD;
1969  LLL->Init(2);
1970  LLL->m[0].rtyp=STRING_CMD;
1971  LLL->m[0].data=(void *)omStrDup(rSimpleOrdStr(r->order[i]));
1972 
1973  if(r->order[i] == ringorder_IS) // || r->order[i] == ringorder_s || r->order[i] == ringorder_S)
1974  {
1975  assume( r->block0[i] == r->block1[i] );
1976  const int s = r->block0[i];
1977  assume( -2 < s && s < 2);
1978 
1979  iv=new intvec(1);
1980  (*iv)[0] = s;
1981  }
1982  else if (r->block1[i]-r->block0[i] >=0 )
1983  {
1984  int bl=j=r->block1[i]-r->block0[i];
1985  if (r->order[i]==ringorder_M)
1986  {
1987  j=(j+1)*(j+1)-1;
1988  bl=j+1;
1989  }
1990  else if (r->order[i]==ringorder_am)
1991  {
1992  j+=r->wvhdl[i][bl+1];
1993  }
1994  iv=new intvec(j+1);
1995  if ((r->wvhdl!=NULL) && (r->wvhdl[i]!=NULL))
1996  {
1997  for(;j>=0; j--) (*iv)[j]=r->wvhdl[i][j+(j>bl)];
1998  }
1999  else switch (r->order[i])
2000  {
2001  case ringorder_dp:
2002  case ringorder_Dp:
2003  case ringorder_ds:
2004  case ringorder_Ds:
2005  case ringorder_lp:
2006  for(;j>=0; j--) (*iv)[j]=1;
2007  break;
2008  default: /* do nothing */;
2009  }
2010  }
2011  else
2012  {
2013  iv=new intvec(1);
2014  }
2015  LLL->m[1].rtyp=INTVEC_CMD;
2016  LLL->m[1].data=(void *)iv;
2017  LL->m[i].data=(void *)LLL;
2018  }
2019  L->m[2].rtyp=LIST_CMD;
2020  L->m[2].data=(void *)LL;
2021  // ----------------------------------------
2022  // 3: qideal
2023  L->m[3].rtyp=IDEAL_CMD;
2024  if (r->qideal==NULL)
2025  L->m[3].data=(void *)idInit(1,1);
2026  else
2027  L->m[3].data=(void *)idCopy(r->qideal);
2028  // ----------------------------------------
2029 #ifdef HAVE_PLURAL // NC! in rDecompose
2030  if (rIsPluralRing(r))
2031  {
2032  L->m[4].rtyp=MATRIX_CMD;
2033  L->m[4].data=(void *)mp_Copy(r->GetNC()->C, r, r);
2034  L->m[5].rtyp=MATRIX_CMD;
2035  L->m[5].data=(void *)mp_Copy(r->GetNC()->D, r, r);
2036  }
2037 #endif
2038  return L;
2039 }
2040 
2041 lists rDecompose(const ring r)
2042 {
2043  assume( r != NULL );
2044  const coeffs C = r->cf;
2045  assume( C != NULL );
2046 
2047  // sanity check: require currRing==r for rings with polynomial data
2048  if ( (r!=currRing) && (
2049  (nCoeff_is_algExt(C) && (C != currRing->cf))
2050  || (r->qideal != NULL)
2051 #ifdef HAVE_PLURAL
2052  || (rIsPluralRing(r))
2053 #endif
2054  )
2055  )
2056  {
2057  WerrorS("ring with polynomial data must be the base ring or compatible");
2058  return NULL;
2059  }
2060  // 0: char/ cf - ring
2061  // 1: list (var)
2062  // 2: list (ord)
2063  // 3: qideal
2064  // possibly:
2065  // 4: C
2066  // 5: D
2068  if (rIsPluralRing(r))
2069  L->Init(6);
2070  else
2071  L->Init(4);
2072  // ----------------------------------------
2073  // 0: char/ cf - ring
2074  if (rField_is_numeric(r))
2075  {
2076  rDecomposeC(&(L->m[0]),r);
2077  }
2078  else if (rField_is_Ring(r))
2079  {
2080  rDecomposeRing(&(L->m[0]),r);
2081  }
2082  else if ( r->cf->extRing!=NULL )// nCoeff_is_algExt(r->cf))
2083  {
2084  rDecomposeCF(&(L->m[0]), r->cf->extRing, r);
2085  }
2086  else if(rField_is_GF(r))
2087  {
2089  Lc->Init(4);
2090  // char:
2091  Lc->m[0].rtyp=INT_CMD;
2092  Lc->m[0].data=(void*)(long)r->cf->m_nfCharQ;
2093  // var:
2095  Lv->Init(1);
2096  Lv->m[0].rtyp=STRING_CMD;
2097  Lv->m[0].data=(void *)omStrDup(*rParameter(r));
2098  Lc->m[1].rtyp=LIST_CMD;
2099  Lc->m[1].data=(void*)Lv;
2100  // ord:
2102  Lo->Init(1);
2104  Loo->Init(2);
2105  Loo->m[0].rtyp=STRING_CMD;
2106  Loo->m[0].data=(void *)omStrDup(rSimpleOrdStr(ringorder_lp));
2107 
2108  intvec *iv=new intvec(1); (*iv)[0]=1;
2109  Loo->m[1].rtyp=INTVEC_CMD;
2110  Loo->m[1].data=(void *)iv;
2111 
2112  Lo->m[0].rtyp=LIST_CMD;
2113  Lo->m[0].data=(void*)Loo;
2114 
2115  Lc->m[2].rtyp=LIST_CMD;
2116  Lc->m[2].data=(void*)Lo;
2117  // q-ideal:
2118  Lc->m[3].rtyp=IDEAL_CMD;
2119  Lc->m[3].data=(void *)idInit(1,1);
2120  // ----------------------
2121  L->m[0].rtyp=LIST_CMD;
2122  L->m[0].data=(void*)Lc;
2123  }
2124  else
2125  {
2126  L->m[0].rtyp=INT_CMD;
2127  L->m[0].data=(void *)(long)r->cf->ch;
2128  }
2129  // ----------------------------------------
2130  // 1: list (var)
2132  LL->Init(r->N);
2133  int i;
2134  for(i=0; i<r->N; i++)
2135  {
2136  LL->m[i].rtyp=STRING_CMD;
2137  LL->m[i].data=(void *)omStrDup(r->names[i]);
2138  }
2139  L->m[1].rtyp=LIST_CMD;
2140  L->m[1].data=(void *)LL;
2141  // ----------------------------------------
2142  // 2: list (ord)
2144  i=rBlocks(r)-1;
2145  LL->Init(i);
2146  i--;
2147  lists LLL;
2148  for(; i>=0; i--)
2149  {
2150  intvec *iv;
2151  int j;
2152  LL->m[i].rtyp=LIST_CMD;
2154  LLL->Init(2);
2155  LLL->m[0].rtyp=STRING_CMD;
2156  LLL->m[0].data=(void *)omStrDup(rSimpleOrdStr(r->order[i]));
2157 
2158  if((r->order[i] == ringorder_IS)
2159  || (r->order[i] == ringorder_s)) //|| r->order[i] == ringorder_S)
2160  {
2161  assume( r->block0[i] == r->block1[i] );
2162  const int s = r->block0[i];
2163  assume( (-2 < s && s < 2)||(r->order[i] != ringorder_IS));
2164 
2165  iv=new intvec(1);
2166  (*iv)[0] = s;
2167  }
2168  else if (r->block1[i]-r->block0[i] >=0 )
2169  {
2170  int bl=j=r->block1[i]-r->block0[i];
2171  if (r->order[i]==ringorder_M)
2172  {
2173  j=(j+1)*(j+1)-1;
2174  bl=j+1;
2175  }
2176  else if (r->order[i]==ringorder_am)
2177  {
2178  j+=r->wvhdl[i][bl+1];
2179  }
2180  iv=new intvec(j+1);
2181  if ((r->wvhdl!=NULL) && (r->wvhdl[i]!=NULL))
2182  {
2183  for(;j>=0; j--) (*iv)[j]=r->wvhdl[i][j+(j>bl)];
2184  }
2185  else switch (r->order[i])
2186  {
2187  case ringorder_dp:
2188  case ringorder_Dp:
2189  case ringorder_ds:
2190  case ringorder_Ds:
2191  case ringorder_lp:
2192  for(;j>=0; j--) (*iv)[j]=1;
2193  break;
2194  default: /* do nothing */;
2195  }
2196  }
2197  else
2198  {
2199  iv=new intvec(1);
2200  }
2201  LLL->m[1].rtyp=INTVEC_CMD;
2202  LLL->m[1].data=(void *)iv;
2203  LL->m[i].data=(void *)LLL;
2204  }
2205  L->m[2].rtyp=LIST_CMD;
2206  L->m[2].data=(void *)LL;
2207  // ----------------------------------------
2208  // 3: qideal
2209  L->m[3].rtyp=IDEAL_CMD;
2210  if (r->qideal==NULL)
2211  L->m[3].data=(void *)idInit(1,1);
2212  else
2213  L->m[3].data=(void *)idCopy(r->qideal);
2214  // ----------------------------------------
2215 #ifdef HAVE_PLURAL // NC! in rDecompose
2216  if (rIsPluralRing(r))
2217  {
2218  L->m[4].rtyp=MATRIX_CMD;
2219  L->m[4].data=(void *)mp_Copy(r->GetNC()->C, r, r);
2220  L->m[5].rtyp=MATRIX_CMD;
2221  L->m[5].data=(void *)mp_Copy(r->GetNC()->D, r, r);
2222  }
2223 #endif
2224  return L;
2225 }
2226 
2227 void rComposeC(lists L, ring R)
2228 /* field is R or C */
2229 {
2230  // ----------------------------------------
2231  // 0: char/ cf - ring
2232  if ((L->m[0].rtyp!=INT_CMD) || (L->m[0].data!=(char *)0))
2233  {
2234  WerrorS("invalid coeff. field description, expecting 0");
2235  return;
2236  }
2237 // R->cf->ch=0;
2238  // ----------------------------------------
2239  // 1:
2240  if (L->m[1].rtyp!=LIST_CMD)
2241  {
2242  WerrorS("invalid coeff. field description, expecting precision list");
2243  return;
2244  }
2245  lists LL=(lists)L->m[1].data;
2246  if (((LL->nr!=2)
2247  || (LL->m[0].rtyp!=INT_CMD)
2248  || (LL->m[1].rtyp!=INT_CMD))
2249  && ((LL->nr!=1)
2250  || (LL->m[0].rtyp!=INT_CMD)))
2251  {
2252  WerrorS("invalid coeff. field description list");
2253  return;
2254  }
2255  int r1=(int)(long)LL->m[0].data;
2256  int r2=(int)(long)LL->m[1].data;
2257  if (L->nr==2) // complex
2258  R->cf = nInitChar(n_long_C, NULL);
2259  else if ((r1<=SHORT_REAL_LENGTH)
2260  && (r2=SHORT_REAL_LENGTH))
2261  R->cf = nInitChar(n_R, NULL);
2262  else
2263  {
2265  p->float_len=r1;
2266  p->float_len2=r2;
2267  R->cf = nInitChar(n_long_R, NULL);
2268  }
2269 
2270  if ((r1<=SHORT_REAL_LENGTH) // should go into nInitChar
2271  && (r2=SHORT_REAL_LENGTH))
2272  {
2273  R->cf->float_len=SHORT_REAL_LENGTH/2;
2274  R->cf->float_len2=SHORT_REAL_LENGTH;
2275  }
2276  else
2277  {
2278  R->cf->float_len=si_min(r1,32767);
2279  R->cf->float_len2=si_min(r2,32767);
2280  }
2281  // ----------------------------------------
2282  // 2: list (par)
2283  if (L->nr==2)
2284  {
2285  //R->cf->extRing->N=1;
2286  if (L->m[2].rtyp!=STRING_CMD)
2287  {
2288  WerrorS("invalid coeff. field description, expecting parameter name");
2289  return;
2290  }
2291  //(rParameter(R))=(char**)omAlloc0(rPar(R)*sizeof(char_ptr));
2292  rParameter(R)[0]=omStrDup((char *)L->m[2].data);
2293  }
2294  // ----------------------------------------
2295 }
2296 
2297 #ifdef HAVE_RINGS
2298 void rComposeRing(lists L, ring R)
2299 /* field is R or C */
2300 {
2301  // ----------------------------------------
2302  // 0: string: integer
2303  // no further entries --> Z
2304  mpz_t modBase;
2305  unsigned int modExponent = 1;
2306 
2307  if (L->nr == 0)
2308  {
2309  mpz_init_set_ui(modBase,0);
2310  modExponent = 1;
2311  }
2312  // ----------------------------------------
2313  // 1:
2314  else
2315  {
2316  if (L->m[1].rtyp!=LIST_CMD) WerrorS("invalid data, expecting list of numbers");
2317  lists LL=(lists)L->m[1].data;
2318  if ((LL->nr >= 0) && LL->m[0].rtyp == BIGINT_CMD)
2319  {
2320  number tmp= (number) LL->m[0].data; // never use CopyD() on list elements
2321  // assume that tmp is integer, not rational
2322  mpz_init(modBase);
2323  n_MPZ (modBase, tmp, coeffs_BIGINT);
2324  }
2325  else if (LL->nr >= 0 && LL->m[0].rtyp == INT_CMD)
2326  {
2327  mpz_init_set_ui(modBase,(unsigned long) LL->m[0].data);
2328  }
2329  else
2330  {
2331  mpz_init_set_ui(modBase,0);
2332  }
2333  if (LL->nr >= 1)
2334  {
2335  modExponent = (unsigned long) LL->m[1].data;
2336  }
2337  else
2338  {
2339  modExponent = 1;
2340  }
2341  }
2342  // ----------------------------------------
2343  if ((mpz_cmp_ui(modBase, 1) == 0) && (mpz_sgn1(modBase) < 0))
2344  {
2345  WerrorS("Wrong ground ring specification (module is 1)");
2346  return;
2347  }
2348  if (modExponent < 1)
2349  {
2350  WerrorS("Wrong ground ring specification (exponent smaller than 1)");
2351  return;
2352  }
2353  // module is 0 ---> integers
2354  if (mpz_sgn1(modBase) == 0)
2355  {
2356  R->cf=nInitChar(n_Z,NULL);
2357  }
2358  // we have an exponent
2359  else if (modExponent > 1)
2360  {
2361  //R->cf->ch = R->cf->modExponent;
2362  if ((mpz_cmp_ui(modBase, 2) == 0) && (modExponent <= 8*sizeof(unsigned long)))
2363  {
2364  /* this branch should be active for modExponent = 2..32 resp. 2..64,
2365  depending on the size of a long on the respective platform */
2366  R->cf=nInitChar(n_Z2m,(void*)(long)modExponent); // Use Z/2^ch
2367  }
2368  else
2369  {
2370  //ringtype 3
2371  ZnmInfo info;
2372  info.base= modBase;
2373  info.exp= modExponent;
2374  R->cf=nInitChar(n_Znm,(void*) &info);
2375  }
2376  }
2377  // just a module m > 1
2378  else
2379  {
2380  //ringtype = 2;
2381  //const int ch = mpz_get_ui(modBase);
2382  ZnmInfo info;
2383  info.base= modBase;
2384  info.exp= modExponent;
2385  R->cf=nInitChar(n_Zn,(void*) &info);
2386  }
2387  mpz_clear(modBase);
2388 }
2389 #endif
2390 
2391 static void rRenameVars(ring R)
2392 {
2393  int i,j;
2394  BOOLEAN ch;
2395  do
2396  {
2397  ch=0;
2398  for(i=0;i<R->N-1;i++)
2399  {
2400  for(j=i+1;j<R->N;j++)
2401  {
2402  if (strcmp(R->names[i],R->names[j])==0)
2403  {
2404  ch=TRUE;
2405  Warn("name conflict var(%d) and var(%d): `%s`, rename to `@%s`",i+1,j+1,R->names[i],R->names[i]);
2406  omFree(R->names[j]);
2407  R->names[j]=(char *)omAlloc(2+strlen(R->names[i]));
2408  sprintf(R->names[j],"@%s",R->names[i]);
2409  }
2410  }
2411  }
2412  }
2413  while (ch);
2414  for(i=0;i<rPar(R); i++)
2415  {
2416  for(j=0;j<R->N;j++)
2417  {
2418  if (strcmp(rParameter(R)[i],R->names[j])==0)
2419  {
2420  Warn("name conflict par(%d) and var(%d): `%s`, renaming the VARIABLE to `@@(%d)`",i+1,j+1,R->names[j],i+1);
2421 // omFree(rParameter(R)[i]);
2422 // rParameter(R)[i]=(char *)omAlloc(10);
2423 // sprintf(rParameter(R)[i],"@@(%d)",i+1);
2424  omFree(R->names[j]);
2425  R->names[j]=(char *)omAlloc(10);
2426  sprintf(R->names[j],"@@(%d)",i+1);
2427  }
2428  }
2429  }
2430 }
2431 
2432 static inline BOOLEAN rComposeVar(const lists L, ring R)
2433 {
2434  assume(R!=NULL);
2435  if (L->m[1].Typ()==LIST_CMD)
2436  {
2437  lists v=(lists)L->m[1].Data();
2438  R->N = v->nr+1;
2439  if (R->N<=0)
2440  {
2441  WerrorS("no ring variables");
2442  return TRUE;
2443  }
2444  R->names = (char **)omAlloc0(R->N * sizeof(char_ptr));
2445  int i;
2446  for(i=0;i<R->N;i++)
2447  {
2448  if (v->m[i].Typ()==STRING_CMD)
2449  R->names[i]=omStrDup((char *)v->m[i].Data());
2450  else if (v->m[i].Typ()==POLY_CMD)
2451  {
2452  poly p=(poly)v->m[i].Data();
2453  int nr=pIsPurePower(p);
2454  if (nr>0)
2455  R->names[i]=omStrDup(currRing->names[nr-1]);
2456  else
2457  {
2458  Werror("var name %d must be a string or a ring variable",i+1);
2459  return TRUE;
2460  }
2461  }
2462  else
2463  {
2464  Werror("var name %d must be `string`",i+1);
2465  return TRUE;
2466  }
2467  }
2468  }
2469  else
2470  {
2471  WerrorS("variable must be given as `list`");
2472  return TRUE;
2473  }
2474  return FALSE;
2475 }
2476 
2477 static inline BOOLEAN rComposeOrder(const lists L, const BOOLEAN check_comp, ring R)
2478 {
2479  assume(R!=NULL);
2480  long bitmask=0L;
2481  if (L->m[2].Typ()==LIST_CMD)
2482  {
2483  lists v=(lists)L->m[2].Data();
2484  int n= v->nr+2;
2485  int j_in_R,j_in_L;
2486  // do we have an entry "L",... ?: set bitmask
2487  for (int j=0; j < n-1; j++)
2488  {
2489  if (v->m[j].Typ()==LIST_CMD)
2490  {
2491  lists vv=(lists)v->m[j].Data();
2492  if ((vv->nr==1)
2493  &&(vv->m[0].Typ()==STRING_CMD)
2494  &&(strcmp((char*)vv->m[0].Data(),"L")==0))
2495  {
2496  number nn=(number)vv->m[1].Data();
2497  if (vv->m[1].Typ()==BIGINT_CMD)
2498  bitmask=n_Int(nn,coeffs_BIGINT);
2499  else if (vv->m[1].Typ()==INT_CMD)
2500  bitmask=(long)nn;
2501  else
2502  {
2503  Werror("illegal argument for pseudo ordering L: %d",vv->m[1].Typ());
2504  return TRUE;
2505  }
2506  break;
2507  }
2508  }
2509  }
2510  if (bitmask!=0) n--;
2511 
2512  // initialize fields of R
2513  R->order=(rRingOrder_t *)omAlloc0(n*sizeof(rRingOrder_t));
2514  R->block0=(int *)omAlloc0(n*sizeof(int));
2515  R->block1=(int *)omAlloc0(n*sizeof(int));
2516  R->wvhdl=(int**)omAlloc0(n*sizeof(int_ptr));
2517  // init order, so that rBlocks works correctly
2518  for (j_in_R= n-2; j_in_R>=0; j_in_R--)
2519  R->order[j_in_R] = ringorder_unspec;
2520  // orderings
2521  for(j_in_R=0,j_in_L=0;j_in_R<n-1;j_in_R++,j_in_L++)
2522  {
2523  // todo: a(..), M
2524  if (v->m[j_in_L].Typ()!=LIST_CMD)
2525  {
2526  WerrorS("ordering must be list of lists");
2527  return TRUE;
2528  }
2529  lists vv=(lists)v->m[j_in_L].Data();
2530  if ((vv->nr==1)
2531  && (vv->m[0].Typ()==STRING_CMD))
2532  {
2533  if (strcmp((char*)vv->m[0].Data(),"L")==0)
2534  {
2535  j_in_R--;
2536  continue;
2537  }
2538  if ((vv->m[1].Typ()!=INTVEC_CMD) && (vv->m[1].Typ()!=INT_CMD))
2539  {
2540  PrintS(lString(vv));
2541  WerrorS("ordering name must be a (string,intvec)(1)");
2542  return TRUE;
2543  }
2544  R->order[j_in_R]=rOrderName(omStrDup((char*)vv->m[0].Data())); // assume STRING
2545 
2546  if (j_in_R==0) R->block0[0]=1;
2547  else
2548  {
2549  int jj=j_in_R-1;
2550  while((jj>=0)
2551  && ((R->order[jj]== ringorder_a)
2552  || (R->order[jj]== ringorder_aa)
2553  || (R->order[jj]== ringorder_am)
2554  || (R->order[jj]== ringorder_c)
2555  || (R->order[jj]== ringorder_C)
2556  || (R->order[jj]== ringorder_s)
2557  || (R->order[jj]== ringorder_S)
2558  ))
2559  {
2560  //Print("jj=%, skip %s\n",rSimpleOrdStr(R->order[jj]));
2561  jj--;
2562  }
2563  if (jj<0) R->block0[j_in_R]=1;
2564  else R->block0[j_in_R]=R->block1[jj]+1;
2565  }
2566  intvec *iv;
2567  if (vv->m[1].Typ()==INT_CMD)
2568  iv=new intvec((int)(long)vv->m[1].Data(),(int)(long)vv->m[1].Data());
2569  else
2570  iv=ivCopy((intvec*)vv->m[1].Data()); //assume INTVEC
2571  int iv_len=iv->length();
2572  if ((R->order[j_in_R]!=ringorder_s)
2573  &&(R->order[j_in_R]!=ringorder_c)
2574  &&(R->order[j_in_R]!=ringorder_C))
2575  {
2576  R->block1[j_in_R]=si_max(R->block0[j_in_R],R->block0[j_in_R]+iv_len-1);
2577  if (R->block1[j_in_R]>R->N)
2578  {
2579  if (R->block0[j_in_R]>R->N)
2580  {
2581  Werror("not enough variables for ordering %d (%s)",j_in_R,rSimpleOrdStr(R->order[j_in_R]));
2582  return TRUE;
2583  }
2584  R->block1[j_in_R]=R->N;
2585  iv_len=R->block1[j_in_R]-R->block0[j_in_R]+1;
2586  }
2587  //Print("block %d from %d to %d\n",j,R->block0[j], R->block1[j]);
2588  }
2589  int i;
2590  switch (R->order[j_in_R])
2591  {
2592  case ringorder_ws:
2593  case ringorder_Ws:
2594  R->OrdSgn=-1;
2595  case ringorder_aa:
2596  case ringorder_a:
2597  case ringorder_wp:
2598  case ringorder_Wp:
2599  R->wvhdl[j_in_R] =( int *)omAlloc(iv_len*sizeof(int));
2600  for (i=0; i<iv_len;i++)
2601  {
2602  R->wvhdl[j_in_R][i]=(*iv)[i];
2603  }
2604  break;
2605  case ringorder_am:
2606  R->wvhdl[j_in_R] =( int *)omAlloc((iv->length()+1)*sizeof(int));
2607  for (i=0; i<iv_len;i++)
2608  {
2609  R->wvhdl[j_in_R][i]=(*iv)[i];
2610  }
2611  R->wvhdl[j_in_R][i]=iv->length() - iv_len;
2612  //printf("ivlen:%d,iv->len:%d,mod:%d\n",iv_len,iv->length(),R->wvhdl[j][i]);
2613  for (; i<iv->length(); i++)
2614  {
2615  R->wvhdl[j_in_R][i+1]=(*iv)[i];
2616  }
2617  break;
2618  case ringorder_M:
2619  R->wvhdl[j_in_R] =( int *)omAlloc((iv->length())*sizeof(int));
2620  for (i=0; i<iv->length();i++) R->wvhdl[j_in_R][i]=(*iv)[i];
2621  R->block1[j_in_R]=si_max(R->block0[j_in_R],R->block0[j_in_R]+(int)sqrt((double)(iv->length()-1)));
2622  if (R->block1[j_in_R]>R->N)
2623  {
2624  WerrorS("ordering matrix too big");
2625  return TRUE;
2626  }
2627  break;
2628  case ringorder_ls:
2629  case ringorder_ds:
2630  case ringorder_Ds:
2631  case ringorder_rs:
2632  R->OrdSgn=-1;
2633  case ringorder_lp:
2634  case ringorder_dp:
2635  case ringorder_Dp:
2636  case ringorder_rp:
2637  break;
2638  case ringorder_S:
2639  break;
2640  case ringorder_c:
2641  case ringorder_C:
2642  R->block1[j_in_R]=R->block0[j_in_R]=0;
2643  break;
2644 
2645  case ringorder_s:
2646  R->block1[j_in_R]=R->block0[j_in_R]=(*iv)[0];
2647  rSetSyzComp(R->block0[j_in_R],R);
2648  break;
2649 
2650  case ringorder_IS:
2651  {
2652  R->block1[j_in_R] = R->block0[j_in_R] = 0;
2653  if( iv->length() > 0 )
2654  {
2655  const int s = (*iv)[0];
2656  assume( -2 < s && s < 2 );
2657  R->block1[j_in_R] = R->block0[j_in_R] = s;
2658  }
2659  break;
2660  }
2661  case 0:
2662  case ringorder_unspec:
2663  break;
2664  case ringorder_L: /* cannot happen */
2665  case ringorder_a64: /*not implemented */
2666  WerrorS("ring order not implemented");
2667  return TRUE;
2668  }
2669  delete iv;
2670  }
2671  else
2672  {
2673  PrintS(lString(vv));
2674  WerrorS("ordering name must be a (string,intvec)");
2675  return TRUE;
2676  }
2677  }
2678  // sanity check
2679  j_in_R=n-2;
2680  if ((R->order[j_in_R]==ringorder_c)
2681  || (R->order[j_in_R]==ringorder_C)
2682  || (R->order[j_in_R]==ringorder_unspec)) j_in_R--;
2683  if (R->block1[j_in_R] != R->N)
2684  {
2685  if (((R->order[j_in_R]==ringorder_dp) ||
2686  (R->order[j_in_R]==ringorder_ds) ||
2687  (R->order[j_in_R]==ringorder_Dp) ||
2688  (R->order[j_in_R]==ringorder_Ds) ||
2689  (R->order[j_in_R]==ringorder_rp) ||
2690  (R->order[j_in_R]==ringorder_rs) ||
2691  (R->order[j_in_R]==ringorder_lp) ||
2692  (R->order[j_in_R]==ringorder_ls))
2693  &&
2694  R->block0[j_in_R] <= R->N)
2695  {
2696  R->block1[j_in_R] = R->N;
2697  }
2698  else
2699  {
2700  Werror("ordering incomplete: size (%d) should be %d",R->block1[j_in_R],R->N);
2701  return TRUE;
2702  }
2703  }
2704  if (R->block0[j_in_R]>R->N)
2705  {
2706  Werror("not enough variables (%d) for ordering block %d, scanned so far:",R->N,j_in_R+1);
2707  for(int ii=0;ii<=j_in_R;ii++)
2708  Werror("ord[%d]: %s from v%d to v%d",ii+1,rSimpleOrdStr(R->order[ii]),R->block0[ii],R->block1[ii]);
2709  return TRUE;
2710  }
2711  if (check_comp)
2712  {
2713  BOOLEAN comp_order=FALSE;
2714  int jj;
2715  for(jj=0;jj<n;jj++)
2716  {
2717  if ((R->order[jj]==ringorder_c) ||
2718  (R->order[jj]==ringorder_C)) { comp_order=TRUE; break; }
2719  }
2720  if (!comp_order)
2721  {
2722  R->order=(rRingOrder_t*)omRealloc0Size(R->order,n*sizeof(rRingOrder_t),(n+1)*sizeof(rRingOrder_t));
2723  R->block0=(int*)omRealloc0Size(R->block0,n*sizeof(int),(n+1)*sizeof(int));
2724  R->block1=(int*)omRealloc0Size(R->block1,n*sizeof(int),(n+1)*sizeof(int));
2725  R->wvhdl=(int**)omRealloc0Size(R->wvhdl,n*sizeof(int_ptr),(n+1)*sizeof(int_ptr));
2726  R->order[n-1]=ringorder_C;
2727  R->block0[n-1]=0;
2728  R->block1[n-1]=0;
2729  R->wvhdl[n-1]=NULL;
2730  n++;
2731  }
2732  }
2733  }
2734  else
2735  {
2736  WerrorS("ordering must be given as `list`");
2737  return TRUE;
2738  }
2739  if (bitmask!=0) R->bitmask=bitmask*2;
2740  return FALSE;
2741 }
2742 
2743 ring rCompose(const lists L, const BOOLEAN check_comp, const long bitmask)
2744 {
2745  if ((L->nr!=3)
2746 #ifdef HAVE_PLURAL
2747  &&(L->nr!=5)
2748 #endif
2749  )
2750  return NULL;
2751  int is_gf_char=0;
2752  // 0: char/ cf - ring
2753  // 1: list (var)
2754  // 2: list (ord)
2755  // 3: qideal
2756  // possibly:
2757  // 4: C
2758  // 5: D
2759 
2760  ring R = (ring) omAlloc0Bin(sip_sring_bin);
2761 
2762  // ------------------------------------------------------------------
2763  // 0: char:
2764  if (L->m[0].Typ()==CRING_CMD)
2765  {
2766  R->cf=(coeffs)L->m[0].Data();
2767  R->cf->ref++;
2768  }
2769  else if (L->m[0].Typ()==INT_CMD)
2770  {
2771  int ch = (int)(long)L->m[0].Data();
2772  assume( ch >= 0 );
2773 
2774  if (ch == 0) // Q?
2775  R->cf = nInitChar(n_Q, NULL);
2776  else
2777  {
2778  int l = IsPrime(ch); // Zp?
2779  if( l != ch )
2780  {
2781  Warn("%d is invalid characteristic of ground field. %d is used.", ch, l);
2782  ch = l;
2783  }
2784  R->cf = nInitChar(n_Zp, (void*)(long)ch);
2785  }
2786  }
2787  else if (L->m[0].Typ()==LIST_CMD) // something complicated...
2788  {
2789  lists LL=(lists)L->m[0].Data();
2790 
2791 #ifdef HAVE_RINGS
2792  if (LL->m[0].Typ() == STRING_CMD) // 1st comes a string?
2793  {
2794  rComposeRing(LL, R); // Ring!?
2795  }
2796  else
2797 #endif
2798  if (LL->nr < 3)
2799  rComposeC(LL,R); // R, long_R, long_C
2800  else
2801  {
2802  if (LL->m[0].Typ()==INT_CMD)
2803  {
2804  int ch = (int)(long)LL->m[0].Data();
2805  while ((ch!=fftable[is_gf_char]) && (fftable[is_gf_char])) is_gf_char++;
2806  if (fftable[is_gf_char]==0) is_gf_char=-1;
2807 
2808  if(is_gf_char!= -1)
2809  {
2810  GFInfo param;
2811 
2812  param.GFChar = ch;
2813  param.GFDegree = 1;
2814  param.GFPar_name = (const char*)(((lists)(LL->m[1].Data()))->m[0].Data());
2815 
2816  // nfInitChar should be able to handle the case when ch is in fftables!
2817  R->cf = nInitChar(n_GF, (void*)&param);
2818  }
2819  }
2820 
2821  if( R->cf == NULL )
2822  {
2823  ring extRing = rCompose((lists)L->m[0].Data(),FALSE,0x7fff);
2824 
2825  if (extRing==NULL)
2826  {
2827  WerrorS("could not create the specified coefficient field");
2828  goto rCompose_err;
2829  }
2830 
2831  if( extRing->qideal != NULL ) // Algebraic extension
2832  {
2833  AlgExtInfo extParam;
2834 
2835  extParam.r = extRing;
2836 
2837  R->cf = nInitChar(n_algExt, (void*)&extParam);
2838  }
2839  else // Transcendental extension
2840  {
2841  TransExtInfo extParam;
2842  extParam.r = extRing;
2843  assume( extRing->qideal == NULL );
2844 
2845  R->cf = nInitChar(n_transExt, &extParam);
2846  }
2847  }
2848  }
2849  }
2850  else
2851  {
2852  WerrorS("coefficient field must be described by `int` or `list`");
2853  goto rCompose_err;
2854  }
2855 
2856  if( R->cf == NULL )
2857  {
2858  WerrorS("could not create coefficient field described by the input!");
2859  goto rCompose_err;
2860  }
2861 
2862  // ------------------------- VARS ---------------------------
2863  if (rComposeVar(L,R)) goto rCompose_err;
2864  // ------------------------ ORDER ------------------------------
2865  if (rComposeOrder(L,check_comp,R)) goto rCompose_err;
2866 
2867  // ------------------------ ??????? --------------------
2868 
2869  rRenameVars(R);
2870  if (bitmask!=0x7fff) R->bitmask=bitmask*2;
2871  rComplete(R);
2872 
2873  // ------------------------ Q-IDEAL ------------------------
2874 
2875  if (L->m[3].Typ()==IDEAL_CMD)
2876  {
2877  ideal q=(ideal)L->m[3].Data();
2878  if (q->m[0]!=NULL)
2879  {
2880  if (R->cf != currRing->cf) //->cf->ch!=currRing->cf->ch)
2881  {
2882  #if 0
2883  WerrorS("coefficient fields must be equal if q-ideal !=0");
2884  goto rCompose_err;
2885  #else
2886  ring orig_ring=currRing;
2887  rChangeCurrRing(R);
2888  int *perm=NULL;
2889  int *par_perm=NULL;
2890  int par_perm_size=0;
2891  nMapFunc nMap;
2892 
2893  if ((nMap=nSetMap(orig_ring->cf))==NULL)
2894  {
2895  if (rEqual(orig_ring,currRing))
2896  {
2897  nMap=n_SetMap(currRing->cf, currRing->cf);
2898  }
2899  else
2900  // Allow imap/fetch to be make an exception only for:
2901  if ( (rField_is_Q_a(orig_ring) && // Q(a..) -> Q(a..) || Q || Zp || Zp(a)
2904  ||
2905  (rField_is_Zp_a(orig_ring) && // Zp(a..) -> Zp(a..) || Zp
2906  (rField_is_Zp(currRing, rInternalChar(orig_ring)) ||
2907  rField_is_Zp_a(currRing, rInternalChar(orig_ring)))) )
2908  {
2909  par_perm_size=rPar(orig_ring);
2910 
2911 // if ((orig_ring->minpoly != NULL) || (orig_ring->qideal != NULL))
2912 // naSetChar(rInternalChar(orig_ring),orig_ring);
2913 // else ntSetChar(rInternalChar(orig_ring),orig_ring);
2914 
2915  nSetChar(currRing->cf);
2916  }
2917  else
2918  {
2919  WerrorS("coefficient fields must be equal if q-ideal !=0");
2920  goto rCompose_err;
2921  }
2922  }
2923  perm=(int *)omAlloc0((orig_ring->N+1)*sizeof(int));
2924  if (par_perm_size!=0)
2925  par_perm=(int *)omAlloc0(par_perm_size*sizeof(int));
2926  int i;
2927  #if 0
2928  // use imap:
2929  maFindPerm(orig_ring->names,orig_ring->N,orig_ring->parameter,orig_ring->P,
2930  currRing->names,currRing->N,currRing->parameter, currRing->P,
2931  perm,par_perm, currRing->ch);
2932  #else
2933  // use fetch
2934  if ((rPar(orig_ring)>0) && (rPar(currRing)==0))
2935  {
2936  for(i=si_min(rPar(orig_ring),rVar(currRing))-1;i>=0;i--) par_perm[i]=i+1;
2937  }
2938  else if (par_perm_size!=0)
2939  for(i=si_min(rPar(orig_ring),rPar(currRing))-1;i>=0;i--) par_perm[i]=-(i+1);
2940  for(i=si_min(orig_ring->N,rVar(currRing));i>0;i--) perm[i]=i;
2941  #endif
2942  ideal dest_id=idInit(IDELEMS(q),1);
2943  for(i=IDELEMS(q)-1; i>=0; i--)
2944  {
2945  dest_id->m[i]=p_PermPoly(q->m[i],perm,orig_ring, currRing,nMap,
2946  par_perm,par_perm_size);
2947  // PrintS("map:");pWrite(dest_id->m[i]);PrintLn();
2948  pTest(dest_id->m[i]);
2949  }
2950  R->qideal=dest_id;
2951  if (perm!=NULL)
2952  omFreeSize((ADDRESS)perm,(orig_ring->N+1)*sizeof(int));
2953  if (par_perm!=NULL)
2954  omFreeSize((ADDRESS)par_perm,par_perm_size*sizeof(int));
2955  rChangeCurrRing(orig_ring);
2956  #endif
2957  }
2958  else
2959  R->qideal=idrCopyR(q,currRing,R);
2960  }
2961  }
2962  else
2963  {
2964  WerrorS("q-ideal must be given as `ideal`");
2965  goto rCompose_err;
2966  }
2967 
2968 
2969  // ---------------------------------------------------------------
2970  #ifdef HAVE_PLURAL
2971  if (L->nr==5)
2972  {
2973  if (nc_CallPlural((matrix)L->m[4].Data(),
2974  (matrix)L->m[5].Data(),
2975  NULL,NULL,
2976  R,
2977  true, // !!!
2978  true, false,
2979  currRing, FALSE)) goto rCompose_err;
2980  // takes care about non-comm. quotient! i.e. calls "nc_SetupQuotient" due to last true
2981  }
2982  #endif
2983  return R;
2984 
2985 rCompose_err:
2986  if (R->N>0)
2987  {
2988  int i;
2989  if (R->names!=NULL)
2990  {
2991  i=R->N-1;
2992  while (i>=0) { omfree(R->names[i]); i--; }
2993  omFree(R->names);
2994  }
2995  }
2996  omfree(R->order);
2997  omfree(R->block0);
2998  omfree(R->block1);
2999  omfree(R->wvhdl);
3000  omFree(R);
3001  return NULL;
3002 }
3003 
3004 // from matpol.cc
3005 
3006 /*2
3007 * compute the jacobi matrix of an ideal
3008 */
3010 {
3011  int i,j;
3012  matrix result;
3013  ideal id=(ideal)a->Data();
3014 
3015  result =mpNew(IDELEMS(id),rVar(currRing));
3016  for (i=1; i<=IDELEMS(id); i++)
3017  {
3018  for (j=1; j<=rVar(currRing); j++)
3019  {
3020  MATELEM(result,i,j) = pDiff(id->m[i-1],j);
3021  }
3022  }
3023  res->data=(char *)result;
3024  return FALSE;
3025 }
3026 
3027 /*2
3028 * returns the Koszul-matrix of degree d of a vectorspace with dimension n
3029 * uses the first n entrees of id, if id <> NULL
3030 */
3032 {
3033  int n=(int)(long)b->Data();
3034  int d=(int)(long)c->Data();
3035  int k,l,sign,row,col;
3036  matrix result;
3037  ideal temp;
3038  BOOLEAN bo;
3039  poly p;
3040 
3041  if ((d>n) || (d<1) || (n<1))
3042  {
3043  res->data=(char *)mpNew(1,1);
3044  return FALSE;
3045  }
3046  int *choise = (int*)omAlloc(d*sizeof(int));
3047  if (id==NULL)
3048  temp=idMaxIdeal(1);
3049  else
3050  temp=(ideal)id->Data();
3051 
3052  k = binom(n,d);
3053  l = k*d;
3054  l /= n-d+1;
3055  result =mpNew(l,k);
3056  col = 1;
3057  idInitChoise(d,1,n,&bo,choise);
3058  while (!bo)
3059  {
3060  sign = 1;
3061  for (l=1;l<=d;l++)
3062  {
3063  if (choise[l-1]<=IDELEMS(temp))
3064  {
3065  p = pCopy(temp->m[choise[l-1]-1]);
3066  if (sign == -1) p = pNeg(p);
3067  sign *= -1;
3068  row = idGetNumberOfChoise(l-1,d,1,n,choise);
3069  MATELEM(result,row,col) = p;
3070  }
3071  }
3072  col++;
3073  idGetNextChoise(d,n,&bo,choise);
3074  }
3075  omFreeSize(choise,d*sizeof(int));
3076  if (id==NULL) idDelete(&temp);
3077 
3078  res->data=(char *)result;
3079  return FALSE;
3080 }
3081 
3082 // from syz1.cc
3083 /*2
3084 * read out the Betti numbers from resolution
3085 * (interpreter interface)
3086 */
3088 {
3089  syStrategy syzstr=(syStrategy)u->Data();
3090 
3091  BOOLEAN minim=(int)(long)w->Data();
3092  int row_shift=0;
3093  int add_row_shift=0;
3094  intvec *weights=NULL;
3095  intvec *ww=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
3096  if (ww!=NULL)
3097  {
3098  weights=ivCopy(ww);
3099  add_row_shift = ww->min_in();
3100  (*weights) -= add_row_shift;
3101  }
3102 
3103  res->data=(void *)syBettiOfComputation(syzstr,minim,&row_shift,weights);
3104  //row_shift += add_row_shift;
3105  //Print("row_shift=%d, add_row_shift=%d\n",row_shift,add_row_shift);
3106  atSet(res,omStrDup("rowShift"),(void*)(long)add_row_shift,INT_CMD);
3107 
3108  return FALSE;
3109 }
3111 {
3112  sleftv tmp;
3113  memset(&tmp,0,sizeof(tmp));
3114  tmp.rtyp=INT_CMD;
3115  tmp.data=(void *)1;
3116  return syBetti2(res,u,&tmp);
3117 }
3118 
3119 /*3
3120 * converts a resolution into a list of modules
3121 */
3122 lists syConvRes(syStrategy syzstr,BOOLEAN toDel,int add_row_shift)
3123 {
3124  resolvente fullres = syzstr->fullres;
3125  resolvente minres = syzstr->minres;
3126 
3127  const int length = syzstr->length;
3128 
3129  if ((fullres==NULL) && (minres==NULL))
3130  {
3131  if (syzstr->hilb_coeffs==NULL)
3132  { // La Scala
3133  fullres = syReorder(syzstr->res, length, syzstr);
3134  }
3135  else
3136  { // HRES
3137  minres = syReorder(syzstr->orderedRes, length, syzstr);
3138  syKillEmptyEntres(minres, length);
3139  }
3140  }
3141 
3142  resolvente tr;
3143  int typ0=IDEAL_CMD;
3144 
3145  if (minres!=NULL)
3146  tr = minres;
3147  else
3148  tr = fullres;
3149 
3150  resolvente trueres=NULL;
3151  intvec ** w=NULL;
3152 
3153  if (length>0)
3154  {
3155  trueres = (resolvente)omAlloc0((length)*sizeof(ideal));
3156  for (int i=length-1;i>=0;i--)
3157  {
3158  if (tr[i]!=NULL)
3159  {
3160  trueres[i] = idCopy(tr[i]);
3161  }
3162  }
3163  if ( id_RankFreeModule(trueres[0], currRing) > 0)
3164  typ0 = MODUL_CMD;
3165  if (syzstr->weights!=NULL)
3166  {
3167  w = (intvec**)omAlloc0(length*sizeof(intvec*));
3168  for (int i=length-1;i>=0;i--)
3169  {
3170  if (syzstr->weights[i]!=NULL) w[i] = ivCopy(syzstr->weights[i]);
3171  }
3172  }
3173  }
3174 
3175  lists li = liMakeResolv(trueres, length, syzstr->list_length,typ0,
3176  w, add_row_shift);
3177 
3178  if (toDel)
3179  syKillComputation(syzstr);
3180  else
3181  {
3182  if( fullres != NULL && syzstr->fullres == NULL )
3183  syzstr->fullres = fullres;
3184 
3185  if( minres != NULL && syzstr->minres == NULL )
3186  syzstr->minres = minres;
3187  }
3188  return li;
3189 }
3190 
3191 /*3
3192 * converts a list of modules into a resolution
3193 */
3195 {
3196  int typ0;
3198 
3199  resolvente fr = liFindRes(li,&(result->length),&typ0,&(result->weights));
3200  if (fr != NULL)
3201  {
3202 
3203  result->fullres = (resolvente)omAlloc0((result->length+1)*sizeof(ideal));
3204  for (int i=result->length-1;i>=0;i--)
3205  {
3206  if (fr[i]!=NULL)
3207  result->fullres[i] = idCopy(fr[i]);
3208  }
3209  result->list_length=result->length;
3210  omFreeSize((ADDRESS)fr,(result->length)*sizeof(ideal));
3211  }
3212  else
3213  {
3214  omFreeSize(result, sizeof(ssyStrategy));
3215  result = NULL;
3216  }
3217  return result;
3218 }
3219 
3220 /*3
3221 * converts a list of modules into a minimal resolution
3222 */
3224 {
3225  int typ0;
3227 
3228  resolvente fr = liFindRes(li,&(result->length),&typ0);
3229  result->minres = (resolvente)omAlloc0((result->length+1)*sizeof(ideal));
3230  for (int i=result->length-1;i>=0;i--)
3231  {
3232  if (fr[i]!=NULL)
3233  result->minres[i] = idCopy(fr[i]);
3234  }
3235  omFreeSize((ADDRESS)fr,(result->length)*sizeof(ideal));
3236  return result;
3237 }
3238 // from weight.cc
3240 {
3241  ideal F=(ideal)id->Data();
3242  intvec * iv = new intvec(rVar(currRing));
3243  polyset s;
3244  int sl, n, i;
3245  int *x;
3246 
3247  res->data=(char *)iv;
3248  s = F->m;
3249  sl = IDELEMS(F) - 1;
3250  n = rVar(currRing);
3251  double wNsqr = (double)2.0 / (double)n;
3253  x = (int * )omAlloc(2 * (n + 1) * sizeof(int));
3254  wCall(s, sl, x, wNsqr, currRing);
3255  for (i = n; i!=0; i--)
3256  (*iv)[i-1] = x[i + n + 1];
3257  omFreeSize((ADDRESS)x, 2 * (n + 1) * sizeof(int));
3258  return FALSE;
3259 }
3260 
3262 {
3263  res->data=(char *)id_QHomWeight((ideal)v->Data(), currRing);
3264  if (res->data==NULL)
3265  res->data=(char *)new intvec(rVar(currRing));
3266  return FALSE;
3267 }
3268 /*==============================================================*/
3269 // from clapsing.cc
3270 #if 0
3271 BOOLEAN jjIS_SQR_FREE(leftv res, leftv u)
3272 {
3273  BOOLEAN b=singclap_factorize((poly)(u->CopyD()), &v, 0);
3274  res->data=(void *)b;
3275 }
3276 #endif
3277 
3279 {
3280  res->data=singclap_resultant((poly)u->CopyD(),(poly)v->CopyD(),
3281  (poly)w->CopyD(), currRing);
3282  return errorreported;
3283 }
3284 
3286 {
3287  res->data=singclap_irrCharSeries((ideal)u->Data(), currRing);
3288  return (res->data==NULL);
3289 }
3290 
3291 // from semic.cc
3292 #ifdef HAVE_SPECTRUM
3293 
3294 // ----------------------------------------------------------------------------
3295 // Initialize a spectrum deep from a singular lists
3296 // ----------------------------------------------------------------------------
3297 
3298 void copy_deep( spectrum& spec, lists l )
3299 {
3300  spec.mu = (int)(long)(l->m[0].Data( ));
3301  spec.pg = (int)(long)(l->m[1].Data( ));
3302  spec.n = (int)(long)(l->m[2].Data( ));
3303 
3304  spec.copy_new( spec.n );
3305 
3306  intvec *num = (intvec*)l->m[3].Data( );
3307  intvec *den = (intvec*)l->m[4].Data( );
3308  intvec *mul = (intvec*)l->m[5].Data( );
3309 
3310  for( int i=0; i<spec.n; i++ )
3311  {
3312  spec.s[i] = (Rational)((*num)[i])/(Rational)((*den)[i]);
3313  spec.w[i] = (*mul)[i];
3314  }
3315 }
3316 
3317 // ----------------------------------------------------------------------------
3318 // singular lists constructor for spectrum
3319 // ----------------------------------------------------------------------------
3320 
3321 spectrum /*former spectrum::spectrum ( lists l )*/
3323 {
3324  spectrum result;
3325  copy_deep( result, l );
3326  return result;
3327 }
3328 
3329 // ----------------------------------------------------------------------------
3330 // generate a Singular lists from a spectrum
3331 // ----------------------------------------------------------------------------
3332 
3333 /* former spectrum::thelist ( void )*/
3335 {
3337 
3338  L->Init( 6 );
3339 
3340  intvec *num = new intvec( spec.n );
3341  intvec *den = new intvec( spec.n );
3342  intvec *mult = new intvec( spec.n );
3343 
3344  for( int i=0; i<spec.n; i++ )
3345  {
3346  (*num) [i] = spec.s[i].get_num_si( );
3347  (*den) [i] = spec.s[i].get_den_si( );
3348  (*mult)[i] = spec.w[i];
3349  }
3350 
3351  L->m[0].rtyp = INT_CMD; // milnor number
3352  L->m[1].rtyp = INT_CMD; // geometrical genus
3353  L->m[2].rtyp = INT_CMD; // # of spectrum numbers
3354  L->m[3].rtyp = INTVEC_CMD; // numerators
3355  L->m[4].rtyp = INTVEC_CMD; // denomiantors
3356  L->m[5].rtyp = INTVEC_CMD; // multiplicities
3357 
3358  L->m[0].data = (void*)(long)spec.mu;
3359  L->m[1].data = (void*)(long)spec.pg;
3360  L->m[2].data = (void*)(long)spec.n;
3361  L->m[3].data = (void*)num;
3362  L->m[4].data = (void*)den;
3363  L->m[5].data = (void*)mult;
3364 
3365  return L;
3366 }
3367 // from spectrum.cc
3368 // ----------------------------------------------------------------------------
3369 // print out an error message for a spectrum list
3370 // ----------------------------------------------------------------------------
3371 
3372 typedef enum
3373 {
3376 
3379 
3386 
3391 
3397 
3400 
3403 
3404 } semicState;
3405 
3406 void list_error( semicState state )
3407 {
3408  switch( state )
3409  {
3410  case semicListTooShort:
3411  WerrorS( "the list is too short" );
3412  break;
3413  case semicListTooLong:
3414  WerrorS( "the list is too long" );
3415  break;
3416 
3418  WerrorS( "first element of the list should be int" );
3419  break;
3421  WerrorS( "second element of the list should be int" );
3422  break;
3424  WerrorS( "third element of the list should be int" );
3425  break;
3427  WerrorS( "fourth element of the list should be intvec" );
3428  break;
3430  WerrorS( "fifth element of the list should be intvec" );
3431  break;
3433  WerrorS( "sixth element of the list should be intvec" );
3434  break;
3435 
3436  case semicListNNegative:
3437  WerrorS( "first element of the list should be positive" );
3438  break;
3440  WerrorS( "wrong number of numerators" );
3441  break;
3443  WerrorS( "wrong number of denominators" );
3444  break;
3446  WerrorS( "wrong number of multiplicities" );
3447  break;
3448 
3449  case semicListMuNegative:
3450  WerrorS( "the Milnor number should be positive" );
3451  break;
3452  case semicListPgNegative:
3453  WerrorS( "the geometrical genus should be nonnegative" );
3454  break;
3455  case semicListNumNegative:
3456  WerrorS( "all numerators should be positive" );
3457  break;
3458  case semicListDenNegative:
3459  WerrorS( "all denominators should be positive" );
3460  break;
3461  case semicListMulNegative:
3462  WerrorS( "all multiplicities should be positive" );
3463  break;
3464 
3465  case semicListNotSymmetric:
3466  WerrorS( "it is not symmetric" );
3467  break;
3469  WerrorS( "it is not monotonous" );
3470  break;
3471 
3472  case semicListMilnorWrong:
3473  WerrorS( "the Milnor number is wrong" );
3474  break;
3475  case semicListPGWrong:
3476  WerrorS( "the geometrical genus is wrong" );
3477  break;
3478 
3479  default:
3480  WerrorS( "unspecific error" );
3481  break;
3482  }
3483 }
3484 // ----------------------------------------------------------------------------
3485 // this is the main spectrum computation function
3486 // ----------------------------------------------------------------------------
3487 
3489 {
3499 };
3500 
3501 // from splist.cc
3502 // ----------------------------------------------------------------------------
3503 // Compute the spectrum of a spectrumPolyList
3504 // ----------------------------------------------------------------------------
3505 
3506 /* former spectrumPolyList::spectrum ( lists*, int) */
3508 {
3509  spectrumPolyNode **node = &speclist.root;
3511 
3512  poly f,tmp;
3513  int found,cmp;
3514 
3515  Rational smax( ( fast==0 ? 0 : rVar(currRing) ),
3516  ( fast==2 ? 2 : 1 ) );
3517 
3518  Rational weight_prev( 0,1 );
3519 
3520  int mu = 0; // the milnor number
3521  int pg = 0; // the geometrical genus
3522  int n = 0; // number of different spectral numbers
3523  int z = 0; // number of spectral number equal to smax
3524 
3525  while( (*node)!=(spectrumPolyNode*)NULL &&
3526  ( fast==0 || (*node)->weight<=smax ) )
3527  {
3528  // ---------------------------------------
3529  // determine the first normal form which
3530  // contains the monomial node->mon
3531  // ---------------------------------------
3532 
3533  found = FALSE;
3534  search = *node;
3535 
3536  while( search!=(spectrumPolyNode*)NULL && found==FALSE )
3537  {
3538  if( search->nf!=(poly)NULL )
3539  {
3540  f = search->nf;
3541 
3542  do
3543  {
3544  // --------------------------------
3545  // look for (*node)->mon in f
3546  // --------------------------------
3547 
3548  cmp = pCmp( (*node)->mon,f );
3549 
3550  if( cmp<0 )
3551  {
3552  f = pNext( f );
3553  }
3554  else if( cmp==0 )
3555  {
3556  // -----------------------------
3557  // we have found a normal form
3558  // -----------------------------
3559 
3560  found = TRUE;
3561 
3562  // normalize coefficient
3563 
3564  number inv = nInvers( pGetCoeff( f ) );
3565  search->nf=__p_Mult_nn( search->nf,inv,currRing );
3566  nDelete( &inv );
3567 
3568  // exchange normal forms
3569 
3570  tmp = (*node)->nf;
3571  (*node)->nf = search->nf;
3572  search->nf = tmp;
3573  }
3574  }
3575  while( cmp<0 && f!=(poly)NULL );
3576  }
3577  search = search->next;
3578  }
3579 
3580  if( found==FALSE )
3581  {
3582  // ------------------------------------------------
3583  // the weight of node->mon is a spectrum number
3584  // ------------------------------------------------
3585 
3586  mu++;
3587 
3588  if( (*node)->weight<=(Rational)1 ) pg++;
3589  if( (*node)->weight==smax ) z++;
3590  if( (*node)->weight>weight_prev ) n++;
3591 
3592  weight_prev = (*node)->weight;
3593  node = &((*node)->next);
3594  }
3595  else
3596  {
3597  // -----------------------------------------------
3598  // determine all other normal form which contain
3599  // the monomial node->mon
3600  // replace for node->mon its normal form
3601  // -----------------------------------------------
3602 
3603  while( search!=(spectrumPolyNode*)NULL )
3604  {
3605  if( search->nf!=(poly)NULL )
3606  {
3607  f = search->nf;
3608 
3609  do
3610  {
3611  // --------------------------------
3612  // look for (*node)->mon in f
3613  // --------------------------------
3614 
3615  cmp = pCmp( (*node)->mon,f );
3616 
3617  if( cmp<0 )
3618  {
3619  f = pNext( f );
3620  }
3621  else if( cmp==0 )
3622  {
3623  search->nf = pSub( search->nf,
3624  __pp_Mult_nn( (*node)->nf,pGetCoeff( f ),currRing ) );
3625  pNorm( search->nf );
3626  }
3627  }
3628  while( cmp<0 && f!=(poly)NULL );
3629  }
3630  search = search->next;
3631  }
3632  speclist.delete_node( node );
3633  }
3634 
3635  }
3636 
3637  // --------------------------------------------------------
3638  // fast computation exploits the symmetry of the spectrum
3639  // --------------------------------------------------------
3640 
3641  if( fast==2 )
3642  {
3643  mu = 2*mu - z;
3644  n = ( z > 0 ? 2*n - 1 : 2*n );
3645  }
3646 
3647  // --------------------------------------------------------
3648  // compute the spectrum numbers with their multiplicities
3649  // --------------------------------------------------------
3650 
3651  intvec *nom = new intvec( n );
3652  intvec *den = new intvec( n );
3653  intvec *mult = new intvec( n );
3654 
3655  int count = 0;
3656  int multiplicity = 1;
3657 
3658  for( search=speclist.root; search!=(spectrumPolyNode*)NULL &&
3659  ( fast==0 || search->weight<=smax );
3660  search=search->next )
3661  {
3662  if( search->next==(spectrumPolyNode*)NULL ||
3663  search->weight<search->next->weight )
3664  {
3665  (*nom) [count] = search->weight.get_num_si( );
3666  (*den) [count] = search->weight.get_den_si( );
3667  (*mult)[count] = multiplicity;
3668 
3669  multiplicity=1;
3670  count++;
3671  }
3672  else
3673  {
3674  multiplicity++;
3675  }
3676  }
3677 
3678  // --------------------------------------------------------
3679  // fast computation exploits the symmetry of the spectrum
3680  // --------------------------------------------------------
3681 
3682  if( fast==2 )
3683  {
3684  int n1,n2;
3685  for( n1=0, n2=n-1; n1<n2; n1++, n2-- )
3686  {
3687  (*nom) [n2] = rVar(currRing)*(*den)[n1]-(*nom)[n1];
3688  (*den) [n2] = (*den)[n1];
3689  (*mult)[n2] = (*mult)[n1];
3690  }
3691  }
3692 
3693  // -----------------------------------
3694  // test if the spectrum is symmetric
3695  // -----------------------------------
3696 
3697  if( fast==0 || fast==1 )
3698  {
3699  int symmetric=TRUE;
3700 
3701  for( int n1=0, n2=n-1 ; n1<n2 && symmetric==TRUE; n1++, n2-- )
3702  {
3703  if( (*mult)[n1]!=(*mult)[n2] ||
3704  (*den) [n1]!= (*den)[n2] ||
3705  (*nom)[n1]+(*nom)[n2]!=rVar(currRing)*(*den) [n1] )
3706  {
3707  symmetric = FALSE;
3708  }
3709  }
3710 
3711  if( symmetric==FALSE )
3712  {
3713  // ---------------------------------------------
3714  // the spectrum is not symmetric => degenerate
3715  // principal part
3716  // ---------------------------------------------
3717 
3718  *L = (lists)omAllocBin( slists_bin);
3719  (*L)->Init( 1 );
3720  (*L)->m[0].rtyp = INT_CMD; // milnor number
3721  (*L)->m[0].data = (void*)(long)mu;
3722 
3723  return spectrumDegenerate;
3724  }
3725  }
3726 
3727  *L = (lists)omAllocBin( slists_bin);
3728 
3729  (*L)->Init( 6 );
3730 
3731  (*L)->m[0].rtyp = INT_CMD; // milnor number
3732  (*L)->m[1].rtyp = INT_CMD; // geometrical genus
3733  (*L)->m[2].rtyp = INT_CMD; // number of spectrum values
3734  (*L)->m[3].rtyp = INTVEC_CMD; // nominators
3735  (*L)->m[4].rtyp = INTVEC_CMD; // denomiantors
3736  (*L)->m[5].rtyp = INTVEC_CMD; // multiplicities
3737 
3738  (*L)->m[0].data = (void*)(long)mu;
3739  (*L)->m[1].data = (void*)(long)pg;
3740  (*L)->m[2].data = (void*)(long)n;
3741  (*L)->m[3].data = (void*)nom;
3742  (*L)->m[4].data = (void*)den;
3743  (*L)->m[5].data = (void*)mult;
3744 
3745  return spectrumOK;
3746 }
3747 
3749 {
3750  int i;
3751 
3752  #ifdef SPECTRUM_DEBUG
3753  #ifdef SPECTRUM_PRINT
3754  #ifdef SPECTRUM_IOSTREAM
3755  cout << "spectrumCompute\n";
3756  if( fast==0 ) cout << " no optimization" << endl;
3757  if( fast==1 ) cout << " weight optimization" << endl;
3758  if( fast==2 ) cout << " symmetry optimization" << endl;
3759  #else
3760  fputs( "spectrumCompute\n",stdout );
3761  if( fast==0 ) fputs( " no optimization\n", stdout );
3762  if( fast==1 ) fputs( " weight optimization\n", stdout );
3763  if( fast==2 ) fputs( " symmetry optimization\n", stdout );
3764  #endif
3765  #endif
3766  #endif
3767 
3768  // ----------------------
3769  // check if h is zero
3770  // ----------------------
3771 
3772  if( h==(poly)NULL )
3773  {
3774  return spectrumZero;
3775  }
3776 
3777  // ----------------------------------
3778  // check if h has a constant term
3779  // ----------------------------------
3780 
3781  if( hasConstTerm( h, currRing ) )
3782  {
3783  return spectrumBadPoly;
3784  }
3785 
3786  // --------------------------------
3787  // check if h has a linear term
3788  // --------------------------------
3789 
3790  if( hasLinearTerm( h, currRing ) )
3791  {
3792  *L = (lists)omAllocBin( slists_bin);
3793  (*L)->Init( 1 );
3794  (*L)->m[0].rtyp = INT_CMD; // milnor number
3795  /* (*L)->m[0].data = (void*)0;a -- done by Init */
3796 
3797  return spectrumNoSingularity;
3798  }
3799 
3800  // ----------------------------------
3801  // compute the jacobi ideal of (h)
3802  // ----------------------------------
3803 
3804  ideal J = NULL;
3805  J = idInit( rVar(currRing),1 );
3806 
3807  #ifdef SPECTRUM_DEBUG
3808  #ifdef SPECTRUM_PRINT
3809  #ifdef SPECTRUM_IOSTREAM
3810  cout << "\n computing the Jacobi ideal...\n";
3811  #else
3812  fputs( "\n computing the Jacobi ideal...\n",stdout );
3813  #endif
3814  #endif
3815  #endif
3816 
3817  for( i=0; i<rVar(currRing); i++ )
3818  {
3819  J->m[i] = pDiff( h,i+1); //j );
3820 
3821  #ifdef SPECTRUM_DEBUG
3822  #ifdef SPECTRUM_PRINT
3823  #ifdef SPECTRUM_IOSTREAM
3824  cout << " ";
3825  #else
3826  fputs(" ", stdout );
3827  #endif
3828  pWrite( J->m[i] );
3829  #endif
3830  #endif
3831  }
3832 
3833  // --------------------------------------------
3834  // compute a standard basis stdJ of jac(h)
3835  // --------------------------------------------
3836 
3837  #ifdef SPECTRUM_DEBUG
3838  #ifdef SPECTRUM_PRINT
3839  #ifdef SPECTRUM_IOSTREAM
3840  cout << endl;
3841  cout << " computing a standard basis..." << endl;
3842  #else
3843  fputs( "\n", stdout );
3844  fputs( " computing a standard basis...\n", stdout );
3845  #endif
3846  #endif
3847  #endif
3848 
3849  ideal stdJ = kStd(J,currRing->qideal,isNotHomog,NULL);
3850  idSkipZeroes( stdJ );
3851 
3852  #ifdef SPECTRUM_DEBUG
3853  #ifdef SPECTRUM_PRINT
3854  for( i=0; i<IDELEMS(stdJ); i++ )
3855  {
3856  #ifdef SPECTRUM_IOSTREAM
3857  cout << " ";
3858  #else
3859  fputs( " ",stdout );
3860  #endif
3861 
3862  pWrite( stdJ->m[i] );
3863  }
3864  #endif
3865  #endif
3866 
3867  idDelete( &J );
3868 
3869  // ------------------------------------------
3870  // check if the h has a singularity
3871  // ------------------------------------------
3872 
3873  if( hasOne( stdJ, currRing ) )
3874  {
3875  // -------------------------------
3876  // h is smooth in the origin
3877  // return only the Milnor number
3878  // -------------------------------
3879 
3880  *L = (lists)omAllocBin( slists_bin);
3881  (*L)->Init( 1 );
3882  (*L)->m[0].rtyp = INT_CMD; // milnor number
3883  /* (*L)->m[0].data = (void*)0;a -- done by Init */
3884 
3885  return spectrumNoSingularity;
3886  }
3887 
3888  // ------------------------------------------
3889  // check if the singularity h is isolated
3890  // ------------------------------------------
3891 
3892  for( i=rVar(currRing); i>0; i-- )
3893  {
3894  if( hasAxis( stdJ,i, currRing )==FALSE )
3895  {
3896  return spectrumNotIsolated;
3897  }
3898  }
3899 
3900  // ------------------------------------------
3901  // compute the highest corner hc of stdJ
3902  // ------------------------------------------
3903 
3904  #ifdef SPECTRUM_DEBUG
3905  #ifdef SPECTRUM_PRINT
3906  #ifdef SPECTRUM_IOSTREAM
3907  cout << "\n computing the highest corner...\n";
3908  #else
3909  fputs( "\n computing the highest corner...\n", stdout );
3910  #endif
3911  #endif
3912  #endif
3913 
3914  poly hc = (poly)NULL;
3915 
3916  scComputeHC( stdJ,currRing->qideal, 0,hc );
3917 
3918  if( hc!=(poly)NULL )
3919  {
3920  pGetCoeff(hc) = nInit(1);
3921 
3922  for( i=rVar(currRing); i>0; i-- )
3923  {
3924  if( pGetExp( hc,i )>0 ) pDecrExp( hc,i );
3925  }
3926  pSetm( hc );
3927  }
3928  else
3929  {
3930  return spectrumNoHC;
3931  }
3932 
3933  #ifdef SPECTRUM_DEBUG
3934  #ifdef SPECTRUM_PRINT
3935  #ifdef SPECTRUM_IOSTREAM
3936  cout << " ";
3937  #else
3938  fputs( " ", stdout );
3939  #endif
3940  pWrite( hc );
3941  #endif
3942  #endif
3943 
3944  // ----------------------------------------
3945  // compute the Newton polygon nph of h
3946  // ----------------------------------------
3947 
3948  #ifdef SPECTRUM_DEBUG
3949  #ifdef SPECTRUM_PRINT
3950  #ifdef SPECTRUM_IOSTREAM
3951  cout << "\n computing the newton polygon...\n";
3952  #else
3953  fputs( "\n computing the newton polygon...\n", stdout );
3954  #endif
3955  #endif
3956  #endif
3957 
3958  newtonPolygon nph( h, currRing );
3959 
3960  #ifdef SPECTRUM_DEBUG
3961  #ifdef SPECTRUM_PRINT
3962  cout << nph;
3963  #endif
3964  #endif
3965 
3966  // -----------------------------------------------
3967  // compute the weight corner wc of (stdj,nph)
3968  // -----------------------------------------------
3969 
3970  #ifdef SPECTRUM_DEBUG
3971  #ifdef SPECTRUM_PRINT
3972  #ifdef SPECTRUM_IOSTREAM
3973  cout << "\n computing the weight corner...\n";
3974  #else
3975  fputs( "\n computing the weight corner...\n", stdout );
3976  #endif
3977  #endif
3978  #endif
3979 
3980  poly wc = ( fast==0 ? pCopy( hc ) :
3981  ( fast==1 ? computeWC( nph,(Rational)rVar(currRing), currRing ) :
3982  /* fast==2 */computeWC( nph,
3983  ((Rational)rVar(currRing))/(Rational)2, currRing ) ) );
3984 
3985  #ifdef SPECTRUM_DEBUG
3986  #ifdef SPECTRUM_PRINT
3987  #ifdef SPECTRUM_IOSTREAM
3988  cout << " ";
3989  #else
3990  fputs( " ", stdout );
3991  #endif
3992  pWrite( wc );
3993  #endif
3994  #endif
3995 
3996  // -------------
3997  // compute NF
3998  // -------------
3999 
4000  #ifdef SPECTRUM_DEBUG
4001  #ifdef SPECTRUM_PRINT
4002  #ifdef SPECTRUM_IOSTREAM
4003  cout << "\n computing NF...\n" << endl;
4004  #else
4005  fputs( "\n computing NF...\n", stdout );
4006  #endif
4007  #endif
4008  #endif
4009 
4010  spectrumPolyList NF( &nph );
4011 
4012  computeNF( stdJ,hc,wc,&NF, currRing );
4013 
4014  #ifdef SPECTRUM_DEBUG
4015  #ifdef SPECTRUM_PRINT
4016  cout << NF;
4017  #ifdef SPECTRUM_IOSTREAM
4018  cout << endl;
4019  #else
4020  fputs( "\n", stdout );
4021  #endif
4022  #endif
4023  #endif
4024 
4025  // ----------------------------
4026  // compute the spectrum of h
4027  // ----------------------------
4028 // spectrumState spectrumStateFromList( spectrumPolyList& speclist, lists *L, int fast );
4029 
4030  return spectrumStateFromList(NF, L, fast );
4031 }
4032 
4033 // ----------------------------------------------------------------------------
4034 // this procedure is called from the interpreter
4035 // ----------------------------------------------------------------------------
4036 // first = polynomial
4037 // result = list of spectrum numbers
4038 // ----------------------------------------------------------------------------
4039 
4041 {
4042  switch( state )
4043  {
4044  case spectrumZero:
4045  WerrorS( "polynomial is zero" );
4046  break;
4047  case spectrumBadPoly:
4048  WerrorS( "polynomial has constant term" );
4049  break;
4050  case spectrumNoSingularity:
4051  WerrorS( "not a singularity" );
4052  break;
4053  case spectrumNotIsolated:
4054  WerrorS( "the singularity is not isolated" );
4055  break;
4056  case spectrumNoHC:
4057  WerrorS( "highest corner cannot be computed" );
4058  break;
4059  case spectrumDegenerate:
4060  WerrorS( "principal part is degenerate" );
4061  break;
4062  case spectrumOK:
4063  break;
4064 
4065  default:
4066  WerrorS( "unknown error occurred" );
4067  break;
4068  }
4069 }
4070 
4072 {
4073  spectrumState state = spectrumOK;
4074 
4075  // -------------------
4076  // check consistency
4077  // -------------------
4078 
4079  // check for a local ring
4080 
4081  if( !ringIsLocal(currRing ) )
4082  {
4083  WerrorS( "only works for local orderings" );
4084  state = spectrumWrongRing;
4085  }
4086 
4087  // no quotient rings are allowed
4088 
4089  else if( currRing->qideal != NULL )
4090  {
4091  WerrorS( "does not work in quotient rings" );
4092  state = spectrumWrongRing;
4093  }
4094  else
4095  {
4096  lists L = (lists)NULL;
4097  int flag = 1; // weight corner optimization is safe
4098 
4099  state = spectrumCompute( (poly)first->Data( ),&L,flag );
4100 
4101  if( state==spectrumOK )
4102  {
4103  result->rtyp = LIST_CMD;
4104  result->data = (char*)L;
4105  }
4106  else
4107  {
4108  spectrumPrintError(state);
4109  }
4110  }
4111 
4112  return (state!=spectrumOK);
4113 }
4114 
4115 // ----------------------------------------------------------------------------
4116 // this procedure is called from the interpreter
4117 // ----------------------------------------------------------------------------
4118 // first = polynomial
4119 // result = list of spectrum numbers
4120 // ----------------------------------------------------------------------------
4121 
4123 {
4124  spectrumState state = spectrumOK;
4125 
4126  // -------------------
4127  // check consistency
4128  // -------------------
4129 
4130  // check for a local polynomial ring
4131 
4132  if( currRing->OrdSgn != -1 )
4133  // ?? HS: the test above is also true for k[x][[y]], k[[x]][y]
4134  // or should we use:
4135  //if( !ringIsLocal( ) )
4136  {
4137  WerrorS( "only works for local orderings" );
4138  state = spectrumWrongRing;
4139  }
4140  else if( currRing->qideal != NULL )
4141  {
4142  WerrorS( "does not work in quotient rings" );
4143  state = spectrumWrongRing;
4144  }
4145  else
4146  {
4147  lists L = (lists)NULL;
4148  int flag = 2; // symmetric optimization
4149 
4150  state = spectrumCompute( (poly)first->Data( ),&L,flag );
4151 
4152  if( state==spectrumOK )
4153  {
4154  result->rtyp = LIST_CMD;
4155  result->data = (char*)L;
4156  }
4157  else
4158  {
4159  spectrumPrintError(state);
4160  }
4161  }
4162 
4163  return (state!=spectrumOK);
4164 }
4165 
4166 // ----------------------------------------------------------------------------
4167 // check if a list is a spectrum
4168 // check for:
4169 // list has 6 elements
4170 // 1st element is int (mu=Milnor number)
4171 // 2nd element is int (pg=geometrical genus)
4172 // 3rd element is int (n =number of different spectrum numbers)
4173 // 4th element is intvec (num=numerators)
4174 // 5th element is intvec (den=denomiantors)
4175 // 6th element is intvec (mul=multiplicities)
4176 // exactly n numerators
4177 // exactly n denominators
4178 // exactly n multiplicities
4179 // mu>0
4180 // pg>=0
4181 // n>0
4182 // num>0
4183 // den>0
4184 // mul>0
4185 // symmetriy with respect to numberofvariables/2
4186 // monotony
4187 // mu = sum of all multiplicities
4188 // pg = sum of all multiplicities where num/den<=1
4189 // ----------------------------------------------------------------------------
4190 
4192 {
4193  // -------------------
4194  // check list length
4195  // -------------------
4196 
4197  if( l->nr < 5 )
4198  {
4199  return semicListTooShort;
4200  }
4201  else if( l->nr > 5 )
4202  {
4203  return semicListTooLong;
4204  }
4205 
4206  // -------------
4207  // check types
4208  // -------------
4209 
4210  if( l->m[0].rtyp != INT_CMD )
4211  {
4213  }
4214  else if( l->m[1].rtyp != INT_CMD )
4215  {
4217  }
4218  else if( l->m[2].rtyp != INT_CMD )
4219  {
4221  }
4222  else if( l->m[3].rtyp != INTVEC_CMD )
4223  {
4225  }
4226  else if( l->m[4].rtyp != INTVEC_CMD )
4227  {
4229  }
4230  else if( l->m[5].rtyp != INTVEC_CMD )
4231  {
4233  }
4234 
4235  // -------------------------
4236  // check number of entries
4237  // -------------------------
4238 
4239  int mu = (int)(long)(l->m[0].Data( ));
4240  int pg = (int)(long)(l->m[1].Data( ));
4241  int n = (int)(long)(l->m[2].Data( ));
4242 
4243  if( n <= 0 )
4244  {
4245  return semicListNNegative;
4246  }
4247 
4248  intvec *num = (intvec*)l->m[3].Data( );
4249  intvec *den = (intvec*)l->m[4].Data( );
4250  intvec *mul = (intvec*)l->m[5].Data( );
4251 
4252  if( n != num->length( ) )
4253  {
4255  }
4256  else if( n != den->length( ) )
4257  {
4259  }
4260  else if( n != mul->length( ) )
4261  {
4263  }
4264 
4265  // --------
4266  // values
4267  // --------
4268 
4269  if( mu <= 0 )
4270  {
4271  return semicListMuNegative;
4272  }
4273  if( pg < 0 )
4274  {
4275  return semicListPgNegative;
4276  }
4277 
4278  int i;
4279 
4280  for( i=0; i<n; i++ )
4281  {
4282  if( (*num)[i] <= 0 )
4283  {
4284  return semicListNumNegative;
4285  }
4286  if( (*den)[i] <= 0 )
4287  {
4288  return semicListDenNegative;
4289  }
4290  if( (*mul)[i] <= 0 )
4291  {
4292  return semicListMulNegative;
4293  }
4294  }
4295 
4296  // ----------------
4297  // check symmetry
4298  // ----------------
4299 
4300  int j;
4301 
4302  for( i=0, j=n-1; i<=j; i++,j-- )
4303  {
4304  if( (*num)[i] != rVar(currRing)*((*den)[i]) - (*num)[j] ||
4305  (*den)[i] != (*den)[j] ||
4306  (*mul)[i] != (*mul)[j] )
4307  {
4308  return semicListNotSymmetric;
4309  }
4310  }
4311 
4312  // ----------------
4313  // check monotony
4314  // ----------------
4315 
4316  for( i=0, j=1; i<n/2; i++,j++ )
4317  {
4318  if( (*num)[i]*(*den)[j] >= (*num)[j]*(*den)[i] )
4319  {
4320  return semicListNotMonotonous;
4321  }
4322  }
4323 
4324  // ---------------------
4325  // check Milnor number
4326  // ---------------------
4327 
4328  for( mu=0, i=0; i<n; i++ )
4329  {
4330  mu += (*mul)[i];
4331  }
4332 
4333  if( mu != (int)(long)(l->m[0].Data( )) )
4334  {
4335  return semicListMilnorWrong;
4336  }
4337 
4338  // -------------------------
4339  // check geometrical genus
4340  // -------------------------
4341 
4342  for( pg=0, i=0; i<n; i++ )
4343  {
4344  if( (*num)[i]<=(*den)[i] )
4345  {
4346  pg += (*mul)[i];
4347  }
4348  }
4349 
4350  if( pg != (int)(long)(l->m[1].Data( )) )
4351  {
4352  return semicListPGWrong;
4353  }
4354 
4355  return semicOK;
4356 }
4357 
4358 // ----------------------------------------------------------------------------
4359 // this procedure is called from the interpreter
4360 // ----------------------------------------------------------------------------
4361 // first = list of spectrum numbers
4362 // second = list of spectrum numbers
4363 // result = sum of the two lists
4364 // ----------------------------------------------------------------------------
4365 
4367 {
4368  semicState state;
4369 
4370  // -----------------
4371  // check arguments
4372  // -----------------
4373 
4374  lists l1 = (lists)first->Data( );
4375  lists l2 = (lists)second->Data( );
4376 
4377  if( (state=list_is_spectrum( l1 )) != semicOK )
4378  {
4379  WerrorS( "first argument is not a spectrum:" );
4380  list_error( state );
4381  }
4382  else if( (state=list_is_spectrum( l2 )) != semicOK )
4383  {
4384  WerrorS( "second argument is not a spectrum:" );
4385  list_error( state );
4386  }
4387  else
4388  {
4389  spectrum s1= spectrumFromList ( l1 );
4390  spectrum s2= spectrumFromList ( l2 );
4391  spectrum sum( s1+s2 );
4392 
4393  result->rtyp = LIST_CMD;
4394  result->data = (char*)(getList(sum));
4395  }
4396 
4397  return (state!=semicOK);
4398 }
4399 
4400 // ----------------------------------------------------------------------------
4401 // this procedure is called from the interpreter
4402 // ----------------------------------------------------------------------------
4403 // first = list of spectrum numbers
4404 // second = integer
4405 // result = the multiple of the first list by the second factor
4406 // ----------------------------------------------------------------------------
4407 
4409 {
4410  semicState state;
4411 
4412  // -----------------
4413  // check arguments
4414  // -----------------
4415 
4416  lists l = (lists)first->Data( );
4417  int k = (int)(long)second->Data( );
4418 
4419  if( (state=list_is_spectrum( l ))!=semicOK )
4420  {
4421  WerrorS( "first argument is not a spectrum" );
4422  list_error( state );
4423  }
4424  else if( k < 0 )
4425  {
4426  WerrorS( "second argument should be positive" );
4427  state = semicMulNegative;
4428  }
4429  else
4430  {
4432  spectrum product( k*s );
4433 
4434  result->rtyp = LIST_CMD;
4435  result->data = (char*)getList(product);
4436  }
4437 
4438  return (state!=semicOK);
4439 }
4440 
4441 // ----------------------------------------------------------------------------
4442 // this procedure is called from the interpreter
4443 // ----------------------------------------------------------------------------
4444 // first = list of spectrum numbers
4445 // second = list of spectrum numbers
4446 // result = semicontinuity index
4447 // ----------------------------------------------------------------------------
4448 
4450 {
4451  semicState state;
4452  BOOLEAN qh=(((int)(long)w->Data())==1);
4453 
4454  // -----------------
4455  // check arguments
4456  // -----------------
4457 
4458  lists l1 = (lists)u->Data( );
4459  lists l2 = (lists)v->Data( );
4460 
4461  if( (state=list_is_spectrum( l1 ))!=semicOK )
4462  {
4463  WerrorS( "first argument is not a spectrum" );
4464  list_error( state );
4465  }
4466  else if( (state=list_is_spectrum( l2 ))!=semicOK )
4467  {
4468  WerrorS( "second argument is not a spectrum" );
4469  list_error( state );
4470  }
4471  else
4472  {
4473  spectrum s1= spectrumFromList( l1 );
4474  spectrum s2= spectrumFromList( l2 );
4475 
4476  res->rtyp = INT_CMD;
4477  if (qh)
4478  res->data = (void*)(long)(s1.mult_spectrumh( s2 ));
4479  else
4480  res->data = (void*)(long)(s1.mult_spectrum( s2 ));
4481  }
4482 
4483  // -----------------
4484  // check status
4485  // -----------------
4486 
4487  return (state!=semicOK);
4488 }
4490 {
4491  sleftv tmp;
4492  memset(&tmp,0,sizeof(tmp));
4493  tmp.rtyp=INT_CMD;
4494  /* tmp.data = (void *)0; -- done by memset */
4495 
4496  return semicProc3(res,u,v,&tmp);
4497 }
4498 
4499 #endif
4500 
4502 {
4503  res->data= (void*)loNewtonPolytope( (ideal)arg1->Data() );
4504  return FALSE;
4505 }
4506 
4508 {
4509  if ( !(rField_is_long_R(currRing)) )
4510  {
4511  WerrorS("Ground field not implemented!");
4512  return TRUE;
4513  }
4514 
4515  simplex * LP;
4516  matrix m;
4517 
4518  leftv v= args;
4519  if ( v->Typ() != MATRIX_CMD ) // 1: matrix
4520  return TRUE;
4521  else
4522  m= (matrix)(v->CopyD());
4523 
4524  LP = new simplex(MATROWS(m),MATCOLS(m));
4525  LP->mapFromMatrix(m);
4526 
4527  v= v->next;
4528  if ( v->Typ() != INT_CMD ) // 2: m = number of constraints
4529  return TRUE;
4530  else
4531  LP->m= (int)(long)(v->Data());
4532 
4533  v= v->next;
4534  if ( v->Typ() != INT_CMD ) // 3: n = number of variables
4535  return TRUE;
4536  else
4537  LP->n= (int)(long)(v->Data());
4538 
4539  v= v->next;
4540  if ( v->Typ() != INT_CMD ) // 4: m1 = number of <= constraints
4541  return TRUE;
4542  else
4543  LP->m1= (int)(long)(v->Data());
4544 
4545  v= v->next;
4546  if ( v->Typ() != INT_CMD ) // 5: m2 = number of >= constraints
4547  return TRUE;
4548  else
4549  LP->m2= (int)(long)(v->Data());
4550 
4551  v= v->next;
4552  if ( v->Typ() != INT_CMD ) // 6: m3 = number of == constraints
4553  return TRUE;
4554  else
4555  LP->m3= (int)(long)(v->Data());
4556 
4557 #ifdef mprDEBUG_PROT
4558  Print("m (constraints) %d\n",LP->m);
4559  Print("n (columns) %d\n",LP->n);
4560  Print("m1 (<=) %d\n",LP->m1);
4561  Print("m2 (>=) %d\n",LP->m2);
4562  Print("m3 (==) %d\n",LP->m3);
4563 #endif
4564 
4565  LP->compute();
4566 
4567  lists lres= (lists)omAlloc( sizeof(slists) );
4568  lres->Init( 6 );
4569 
4570  lres->m[0].rtyp= MATRIX_CMD; // output matrix
4571  lres->m[0].data=(void*)LP->mapToMatrix(m);
4572 
4573  lres->m[1].rtyp= INT_CMD; // found a solution?
4574  lres->m[1].data=(void*)(long)LP->icase;
4575 
4576  lres->m[2].rtyp= INTVEC_CMD;
4577  lres->m[2].data=(void*)LP->posvToIV();
4578 
4579  lres->m[3].rtyp= INTVEC_CMD;
4580  lres->m[3].data=(void*)LP->zrovToIV();
4581 
4582  lres->m[4].rtyp= INT_CMD;
4583  lres->m[4].data=(void*)(long)LP->m;
4584 
4585  lres->m[5].rtyp= INT_CMD;
4586  lres->m[5].data=(void*)(long)LP->n;
4587 
4588  res->data= (void*)lres;
4589 
4590  return FALSE;
4591 }
4592 
4594 {
4595  ideal gls = (ideal)(arg1->Data());
4596  int imtype= (int)(long)arg2->Data();
4597 
4598  uResultant::resMatType mtype= determineMType( imtype );
4599 
4600  // check input ideal ( = polynomial system )
4601  if ( mprIdealCheck( gls, arg1->Name(), mtype, true ) != mprOk )
4602  {
4603  return TRUE;
4604  }
4605 
4606  uResultant *resMat= new uResultant( gls, mtype, false );
4607  if (resMat!=NULL)
4608  {
4609  res->rtyp = MODUL_CMD;
4610  res->data= (void*)resMat->accessResMat()->getMatrix();
4611  if (!errorreported) delete resMat;
4612  }
4613  return errorreported;
4614 }
4615 
4617 {
4618 
4619  poly gls;
4620  gls= (poly)(arg1->Data());
4621  int howclean= (int)(long)arg3->Data();
4622 
4623  if ( !(rField_is_R(currRing) ||
4624  rField_is_Q(currRing) ||
4627  {
4628  WerrorS("Ground field not implemented!");
4629  return TRUE;
4630  }
4631 
4634  {
4635  unsigned long int ii = (unsigned long int)arg2->Data();
4636  setGMPFloatDigits( ii, ii );
4637  }
4638 
4639  if ( gls == NULL || pIsConstant( gls ) )
4640  {
4641  WerrorS("Input polynomial is constant!");
4642  return TRUE;
4643  }
4644 
4645  int ldummy;
4646  int deg= currRing->pLDeg( gls, &ldummy, currRing );
4647  int i,vpos=0;
4648  poly piter;
4649  lists elist;
4650  lists rlist;
4651 
4652  elist= (lists)omAlloc( sizeof(slists) );
4653  elist->Init( 0 );
4654 
4655  if ( rVar(currRing) > 1 )
4656  {
4657  piter= gls;
4658  for ( i= 1; i <= rVar(currRing); i++ )
4659  if ( pGetExp( piter, i ) )
4660  {
4661  vpos= i;
4662  break;
4663  }
4664  while ( piter )
4665  {
4666  for ( i= 1; i <= rVar(currRing); i++ )
4667  if ( (vpos != i) && (pGetExp( piter, i ) != 0) )
4668  {
4669  WerrorS("The input polynomial must be univariate!");
4670  return TRUE;
4671  }
4672  pIter( piter );
4673  }
4674  }
4675 
4676  rootContainer * roots= new rootContainer();
4677  number * pcoeffs= (number *)omAlloc( (deg+1) * sizeof( number ) );
4678  piter= gls;
4679  for ( i= deg; i >= 0; i-- )
4680  {
4681  if ( piter && pTotaldegree(piter) == i )
4682  {
4683  pcoeffs[i]= nCopy( pGetCoeff( piter ) );
4684  //nPrint( pcoeffs[i] );PrintS(" ");
4685  pIter( piter );
4686  }
4687  else
4688  {
4689  pcoeffs[i]= nInit(0);
4690  }
4691  }
4692 
4693 #ifdef mprDEBUG_PROT
4694  for (i=deg; i >= 0; i--)
4695  {
4696  nPrint( pcoeffs[i] );PrintS(" ");
4697  }
4698  PrintLn();
4699 #endif
4700 
4701  roots->fillContainer( pcoeffs, NULL, 1, deg, rootContainer::onepoly, 1 );
4702  roots->solver( howclean );
4703 
4704  int elem= roots->getAnzRoots();
4705  char *dummy;
4706  int j;
4707 
4708  rlist= (lists)omAlloc( sizeof(slists) );
4709  rlist->Init( elem );
4710 
4712  {
4713  for ( j= 0; j < elem; j++ )
4714  {
4715  rlist->m[j].rtyp=NUMBER_CMD;
4716  rlist->m[j].data=(void *)nCopy((number)(roots->getRoot(j)));
4717  //rlist->m[j].data=(void *)(number)(roots->getRoot(j));
4718  }
4719  }
4720  else
4721  {
4722  for ( j= 0; j < elem; j++ )
4723  {
4724  dummy = complexToStr( (*roots)[j], gmp_output_digits, currRing->cf );
4725  rlist->m[j].rtyp=STRING_CMD;
4726  rlist->m[j].data=(void *)dummy;
4727  }
4728  }
4729 
4730  elist->Clean();
4731  //omFreeSize( (ADDRESS) elist, sizeof(slists) );
4732 
4733  // this is (via fillContainer) the same data as in root
4734  //for ( i= deg; i >= 0; i-- ) nDelete( &pcoeffs[i] );
4735  //omFreeSize( (ADDRESS) pcoeffs, (deg+1) * sizeof( number ) );
4736 
4737  delete roots;
4738 
4739  res->rtyp= LIST_CMD;
4740  res->data= (void*)rlist;
4741 
4742  return FALSE;
4743 }
4744 
4746 {
4747  int i;
4748  ideal p,w;
4749  p= (ideal)arg1->Data();
4750  w= (ideal)arg2->Data();
4751 
4752  // w[0] = f(p^0)
4753  // w[1] = f(p^1)
4754  // ...
4755  // p can be a vector of numbers (multivariate polynom)
4756  // or one number (univariate polynom)
4757  // tdg = deg(f)
4758 
4759  int n= IDELEMS( p );
4760  int m= IDELEMS( w );
4761  int tdg= (int)(long)arg3->Data();
4762 
4763  res->data= (void*)NULL;
4764 
4765  // check the input
4766  if ( tdg < 1 )
4767  {
4768  WerrorS("Last input parameter must be > 0!");
4769  return TRUE;
4770  }
4771  if ( n != rVar(currRing) )
4772  {
4773  Werror("Size of first input ideal must be equal to %d!",rVar(currRing));
4774  return TRUE;
4775  }
4776  if ( m != (int)pow((double)tdg+1,(double)n) )
4777  {
4778  Werror("Size of second input ideal must be equal to %d!",
4779  (int)pow((double)tdg+1,(double)n));
4780  return TRUE;
4781  }
4782  if ( !(rField_is_Q(currRing) /* ||
4783  rField_is_R() || rField_is_long_R() ||
4784  rField_is_long_C()*/ ) )
4785  {
4786  WerrorS("Ground field not implemented!");
4787  return TRUE;
4788  }
4789 
4790  number tmp;
4791  number *pevpoint= (number *)omAlloc( n * sizeof( number ) );
4792  for ( i= 0; i < n; i++ )
4793  {
4794  pevpoint[i]=nInit(0);
4795  if ( (p->m)[i] )
4796  {
4797  tmp = pGetCoeff( (p->m)[i] );
4798  if ( nIsZero(tmp) || nIsOne(tmp) || nIsMOne(tmp) )
4799  {
4800  omFreeSize( (ADDRESS)pevpoint, n * sizeof( number ) );
4801  WerrorS("Elements of first input ideal must not be equal to -1, 0, 1!");
4802  return TRUE;
4803  }
4804  } else tmp= NULL;
4805  if ( !nIsZero(tmp) )
4806  {
4807  if ( !pIsConstant((p->m)[i]))
4808  {
4809  omFreeSize( (ADDRESS)pevpoint, n * sizeof( number ) );
4810  WerrorS("Elements of first input ideal must be numbers!");
4811  return TRUE;
4812  }
4813  pevpoint[i]= nCopy( tmp );
4814  }
4815  }
4816 
4817  number *wresults= (number *)omAlloc( m * sizeof( number ) );
4818  for ( i= 0; i < m; i++ )
4819  {
4820  wresults[i]= nInit(0);
4821  if ( (w->m)[i] && !nIsZero(pGetCoeff((w->m)[i])) )
4822  {
4823  if ( !pIsConstant((w->m)[i]))
4824  {
4825  omFreeSize( (ADDRESS)pevpoint, n * sizeof( number ) );
4826  omFreeSize( (ADDRESS)wresults, m * sizeof( number ) );
4827  WerrorS("Elements of second input ideal must be numbers!");
4828  return TRUE;
4829  }
4830  wresults[i]= nCopy(pGetCoeff((w->m)[i]));
4831  }
4832  }
4833 
4834  vandermonde vm( m, n, tdg, pevpoint, FALSE );
4835  number *ncpoly= vm.interpolateDense( wresults );
4836  // do not free ncpoly[]!!
4837  poly rpoly= vm.numvec2poly( ncpoly );
4838 
4839  omFreeSize( (ADDRESS)pevpoint, n * sizeof( number ) );
4840  omFreeSize( (ADDRESS)wresults, m * sizeof( number ) );
4841 
4842  res->data= (void*)rpoly;
4843  return FALSE;
4844 }
4845 
4847 {
4848  leftv v= args;
4849 
4850  ideal gls;
4851  int imtype;
4852  int howclean;
4853 
4854  // get ideal
4855  if ( v->Typ() != IDEAL_CMD )
4856  return TRUE;
4857  else gls= (ideal)(v->Data());
4858  v= v->next;
4859 
4860  // get resultant matrix type to use (0,1)
4861  if ( v->Typ() != INT_CMD )
4862  return TRUE;
4863  else imtype= (int)(long)v->Data();
4864  v= v->next;
4865 
4866  if (imtype==0)
4867  {
4868  ideal test_id=idInit(1,1);
4869  int j;
4870  for(j=IDELEMS(gls)-1;j>=0;j--)
4871  {
4872  if (gls->m[j]!=NULL)
4873  {
4874  test_id->m[0]=gls->m[j];
4875  intvec *dummy_w=id_QHomWeight(test_id, currRing);
4876  if (dummy_w!=NULL)
4877  {
4878  WerrorS("Newton polytope not of expected dimension");
4879  delete dummy_w;
4880  return TRUE;
4881  }
4882  }
4883  }
4884  }
4885 
4886  // get and set precision in digits ( > 0 )
4887  if ( v->Typ() != INT_CMD )
4888  return TRUE;
4889  else if ( !(rField_is_R(currRing) || rField_is_long_R(currRing) || \
4891  {
4892  unsigned long int ii=(unsigned long int)v->Data();
4893  setGMPFloatDigits( ii, ii );
4894  }
4895  v= v->next;
4896 
4897  // get interpolation steps (0,1,2)
4898  if ( v->Typ() != INT_CMD )
4899  return TRUE;
4900  else howclean= (int)(long)v->Data();
4901 
4902  uResultant::resMatType mtype= determineMType( imtype );
4903  int i,count;
4904  lists listofroots= NULL;
4905  number smv= NULL;
4906  BOOLEAN interpolate_det= (mtype==uResultant::denseResMat)?TRUE:FALSE;
4907 
4908  //emptylist= (lists)omAlloc( sizeof(slists) );
4909  //emptylist->Init( 0 );
4910 
4911  //res->rtyp = LIST_CMD;
4912  //res->data= (void *)emptylist;
4913 
4914  // check input ideal ( = polynomial system )
4915  if ( mprIdealCheck( gls, args->Name(), mtype ) != mprOk )
4916  {
4917  return TRUE;
4918  }
4919 
4920  uResultant * ures;
4921  rootContainer ** iproots;
4922  rootContainer ** muiproots;
4923  rootArranger * arranger;
4924 
4925  // main task 1: setup of resultant matrix
4926  ures= new uResultant( gls, mtype );
4927  if ( ures->accessResMat()->initState() != resMatrixBase::ready )
4928  {
4929  WerrorS("Error occurred during matrix setup!");
4930  return TRUE;
4931  }
4932 
4933  // if dense resultant, check if minor nonsingular
4934  if ( mtype == uResultant::denseResMat )
4935  {
4936  smv= ures->accessResMat()->getSubDet();
4937 #ifdef mprDEBUG_PROT
4938  PrintS("// Determinant of submatrix: ");nPrint(smv);PrintLn();
4939 #endif
4940  if ( nIsZero(smv) )
4941  {
4942  WerrorS("Unsuitable input ideal: Minor of resultant matrix is singular!");
4943  return TRUE;
4944  }
4945  }
4946 
4947  // main task 2: Interpolate specialized resultant polynomials
4948  if ( interpolate_det )
4949  iproots= ures->interpolateDenseSP( false, smv );
4950  else
4951  iproots= ures->specializeInU( false, smv );
4952 
4953  // main task 3: Interpolate specialized resultant polynomials
4954  if ( interpolate_det )
4955  muiproots= ures->interpolateDenseSP( true, smv );
4956  else
4957  muiproots= ures->specializeInU( true, smv );
4958 
4959 #ifdef mprDEBUG_PROT
4960  int c= iproots[0]->getAnzElems();
4961  for (i=0; i < c; i++) pWrite(iproots[i]->getPoly());
4962  c= muiproots[0]->getAnzElems();
4963  for (i=0; i < c; i++) pWrite(muiproots[i]->getPoly());
4964 #endif
4965 
4966  // main task 4: Compute roots of specialized polys and match them up
4967  arranger= new rootArranger( iproots, muiproots, howclean );
4968  arranger->solve_all();
4969 
4970  // get list of roots
4971  if ( arranger->success() )
4972  {
4973  arranger->arrange();
4974  listofroots= listOfRoots(arranger, gmp_output_digits );
4975  }
4976  else
4977  {
4978  WerrorS("Solver was unable to find any roots!");
4979  return TRUE;
4980  }
4981 
4982  // free everything
4983  count= iproots[0]->getAnzElems();
4984  for (i=0; i < count; i++) delete iproots[i];
4985  omFreeSize( (ADDRESS) iproots, count * sizeof(rootContainer*) );
4986  count= muiproots[0]->getAnzElems();
4987  for (i=0; i < count; i++) delete muiproots[i];
4988  omFreeSize( (ADDRESS) muiproots, count * sizeof(rootContainer*) );
4989 
4990  delete ures;
4991  delete arranger;
4992  nDelete( &smv );
4993 
4994  res->data= (void *)listofroots;
4995 
4996  //emptylist->Clean();
4997  // omFreeSize( (ADDRESS) emptylist, sizeof(slists) );
4998 
4999  return FALSE;
5000 }
5001 
5002 // from mpr_numeric.cc
5003 lists listOfRoots( rootArranger* self, const unsigned int oprec )
5004 {
5005  int i,j;
5006  int count= self->roots[0]->getAnzRoots(); // number of roots
5007  int elem= self->roots[0]->getAnzElems(); // number of koordinates per root
5008 
5009  lists listofroots= (lists)omAlloc( sizeof(slists) ); // must be done this way!
5010 
5011  if ( self->found_roots )
5012  {
5013  listofroots->Init( count );
5014 
5015  for (i=0; i < count; i++)
5016  {
5017  lists onepoint= (lists)omAlloc(sizeof(slists)); // must be done this way!
5018  onepoint->Init(elem);
5019  for ( j= 0; j < elem; j++ )
5020  {
5021  if ( !rField_is_long_C(currRing) )
5022  {
5023  onepoint->m[j].rtyp=STRING_CMD;
5024  onepoint->m[j].data=(void *)complexToStr((*self->roots[j])[i],oprec, currRing->cf);
5025  }
5026  else
5027  {
5028  onepoint->m[j].rtyp=NUMBER_CMD;
5029  onepoint->m[j].data=(void *)n_Copy((number)(self->roots[j]->getRoot(i)), currRing->cf);
5030  }
5031  onepoint->m[j].next= NULL;
5032  onepoint->m[j].name= NULL;
5033  }
5034  listofroots->m[i].rtyp=LIST_CMD;
5035  listofroots->m[i].data=(void *)onepoint;
5036  listofroots->m[j].next= NULL;
5037  listofroots->m[j].name= NULL;
5038  }
5039 
5040  }
5041  else
5042  {
5043  listofroots->Init( 0 );
5044  }
5045 
5046  return listofroots;
5047 }
5048 
5049 // from ring.cc
5051 {
5052  ring rg = NULL;
5053  if (h!=NULL)
5054  {
5055 // Print(" new ring:%s (l:%d)\n",IDID(h),IDLEV(h));
5056  rg = IDRING(h);
5057  if (rg==NULL) return; //id <>NULL, ring==NULL
5058  omCheckAddrSize((ADDRESS)h,sizeof(idrec));
5059  if (IDID(h)) // OB: ????
5061  rTest(rg);
5062  }
5063  else return;
5064 
5065  // clean up history
5066  if (currRing!=NULL)
5067  {
5069  {
5071  //memset(&sLastPrinted,0,sizeof(sleftv)); // done by Cleanup,Init
5072  }
5073 
5074  if (rg!=currRing)/*&&(currRing!=NULL)*/
5075  {
5076  if (rg->cf!=currRing->cf)
5077  {
5079  if (DENOMINATOR_LIST!=NULL)
5080  {
5081  if (TEST_V_ALLWARN)
5082  Warn("deleting denom_list for ring change to %s",IDID(h));
5083  do
5084  {
5085  n_Delete(&(dd->n),currRing->cf);
5086  dd=dd->next;
5088  DENOMINATOR_LIST=dd;
5089  } while(DENOMINATOR_LIST!=NULL);
5090  }
5091  }
5092  }
5093  }
5094 
5095  // test for valid "currRing":
5096  if ((rg!=NULL) && (rg->idroot==NULL))
5097  {
5098  ring old=rg;
5099  rg=rAssure_HasComp(rg);
5100  if (old!=rg)
5101  {
5102  rKill(old);
5103  IDRING(h)=rg;
5104  }
5105  }
5106  /*------------ change the global ring -----------------------*/
5107  rChangeCurrRing(rg);
5108  currRingHdl = h;
5109 }
5110 
5112 {
5113  // change some bad orderings/combination into better ones
5114  leftv h=ord;
5115  while(h!=NULL)
5116  {
5117  BOOLEAN change=FALSE;
5118  intvec *iv = (intvec *)(h->data);
5119  // ws(-i) -> wp(i)
5120  if ((*iv)[1]==ringorder_ws)
5121  {
5122  BOOLEAN neg=TRUE;
5123  for(int i=2;i<iv->length();i++)
5124  if((*iv)[i]>=0) { neg=FALSE; break; }
5125  if (neg)
5126  {
5127  (*iv)[1]=ringorder_wp;
5128  for(int i=2;i<iv->length();i++)
5129  (*iv)[i]= - (*iv)[i];
5130  change=TRUE;
5131  }
5132  }
5133  // Ws(-i) -> Wp(i)
5134  if ((*iv)[1]==ringorder_Ws)
5135  {
5136  BOOLEAN neg=TRUE;
5137  for(int i=2;i<iv->length();i++)
5138  if((*iv)[i]>=0) { neg=FALSE; break; }
5139  if (neg)
5140  {
5141  (*iv)[1]=ringorder_Wp;
5142  for(int i=2;i<iv->length();i++)
5143  (*iv)[i]= -(*iv)[i];
5144  change=TRUE;
5145  }
5146  }
5147  // wp(1) -> dp
5148  if ((*iv)[1]==ringorder_wp)
5149  {
5150  BOOLEAN all_one=TRUE;
5151  for(int i=2;i<iv->length();i++)
5152  if((*iv)[i]!=1) { all_one=FALSE; break; }
5153  if (all_one)
5154  {
5155  intvec *iv2=new intvec(3);
5156  (*iv2)[0]=1;
5157  (*iv2)[1]=ringorder_dp;
5158  (*iv2)[2]=iv->length()-2;
5159  delete iv;
5160  iv=iv2;
5161  h->data=iv2;
5162  change=TRUE;
5163  }
5164  }
5165  // Wp(1) -> Dp
5166  if ((*iv)[1]==ringorder_Wp)
5167  {
5168  BOOLEAN all_one=TRUE;
5169  for(int i=2;i<iv->length();i++)
5170  if((*iv)[i]!=1) { all_one=FALSE; break; }
5171  if (all_one)
5172  {
5173  intvec *iv2=new intvec(3);
5174  (*iv2)[0]=1;
5175  (*iv2)[1]=ringorder_Dp;
5176  (*iv2)[2]=iv->length()-2;
5177  delete iv;
5178  iv=iv2;
5179  h->data=iv2;
5180  change=TRUE;
5181  }
5182  }
5183  // dp(1)/Dp(1)/rp(1) -> lp(1)
5184  if (((*iv)[1]==ringorder_dp)
5185  || ((*iv)[1]==ringorder_Dp)
5186  || ((*iv)[1]==ringorder_rp))
5187  {
5188  if (iv->length()==3)
5189  {
5190  if ((*iv)[2]==1)
5191  {
5192  (*iv)[1]=ringorder_lp;
5193  change=TRUE;
5194  }
5195  }
5196  }
5197  // lp(i),lp(j) -> lp(i+j)
5198  if(((*iv)[1]==ringorder_lp)
5199  && (h->next!=NULL))
5200  {
5201  intvec *iv2 = (intvec *)(h->next->data);
5202  if ((*iv2)[1]==ringorder_lp)
5203  {
5204  leftv hh=h->next;
5205  h->next=hh->next;
5206  hh->next=NULL;
5207  if ((*iv2)[0]==1)
5208  (*iv)[2] += 1; // last block unspecified, at least 1
5209  else
5210  (*iv)[2] += (*iv2)[2];
5211  hh->CleanUp();
5212  omFree(hh);
5213  change=TRUE;
5214  }
5215  }
5216  // -------------------
5217  if (!change) h=h->next;
5218  }
5219  return ord;
5220 }
5221 
5222 
5224 {
5225  int last = 0, o=0, n = 1, i=0, typ = 1, j;
5226  ord=rOptimizeOrdAsSleftv(ord);
5227  sleftv *sl = ord;
5228 
5229  // determine nBlocks
5230  while (sl!=NULL)
5231  {
5232  intvec *iv = (intvec *)(sl->data);
5233  if (((*iv)[1]==ringorder_c)||((*iv)[1]==ringorder_C))
5234  i++;
5235  else if ((*iv)[1]==ringorder_L)
5236  {
5237  R->bitmask=(*iv)[2]*2+1;
5238  n--;
5239  }
5240  else if (((*iv)[1]!=ringorder_a)
5241  && ((*iv)[1]!=ringorder_a64)
5242  && ((*iv)[1]!=ringorder_am))
5243  o++;
5244  n++;
5245  sl=sl->next;
5246  }
5247  // check whether at least one real ordering
5248  if (o==0)
5249  {
5250  WerrorS("invalid combination of orderings");
5251  return TRUE;
5252  }
5253  // if no c/C ordering is given, increment n
5254  if (i==0) n++;
5255  else if (i != 1)
5256  {
5257  // throw error if more than one is given
5258  WerrorS("more than one ordering c/C specified");
5259  return TRUE;
5260  }
5261 
5262  // initialize fields of R
5263  R->order=(rRingOrder_t *)omAlloc0(n*sizeof(rRingOrder_t));
5264  R->block0=(int *)omAlloc0(n*sizeof(int));
5265  R->block1=(int *)omAlloc0(n*sizeof(int));
5266  R->wvhdl=(int**)omAlloc0(n*sizeof(int_ptr));
5267 
5268  int *weights=(int*)omAlloc0((R->N+1)*sizeof(int));
5269 
5270  // init order, so that rBlocks works correctly
5271  for (j=0; j < n-1; j++)
5272  R->order[j] = ringorder_unspec;
5273  // set last _C order, if no c/C order was given
5274  if (i == 0) R->order[n-2] = ringorder_C;
5275 
5276  /* init orders */
5277  sl=ord;
5278  n=-1;
5279  while (sl!=NULL)
5280  {
5281  intvec *iv;
5282  iv = (intvec *)(sl->data);
5283  if ((*iv)[1]!=ringorder_L)
5284  {
5285  n++;
5286 
5287  /* the format of an ordering:
5288  * iv[0]: factor
5289  * iv[1]: ordering
5290  * iv[2..end]: weights
5291  */
5292  R->order[n] = (rRingOrder_t)((*iv)[1]);
5293  typ=1;
5294  switch ((*iv)[1])
5295  {
5296  case ringorder_ws:
5297  case ringorder_Ws:
5298  typ=-1;
5299  case ringorder_wp:
5300  case ringorder_Wp:
5301  R->wvhdl[n]=(int*)omAlloc((iv->length()-1)*sizeof(int));
5302  R->block0[n] = last+1;
5303  for (i=2; i<iv->length(); i++)
5304  {
5305  R->wvhdl[n][i-2] = (*iv)[i];
5306  last++;
5307  if (weights[last]==0) weights[last]=(*iv)[i]*typ;
5308  }
5309  R->block1[n] = si_min(last,R->N);
5310  break;
5311  case ringorder_ls:
5312  case ringorder_ds:
5313  case ringorder_Ds:
5314  case ringorder_rs:
5315  typ=-1;
5316  case ringorder_lp:
5317  case ringorder_dp:
5318  case ringorder_Dp:
5319  case ringorder_rp:
5320  R->block0[n] = last+1;
5321  if (iv->length() == 3) last+=(*iv)[2];
5322  else last += (*iv)[0];
5323  R->block1[n] = si_min(last,R->N);
5324  if (rCheckIV(iv)) return TRUE;
5325  for(i=si_min(rVar(R),R->block1[n]);i>=R->block0[n];i--)
5326  {
5327  if (weights[i]==0) weights[i]=typ;
5328  }
5329  break;
5330 
5331  case ringorder_s: // no 'rank' params!
5332  {
5333 
5334  if(iv->length() > 3)
5335  return TRUE;
5336 
5337  if(iv->length() == 3)
5338  {
5339  const int s = (*iv)[2];
5340  R->block0[n] = s;
5341  R->block1[n] = s;
5342  }
5343  break;
5344  }
5345  case ringorder_IS:
5346  {
5347  if(iv->length() != 3) return TRUE;
5348 
5349  const int s = (*iv)[2];
5350 
5351  if( 1 < s || s < -1 ) return TRUE;
5352 
5353  R->block0[n] = s;
5354  R->block1[n] = s;
5355  break;
5356  }
5357  case ringorder_S:
5358  case ringorder_c:
5359  case ringorder_C:
5360  {
5361  if (rCheckIV(iv)) return TRUE;
5362  break;
5363  }
5364  case ringorder_aa:
5365  case ringorder_a:
5366  {
5367  R->block0[n] = last+1;
5368  R->block1[n] = si_min(last+iv->length()-2 , R->N);
5369  R->wvhdl[n] = (int*)omAlloc((iv->length()-1)*sizeof(int));
5370  for (i=2; i<iv->length(); i++)
5371  {
5372  R->wvhdl[n][i-2]=(*iv)[i];
5373  last++;
5374  if (weights[last]==0) weights[last]=(*iv)[i]*typ;
5375  }
5376  last=R->block0[n]-1;
5377  break;
5378  }
5379  case ringorder_am:
5380  {
5381  R->block0[n] = last+1;
5382  R->block1[n] = si_min(last+iv->length()-2 , R->N);
5383  R->wvhdl[n] = (int*)omAlloc(iv->length()*sizeof(int));
5384  if (R->block1[n]- R->block0[n]+2>=iv->length())
5385  WarnS("missing module weights");
5386  for (i=2; i<=(R->block1[n]-R->block0[n]+2); i++)
5387  {
5388  R->wvhdl[n][i-2]=(*iv)[i];
5389  last++;
5390  if (weights[last]==0) weights[last]=(*iv)[i]*typ;
5391  }
5392  R->wvhdl[n][i-2]=iv->length() -3 -(R->block1[n]- R->block0[n]);
5393  for (; i<iv->length(); i++)
5394  {
5395  R->wvhdl[n][i-1]=(*iv)[i];
5396  }
5397  last=R->block0[n]-1;
5398  break;
5399  }
5400  case ringorder_a64:
5401  {
5402  R->block0[n] = last+1;
5403  R->block1[n] = si_min(last+iv->length()-2 , R->N);
5404  R->wvhdl[n] = (int*)omAlloc((iv->length()-1)*sizeof(int64));
5405  int64 *w=(int64 *)R->wvhdl[n];
5406  for (i=2; i<iv->length(); i++)
5407  {
5408  w[i-2]=(*iv)[i];
5409  last++;
5410  if (weights[last]==0) weights[last]=(*iv)[i]*typ;
5411  }
5412  last=R->block0[n]-1;
5413  break;
5414  }
5415  case ringorder_M:
5416  {
5417  int Mtyp=rTypeOfMatrixOrder(iv);
5418  if (Mtyp==0) return TRUE;
5419  if (Mtyp==-1) typ = -1;
5420 
5421  R->wvhdl[n] =( int *)omAlloc((iv->length()-1)*sizeof(int));
5422  for (i=2; i<iv->length();i++)
5423  R->wvhdl[n][i-2]=(*iv)[i];
5424 
5425  R->block0[n] = last+1;
5426  last += (int)sqrt((double)(iv->length()-2));
5427  R->block1[n] = si_min(last,R->N);
5428  for(i=R->block1[n];i>=R->block0[n];i--)
5429  {
5430  if (weights[i]==0) weights[i]=typ;
5431  }
5432  break;
5433  }
5434 
5435  case ringorder_no:
5436  R->order[n] = ringorder_unspec;
5437  return TRUE;
5438 
5439  default:
5440  Werror("Internal Error: Unknown ordering %d", (*iv)[1]);
5441  R->order[n] = ringorder_unspec;
5442  return TRUE;
5443  }
5444  }
5445  if (last>R->N)
5446  {
5447  Werror("mismatch of number of vars (%d) and ordering (>=%d vars)",
5448  R->N,last);
5449  return TRUE;
5450  }
5451  sl=sl->next;
5452  }
5453  // find OrdSgn:
5454  R->OrdSgn = 1;
5455  for(i=1;i<=R->N;i++)
5456  { if (weights[i]<0) { R->OrdSgn=-1;break; }}
5457  omFree(weights);
5458 
5459  // check for complete coverage
5460  while ( n >= 0 && (
5461  (R->order[n]==ringorder_c)
5462  || (R->order[n]==ringorder_C)
5463  || (R->order[n]==ringorder_s)
5464  || (R->order[n]==ringorder_S)
5465  || (R->order[n]==ringorder_IS)
5466  )) n--;
5467 
5468  assume( n >= 0 );
5469 
5470  if (R->block1[n] != R->N)
5471  {
5472  if (((R->order[n]==ringorder_dp) ||
5473  (R->order[n]==ringorder_ds) ||
5474  (R->order[n]==ringorder_Dp) ||
5475  (R->order[n]==ringorder_Ds) ||
5476  (R->order[n]==ringorder_rp) ||
5477  (R->order[n]==ringorder_rs) ||
5478  (R->order[n]==ringorder_lp) ||
5479  (R->order[n]==ringorder_ls))
5480  &&
5481  R->block0[n] <= R->N)
5482  {
5483  R->block1[n] = R->N;
5484  }
5485  else
5486  {
5487  Werror("mismatch of number of vars (%d) and ordering (%d vars)",
5488  R->N,R->block1[n]);
5489  return TRUE;
5490  }
5491  }
5492  return FALSE;
5493 }
5494 
5496 {
5497 
5498  while(sl!=NULL)
5499  {
5500  if ((sl->rtyp == IDHDL)||(sl->rtyp==ALIAS_CMD))
5501  {
5502  *p = omStrDup(sl->Name());
5503  }
5504  else if (sl->name!=NULL)
5505  {
5506  *p = (char*)sl->name;
5507  sl->name=NULL;
5508  }
5509  else if (sl->rtyp==POLY_CMD)
5510  {
5511  sleftv s_sl;
5512  iiConvert(POLY_CMD,ANY_TYPE,-1,sl,&s_sl);
5513  if (s_sl.name != NULL)
5514  {
5515  *p = (char*)s_sl.name; s_sl.name=NULL;
5516  }
5517  else
5518  *p = NULL;
5519  sl->next = s_sl.next;
5520  s_sl.next = NULL;
5521  s_sl.CleanUp();
5522  if (*p == NULL) return TRUE;
5523  }
5524  else return TRUE;
5525  p++;
5526  sl=sl->next;
5527  }
5528  return FALSE;
5529 }
5530 
5531 const short MAX_SHORT = 32767; // (1 << (sizeof(short)*8)) - 1;
5532 
5533 ////////////////////
5534 //
5535 // rInit itself:
5536 //
5537 // INPUT: pn: ch & parameter (names), rv: variable (names)
5538 // ord: ordering (all !=NULL)
5539 // RETURN: currRingHdl on success
5540 // NULL on error
5541 // NOTE: * makes new ring to current ring, on success
5542 // * considers input sleftv's as read-only
5543 ring rInit(leftv pn, leftv rv, leftv ord)
5544 {
5545  int float_len=0;
5546  int float_len2=0;
5547  ring R = NULL;
5548  //BOOLEAN ffChar=FALSE;
5549 
5550  /* ch -------------------------------------------------------*/
5551  // get ch of ground field
5552 
5553  // allocated ring
5554  R = (ring) omAlloc0Bin(sip_sring_bin);
5555 
5556  coeffs cf = NULL;
5557 
5558  assume( pn != NULL );
5559  const int P = pn->listLength();
5560 
5561  if (pn->Typ()==CRING_CMD)
5562  {
5563  cf=(coeffs)pn->CopyD();
5564  leftv pnn=pn;
5565  if(P>1) /*parameter*/
5566  {
5567  pnn = pnn->next;
5568  const int pars = pnn->listLength();
5569  assume( pars > 0 );
5570  char ** names = (char**)omAlloc0(pars * sizeof(char_ptr));
5571 
5572  if (rSleftvList2StringArray(pnn, names))
5573  {
5574  WerrorS("parameter expected");
5575  goto rInitError;
5576  }
5577 
5578  TransExtInfo extParam;
5579 
5580  extParam.r = rDefault( cf, pars, names); // Q/Zp [ p_1, ... p_pars ]
5581  for(int i=pars-1; i>=0;i--)
5582  {
5583  omFree(names[i]);
5584  }
5585  omFree(names);
5586 
5587  cf = nInitChar(n_transExt, &extParam);
5588  }
5589  assume( cf != NULL );
5590  }
5591  else if (pn->Typ()==INT_CMD)
5592  {
5593  int ch = (int)(long)pn->Data();
5594  leftv pnn=pn;
5595 
5596  /* parameter? -------------------------------------------------------*/
5597  pnn = pnn->next;
5598 
5599  if (pnn == NULL) // no params!?
5600  {
5601  if (ch!=0)
5602  {
5603  int ch2=IsPrime(ch);
5604  if ((ch<2)||(ch!=ch2))
5605  {
5606  Warn("%d is invalid as characteristic of the ground field. 32003 is used.", ch);
5607  ch=32003;
5608  }
5609  cf = nInitChar(n_Zp, (void*)(long)ch);
5610  }
5611  else
5612  cf = nInitChar(n_Q, (void*)(long)ch);
5613  }
5614  else
5615  {
5616  const int pars = pnn->listLength();
5617 
5618  assume( pars > 0 );
5619 
5620  // predefined finite field: (p^k, a)
5621  if ((ch!=0) && (ch!=IsPrime(ch)) && (pars == 1))
5622  {
5623  GFInfo param;
5624 
5625  param.GFChar = ch;
5626  param.GFDegree = 1;
5627  param.GFPar_name = pnn->name;
5628 
5629  cf = nInitChar(n_GF, &param);
5630  }
5631  else // (0/p, a, b, ..., z)
5632  {
5633  if ((ch!=0) && (ch!=IsPrime(ch)))
5634  {
5635  WerrorS("too many parameters");
5636  goto rInitError;
5637  }
5638 
5639  char ** names = (char**)omAlloc0(pars * sizeof(char_ptr));
5640 
5641  if (rSleftvList2StringArray(pnn, names))
5642  {
5643  WerrorS("parameter expected");
5644  goto rInitError;
5645  }
5646 
5647  TransExtInfo extParam;
5648 
5649  extParam.r = rDefault( ch, pars, names); // Q/Zp [ p_1, ... p_pars ]
5650  for(int i=pars-1; i>=0;i--)
5651  {
5652  omFree(names[i]);
5653  }
5654  omFree(names);
5655 
5656  cf = nInitChar(n_transExt, &extParam);
5657  }
5658  }
5659 
5660  //if (cf==NULL) ->Error: Invalid ground field specification
5661  }
5662  else if ((pn->name != NULL)
5663  && ((strcmp(pn->name,"real")==0) || (strcmp(pn->name,"complex")==0)))
5664  {
5665  leftv pnn=pn->next;
5666  BOOLEAN complex_flag=(strcmp(pn->name,"complex")==0);
5667  if ((pnn!=NULL) && (pnn->Typ()==INT_CMD))
5668  {
5669  float_len=(int)(long)pnn->Data();
5670  float_len2=float_len;
5671  pnn=pnn->next;
5672  if ((pnn!=NULL) && (pnn->Typ()==INT_CMD))
5673  {
5674  float_len2=(int)(long)pnn->Data();
5675  pnn=pnn->next;
5676  }
5677  }
5678 
5679  if (!complex_flag)
5680  complex_flag= (pnn!=NULL) && (pnn->name!=NULL);
5681  if( !complex_flag && (float_len2 <= (short)SHORT_REAL_LENGTH))
5682  cf=nInitChar(n_R, NULL);
5683  else // longR or longC?
5684  {
5685  LongComplexInfo param;
5686 
5687  param.float_len = si_min (float_len, 32767);
5688  param.float_len2 = si_min (float_len2, 32767);
5689 
5690  // set the parameter name
5691  if (complex_flag)
5692  {
5693  if (param.float_len < SHORT_REAL_LENGTH)
5694  {
5697  }
5698  if ((pnn == NULL) || (pnn->name == NULL))
5699  param.par_name=(const char*)"i"; //default to i
5700  else
5701  param.par_name = (const char*)pnn->name;
5702  }
5703 
5704  cf = nInitChar(complex_flag ? n_long_C: n_long_R, (void*)&param);
5705  }
5706  assume( cf != NULL );
5707  }
5708 #ifdef HAVE_RINGS
5709  else if ((pn->name != NULL) && (strcmp(pn->name, "integer") == 0))
5710  {
5711  // TODO: change to use coeffs_BIGINT!?
5712  mpz_t modBase;
5713  unsigned int modExponent = 1;
5714  mpz_init_set_si(modBase, 0);
5715  if (pn->next!=NULL)
5716  {
5717  leftv pnn=pn;
5718  if (pnn->next->Typ()==INT_CMD)
5719  {
5720  pnn=pnn->next;
5721  mpz_set_ui(modBase, (int)(long) pnn->Data());
5722  if ((pnn->next!=NULL) && (pnn->next->Typ()==INT_CMD))
5723  {
5724  pnn=pnn->next;
5725  modExponent = (long) pnn->Data();
5726  }
5727  while ((pnn->next!=NULL) && (pnn->next->Typ()==INT_CMD))
5728  {
5729  pnn=pnn->next;
5730  mpz_mul_ui(modBase, modBase, (int)(long) pnn->Data());
5731  }
5732  }
5733  else if (pnn->next->Typ()==BIGINT_CMD)
5734  {
5735  number p=(number)pnn->next->CopyD();
5736  nlGMP(p,modBase,coeffs_BIGINT); // TODO? // extern void nlGMP(number &i, mpz_t n, const coeffs r); // FIXME: n_MPZ( modBase, p, coeffs_BIGINT); ?
5738  }
5739  }
5740  else
5741  cf=nInitChar(n_Z,NULL);
5742 
5743  if ((mpz_cmp_ui(modBase, 1) == 0) && (mpz_sgn1(modBase) < 0))
5744  {
5745  WerrorS("Wrong ground ring specification (module is 1)");
5746  goto rInitError;
5747  }
5748  if (modExponent < 1)
5749  {
5750  WerrorS("Wrong ground ring specification (exponent smaller than 1");
5751  goto rInitError;
5752  }
5753  // module is 0 ---> integers ringtype = 4;
5754  // we have an exponent
5755  if (modExponent > 1 && cf == NULL)
5756  {
5757  if ((mpz_cmp_ui(modBase, 2) == 0) && (modExponent <= 8*sizeof(unsigned long)))
5758  {
5759  /* this branch should be active for modExponent = 2..32 resp. 2..64,
5760  depending on the size of a long on the respective platform */
5761  //ringtype = 1; // Use Z/2^ch
5762  cf=nInitChar(n_Z2m,(void*)(long)modExponent);
5763  }
5764  else
5765  {
5766  if (mpz_sgn1(modBase)==0)
5767  {
5768  WerrorS("modulus must not be 0 or parameter not allowed");
5769  goto rInitError;
5770  }
5771  //ringtype = 3;
5772  ZnmInfo info;
5773  info.base= modBase;
5774  info.exp= modExponent;
5775  cf=nInitChar(n_Znm,(void*) &info); //exponent is missing
5776  }
5777  }
5778  // just a module m > 1
5779  else if (cf == NULL)
5780  {
5781  if (mpz_sgn1(modBase)==0)
5782  {
5783  WerrorS("modulus must not be 0 or parameter not allowed");
5784  goto rInitError;
5785  }
5786  //ringtype = 2;
5787  ZnmInfo info;
5788  info.base= modBase;
5789  info.exp= modExponent;
5790  cf=nInitChar(n_Zn,(void*) &info);
5791  }
5792  assume( cf != NULL );
5793  mpz_clear(modBase);
5794  }
5795 #endif
5796  // ring NEW = OLD, (), (); where OLD is a polynomial ring...
5797  else if ((pn->Typ()==RING_CMD) && (P == 1))
5798  {
5799  TransExtInfo extParam;
5800  extParam.r = (ring)pn->Data();
5801  cf = nInitChar(n_transExt, &extParam);
5802  }
5803  //else if ((pn->Typ()==QRING_CMD) && (P == 1)) // same for qrings - which should be fields!?
5804  //{
5805  // AlgExtInfo extParam;
5806  // extParam.r = (ring)pn->Data();
5807 
5808  // cf = nInitChar(n_algExt, &extParam); // Q[a]/<minideal>
5809  //}
5810  else
5811  {
5812  WerrorS("Wrong or unknown ground field specification");
5813 #if 0
5814 // debug stuff for unknown cf descriptions:
5815  sleftv* p = pn;
5816  while (p != NULL)
5817  {
5818  Print( "pn[%p]: type: %d [%s]: %p, name: %s", (void*)p, p->Typ(), Tok2Cmdname(p->Typ()), p->Data(), (p->name == NULL? "NULL" : p->name) );
5819  PrintLn();
5820  p = p->next;
5821  }
5822 #endif
5823  goto rInitError;
5824  }
5825 
5826  /*every entry in the new ring is initialized to 0*/
5827 
5828  /* characteristic -----------------------------------------------*/
5829  /* input: 0 ch=0 : Q parameter=NULL ffChar=FALSE float_len
5830  * 0 1 : Q(a,...) *names FALSE
5831  * 0 -1 : R NULL FALSE 0
5832  * 0 -1 : R NULL FALSE prec. >6
5833  * 0 -1 : C *names FALSE prec. 0..?
5834  * p p : Fp NULL FALSE
5835  * p -p : Fp(a) *names FALSE
5836  * q q : GF(q=p^n) *names TRUE
5837  */
5838  if (cf==NULL)
5839  {
5840  WerrorS("Invalid ground field specification");
5841  goto rInitError;
5842 // const int ch=32003;
5843 // cf=nInitChar(n_Zp, (void*)(long)ch);
5844  }
5845 
5846  assume( R != NULL );
5847 
5848  R->cf = cf;
5849 
5850  /* names and number of variables-------------------------------------*/
5851  {
5852  int l=rv->listLength();
5853 
5854  if (l>MAX_SHORT)
5855  {
5856  Werror("too many ring variables(%d), max is %d",l,MAX_SHORT);
5857  goto rInitError;
5858  }
5859  R->N = l; /*rv->listLength();*/
5860  }
5861  R->names = (char **)omAlloc0(R->N * sizeof(char_ptr));
5862  if (rSleftvList2StringArray(rv, R->names))
5863  {
5864  WerrorS("name of ring variable expected");
5865  goto rInitError;
5866  }
5867 
5868  /* check names and parameters for conflicts ------------------------- */
5869  rRenameVars(R); // conflicting variables will be renamed
5870  /* ordering -------------------------------------------------------------*/
5871  if (rSleftvOrdering2Ordering(ord, R))
5872  goto rInitError;
5873 
5874  // Complete the initialization
5875  if (rComplete(R,1))
5876  goto rInitError;
5877 
5878 /*#ifdef HAVE_RINGS
5879 // currently, coefficients which are ring elements require a global ordering:
5880  if (rField_is_Ring(R) && (R->OrdSgn==-1))
5881  {
5882  WerrorS("global ordering required for these coefficients");
5883  goto rInitError;
5884  }
5885 #endif*/
5886 
5887  rTest(R);
5888 
5889  // try to enter the ring into the name list
5890  // need to clean up sleftv here, before this ring can be set to
5891  // new currRing or currRing can be killed beacuse new ring has
5892  // same name
5893  pn->CleanUp();
5894  rv->CleanUp();
5895  ord->CleanUp();
5896  //if ((tmp = enterid(s, myynest, RING_CMD, &IDROOT))==NULL)
5897  // goto rInitError;
5898 
5899  //memcpy(IDRING(tmp),R,sizeof(*R));
5900  // set current ring
5901  //omFreeBin(R, ip_sring_bin);
5902  //return tmp;
5903  return R;
5904 
5905  // error case:
5906  rInitError:
5907  if ((R != NULL)&&(R->cf!=NULL)) rDelete(R);
5908  pn->CleanUp();
5909  rv->CleanUp();
5910  ord->CleanUp();
5911  return NULL;
5912 }
5913 
5914 ring rSubring(ring org_ring, sleftv* rv)
5915 {
5916  ring R = rCopy0(org_ring);
5917  int *perm=(int *)omAlloc0((org_ring->N+1)*sizeof(int));
5918  int n = rBlocks(org_ring), i=0, j;
5919 
5920  /* names and number of variables-------------------------------------*/
5921  {
5922  int l=rv->listLength();
5923  if (l>MAX_SHORT)
5924  {
5925  Werror("too many ring variables(%d), max is %d",l,MAX_SHORT);
5926  goto rInitError;
5927  }
5928  R->N = l; /*rv->listLength();*/
5929  }
5930  omFree(R->names);
5931  R->names = (char **)omAlloc0(R->N * sizeof(char_ptr));
5932  if (rSleftvList2StringArray(rv, R->names))
5933  {
5934  WerrorS("name of ring variable expected");
5935  goto rInitError;
5936  }
5937 
5938  /* check names for subring in org_ring ------------------------- */
5939  {
5940  i=0;
5941 
5942  for(j=0;j<R->N;j++)
5943  {
5944  for(;i<org_ring->N;i++)
5945  {
5946  if (strcmp(org_ring->names[i],R->names[j])==0)
5947  {
5948  perm[i+1]=j+1;
5949  break;
5950  }
5951  }
5952  if (i>org_ring->N)
5953  {
5954  Werror("variable %d (%s) not in basering",j+1,R->names[j]);
5955  break;
5956  }
5957  }
5958  }
5959  //Print("perm=");
5960  //for(i=1;i<org_ring->N;i++) Print("v%d -> v%d\n",i,perm[i]);
5961  /* ordering -------------------------------------------------------------*/
5962 
5963  for(i=0;i<n;i++)
5964  {
5965  int min_var=-1;
5966  int max_var=-1;
5967  for(j=R->block0[i];j<=R->block1[i];j++)
5968  {
5969  if (perm[j]>0)
5970  {
5971  if (min_var==-1) min_var=perm[j];
5972  max_var=perm[j];
5973  }
5974  }
5975  if (min_var!=-1)
5976  {
5977  //Print("block %d: old %d..%d, now:%d..%d\n",
5978  // i,R->block0[i],R->block1[i],min_var,max_var);
5979  R->block0[i]=min_var;
5980  R->block1[i]=max_var;
5981  if (R->wvhdl[i]!=NULL)
5982  {
5983  omFree(R->wvhdl[i]);
5984  R->wvhdl[i]=(int*)omAlloc0((max_var-min_var+1)*sizeof(int));
5985  for(j=org_ring->block0[i];j<=org_ring->block1[i];j++)
5986  {
5987  if (perm[j]>0)
5988  {
5989  R->wvhdl[i][perm[j]-R->block0[i]]=
5990  org_ring->wvhdl[i][j-org_ring->block0[i]];
5991  //Print("w%d=%d (orig_w%d)\n",perm[j],R->wvhdl[i][perm[j]-R->block0[i]],j);
5992  }
5993  }
5994  }
5995  }
5996  else
5997  {
5998  if(R->block0[i]>0)
5999  {
6000  //Print("skip block %d\n",i);
6001  R->order[i]=ringorder_unspec;
6002  if (R->wvhdl[i] !=NULL) omFree(R->wvhdl[i]);
6003  R->wvhdl[i]=NULL;
6004  }
6005  //else Print("keep block %d\n",i);
6006  }
6007  }
6008  i=n-1;
6009  while(i>0)
6010  {
6011  // removed unneded blocks
6012  if(R->order[i-1]==ringorder_unspec)
6013  {
6014  for(j=i;j<=n;j++)
6015  {
6016  R->order[j-1]=R->order[j];
6017  R->block0[j-1]=R->block0[j];
6018  R->block1[j-1]=R->block1[j];
6019  if (R->wvhdl[j-1] !=NULL) omFree(R->wvhdl[j-1]);
6020  R->wvhdl[j-1]=R->wvhdl[j];
6021  }
6022  R->order[n]=ringorder_unspec;
6023  n--;
6024  }
6025  i--;
6026  }
6027  n=rBlocks(org_ring)-1;
6028  while (R->order[n]==0) n--;
6029  while (R->order[n]==ringorder_unspec) n--;
6030  if ((R->order[n]==ringorder_c) || (R->order[n]==ringorder_C)) n--;
6031  if (R->block1[n] != R->N)
6032  {
6033  if (((R->order[n]==ringorder_dp) ||
6034  (R->order[n]==ringorder_ds) ||
6035  (R->order[n]==ringorder_Dp) ||
6036  (R->order[n]==ringorder_Ds) ||
6037  (R->order[n]==ringorder_rp) ||
6038  (R->order[n]==ringorder_rs) ||
6039  (R->order[n]==ringorder_lp) ||
6040  (R->order[n]==ringorder_ls))
6041  &&
6042  R->block0[n] <= R->N)
6043  {
6044  R->block1[n] = R->N;
6045  }
6046  else
6047  {
6048  Werror("mismatch of number of vars (%d) and ordering (%d vars) in block %d",
6049  R->N,R->block1[n],n);
6050  return NULL;
6051  }
6052  }
6053  omFree(perm);
6054  // find OrdSgn:
6055  R->OrdSgn = org_ring->OrdSgn; // IMPROVE!
6056  //for(i=1;i<=R->N;i++)
6057  //{ if (weights[i]<0) { R->OrdSgn=-1;break; }}
6058  //omFree(weights);
6059  // Complete the initialization
6060  if (rComplete(R,1))
6061  goto rInitError;
6062 
6063  rTest(R);
6064 
6065  if (rv != NULL) rv->CleanUp();
6066 
6067  return R;
6068 
6069  // error case:
6070  rInitError:
6071  if (R != NULL) rDelete(R);
6072  if (rv != NULL) rv->CleanUp();
6073  return NULL;
6074 }
6075 
6076 void rKill(ring r)
6077 {
6078  if ((r->ref<=0)&&(r->order!=NULL))
6079  {
6080 #ifdef RDEBUG
6081  if (traceit &TRACE_SHOW_RINGS) Print("kill ring %lx\n",(long)r);
6082 #endif
6083  int j;
6084  for (j=0;j<myynest;j++)
6085  {
6086  if (iiLocalRing[j]==r)
6087  {
6088  if (j==0) WarnS("killing the basering for level 0");
6089  iiLocalRing[j]=NULL;
6090  }
6091  }
6092 // any variables depending on r ?
6093  while (r->idroot!=NULL)
6094  {
6095  r->idroot->lev=myynest; // avoid warning about kill global objects
6096  killhdl2(r->idroot,&(r->idroot),r);
6097  }
6098  if (r==currRing)
6099  {
6100  // all dependend stuff is done, clean global vars:
6101  if ((currRing->ppNoether)!=NULL) pDelete(&(currRing->ppNoether));
6103  {
6105  }
6106  //if ((myynest>0) && (iiRETURNEXPR.RingDependend()))
6107  //{
6108  // WerrorS("return value depends on local ring variable (export missing ?)");
6109  // iiRETURNEXPR.CleanUp();
6110  //}
6111  currRing=NULL;
6112  currRingHdl=NULL;
6113  }
6114 
6115  /* nKillChar(r); will be called from inside of rDelete */
6116  rDelete(r);
6117  return;
6118  }
6119  r->ref--;
6120 }
6121 
6123 {
6124  ring r = IDRING(h);
6125  int ref=0;
6126  if (r!=NULL)
6127  {
6128  // avoid, that sLastPrinted is the last reference to the base ring:
6129  // clean up before killing the last "named" refrence:
6130  if ((sLastPrinted.rtyp==RING_CMD)
6131  && (sLastPrinted.data==(void*)r))
6132  {
6133  sLastPrinted.CleanUp(r);
6134  }
6135  ref=r->ref;
6136  if ((ref<=0)&&(r==currRing))
6137  {
6138  // cleanup DENOMINATOR_LIST
6139  if (DENOMINATOR_LIST!=NULL)
6140  {
6142  if (TEST_V_ALLWARN)
6143  Warn("deleting denom_list for ring change from %s",IDID(h));
6144  do
6145  {
6146  n_Delete(&(dd->n),currRing->cf);
6147  dd=dd->next;
6149  DENOMINATOR_LIST=dd;
6150  } while(DENOMINATOR_LIST!=NULL);
6151  }
6152  }
6153  rKill(r);
6154  }
6155  if (h==currRingHdl)
6156  {
6157  if (ref<=0) { currRing=NULL; currRingHdl=NULL;}
6158  else
6159  {
6161  }
6162  }
6163 }
6164 
6166 {
6167  idhdl h=root;
6168  while (h!=NULL)
6169  {
6170  if ((IDTYP(h)==RING_CMD)
6171  && (h!=n)
6172  && (IDRING(h)==r)
6173  )
6174  {
6175  return h;
6176  }
6177  h=IDNEXT(h);
6178  }
6179  return NULL;
6180 }
6181 
6182 extern BOOLEAN jjPROC(leftv res, leftv u, leftv v);
6183 ideal kGroebner(ideal F, ideal Q)
6184 {
6185  //test|=Sy_bit(OPT_PROT);
6186  idhdl save_ringhdl=currRingHdl;
6187  ideal resid;
6188  idhdl new_ring=NULL;
6189  if ((currRingHdl==NULL) || (IDRING(currRingHdl)!=currRing))
6190  {
6191  currRingHdl=enterid(" GROEBNERring",0,RING_CMD,&IDROOT,FALSE);
6192  new_ring=currRingHdl;
6194  }
6195  sleftv v; memset(&v,0,sizeof(v)); v.rtyp=IDEAL_CMD; v.data=(char *) F;
6196  idhdl h=ggetid("groebner");
6197  sleftv u; memset(&u,0,sizeof(u)); u.rtyp=IDHDL; u.data=(char *) h;
6198  u.name=IDID(h);
6199 
6200  sleftv res; memset(&res,0,sizeof(res));
6201  if(jjPROC(&res,&u,&v))
6202  {
6203  resid=kStd(F,Q,testHomog,NULL);
6204  }
6205  else
6206  {
6207  //printf("typ:%d\n",res.rtyp);
6208  resid=(ideal)(res.data);
6209  }
6210  // cleanup GROEBNERring, save_ringhdl, u,v,(res )
6211  if (new_ring!=NULL)
6212  {
6213  idhdl h=IDROOT;
6214  if (h==new_ring) IDROOT=h->next;
6215  else
6216  {
6217  while ((h!=NULL) &&(h->next!=new_ring)) h=h->next;
6218  if (h!=NULL) h->next=h->next->next;
6219  }
6220  if (h!=NULL) omFreeSize(h,sizeof(*h));
6221  }
6222  currRingHdl=save_ringhdl;
6223  u.CleanUp();
6224  v.CleanUp();
6225  return resid;
6226 }
6227 
6228 static void jjINT_S_TO_ID(int n,int *e, leftv res)
6229 {
6230  if (n==0) n=1;
6231  ideal l=idInit(n,1);
6232  int i;
6233  poly p;
6234  for(i=rVar(currRing);i>0;i--)
6235  {
6236  if (e[i]>0)
6237  {
6238  n--;
6239  p=pOne();
6240  pSetExp(p,i,1);
6241  pSetm(p);
6242  l->m[n]=p;
6243  if (n==0) break;
6244  }
6245  }
6246  res->data=(char*)l;
6247  setFlag(res,FLAG_STD);
6248  omFreeSize((ADDRESS)e,(rVar(currRing)+1)*sizeof(int));
6249 }
6251 {
6252  int *e=(int *)omAlloc0((rVar(currRing)+1)*sizeof(int));
6253  int n=pGetVariables((poly)u->Data(),e);
6254  jjINT_S_TO_ID(n,e,res);
6255  return FALSE;
6256 }
6257 
6259 {
6260  int *e=(int *)omAlloc0((rVar(currRing)+1)*sizeof(int));
6261  ideal I=(ideal)u->Data();
6262  int i;
6263  int n=0;
6264  for(i=I->nrows*I->ncols-1;i>=0;i--)
6265  {
6266  int n0=pGetVariables(I->m[i],e);
6267  if (n0>n) n=n0;
6268  }
6269  jjINT_S_TO_ID(n,e,res);
6270  return FALSE;
6271 }
6272 
6273 void paPrint(const char *n,package p)
6274 {
6275  Print(" %s (",n);
6276  switch (p->language)
6277  {
6278  case LANG_SINGULAR: PrintS("S"); break;
6279  case LANG_C: PrintS("C"); break;
6280  case LANG_TOP: PrintS("T"); break;
6281  case LANG_MAX: PrintS("M"); break;
6282  case LANG_NONE: PrintS("N"); break;
6283  default: PrintS("U");
6284  }
6285  if(p->libname!=NULL)
6286  Print(",%s", p->libname);
6287  PrintS(")");
6288 }
6289 
6291 {
6292  intvec *aa=(intvec*)a->Data();
6293  sleftv tmp_out;
6294  sleftv tmp_in;
6295  leftv curr=res;
6296  BOOLEAN bo=FALSE;
6297  for(int i=0;i<aa->length(); i++)
6298  {
6299  memset(&tmp_in,0,sizeof(tmp_in));
6300  tmp_in.rtyp=INT_CMD;
6301  tmp_in.data=(void*)(long)(*aa)[i];
6302  if (proc==NULL)
6303  bo=iiExprArith1(&tmp_out,&tmp_in,op);
6304  else
6305  bo=jjPROC(&tmp_out,proc,&tmp_in);
6306  if (bo)
6307  {
6308  res->CleanUp(currRing);
6309  Werror("apply fails at index %d",i+1);
6310  return TRUE;
6311  }
6312  if (i==0) { memcpy(res,&tmp_out,sizeof(tmp_out)); }
6313  else
6314  {
6315  curr->next=(leftv)omAllocBin(sleftv_bin);
6316  curr=curr->next;
6317  memcpy(curr,&tmp_out,sizeof(tmp_out));
6318  }
6319  }
6320  return FALSE;
6321 }
6323 {
6324  WerrorS("not implemented");
6325  return TRUE;
6326 }
6328 {
6329  WerrorS("not implemented");
6330  return TRUE;
6331 }
6333 {
6334  lists aa=(lists)a->Data();
6335  sleftv tmp_out;
6336  sleftv tmp_in;
6337  leftv curr=res;
6338  BOOLEAN bo=FALSE;
6339  for(int i=0;i<=aa->nr; i++)
6340  {
6341  memset(&tmp_in,0,sizeof(tmp_in));
6342  tmp_in.Copy(&(aa->m[i]));
6343  if (proc==NULL)
6344  bo=iiExprArith1(&tmp_out,&tmp_in,op);
6345  else
6346  bo=jjPROC(&tmp_out,proc,&tmp_in);
6347  tmp_in.CleanUp();
6348  if (bo)
6349  {
6350  res->CleanUp(currRing);
6351  Werror("apply fails at index %d",i+1);
6352  return TRUE;
6353  }
6354  if (i==0) { memcpy(res,&tmp_out,sizeof(tmp_out)); }
6355  else
6356  {
6357  curr->next=(leftv)omAllocBin(sleftv_bin);
6358  curr=curr->next;
6359  memcpy(curr,&tmp_out,sizeof(tmp_out));
6360  }
6361  }
6362  return FALSE;
6363 }
6365 {
6366  memset(res,0,sizeof(sleftv));
6367  res->rtyp=a->Typ();
6368  switch (res->rtyp /*a->Typ()*/)
6369  {
6370  case INTVEC_CMD:
6371  case INTMAT_CMD:
6372  return iiApplyINTVEC(res,a,op,proc);
6373  case BIGINTMAT_CMD:
6374  return iiApplyBIGINTMAT(res,a,op,proc);
6375  case IDEAL_CMD:
6376  case MODUL_CMD:
6377  case MATRIX_CMD:
6378  return iiApplyIDEAL(res,a,op,proc);
6379  case LIST_CMD:
6380  return iiApplyLIST(res,a,op,proc);
6381  }
6382  WerrorS("first argument to `apply` must allow an index");
6383  return TRUE;
6384 }
6385 
6387 {
6388  // assume a: level
6389  if ((a->Typ()==INT_CMD)&&((long)a->Data()>=0))
6390  {
6391  if ((TEST_V_ALLWARN) && (myynest==0)) WarnS("ASSUME at top level is of no use: see documentation");
6392  char assume_yylinebuf[80];
6393  strncpy(assume_yylinebuf,my_yylinebuf,79);
6394  int lev=(long)a->Data();
6395  int startlev=0;
6396  idhdl h=ggetid("assumeLevel");
6397  if ((h!=NULL)&&(IDTYP(h)==INT_CMD)) startlev=(long)IDINT(h);
6398  if(lev <=startlev)
6399  {
6400  BOOLEAN bo=b->Eval();
6401  if (bo) { WerrorS("syntax error in ASSUME");return TRUE;}
6402  if (b->Typ()!=INT_CMD) { WerrorS("ASUMME(<level>,<int expr>)");return TRUE; }
6403  if (b->Data()==NULL) { Werror("ASSUME failed:%s",assume_yylinebuf);return TRUE;}
6404  }
6405  }
6406  b->CleanUp();
6407  a->CleanUp();
6408  return FALSE;
6409 }
6410 
6411 #include "libparse.h"
6412 
6413 BOOLEAN iiARROW(leftv r, char* a, char *s)
6414 {
6415  char *ss=(char*)omAlloc(strlen(a)+strlen(s)+30); /* max. 27 currently */
6416  // find end of s:
6417  int end_s=strlen(s);
6418  while ((end_s>0) && ((s[end_s]<=' ')||(s[end_s]==';'))) end_s--;
6419  s[end_s+1]='\0';
6420  char *name=(char *)omAlloc(strlen(a)+strlen(s)+30);
6421  sprintf(name,"%s->%s",a,s);
6422  // find start of last expression
6423  int start_s=end_s-1;
6424  while ((start_s>=0) && (s[start_s]!=';')) start_s--;
6425  if (start_s<0) // ';' not found
6426  {
6427  sprintf(ss,"parameter def %s;return(%s);\n",a,s);
6428  }
6429  else // s[start_s] is ';'
6430  {
6431  s[start_s]='\0';
6432  sprintf(ss,"parameter def %s;%s;return(%s);\n",a,s,s+start_s+1);
6433  }
6434  memset(r,0,sizeof(*r));
6435  // now produce procinfo for PROC_CMD:
6436  r->data = (void *)omAlloc0Bin(procinfo_bin);
6437  ((procinfo *)(r->data))->language=LANG_NONE;
6438  iiInitSingularProcinfo((procinfo *)r->data,"",name,0,0);
6439  ((procinfo *)r->data)->data.s.body=ss;
6440  omFree(name);
6441  r->rtyp=PROC_CMD;
6442  //r->rtyp=STRING_CMD;
6443  //r->data=ss;
6444  return FALSE;
6445 }
6446 
6448 {
6449  char* ring_name=omStrDup((char*)r->Name());
6450  int t=arg->Typ();
6451  if (t==RING_CMD)
6452  {
6453  sleftv tmp;
6454  memset(&tmp,0,sizeof(tmp));
6455  tmp.rtyp=IDHDL;
6456  tmp.data=(char*)rDefault(ring_name);
6457  if (tmp.data!=NULL)
6458  {
6459  BOOLEAN b=iiAssign(&tmp,arg);
6460  if (b) return TRUE;
6461  rSetHdl(ggetid(ring_name));
6462  omFree(ring_name);
6463  return FALSE;
6464  }
6465  else
6466  return TRUE;
6467  }
6468  else if (t==CRING_CMD)
6469  {
6470  sleftv tmp;
6471  sleftv n;
6472  memset(&n,0,sizeof(n));
6473  n.name=ring_name;
6474  if (iiDeclCommand(&tmp,&n,myynest,CRING_CMD,&IDROOT)) return TRUE;
6475  if (iiAssign(&tmp,arg)) return TRUE;
6476  //Print("create %s\n",r->Name());
6477  //Print("from %s(%d)\n",Tok2Cmdname(arg->Typ()),arg->Typ());
6478  return FALSE;
6479  }
6480  //Print("create %s\n",r->Name());
6481  //Print("from %s(%d)\n",Tok2Cmdname(arg->Typ()),arg->Typ());
6482  return TRUE;// not handled -> error for now
6483 }
6484 
6485 static void iiReportTypes(int nr,int t,const short *T)
6486 {
6487  char buf[250];
6488  buf[0]='\0';
6489  if (nr==0)
6490  sprintf(buf,"wrong length of parameters(%d), expected ",t);
6491  else
6492  sprintf(buf,"par. %d is of type `%s`, expected ",nr,Tok2Cmdname(t));
6493  for(int i=1;i<=T[0];i++)
6494  {
6495  strcat(buf,"`");
6496  strcat(buf,Tok2Cmdname(T[i]));
6497  strcat(buf,"`");
6498  if (i<T[0]) strcat(buf,",");
6499  }
6500  WerrorS(buf);
6501 }
6502 
6503 BOOLEAN iiCheckTypes(leftv args, const short *type_list, int report)
6504 {
6505  int l=0;
6506  if (args==NULL)
6507  {
6508  if (type_list[0]==0) return TRUE;
6509  }
6510  else l=args->listLength();
6511  if (l!=(int)type_list[0])
6512  {
6513  if (report) iiReportTypes(0,l,type_list);
6514  return FALSE;
6515  }
6516  for(int i=1;i<=l;i++,args=args->next)
6517  {
6518  short t=type_list[i];
6519  if (t!=ANY_TYPE)
6520  {
6521  if (((t==IDHDL)&&(args->rtyp!=IDHDL))
6522  || (t!=args->Typ()))
6523  {
6524  if (report) iiReportTypes(i,args->Typ(),type_list);
6525  return FALSE;
6526  }
6527  }
6528  }
6529  return TRUE;
6530 }
iiConvert
BOOLEAN iiConvert(int inputType, int outputType, int index, leftv input, leftv output, const struct sConvertTypes *dConvertTypes)
Definition: ipconv.cc:401
si_min
static int si_min(const int a, const int b)
Definition: auxiliary.h:139
FALSE
#define FALSE
Definition: auxiliary.h:94
IDINT
#define IDINT(a)
Definition: ipid.h:120
idCopy
ideal idCopy(ideal A)
Definition: ideals.h:60
rDecomposeC
static void rDecomposeC(leftv h, const ring R)
Definition: ipshell.cc:1743
rComposeRing
void rComposeRing(lists L, ring R)
Definition: ipshell.cc:2298
vandermonde::interpolateDense
number * interpolateDense(const number *q)
Solves the Vandermode linear system \sum_{i=1}^{n} x_i^k-1 w_i = q_k, k=1,..,n.
Definition: mpr_numeric.cc:151
LongComplexInfo::float_len2
short float_len2
additional char-flags, rInit
Definition: coeffs.h:103
omCheckAddrSize
#define omCheckAddrSize(addr, size)
Definition: omAllocDecl.h:327
omalloc.h
n_Zn
@ n_Zn
only used if HAVE_RINGS is defined
Definition: coeffs.h:45
hIndMult
void hIndMult(scmon pure, int Npure, scfmon rad, int Nrad, varset var, int Nvar)
Definition: hdegree.cc:313
matrix
ip_smatrix * matrix
Definition: matpol.h:31
wFunctionalBuch
double wFunctionalBuch(int *degw, int *lpol, int npol, double *rel, double wx, double wNsqr)
Definition: weight0.c:78
hutil.h
sleftv::Data
void * Data()
Definition: subexpr.cc:1134
IDMAP
#define IDMAP(a)
Definition: ipid.h:130
nCoeff_is_numeric
static FORCE_INLINE BOOLEAN nCoeff_is_numeric(const coeffs r)
Definition: coeffs.h:846
rField_is_long_R
static BOOLEAN rField_is_long_R(const ring r)
Definition: ring.h:534
rootContainer::onepoly
@ onepoly
Definition: mpr_numeric.h:68
GFInfo::GFChar
int GFChar
Definition: coeffs.h:95
iiCheckPack
void iiCheckPack(package &p)
Definition: ipshell.cc:1536
jjBETTI2_ID
BOOLEAN jjBETTI2_ID(leftv res, leftv u, leftv v)
Definition: ipshell.cc:899
pIsConstant
#define pIsConstant(p)
like above, except that Comp might be != 0
Definition: polys.h:225
rCheckIV
BOOLEAN rCheckIV(const intvec *iv)
Definition: ring.cc:176
copy_deep
void copy_deep(spectrum &spec, lists l)
Definition: ipshell.cc:3298
ipListFlag
void ipListFlag(idhdl h)
Definition: ipid.cc:528
Voice::buffer
char * buffer
Definition: fevoices.h:69
ringorder_Ds
@ ringorder_Ds
Definition: ring.h:92
ip_smatrix
Definition: matpol.h:14
simplex::m
int m
Definition: mpr_numeric.h:198
TransExtInfo
struct for passing initialization parameters to naInitChar
Definition: transext.h:88
kGroebner
ideal kGroebner(ideal F, ideal Q)
Definition: ipshell.cc:6183
syMinimizeResolvente
void syMinimizeResolvente(resolvente res, int length, int first)
Definition: syz.cc:356
nSetChar
static FORCE_INLINE void nSetChar(const coeffs r)
initialisations after each ring change
Definition: coeffs.h:437
kutil.h
IsPrime
int IsPrime(int p)
Definition: prime.cc:61
jjMINRES
BOOLEAN jjMINRES(leftv res, leftv v)
Definition: ipshell.cc:865
uResultant::denseResMat
@ denseResMat
Definition: mpr_base.h:65
j
int j
Definition: facHensel.cc:105
f
FILE * f
Definition: checklibs.c:9
spectrumfProc
BOOLEAN spectrumfProc(leftv result, leftv first)
Definition: ipshell.cc:4122
pNorm
void pNorm(poly p, const ring R=currRing)
Definition: polys.h:349
omFree
#define omFree(addr)
Definition: omAllocDecl.h:261
gmp_output_digits
size_t gmp_output_digits
Definition: mpr_complex.cc:43
resMatrixBase::initState
virtual IStateType initState() const
Definition: mpr_base.h:41
iiRegularity
int iiRegularity(lists L)
Definition: ipshell.cc:956
errorreported
short errorreported
Definition: feFopen.cc:23
k
int k
Definition: cfEzgcd.cc:92
idDelete
#define idDelete(H)
delete an ideal
Definition: ideals.h:29
scComputeHC
void scComputeHC(ideal S, ideal Q, int ak, poly &hEdge, ring tailRing)
Definition: hdegree.cc:1005
CRING_CMD
@ CRING_CMD
Definition: tok.h:56
semicListNumNegative
@ semicListNumNegative
Definition: ipshell.cc:3394
LongComplexInfo
Definition: coeffs.h:100
mprOk
@ mprOk
Definition: mpr_base.h:98
iiApplyLIST
BOOLEAN iiApplyLIST(leftv res, leftv a, int op, leftv proc)
Definition: ipshell.cc:6332
nuVanderSys
BOOLEAN nuVanderSys(leftv res, leftv arg1, leftv arg2, leftv arg3)
COMPUTE: polynomial p with values given by v at points p1,..,pN derived from p; more precisely: consi...
Definition: ipshell.cc:4745
x
Variable x
Definition: cfModGcd.cc:4023
NUMBER_CMD
@ NUMBER_CMD
Definition: grammar.cc:287
MATELEM
#define MATELEM(mat, i, j)
Definition: matpol.h:30
bigintmat
Definition: bigintmat.h:51
lastreserved
const char * lastreserved
Definition: ipshell.cc:80
rChangeCurrRing
void rChangeCurrRing(ring r)
Definition: polys.cc:15
COLONCOLON
@ COLONCOLON
Definition: grammar.cc:275
result
return result
Definition: facAbsBiFact.cc:76
syBetti1
BOOLEAN syBetti1(leftv res, leftv u)
Definition: ipshell.cc:3110
LANG_TOP
@ LANG_TOP
Definition: subexpr.h:24
V_DEF_RES
#define V_DEF_RES
Definition: options.h:50
SHORT_REAL_LENGTH
#define SHORT_REAL_LENGTH
Definition: numbers.h:58
BT_execute
@ BT_execute
Definition: fevoices.h:25
LANG_SINGULAR
@ LANG_SINGULAR
Definition: subexpr.h:24
GFInfo
Creation data needed for finite fields.
Definition: coeffs.h:93
BIGINT_CMD
@ BIGINT_CMD
Definition: tok.h:38
iiDebugMarker
BOOLEAN iiDebugMarker
Definition: ipshell.cc:982
n_long_C
@ n_long_C
complex floating point (GMP) numbers
Definition: coeffs.h:42
iiExprArith1
BOOLEAN iiExprArith1(leftv res, leftv a, int op)
Definition: iparith.cc:8267
polyset
poly * polyset
Definition: polys.h:246
LIST_CMD
@ LIST_CMD
Definition: tok.h:118
uResultant::resMatType
resMatType
Definition: mpr_base.h:65
syBetti2
BOOLEAN syBetti2(leftv res, leftv u, leftv w)
Definition: ipshell.cc:3087
syStrategy
ssyStrategy * syStrategy
Definition: syz.h:35
pGetExp
#define pGetExp(p, i)
Exponent.
Definition: polys.h:41
ringorder_ds
@ ringorder_ds
Definition: ring.h:91
lists.h
attrib.h
ADDRESS
void * ADDRESS
Definition: auxiliary.h:133
enterid
idhdl enterid(const char *s, int lev, int t, idhdl *root, BOOLEAN init, BOOLEAN search)
Definition: ipid.cc:257
mpz_sgn1
#define mpz_sgn1(A)
Definition: si_gmp.h:13
IDPOLY
#define IDPOLY(a)
Definition: ipid.h:125
hRadical
void hRadical(scfmon rad, int *Nrad, int Nvar)
Definition: hutil.cc:417
semicListThirdElementWrongType
@ semicListThirdElementWrongType
Definition: ipshell.cc:3382
MODUL_CMD
@ MODUL_CMD
Definition: grammar.cc:286
ringorder_ws
@ ringorder_ws
Definition: ring.h:93
STRING_CMD
@ STRING_CMD
Definition: tok.h:183
LANG_MAX
@ LANG_MAX
Definition: subexpr.h:24
CNUMBER_CMD
@ CNUMBER_CMD
Definition: tok.h:47
ssyStrategy::fullres
resolvente fullres
Definition: syz.h:57
number2.h
iiAssignCR
BOOLEAN iiAssignCR(leftv r, leftv arg)
Definition: ipshell.cc:6447
resMatrixBase::getSubDet
virtual number getSubDet()
Definition: mpr_base.h:37
jjBETTI2
BOOLEAN jjBETTI2(leftv res, leftv u, leftv v)
Definition: ipshell.cc:920
num
CanonicalForm num(const CanonicalForm &f)
Definition: canonicalform.h:330
paPrint
void paPrint(const char *n, package p)
Definition: ipshell.cc:6273
spectrumZero
@ spectrumZero
Definition: ipshell.cc:3491
rootContainer::solver
bool solver(const int polishmode=PM_NONE)
Definition: mpr_numeric.cc:441
hMu
int hMu
Definition: hdegree.cc:22
map
CanonicalForm map(const CanonicalForm &primElem, const Variable &alpha, const CanonicalForm &F, const Variable &beta)
map from to such that is mapped onto
Definition: cf_map_ext.cc:400
BITSET
#define BITSET
Definition: structs.h:18
gen_maps.h
currid
const char * currid
Definition: grammar.cc:171
test_cmd
void test_cmd(int i)
Definition: ipshell.cc:506
search
int search(const CFArray &A, const CanonicalForm &F, int i, int j)
search for F in A between index i and j
Definition: facSparseHensel.h:566
spectrum::w
int * w
Definition: semic.h:71
isNotHomog
@ isNotHomog
Definition: structs.h:39
BT_proc
@ BT_proc
Definition: fevoices.h:22
n_Z2m
@ n_Z2m
only used if HAVE_RINGS is defined
Definition: coeffs.h:47
semicMulNegative
@ semicMulNegative
Definition: ipshell.cc:3375
singclap_factorize
ideal singclap_factorize(poly f, intvec **v, int with_exps, const ring r)
Definition: clapsing.cc:854
uResultant::interpolateDenseSP
rootContainer ** interpolateDenseSP(BOOLEAN matchUp=false, const number subDetVal=NULL)
Definition: mpr_base.cc:2923
semicListWrongNumberOfMultiplicities
@ semicListWrongNumberOfMultiplicities
Definition: ipshell.cc:3390
weight.h
cf
CanonicalForm cf
Definition: cfModGcd.cc:4024
myychangebuffer
void myychangebuffer()
Definition: scanner.cc:2330
polys.h
syBetti
intvec * syBetti(resolvente res, int length, int *regularity, intvec *weights, BOOLEAN tomin, int *row_shift)
Definition: syz.cc:771
loNewtonPolytope
ideal loNewtonPolytope(const ideal id)
Definition: mpr_base.cc:3192
IDDATA
#define IDDATA(a)
Definition: ipid.h:121
hNrad
int hNrad
Definition: hutil.cc:22
spectrumPolyList::root
spectrumPolyNode * root
Definition: splist.h:60
BREAK_LINE_LENGTH
#define BREAK_LINE_LENGTH
Definition: ipshell.cc:983
id_QHomWeight
intvec * id_QHomWeight(ideal id, const ring r)
Definition: simpleideals.cc:1535
type_cmd
void type_cmd(leftv v)
Definition: ipshell.cc:246
ip_smatrix::cols
int & cols()
Definition: matpol.h:26
semicListMulNegative
@ semicListMulNegative
Definition: ipshell.cc:3396
rKill
void rKill(ring r)
Definition: ipshell.cc:6076
idGetNextChoise
void idGetNextChoise(int r, int end, BOOLEAN *endch, int *choise)
Definition: simpleideals.cc:855
iiDeclCommand
int iiDeclCommand(leftv sy, leftv name, int lev, int t, idhdl *root, BOOLEAN isring, BOOLEAN init_b)
Definition: ipshell.cc:1122
rComposeVar
static BOOLEAN rComposeVar(const lists L, ring R)
Definition: ipshell.cc:2432
vandermonde
vandermonde system solver for interpolating polynomials from their values
Definition: mpr_numeric.h:28
length
static BOOLEAN length(leftv result, leftv arg)
Definition: interval.cc:267
rDefault
idhdl rDefault(const char *s)
Definition: ipshell.cc:1550
idrec::get
idhdl get(const char *s, int lev)
Definition: ipid.cc:86
procinfo
Definition: subexpr.h:53
yylineno
int yylineno
Definition: febase.cc:40
sattr
Definition: attrib.h:17
liMakeResolv
lists liMakeResolv(resolvente r, int length, int reallen, int typ0, intvec **weights, int add_row_shift)
Definition: lists.cc:216
omStrDup
#define omStrDup(s)
Definition: omAllocDecl.h:263
sign
static int sign(int x)
Definition: ring.cc:3328
spmulProc
BOOLEAN spmulProc(leftv result, leftv first, leftv second)
Definition: ipshell.cc:4408
indset
indlist * indset
Definition: hutil.h:28
list1
static void list1(const char *s, idhdl h, BOOLEAN c, BOOLEAN fullname)
Definition: ipshell.cc:147
mpKoszul
BOOLEAN mpKoszul(leftv res, leftv c, leftv b, leftv id)
Definition: ipshell.cc:3031
n_Delete
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:456
Voice::filename
char * filename
Definition: fevoices.h:63
ssyStrategy::minres
resolvente minres
Definition: syz.h:58
DEF_CMD
@ DEF_CMD
Definition: tok.h:58
n_GF
@ n_GF
\GF{p^n < 2^16}
Definition: coeffs.h:33
iiLocalRing
ring * iiLocalRing
Definition: iplib.cc:454
pNeg
#define pNeg(p)
Definition: polys.h:185
sleftv::attribute
attr attribute
Definition: subexpr.h:89
nInitChar
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
Definition: numbers.cc:349
omAllocBin
#define omAllocBin(bin)
Definition: omAllocDecl.h:205
n_Q
@ n_Q
rational (GMP) numbers
Definition: coeffs.h:31
iiCopyRes
static resolvente iiCopyRes(resolvente r, int l)
Definition: ipshell.cc:855
options.h
semicListPGWrong
@ semicListPGWrong
Definition: ipshell.cc:3402
sqrt
gmp_float sqrt(const gmp_float &a)
Definition: mpr_complex.cc:328
list_is_spectrum
semicState list_is_spectrum(lists l)
Definition: ipshell.cc:4191
ssyStrategy::list_length
short list_length
Definition: syz.h:62
BIGINTMAT_CMD
@ BIGINTMAT_CMD
Definition: grammar.cc:278
omAlloc0Bin
#define omAlloc0Bin(bin)
Definition: omAllocDecl.h:206
semicProc3
BOOLEAN semicProc3(leftv res, leftv u, leftv v, leftv w)
Definition: ipshell.cc:4449
n_Znm
@ n_Znm
only used if HAVE_RINGS is defined
Definition: coeffs.h:46
pDelete
#define pDelete(p_ptr)
Definition: polys.h:173
hDimSolve
void hDimSolve(scmon pure, int Npure, scfmon rad, int Nrad, varset var, int Nvar)
Definition: hdegree.cc:29
spectrumOK
@ spectrumOK
Definition: ipshell.cc:3490
currPack
package currPack
Definition: ipid.cc:59
rTest
#define rTest(r)
Definition: ring.h:777
nIsMOne
#define nIsMOne(n)
Definition: numbers.h:27
hexist
scfmon hexist
Definition: hutil.cc:19
rField_is_Zp_a
static BOOLEAN rField_is_Zp_a(const ring r)
Definition: ring.h:521
nCoeff_is_GF
static FORCE_INLINE BOOLEAN nCoeff_is_GF(const coeffs r)
Definition: coeffs.h:853
newtonPolygon
Definition: npolygon.h:61
scfmon
scmon * scfmon
Definition: hutil.h:15
syReorder
resolvente syReorder(resolvente res, int length, syStrategy syzstr, BOOLEAN toCopy=TRUE, resolvente totake=NULL)
Definition: syz1.cc:1642
Variable::next
Variable next() const
Definition: factory.h:137
testHomog
@ testHomog
Definition: structs.h:41
fe_fgets_stdin
char *(* fe_fgets_stdin)(const char *pr, char *s, int size)
Definition: feread.cc:34
sleftv::RingDependend
BOOLEAN RingDependend()
Definition: subexpr.cc:398
kOptions
BITSET kOptions
Definition: kstd1.cc:44
IDMATRIX
#define IDMATRIX(a)
Definition: ipid.h:129
semicListWrongNumberOfNumerators
@ semicListWrongNumberOfNumerators
Definition: ipshell.cc:3388
idIs0
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
Definition: simpleideals.cc:768
semicListTooLong
@ semicListTooLong
Definition: ipshell.cc:3378
iiOpsTwoChar
int iiOpsTwoChar(const char *s)
Definition: ipshell.cc:119
loop
#define loop
Definition: structs.h:78
vandermonde::numvec2poly
poly numvec2poly(const number *q)
Definition: mpr_numeric.cc:98
sleftv
Class used for (list of) interpreter objects.
Definition: subexpr.h:82
slists::nr
int nr
Definition: lists.h:43
pSetComp
#define pSetComp(p, v)
Definition: polys.h:38
spectrumUnspecErr
@ spectrumUnspecErr
Definition: ipshell.cc:3498
idhdl
idrec * idhdl
Definition: ring.h:21
rCompose
ring rCompose(const lists L, const BOOLEAN check_comp, const long bitmask)
Definition: ipshell.cc:2743
w
const CanonicalForm & w
Definition: facAbsFact.cc:55
rSleftvOrdering2Ordering
BOOLEAN rSleftvOrdering2Ordering(sleftv *ord, ring R)
Definition: ipshell.cc:5223
nCoeff_is_long_C
static FORCE_INLINE BOOLEAN nCoeff_is_long_C(const coeffs r)
Definition: coeffs.h:908
RING_CMD
@ RING_CMD
Definition: grammar.cc:281
spectrumDegenerate
@ spectrumDegenerate
Definition: ipshell.cc:3495
procstack
proclevel * procstack
Definition: ipid.cc:54
b
CanonicalForm b
Definition: cfModGcd.cc:4044
__p_Mult_nn
#define __p_Mult_nn(p, n, r)
Definition: p_polys.h:927
bigintmat.h
semicListSecondElementWrongType
@ semicListSecondElementWrongType
Definition: ipshell.cc:3381
currRingHdl
idhdl currRingHdl
Definition: ipid.cc:61
slists_bin
omBin slists_bin
Definition: lists.cc:23
simplex::posvToIV
intvec * posvToIV()
Definition: mpr_numeric.cc:1077
mprIdealCheck
mprState mprIdealCheck(const ideal theIdeal, const char *name, uResultant::resMatType mtype, BOOLEAN rmatrix=false)
hasAxis
BOOLEAN hasAxis(ideal J, int k, const ring r)
Definition: spectrum.cc:81
fftable
const unsigned short fftable[]
Definition: ffields.cc:31
RingDependend
int RingDependend(int t)
Definition: gentable.cc:29
simplex::m1
int m1
Definition: mpr_numeric.h:200
maApplyFetch
BOOLEAN maApplyFetch(int what, map theMap, leftv res, leftv w, ring preimage_r, int *perm, int *par_perm, int P, nMapFunc nMap)
Definition: maps_ip.cc:46
MATRIX_CMD
@ MATRIX_CMD
Definition: grammar.cc:285
IDLIST
#define IDLIST(a)
Definition: ipid.h:132
semicListMilnorWrong
@ semicListMilnorWrong
Definition: ipshell.cc:3401
pTotaldegree
static long pTotaldegree(poly p)
Definition: polys.h:268
semicListNNegative
@ semicListNNegative
Definition: ipshell.cc:3387
spectrumFromList
spectrum spectrumFromList(lists l)
Definition: ipshell.cc:3322
ANY_TYPE
#define ANY_TYPE
Definition: tok.h:30
n_long_R
@ n_long_R
real floating point (GMP) numbers
Definition: coeffs.h:34
leftv
sleftv * leftv
Definition: structs.h:60
found
bool found
Definition: facFactorize.cc:56
ringorder_C
@ ringorder_C
Definition: ring.h:80
rCopy0
ring rCopy0(const ring r, BOOLEAN copy_qideal, BOOLEAN copy_ordering)
Definition: ring.cc:1325
mu
void mu(int **points, int sizePoints)
Definition: cfNewtonPolygon.cc:467
rIsPluralRing
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
Definition: ring.h:404
IDLEV
#define IDLEV(a)
Definition: ipid.h:116
pLength
static unsigned pLength(poly a)
Definition: p_polys.h:192
rEqual
BOOLEAN rEqual(ring r1, ring r2, BOOLEAN qr)
returns TRUE, if r1 equals r2 FALSE, otherwise Equality is determined componentwise,...
Definition: ring.cc:1620
singclap_resultant
poly singclap_resultant(poly f, poly g, poly x, const ring r)
Definition: clapsing.cc:295
ringorder_Wp
@ ringorder_Wp
Definition: ring.h:89
ringorder_S
@ ringorder_S
S?
Definition: ring.h:82
pi
#define pi
Definition: libparse.cc:1143
spectrum::mu
int mu
Definition: semic.h:67
for
for(int i=0;i<=n;i++) degsf[i]
Definition: cfEzgcd.cc:65
rComposeOrder
static BOOLEAN rComposeOrder(const lists L, const BOOLEAN check_comp, ring R)
Definition: ipshell.cc:2477
packFindHdl
idhdl packFindHdl(package r)
Definition: ipid.cc:742
hNexist
int hNexist
Definition: hutil.cc:22
TransExtInfo::r
ring r
Definition: transext.h:90
currRing
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
stairc.h
rVar
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:583
sleftv::name
const char * name
Definition: subexpr.h:87
IDINTVEC
#define IDINTVEC(a)
Definition: ipid.h:123
rField_is_Ring_Z
static BOOLEAN rField_is_Ring_Z(const ring r)
Definition: ring.h:474
semicListFirstElementWrongType
@ semicListFirstElementWrongType
Definition: ipshell.cc:3380
TRUE
#define TRUE
Definition: auxiliary.h:98
i
int i
Definition: cfEzgcd.cc:125
Lc
CanonicalForm Lc(const CanonicalForm &f)
Definition: canonicalform.h:300
ivCopy
intvec * ivCopy(const intvec *o)
Definition: intvec.h:133
rHasLocalOrMixedOrdering
BOOLEAN rHasLocalOrMixedOrdering(const ring r)
Definition: ring.h:752
AlgExtInfo
struct for passing initialization parameters to naInitChar
Definition: algext.h:37
feread.h
semicListNotSymmetric
@ semicListNotSymmetric
Definition: ipshell.cc:3398
p_PermPoly
poly p_PermPoly(poly p, const int *perm, const ring oldRing, const ring dst, nMapFunc nMap, const int *par_perm, int OldPar, BOOLEAN use_mult)
Definition: p_polys.cc:4014
spectrumNoSingularity
@ spectrumNoSingularity
Definition: ipshell.cc:3493
ip_smatrix::rows
int & rows()
Definition: matpol.h:25
res
CanonicalForm res
Definition: facAbsFact.cc:64
rDecompose_CF
BOOLEAN rDecompose_CF(leftv res, const coeffs C)
Definition: ipshell.cc:1839
nIsOne
#define nIsOne(n)
Definition: numbers.h:26
INT_CMD
@ INT_CMD
Definition: tok.h:96
prCopy.h
ssyStrategy::orderedRes
resolvente orderedRes
Definition: syz.h:48
id_RankFreeModule
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
Definition: simpleideals.cc:782
nMapFunc
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:74
idIsZeroDim
static BOOLEAN idIsZeroDim(ideal i)
Definition: ideals.h:178
indlist_bin
omBin indlist_bin
Definition: hdegree.cc:23
matpol.h
rField_is_Q_a
static BOOLEAN rField_is_Q_a(const ring r)
Definition: ring.h:531
nuUResSolve
BOOLEAN nuUResSolve(leftv res, leftv args)
solve a multipolynomial system using the u-resultant Input ideal must be 0-dimensional and (currRing-...
Definition: ipshell.cc:4846
ringorder_Dp
@ ringorder_Dp
Definition: ring.h:87
Sy_bit
#define Sy_bit(x)
Definition: options.h:32
intvec::min_in
int min_in()
Definition: intvec.h:121
buf
int status int void * buf
Definition: si_signals.h:59
semicListMuNegative
@ semicListMuNegative
Definition: ipshell.cc:3392
syConvList
syStrategy syConvList(lists li)
Definition: ipshell.cc:3194
setGMPFloatDigits
void setGMPFloatDigits(size_t digits, size_t rest)
Set size of mantissa digits - the number of output digits (basis 10) the size of mantissa consists of...
Definition: mpr_complex.cc:61
hpure
scmon hpure
Definition: hutil.cc:20
killlocals_rec
void killlocals_rec(idhdl *root, int v, ring r)
Definition: ipshell.cc:322
PrintS
void PrintS(const char *s)
Definition: reporter.cc:284
omFreeSize
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
BOOLEAN
int BOOLEAN
Definition: auxiliary.h:85
nCoeff_is_algExt
static FORCE_INLINE BOOLEAN nCoeff_is_algExt(const coeffs r)
TRUE iff r represents an algebraic extension field.
Definition: coeffs.h:924
proclevel
Definition: ipid.h:54
killlocals
void killlocals(int v)
Definition: ipshell.cc:378
pTest
#define pTest(p)
Definition: polys.h:401
killhdl2
void killhdl2(idhdl h, idhdl *ih, ring r)
Definition: ipid.cc:407
hwork
scfmon hwork
Definition: hutil.cc:19
hvar
varset hvar
Definition: hutil.cc:21
rComposeC
void rComposeC(lists L, ring R)
Definition: ipshell.cc:2227
sNoName_fe
const char sNoName_fe[]
Definition: fevoices.cc:56
PROC_CMD
@ PROC_CMD
Definition: grammar.cc:280
simplex::m2
int m2
Definition: mpr_numeric.h:200
clapsing.h
hMu2
int hMu2
Definition: hdegree.cc:22
iiApplyIDEAL
BOOLEAN iiApplyIDEAL(leftv, leftv, int, leftv)
Definition: ipshell.cc:6327
procinfo_bin
omBin procinfo_bin
Definition: subexpr.cc:47
simplex::icase
int icase
Definition: mpr_numeric.h:201
rootContainer::getRoot
gmp_complex * getRoot(const int i)
Definition: mpr_numeric.h:88
maMapIdeal
ideal maMapIdeal(const ideal map_id, const ring preimage_r, const ideal image_id, const ring image_r, const nMapFunc nMap)
polynomial map for ideals/module/matrix map_id: the ideal to map map_r: the base ring for map_id imag...
Definition: gen_maps.cc:88
nPrint
#define nPrint(a)
only for debug, over any initalized currRing
Definition: numbers.h:47
kWeight
BOOLEAN kWeight(leftv res, leftv id)
Definition: ipshell.cc:3239
iiExport
BOOLEAN iiExport(leftv v, int toLev)
Definition: ipshell.cc:1414
T
static jList * T
Definition: janet.cc:31
iiRETURNEXPR_len
int iiRETURNEXPR_len
Definition: iplib.cc:456
currentVoice
Voice * currentVoice
Definition: fevoices.cc:48
rmodulon.h
idSkipZeroes
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
Definition: simpleideals.cc:172
iiCurrProc
idhdl iiCurrProc
Definition: ipshell.cc:79
iiGetLibProcBuffer
char * iiGetLibProcBuffer(procinfo *pi, int part)
Definition: iplib.cc:192
rField_is_Ring
static BOOLEAN rField_is_Ring(const ring r)
Definition: ring.h:477
denominator_list_s
Definition: kutil.h:61
IDROOT
#define IDROOT
Definition: ipid.h:18
syForceMin
syStrategy syForceMin(lists li)
Definition: ipshell.cc:3223
jjPROC
BOOLEAN jjPROC(leftv res, leftv u, leftv v)
Definition: iparith.cc:1527
ringorder_M
@ ringorder_M
Definition: ring.h:81
sleftv::Init
void Init()
Definition: subexpr.h:107
char_ptr
char * char_ptr
Definition: structs.h:56
resolvente
ideal * resolvente
Definition: ideals.h:18
semicListWrongNumberOfDenominators
@ semicListWrongNumberOfDenominators
Definition: ipshell.cc:3389
nCoeff_is_Ring
static FORCE_INLINE BOOLEAN nCoeff_is_Ring(const coeffs r)
Definition: coeffs.h:759
spectrum::copy_new
void copy_new(int)
Definition: semic.cc:54
hrad
scfmon hrad
Definition: hutil.cc:19
iiMakeResolv
void iiMakeResolv(resolvente r, int length, int rlen, char *name, int typ0, intvec **weights)
Definition: ipshell.cc:766
IDEAL_CMD
@ IDEAL_CMD
Definition: grammar.cc:283
spectrumStateFromList
spectrumState spectrumStateFromList(spectrumPolyList &speclist, lists *L, int fast)
Definition: ipshell.cc:3507
h
static Poly * h
Definition: janet.cc:972
lRingDependend
BOOLEAN lRingDependend(lists L)
Definition: lists.cc:199
semicProc
BOOLEAN semicProc(leftv res, leftv u, leftv v)
Definition: ipshell.cc:4489
mod2.h
GFInfo::GFDegree
int GFDegree
Definition: coeffs.h:96
spectrumWrongRing
@ spectrumWrongRing
Definition: ipshell.cc:3496
rDecompose
lists rDecompose(const ring r)
Definition: ipshell.cc:2041
hKill
void hKill(monf xmem, int Nvar)
Definition: hutil.cc:1016
jjBETTI
BOOLEAN jjBETTI(leftv res, leftv u)
Definition: ipshell.cc:886
iiTestAssume
BOOLEAN iiTestAssume(leftv a, leftv b)
Definition: ipshell.cc:6386
coeffs
pOne
#define pOne()
Definition: polys.h:301
atSet
void atSet(idhdl root, char *name, void *data, int typ)
Definition: attrib.cc:152
EQUAL_EQUAL
@ EQUAL_EQUAL
Definition: grammar.cc:268
singclap_irrCharSeries
matrix singclap_irrCharSeries(ideal I, const ring r)
Definition: clapsing.cc:1456
TRACE_SHOW_RINGS
#define TRACE_SHOW_RINGS
Definition: reporter.h:35
intvec
Definition: intvec.h:17
IDPROC
#define IDPROC(a)
Definition: ipid.h:135
LE
@ LE
Definition: grammar.cc:270
n_Z
@ n_Z
only used if HAVE_RINGS is defined
Definition: coeffs.h:44
sleftv::data
void * data
Definition: subexpr.h:88
spectrumPolyNode
Definition: splist.h:35
pIter
#define pIter(p)
Definition: monomials.h:44
list_cmd
void list_cmd(int typ, const char *what, const char *prefix, BOOLEAN iterate, BOOLEAN fullname)
Definition: ipshell.cc:417
rRenameVars
static void rRenameVars(ring R)
Definition: ipshell.cc:2391
omAlloc
#define omAlloc(size)
Definition: omAllocDecl.h:210
PLUSPLUS
@ PLUSPLUS
Definition: grammar.cc:274
ssyStrategy::length
int length
Definition: syz.h:60
spaddProc
BOOLEAN spaddProc(leftv result, leftv first, leftv second)
Definition: ipshell.cc:4366
LANG_C
@ LANG_C
Definition: subexpr.h:24
rPar
static int rPar(const ring r)
(r->cf->P)
Definition: ring.h:590
GFInfo::GFPar_name
const char * GFPar_name
Definition: coeffs.h:97
hDelete
void hDelete(scfmon ev, int ev_length)
Definition: hutil.cc:146
fevoices.h
iiNoKeepRing
static BOOLEAN iiNoKeepRing
Definition: ipshell.cc:82
uResultant::accessResMat
resMatrixBase * accessResMat()
Definition: mpr_base.h:78
LongComplexInfo::float_len
short float_len
additional char-flags, rInit
Definition: coeffs.h:102
syBettiOfComputation
intvec * syBettiOfComputation(syStrategy syzstr, BOOLEAN minim=TRUE, int *row_shift=NULL, intvec *weights=NULL)
Definition: syz1.cc:1756
MAX_SHORT
const short MAX_SHORT
Definition: ipshell.cc:5531
rootArranger
Definition: mpr_numeric.h:149
p_Init
static poly p_Init(const ring r, omBin bin)
Definition: p_polys.h:1266
VECTOR_CMD
@ VECTOR_CMD
Definition: grammar.cc:290
myynest
int myynest
Definition: febase.cc:41
rField_is_R
static BOOLEAN rField_is_R(const ring r)
Definition: ring.h:510
wFunctional
double(* wFunctional)(int *degw, int *lpol, int npol, double *rel, double wx, double wNsqr)
Definition: weight.cc:26
semicListDenNegative
@ semicListDenNegative
Definition: ipshell.cc:3395
ringorder_am
@ ringorder_am
Definition: ring.h:95
idrec::attribute
attr attribute
Definition: idrec.h:41
IDTYP
#define IDTYP(a)
Definition: ipid.h:114
scIndIndset
lists scIndIndset(ideal S, BOOLEAN all, ideal Q)
Definition: ipshell.cc:1022
sattr::CopyA
void * CopyA()
Definition: subexpr.cc:1944
maps.h
slists::m
sleftv * m
Definition: lists.h:45
computeWC
poly computeWC(const newtonPolygon &np, Rational max_weight, const ring r)
Definition: spectrum.cc:142
hCo
int hCo
Definition: hdegree.cc:22
intvec.h
rBlocks
static int rBlocks(ring r)
Definition: ring.h:559
__pp_Mult_nn
#define __pp_Mult_nn(p, n, r)
Definition: p_polys.h:958
subexpr.h
iiTestConvert
int iiTestConvert(int inputType, int outputType)
Definition: gentable.cc:299
VoiceBackTrack
void VoiceBackTrack()
Definition: fevoices.cc:68
my_yylinebuf
char my_yylinebuf[80]
Definition: febase.cc:43
den
CanonicalForm den(const CanonicalForm &f)
Definition: canonicalform.h:333
LANG_NONE
@ LANG_NONE
Definition: subexpr.h:24
nuMPResMat
BOOLEAN nuMPResMat(leftv res, leftv arg1, leftv arg2)
returns module representing the multipolynomial resultant matrix Arguments 2: ideal i,...
Definition: ipshell.cc:4593
sleftv::CleanUp
void CleanUp(ring r=currRing)
Definition: subexpr.cc:328
rSimpleFindHdl
idhdl rSimpleFindHdl(ring r, idhdl root, idhdl n)
Definition: ipshell.cc:6165
ipconv.h
wCall
void wCall(poly *s, int sl, int *x, double wNsqr, const ring R)
Definition: weight.cc:114
idGetNumberOfChoise
int idGetNumberOfChoise(int t, int d, int begin, int end, int *choise)
Definition: simpleideals.cc:881
hIndAllMult
void hIndAllMult(scmon pure, int Npure, scfmon rad, int Nrad, varset var, int Nvar)
Definition: hdegree.cc:496
scmon
int * scmon
Definition: hutil.h:14
nCoeff_is_transExt
static FORCE_INLINE BOOLEAN nCoeff_is_transExt(const coeffs r)
TRUE iff r represents a transcendental extension field.
Definition: coeffs.h:932
siq
BOOLEAN siq
Definition: subexpr.cc:53
mpNew
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:36
rootContainer::fillContainer
void fillContainer(number *_coeffs, number *_ievpoint, const int _var, const int _tdg, const rootType _rt, const int _anz)
Definition: mpr_numeric.cc:304
ringorder_c
@ ringorder_c
Definition: ring.h:79
ringorder_lp
@ ringorder_lp
Definition: ring.h:84
complexToStr
char * complexToStr(gmp_complex &c, const unsigned int oprec, const coeffs src)
Definition: mpr_complex.cc:705
nlMapGMP
number nlMapGMP(number from, const coeffs src, const coeffs dst)
Definition: longrat.cc:201
last
static poly last
Definition: hdegree.cc:1077
jjVARIABLES_P
BOOLEAN jjVARIABLES_P(leftv res, leftv u)
Definition: ipshell.cc:6250
DENOMINATOR_LIST
denominator_list DENOMINATOR_LIST
Definition: kutil.cc:87
n_transExt
@ n_transExt
used for all transcendental extensions, i.e., the top-most extension in an extension tower is transce...
Definition: coeffs.h:39
semicListTooShort
@ semicListTooShort
Definition: ipshell.cc:3377
IDRING
#define IDRING(a)
Definition: ipid.h:122
ringorder_dp
@ ringorder_dp
Definition: ring.h:85
iiDefaultParameter
BOOLEAN iiDefaultParameter(leftv p)
Definition: ipshell.cc:1166
simplex
Linear Programming / Linear Optimization using Simplex - Algorithm.
Definition: mpr_numeric.h:194
exprlist_length
int exprlist_length(leftv v)
Definition: ipshell.cc:544
iiInternalExport
static BOOLEAN iiInternalExport(leftv v, int toLev)
Definition: ipshell.cc:1316
hNpure
int hNpure
Definition: hutil.cc:22
n_R
@ n_R
single prescision (6,6) real numbers
Definition: coeffs.h:32
pDecrExp
#define pDecrExp(p, i)
Definition: polys.h:44
n_ParameterNames
static FORCE_INLINE const char ** n_ParameterNames(const coeffs r)
Returns a (const!) pointer to (const char*) names of parameters.
Definition: coeffs.h:809
slists
Definition: lists.h:22
uResultant
Base class for solving 0-dim poly systems using u-resultant.
Definition: mpr_base.h:62
hPure
void hPure(scfmon stc, int a, int *Nstc, varset var, int Nvar, scmon pure, int *Npure)
Definition: hutil.cc:627
hasConstTerm
BOOLEAN hasConstTerm(poly h, const ring r)
Definition: spectrum.h:28
liFindRes
resolvente liFindRes(lists L, int *len, int *typ0, intvec ***weights)
Definition: lists.cc:315
idrec::next
idhdl next
Definition: idrec.h:38
jjRESULTANT
BOOLEAN jjRESULTANT(leftv res, leftv u, leftv v, leftv w)
Definition: ipshell.cc:3278
rDelete
void rDelete(ring r)
unconditionally deletes fields in r
Definition: ring.cc:439
INTVEC_CMD
@ INTVEC_CMD
Definition: tok.h:101
determineMType
uResultant::resMatType determineMType(int imtype)
INTMAT_CMD
@ INTMAT_CMD
Definition: grammar.cc:279
iiReportTypes
static void iiReportTypes(int nr, int t, const short *T)
Definition: ipshell.cc:6485
rFindHdl
idhdl rFindHdl(ring r, idhdl n)
Definition: ipshell.cc:1595
sip_sring_bin
omBin sip_sring_bin
Definition: ring.cc:44
nIsZero
#define nIsZero(n)
Definition: numbers.h:20
IMATELEM
#define IMATELEM(M, I, J)
Definition: intvec.h:85
coeffs_BIGINT
coeffs coeffs_BIGINT
Definition: ipid.cc:52
ring.h
idrec
Definition: idrec.h:34
iiInitSingularProcinfo
procinfo * iiInitSingularProcinfo(procinfov pi, const char *libname, const char *procname, int, long pos, BOOLEAN pstatic)
Definition: iplib.cc:991
varset
int * varset
Definition: hutil.h:16
transext.h
hInit
scfmon hInit(ideal S, ideal Q, int *Nexist, ring tailRing)
Definition: hutil.cc:34
kstd1.h
IsCmd
int IsCmd(const char *n, int &tok)
Definition: iparith.cc:8679
rField_is_numeric
static BOOLEAN rField_is_numeric(const ring r)
Definition: ring.h:507
maps_ip.h
rField_is_GF
static BOOLEAN rField_is_GF(const ring r)
Definition: ring.h:513
rInit
ring rInit(leftv pn, leftv rv, leftv ord)
Definition: ipshell.cc:5543
nc_CallPlural
BOOLEAN nc_CallPlural(matrix cc, matrix dd, poly cn, poly dn, ring r, bool bSetupQuotient, bool bCopyInput, bool bBeQuiet, ring curr, bool dummy_ring=false)
returns TRUE if there were errors analyze inputs, check them for consistency detects nc_type,...
Definition: old.gring.cc:2681
ALIAS_CMD
@ ALIAS_CMD
Definition: tok.h:34
spectrumNoHC
@ spectrumNoHC
Definition: ipshell.cc:3497
sleftv::Attribute
attr * Attribute()
Definition: subexpr.cc:1389
rootContainer::getAnzRoots
int getAnzRoots()
Definition: mpr_numeric.h:97
spectrumPolyList
Definition: splist.h:56
libparse.h
hNvar
int hNvar
Definition: hutil.cc:22
Rational::get_den_si
int get_den_si()
Definition: GMPrat.cc:155
pDiff
#define pDiff(a, b)
Definition: polys.h:282
rDecomposeCF
void rDecomposeCF(leftv h, const ring r, const ring R)
Definition: ipshell.cc:1621
simplex::m3
int m3
Definition: mpr_numeric.h:200
IDPACKAGE
#define IDPACKAGE(a)
Definition: ipid.h:134
Rational::get_num_si
int get_num_si()
Definition: GMPrat.cc:141
n_Zp
@ n_Zp
\F{p < 2^31}
Definition: coeffs.h:30
mpr_numeric.h
iiWRITE
BOOLEAN iiWRITE(leftv, leftv v)
Definition: ipshell.cc:580
spectrumProc
BOOLEAN spectrumProc(leftv result, leftv first)
Definition: ipshell.cc:4071
si_max
static int si_max(const int a, const int b)
Definition: auxiliary.h:138
jjVARIABLES_ID
BOOLEAN jjVARIABLES_ID(leftv res, leftv u)
Definition: ipshell.cc:6258
mpr_base.h
mult
void mult(unsigned long *result, unsigned long *a, unsigned long *b, unsigned long p, int dega, int degb)
Definition: minpoly.cc:647
simplex::zrovToIV
intvec * zrovToIV()
Definition: mpr_numeric.cc:1088
list_error
void list_error(semicState state)
Definition: ipshell.cc:3406
resMatrixBase::ready
@ ready
Definition: mpr_base.h:26
iiDebug
void iiDebug()
Definition: ipshell.cc:984
iiMap
leftv iiMap(map theMap, const char *what)
Definition: ipshell.cc:607
spectrum::mult_spectrum
int mult_spectrum(spectrum &)
Definition: semic.cc:396
ringIsLocal
BOOLEAN ringIsLocal(const ring r)
Definition: spectrum.cc:461
semicListFifthElementWrongType
@ semicListFifthElementWrongType
Definition: ipshell.cc:3384
ringorder_a
@ ringorder_a
Definition: ring.h:77
BVERBOSE
#define BVERBOSE(a)
Definition: options.h:35
prime.h
Print
#define Print
Definition: emacs.cc:80
nInvers
#define nInvers(a)
Definition: numbers.h:34
QRING_CMD
@ QRING_CMD
Definition: tok.h:158
spectrumNotIsolated
@ spectrumNotIsolated
Definition: ipshell.cc:3494
spectrumPrintError
void spectrumPrintError(spectrumState state)
Definition: ipshell.cc:4040
iiTwoOps
const char * iiTwoOps(int t)
Definition: ipshell.cc:86
mylimits.h
iiRETURNEXPR
sleftv iiRETURNEXPR
Definition: iplib.cc:455
VoiceName
const char * VoiceName()
Definition: fevoices.cc:57
spectrumPolyList::delete_node
void delete_node(spectrumPolyNode **)
Definition: splist.cc:256
iiApplyINTVEC
BOOLEAN iiApplyINTVEC(leftv res, leftv a, int op, leftv proc)
Definition: ipshell.cc:6290
hSupp
void hSupp(scfmon stc, int Nstc, varset var, int *Nvar)
Definition: hutil.cc:180
rSetSyzComp
void rSetSyzComp(int k, const ring r)
Definition: ring.cc:4973
ringorder_IS
@ ringorder_IS
Induced (Schreyer) ordering.
Definition: ring.h:100
atGet
void * atGet(idhdl root, const char *name, int t, void *defaultReturnValue)
Definition: attrib.cc:131
Werror
void Werror(const char *fmt,...)
Definition: reporter.cc:189
int64
long int64
Definition: auxiliary.h:66
idInitChoise
void idInitChoise(int r, int beg, int end, BOOLEAN *endch, int *choise)
Definition: simpleideals.cc:833
rOptimizeOrdAsSleftv
static leftv rOptimizeOrdAsSleftv(leftv ord)
Definition: ipshell.cc:5111
pIsPurePower
#define pIsPurePower(p)
Definition: polys.h:235
idInit
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:37
hasOne
int hasOne(ideal J, const ring r)
Definition: spectrum.cc:96
rSimpleOrdStr
const char * rSimpleOrdStr(int ord)
Definition: ring.cc:78
PACKAGE_CMD
@ PACKAGE_CMD
Definition: tok.h:149
ringorder_ls
@ ringorder_ls
Definition: ring.h:90
ringorder_rp
@ ringorder_rp
Definition: ring.h:86
rootArranger::success
bool success()
Definition: mpr_numeric.h:162
name
char name(const Variable &v)
Definition: factory.h:180
pSetCoeff0
#define pSetCoeff0(p, n)
Definition: monomials.h:66
tok.h
IDHDL
#define IDHDL
Definition: tok.h:31
lString
char * lString(lists l, BOOLEAN typed, int dim)
Definition: lists.cc:380
n_Copy
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of 'n'
Definition: coeffs.h:452
yyparse
int yyparse(void)
Definition: grammar.cc:2109
pow
Rational pow(const Rational &a, int e)
Definition: GMPrat.cc:414
WerrorS
void WerrorS(const char *s)
Definition: feFopen.cc:24
JSet
indset JSet
Definition: hdegree.cc:279
rootArranger::arrange
void arrange()
Definition: mpr_numeric.cc:887
ringorder_s
@ ringorder_s
s?
Definition: ring.h:83
sleftv::Typ
int Typ()
Definition: subexpr.cc:992
m
int m
Definition: cfEzgcd.cc:121
idrec::typ
int typ
Definition: idrec.h:43
MATCOLS
#define MATCOLS(i)
Definition: matpol.h:29
WarnS
#define WarnS
Definition: emacs.cc:78
iiHighCorner
poly iiHighCorner(ideal I, int ak)
Definition: ipshell.cc:1512
Variable::name
char name() const
Definition: variable.cc:122
sleftv::rtyp
int rtyp
Definition: subexpr.h:91
syz.h
basePack
package basePack
Definition: ipid.cc:60
assume
#define assume(x)
Definition: mod2.h:390
ringorder_L
@ ringorder_L
Definition: ring.h:96
semicListNotMonotonous
@ semicListNotMonotonous
Definition: ipshell.cc:3399
hisModule
int hisModule
Definition: hutil.cc:23
sLastPrinted
sleftv sLastPrinted
Definition: subexpr.cc:51
sleftv::listLength
int listLength()
Definition: subexpr.cc:56
NULL
#define NULL
Definition: omList.c:10
resMatrixBase::getMatrix
virtual ideal getMatrix()
Definition: mpr_base.h:31
MAP_CMD
@ MAP_CMD
Definition: grammar.cc:284
sleftv::CopyD
void * CopyD(int t)
Definition: subexpr.cc:703
nCoeffName
static FORCE_INLINE char * nCoeffName(const coeffs cf)
Definition: coeffs.h:977
lists
slists * lists
Definition: mpr_numeric.h:146
iiARROW
BOOLEAN iiARROW(leftv r, char *a, char *s)
Definition: ipshell.cc:6413
sleftv::Copy
void Copy(leftv e)
Definition: subexpr.cc:684
ringorder_Ws
@ ringorder_Ws
Definition: ring.h:94
pSetm
#define pSetm(p)
Definition: polys.h:257
ringorder_no
@ ringorder_no
Definition: ring.h:76
sdb.h
semicListSixthElementWrongType
@ semicListSixthElementWrongType
Definition: ipshell.cc:3385
rSleftvList2StringArray
static BOOLEAN rSleftvList2StringArray(leftv sl, char **p)
Definition: ipshell.cc:5495
computeNF
void computeNF(ideal stdJ, poly hc, poly wc, spectrumPolyList *NF, const ring r)
Definition: spectrum.cc:309
maFindPerm
void maFindPerm(char const *const *const preim_names, int preim_n, char const *const *const preim_par, int preim_p, char const *const *const names, int n, char const *const *const par, int nop, int *perm, int *par_perm, n_coeffType ch)
Definition: maps.cc:165
ideals.h
jjINT_S_TO_ID
static void jjINT_S_TO_ID(int n, int *e, leftv res)
Definition: ipshell.cc:6228
currPackHdl
idhdl currPackHdl
Definition: ipid.cc:57
l
int l
Definition: cfEzgcd.cc:93
IDSTRING
#define IDSTRING(a)
Definition: ipid.h:131
killlocals0
static void killlocals0(int v, idhdl *localhdl, const ring r)
Definition: ipshell.cc:287
nDelete
#define nDelete(n)
Definition: numbers.h:17
simplex::compute
void compute()
Definition: mpr_numeric.cc:1099
IDNEXT
#define IDNEXT(a)
Definition: ipid.h:113
n_Int
static FORCE_INLINE long n_Int(number &n, const coeffs r)
conversion of n to an int; 0 if not possible in Z/pZ: the representing int lying in (-p/2 ....
Definition: coeffs.h:548
binom
int binom(int n, int r)
Definition: simpleideals.cc:913
omRealloc0Size
#define omRealloc0Size(addr, o_size, size)
Definition: omAllocDecl.h:221
R
#define R
Definition: sirandom.c:26
rootArranger::solve_all
void solve_all()
Definition: mpr_numeric.cc:862
spectrum
Definition: semic.h:63
intvec::rows
int rows() const
Definition: intvec.h:96
validOpts
BITSET validOpts
Definition: kstd1.cc:59
iiCheckRing
BOOLEAN iiCheckRing(int i)
Definition: ipshell.cc:1492
rAssure_HasComp
ring rAssure_HasComp(const ring r)
Definition: ring.cc:4540
listOfRoots
lists listOfRoots(rootArranger *self, const unsigned int oprec)
Definition: ipshell.cc:5003
Warn
#define Warn
Definition: emacs.cc:77
semicListPgNegative
@ semicListPgNegative
Definition: ipshell.cc:3393
traceit
int traceit
Definition: febase.cc:42
pSetExp
#define pSetExp(p, i, v)
Definition: polys.h:42
v
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
ringorder_wp
@ ringorder_wp
Definition: ring.h:88
sleftv_bin
omBin sleftv_bin
Definition: subexpr.cc:46
denominator_list_s::next
denominator_list next
Definition: kutil.h:61
omCheckAddr
#define omCheckAddr(addr)
Definition: omAllocDecl.h:328
slists::Init
INLINE_THIS void Init(int l=0)
ISet
indset ISet
Definition: hdegree.cc:279
GE
@ GE
Definition: grammar.cc:269
simplex::mapFromMatrix
BOOLEAN mapFromMatrix(matrix m)
Definition: mpr_numeric.cc:1015
p_Totaldegree
static long p_Totaldegree(poly p, const ring r)
Definition: p_polys.h:1453
jjCHARSERIES
BOOLEAN jjCHARSERIES(leftv res, leftv u)
Definition: ipshell.cc:3285
p
int p
Definition: cfModGcd.cc:4019
LongComplexInfo::par_name
const char * par_name
parameter name
Definition: coeffs.h:104
iiCurrArgs
leftv iiCurrArgs
Definition: ipshell.cc:78
sleftv::Name
const char * Name()
Definition: subexpr.h:120
setFlag
#define setFlag(A, F)
Definition: ipid.h:108
longrat.h
ZnmInfo
Definition: rmodulon.h:18
iiApplyBIGINTMAT
BOOLEAN iiApplyBIGINTMAT(leftv, leftv, int, leftv)
Definition: ipshell.cc:6322
ringorder_unspec
@ ringorder_unspec
Definition: ring.h:101
spectrum::mult_spectrumh
int mult_spectrumh(spectrum &)
Definition: semic.cc:425
spectrum::s
Rational * s
Definition: semic.h:70
ringorder_aa
@ ringorder_aa
for idElimination, like a, except pFDeg, pWeigths ignore it
Definition: ring.h:98
semic.h
ggetid
idhdl ggetid(const char *n)
Definition: ipid.cc:513
s
const CanonicalForm int s
Definition: facAbsFact.cc:55
iiCheckTypes
BOOLEAN iiCheckTypes(leftv args, const short *type_list, int report)
check a list of arguemys against a given field of types return TRUE if the types match return FALSE (...
Definition: ipshell.cc:6503
rTypeOfMatrixOrder
int rTypeOfMatrixOrder(const intvec *order)
Definition: ring.cc:186
nInit
#define nInit(i)
Definition: numbers.h:25
POLY_CMD
@ POLY_CMD
Definition: grammar.cc:288
count
int status int void size_t count
Definition: si_signals.h:59
Tok2Cmdname
const char * Tok2Cmdname(int tok)
Definition: gentable.cc:138
NOTEQUAL
@ NOTEQUAL
Definition: grammar.cc:273
IDID
#define IDID(a)
Definition: ipid.h:117
rDecompose_list_cf
lists rDecompose_list_cf(const ring r)
Definition: ipshell.cc:1910
rootContainer::getAnzElems
int getAnzElems()
Definition: mpr_numeric.h:95
ssyStrategy::hilb_coeffs
intvec ** hilb_coeffs
Definition: syz.h:46
pCopy
#define pCopy(p)
return a copy of the poly
Definition: polys.h:172
spectrumCompute
spectrumState spectrumCompute(poly h, lists *L, int fast)
Definition: ipshell.cc:3748
ipshell.h
n_SetMap
static FORCE_INLINE nMapFunc n_SetMap(const coeffs src, const coeffs dst)
set the mapping function pointers for translating numbers from src to dst
Definition: coeffs.h:722
IDELEMS
#define IDELEMS(i)
Definition: simpleideals.h:26
mpJacobi
BOOLEAN mpJacobi(leftv res, leftv a)
Definition: ipshell.cc:3009
iiParameter
BOOLEAN iiParameter(leftv p)
Definition: ipshell.cc:1280
multiplicity
static int * multiplicity
Definition: interpolation.cc:86
kStd
ideal kStd(ideal F, ideal Q, tHomog h, intvec **w, intvec *hilb, int syzComp, int newIdeal, intvec *vw, s_poly_proc_t sp)
Definition: kstd1.cc:2096
rDecomposeRing_41
void rDecomposeRing_41(leftv h, const coeffs C)
Definition: ipshell.cc:1779
Q
#define Q
Definition: sirandom.c:25
semicState
semicState
Definition: ipshell.cc:3372
int_ptr
int * int_ptr
Definition: structs.h:57
ringorder_rs
@ ringorder_rs
opposite of ls
Definition: ring.h:99
ringorder_a64
@ ringorder_a64
for int64 weights
Definition: ring.h:78
FLAG_STD
#define FLAG_STD
Definition: ipid.h:104
radmem
monf radmem
Definition: hutil.cc:24
rootContainer
complex root finder for univariate polynomials based on laguers algorithm
Definition: mpr_numeric.h:65
pGetCoeff
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
getList
lists getList(spectrum &spec)
Definition: ipshell.cc:3334
tmp2
CFList tmp2
Definition: facFqBivar.cc:70
denominator_list_s::n
number n
Definition: kutil.h:61
V_REDEFINE
#define V_REDEFINE
Definition: options.h:45
PrintLn
void PrintLn()
Definition: reporter.cc:310
simplex::n
int n
Definition: mpr_numeric.h:199
ssyStrategy::res
resolvente res
Definition: syz.h:47
rParameter
static const char ** rParameter(const ring r)
(r->cf->parameter)
Definition: ring.h:616
syConvRes
lists syConvRes(syStrategy syzstr, BOOLEAN toDel, int add_row_shift)
Definition: ipshell.cc:3122
mp_Copy
matrix mp_Copy(matrix a, const ring r)
copies matrix a (from ring r to r)
Definition: matpol.cc:63
sattr::atyp
int atyp
Definition: attrib.h:27
intvec::length
int length() const
Definition: intvec.h:94
rField_is_long_C
static BOOLEAN rField_is_long_C(const ring r)
Definition: ring.h:537
MATROWS
#define MATROWS(i)
Definition: matpol.h:28
proc
unsigned char * proc[NUM_PROC]
Definition: checklibs.c:16
sattr::get
attr get(const char *s)
Definition: attrib.cc:92
splist.h
omFreeBin
#define omFreeBin(addr, bin)
Definition: omAllocDecl.h:259
MINUSMINUS
@ MINUSMINUS
Definition: grammar.cc:271
spectrum.h
rField_is_Zp
static BOOLEAN rField_is_Zp(const ring r)
Definition: ring.h:495
newBuffer
void newBuffer(char *s, feBufferTypes t, procinfo *pi, int lineno)
Definition: fevoices.cc:157
TEST_V_ALLWARN
#define TEST_V_ALLWARN
Definition: options.h:140
algext.h
AlgExtInfo::r
ring r
Definition: algext.h:39
loNewtonP
BOOLEAN loNewtonP(leftv res, leftv arg1)
compute Newton Polytopes of input polynomials
Definition: ipshell.cc:4501
pGetVariables
#define pGetVariables(p, e)
Definition: polys.h:238
hLexR
void hLexR(scfmon rad, int Nrad, varset var, int Nvar)
Definition: hutil.cc:571
n_MPZ
static FORCE_INLINE void n_MPZ(mpz_t result, number &n, const coeffs r)
conversion of n to a GMP integer; 0 if not possible
Definition: coeffs.h:552
rOrderName
rRingOrder_t rOrderName(char *ordername)
Definition: ring.cc:499
loSimplex
BOOLEAN loSimplex(leftv res, leftv args)
Implementation of the Simplex Algorithm.
Definition: ipshell.cc:4507
pSub
#define pSub(a, b)
Definition: polys.h:273
nCoeff_is_Ring_Z
static FORCE_INLINE BOOLEAN nCoeff_is_Ring_Z(const coeffs r)
Definition: coeffs.h:756
nCopy
#define nCopy(n)
Definition: numbers.h:16
iiAssign
BOOLEAN iiAssign(leftv l, leftv r, BOOLEAN toplevel)
Definition: ipassign.cc:1792
info
const ExtensionInfo & info
< [in] sqrfree poly
Definition: facFqFactorize.h:38
rRingOrder_t
rRingOrder_t
order stuff
Definition: ring.h:74
LINK_CMD
@ LINK_CMD
Definition: tok.h:117
numbers.h
buf2
CanonicalForm buf2
Definition: facFqBivar.cc:71
ssyStrategy::weights
intvec ** weights
Definition: syz.h:45
semicListFourthElementWrongType
@ semicListFourthElementWrongType
Definition: ipshell.cc:3383
pNext
#define pNext(p)
Definition: monomials.h:43
kQHWeight
BOOLEAN kQHWeight(leftv res, leftv v)
Definition: ipshell.cc:3261
CMATRIX_CMD
@ CMATRIX_CMD
Definition: tok.h:46
simplex::mapToMatrix
matrix mapToMatrix(matrix m)
Definition: mpr_numeric.cc:1044
ipid.h
omAlloc0
#define omAlloc0(size)
Definition: omAllocDecl.h:211
nuLagSolve
BOOLEAN nuLagSolve(leftv res, leftv arg1, leftv arg2, leftv arg3)
find the (complex) roots an univariate polynomial Determines the roots of an univariate polynomial us...
Definition: ipshell.cc:4616
nSetMap
#define nSetMap(R)
Definition: numbers.h:44
Voice::fptr
long fptr
Definition: fevoices.h:70
semicOK
@ semicOK
Definition: ipshell.cc:3374
rDecomposeC_41
static void rDecomposeC_41(leftv h, const coeffs C)
Definition: ipshell.cc:1709
pCmp
#define pCmp(p1, p2)
pCmp: args may be NULL returns: (p2==NULL ? 1 : (p1 == NULL ? -1 : p_LmCmp(p1, p2)))
Definition: polys.h:115
Rational
Definition: GMPrat.h:14
spectrumState
spectrumState
Definition: ipshell.cc:3488
rSetHdl
void rSetHdl(idhdl h)
Definition: ipshell.cc:5050
if
if(yy_init)
Definition: libparse.cc:1418
syKillComputation
void syKillComputation(syStrategy syzstr, ring r=currRing)
Definition: syz1.cc:1496
rSubring
ring rSubring(ring org_ring, sleftv *rv)
Definition: ipshell.cc:5914
package
ip_package * package
Definition: structs.h:46
syKillEmptyEntres
void syKillEmptyEntres(resolvente res, int length)
Definition: syz1.cc:2201
spectrum::n
int n
Definition: semic.h:69
sleftv::next
leftv next
Definition: subexpr.h:86
IDIDEAL
#define IDIDEAL(a)
Definition: ipid.h:128
killlocals_list
BOOLEAN killlocals_list(int v, lists L)
Definition: ipshell.cc:358
uResultant::specializeInU
rootContainer ** specializeInU(BOOLEAN matchUp=false, const number subDetVal=NULL)
Definition: mpr_base.cc:3061
sdb_flags
int sdb_flags
Definition: sdb.cc:32
si_opt_2
unsigned si_opt_2
Definition: options.c:6
spectrumBadPoly
@ spectrumBadPoly
Definition: ipshell.cc:3492
idrCopyR
ideal idrCopyR(ideal id, ring src_r, ring dest_r)
Definition: prCopy.cc:192
rDecomposeRing
void rDecomposeRing(leftv h, const ring R)
Definition: ipshell.cc:1807
ssyStrategy
Definition: syz.h:37
n_algExt
@ n_algExt
used for all algebraic extensions, i.e., the top-most extension in an extension tower is algebraic
Definition: coeffs.h:36
coeffs.h
hCreate
monf hCreate(int Nvar)
Definition: hutil.cc:1002
rField_is_Q
static BOOLEAN rField_is_Q(const ring r)
Definition: ring.h:501
iiApply
BOOLEAN iiApply(leftv res, leftv a, int op, leftv proc)
Definition: ipshell.cc:6364
rInternalChar
static int rInternalChar(const ring r)
Definition: ring.h:680
spectrum::pg
int pg
Definition: semic.h:68
iiBranchTo
BOOLEAN iiBranchTo(leftv, leftv args)
Definition: ipshell.cc:1179
rComplete
BOOLEAN rComplete(ring r, int force)
this needs to be called whenever a new ring is created: new fields in ring are created (like VarOffse...
Definition: ring.cc:3351
pWrite
void pWrite(poly p)
Definition: polys.h:294
omReallocSize
#define omReallocSize(addr, o_size, size)
Definition: omAllocDecl.h:220
wrp
void wrp(poly p)
Definition: polys.h:296
nlGMP
void nlGMP(number &i, mpz_t n, const coeffs r)
Definition: longrat.cc:1478
omfree
#define omfree(addr)
Definition: omAllocDecl.h:237
hasLinearTerm
BOOLEAN hasLinearTerm(poly h, const ring r)
Definition: spectrum.h:30
slists::Clean
void Clean(ring r=currRing)
Definition: lists.h:25
DOTDOT
@ DOTDOT
Definition: grammar.cc:267
idMaxIdeal
#define idMaxIdeal(D)
initialise the maximal ideal (at 0)
Definition: ideals.h:33
si_opt_1
unsigned si_opt_1
Definition: options.c:5