My Project
extra.cc
Go to the documentation of this file.
1 /*****************************************
2 * Computer Algebra System SINGULAR *
3 *****************************************/
4 /*
5 * ABSTRACT: general interface to internals of Singular ("system" command)
6 * jjSYSTEM: official commands, must be documented in the manual,
7 * #defines must be local to each command
8 * jjEXTENDED_SYSTEM: tests, temporary comands etc.
9 */
10 
11 #define HAVE_WALK 1
12 
13 #include "kernel/mod2.h"
14 #include "misc/sirandom.h"
15 #include "resources/omFindExec.h"
16 
17 #ifdef HAVE_CCLUSTER
18 #undef CC
19 #include "ccluster/ccluster.h"
20 #endif
21 
22 #include "factory/factory.h"
23 
24 #ifdef TIME_WITH_SYS_TIME
25 # include <time.h>
26 # ifdef HAVE_SYS_TIME_H
27 # include <sys/time.h>
28 # endif
29 #else
30 # ifdef HAVE_SYS_TIME_H
31 # include <sys/time.h>
32 # else
33 # include <time.h>
34 # endif
35 #endif
36 #ifdef HAVE_SYS_TIMES_H
37 #include <sys/times.h>
38 #endif
39 
40 #include <unistd.h>
41 
42 #include "misc/options.h"
43 
44 // #include "coeffs/ffields.h"
45 #include "coeffs/coeffs.h"
46 #include "coeffs/mpr_complex.h"
47 
48 
49 #include "resources/feResource.h"
50 #include "polys/monomials/ring.h"
51 #include "kernel/polys.h"
52 
53 #include "polys/monomials/maps.h"
54 #include "polys/matpol.h"
55 #include "polys/pCoeff.h"
56 
57 #include "polys/weight.h"
58 
59 #ifdef HAVE_SHIFTBBA
60 #include "polys/shiftop.h"
61 #endif
62 
63 #include "coeffs/bigintmat.h"
64 #include "kernel/fast_mult.h"
65 #include "kernel/digitech.h"
67 #include "kernel/ideals.h"
68 #include "kernel/GBEngine/kstd1.h"
69 #include "kernel/GBEngine/syz.h"
70 #include "kernel/GBEngine/kutil.h"
72 
74 
76 
77 // for tests of t-rep-GB
78 #include "kernel/GBEngine/tgb.h"
79 
81 
82 #include "numeric/mpr_base.h"
83 
84 #include "tok.h"
85 #include "ipid.h"
86 #include "lists.h"
87 #include "cntrlc.h"
88 #include "ipshell.h"
89 #include "sdb.h"
90 #include "feOpt.h"
91 #include "fehelp.h"
92 #include "misc/distrib.h"
93 
94 #include "misc_ip.h"
95 
96 #include "attrib.h"
97 
98 #include "links/silink.h"
99 #include "links/ssiLink.h"
100 #include "walk.h"
101 #include "Singular/newstruct.h"
102 #include "Singular/blackbox.h"
103 #include "Singular/pyobject_setup.h"
104 
105 
106 #ifdef HAVE_RINGS
107 #include "kernel/GBEngine/ringgb.h"
108 #endif
109 
110 #ifdef HAVE_F5
111 #include "kernel/GBEngine/f5gb.h"
112 #endif
113 
114 #ifdef HAVE_WALK
115 #include "walk.h"
116 #endif
117 
118 #ifdef HAVE_SPECTRUM
120 #endif
121 
122 #ifdef HAVE_PLURAL
123 #include "polys/nc/nc.h"
124 #include "polys/nc/ncSAMult.h" // for CMultiplier etc classes
125 #include "polys/nc/sca.h"
126 #include "kernel/GBEngine/nc.h"
127 #include "ipconv.h"
128 #ifdef HAVE_RATGRING
130 #endif
131 #endif
132 
133 #ifdef __CYGWIN__ /* only for the DLLTest */
134 /* #include "WinDllTest.h" */
135 #ifdef HAVE_DL
136 #include "polys/mod_raw.h"
137 #endif
138 #endif
139 
140 // Define to enable many more system commands
141 //#undef MAKE_DISTRIBUTION
142 #ifndef MAKE_DISTRIBUTION
143 #define HAVE_EXTENDED_SYSTEM 1
144 #endif
145 
146 #include "polys/flintconv.h"
147 #include "polys/clapconv.h"
148 #include "kernel/GBEngine/kstdfac.h"
149 
150 #include "polys/clapsing.h"
151 
152 #ifdef HAVE_EIGENVAL
153 #include "eigenval_ip.h"
154 #endif
155 
156 #ifdef HAVE_GMS
157 #include "gms.h"
158 #endif
159 
160 #ifdef HAVE_SIMPLEIPC
162 #endif
163 
164 #ifdef HAVE_PCV
165 #include "pcv.h"
166 #endif
167 
168 #ifndef MAKE_DISTRIBUTION
170 #endif
172 
173 /* expects a SINGULAR square matrix with number entries
174  where currRing is expected to be over some field F_p;
175  returns a long** matrix with the "same", i.e.,
176  appropriately mapped entries;
177  leaves singularMatrix unmodified */
178 unsigned long** singularMatrixToLongMatrix(matrix singularMatrix)
179 {
180  int n = singularMatrix->rows();
181  assume(n == singularMatrix->cols());
182  unsigned long **longMatrix = 0;
183  longMatrix = new unsigned long *[n] ;
184  for (int i = 0 ; i < n; i++)
185  longMatrix[i] = new unsigned long [n];
186  number entry;
187  for (int r = 0; r < n; r++)
188  for (int c = 0; c < n; c++)
189  {
190  poly p=MATELEM(singularMatrix, r + 1, c + 1);
191  int entryAsInt;
192  if (p!=NULL)
193  {
194  entry = p_GetCoeff(p, currRing);
195  entryAsInt = n_Int(entry, currRing->cf);
196  if (entryAsInt < 0) entryAsInt += n_GetChar(currRing->cf);
197  }
198  else
199  entryAsInt=0;
200  longMatrix[r][c] = (unsigned long)entryAsInt;
201  }
202  return longMatrix;
203 }
204 
205 /* expects an array of unsigned longs with valid indices 0..degree;
206  returns the following poly, where x denotes the first ring variable
207  of currRing, and d = degree:
208  polyCoeffs[d] * x^d + polyCoeffs[d-1] * x^(d-1) + ... + polyCoeffs[0]
209  leaves polyCoeffs unmodified */
210 poly longCoeffsToSingularPoly(unsigned long *polyCoeffs, const int degree)
211 {
212  poly result = NULL;
213  for (int i = 0; i <= degree; i++)
214  {
215  if ((int)polyCoeffs[i] != 0)
216  {
217  poly term = p_ISet((int)polyCoeffs[i], currRing);
218  if (i > 0)
219  {
220  p_SetExp(term, 1, i, currRing);
221  p_Setm(term, currRing);
222  }
224  }
225  }
226  return result;
227 }
228 
229 /*2
230 * the "system" command
231 */
233 {
234  if(args->Typ() == STRING_CMD)
235  {
236  const char *sys_cmd=(char *)(args->Data());
237  leftv h=args->next;
238 // ONLY documented system calls go here
239 // Undocumented system calls go down into jjEXTENDED_SYSTEM (#ifdef HAVE_EXTENDED_SYSTEM)
240 /*==================== nblocks ==================================*/
241  if (strcmp(sys_cmd, "nblocks") == 0)
242  {
243  ring r;
244  if (h == NULL)
245  {
246  if (currRingHdl != NULL)
247  {
248  r = IDRING(currRingHdl);
249  }
250  else
251  {
252  WerrorS("no ring active");
253  return TRUE;
254  }
255  }
256  else
257  {
258  if (h->Typ() != RING_CMD)
259  {
260  WerrorS("ring expected");
261  return TRUE;
262  }
263  r = (ring) h->Data();
264  }
265  res->rtyp = INT_CMD;
266  res->data = (void*) (long)(rBlocks(r) - 1);
267  return FALSE;
268  }
269 /*==================== version ==================================*/
270  if(strcmp(sys_cmd,"version")==0)
271  {
272  res->rtyp=INT_CMD;
273  res->data=(void *)SINGULAR_VERSION;
274  return FALSE;
275  }
276  else
277 /*==================== alarm ==================================*/
278  if(strcmp(sys_cmd,"alarm")==0)
279  {
280  if ((h!=NULL) &&(h->Typ()==INT_CMD))
281  {
282  // standard variant -> SIGALARM (standard: abort)
283  //alarm((unsigned)h->next->Data());
284  // process time (user +system): SIGVTALARM
285  struct itimerval t,o;
286  memset(&t,0,sizeof(t));
287  t.it_value.tv_sec =(unsigned)((unsigned long)h->Data());
288  setitimer(ITIMER_VIRTUAL,&t,&o);
289  return FALSE;
290  }
291  else
292  WerrorS("int expected");
293  }
294  else
295 /*==================== content ==================================*/
296  if(strcmp(sys_cmd,"content")==0)
297  {
298  if ((h!=NULL) && ((h->Typ()==POLY_CMD)||(h->Typ()==VECTOR_CMD)))
299  {
300  int t=h->Typ();
301  poly p=(poly)h->CopyD();
302  if (p!=NULL)
303  {
306  }
307  res->data=(void *)p;
308  res->rtyp=t;
309  return FALSE;
310  }
311  return TRUE;
312  }
313  else
314 /*==================== cpu ==================================*/
315  if(strcmp(sys_cmd,"cpu")==0)
316  {
317  long cpu=1; //feOptValue(FE_OPT_CPUS);
318  #ifdef _SC_NPROCESSORS_ONLN
319  cpu=sysconf(_SC_NPROCESSORS_ONLN);
320  #elif defined(_SC_NPROCESSORS_CONF)
321  cpu=sysconf(_SC_NPROCESSORS_CONF);
322  #endif
323  res->data=(void *)cpu;
324  res->rtyp=INT_CMD;
325  return FALSE;
326  }
327  else
328 /*==================== executable ==================================*/
329  if(strcmp(sys_cmd,"executable")==0)
330  {
331  if ((h!=NULL) && (h->Typ()==STRING_CMD))
332  {
333  char tbuf[MAXPATHLEN];
334  char *s=omFindExec((char*)h->Data(),tbuf);
335  if(s==NULL) s=(char*)"";
336  res->data=(void *)omStrDup(s);
337  res->rtyp=STRING_CMD;
338  return FALSE;
339  }
340  return TRUE;
341  }
342  else
343  /*==================== flatten =============================*/
344  if(strcmp(sys_cmd,"flatten")==0)
345  {
346  if ((h!=NULL) &&(h->Typ()==SMATRIX_CMD))
347  {
348  res->data=(char*)sm_Flatten((ideal)h->Data(),currRing);
349  res->rtyp=SMATRIX_CMD;
350  return FALSE;
351  }
352  else
353  WerrorS("smatrix expected");
354  }
355  else
356  /*==================== unflatten =============================*/
357  if(strcmp(sys_cmd,"unflatten")==0)
358  {
359  const short t1[]={2,SMATRIX_CMD,INT_CMD};
360  if (iiCheckTypes(h,t1,1))
361  {
362  res->data=(char*)sm_UnFlatten((ideal)h->Data(),(int)(long)h->next->Data(),currRing);
363  res->rtyp=SMATRIX_CMD;
364  return res->data==NULL;
365  }
366  else return TRUE;
367  }
368  else
369  /*==================== neworder =============================*/
370  if(strcmp(sys_cmd,"neworder")==0)
371  {
372  if ((h!=NULL) &&(h->Typ()==IDEAL_CMD))
373  {
374  res->rtyp=STRING_CMD;
375  res->data=(void *)singclap_neworder((ideal)h->Data(), currRing);
376  return FALSE;
377  }
378  else
379  WerrorS("ideal expected");
380  }
381  else
382 /*===== nc_hilb ===============================================*/
383  // Hilbert series of non-commutative monomial algebras
384  if(strcmp(sys_cmd,"nc_hilb") == 0)
385  {
386  ideal i; int lV;
387  bool ig = FALSE;
388  bool mgrad = FALSE;
389  bool autop = FALSE;
390  int trunDegHs=0;
391  if((h != NULL)&&(h->Typ() == IDEAL_CMD))
392  i = (ideal)h->Data();
393  else
394  {
395  WerrorS("nc_Hilb:ideal expected");
396  return TRUE;
397  }
398  h = h->next;
399  if((h != NULL)&&(h->Typ() == INT_CMD))
400  lV = (int)(long)h->Data();
401  else
402  {
403  WerrorS("nc_Hilb:int expected");
404  return TRUE;
405  }
406  h = h->next;
407  while(h != NULL)
408  {
409  if((int)(long)h->Data() == 1)
410  ig = TRUE;
411  else if((int)(long)h->Data() == 2)
412  mgrad = TRUE;
413  else if(h->Typ()==STRING_CMD)
414  autop = TRUE;
415  else if(h->Typ() == INT_CMD)
416  trunDegHs = (int)(long)h->Data();
417  h = h->next;
418  }
419  if(h != NULL)
420  {
421  WerrorS("nc_Hilb:int 1,2, total degree for the truncation, and a string for printing the details are expected");
422  return TRUE;
423  }
424 
425  HilbertSeries_OrbitData(i, lV, ig, mgrad, autop, trunDegHs);
426  return(FALSE);
427  }
428  else
429 /* ====== verify ============================*/
430  if(strcmp(sys_cmd,"verifyGB")==0)
431  {
432  if (rIsNCRing(currRing))
433  {
434  WerrorS("system(\"verifyGB\",<ideal>,..) expects a commutative ring");
435  return TRUE;
436  }
437  if (h->Typ()!=IDEAL_CMD)
438  {
439  WerrorS("expected system(\"verifyGB\",<ideal>,..)");
440  return TRUE;
441  }
442  ideal F=(ideal)h->Data();
443  if (h->next==NULL)
444  {
445  #ifdef HAVE_VSPACE
446  int cpus = (long) feOptValue(FE_OPT_CPUS);
447  if (cpus>1)
448  res->data=(char*)(long) kVerify2(F,currRing->qideal);
449  else
450  #endif
451  res->data=(char*)(long) kVerify1(F,currRing->qideal);
452  }
453  else return TRUE;
454  res->rtyp=INT_CMD;
455  return FALSE;
456  }
457  else
458 /*===== rcolon ===============================================*/
459  if(strcmp(sys_cmd,"rcolon") == 0)
460  {
461  const short t1[]={3,IDEAL_CMD,POLY_CMD,INT_CMD};
462  if (iiCheckTypes(h,t1,1))
463  {
464  ideal i = (ideal)h->Data();
465  h = h->next;
466  poly w=(poly)h->Data();
467  h = h->next;
468  int lV = (int)(long)h->Data();
469  res->rtyp = IDEAL_CMD;
470  res->data = RightColonOperation(i, w, lV);
471  return(FALSE);
472  }
473  else
474  return TRUE;
475  }
476  else
477 
478 /*==================== sh ==================================*/
479  if(strcmp(sys_cmd,"sh")==0)
480  {
482  {
483  WerrorS("shell execution is disallowed in restricted mode");
484  return TRUE;
485  }
486  res->rtyp=INT_CMD;
487  if (h==NULL) res->data = (void *)(long) system("sh");
488  else if (h->Typ()==STRING_CMD)
489  res->data = (void*)(long) system((char*)(h->Data()));
490  else
491  WerrorS("string expected");
492  return FALSE;
493  }
494  else
495 /*========reduce procedure like the global one but with jet bounds=======*/
496  if(strcmp(sys_cmd,"reduce_bound")==0)
497  {
498  poly p;
499  ideal pid=NULL;
500  const short t1[]={3,POLY_CMD,IDEAL_CMD,INT_CMD};
501  const short t2[]={3,IDEAL_CMD,IDEAL_CMD,INT_CMD};
502  const short t3[]={3,VECTOR_CMD,MODUL_CMD,INT_CMD};
503  const short t4[]={3,MODUL_CMD,MODUL_CMD,INT_CMD};
504  if ((iiCheckTypes(h,t1,0))||((iiCheckTypes(h,t3,0))))
505  {
506  p = (poly)h->CopyD();
507  }
508  else if ((iiCheckTypes(h,t2,0))||(iiCheckTypes(h,t4,1)))
509  {
510  pid = (ideal)h->CopyD();
511  }
512  else return TRUE;
513  //int htype;
514  res->rtyp= h->Typ(); /*htype*/
515  ideal q = (ideal)h->next->CopyD();
516  int bound = (int)(long)h->next->next->Data();
517  if (pid==NULL) /*(htype == POLY_CMD || htype == VECTOR_CMD)*/
518  res->data = (char *)kNFBound(q,currRing->qideal,p,bound);
519  else /*(htype == IDEAL_CMD || htype == MODUL_CMD)*/
520  res->data = (char *)kNFBound(q,currRing->qideal,pid,bound);
521  return FALSE;
522  }
523  else
524 /*==================== uname ==================================*/
525  if(strcmp(sys_cmd,"uname")==0)
526  {
527  res->rtyp=STRING_CMD;
528  res->data = omStrDup(S_UNAME);
529  return FALSE;
530  }
531  else
532 /*==================== with ==================================*/
533  if(strcmp(sys_cmd,"with")==0)
534  {
535  if (h==NULL)
536  {
537  res->rtyp=STRING_CMD;
538  res->data=(void *)versionString();
539  return FALSE;
540  }
541  else if (h->Typ()==STRING_CMD)
542  {
543  #define TEST_FOR(A) if(strcmp(s,A)==0) res->data=(void *)1; else
544  char *s=(char *)h->Data();
545  res->rtyp=INT_CMD;
546  #ifdef HAVE_DBM
547  TEST_FOR("DBM")
548  #endif
549  #ifdef HAVE_DLD
550  TEST_FOR("DLD")
551  #endif
552  //TEST_FOR("factory")
553  //TEST_FOR("libfac")
554  #ifdef HAVE_READLINE
555  TEST_FOR("readline")
556  #endif
557  #ifdef TEST_MAC_ORDER
558  TEST_FOR("MAC_ORDER")
559  #endif
560  // unconditional since 3-1-0-6
561  TEST_FOR("Namespaces")
562  #ifdef HAVE_DYNAMIC_LOADING
563  TEST_FOR("DynamicLoading")
564  #endif
565  #ifdef HAVE_EIGENVAL
566  TEST_FOR("eigenval")
567  #endif
568  #ifdef HAVE_GMS
569  TEST_FOR("gms")
570  #endif
571  #ifdef OM_NDEBUG
572  TEST_FOR("om_ndebug")
573  #endif
574  #ifdef SING_NDEBUG
575  TEST_FOR("ndebug")
576  #endif
577  {};
578  return FALSE;
579  #undef TEST_FOR
580  }
581  return TRUE;
582  }
583  else
584  /*==================== browsers ==================================*/
585  if (strcmp(sys_cmd,"browsers")==0)
586  {
587  res->rtyp = STRING_CMD;
588  StringSetS("");
590  res->data = StringEndS();
591  return FALSE;
592  }
593  else
594  /*==================== pid ==================================*/
595  if (strcmp(sys_cmd,"pid")==0)
596  {
597  res->rtyp=INT_CMD;
598  res->data=(void *)(long) getpid();
599  return FALSE;
600  }
601  else
602  /*==================== getenv ==================================*/
603  if (strcmp(sys_cmd,"getenv")==0)
604  {
605  if ((h!=NULL) && (h->Typ()==STRING_CMD))
606  {
607  res->rtyp=STRING_CMD;
608  const char *r=getenv((char *)h->Data());
609  if (r==NULL) r="";
610  res->data=(void *)omStrDup(r);
611  return FALSE;
612  }
613  else
614  {
615  WerrorS("string expected");
616  return TRUE;
617  }
618  }
619  else
620  /*==================== setenv ==================================*/
621  if (strcmp(sys_cmd,"setenv")==0)
622  {
623  #ifdef HAVE_SETENV
624  const short t[]={2,STRING_CMD,STRING_CMD};
625  if (iiCheckTypes(h,t,1))
626  {
627  res->rtyp=STRING_CMD;
628  setenv((char *)h->Data(), (char *)h->next->Data(), 1);
629  res->data=(void *)omStrDup((char *)h->next->Data());
631  return FALSE;
632  }
633  else
634  {
635  return TRUE;
636  }
637  #else
638  WerrorS("setenv not supported on this platform");
639  return TRUE;
640  #endif
641  }
642  else
643  /*==================== Singular ==================================*/
644  if (strcmp(sys_cmd, "Singular") == 0)
645  {
646  res->rtyp=STRING_CMD;
647  const char *r=feResource("Singular");
648  if (r == NULL) r="";
649  res->data = (void*) omStrDup( r );
650  return FALSE;
651  }
652  else
653  if (strcmp(sys_cmd, "SingularLib") == 0)
654  {
655  res->rtyp=STRING_CMD;
656  const char *r=feResource("SearchPath");
657  if (r == NULL) r="";
658  res->data = (void*) omStrDup( r );
659  return FALSE;
660  }
661  else
662  if (strcmp(sys_cmd, "SingularBin") == 0)
663  {
664  res->rtyp=STRING_CMD;
665  const char *r=feResource('r');
666  if (r == NULL) r="/usr/local";
667  int l=strlen(r);
668  /* where to find Singular's programs: */
669  #define SINGULAR_PROCS_DIR "/libexec/singular/MOD"
670  int ll=si_max((int)strlen(SINGULAR_PROCS_DIR),(int)strlen(LIBEXEC_DIR));
671  char *s=(char*)omAlloc(l+ll+2);
672  if ((strstr(r,".libs/..")==NULL) /*not installed Singular (libtool)*/
673  &&(strstr(r,"Singular/..")==NULL)) /*not installed Singular (static)*/
674  {
675  strcpy(s,r);
676  strcat(s,SINGULAR_PROCS_DIR);
677  if (access(s,X_OK)==0)
678  {
679  strcat(s,"/");
680  }
681  else
682  {
683  /*second try: LIBEXEC_DIR*/
684  strcpy(s,LIBEXEC_DIR);
685  if (access(s,X_OK)==0)
686  {
687  strcat(s,"/");
688  }
689  else
690  {
691  s[0]='\0';
692  }
693  }
694  }
695  else
696  {
697  const char *r=feResource('b');
698  if (r == NULL)
699  {
700  s[0]='\0';
701  }
702  else
703  {
704  strcpy(s,r);
705  strcat(s,"/");
706  }
707  }
708  res->data = (void*)s;
709  return FALSE;
710  }
711  else
712  /*==================== options ==================================*/
713  if (strstr(sys_cmd, "--") == sys_cmd)
714  {
715  if (strcmp(sys_cmd, "--") == 0)
716  {
718  return FALSE;
719  }
720  feOptIndex opt = feGetOptIndex(&sys_cmd[2]);
721  if (opt == FE_OPT_UNDEF)
722  {
723  Werror("Unknown option %s", sys_cmd);
724  WerrorS("Use 'system(\"--\");' for listing of available options");
725  return TRUE;
726  }
727  // for Untyped Options (help version),
728  // setting it just triggers action
729  if (feOptSpec[opt].type == feOptUntyped)
730  {
731  feSetOptValue(opt,0);
732  return FALSE;
733  }
734  if (h == NULL)
735  {
736  if (feOptSpec[opt].type == feOptString)
737  {
738  res->rtyp = STRING_CMD;
739  const char *r=(const char*)feOptSpec[opt].value;
740  if (r == NULL) r="";
741  res->data = omStrDup(r);
742  }
743  else
744  {
745  res->rtyp = INT_CMD;
746  res->data = feOptSpec[opt].value;
747  }
748  return FALSE;
749  }
750  if (h->Typ() != STRING_CMD &&
751  h->Typ() != INT_CMD)
752  {
753  WerrorS("Need string or int argument to set option value");
754  return TRUE;
755  }
756  const char* errormsg;
757  if (h->Typ() == INT_CMD)
758  {
759  if (feOptSpec[opt].type == feOptString)
760  {
761  Werror("Need string argument to set value of option %s", sys_cmd);
762  return TRUE;
763  }
764  errormsg = feSetOptValue(opt, (int)((long) h->Data()));
765  if (errormsg != NULL)
766  Werror("Option '--%s=%d' %s", sys_cmd, (int) ((long)h->Data()), errormsg);
767  }
768  else
769  {
770  errormsg = feSetOptValue(opt, (char*) h->Data());
771  if (errormsg != NULL)
772  Werror("Option '--%s=%s' %s", sys_cmd, (char*) h->Data(), errormsg);
773  }
774  if (errormsg != NULL) return TRUE;
775  return FALSE;
776  }
777  else
778  /*==================== HC ==================================*/
779  if (strcmp(sys_cmd,"HC")==0)
780  {
781  res->rtyp=INT_CMD;
782  res->data=(void *)(long) HCord;
783  return FALSE;
784  }
785  else
786  /*==================== random ==================================*/
787  if(strcmp(sys_cmd,"random")==0)
788  {
789  const short t[]={1,INT_CMD};
790  if (h!=NULL)
791  {
792  if (iiCheckTypes(h,t,1))
793  {
794  siRandomStart=(int)((long)h->Data());
797  return FALSE;
798  }
799  else
800  {
801  return TRUE;
802  }
803  }
804  res->rtyp=INT_CMD;
805  res->data=(void*)(long) siSeed;
806  return FALSE;
807  }
808  else
809  /*======================= demon_list =====================*/
810  if (strcmp(sys_cmd,"denom_list")==0)
811  {
812  res->rtyp=LIST_CMD;
813  extern lists get_denom_list();
814  res->data=(lists)get_denom_list();
815  return FALSE;
816  }
817  else
818  /*==================== complexNearZero ======================*/
819  if(strcmp(sys_cmd,"complexNearZero")==0)
820  {
821  const short t[]={2,NUMBER_CMD,INT_CMD};
822  if (iiCheckTypes(h,t,1))
823  {
824  if ( !rField_is_long_C(currRing) )
825  {
826  WerrorS( "unsupported ground field!");
827  return TRUE;
828  }
829  else
830  {
831  res->rtyp=INT_CMD;
832  res->data=(void*)complexNearZero((gmp_complex*)h->Data(),
833  (int)((long)(h->next->Data())));
834  return FALSE;
835  }
836  }
837  else
838  {
839  return TRUE;
840  }
841  }
842  else
843  /*==================== getPrecDigits ======================*/
844  if(strcmp(sys_cmd,"getPrecDigits")==0)
845  {
846  if ( (currRing==NULL)
848  {
849  WerrorS( "unsupported ground field!");
850  return TRUE;
851  }
852  res->rtyp=INT_CMD;
853  res->data=(void*)(long)gmp_output_digits;
854  //if (gmp_output_digits!=getGMPFloatDigits())
855  //{ Print("%d, %d\n",getGMPFloatDigits(),gmp_output_digits);}
856  return FALSE;
857  }
858  else
859  /*==================== lduDecomp ======================*/
860  if(strcmp(sys_cmd, "lduDecomp")==0)
861  {
862  const short t[]={1,MATRIX_CMD};
863  if (iiCheckTypes(h,t,1))
864  {
865  matrix aMat = (matrix)h->Data();
866  matrix pMat; matrix lMat; matrix dMat; matrix uMat;
867  poly l; poly u; poly prodLU;
868  lduDecomp(aMat, pMat, lMat, dMat, uMat, l, u, prodLU);
870  L->Init(7);
871  L->m[0].rtyp = MATRIX_CMD; L->m[0].data=(void*)pMat;
872  L->m[1].rtyp = MATRIX_CMD; L->m[1].data=(void*)lMat;
873  L->m[2].rtyp = MATRIX_CMD; L->m[2].data=(void*)dMat;
874  L->m[3].rtyp = MATRIX_CMD; L->m[3].data=(void*)uMat;
875  L->m[4].rtyp = POLY_CMD; L->m[4].data=(void*)l;
876  L->m[5].rtyp = POLY_CMD; L->m[5].data=(void*)u;
877  L->m[6].rtyp = POLY_CMD; L->m[6].data=(void*)prodLU;
878  res->rtyp = LIST_CMD;
879  res->data = (char *)L;
880  return FALSE;
881  }
882  else
883  {
884  return TRUE;
885  }
886  }
887  else
888  /*==================== lduSolve ======================*/
889  if(strcmp(sys_cmd, "lduSolve")==0)
890  {
891  /* for solving a linear equation system A * x = b, via the
892  given LDU-decomposition of the matrix A;
893  There is one valid parametrisation:
894  1) exactly eight arguments P, L, D, U, l, u, lTimesU, b;
895  P, L, D, and U realise the LDU-decomposition of A, that is,
896  P * A = L * D^(-1) * U, and P, L, D, and U satisfy the
897  properties decribed in method 'luSolveViaLDUDecomp' in
898  linearAlgebra.h; see there;
899  l, u, and lTimesU are as described in the same location;
900  b is the right-hand side vector of the linear equation system;
901  The method will return a list of either 1 entry or three entries:
902  1) [0] if there is no solution to the system;
903  2) [1, x, H] if there is at least one solution;
904  x is any solution of the given linear system,
905  H is the matrix with column vectors spanning the homogeneous
906  solution space.
907  The method produces an error if matrix and vector sizes do not
908  fit. */
910  if (!iiCheckTypes(h,t,1))
911  {
912  return TRUE;
913  }
915  {
916  WerrorS("field required");
917  return TRUE;
918  }
919  matrix pMat = (matrix)h->Data();
920  matrix lMat = (matrix)h->next->Data();
921  matrix dMat = (matrix)h->next->next->Data();
922  matrix uMat = (matrix)h->next->next->next->Data();
923  poly l = (poly) h->next->next->next->next->Data();
924  poly u = (poly) h->next->next->next->next->next->Data();
925  poly lTimesU = (poly) h->next->next->next->next->next->next->Data();
926  matrix bVec = (matrix)h->next->next->next->next->next->next->next->Data();
927  matrix xVec; int solvable; matrix homogSolSpace;
928  if (pMat->rows() != pMat->cols())
929  {
930  Werror("first matrix (%d x %d) is not quadratic",
931  pMat->rows(), pMat->cols());
932  return TRUE;
933  }
934  if (lMat->rows() != lMat->cols())
935  {
936  Werror("second matrix (%d x %d) is not quadratic",
937  lMat->rows(), lMat->cols());
938  return TRUE;
939  }
940  if (dMat->rows() != dMat->cols())
941  {
942  Werror("third matrix (%d x %d) is not quadratic",
943  dMat->rows(), dMat->cols());
944  return TRUE;
945  }
946  if (dMat->cols() != uMat->rows())
947  {
948  Werror("third matrix (%d x %d) and fourth matrix (%d x %d) %s",
949  dMat->rows(), dMat->cols(), uMat->rows(), uMat->cols(),
950  "do not t");
951  return TRUE;
952  }
953  if (uMat->rows() != bVec->rows())
954  {
955  Werror("fourth matrix (%d x %d) and vector (%d x 1) do not fit",
956  uMat->rows(), uMat->cols(), bVec->rows());
957  return TRUE;
958  }
959  solvable = luSolveViaLDUDecomp(pMat, lMat, dMat, uMat, l, u, lTimesU,
960  bVec, xVec, homogSolSpace);
961 
962  /* build the return structure; a list with either one or
963  three entries */
965  if (solvable)
966  {
967  ll->Init(3);
968  ll->m[0].rtyp=INT_CMD; ll->m[0].data=(void *)(long)solvable;
969  ll->m[1].rtyp=MATRIX_CMD; ll->m[1].data=(void *)xVec;
970  ll->m[2].rtyp=MATRIX_CMD; ll->m[2].data=(void *)homogSolSpace;
971  }
972  else
973  {
974  ll->Init(1);
975  ll->m[0].rtyp=INT_CMD; ll->m[0].data=(void *)(long)solvable;
976  }
977  res->rtyp = LIST_CMD;
978  res->data=(char*)ll;
979  return FALSE;
980  }
981  else
982  /*==== countedref: reference and shared ====*/
983  if (strcmp(sys_cmd, "shared") == 0)
984  {
985  #ifndef SI_COUNTEDREF_AUTOLOAD
986  void countedref_shared_load();
988  #endif
989  res->rtyp = NONE;
990  return FALSE;
991  }
992  else if (strcmp(sys_cmd, "reference") == 0)
993  {
994  #ifndef SI_COUNTEDREF_AUTOLOAD
997  #endif
998  res->rtyp = NONE;
999  return FALSE;
1000  }
1001  else
1002 /*==================== semaphore =================*/
1003 #ifdef HAVE_SIMPLEIPC
1004  if (strcmp(sys_cmd,"semaphore")==0)
1005  {
1006  if((h!=NULL) && (h->Typ()==STRING_CMD) && (h->next!=NULL) && (h->next->Typ()==INT_CMD))
1007  {
1008  int v=1;
1009  if ((h->next->next!=NULL)&& (h->next->next->Typ()==INT_CMD))
1010  v=(int)(long)h->next->next->Data();
1011  res->data=(char *)(long)simpleipc_cmd((char *)h->Data(),(int)(long)h->next->Data(),v);
1012  res->rtyp=INT_CMD;
1013  return FALSE;
1014  }
1015  else
1016  {
1017  WerrorS("Usage: system(\"semaphore\",<cmd>,int)");
1018  return TRUE;
1019  }
1020  }
1021  else
1022 #endif
1023 /*==================== reserved port =================*/
1024  if (strcmp(sys_cmd,"reserve")==0)
1025  {
1026  int ssiReservePort(int clients);
1027  const short t[]={1,INT_CMD};
1028  if (iiCheckTypes(h,t,1))
1029  {
1030  res->rtyp=INT_CMD;
1031  int p=ssiReservePort((int)(long)h->Data());
1032  res->data=(void*)(long)p;
1033  return (p==0);
1034  }
1035  return TRUE;
1036  }
1037  else
1038 /*==================== reserved link =================*/
1039  if (strcmp(sys_cmd,"reservedLink")==0)
1040  {
1041  res->rtyp=LINK_CMD;
1043  res->data=(void*)p;
1044  return (p==NULL);
1045  }
1046  else
1047 /*==================== install newstruct =================*/
1048  if (strcmp(sys_cmd,"install")==0)
1049  {
1050  const short t[]={4,STRING_CMD,STRING_CMD,PROC_CMD,INT_CMD};
1051  if (iiCheckTypes(h,t,1))
1052  {
1053  return newstruct_set_proc((char*)h->Data(),(char*)h->next->Data(),
1054  (int)(long)h->next->next->next->Data(),
1055  (procinfov)h->next->next->Data());
1056  }
1057  return TRUE;
1058  }
1059  else
1060 /*==================== newstruct =================*/
1061  if (strcmp(sys_cmd,"newstruct")==0)
1062  {
1063  const short t[]={1,STRING_CMD};
1064  if (iiCheckTypes(h,t,1))
1065  {
1066  int id=0;
1067  char *n=(char*)h->Data();
1068  blackboxIsCmd(n,id);
1069  if (id>0)
1070  {
1071  blackbox *bb=getBlackboxStuff(id);
1072  if (BB_LIKE_LIST(bb))
1073  {
1074  newstruct_desc desc=(newstruct_desc)bb->data;
1075  newstructShow(desc);
1076  return FALSE;
1077  }
1078  else Werror("'%s' is not a newstruct",n);
1079  }
1080  else Werror("'%s' is not a blackbox object",n);
1081  }
1082  return TRUE;
1083  }
1084  else
1085 /*==================== blackbox =================*/
1086  if (strcmp(sys_cmd,"blackbox")==0)
1087  {
1089  return FALSE;
1090  }
1091  else
1092  /*================= absBiFact ======================*/
1093  #if defined(HAVE_FLINT) || defined(HAVE_NTL)
1094  if (strcmp(sys_cmd, "absFact") == 0)
1095  {
1096  const short t[]={1,POLY_CMD};
1097  if (iiCheckTypes(h,t,1)
1098  && (currRing!=NULL)
1099  && (getCoeffType(currRing->cf)==n_transExt))
1100  {
1101  res->rtyp=LIST_CMD;
1102  intvec *v=NULL;
1103  ideal mipos= NULL;
1104  int n= 0;
1105  ideal f=singclap_absFactorize((poly)(h->Data()), mipos, &v, n, currRing);
1106  if (f==NULL) return TRUE;
1107  ivTest(v);
1109  l->Init(4);
1110  l->m[0].rtyp=IDEAL_CMD;
1111  l->m[0].data=(void *)f;
1112  l->m[1].rtyp=INTVEC_CMD;
1113  l->m[1].data=(void *)v;
1114  l->m[2].rtyp=IDEAL_CMD;
1115  l->m[2].data=(void*) mipos;
1116  l->m[3].rtyp=INT_CMD;
1117  l->m[3].data=(void*) (long) n;
1118  res->data=(void *)l;
1119  return FALSE;
1120  }
1121  else return TRUE;
1122  }
1123  else
1124  #endif
1125  /* =================== LLL via NTL ==============================*/
1126  #ifdef HAVE_NTL
1127  if (strcmp(sys_cmd, "LLL") == 0)
1128  {
1129  if (h!=NULL)
1130  {
1131  res->rtyp=h->Typ();
1132  if (h->Typ()==MATRIX_CMD)
1133  {
1134  res->data=(char *)singntl_LLL((matrix)h->Data(), currRing);
1135  return FALSE;
1136  }
1137  else if (h->Typ()==INTMAT_CMD)
1138  {
1139  res->data=(char *)singntl_LLL((intvec*)h->Data());
1140  return FALSE;
1141  }
1142  else return TRUE;
1143  }
1144  else return TRUE;
1145  }
1146  else
1147  #endif
1148  /* =================== LLL via Flint ==============================*/
1149  #ifdef HAVE_FLINT
1150  #if __FLINT_RELEASE >= 20500
1151  if (strcmp(sys_cmd, "LLL_Flint") == 0)
1152  {
1153  if (h!=NULL)
1154  {
1155  if(h->next == NULL)
1156  {
1157  res->rtyp=h->Typ();
1158  if (h->Typ()==BIGINTMAT_CMD)
1159  {
1160  res->data=(char *)singflint_LLL((bigintmat*)h->Data(), NULL);
1161  return FALSE;
1162  }
1163  else if (h->Typ()==INTMAT_CMD)
1164  {
1165  res->data=(char *)singflint_LLL((intvec*)h->Data(), NULL);
1166  return FALSE;
1167  }
1168  else return TRUE;
1169  }
1170  if(h->next->Typ()!= INT_CMD)
1171  {
1172  WerrorS("matrix,int or bigint,int expected");
1173  return TRUE;
1174  }
1175  if(h->next->Typ()== INT_CMD)
1176  {
1177  if(((int)((long)(h->next->Data())) != 0) && (int)((long)(h->next->Data()) != 1))
1178  {
1179  WerrorS("int is different from 0, 1");
1180  return TRUE;
1181  }
1182  res->rtyp=h->Typ();
1183  if((long)(h->next->Data()) == 0)
1184  {
1185  if (h->Typ()==BIGINTMAT_CMD)
1186  {
1187  res->data=(char *)singflint_LLL((bigintmat*)h->Data(), NULL);
1188  return FALSE;
1189  }
1190  else if (h->Typ()==INTMAT_CMD)
1191  {
1192  res->data=(char *)singflint_LLL((intvec*)h->Data(), NULL);
1193  return FALSE;
1194  }
1195  else return TRUE;
1196  }
1197  // This will give also the transformation matrix U s.t. res = U * m
1198  if((long)(h->next->Data()) == 1)
1199  {
1200  if (h->Typ()==BIGINTMAT_CMD)
1201  {
1202  bigintmat* m = (bigintmat*)h->Data();
1203  bigintmat* T = new bigintmat(m->rows(),m->rows(),m->basecoeffs());
1204  for(int i = 1; i<=m->rows(); i++)
1205  {
1206  n_Delete(&(BIMATELEM(*T,i,i)),T->basecoeffs());
1207  BIMATELEM(*T,i,i)=n_Init(1, T->basecoeffs());
1208  }
1209  m = singflint_LLL(m,T);
1211  L->Init(2);
1212  L->m[0].rtyp = BIGINTMAT_CMD; L->m[0].data = (void*)m;
1213  L->m[1].rtyp = BIGINTMAT_CMD; L->m[1].data = (void*)T;
1214  res->data=L;
1215  res->rtyp=LIST_CMD;
1216  return FALSE;
1217  }
1218  else if (h->Typ()==INTMAT_CMD)
1219  {
1220  intvec* m = (intvec*)h->Data();
1221  intvec* T = new intvec(m->rows(),m->rows(),(int)0);
1222  for(int i = 1; i<=m->rows(); i++)
1223  IMATELEM(*T,i,i)=1;
1224  m = singflint_LLL(m,T);
1226  L->Init(2);
1227  L->m[0].rtyp = INTMAT_CMD; L->m[0].data = (void*)m;
1228  L->m[1].rtyp = INTMAT_CMD; L->m[1].data = (void*)T;
1229  res->data=L;
1230  res->rtyp=LIST_CMD;
1231  return FALSE;
1232  }
1233  else return TRUE;
1234  }
1235  }
1236 
1237  }
1238  else return TRUE;
1239  }
1240  else
1241  #endif
1242  #endif
1243 /* ====== rref ============================*/
1244  #if defined(HAVE_FLINT) || defined(HAVE_NTL)
1245  if(strcmp(sys_cmd,"rref")==0)
1246  {
1247  const short t1[]={1,MATRIX_CMD};
1248  const short t2[]={1,SMATRIX_CMD};
1249  if (iiCheckTypes(h,t1,0))
1250  {
1251  matrix M=(matrix)h->Data();
1252  #if defined(HAVE_FLINT)
1253  res->data=(void*)singflint_rref(M,currRing);
1254  #elif defined(HAVE_NTL)
1255  res->data=(void*)singntl_rref(M,currRing);
1256  #endif
1257  res->rtyp=MATRIX_CMD;
1258  return FALSE;
1259  }
1260  else if (iiCheckTypes(h,t2,1))
1261  {
1262  ideal M=(ideal)h->Data();
1263  #if defined(HAVE_FLINT)
1264  res->data=(void*)singflint_rref(M,currRing);
1265  #elif defined(HAVE_NTL)
1266  res->data=(void*)singntl_rref(M,currRing);
1267  #endif
1268  res->rtyp=SMATRIX_CMD;
1269  return FALSE;
1270  }
1271  else
1272  {
1273  WerrorS("expected system(\"rref\",<matrix>/<smatrix>)");
1274  return TRUE;
1275  }
1276  }
1277  else
1278  #endif
1279  /*==================== pcv ==================================*/
1280  #ifdef HAVE_PCV
1281  if(strcmp(sys_cmd,"pcvLAddL")==0)
1282  {
1283  return pcvLAddL(res,h);
1284  }
1285  else
1286  if(strcmp(sys_cmd,"pcvPMulL")==0)
1287  {
1288  return pcvPMulL(res,h);
1289  }
1290  else
1291  if(strcmp(sys_cmd,"pcvMinDeg")==0)
1292  {
1293  return pcvMinDeg(res,h);
1294  }
1295  else
1296  if(strcmp(sys_cmd,"pcvP2CV")==0)
1297  {
1298  return pcvP2CV(res,h);
1299  }
1300  else
1301  if(strcmp(sys_cmd,"pcvCV2P")==0)
1302  {
1303  return pcvCV2P(res,h);
1304  }
1305  else
1306  if(strcmp(sys_cmd,"pcvDim")==0)
1307  {
1308  return pcvDim(res,h);
1309  }
1310  else
1311  if(strcmp(sys_cmd,"pcvBasis")==0)
1312  {
1313  return pcvBasis(res,h);
1314  }
1315  else
1316  #endif
1317  /*==================== hessenberg/eigenvalues ==================================*/
1318  #ifdef HAVE_EIGENVAL
1319  if(strcmp(sys_cmd,"hessenberg")==0)
1320  {
1321  return evHessenberg(res,h);
1322  }
1323  else
1324  #endif
1325  /*==================== eigenvalues ==================================*/
1326  #ifdef HAVE_EIGENVAL
1327  if(strcmp(sys_cmd,"eigenvals")==0)
1328  {
1329  return evEigenvals(res,h);
1330  }
1331  else
1332  #endif
1333  /*==================== rowelim ==================================*/
1334  #ifdef HAVE_EIGENVAL
1335  if(strcmp(sys_cmd,"rowelim")==0)
1336  {
1337  return evRowElim(res,h);
1338  }
1339  else
1340  #endif
1341  /*==================== rowcolswap ==================================*/
1342  #ifdef HAVE_EIGENVAL
1343  if(strcmp(sys_cmd,"rowcolswap")==0)
1344  {
1345  return evSwap(res,h);
1346  }
1347  else
1348  #endif
1349  /*==================== Gauss-Manin system ==================================*/
1350  #ifdef HAVE_GMS
1351  if(strcmp(sys_cmd,"gmsnf")==0)
1352  {
1353  return gmsNF(res,h);
1354  }
1355  else
1356  #endif
1357  /*==================== contributors =============================*/
1358  if(strcmp(sys_cmd,"contributors") == 0)
1359  {
1360  res->rtyp=STRING_CMD;
1361  res->data=(void *)omStrDup(
1362  "Olaf Bachmann, Michael Brickenstein, Hubert Grassmann, Kai Krueger, Victor Levandovskyy, Wolfgang Neumann, Thomas Nuessler, Wilfred Pohl, Jens Schmidt, Mathias Schulze, Thomas Siebert, Ruediger Stobbe, Moritz Wenk, Tim Wichmann");
1363  return FALSE;
1364  }
1365  else
1366  /*==================== spectrum =============================*/
1367  #ifdef HAVE_SPECTRUM
1368  if(strcmp(sys_cmd,"spectrum") == 0)
1369  {
1370  if ((h==NULL) || (h->Typ()!=POLY_CMD))
1371  {
1372  WerrorS("poly expected");
1373  return TRUE;
1374  }
1375  if (h->next==NULL)
1376  return spectrumProc(res,h);
1377  if (h->next->Typ()!=INT_CMD)
1378  {
1379  WerrorS("poly,int expected");
1380  return TRUE;
1381  }
1382  if(((long)h->next->Data())==1L)
1383  return spectrumfProc(res,h);
1384  return spectrumProc(res,h);
1385  }
1386  else
1387  /*==================== semic =============================*/
1388  if(strcmp(sys_cmd,"semic") == 0)
1389  {
1390  if ((h->next!=NULL)
1391  && (h->Typ()==LIST_CMD)
1392  && (h->next->Typ()==LIST_CMD))
1393  {
1394  if (h->next->next==NULL)
1395  return semicProc(res,h,h->next);
1396  else if (h->next->next->Typ()==INT_CMD)
1397  return semicProc3(res,h,h->next,h->next->next);
1398  }
1399  return TRUE;
1400  }
1401  else
1402  /*==================== spadd =============================*/
1403  if(strcmp(sys_cmd,"spadd") == 0)
1404  {
1405  const short t[]={2,LIST_CMD,LIST_CMD};
1406  if (iiCheckTypes(h,t,1))
1407  {
1408  return spaddProc(res,h,h->next);
1409  }
1410  return TRUE;
1411  }
1412  else
1413  /*==================== spmul =============================*/
1414  if(strcmp(sys_cmd,"spmul") == 0)
1415  {
1416  const short t[]={2,LIST_CMD,INT_CMD};
1417  if (iiCheckTypes(h,t,1))
1418  {
1419  return spmulProc(res,h,h->next);
1420  }
1421  return TRUE;
1422  }
1423  else
1424  #endif
1425 /*==================== tensorModuleMult ========================= */
1426  #define HAVE_SHEAFCOH_TRICKS 1
1427 
1428  #ifdef HAVE_SHEAFCOH_TRICKS
1429  if(strcmp(sys_cmd,"tensorModuleMult")==0)
1430  {
1431  const short t[]={2,INT_CMD,MODUL_CMD};
1432  // WarnS("tensorModuleMult!");
1433  if (iiCheckTypes(h,t,1))
1434  {
1435  int m = (int)( (long)h->Data() );
1436  ideal M = (ideal)h->next->Data();
1437  res->rtyp=MODUL_CMD;
1438  res->data=(void *)id_TensorModuleMult(m, M, currRing);
1439  return FALSE;
1440  }
1441  return TRUE;
1442  }
1443  else
1444  #endif
1445  /*==================== twostd =================*/
1446  #ifdef HAVE_PLURAL
1447  if (strcmp(sys_cmd, "twostd") == 0)
1448  {
1449  ideal I;
1450  if ((h!=NULL) && (h->Typ()==IDEAL_CMD))
1451  {
1452  I=(ideal)h->CopyD();
1453  res->rtyp=IDEAL_CMD;
1454  if (rIsPluralRing(currRing)) res->data=twostd(I);
1455  else res->data=I;
1457  setFlag(res,FLAG_STD);
1458  }
1459  else return TRUE;
1460  return FALSE;
1461  }
1462  else
1463  #endif
1464  /*==================== lie bracket =================*/
1465  #ifdef HAVE_PLURAL
1466  if (strcmp(sys_cmd, "bracket") == 0)
1467  {
1468  const short t[]={2,POLY_CMD,POLY_CMD};
1469  if (iiCheckTypes(h,t,1))
1470  {
1471  poly p=(poly)h->CopyD();
1472  h=h->next;
1473  poly q=(poly)h->Data();
1474  res->rtyp=POLY_CMD;
1476  return FALSE;
1477  }
1478  return TRUE;
1479  }
1480  else
1481  #endif
1482  /*==================== env ==================================*/
1483  #ifdef HAVE_PLURAL
1484  if (strcmp(sys_cmd, "env")==0)
1485  {
1486  if ((h!=NULL) && (h->Typ()==RING_CMD))
1487  {
1488  ring r = (ring)h->Data();
1489  res->data = rEnvelope(r);
1490  res->rtyp = RING_CMD;
1491  return FALSE;
1492  }
1493  else
1494  {
1495  WerrorS("`system(\"env\",<ring>)` expected");
1496  return TRUE;
1497  }
1498  }
1499  else
1500  #endif
1501 /* ============ opp ======================== */
1502  #ifdef HAVE_PLURAL
1503  if (strcmp(sys_cmd, "opp")==0)
1504  {
1505  if ((h!=NULL) && (h->Typ()==RING_CMD))
1506  {
1507  ring r=(ring)h->Data();
1508  res->data=rOpposite(r);
1509  res->rtyp=RING_CMD;
1510  return FALSE;
1511  }
1512  else
1513  {
1514  WerrorS("`system(\"opp\",<ring>)` expected");
1515  return TRUE;
1516  }
1517  }
1518  else
1519  #endif
1520  /*==================== oppose ==================================*/
1521  #ifdef HAVE_PLURAL
1522  if (strcmp(sys_cmd, "oppose")==0)
1523  {
1524  if ((h!=NULL) && (h->Typ()==RING_CMD)
1525  && (h->next!= NULL))
1526  {
1527  ring Rop = (ring)h->Data();
1528  h = h->next;
1529  idhdl w;
1530  if ((w=Rop->idroot->get(h->Name(),myynest))!=NULL)
1531  {
1532  poly p = (poly)IDDATA(w);
1533  res->data = pOppose(Rop, p, currRing); // into CurrRing?
1534  res->rtyp = POLY_CMD;
1535  return FALSE;
1536  }
1537  }
1538  else
1539  {
1540  WerrorS("`system(\"oppose\",<ring>,<poly>)` expected");
1541  return TRUE;
1542  }
1543  }
1544  else
1545  #endif
1546  /*==================== walk stuff =================*/
1547  /*==================== walkNextWeight =================*/
1548  #ifdef HAVE_WALK
1549  #ifdef OWNW
1550  if (strcmp(sys_cmd, "walkNextWeight") == 0)
1551  {
1552  const short t[]={3,INTVEC_CMD,INTVEC_CMD,IDEAL_CMD};
1553  if (!iiCheckTypes(h,t,1)) return TRUE;
1554  if (((intvec*) h->Data())->length() != currRing->N ||
1555  ((intvec*) h->next->Data())->length() != currRing->N)
1556  {
1557  Werror("system(\"walkNextWeight\" ...) intvecs not of length %d\n",
1558  currRing->N);
1559  return TRUE;
1560  }
1561  res->data = (void*) walkNextWeight(((intvec*) h->Data()),
1562  ((intvec*) h->next->Data()),
1563  (ideal) h->next->next->Data());
1564  if (res->data == NULL || res->data == (void*) 1L)
1565  {
1566  res->rtyp = INT_CMD;
1567  }
1568  else
1569  {
1570  res->rtyp = INTVEC_CMD;
1571  }
1572  return FALSE;
1573  }
1574  else
1575  #endif
1576  #endif
1577  /*==================== walkNextWeight =================*/
1578  #ifdef HAVE_WALK
1579  #ifdef OWNW
1580  if (strcmp(sys_cmd, "walkInitials") == 0)
1581  {
1582  if (h == NULL || h->Typ() != IDEAL_CMD)
1583  {
1584  WerrorS("system(\"walkInitials\", ideal) expected");
1585  return TRUE;
1586  }
1587  res->data = (void*) walkInitials((ideal) h->Data());
1588  res->rtyp = IDEAL_CMD;
1589  return FALSE;
1590  }
1591  else
1592  #endif
1593  #endif
1594  /*==================== walkAddIntVec =================*/
1595  #ifdef HAVE_WALK
1596  #ifdef WAIV
1597  if (strcmp(sys_cmd, "walkAddIntVec") == 0)
1598  {
1599  const short t[]={2,INTVEC_CMD,INTVEC_CMD};
1600  if (!iiCheckTypes(h,t,1)) return TRUE;
1601  intvec* arg1 = (intvec*) h->Data();
1602  intvec* arg2 = (intvec*) h->next->Data();
1603  res->data = (intvec*) walkAddIntVec(arg1, arg2);
1604  res->rtyp = INTVEC_CMD;
1605  return FALSE;
1606  }
1607  else
1608  #endif
1609  #endif
1610  /*==================== MwalkNextWeight =================*/
1611  #ifdef HAVE_WALK
1612  #ifdef MwaklNextWeight
1613  if (strcmp(sys_cmd, "MwalkNextWeight") == 0)
1614  {
1615  const short t[]={3,INTVEC_CMD,INTVEC_CMD,IDEAL_CMD};
1616  if (!iiCheckTypes(h,t,1)) return TRUE;
1617  if (((intvec*) h->Data())->length() != currRing->N ||
1618  ((intvec*) h->next->Data())->length() != currRing->N)
1619  {
1620  Werror("system(\"MwalkNextWeight\" ...) intvecs not of length %d\n",
1621  currRing->N);
1622  return TRUE;
1623  }
1624  intvec* arg1 = (intvec*) h->Data();
1625  intvec* arg2 = (intvec*) h->next->Data();
1626  ideal arg3 = (ideal) h->next->next->Data();
1627  intvec* result = (intvec*) MwalkNextWeight(arg1, arg2, arg3);
1628  res->rtyp = INTVEC_CMD;
1629  res->data = result;
1630  return FALSE;
1631  }
1632  else
1633  #endif //MWalkNextWeight
1634  #endif
1635  /*==================== Mivdp =================*/
1636  #ifdef HAVE_WALK
1637  if(strcmp(sys_cmd, "Mivdp") == 0)
1638  {
1639  if (h == NULL || h->Typ() != INT_CMD)
1640  {
1641  WerrorS("system(\"Mivdp\", int) expected");
1642  return TRUE;
1643  }
1644  if ((int) ((long)(h->Data())) != currRing->N)
1645  {
1646  Werror("system(\"Mivdp\" ...) intvecs not of length %d\n",
1647  currRing->N);
1648  return TRUE;
1649  }
1650  int arg1 = (int) ((long)(h->Data()));
1651  intvec* result = (intvec*) Mivdp(arg1);
1652  res->rtyp = INTVEC_CMD;
1653  res->data = result;
1654  return FALSE;
1655  }
1656  else
1657  #endif
1658  /*==================== Mivlp =================*/
1659  #ifdef HAVE_WALK
1660  if(strcmp(sys_cmd, "Mivlp") == 0)
1661  {
1662  if (h == NULL || h->Typ() != INT_CMD)
1663  {
1664  WerrorS("system(\"Mivlp\", int) expected");
1665  return TRUE;
1666  }
1667  if ((int) ((long)(h->Data())) != currRing->N)
1668  {
1669  Werror("system(\"Mivlp\" ...) intvecs not of length %d\n",
1670  currRing->N);
1671  return TRUE;
1672  }
1673  int arg1 = (int) ((long)(h->Data()));
1674  intvec* result = (intvec*) Mivlp(arg1);
1675  res->rtyp = INTVEC_CMD;
1676  res->data = result;
1677  return FALSE;
1678  }
1679  else
1680  #endif
1681  /*==================== MpDiv =================*/
1682  #ifdef HAVE_WALK
1683  #ifdef MpDiv
1684  if(strcmp(sys_cmd, "MpDiv") == 0)
1685  {
1686  const short t[]={2,POLY_CMD,POLY_CMD};
1687  if (!iiCheckTypes(h,t,1)) return TRUE;
1688  poly arg1 = (poly) h->Data();
1689  poly arg2 = (poly) h->next->Data();
1690  poly result = MpDiv(arg1, arg2);
1691  res->rtyp = POLY_CMD;
1692  res->data = result;
1693  return FALSE;
1694  }
1695  else
1696  #endif
1697  #endif
1698  /*==================== MpMult =================*/
1699  #ifdef HAVE_WALK
1700  #ifdef MpMult
1701  if(strcmp(sys_cmd, "MpMult") == 0)
1702  {
1703  const short t[]={2,POLY_CMD,POLY_CMD};
1704  if (!iiCheckTypes(h,t,1)) return TRUE;
1705  poly arg1 = (poly) h->Data();
1706  poly arg2 = (poly) h->next->Data();
1707  poly result = MpMult(arg1, arg2);
1708  res->rtyp = POLY_CMD;
1709  res->data = result;
1710  return FALSE;
1711  }
1712  else
1713  #endif
1714  #endif
1715  /*==================== MivSame =================*/
1716  #ifdef HAVE_WALK
1717  if (strcmp(sys_cmd, "MivSame") == 0)
1718  {
1719  const short t[]={2,INTVEC_CMD,INTVEC_CMD};
1720  if (!iiCheckTypes(h,t,1)) return TRUE;
1721  /*
1722  if (((intvec*) h->Data())->length() != currRing->N ||
1723  ((intvec*) h->next->Data())->length() != currRing->N)
1724  {
1725  Werror("system(\"MivSame\" ...) intvecs not of length %d\n",
1726  currRing->N);
1727  return TRUE;
1728  }
1729  */
1730  intvec* arg1 = (intvec*) h->Data();
1731  intvec* arg2 = (intvec*) h->next->Data();
1732  /*
1733  poly result = (poly) MivSame(arg1, arg2);
1734  res->rtyp = POLY_CMD;
1735  res->data = (poly) result;
1736  */
1737  res->rtyp = INT_CMD;
1738  res->data = (void*)(long) MivSame(arg1, arg2);
1739  return FALSE;
1740  }
1741  else
1742  #endif
1743  /*==================== M3ivSame =================*/
1744  #ifdef HAVE_WALK
1745  if (strcmp(sys_cmd, "M3ivSame") == 0)
1746  {
1747  const short t[]={3,INTVEC_CMD,INTVEC_CMD,INTVEC_CMD};
1748  if (!iiCheckTypes(h,t,1)) return TRUE;
1749  /*
1750  if (((intvec*) h->Data())->length() != currRing->N ||
1751  ((intvec*) h->next->Data())->length() != currRing->N ||
1752  ((intvec*) h->next->next->Data())->length() != currRing->N )
1753  {
1754  Werror("system(\"M3ivSame\" ...) intvecs not of length %d\n",
1755  currRing->N);
1756  return TRUE;
1757  }
1758  */
1759  intvec* arg1 = (intvec*) h->Data();
1760  intvec* arg2 = (intvec*) h->next->Data();
1761  intvec* arg3 = (intvec*) h->next->next->Data();
1762  /*
1763  poly result = (poly) M3ivSame(arg1, arg2, arg3);
1764  res->rtyp = POLY_CMD;
1765  res->data = (poly) result;
1766  */
1767  res->rtyp = INT_CMD;
1768  res->data = (void*)(long) M3ivSame(arg1, arg2, arg3);
1769  return FALSE;
1770  }
1771  else
1772  #endif
1773  /*==================== MwalkInitialForm =================*/
1774  #ifdef HAVE_WALK
1775  if(strcmp(sys_cmd, "MwalkInitialForm") == 0)
1776  {
1777  const short t[]={2,IDEAL_CMD,INTVEC_CMD};
1778  if (!iiCheckTypes(h,t,1)) return TRUE;
1779  if(((intvec*) h->next->Data())->length() != currRing->N)
1780  {
1781  Werror("system \"MwalkInitialForm\"...) intvec not of length %d\n",
1782  currRing->N);
1783  return TRUE;
1784  }
1785  ideal id = (ideal) h->Data();
1786  intvec* int_w = (intvec*) h->next->Data();
1787  ideal result = (ideal) MwalkInitialForm(id, int_w);
1788  res->rtyp = IDEAL_CMD;
1789  res->data = result;
1790  return FALSE;
1791  }
1792  else
1793  #endif
1794  /*==================== MivMatrixOrder =================*/
1795  #ifdef HAVE_WALK
1796  /************** Perturbation walk **********/
1797  if(strcmp(sys_cmd, "MivMatrixOrder") == 0)
1798  {
1799  if(h==NULL || h->Typ() != INTVEC_CMD)
1800  {
1801  WerrorS("system(\"MivMatrixOrder\",intvec) expected");
1802  return TRUE;
1803  }
1804  intvec* arg1 = (intvec*) h->Data();
1805  intvec* result = MivMatrixOrder(arg1);
1806  res->rtyp = INTVEC_CMD;
1807  res->data = result;
1808  return FALSE;
1809  }
1810  else
1811  #endif
1812  /*==================== MivMatrixOrderdp =================*/
1813  #ifdef HAVE_WALK
1814  if(strcmp(sys_cmd, "MivMatrixOrderdp") == 0)
1815  {
1816  if(h==NULL || h->Typ() != INT_CMD)
1817  {
1818  WerrorS("system(\"MivMatrixOrderdp\",intvec) expected");
1819  return TRUE;
1820  }
1821  int arg1 = (int) ((long)(h->Data()));
1822  intvec* result = (intvec*) MivMatrixOrderdp(arg1);
1823  res->rtyp = INTVEC_CMD;
1824  res->data = result;
1825  return FALSE;
1826  }
1827  else
1828  #endif
1829  /*==================== MPertVectors =================*/
1830  #ifdef HAVE_WALK
1831  if(strcmp(sys_cmd, "MPertVectors") == 0)
1832  {
1833  const short t[]={3,IDEAL_CMD,INTVEC_CMD,INT_CMD};
1834  if (!iiCheckTypes(h,t,1)) return TRUE;
1835  ideal arg1 = (ideal) h->Data();
1836  intvec* arg2 = (intvec*) h->next->Data();
1837  int arg3 = (int) ((long)(h->next->next->Data()));
1838  intvec* result = (intvec*) MPertVectors(arg1, arg2, arg3);
1839  res->rtyp = INTVEC_CMD;
1840  res->data = result;
1841  return FALSE;
1842  }
1843  else
1844  #endif
1845  /*==================== MPertVectorslp =================*/
1846  #ifdef HAVE_WALK
1847  if(strcmp(sys_cmd, "MPertVectorslp") == 0)
1848  {
1849  const short t[]={3,IDEAL_CMD,INTVEC_CMD,INT_CMD};
1850  if (!iiCheckTypes(h,t,1)) return TRUE;
1851  ideal arg1 = (ideal) h->Data();
1852  intvec* arg2 = (intvec*) h->next->Data();
1853  int arg3 = (int) ((long)(h->next->next->Data()));
1854  intvec* result = (intvec*) MPertVectorslp(arg1, arg2, arg3);
1855  res->rtyp = INTVEC_CMD;
1856  res->data = result;
1857  return FALSE;
1858  }
1859  else
1860  #endif
1861  /************** fractal walk **********/
1862  #ifdef HAVE_WALK
1863  if(strcmp(sys_cmd, "Mfpertvector") == 0)
1864  {
1865  const short t[]={2,IDEAL_CMD,INTVEC_CMD};
1866  if (!iiCheckTypes(h,t,1)) return TRUE;
1867  ideal arg1 = (ideal) h->Data();
1868  intvec* arg2 = (intvec*) h->next->Data();
1869  intvec* result = Mfpertvector(arg1, arg2);
1870  res->rtyp = INTVEC_CMD;
1871  res->data = result;
1872  return FALSE;
1873  }
1874  else
1875  #endif
1876  /*==================== MivUnit =================*/
1877  #ifdef HAVE_WALK
1878  if(strcmp(sys_cmd, "MivUnit") == 0)
1879  {
1880  const short t[]={1,INT_CMD};
1881  if (!iiCheckTypes(h,t,1)) return TRUE;
1882  int arg1 = (int) ((long)(h->Data()));
1883  intvec* result = (intvec*) MivUnit(arg1);
1884  res->rtyp = INTVEC_CMD;
1885  res->data = result;
1886  return FALSE;
1887  }
1888  else
1889  #endif
1890  /*==================== MivWeightOrderlp =================*/
1891  #ifdef HAVE_WALK
1892  if(strcmp(sys_cmd, "MivWeightOrderlp") == 0)
1893  {
1894  const short t[]={1,INTVEC_CMD};
1895  if (!iiCheckTypes(h,t,1)) return TRUE;
1896  intvec* arg1 = (intvec*) h->Data();
1897  intvec* result = MivWeightOrderlp(arg1);
1898  res->rtyp = INTVEC_CMD;
1899  res->data = result;
1900  return FALSE;
1901  }
1902  else
1903  #endif
1904  /*==================== MivWeightOrderdp =================*/
1905  #ifdef HAVE_WALK
1906  if(strcmp(sys_cmd, "MivWeightOrderdp") == 0)
1907  {
1908  if(h==NULL || h->Typ() != INTVEC_CMD)
1909  {
1910  WerrorS("system(\"MivWeightOrderdp\",intvec) expected");
1911  return TRUE;
1912  }
1913  intvec* arg1 = (intvec*) h->Data();
1914  //int arg2 = (int) h->next->Data();
1915  intvec* result = MivWeightOrderdp(arg1);
1916  res->rtyp = INTVEC_CMD;
1917  res->data = result;
1918  return FALSE;
1919  }
1920  else
1921  #endif
1922  /*==================== MivMatrixOrderlp =================*/
1923  #ifdef HAVE_WALK
1924  if(strcmp(sys_cmd, "MivMatrixOrderlp") == 0)
1925  {
1926  if(h==NULL || h->Typ() != INT_CMD)
1927  {
1928  WerrorS("system(\"MivMatrixOrderlp\",int) expected");
1929  return TRUE;
1930  }
1931  int arg1 = (int) ((long)(h->Data()));
1932  intvec* result = (intvec*) MivMatrixOrderlp(arg1);
1933  res->rtyp = INTVEC_CMD;
1934  res->data = result;
1935  return FALSE;
1936  }
1937  else
1938  #endif
1939  /*==================== MkInterRedNextWeight =================*/
1940  #ifdef HAVE_WALK
1941  if (strcmp(sys_cmd, "MkInterRedNextWeight") == 0)
1942  {
1943  const short t[]={3,INTVEC_CMD,INTVEC_CMD,IDEAL_CMD};
1944  if (!iiCheckTypes(h,t,1)) return TRUE;
1945  if (((intvec*) h->Data())->length() != currRing->N ||
1946  ((intvec*) h->next->Data())->length() != currRing->N)
1947  {
1948  Werror("system(\"MkInterRedNextWeight\" ...) intvecs not of length %d\n",
1949  currRing->N);
1950  return TRUE;
1951  }
1952  intvec* arg1 = (intvec*) h->Data();
1953  intvec* arg2 = (intvec*) h->next->Data();
1954  ideal arg3 = (ideal) h->next->next->Data();
1955  intvec* result = (intvec*) MkInterRedNextWeight(arg1, arg2, arg3);
1956  res->rtyp = INTVEC_CMD;
1957  res->data = result;
1958  return FALSE;
1959  }
1960  else
1961  #endif
1962  /*==================== MPertNextWeight =================*/
1963  #ifdef HAVE_WALK
1964  #ifdef MPertNextWeight
1965  if (strcmp(sys_cmd, "MPertNextWeight") == 0)
1966  {
1967  const short t[]={3,INTVEC_CMD,IDEAL_CMD,INT_CMD};
1968  if (!iiCheckTypes(h,t,1)) return TRUE;
1969  if (((intvec*) h->Data())->length() != currRing->N)
1970  {
1971  Werror("system(\"MPertNextWeight\" ...) intvecs not of length %d\n",
1972  currRing->N);
1973  return TRUE;
1974  }
1975  intvec* arg1 = (intvec*) h->Data();
1976  ideal arg2 = (ideal) h->next->Data();
1977  int arg3 = (int) h->next->next->Data();
1978  intvec* result = (intvec*) MPertNextWeight(arg1, arg2, arg3);
1979  res->rtyp = INTVEC_CMD;
1980  res->data = result;
1981  return FALSE;
1982  }
1983  else
1984  #endif //MPertNextWeight
1985  #endif
1986  /*==================== Mivperttarget =================*/
1987  #ifdef HAVE_WALK
1988  #ifdef Mivperttarget
1989  if (strcmp(sys_cmd, "Mivperttarget") == 0)
1990  {
1991  const short t[]={2,IDEAL_CMD,INT_CMD};
1992  if (!iiCheckTypes(h,t,1)) return TRUE;
1993  ideal arg1 = (ideal) h->Data();
1994  int arg2 = (int) h->next->Data();
1995  intvec* result = (intvec*) Mivperttarget(arg1, arg2);
1996  res->rtyp = INTVEC_CMD;
1997  res->data = result;
1998  return FALSE;
1999  }
2000  else
2001  #endif //Mivperttarget
2002  #endif
2003  /*==================== Mwalk =================*/
2004  #ifdef HAVE_WALK
2005  if (strcmp(sys_cmd, "Mwalk") == 0)
2006  {
2007  const short t[]={6,IDEAL_CMD,INTVEC_CMD,INTVEC_CMD,RING_CMD,INT_CMD,INT_CMD};
2008  if (!iiCheckTypes(h,t,1)) return TRUE;
2009  if (((intvec*) h->next->Data())->length() != currRing->N &&
2010  ((intvec*) h->next->next->Data())->length() != currRing->N )
2011  {
2012  Werror("system(\"Mwalk\" ...) intvecs not of length %d\n",
2013  currRing->N);
2014  return TRUE;
2015  }
2016  ideal arg1 = (ideal) h->CopyD();
2017  intvec* arg2 = (intvec*) h->next->Data();
2018  intvec* arg3 = (intvec*) h->next->next->Data();
2019  ring arg4 = (ring) h->next->next->next->Data();
2020  int arg5 = (int) (long) h->next->next->next->next->Data();
2021  int arg6 = (int) (long) h->next->next->next->next->next->Data();
2022  ideal result = (ideal) Mwalk(arg1, arg2, arg3, arg4, arg5, arg6);
2023  res->rtyp = IDEAL_CMD;
2024  res->data = result;
2025  return FALSE;
2026  }
2027  else
2028  #endif
2029  /*==================== Mpwalk =================*/
2030  #ifdef HAVE_WALK
2031  #ifdef MPWALK_ORIG
2032  if (strcmp(sys_cmd, "Mwalk") == 0)
2033  {
2034  const short t[]={4,IDEAL_CMD,INTVEC_CMD,INTVEC_CMD,RING_CMD};
2035  if (!iiCheckTypes(h,t,1)) return TRUE;
2036  if ((((intvec*) h->next->Data())->length() != currRing->N &&
2037  ((intvec*) h->next->next->Data())->length() != currRing->N ) &&
2038  (((intvec*) h->next->Data())->length() != (currRing->N)*(currRing->N) &&
2039  ((intvec*) h->next->next->Data())->length() != (currRing->N)*(currRing->N)))
2040  {
2041  Werror("system(\"Mwalk\" ...) intvecs not of length %d or %d\n",
2042  currRing->N,(currRing->N)*(currRing->N));
2043  return TRUE;
2044  }
2045  ideal arg1 = (ideal) h->Data();
2046  intvec* arg2 = (intvec*) h->next->Data();
2047  intvec* arg3 = (intvec*) h->next->next->Data();
2048  ring arg4 = (ring) h->next->next->next->Data();
2049  ideal result = (ideal) Mwalk(arg1, arg2, arg3,arg4);
2050  res->rtyp = IDEAL_CMD;
2051  res->data = result;
2052  return FALSE;
2053  }
2054  else
2055  #else
2056  if (strcmp(sys_cmd, "Mpwalk") == 0)
2057  {
2059  if (!iiCheckTypes(h,t,1)) return TRUE;
2060  if(((intvec*) h->next->next->next->Data())->length() != currRing->N &&
2061  ((intvec*) h->next->next->next->next->Data())->length()!=currRing->N)
2062  {
2063  Werror("system(\"Mpwalk\" ...) intvecs not of length %d\n",currRing->N);
2064  return TRUE;
2065  }
2066  ideal arg1 = (ideal) h->Data();
2067  int arg2 = (int) (long) h->next->Data();
2068  int arg3 = (int) (long) h->next->next->Data();
2069  intvec* arg4 = (intvec*) h->next->next->next->Data();
2070  intvec* arg5 = (intvec*) h->next->next->next->next->Data();
2071  int arg6 = (int) (long) h->next->next->next->next->next->Data();
2072  int arg7 = (int) (long) h->next->next->next->next->next->next->Data();
2073  int arg8 = (int) (long) h->next->next->next->next->next->next->next->Data();
2074  ideal result = (ideal) Mpwalk(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
2075  res->rtyp = IDEAL_CMD;
2076  res->data = result;
2077  return FALSE;
2078  }
2079  else
2080  #endif
2081  #endif
2082  /*==================== Mrwalk =================*/
2083  #ifdef HAVE_WALK
2084  if (strcmp(sys_cmd, "Mrwalk") == 0)
2085  {
2087  if (!iiCheckTypes(h,t,1)) return TRUE;
2088  if(((intvec*) h->next->Data())->length() != currRing->N &&
2089  ((intvec*) h->next->Data())->length() != (currRing->N)*(currRing->N) &&
2090  ((intvec*) h->next->next->Data())->length() != currRing->N &&
2091  ((intvec*) h->next->next->Data())->length() != (currRing->N)*(currRing->N) )
2092  {
2093  Werror("system(\"Mrwalk\" ...) intvecs not of length %d or %d\n",
2094  currRing->N,(currRing->N)*(currRing->N));
2095  return TRUE;
2096  }
2097  ideal arg1 = (ideal) h->Data();
2098  intvec* arg2 = (intvec*) h->next->Data();
2099  intvec* arg3 = (intvec*) h->next->next->Data();
2100  int arg4 = (int)(long) h->next->next->next->Data();
2101  int arg5 = (int)(long) h->next->next->next->next->Data();
2102  int arg6 = (int)(long) h->next->next->next->next->next->Data();
2103  int arg7 = (int)(long) h->next->next->next->next->next->next->Data();
2104  ideal result = (ideal) Mrwalk(arg1, arg2, arg3, arg4, arg5, arg6, arg7);
2105  res->rtyp = IDEAL_CMD;
2106  res->data = result;
2107  return FALSE;
2108  }
2109  else
2110  #endif
2111  /*==================== MAltwalk1 =================*/
2112  #ifdef HAVE_WALK
2113  if (strcmp(sys_cmd, "MAltwalk1") == 0)
2114  {
2115  const short t[]={5,IDEAL_CMD,INT_CMD,INT_CMD,INTVEC_CMD,INTVEC_CMD};
2116  if (!iiCheckTypes(h,t,1)) return TRUE;
2117  if (((intvec*) h->next->next->next->Data())->length() != currRing->N &&
2118  ((intvec*) h->next->next->next->next->Data())->length()!=currRing->N)
2119  {
2120  Werror("system(\"MAltwalk1\" ...) intvecs not of length %d\n",
2121  currRing->N);
2122  return TRUE;
2123  }
2124  ideal arg1 = (ideal) h->Data();
2125  int arg2 = (int) ((long)(h->next->Data()));
2126  int arg3 = (int) ((long)(h->next->next->Data()));
2127  intvec* arg4 = (intvec*) h->next->next->next->Data();
2128  intvec* arg5 = (intvec*) h->next->next->next->next->Data();
2129  ideal result = (ideal) MAltwalk1(arg1, arg2, arg3, arg4, arg5);
2130  res->rtyp = IDEAL_CMD;
2131  res->data = result;
2132  return FALSE;
2133  }
2134  else
2135  #endif
2136  /*==================== MAltwalk1 =================*/
2137  #ifdef HAVE_WALK
2138  #ifdef MFWALK_ALT
2139  if (strcmp(sys_cmd, "Mfwalk_alt") == 0)
2140  {
2141  const short t[]={4,IDEAL_CMD,INTVEC_CMD,INTVEC_CMD,INT_CMD};
2142  if (!iiCheckTypes(h,t,1)) return TRUE;
2143  if (((intvec*) h->next->Data())->length() != currRing->N &&
2144  ((intvec*) h->next->next->Data())->length() != currRing->N )
2145  {
2146  Werror("system(\"Mfwalk\" ...) intvecs not of length %d\n",
2147  currRing->N);
2148  return TRUE;
2149  }
2150  ideal arg1 = (ideal) h->Data();
2151  intvec* arg2 = (intvec*) h->next->Data();
2152  intvec* arg3 = (intvec*) h->next->next->Data();
2153  int arg4 = (int) h->next->next->next->Data();
2154  ideal result = (ideal) Mfwalk_alt(arg1, arg2, arg3, arg4);
2155  res->rtyp = IDEAL_CMD;
2156  res->data = result;
2157  return FALSE;
2158  }
2159  else
2160  #endif
2161  #endif
2162  /*==================== Mfwalk =================*/
2163  #ifdef HAVE_WALK
2164  if (strcmp(sys_cmd, "Mfwalk") == 0)
2165  {
2166  const short t[]={5,IDEAL_CMD,INTVEC_CMD,INTVEC_CMD,INT_CMD,INT_CMD};
2167  if (!iiCheckTypes(h,t,1)) return TRUE;
2168  if (((intvec*) h->next->Data())->length() != currRing->N &&
2169  ((intvec*) h->next->next->Data())->length() != currRing->N )
2170  {
2171  Werror("system(\"Mfwalk\" ...) intvecs not of length %d\n",
2172  currRing->N);
2173  return TRUE;
2174  }
2175  ideal arg1 = (ideal) h->Data();
2176  intvec* arg2 = (intvec*) h->next->Data();
2177  intvec* arg3 = (intvec*) h->next->next->Data();
2178  int arg4 = (int)(long) h->next->next->next->Data();
2179  int arg5 = (int)(long) h->next->next->next->next->Data();
2180  ideal result = (ideal) Mfwalk(arg1, arg2, arg3, arg4, arg5);
2181  res->rtyp = IDEAL_CMD;
2182  res->data = result;
2183  return FALSE;
2184  }
2185  else
2186  #endif
2187  /*==================== Mfrwalk =================*/
2188  #ifdef HAVE_WALK
2189  if (strcmp(sys_cmd, "Mfrwalk") == 0)
2190  {
2191  const short t[]={6,IDEAL_CMD,INTVEC_CMD,INTVEC_CMD,INT_CMD,INT_CMD,INT_CMD};
2192  if (!iiCheckTypes(h,t,1)) return TRUE;
2193 /*
2194  if (((intvec*) h->next->Data())->length() != currRing->N &&
2195  ((intvec*) h->next->next->Data())->length() != currRing->N)
2196  {
2197  Werror("system(\"Mfrwalk\" ...) intvecs not of length %d\n",currRing->N);
2198  return TRUE;
2199  }
2200 */
2201  if((((intvec*) h->next->Data())->length() != currRing->N &&
2202  ((intvec*) h->next->next->Data())->length() != currRing->N ) &&
2203  (((intvec*) h->next->Data())->length() != (currRing->N)*(currRing->N) &&
2204  ((intvec*) h->next->next->Data())->length() != (currRing->N)*(currRing->N) ))
2205  {
2206  Werror("system(\"Mfrwalk\" ...) intvecs not of length %d or %d\n",
2207  currRing->N,(currRing->N)*(currRing->N));
2208  return TRUE;
2209  }
2210 
2211  ideal arg1 = (ideal) h->Data();
2212  intvec* arg2 = (intvec*) h->next->Data();
2213  intvec* arg3 = (intvec*) h->next->next->Data();
2214  int arg4 = (int)(long) h->next->next->next->Data();
2215  int arg5 = (int)(long) h->next->next->next->next->Data();
2216  int arg6 = (int)(long) h->next->next->next->next->next->Data();
2217  ideal result = (ideal) Mfrwalk(arg1, arg2, arg3, arg4, arg5, arg6);
2218  res->rtyp = IDEAL_CMD;
2219  res->data = result;
2220  return FALSE;
2221  }
2222  else
2223  /*==================== Mprwalk =================*/
2224  if (strcmp(sys_cmd, "Mprwalk") == 0)
2225  {
2227  if (!iiCheckTypes(h,t,1)) return TRUE;
2228  if((((intvec*) h->next->Data())->length() != currRing->N &&
2229  ((intvec*) h->next->next->Data())->length() != currRing->N ) &&
2230  (((intvec*) h->next->Data())->length() != (currRing->N)*(currRing->N) &&
2231  ((intvec*) h->next->next->Data())->length() != (currRing->N)*(currRing->N) ))
2232  {
2233  Werror("system(\"Mrwalk\" ...) intvecs not of length %d or %d\n",
2234  currRing->N,(currRing->N)*(currRing->N));
2235  return TRUE;
2236  }
2237  ideal arg1 = (ideal) h->Data();
2238  intvec* arg2 = (intvec*) h->next->Data();
2239  intvec* arg3 = (intvec*) h->next->next->Data();
2240  int arg4 = (int)(long) h->next->next->next->Data();
2241  int arg5 = (int)(long) h->next->next->next->next->Data();
2242  int arg6 = (int)(long) h->next->next->next->next->next->Data();
2243  int arg7 = (int)(long) h->next->next->next->next->next->next->Data();
2244  int arg8 = (int)(long) h->next->next->next->next->next->next->next->Data();
2245  int arg9 = (int)(long) h->next->next->next->next->next->next->next->next->Data();
2246  ideal result = (ideal) Mprwalk(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
2247  res->rtyp = IDEAL_CMD;
2248  res->data = result;
2249  return FALSE;
2250  }
2251  else
2252  #endif
2253  /*==================== TranMImprovwalk =================*/
2254  #ifdef HAVE_WALK
2255  #ifdef TRAN_Orig
2256  if (strcmp(sys_cmd, "TranMImprovwalk") == 0)
2257  {
2258  const short t[]={3,IDEAL_CMD,INTVEC_CMD,INTVEC_CMD};
2259  if (!iiCheckTypes(h,t,1)) return TRUE;
2260  if (((intvec*) h->next->Data())->length() != currRing->N &&
2261  ((intvec*) h->next->next->Data())->length() != currRing->N )
2262  {
2263  Werror("system(\"TranMImprovwalk\" ...) intvecs not of length %d\n",
2264  currRing->N);
2265  return TRUE;
2266  }
2267  ideal arg1 = (ideal) h->Data();
2268  intvec* arg2 = (intvec*) h->next->Data();
2269  intvec* arg3 = (intvec*) h->next->next->Data();
2270  ideal result = (ideal) TranMImprovwalk(arg1, arg2, arg3);
2271  res->rtyp = IDEAL_CMD;
2272  res->data = result;
2273  return FALSE;
2274  }
2275  else
2276  #endif
2277  #endif
2278  /*==================== MAltwalk2 =================*/
2279  #ifdef HAVE_WALK
2280  if (strcmp(sys_cmd, "MAltwalk2") == 0)
2281  {
2282  const short t[]={3,IDEAL_CMD,INTVEC_CMD,INTVEC_CMD};
2283  if (!iiCheckTypes(h,t,1)) return TRUE;
2284  if (((intvec*) h->next->Data())->length() != currRing->N &&
2285  ((intvec*) h->next->next->Data())->length() != currRing->N )
2286  {
2287  Werror("system(\"MAltwalk2\" ...) intvecs not of length %d\n",
2288  currRing->N);
2289  return TRUE;
2290  }
2291  ideal arg1 = (ideal) h->Data();
2292  intvec* arg2 = (intvec*) h->next->Data();
2293  intvec* arg3 = (intvec*) h->next->next->Data();
2294  ideal result = (ideal) MAltwalk2(arg1, arg2, arg3);
2295  res->rtyp = IDEAL_CMD;
2296  res->data = result;
2297  return FALSE;
2298  }
2299  else
2300  #endif
2301  /*==================== MAltwalk2 =================*/
2302  #ifdef HAVE_WALK
2303  if (strcmp(sys_cmd, "TranMImprovwalk") == 0)
2304  {
2305  const short t[]={4,IDEAL_CMD,INTVEC_CMD,INTVEC_CMD,INT_CMD};
2306  if (!iiCheckTypes(h,t,1)) return TRUE;
2307  if (((intvec*) h->next->Data())->length() != currRing->N &&
2308  ((intvec*) h->next->next->Data())->length() != currRing->N )
2309  {
2310  Werror("system(\"TranMImprovwalk\" ...) intvecs not of length %d\n",
2311  currRing->N);
2312  return TRUE;
2313  }
2314  ideal arg1 = (ideal) h->Data();
2315  intvec* arg2 = (intvec*) h->next->Data();
2316  intvec* arg3 = (intvec*) h->next->next->Data();
2317  int arg4 = (int) ((long)(h->next->next->next->Data()));
2318  ideal result = (ideal) TranMImprovwalk(arg1, arg2, arg3, arg4);
2319  res->rtyp = IDEAL_CMD;
2320  res->data = result;
2321  return FALSE;
2322  }
2323  else
2324  #endif
2325  /*==================== TranMrImprovwalk =================*/
2326  #if 0
2327  #ifdef HAVE_WALK
2328  if (strcmp(sys_cmd, "TranMrImprovwalk") == 0)
2329  {
2330  if (h == NULL || h->Typ() != IDEAL_CMD ||
2331  h->next == NULL || h->next->Typ() != INTVEC_CMD ||
2332  h->next->next == NULL || h->next->next->Typ() != INTVEC_CMD ||
2333  h->next->next->next == NULL || h->next->next->next->Typ() != INT_CMD ||
2334  h->next->next->next == NULL || h->next->next->next->next->Typ() != INT_CMD ||
2335  h->next->next->next == NULL || h->next->next->next->next->next->Typ() != INT_CMD)
2336  {
2337  WerrorS("system(\"TranMrImprovwalk\", ideal, intvec, intvec) expected");
2338  return TRUE;
2339  }
2340  if (((intvec*) h->next->Data())->length() != currRing->N &&
2341  ((intvec*) h->next->next->Data())->length() != currRing->N )
2342  {
2343  Werror("system(\"TranMrImprovwalk\" ...) intvecs not of length %d\n", currRing->N);
2344  return TRUE;
2345  }
2346  ideal arg1 = (ideal) h->Data();
2347  intvec* arg2 = (intvec*) h->next->Data();
2348  intvec* arg3 = (intvec*) h->next->next->Data();
2349  int arg4 = (int)(long) h->next->next->next->Data();
2350  int arg5 = (int)(long) h->next->next->next->next->Data();
2351  int arg6 = (int)(long) h->next->next->next->next->next->Data();
2352  ideal result = (ideal) TranMrImprovwalk(arg1, arg2, arg3, arg4, arg5, arg6);
2353  res->rtyp = IDEAL_CMD;
2354  res->data = result;
2355  return FALSE;
2356  }
2357  else
2358  #endif
2359  #endif
2360  /*================= Extended system call ========================*/
2361  {
2362  #ifndef MAKE_DISTRIBUTION
2363  return(jjEXTENDED_SYSTEM(res, args));
2364  #else
2365  Werror( "system(\"%s\",...) %s", sys_cmd, feNotImplemented );
2366  #endif
2367  }
2368  } /* typ==string */
2369  return TRUE;
2370 }
2371 
2372 
2373 #ifdef HAVE_EXTENDED_SYSTEM
2374  // You can put your own system calls here
2375 # include "kernel/fglm/fglm.h"
2376 # ifdef HAVE_NEWTON
2377 # include "hc_newton.h"
2378 # endif
2379 
2381 {
2382  if(h->Typ() == STRING_CMD)
2383  {
2384  char *sys_cmd=(char *)(h->Data());
2385  h=h->next;
2386  /*==================== test syz strat =================*/
2387  if (strcmp(sys_cmd, "syz") == 0)
2388  {
2389  if ((h!=NULL) && (h->Typ()==STRING_CMD))
2390  {
2391  const char *s=(const char *)h->Data();
2392  if (strcmp(s,"posInT_EcartFDegpLength")==0)
2394  else if (strcmp(s,"posInT_FDegpLength")==0)
2396  else if (strcmp(s,"posInT_pLength")==0)
2398  else if (strcmp(s,"posInT0")==0)
2400  else if (strcmp(s,"posInT1")==0)
2402  else if (strcmp(s,"posInT2")==0)
2404  else if (strcmp(s,"posInT11")==0)
2406  else if (strcmp(s,"posInT110")==0)
2408  else if (strcmp(s,"posInT13")==0)
2410  else if (strcmp(s,"posInT15")==0)
2412  else if (strcmp(s,"posInT17")==0)
2414  else if (strcmp(s,"posInT17_c")==0)
2416  else if (strcmp(s,"posInT19")==0)
2418  else PrintS("valid posInT:0,1,2,11,110,13,15,17,17_c,19,_EcartFDegpLength,_FDegpLength,_pLength,_EcartpLength\n");
2419  }
2420  else
2421  {
2422  test_PosInT=NULL;
2423  test_PosInL=NULL;
2424  }
2425  si_opt_2|=Sy_bit(23);
2426  return FALSE;
2427  }
2428  else
2429  /*==================== locNF ======================================*/
2430  if(strcmp(sys_cmd,"locNF")==0)
2431  {
2432  const short t[]={4,VECTOR_CMD,MODUL_CMD,INT_CMD,INTVEC_CMD};
2433  if (iiCheckTypes(h,t,1))
2434  {
2435  poly f=(poly)h->Data();
2436  h=h->next;
2437  ideal m=(ideal)h->Data();
2438  assumeStdFlag(h);
2439  h=h->next;
2440  int n=(int)((long)h->Data());
2441  h=h->next;
2442  intvec *v=(intvec *)h->Data();
2443 
2444  /* == now the work starts == */
2445 
2446  int * iv=iv2array(v, currRing);
2447  poly r=0;
2448  poly hp=ppJetW(f,n,iv);
2449  int s=MATCOLS(m);
2450  int j=0;
2451  matrix T=mp_InitI(s,1,0, currRing);
2452 
2453  while (hp != NULL)
2454  {
2455  if (pDivisibleBy(m->m[j],hp))
2456  {
2457  if (MATELEM(T,j+1,1)==0)
2458  {
2459  MATELEM(T,j+1,1)=pDivideM(pHead(hp),pHead(m->m[j]));
2460  }
2461  else
2462  {
2463  pAdd(MATELEM(T,j+1,1),pDivideM(pHead(hp),pHead(m->m[j])));
2464  }
2465  hp=ppJetW(ksOldSpolyRed(m->m[j],hp,0),n,iv);
2466  j=0;
2467  }
2468  else
2469  {
2470  if (j==s-1)
2471  {
2472  r=pAdd(r,pHead(hp));
2473  hp=pLmDeleteAndNext(hp); /* hp=pSub(hp,pHead(hp));*/
2474  j=0;
2475  }
2476  else
2477  {
2478  j++;
2479  }
2480  }
2481  }
2482 
2485  for (int k=1;k<=MATROWS(Temp);k++)
2486  {
2487  MATELEM(R,k,1)=MATELEM(Temp,k,1);
2488  }
2489 
2491  L->Init(2);
2492  L->m[0].rtyp=MATRIX_CMD; L->m[0].data=(void *)R;
2493  L->m[1].rtyp=MATRIX_CMD; L->m[1].data=(void *)T;
2494  res->data=L;
2495  res->rtyp=LIST_CMD;
2496  // iv aufraeumen
2497  omFree(iv);
2498  return FALSE;
2499  }
2500  else
2501  return TRUE;
2502  }
2503  else
2504  /*==================== poly debug ==================================*/
2505  if(strcmp(sys_cmd,"p")==0)
2506  {
2507 # ifdef RDEBUG
2508  p_DebugPrint((poly)h->Data(), currRing);
2509 # else
2510  WarnS("Sorry: not available for release build!");
2511 # endif
2512  return FALSE;
2513  }
2514  else
2515  /*==================== setsyzcomp ==================================*/
2516  if(strcmp(sys_cmd,"setsyzcomp")==0)
2517  {
2518  if ((h!=NULL) && (h->Typ()==INT_CMD))
2519  {
2520  int k = (int)(long)h->Data();
2521  if ( currRing->order[0] == ringorder_s )
2522  {
2524  }
2525  }
2526  }
2527  /*==================== ring debug ==================================*/
2528  if(strcmp(sys_cmd,"r")==0)
2529  {
2530 # ifdef RDEBUG
2531  rDebugPrint((ring)h->Data());
2532 # else
2533  WarnS("Sorry: not available for release build!");
2534 # endif
2535  return FALSE;
2536  }
2537  else
2538  /*==================== changeRing ========================*/
2539  /* The following code changes the names of the variables in the
2540  current ring to "x1", "x2", ..., "xN", where N is the number
2541  of variables in the current ring.
2542  The purpose of this rewriting is to eliminate indexed variables,
2543  as they may cause problems when generating scripts for Magma,
2544  Maple, or Macaulay2. */
2545  if(strcmp(sys_cmd,"changeRing")==0)
2546  {
2547  int varN = currRing->N;
2548  char h[10];
2549  for (int i = 1; i <= varN; i++)
2550  {
2551  omFree(currRing->names[i - 1]);
2552  sprintf(h, "x%d", i);
2553  currRing->names[i - 1] = omStrDup(h);
2554  }
2556  res->rtyp = INT_CMD;
2557  res->data = (void*)0L;
2558  return FALSE;
2559  }
2560  else
2561  /*==================== mtrack ==================================*/
2562  if(strcmp(sys_cmd,"mtrack")==0)
2563  {
2564  #ifdef OM_TRACK
2565  om_Opts.MarkAsStatic = 1;
2566  FILE *fd = NULL;
2567  int max = 5;
2568  while (h != NULL)
2569  {
2571  if (fd == NULL && h->Typ()==STRING_CMD)
2572  {
2573  char *fn=(char*) h->Data();
2574  fd = fopen(fn, "w");
2575  if (fd == NULL)
2576  Warn("Can not open %s for writing og mtrack. Using stdout",fn);
2577  }
2578  else if (h->Typ() == INT_CMD)
2579  {
2580  max = (int)(long)h->Data();
2581  }
2582  h = h->Next();
2583  }
2584  omPrintUsedTrackAddrs((fd == NULL ? stdout : fd), max);
2585  if (fd != NULL) fclose(fd);
2586  om_Opts.MarkAsStatic = 0;
2587  return FALSE;
2588  #else
2589  WerrorS("system(\"mtrack\",..) is not implemented in this version");
2590  return TRUE;
2591  #endif
2592  }
2593  else
2594  /*==================== backtrace ==================================*/
2595  #ifndef OM_NDEBUG
2596  if(strcmp(sys_cmd,"backtrace")==0)
2597  {
2598  omPrintCurrentBackTrace(stdout);
2599  return FALSE;
2600  }
2601  else
2602  #endif
2603 
2604 #if !defined(OM_NDEBUG)
2605  /*==================== omMemoryTest ==================================*/
2606  if (strcmp(sys_cmd,"omMemoryTest")==0)
2607  {
2608 
2609 #ifdef OM_STATS_H
2610  PrintS("\n[om_Info]: \n");
2611  omUpdateInfo();
2612 #define OM_PRINT(name) Print(" %-22s : %10ld \n", #name, om_Info . name)
2613  OM_PRINT(MaxBytesSystem);
2614  OM_PRINT(CurrentBytesSystem);
2615  OM_PRINT(MaxBytesSbrk);
2616  OM_PRINT(CurrentBytesSbrk);
2617  OM_PRINT(MaxBytesMmap);
2618  OM_PRINT(CurrentBytesMmap);
2619  OM_PRINT(UsedBytes);
2620  OM_PRINT(AvailBytes);
2621  OM_PRINT(UsedBytesMalloc);
2622  OM_PRINT(AvailBytesMalloc);
2623  OM_PRINT(MaxBytesFromMalloc);
2624  OM_PRINT(CurrentBytesFromMalloc);
2625  OM_PRINT(MaxBytesFromValloc);
2626  OM_PRINT(CurrentBytesFromValloc);
2627  OM_PRINT(UsedBytesFromValloc);
2628  OM_PRINT(AvailBytesFromValloc);
2629  OM_PRINT(MaxPages);
2630  OM_PRINT(UsedPages);
2631  OM_PRINT(AvailPages);
2632  OM_PRINT(MaxRegionsAlloc);
2633  OM_PRINT(CurrentRegionsAlloc);
2634 #undef OM_PRINT
2635 #endif
2636 
2637 #ifdef OM_OPTS_H
2638  PrintS("\n[om_Opts]: \n");
2639 #define OM_PRINT(format, name) Print(" %-22s : %10" format"\n", #name, om_Opts . name)
2640  OM_PRINT("d", MinTrack);
2641  OM_PRINT("d", MinCheck);
2642  OM_PRINT("d", MaxTrack);
2643  OM_PRINT("d", MaxCheck);
2644  OM_PRINT("d", Keep);
2645  OM_PRINT("d", HowToReportErrors);
2646  OM_PRINT("d", MarkAsStatic);
2647  OM_PRINT("u", PagesPerRegion);
2648  OM_PRINT("p", OutOfMemoryFunc);
2649  OM_PRINT("p", MemoryLowFunc);
2650  OM_PRINT("p", ErrorHook);
2651 #undef OM_PRINT
2652 #endif
2653 
2654 #ifdef OM_ERROR_H
2655  Print("\n\n[om_ErrorStatus] : '%s' (%s)\n",
2658  Print("[om_InternalErrorStatus]: '%s' (%s)\n",
2661 
2662 #endif
2663 
2664 // omTestMemory(1);
2665 // omtTestErrors();
2666  return FALSE;
2667  }
2668  else
2669 #endif
2670  /*==================== pDivStat =============================*/
2671  #if defined(PDEBUG) || defined(PDIV_DEBUG)
2672  if(strcmp(sys_cmd,"pDivStat")==0)
2673  {
2674  extern void pPrintDivisbleByStat();
2676  return FALSE;
2677  }
2678  else
2679  #endif
2680  /*==================== red =============================*/
2681  #if 0
2682  if(strcmp(sys_cmd,"red")==0)
2683  {
2684  if ((h!=NULL) &&(h->Typ()==IDEAL_CMD))
2685  {
2686  res->rtyp=IDEAL_CMD;
2687  res->data=(void *)kStdred((ideal)h->Data(),NULL,testHomog,NULL);
2688  setFlag(res,FLAG_STD);
2689  return FALSE;
2690  }
2691  else
2692  WerrorS("ideal expected");
2693  }
2694  else
2695  #endif
2696  /*==================== fastcomb =============================*/
2697  if(strcmp(sys_cmd,"fastcomb")==0)
2698  {
2699  if ((h!=NULL) &&(h->Typ()==IDEAL_CMD))
2700  {
2701  if (h->next!=NULL)
2702  {
2703  if (h->next->Typ()!=POLY_CMD)
2704  {
2705  WarnS("Wrong types for poly= comb(ideal,poly)");
2706  }
2707  }
2708  res->rtyp=POLY_CMD;
2709  res->data=(void *) fglmLinearCombination(
2710  (ideal)h->Data(),(poly)h->next->Data());
2711  return FALSE;
2712  }
2713  else
2714  WerrorS("ideal expected");
2715  }
2716  else
2717  /*==================== comb =============================*/
2718  if(strcmp(sys_cmd,"comb")==0)
2719  {
2720  if ((h!=NULL) &&(h->Typ()==IDEAL_CMD))
2721  {
2722  if (h->next!=NULL)
2723  {
2724  if (h->next->Typ()!=POLY_CMD)
2725  {
2726  WarnS("Wrong types for poly= comb(ideal,poly)");
2727  }
2728  }
2729  res->rtyp=POLY_CMD;
2730  res->data=(void *)fglmNewLinearCombination(
2731  (ideal)h->Data(),(poly)h->next->Data());
2732  return FALSE;
2733  }
2734  else
2735  WerrorS("ideal expected");
2736  }
2737  else
2738  #if 0 /* debug only */
2739  /*==================== listall ===================================*/
2740  if(strcmp(sys_cmd,"listall")==0)
2741  {
2742  void listall(int showproc);
2743  int showproc=0;
2744  if ((h!=NULL) && (h->Typ()==INT_CMD)) showproc=(int)((long)h->Data());
2745  listall(showproc);
2746  return FALSE;
2747  }
2748  else
2749  #endif
2750  #if 0 /* debug only */
2751  /*==================== proclist =================================*/
2752  if(strcmp(sys_cmd,"proclist")==0)
2753  {
2754  void piShowProcList();
2755  piShowProcList();
2756  return FALSE;
2757  }
2758  else
2759  #endif
2760  /* ==================== newton ================================*/
2761  #ifdef HAVE_NEWTON
2762  if(strcmp(sys_cmd,"newton")==0)
2763  {
2764  if ((h->Typ()!=POLY_CMD)
2765  || (h->next->Typ()!=INT_CMD)
2766  || (h->next->next->Typ()!=INT_CMD))
2767  {
2768  WerrorS("system(\"newton\",<poly>,<int>,<int>) expected");
2769  return TRUE;
2770  }
2771  poly p=(poly)(h->Data());
2772  int l=pLength(p);
2773  short *points=(short *)omAlloc(currRing->N*l*sizeof(short));
2774  int i,j,k;
2775  k=0;
2776  poly pp=p;
2777  for (i=0;pp!=NULL;i++)
2778  {
2779  for(j=1;j<=currRing->N;j++)
2780  {
2781  points[k]=pGetExp(pp,j);
2782  k++;
2783  }
2784  pIter(pp);
2785  }
2786  hc_ERG r=hc_KOENIG(currRing->N, // dimension
2787  l, // number of points
2788  (short*) points, // points: x_1, y_1,z_1, x_2,y_2,z2,...
2789  currRing->OrdSgn==-1,
2790  (int) (h->next->Data()), // 1: Milnor, 0: Newton
2791  (int) (h->next->next->Data()) // debug
2792  );
2793  //----<>---Output-----------------------
2794 
2795 
2796  // PrintS("Bin jetzt in extra.cc bei der Auswertung.\n"); // **********
2797 
2798 
2800  L->Init(6);
2801  L->m[0].rtyp=STRING_CMD; // newtonnumber;
2802  L->m[0].data=(void *)omStrDup(r.nZahl);
2803  L->m[1].rtyp=INT_CMD;
2804  L->m[1].data=(void *)(long)r.achse; // flag for unoccupied axes
2805  L->m[2].rtyp=INT_CMD;
2806  L->m[2].data=(void *)(long)r.deg; // #degenerations
2807  if ( r.deg != 0) // only if degenerations exist
2808  {
2809  L->m[3].rtyp=INT_CMD;
2810  L->m[3].data=(void *)(long)r.anz_punkte; // #points
2811  //---<>--number of points------
2812  int anz = r.anz_punkte; // number of points
2813  int dim = (currRing->N); // dimension
2814  intvec* v = new intvec( anz*dim );
2815  for (i=0; i<anz*dim; i++) // copy points
2816  (*v)[i] = r.pu[i];
2817  L->m[4].rtyp=INTVEC_CMD;
2818  L->m[4].data=(void *)v;
2819  //---<>--degenerations---------
2820  int deg = r.deg; // number of points
2821  intvec* w = new intvec( r.speicher ); // necessary memory
2822  i=0; // start copying
2823  do
2824  {
2825  (*w)[i] = r.deg_tab[i];
2826  i++;
2827  }
2828  while (r.deg_tab[i-1] != -2); // mark for end of list
2829  L->m[5].rtyp=INTVEC_CMD;
2830  L->m[5].data=(void *)w;
2831  }
2832  else
2833  {
2834  L->m[3].rtyp=INT_CMD; L->m[3].data=(char *)0;
2835  L->m[4].rtyp=DEF_CMD;
2836  L->m[5].rtyp=DEF_CMD;
2837  }
2838 
2839  res->data=(void *)L;
2840  res->rtyp=LIST_CMD;
2841  // free all pointer in r:
2842  delete[] r.nZahl;
2843  delete[] r.pu;
2844  delete[] r.deg_tab; // Ist das ein Problem??
2845 
2846  omFreeSize((ADDRESS)points,currRing->N*l*sizeof(short));
2847  return FALSE;
2848  }
2849  else
2850  #endif
2851  /*==== connection to Sebastian Jambor's code ======*/
2852  /* This code connects Sebastian Jambor's code for
2853  computing the minimal polynomial of an (n x n) matrix
2854  with entries in F_p to SINGULAR. Two conversion methods
2855  are needed; see further up in this file:
2856  (1) conversion of a matrix with long entries to
2857  a SINGULAR matrix with number entries, where
2858  the numbers are coefficients in currRing;
2859  (2) conversion of an array of longs (encoding the
2860  coefficients of the minimal polynomial) to a
2861  SINGULAR poly living in currRing. */
2862  if (strcmp(sys_cmd, "minpoly") == 0)
2863  {
2864  if ((h == NULL) || (h->Typ() != MATRIX_CMD) || h->next != NULL)
2865  {
2866  Werror("expected exactly one argument: %s",
2867  "a square matrix with number entries");
2868  return TRUE;
2869  }
2870  else
2871  {
2872  matrix m = (matrix)h->Data();
2873  int n = m->rows();
2874  unsigned long p = (unsigned long)n_GetChar(currRing->cf);
2875  if (n != m->cols())
2876  {
2877  WerrorS("expected exactly one argument: "
2878  "a square matrix with number entries");
2879  return TRUE;
2880  }
2881  unsigned long** ml = singularMatrixToLongMatrix(m);
2882  unsigned long* polyCoeffs = computeMinimalPolynomial(ml, n, p);
2883  poly theMinPoly = longCoeffsToSingularPoly(polyCoeffs, n);
2884  res->rtyp = POLY_CMD;
2885  res->data = (void *)theMinPoly;
2886  for (int i = 0; i < n; i++) delete[] ml[i];
2887  delete[] ml;
2888  delete[] polyCoeffs;
2889  return FALSE;
2890  }
2891  }
2892  else
2893  /*==================== sdb_flags =================*/
2894  #ifdef HAVE_SDB
2895  if (strcmp(sys_cmd, "sdb_flags") == 0)
2896  {
2897  if ((h!=NULL) && (h->Typ()==INT_CMD))
2898  {
2899  sdb_flags=(int)((long)h->Data());
2900  }
2901  else
2902  {
2903  WerrorS("system(\"sdb_flags\",`int`) expected");
2904  return TRUE;
2905  }
2906  return FALSE;
2907  }
2908  else
2909  #endif
2910  /*==================== sdb_edit =================*/
2911  #ifdef HAVE_SDB
2912  if (strcmp(sys_cmd, "sdb_edit") == 0)
2913  {
2915  {
2916  WerrorS("shell execution is disallowed in restricted mode");
2917  return TRUE;
2918  }
2919  if ((h!=NULL) && (h->Typ()==PROC_CMD))
2920  {
2921  procinfov p=(procinfov)h->Data();
2922  sdb_edit(p);
2923  }
2924  else
2925  {
2926  WerrorS("system(\"sdb_edit\",`proc`) expected");
2927  return TRUE;
2928  }
2929  return FALSE;
2930  }
2931  else
2932  #endif
2933  /*==================== GF =================*/
2934  #if 0 // for testing only
2935  if (strcmp(sys_cmd, "GF") == 0)
2936  {
2937  if ((h!=NULL) && (h->Typ()==POLY_CMD))
2938  {
2939  int c=rChar(currRing);
2940  setCharacteristic( c,nfMinPoly[0], currRing->parameter[0][0] );
2941  CanonicalForm F( convSingGFFactoryGF( (poly)h->Data(), currRing ) );
2942  res->rtyp=POLY_CMD;
2943  res->data=convFactoryGFSingGF( F, currRing );
2944  return FALSE;
2945  }
2946  else { WerrorS("wrong typ"); return TRUE;}
2947  }
2948  else
2949  #endif
2950  /*==================== SVD =================*/
2951  #ifdef HAVE_SVD
2952  if (strcmp(sys_cmd, "svd") == 0)
2953  {
2954  extern lists testsvd(matrix M);
2955  res->rtyp=LIST_CMD;
2956  res->data=(char*)(testsvd((matrix)h->Data()));
2957  return FALSE;
2958  }
2959  else
2960  #endif
2961  /*==================== redNF_ring =================*/
2962  #ifdef HAVE_RINGS
2963  if (strcmp(sys_cmd, "redNF_ring")==0)
2964  {
2965  ring r = currRing;
2966  poly f = (poly) h->Data();
2967  h = h->next;
2968  ideal G = (ideal) h->Data();
2969  res->rtyp=POLY_CMD;
2970  res->data=(poly) ringRedNF(f, G, r);
2971  return(FALSE);
2972  }
2973  else
2974  #endif
2975  /*==================== Roune Hilb =================*/
2976  if (strcmp(sys_cmd, "hilbroune") == 0)
2977  {
2978  if ((h!=NULL) && (h->Typ()==IDEAL_CMD))
2979  {
2980  slicehilb((ideal)h->Data());
2981  }
2982  else return TRUE;
2983  return FALSE;
2984  }
2985  else
2986  /*==================== F5 Implementation =================*/
2987  #ifdef HAVE_F5
2988  if (strcmp(sys_cmd, "f5")==0)
2989  {
2990  if (h->Typ()!=IDEAL_CMD)
2991  {
2992  WerrorS("ideal expected");
2993  return TRUE;
2994  }
2995 
2996  ring r = currRing;
2997  ideal G = (ideal) h->Data();
2998  h = h->next;
2999  int opt;
3000  if(h != NULL) {
3001  opt = (int) (long) h->Data();
3002  }
3003  else {
3004  opt = 2;
3005  }
3006  h = h->next;
3007  int plus;
3008  if(h != NULL) {
3009  plus = (int) (long) h->Data();
3010  }
3011  else {
3012  plus = 0;
3013  }
3014  h = h->next;
3015  int termination;
3016  if(h != NULL) {
3017  termination = (int) (long) h->Data();
3018  }
3019  else {
3020  termination = 0;
3021  }
3022  res->rtyp=IDEAL_CMD;
3023  res->data=(ideal) F5main(G,r,opt,plus,termination);
3024  return FALSE;
3025  }
3026  else
3027  #endif
3028  /*==================== Testing groebner basis =================*/
3029  #ifdef HAVE_RINGS
3030  if (strcmp(sys_cmd, "NF_ring")==0)
3031  {
3032  ring r = currRing;
3033  poly f = (poly) h->Data();
3034  h = h->next;
3035  ideal G = (ideal) h->Data();
3036  res->rtyp=POLY_CMD;
3037  res->data=(poly) ringNF(f, G, r);
3038  return(FALSE);
3039  }
3040  else
3041  if (strcmp(sys_cmd, "spoly")==0)
3042  {
3043  poly f = pCopy((poly) h->Data());
3044  h = h->next;
3045  poly g = pCopy((poly) h->Data());
3046 
3047  res->rtyp=POLY_CMD;
3048  res->data=(poly) plain_spoly(f,g);
3049  return(FALSE);
3050  }
3051  else
3052  if (strcmp(sys_cmd, "testGB")==0)
3053  {
3054  ideal I = (ideal) h->Data();
3055  h = h->next;
3056  ideal GI = (ideal) h->Data();
3057  res->rtyp = INT_CMD;
3058  res->data = (void *)(long) testGB(I, GI);
3059  return(FALSE);
3060  }
3061  else
3062  #endif
3063  /*==================== sca:AltVar ==================================*/
3064  #ifdef HAVE_PLURAL
3065  if ( (strcmp(sys_cmd, "AltVarStart") == 0) || (strcmp(sys_cmd, "AltVarEnd") == 0) )
3066  {
3067  ring r = currRing;
3068 
3069  if((h!=NULL) && (h->Typ()==RING_CMD)) r = (ring)h->Data(); else
3070  {
3071  WerrorS("`system(\"AltVarStart/End\"[,<ring>])` expected");
3072  return TRUE;
3073  }
3074 
3075  res->rtyp=INT_CMD;
3076 
3077  if (rIsSCA(r))
3078  {
3079  if(strcmp(sys_cmd, "AltVarStart") == 0)
3080  res->data = (void*)(long)scaFirstAltVar(r);
3081  else
3082  res->data = (void*)(long)scaLastAltVar(r);
3083  return FALSE;
3084  }
3085 
3086  WerrorS("`system(\"AltVarStart/End\",<ring>) requires a SCA ring");
3087  return TRUE;
3088  }
3089  else
3090  #endif
3091  /*==================== RatNF, noncomm rational coeffs =================*/
3092  #ifdef HAVE_RATGRING
3093  if (strcmp(sys_cmd, "intratNF") == 0)
3094  {
3095  poly p;
3096  poly *q;
3097  ideal I;
3098  int is, k, id;
3099  if ((h!=NULL) && (h->Typ()==POLY_CMD))
3100  {
3101  p=(poly)h->CopyD();
3102  h=h->next;
3103  // PrintS("poly is done\n");
3104  }
3105  else return TRUE;
3106  if ((h!=NULL) && (h->Typ()==IDEAL_CMD))
3107  {
3108  I=(ideal)h->CopyD();
3109  q = I->m;
3110  h=h->next;
3111  // PrintS("ideal is done\n");
3112  }
3113  else return TRUE;
3114  if ((h!=NULL) && (h->Typ()==INT_CMD))
3115  {
3116  is=(int)((long)(h->Data()));
3117  // res->rtyp=INT_CMD;
3118  // PrintS("int is done\n");
3119  // res->rtyp=IDEAL_CMD;
3120  if (rIsPluralRing(currRing))
3121  {
3122  id = IDELEMS(I);
3123  int *pl=(int*)omAlloc0(IDELEMS(I)*sizeof(int));
3124  for(k=0; k < id; k++)
3125  {
3126  pl[k] = pLength(I->m[k]);
3127  }
3128  PrintS("starting redRat\n");
3129  //res->data = (char *)
3130  redRat(&p, q, pl, (int)IDELEMS(I),is,currRing);
3131  res->data=p;
3132  res->rtyp=POLY_CMD;
3133  // res->data = ncGCD(p,q,currRing);
3134  }
3135  else
3136  {
3137  res->rtyp=POLY_CMD;
3138  res->data=p;
3139  }
3140  }
3141  else return TRUE;
3142  return FALSE;
3143  }
3144  else
3145  /*==================== RatNF, noncomm rational coeffs =================*/
3146  if (strcmp(sys_cmd, "ratNF") == 0)
3147  {
3148  poly p,q;
3149  int is, htype;
3150  if ((h!=NULL) && ( (h->Typ()==POLY_CMD) || (h->Typ()==VECTOR_CMD) ) )
3151  {
3152  p=(poly)h->CopyD();
3153  h=h->next;
3154  htype = h->Typ();
3155  }
3156  else return TRUE;
3157  if ((h!=NULL) && ( (h->Typ()==POLY_CMD) || (h->Typ()==VECTOR_CMD) ) )
3158  {
3159  q=(poly)h->CopyD();
3160  h=h->next;
3161  }
3162  else return TRUE;
3163  if ((h!=NULL) && (h->Typ()==INT_CMD))
3164  {
3165  is=(int)((long)(h->Data()));
3166  res->rtyp=htype;
3167  // res->rtyp=IDEAL_CMD;
3168  if (rIsPluralRing(currRing))
3169  {
3170  res->data = nc_rat_ReduceSpolyNew(q,p,is, currRing);
3171  // res->data = ncGCD(p,q,currRing);
3172  }
3173  else res->data=p;
3174  }
3175  else return TRUE;
3176  return FALSE;
3177  }
3178  else
3179  /*==================== RatSpoly, noncomm rational coeffs =================*/
3180  if (strcmp(sys_cmd, "ratSpoly") == 0)
3181  {
3182  poly p,q;
3183  int is;
3184  if ((h!=NULL) && (h->Typ()==POLY_CMD))
3185  {
3186  p=(poly)h->CopyD();
3187  h=h->next;
3188  }
3189  else return TRUE;
3190  if ((h!=NULL) && (h->Typ()==POLY_CMD))
3191  {
3192  q=(poly)h->CopyD();
3193  h=h->next;
3194  }
3195  else return TRUE;
3196  if ((h!=NULL) && (h->Typ()==INT_CMD))
3197  {
3198  is=(int)((long)(h->Data()));
3199  res->rtyp=POLY_CMD;
3200  // res->rtyp=IDEAL_CMD;
3201  if (rIsPluralRing(currRing))
3202  {
3203  res->data = nc_rat_CreateSpoly(p,q,is,currRing);
3204  // res->data = ncGCD(p,q,currRing);
3205  }
3206  else res->data=p;
3207  }
3208  else return TRUE;
3209  return FALSE;
3210  }
3211  else
3212  #endif // HAVE_RATGRING
3213  /*==================== Rat def =================*/
3214  if (strcmp(sys_cmd, "ratVar") == 0)
3215  {
3216  int start,end;
3217  if ((h!=NULL) && (h->Typ()==POLY_CMD))
3218  {
3219  start=pIsPurePower((poly)h->Data());
3220  h=h->next;
3221  }
3222  else return TRUE;
3223  if ((h!=NULL) && (h->Typ()==POLY_CMD))
3224  {
3225  end=pIsPurePower((poly)h->Data());
3226  h=h->next;
3227  }
3228  else return TRUE;
3229  currRing->real_var_start=start;
3230  currRing->real_var_end=end;
3231  return (start==0)||(end==0)||(start>end);
3232  }
3233  else
3234  /*==================== t-rep-GB ==================================*/
3235  if (strcmp(sys_cmd, "unifastmult")==0)
3236  {
3237  poly f = (poly)h->Data();
3238  h=h->next;
3239  poly g=(poly)h->Data();
3240  res->rtyp=POLY_CMD;
3241  res->data=unifastmult(f,g,currRing);
3242  return(FALSE);
3243  }
3244  else
3245  if (strcmp(sys_cmd, "multifastmult")==0)
3246  {
3247  poly f = (poly)h->Data();
3248  h=h->next;
3249  poly g=(poly)h->Data();
3250  res->rtyp=POLY_CMD;
3251  res->data=multifastmult(f,g,currRing);
3252  return(FALSE);
3253  }
3254  else
3255  if (strcmp(sys_cmd, "mults")==0)
3256  {
3257  res->rtyp=INT_CMD ;
3258  res->data=(void*)(long) Mults();
3259  return(FALSE);
3260  }
3261  else
3262  if (strcmp(sys_cmd, "fastpower")==0)
3263  {
3264  ring r = currRing;
3265  poly f = (poly)h->Data();
3266  h=h->next;
3267  int n=(int)((long)h->Data());
3268  res->rtyp=POLY_CMD ;
3269  res->data=(void*) pFastPower(f,n,r);
3270  return(FALSE);
3271  }
3272  else
3273  if (strcmp(sys_cmd, "normalpower")==0)
3274  {
3275  poly f = (poly)h->Data();
3276  h=h->next;
3277  int n=(int)((long)h->Data());
3278  res->rtyp=POLY_CMD ;
3279  res->data=(void*) pPower(pCopy(f),n);
3280  return(FALSE);
3281  }
3282  else
3283  if (strcmp(sys_cmd, "MCpower")==0)
3284  {
3285  ring r = currRing;
3286  poly f = (poly)h->Data();
3287  h=h->next;
3288  int n=(int)((long)h->Data());
3289  res->rtyp=POLY_CMD ;
3290  res->data=(void*) pFastPowerMC(f,n,r);
3291  return(FALSE);
3292  }
3293  else
3294  if (strcmp(sys_cmd, "bit_subst")==0)
3295  {
3296  ring r = currRing;
3297  poly outer = (poly)h->Data();
3298  h=h->next;
3299  poly inner=(poly)h->Data();
3300  res->rtyp=POLY_CMD ;
3301  res->data=(void*) uni_subst_bits(outer, inner,r);
3302  return(FALSE);
3303  }
3304  else
3305  /*==================== gcd-varianten =================*/
3306  if (strcmp(sys_cmd, "gcd") == 0)
3307  {
3308  if (h==NULL)
3309  {
3310  #if 0
3311  Print("FLINT_P:%d (use Flints gcd for polynomials in char p)\n",isOn(SW_USE_FL_GCD_P));
3312  Print("FLINT_0:%d (use Flints gcd for polynomials in char 0)\n",isOn(SW_USE_FL_GCD_0));
3313  #endif
3314  Print("EZGCD:%d (use EZGCD for gcd of polynomials in char 0)\n",isOn(SW_USE_EZGCD));
3315  Print("EZGCD_P:%d (use EZGCD_P for gcd of polynomials in char p)\n",isOn(SW_USE_EZGCD_P));
3316  Print("CRGCD:%d (use chinese Remainder for gcd of polynomials in char 0)\n",isOn(SW_USE_CHINREM_GCD));
3317  #ifndef __CYGWIN__
3318  Print("homog:%d (use homog. test for factorization of polynomials)\n",singular_homog_flag);
3319  #endif
3320  return FALSE;
3321  }
3322  else
3323  if ((h!=NULL) && (h->Typ()==STRING_CMD)
3324  && (h->next!=NULL) && (h->next->Typ()==INT_CMD))
3325  {
3326  int d=(int)(long)h->next->Data();
3327  char *s=(char *)h->Data();
3328  #if 0
3329  if (strcmp(s,"FLINT_P")==0) { if (d) On(SW_USE_FL_GCD_P); else Off(SW_USE_FL_GCD_P); } else
3330  if (strcmp(s,"FLINT_0")==0) { if (d) On(SW_USE_FL_GCD_0); else Off(SW_USE_FL_GCD_0); } else
3331  #endif
3332  if (strcmp(s,"EZGCD")==0) { if (d) On(SW_USE_EZGCD); else Off(SW_USE_EZGCD); } else
3333  if (strcmp(s,"EZGCD_P")==0) { if (d) On(SW_USE_EZGCD_P); else Off(SW_USE_EZGCD_P); } else
3334  if (strcmp(s,"CRGCD")==0) { if (d) On(SW_USE_CHINREM_GCD); else Off(SW_USE_CHINREM_GCD); } else
3335  #ifndef __CYGWIN__
3336  if (strcmp(s,"homog")==0) { if (d) singular_homog_flag=1; else singular_homog_flag=0; } else
3337  #endif
3338  return TRUE;
3339  return FALSE;
3340  }
3341  else return TRUE;
3342  }
3343  else
3344  /*==================== subring =================*/
3345  if (strcmp(sys_cmd, "subring") == 0)
3346  {
3347  if (h!=NULL)
3348  {
3349  extern ring rSubring(ring r,leftv v); /* ipshell.cc*/
3350  res->data=(char *)rSubring(currRing,h);
3351  res->rtyp=RING_CMD;
3352  return res->data==NULL;
3353  }
3354  else return TRUE;
3355  }
3356  else
3357  /*==================== HNF =================*/
3358  #ifdef HAVE_NTL
3359  if (strcmp(sys_cmd, "HNF") == 0)
3360  {
3361  if (h!=NULL)
3362  {
3363  res->rtyp=h->Typ();
3364  if (h->Typ()==MATRIX_CMD)
3365  {
3366  res->data=(char *)singntl_HNF((matrix)h->Data(), currRing);
3367  return FALSE;
3368  }
3369  else if (h->Typ()==INTMAT_CMD)
3370  {
3371  res->data=(char *)singntl_HNF((intvec*)h->Data());
3372  return FALSE;
3373  }
3374  else if (h->Typ()==INTMAT_CMD)
3375  {
3376  res->data=(char *)singntl_HNF((intvec*)h->Data());
3377  return FALSE;
3378  }
3379  else
3380  {
3381  WerrorS("expected `system(\"HNF\",<matrix|intmat|bigintmat>)`");
3382  return TRUE;
3383  }
3384  }
3385  else return TRUE;
3386  }
3387  else
3388  /*================= probIrredTest ======================*/
3389  if (strcmp (sys_cmd, "probIrredTest") == 0)
3390  {
3391  if (h!=NULL && (h->Typ()== POLY_CMD) && ((h->next != NULL) && h->next->Typ() == STRING_CMD))
3392  {
3393  CanonicalForm F= convSingPFactoryP((poly)(h->Data()), currRing);
3394  char *s=(char *)h->next->Data();
3395  double error= atof (s);
3396  int irred= probIrredTest (F, error);
3397  res->rtyp= INT_CMD;
3398  res->data= (void*)(long)irred;
3399  return FALSE;
3400  }
3401  else return TRUE;
3402  }
3403  else
3404  #endif
3405  /*==================== mpz_t loader ======================*/
3406  if(strcmp(sys_cmd, "GNUmpLoad")==0)
3407  {
3408  if ((h != NULL) && (h->Typ() == STRING_CMD))
3409  {
3410  char* filename = (char*)h->Data();
3411  FILE* f = fopen(filename, "r");
3412  if (f == NULL)
3413  {
3414  WerrorS( "invalid file name (in paths use '/')");
3415  return FALSE;
3416  }
3417  mpz_t m; mpz_init(m);
3418  mpz_inp_str(m, f, 10);
3419  fclose(f);
3420  number n = n_InitMPZ(m, coeffs_BIGINT);
3421  res->rtyp = BIGINT_CMD;
3422  res->data = (void*)n;
3423  return FALSE;
3424  }
3425  else
3426  {
3427  WerrorS( "expected valid file name as a string");
3428  return TRUE;
3429  }
3430  }
3431  else
3432  /*==================== intvec matching ======================*/
3433  /* Given two non-empty intvecs, the call
3434  'system("intvecMatchingSegments", ivec, jvec);'
3435  computes all occurences of jvec in ivec, i.e., it returns
3436  a list of int indices k such that ivec[k..size(jvec)+k-1] = jvec.
3437  If no such k exists (e.g. when ivec is shorter than jvec), an
3438  intvec with the single entry 0 is being returned. */
3439  if(strcmp(sys_cmd, "intvecMatchingSegments")==0)
3440  {
3441  if ((h != NULL) && (h->Typ() == INTVEC_CMD) &&
3442  (h->next != NULL) && (h->next->Typ() == INTVEC_CMD) &&
3443  (h->next->next == NULL))
3444  {
3445  intvec* ivec = (intvec*)h->Data();
3446  intvec* jvec = (intvec*)h->next->Data();
3447  intvec* r = new intvec(1); (*r)[0] = 0;
3448  int validEntries = 0;
3449  for (int k = 0; k <= ivec->rows() - jvec->rows(); k++)
3450  {
3451  if (memcmp(&(*ivec)[k], &(*jvec)[0],
3452  sizeof(int) * jvec->rows()) == 0)
3453  {
3454  if (validEntries == 0)
3455  (*r)[0] = k + 1;
3456  else
3457  {
3458  r->resize(validEntries + 1);
3459  (*r)[validEntries] = k + 1;
3460  }
3461  validEntries++;
3462  }
3463  }
3464  res->rtyp = INTVEC_CMD;
3465  res->data = (void*)r;
3466  return FALSE;
3467  }
3468  else
3469  {
3470  WerrorS("expected two non-empty intvecs as arguments");
3471  return TRUE;
3472  }
3473  }
3474  else
3475  /* ================== intvecOverlap ======================= */
3476  /* Given two non-empty intvecs, the call
3477  'system("intvecOverlap", ivec, jvec);'
3478  computes the longest intvec kvec such that ivec ends with kvec
3479  and jvec starts with kvec. The length of this overlap is being
3480  returned. If there is no overlap at all, then 0 is being returned. */
3481  if(strcmp(sys_cmd, "intvecOverlap")==0)
3482  {
3483  if ((h != NULL) && (h->Typ() == INTVEC_CMD) &&
3484  (h->next != NULL) && (h->next->Typ() == INTVEC_CMD) &&
3485  (h->next->next == NULL))
3486  {
3487  intvec* ivec = (intvec*)h->Data();
3488  intvec* jvec = (intvec*)h->next->Data();
3489  int ir = ivec->rows(); int jr = jvec->rows();
3490  int r = jr; if (ir < jr) r = ir; /* r = min{ir, jr} */
3491  while ((r >= 1) && (memcmp(&(*ivec)[ir - r], &(*jvec)[0],
3492  sizeof(int) * r) != 0))
3493  r--;
3494  res->rtyp = INT_CMD;
3495  res->data = (void*)(long)r;
3496  return FALSE;
3497  }
3498  else
3499  {
3500  WerrorS("expected two non-empty intvecs as arguments");
3501  return TRUE;
3502  }
3503  }
3504  else
3505  /*==================== Hensel's lemma ======================*/
3506  if(strcmp(sys_cmd, "henselfactors")==0)
3507  {
3508  if ((h != NULL) && (h->Typ() == INT_CMD) &&
3509  (h->next != NULL) && (h->next->Typ() == INT_CMD) &&
3510  (h->next->next != NULL) && (h->next->next->Typ() == POLY_CMD) &&
3511  (h->next->next->next != NULL) &&
3512  (h->next->next->next->Typ() == POLY_CMD) &&
3513  (h->next->next->next->next != NULL) &&
3514  (h->next->next->next->next->Typ() == POLY_CMD) &&
3515  (h->next->next->next->next->next != NULL) &&
3516  (h->next->next->next->next->next->Typ() == INT_CMD) &&
3517  (h->next->next->next->next->next->next == NULL))
3518  {
3519  int xIndex = (int)(long)h->Data();
3520  int yIndex = (int)(long)h->next->Data();
3521  poly hh = (poly)h->next->next->Data();
3522  poly f0 = (poly)h->next->next->next->Data();
3523  poly g0 = (poly)h->next->next->next->next->Data();
3524  int d = (int)(long)h->next->next->next->next->next->Data();
3525  poly f; poly g;
3526  henselFactors(xIndex, yIndex, hh, f0, g0, d, f, g);
3528  L->Init(2);
3529  L->m[0].rtyp = POLY_CMD; L->m[0].data=(void*)f;
3530  L->m[1].rtyp = POLY_CMD; L->m[1].data=(void*)g;
3531  res->rtyp = LIST_CMD;
3532  res->data = (char *)L;
3533  return FALSE;
3534  }
3535  else
3536  {
3537  WerrorS( "expected argument list (int, int, poly, poly, poly, int)");
3538  return TRUE;
3539  }
3540  }
3541  else
3542  /*==================== Approx_Step =================*/
3543  #ifdef HAVE_PLURAL
3544  if (strcmp(sys_cmd, "astep") == 0)
3545  {
3546  ideal I;
3547  if ((h!=NULL) && (h->Typ()==IDEAL_CMD))
3548  {
3549  I=(ideal)h->CopyD();
3550  res->rtyp=IDEAL_CMD;
3551  if (rIsPluralRing(currRing)) res->data=Approx_Step(I);
3552  else res->data=I;
3553  setFlag(res,FLAG_STD);
3554  }
3555  else return TRUE;
3556  return FALSE;
3557  }
3558  else
3559  #endif
3560  /*==================== PrintMat =================*/
3561  #ifdef HAVE_PLURAL
3562  if (strcmp(sys_cmd, "PrintMat") == 0)
3563  {
3564  int a;
3565  int b;
3566  ring r;
3567  int metric;
3568  if (h!=NULL)
3569  {
3570  if (h->Typ()==INT_CMD)
3571  {
3572  a=(int)((long)(h->Data()));
3573  h=h->next;
3574  }
3575  else if (h->Typ()==INT_CMD)
3576  {
3577  b=(int)((long)(h->Data()));
3578  h=h->next;
3579  }
3580  else if (h->Typ()==RING_CMD)
3581  {
3582  r=(ring)h->Data();
3583  h=h->next;
3584  }
3585  else
3586  return TRUE;
3587  }
3588  else
3589  return TRUE;
3590  if ((h!=NULL) && (h->Typ()==INT_CMD))
3591  {
3592  metric=(int)((long)(h->Data()));
3593  }
3594  res->rtyp=MATRIX_CMD;
3595  if (rIsPluralRing(r)) res->data=nc_PrintMat(a,b,r,metric);
3596  else res->data=NULL;
3597  return FALSE;
3598  }
3599  else
3600  #endif
3601 /* ============ NCUseExtensions ======================== */
3602  #ifdef HAVE_PLURAL
3603  if(strcmp(sys_cmd,"NCUseExtensions")==0)
3604  {
3605  if ((h!=NULL) && (h->Typ()==INT_CMD))
3606  res->data=(void *)(long)setNCExtensions( (int)((long)(h->Data())) );
3607  else
3608  res->data=(void *)(long)getNCExtensions();
3609  res->rtyp=INT_CMD;
3610  return FALSE;
3611  }
3612  else
3613  #endif
3614 /* ============ NCGetType ======================== */
3615  #ifdef HAVE_PLURAL
3616  if(strcmp(sys_cmd,"NCGetType")==0)
3617  {
3618  res->rtyp=INT_CMD;
3619  if( rIsPluralRing(currRing) )
3620  res->data=(void *)(long)ncRingType(currRing);
3621  else
3622  res->data=(void *)(-1L);
3623  return FALSE;
3624  }
3625  else
3626  #endif
3627 /* ============ ForceSCA ======================== */
3628  #ifdef HAVE_PLURAL
3629  if(strcmp(sys_cmd,"ForceSCA")==0)
3630  {
3631  if( !rIsPluralRing(currRing) )
3632  return TRUE;
3633  int b, e;
3634  if ((h!=NULL) && (h->Typ()==INT_CMD))
3635  {
3636  b = (int)((long)(h->Data()));
3637  h=h->next;
3638  }
3639  else return TRUE;
3640  if ((h!=NULL) && (h->Typ()==INT_CMD))
3641  {
3642  e = (int)((long)(h->Data()));
3643  }
3644  else return TRUE;
3645  if( !sca_Force(currRing, b, e) )
3646  return TRUE;
3647  return FALSE;
3648  }
3649  else
3650  #endif
3651 /* ============ ForceNewNCMultiplication ======================== */
3652  #ifdef HAVE_PLURAL
3653  if(strcmp(sys_cmd,"ForceNewNCMultiplication")==0)
3654  {
3655  if( !rIsPluralRing(currRing) )
3656  return TRUE;
3657  if( !ncInitSpecialPairMultiplication(currRing) ) // No Plural!
3658  return TRUE;
3659  return FALSE;
3660  }
3661  else
3662  #endif
3663 /* ============ ForceNewOldNCMultiplication ======================== */
3664  #ifdef HAVE_PLURAL
3665  if(strcmp(sys_cmd,"ForceNewOldNCMultiplication")==0)
3666  {
3667  if( !rIsPluralRing(currRing) )
3668  return TRUE;
3669  if( !ncInitSpecialPowersMultiplication(currRing) ) // Enable Formula for Plural (depends on swiches)!
3670  return TRUE;
3671  return FALSE;
3672  }
3673  else
3674  #endif
3675 /*==================== test64 =================*/
3676  #if 0
3677  if(strcmp(sys_cmd,"test64")==0)
3678  {
3679  long l=8;int i;
3680  for(i=1;i<62;i++)
3681  {
3682  l=l<<1;
3683  number n=n_Init(l,coeffs_BIGINT);
3684  Print("%ld= ",l);n_Print(n,coeffs_BIGINT);
3686  n_Delete(&n,coeffs_BIGINT);
3688  PrintS(" F:");
3690  PrintLn();
3691  n_Delete(&n,coeffs_BIGINT);
3692  }
3693  Print("SIZEOF_LONG=%d\n",SIZEOF_LONG);
3694  return FALSE;
3695  }
3696  else
3697  #endif
3698 /*==================== n_SwitchChinRem =================*/
3699  if(strcmp(sys_cmd,"cache_chinrem")==0)
3700  {
3702  Print("caching inverse in chines remainder:%d\n",n_SwitchChinRem);
3703  if ((h!=NULL)&&(h->Typ()==INT_CMD))
3704  n_SwitchChinRem=(int)(long)h->Data();
3705  return FALSE;
3706  }
3707  else
3708 /*==================== LU for bigintmat =================*/
3709 #ifdef SINGULAR_4_2
3710  if(strcmp(sys_cmd,"LU")==0)
3711  {
3712  if ((h!=NULL) && (h->Typ()==CMATRIX_CMD))
3713  {
3714  // get the argument:
3715  bigintmat *b=(bigintmat *)h->Data();
3716  // just for tests: simply transpose
3717  bigintmat *bb=b->transpose();
3718  // return the result:
3719  res->rtyp=CMATRIX_CMD;
3720  res->data=(char*)bb;
3721  return FALSE;
3722  }
3723  else
3724  {
3725  WerrorS("system(\"LU\",<cmatrix>) expected");
3726  return TRUE;
3727  }
3728  }
3729  else
3730 #endif
3731 /*==================== sort =================*/
3732  if(strcmp(sys_cmd,"sort")==0)
3733  {
3734  extern BOOLEAN jjSORTLIST(leftv,leftv);
3735  if (h->Typ()==LIST_CMD)
3736  return jjSORTLIST(res,h);
3737  else
3738  return TRUE;
3739  }
3740  else
3741 /*==================== uniq =================*/
3742  if(strcmp(sys_cmd,"uniq")==0)
3743  {
3744  extern BOOLEAN jjUNIQLIST(leftv, leftv);
3745  if (h->Typ()==LIST_CMD)
3746  return jjUNIQLIST(res,h);
3747  else
3748  return TRUE;
3749  }
3750  else
3751 /*==================== GF(p,n) ==================================*/
3752  if(strcmp(sys_cmd,"GF")==0)
3753  {
3754  const short t[]={3,INT_CMD,INT_CMD,STRING_CMD};
3755  if (iiCheckTypes(h,t,1))
3756  {
3757  int p=(int)(long)h->Data();
3758  int n=(int)(long)h->next->Data();
3759  char *v=(char*)h->next->next->CopyD();
3760  GFInfo param;
3761  param.GFChar = p;
3762  param.GFDegree = n;
3763  param.GFPar_name = v;
3764  coeffs cf= nInitChar(n_GF, &param);
3765  res->rtyp=CRING_CMD;
3766  res->data=cf;
3767  return FALSE;
3768  }
3769  else
3770  return TRUE;
3771  }
3772  else
3773 /*==================== power* ==================================*/
3774  #if 0
3775  if(strcmp(sys_cmd,"power1")==0)
3776  {
3777  res->rtyp=POLY_CMD;
3778  poly f=(poly)h->CopyD();
3779  poly g=pPower(f,2000);
3780  res->data=(void *)g;
3781  return FALSE;
3782  }
3783  else
3784  if(strcmp(sys_cmd,"power2")==0)
3785  {
3786  res->rtyp=POLY_CMD;
3787  poly f=(poly)h->Data();
3788  poly g=pOne();
3789  for(int i=0;i<2000;i++)
3790  g=pMult(g,pCopy(f));
3791  res->data=(void *)g;
3792  return FALSE;
3793  }
3794  if(strcmp(sys_cmd,"power3")==0)
3795  {
3796  res->rtyp=POLY_CMD;
3797  poly f=(poly)h->Data();
3798  poly p2=pMult(pCopy(f),pCopy(f));
3799  poly p4=pMult(pCopy(p2),pCopy(p2));
3800  poly p8=pMult(pCopy(p4),pCopy(p4));
3801  poly p16=pMult(pCopy(p8),pCopy(p8));
3802  poly p32=pMult(pCopy(p16),pCopy(p16));
3803  poly p64=pMult(pCopy(p32),pCopy(p32));
3804  poly p128=pMult(pCopy(p64),pCopy(p64));
3805  poly p256=pMult(pCopy(p128),pCopy(p128));
3806  poly p512=pMult(pCopy(p256),pCopy(p256));
3807  poly p1024=pMult(pCopy(p512),pCopy(p512));
3808  poly p1536=pMult(p1024,p512);
3809  poly p1792=pMult(p1536,p256);
3810  poly p1920=pMult(p1792,p128);
3811  poly p1984=pMult(p1920,p64);
3812  poly p2000=pMult(p1984,p16);
3813  res->data=(void *)p2000;
3814  pDelete(&p2);
3815  pDelete(&p4);
3816  pDelete(&p8);
3817  //pDelete(&p16);
3818  pDelete(&p32);
3819  //pDelete(&p64);
3820  //pDelete(&p128);
3821  //pDelete(&p256);
3822  //pDelete(&p512);
3823  //pDelete(&p1024);
3824  //pDelete(&p1536);
3825  //pDelete(&p1792);
3826  //pDelete(&p1920);
3827  //pDelete(&p1984);
3828  return FALSE;
3829  }
3830  else
3831  #endif
3832 /* ccluster --------------------------------------------------------------*/
3833 #ifdef HAVE_CCLUSTER
3834  if(strcmp(sys_cmd,"ccluster")==0)
3835  {
3836  if ((currRing!=NULL)
3838  {
3839  const short t[]={5,POLY_CMD,NUMBER_CMD,NUMBER_CMD,NUMBER_CMD,NUMBER_CMD};
3841 
3842 // printf("test t : %d\n", h->Typ()==POLY_CMD);
3843 // printf("test t : %d\n", h->next->Typ()==POLY_CMD);
3844  int pol_with_complex_coeffs=0;
3845  if (h->next->Typ()==POLY_CMD)
3846  pol_with_complex_coeffs=1;
3847 
3848  if ( (pol_with_complex_coeffs==0 && iiCheckTypes(h,t,1))
3849  ||(pol_with_complex_coeffs==1 && iiCheckTypes(h,t2,1)) )
3850  {
3851  // convert first arg. to fmpq_poly_t
3852  fmpq_poly_t fre, fim;
3853  convSingPFlintP(fre,(poly)h->Data(),currRing); h=h->next;
3854  if (pol_with_complex_coeffs==1)
3855  { // convert second arg. to fmpq_poly_t
3856  convSingPFlintP(fim,(poly)h->Data(),currRing); h=h->next;
3857  }
3858  // convert box-center(re,im), box-size, epsilon
3859  fmpq_t center_re,center_im,boxsize,eps;
3860  convSingNFlintN(center_re,(number)h->Data(),currRing->cf); h=h->next;
3861  convSingNFlintN(center_im,(number)h->Data(),currRing->cf); h=h->next;
3862  convSingNFlintN(boxsize,(number)h->Data(),currRing->cf); h=h->next;
3863  convSingNFlintN(eps,(number)h->Data(),currRing->cf); h=h->next;
3864  // alloc arrays
3865  int n=fmpq_poly_length(fre);
3866  fmpq_t* re_part=(fmpq_t*)omAlloc(n*sizeof(fmpq_t));
3867  fmpq_t* im_part=(fmpq_t*)omAlloc(n*sizeof(fmpq_t));
3868  int *mult =(int*) omAlloc(n*sizeof(int));
3869  for(int i=0; i<n;i++)
3870  { fmpq_init(re_part[i]); fmpq_init(im_part[i]); }
3871  // call cccluster, adjust n
3872  int verbosity =0; //nothing is printed
3873  int strategy = 23; //default strategy
3874  int nn=0;
3875  long nb_threads = (long) feOptValue(FE_OPT_CPUS);
3876  strategy = strategy+(nb_threads<<6);
3877 // printf("nb threads: %ld\n", nb_threads);
3878 // printf("strategy: %ld\n", strategy);
3879  if (pol_with_complex_coeffs==0)
3880  nn=ccluster_interface_poly_real(re_part,im_part,mult,fre,center_re,center_im,boxsize,eps,strategy,verbosity);
3881  else
3882  nn=ccluster_interface_poly_real_imag(re_part,im_part,mult,fre,fim,center_re,center_im,boxsize,eps,strategy,verbosity);
3883  // convert to list
3885  l->Init(nn);
3886  for(int i=0; i<nn;i++)
3887  {
3889  l->m[i].rtyp=LIST_CMD;
3890  l->m[i].data=ll;
3891  ll->Init(3);
3892  ll->m[0].rtyp=NUMBER_CMD;
3893  ll->m[1].rtyp=NUMBER_CMD;
3894  ll->m[2].rtyp=INT_CMD;
3895  ll->m[0].data=convFlintNSingN(re_part[i],currRing->cf);
3896  ll->m[1].data=convFlintNSingN(im_part[i],currRing->cf);
3897  ll->m[2].data=(void *)(long)mult[i];
3898  }
3899  //clear re, im, mults, fre, fim
3900  for(int i=n-1;i>=0;i--) { fmpq_clear(re_part[i]); fmpq_clear(im_part[i]); }
3901  omFree(re_part);
3902  omFree(im_part);
3903  omFree(mult);
3904  fmpq_clear(center_re); fmpq_clear(center_im); fmpq_clear(boxsize); fmpq_clear(eps);
3905  fmpq_poly_clear(fre);
3906  if (pol_with_complex_coeffs==1) fmpq_poly_clear(fim);
3907  // result
3908  res->rtyp=LIST_CMD;
3909  res->data=l;
3910  return FALSE;
3911  }
3912  }
3913  return TRUE;
3914  }
3915  else
3916 #endif
3917 /* ====== maEvalAt ============================*/
3918  if(strcmp(sys_cmd,"evaluate")==0)
3919  {
3920  extern number maEvalAt(const poly p,const number* pt, const ring r);
3921  if (h->Typ()!=POLY_CMD)
3922  {
3923  WerrorS("expected system(\"evaluate\",<poly>,..)");
3924  return TRUE;
3925  }
3926  poly p=(poly)h->Data();
3927  number *pt=(number*)omAlloc(sizeof(number)*currRing->N);
3928  for(int i=0;i<currRing->N;i++)
3929  {
3930  h=h->next;
3931  if ((h==NULL)||(h->Typ()!=NUMBER_CMD))
3932  {
3933  WerrorS("system(\"evaluate\",<poly>,<number>..) - expect number");
3934  return TRUE;
3935  }
3936  pt[i]=(number)h->Data();
3937  }
3938  res->data=maEvalAt(p,pt,currRing);
3939  res->rtyp=NUMBER_CMD;
3940  return FALSE;
3941  }
3942  else
3943 /* ====== DivRem ============================*/
3944  if(strcmp(sys_cmd,"DivRem")==0)
3945  {
3946  const short t1[]={2,POLY_CMD,POLY_CMD};
3947  if (iiCheckTypes(h,t1,1))
3948  {
3949  poly p=(poly)h->CopyD();
3950  poly q=(poly)h->next->CopyD();
3951  poly rest;
3952  res->data=p_DivRem(p,q,rest,currRing);
3953  res->rtyp=POLY_CMD;
3954  Print("rest:");pWrite(rest);
3955  return FALSE;
3956  }
3957  else
3958  {
3959  WerrorS("expected system(\"DivRem\",<poly>,<poly>)");
3960  return TRUE;
3961  }
3962  }
3963  else
3964 /* ====== CoeffTerm ============================*/
3965  if(strcmp(sys_cmd,"CoeffTerm")==0)
3966  {
3967  const short t1[]={2,POLY_CMD,POLY_CMD};
3968  const short t2[]={2,VECTOR_CMD,VECTOR_CMD};
3969  const short t3[]={2,IDEAL_CMD,POLY_CMD};
3970  const short t4[]={2,MODUL_CMD,VECTOR_CMD};
3971  const short t5[]={2,VECTOR_CMD,POLY_CMD};
3972  const short t6[]={2,MODUL_CMD,POLY_CMD};
3973  if (iiCheckTypes(h,t1,0)
3974  || iiCheckTypes(h,t2,0))
3975  {
3976  poly p=(poly)h->Data();
3977  poly q=(poly)h->next->Data();
3978  res->data=p_CoeffTerm(p,q,currRing);
3979  res->rtyp=NUMBER_CMD;
3980  return FALSE;
3981  }
3982  else if (iiCheckTypes(h,t3,0)
3983  || iiCheckTypes(h,t4,0))
3984  {
3985  ideal p=(ideal)h->Data();
3986  poly q=(poly)h->next->Data();
3987  res->data=id_CoeffTerm(p,q,currRing);
3988  res->rtyp=h->Typ();
3989  return FALSE;
3990  }
3991  else if (iiCheckTypes(h,t5,0))
3992  {
3993  poly p=(poly)h->Data();
3994  poly q=(poly)h->next->Data();
3995  res->data=p_CoeffTermV(p,q,currRing);
3996  res->rtyp=VECTOR_CMD;
3997  return FALSE;
3998  }
3999  else if (iiCheckTypes(h,t6,0))
4000  {
4001  ideal p=(ideal)h->Data();
4002  poly q=(poly)h->next->Data();
4003  res->data=id_CoeffTermV(p,q,currRing);
4004  res->rtyp=MODUL_CMD;
4005  return FALSE;
4006  }
4007  else
4008  {
4009  WerrorS("expected system(\"CoeffTerm\",<poly>/<vector>,<poly>/<vector>)" "\n or <ideal>/<module>,<poly>/<vector>");
4010  return TRUE;
4011  }
4012  }
4013  else
4014 /*==================== Error =================*/
4015  Werror( "(extended) system(\"%s\",...) %s", sys_cmd, feNotImplemented );
4016  }
4017  return TRUE;
4018 }
4019 
4020 #endif // HAVE_EXTENDED_SYSTEM
4021 
4022 
static int si_max(const int a, const int b)
Definition: auxiliary.h:124
int BOOLEAN
Definition: auxiliary.h:87
#define TRUE
Definition: auxiliary.h:100
#define FALSE
Definition: auxiliary.h:96
void * ADDRESS
Definition: auxiliary.h:119
#define BIMATELEM(M, I, J)
Definition: bigintmat.h:133
blackbox * getBlackboxStuff(const int t)
return the structure to the type given by t
Definition: blackbox.cc:17
int blackboxIsCmd(const char *n, int &tok)
used by scanner: returns ROOT_DECL for known types (and the type number in tok)
Definition: blackbox.cc:218
void printBlackboxTypes()
list all defined type (for debugging)
Definition: blackbox.cc:235
#define BB_LIKE_LIST(B)
Definition: blackbox.h:53
lists testsvd(matrix M)
Definition: calcSVD.cc:27
bool isOn(int sw)
switches
void On(int sw)
switches
void Off(int sw)
switches
int degree(const CanonicalForm &f)
CanonicalForm FACTORY_PUBLIC pp(const CanonicalForm &)
CanonicalForm pp ( const CanonicalForm & f )
Definition: cf_gcd.cc:676
void FACTORY_PUBLIC setCharacteristic(int c)
Definition: cf_char.cc:28
int l
Definition: cfEzgcd.cc:100
int m
Definition: cfEzgcd.cc:128
int i
Definition: cfEzgcd.cc:132
int k
Definition: cfEzgcd.cc:99
int p
Definition: cfModGcd.cc:4078
g
Definition: cfModGcd.cc:4090
CanonicalForm cf
Definition: cfModGcd.cc:4083
CanonicalForm b
Definition: cfModGcd.cc:4103
EXTERN_VAR int singular_homog_flag
Definition: cf_algorithm.h:65
static const int SW_USE_CHINREM_GCD
set to 1 to use modular gcd over Z
Definition: cf_defs.h:41
static const int SW_USE_FL_GCD_P
set to 1 to use Flints gcd over F_p
Definition: cf_defs.h:47
static const int SW_USE_EZGCD_P
set to 1 to use EZGCD over F_q
Definition: cf_defs.h:37
static const int SW_USE_EZGCD
set to 1 to use EZGCD over Z
Definition: cf_defs.h:35
static const int SW_USE_FL_GCD_0
set to 1 to use Flints gcd over Q/Z
Definition: cf_defs.h:49
static CanonicalForm bound(const CFMatrix &M)
Definition: cf_linsys.cc:460
void factoryseed(int s)
random seed initializer
Definition: cf_random.cc:189
FILE * f
Definition: checklibs.c:9
CanonicalForm convSingPFactoryP(poly p, const ring r)
Definition: clapconv.cc:136
char * singclap_neworder(ideal I, const ring r)
Definition: clapsing.cc:1664
matrix singntl_HNF(matrix m, const ring s)
Definition: clapsing.cc:1817
matrix singntl_rref(matrix m, const ring R)
Definition: clapsing.cc:1997
matrix singntl_LLL(matrix m, const ring s)
Definition: clapsing.cc:1915
ideal singclap_absFactorize(poly f, ideal &mipos, intvec **exps, int &numFactors, const ring r)
Definition: clapsing.cc:2103
factory's main class
Definition: canonicalform.h:86
Matrices of numbers.
Definition: bigintmat.h:51
gmp_complex numbers based on
Definition: mpr_complex.h:179
Definition: idrec.h:35
Definition: intvec.h:23
void resize(int new_length)
Definition: intvec.cc:106
int rows() const
Definition: intvec.h:96
int & rows()
Definition: matpol.h:23
int & cols()
Definition: matpol.h:24
Class used for (list of) interpreter objects.
Definition: subexpr.h:83
int Typ()
Definition: subexpr.cc:1011
int rtyp
Definition: subexpr.h:91
void * Data()
Definition: subexpr.cc:1154
leftv next
Definition: subexpr.h:86
void * data
Definition: subexpr.h:88
Definition: lists.h:24
sleftv * m
Definition: lists.h:46
INLINE_THIS void Init(int l=0)
Definition: int_poly.h:33
VAR int siRandomStart
Definition: cntrlc.cc:93
Coefficient rings, fields and other domains suitable for Singular polynomials.
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:547
int GFDegree
Definition: coeffs.h:95
@ n_GF
\GF{p^n < 2^16}
Definition: coeffs.h:32
@ n_transExt
used for all transcendental extensions, i.e., the top-most extension in an extension tower is transce...
Definition: coeffs.h:38
static FORCE_INLINE number n_convFactoryNSingN(const CanonicalForm n, const coeffs r)
Definition: coeffs.h:978
void n_Print(number &a, const coeffs r)
print a number (BEWARE of string buffers!) mostly for debugging
Definition: numbers.cc:646
static FORCE_INLINE CanonicalForm n_convSingNFactoryN(number n, BOOLEAN setChar, const coeffs r)
Definition: coeffs.h:981
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
Definition: numbers.cc:392
static FORCE_INLINE BOOLEAN nCoeff_is_Ring(const coeffs r)
Definition: coeffs.h:730
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:421
static FORCE_INLINE int n_GetChar(const coeffs r)
Return the characteristic of the coeff. domain.
Definition: coeffs.h:444
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:455
static FORCE_INLINE number n_InitMPZ(mpz_t n, const coeffs r)
conversion of a GMP integer to number
Definition: coeffs.h:542
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition: coeffs.h:538
const char * GFPar_name
Definition: coeffs.h:96
int GFChar
Definition: coeffs.h:94
Creation data needed for finite fields.
Definition: coeffs.h:93
void countedref_reference_load()
Initialize blackbox types 'reference' and 'shared', or both.
Definition: countedref.cc:700
void countedref_shared_load()
Definition: countedref.cc:724
lists get_denom_list()
Definition: denom_list.cc:8
poly uni_subst_bits(poly outer_uni, poly inner_multi, ring r)
Definition: digitech.cc:47
matrix evRowElim(matrix M, int i, int j, int k)
Definition: eigenval.cc:47
matrix evHessenberg(matrix M)
Definition: eigenval.cc:100
matrix evSwap(matrix M, int i, int j)
Definition: eigenval.cc:25
lists evEigenvals(matrix M)
Definition: eigenval_ip.cc:118
#define Print
Definition: emacs.cc:80
#define Warn
Definition: emacs.cc:77
#define WarnS
Definition: emacs.cc:78
void error(const char *fmt,...)
Definition: emacs.cc:55
BOOLEAN jjSYSTEM(leftv res, leftv args)
Definition: extra.cc:232
poly longCoeffsToSingularPoly(unsigned long *polyCoeffs, const int degree)
Definition: extra.cc:210
EXTERN_VAR BOOLEAN FE_OPT_NO_SHELL_FLAG
Definition: extra.cc:171
#define SINGULAR_PROCS_DIR
unsigned long ** singularMatrixToLongMatrix(matrix singularMatrix)
Definition: extra.cc:178
#define TEST_FOR(A)
static BOOLEAN jjEXTENDED_SYSTEM(leftv res, leftv h)
Definition: extra.cc:2380
ideal F5main(ideal id, ring r, int opt, int plus, int termination)
Definition: f5gb.cc:1889
return result
Definition: facAbsBiFact.cc:75
const CanonicalForm int s
Definition: facAbsFact.cc:51
CanonicalForm res
Definition: facAbsFact.cc:60
const CanonicalForm & w
Definition: facAbsFact.cc:51
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:39
CFList int bool & irred
[in,out] Is A irreducible?
Definition: facFactorize.h:34
int j
Definition: facHensel.cc:110
int probIrredTest(const CanonicalForm &F, double error)
given some error probIrredTest detects irreducibility or reducibility of F with confidence level 1-er...
Definition: facIrredTest.cc:63
poly unifastmult(poly f, poly g, ring r)
Definition: fast_mult.cc:272
poly pFastPowerMC(poly f, int n, ring r)
Definition: fast_mult.cc:588
static int max(int a, int b)
Definition: fast_mult.cc:264
poly pFastPower(poly f, int n, ring r)
Definition: fast_mult.cc:342
int Mults()
Definition: fast_mult.cc:14
poly multifastmult(poly f, poly g, ring r)
Definition: fast_mult.cc:290
void WerrorS(const char *s)
Definition: feFopen.cc:24
feOptIndex
Definition: feOptGen.h:15
@ FE_OPT_UNDEF
Definition: feOptGen.h:15
void fePrintOptValues()
Definition: feOpt.cc:337
const char * feSetOptValue(feOptIndex opt, char *optarg)
Definition: feOpt.cc:154
feOptIndex feGetOptIndex(const char *name)
Definition: feOpt.cc:104
static void * feOptValue(feOptIndex opt)
Definition: feOpt.h:40
EXTERN_VAR struct fe_option feOptSpec[]
Definition: feOpt.h:17
void feReInitResources()
Definition: feResource.cc:185
static char * feResource(feResourceConfig config, int warn)
Definition: feResource.cc:236
VAR int myynest
Definition: febase.cc:41
char * getenv()
@ feOptUntyped
Definition: fegetopt.h:77
@ feOptString
Definition: fegetopt.h:77
void * value
Definition: fegetopt.h:93
void feStringAppendBrowsers(int warn)
Definition: fehelp.cc:341
STATIC_VAR int nfMinPoly[16]
Definition: ffields.cc:549
This file is work in progress and currently not part of the official Singular.
void convSingPFlintP(fmpq_poly_t res, poly p, const ring r)
void convSingNFlintN(fmpz_t f, mpz_t z)
bigintmat * singflint_LLL(bigintmat *A, bigintmat *T)
void convFlintNSingN(mpz_t z, fmpz_t f)
matrix singflint_rref(matrix m, const ring R)
number maEvalAt(const poly p, const number *pt, const ring r)
evaluate the polynomial p at the pt given by the array pt
Definition: gen_maps.cc:167
#define EXTERN_VAR
Definition: globaldefs.h:6
lists gmsNF(ideal p, ideal g, matrix B, int D, int K)
Definition: gms.cc:22
@ IDEAL_CMD
Definition: grammar.cc:284
@ MATRIX_CMD
Definition: grammar.cc:286
@ BIGINTMAT_CMD
Definition: grammar.cc:278
@ PROC_CMD
Definition: grammar.cc:280
@ INTMAT_CMD
Definition: grammar.cc:279
@ MODUL_CMD
Definition: grammar.cc:287
@ SMATRIX_CMD
Definition: grammar.cc:291
@ VECTOR_CMD
Definition: grammar.cc:292
@ NUMBER_CMD
Definition: grammar.cc:288
@ POLY_CMD
Definition: grammar.cc:289
@ RING_CMD
Definition: grammar.cc:281
void HilbertSeries_OrbitData(ideal S, int lV, bool IG_CASE, bool mgrad, bool odp, int trunDegHs)
Definition: hilb.cc:1326
ideal RightColonOperation(ideal S, poly w, int lV)
Definition: hilb.cc:1673
void slicehilb(ideal I)
Definition: hilb.cc:656
ideal id_TensorModuleMult(const int m, const ideal M, const ring rRing)
STATIC_VAR coordinates * points
static BOOLEAN length(leftv result, leftv arg)
Definition: interval.cc:257
#define ivTest(v)
Definition: intvec.h:169
#define IMATELEM(M, I, J)
Definition: intvec.h:85
BOOLEAN jjSORTLIST(leftv, leftv arg)
Definition: iparith.cc:10213
BOOLEAN jjUNIQLIST(leftv, leftv arg)
Definition: iparith.cc:10222
VAR idhdl currRingHdl
Definition: ipid.cc:59
VAR coeffs coeffs_BIGINT
Definition: ipid.cc:50
#define IDDATA(a)
Definition: ipid.h:126
#define setFlag(A, F)
Definition: ipid.h:113
#define FLAG_TWOSTD
Definition: ipid.h:107
#define IDRING(a)
Definition: ipid.h:127
#define FLAG_STD
Definition: ipid.h:106
BOOLEAN spaddProc(leftv result, leftv first, leftv second)
Definition: ipshell.cc:4427
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:6562
BOOLEAN semicProc3(leftv res, leftv u, leftv v, leftv w)
Definition: ipshell.cc:4510
BOOLEAN spectrumfProc(leftv result, leftv first)
Definition: ipshell.cc:4183
BOOLEAN spmulProc(leftv result, leftv first, leftv second)
Definition: ipshell.cc:4469
BOOLEAN spectrumProc(leftv result, leftv first)
Definition: ipshell.cc:4132
ring rSubring(ring org_ring, sleftv *rv)
Definition: ipshell.cc:6008
BOOLEAN semicProc(leftv res, leftv u, leftv v)
Definition: ipshell.cc:4550
char * versionString()
Definition: misc_ip.cc:770
STATIC_VAR jList * T
Definition: janet.cc:30
STATIC_VAR TreeM * G
Definition: janet.cc:31
STATIC_VAR Poly * h
Definition: janet.cc:971
KINLINE poly ksOldSpolyRed(poly p1, poly p2, poly spNoether)
Definition: kInline.h:1185
poly fglmLinearCombination(ideal source, poly monset)
Definition: fglmcomb.cc:415
poly fglmNewLinearCombination(ideal source, poly monset)
Definition: fglmcomb.cc:153
poly kNFBound(ideal F, ideal Q, poly p, int bound, int syzComp, int lazyReduce)
Definition: kstd1.cc:3222
VAR int(* test_PosInL)(const LSet set, const int length, LObject *L, const kStrategy strat)
Definition: kstd2.cc:83
VAR int(* test_PosInT)(const TSet T, const int tl, LObject &h)
Definition: kstd2.cc:82
int posInT17(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5460
VAR int HCord
Definition: kutil.cc:246
int posInT11(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5053
int posInT1(const TSet set, const int length, LObject &p)
Definition: kutil.cc:4996
int posInT0(const TSet, const int length, LObject &)
Definition: kutil.cc:4985
int posInT2(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5025
int posInT_pLength(const TSet set, const int length, LObject &p)
Definition: kutil.cc:11799
int posInT13(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5297
int posInT17_c(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5568
int posInT_EcartFDegpLength(const TSet set, const int length, LObject &p)
Definition: kutil.cc:11708
int posInT15(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5364
int posInT110(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5207
int posInT19(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5696
int posInT_FDegpLength(const TSet set, const int length, LObject &p)
Definition: kutil.cc:11762
BOOLEAN kVerify2(ideal F, ideal Q)
Definition: kverify.cc:138
BOOLEAN kVerify1(ideal F, ideal Q)
Definition: kverify.cc:21
static bool rIsSCA(const ring r)
Definition: nc.h:190
poly pOppose(ring Rop_src, poly p, const ring Rop_dst)
opposes a vector p from Rop to currRing (dst!)
Definition: old.gring.cc:3342
int & getNCExtensions()
Definition: old.gring.cc:82
int setNCExtensions(int iMask)
Definition: old.gring.cc:87
poly nc_p_Bracket_qq(poly p, const poly q, const ring r)
returns [p,q], destroys p
Definition: old.gring.cc:2243
static nc_type & ncRingType(nc_struct *p)
Definition: nc.h:159
matrix nc_PrintMat(int a, int b, ring r, int metric)
returns matrix with the info on noncomm multiplication
Definition: old.gring.cc:2394
bool sca_Force(ring rGR, int b, int e)
Definition: sca.cc:1161
bool luSolveViaLDUDecomp(const matrix pMat, const matrix lMat, const matrix dMat, const matrix uMat, const poly l, const poly u, const poly lTimesU, const matrix bVec, matrix &xVec, matrix &H)
Solves the linear system A * x = b, where A is an (m x n)-matrix which is given by its LDU-decomposit...
void henselFactors(const int xIndex, const int yIndex, const poly h, const poly f0, const poly g0, const int d, poly &f, poly &g)
Computes a factorization of a polynomial h(x, y) in K[[x]][y] up to a certain degree in x,...
void lduDecomp(const matrix aMat, matrix &pMat, matrix &lMat, matrix &dMat, matrix &uMat, poly &l, poly &u, poly &lTimesU)
LU-decomposition of a given (m x n)-matrix with performing only those divisions that yield zero remai...
VAR omBin slists_bin
Definition: lists.cc:23
VAR int n_SwitchChinRem
Definition: longrat.cc:3094
matrix mp_Transp(matrix a, const ring R)
Definition: matpol.cc:254
ideal sm_UnFlatten(ideal a, int col, const ring R)
Definition: matpol.cc:1946
matrix mp_InitI(int r, int c, int v, const ring R)
make it a v * unit matrix
Definition: matpol.cc:129
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:37
ideal sm_Flatten(ideal a, const ring R)
Definition: matpol.cc:1926
#define MATELEM(mat, i, j)
1-based access to matrix
Definition: matpol.h:29
ip_smatrix * matrix
Definition: matpol.h:43
#define MATROWS(i)
Definition: matpol.h:26
#define MATCOLS(i)
Definition: matpol.h:27
unsigned long * computeMinimalPolynomial(unsigned long **matrix, unsigned n, unsigned long p)
Definition: minpoly.cc:428
void mult(unsigned long *result, unsigned long *a, unsigned long *b, unsigned long p, int dega, int degb)
Definition: minpoly.cc:647
This file provides miscellaneous functionality.
#define assume(x)
Definition: mod2.h:389
#define SINGULAR_VERSION
Definition: mod2.h:87
#define pIter(p)
Definition: monomials.h:37
#define p_GetCoeff(p, r)
Definition: monomials.h:50
EXTERN_VAR size_t gmp_output_digits
Definition: mpr_base.h:115
bool complexNearZero(gmp_complex *c, int digits)
Definition: mpr_complex.cc:765
slists * lists
Definition: mpr_numeric.h:146
The main handler for Singular numbers which are suitable for Singular polynomials.
bool ncInitSpecialPowersMultiplication(ring r)
Definition: ncSAFormula.cc:50
BOOLEAN ncInitSpecialPairMultiplication(ring r)
Definition: ncSAMult.cc:266
ideal Approx_Step(ideal L)
Ann: ???
Definition: nc.cc:250
ideal twostd(ideal I)
Compute two-sided GB:
Definition: nc.cc:18
void newstructShow(newstruct_desc d)
Definition: newstruct.cc:826
BOOLEAN newstruct_set_proc(const char *bbname, const char *func, int args, procinfov pr)
Definition: newstruct.cc:846
#define omStrDup(s)
Definition: omAllocDecl.h:263
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
#define omAlloc(size)
Definition: omAllocDecl.h:210
#define omAllocBin(bin)
Definition: omAllocDecl.h:205
#define omAlloc0Bin(bin)
Definition: omAllocDecl.h:206
#define omFree(addr)
Definition: omAllocDecl.h:261
#define omAlloc0(size)
Definition: omAllocDecl.h:211
void omMarkAsStaticAddr(void *addr)
omError_t om_ErrorStatus
Definition: omError.c:13
const char * omError2String(omError_t error)
Definition: omError.c:54
const char * omError2Serror(omError_t error)
Definition: omError.c:65
omError_t om_InternalErrorStatus
Definition: omError.c:14
char * omFindExec(const char *name, char *exec)
Definition: omFindExec.c:314
#define NULL
Definition: omList.c:12
omOpts_t om_Opts
Definition: omOpts.c:13
#define MAXPATHLEN
Definition: omRet2Info.c:22
#define omPrintCurrentBackTrace(fd)
Definition: omRet2Info.h:39
VAR unsigned si_opt_2
Definition: options.c:6
#define Sy_bit(x)
Definition: options.h:31
number p_CoeffTerm(poly p, poly m, const ring r)
find coeff of (polynomial) m in polynomial p find coeff of (vector) m in vector p
Definition: pCoeff.cc:22
ideal id_CoeffTermV(ideal M, poly m, const ring r)
find coeffs of (polynomial) m in all vectors from I
Definition: pCoeff.cc:75
ideal id_CoeffTerm(ideal I, poly m, const ring r)
find coeffs of (polynomial) m in all polynomials from I find coeffs of (vector) m in all vectors from...
Definition: pCoeff.cc:63
poly p_CoeffTermV(poly v, poly m, const ring r)
find vector of coeffs of (polynomial) m in vector v
Definition: pCoeff.cc:39
void pPrintDivisbleByStat()
Definition: pDebug.cc:413
void p_Content(poly ph, const ring r)
Definition: p_polys.cc:2291
poly p_ISet(long i, const ring r)
returns the poly representing the integer i
Definition: p_polys.cc:1297
poly p_Cleardenom(poly p, const ring r)
Definition: p_polys.cc:2910
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:938
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent @Note: VarOffset encodes the position in p->exp
Definition: p_polys.h:490
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:235
static unsigned pLength(poly a)
Definition: p_polys.h:191
poly pcvP2CV(poly p, int d0, int d1)
Definition: pcv.cc:280
int pcvBasis(lists b, int i, poly m, int d, int n)
Definition: pcv.cc:430
int pcvMinDeg(poly p)
Definition: pcv.cc:135
int pcvDim(int d0, int d1)
Definition: pcv.cc:400
lists pcvPMulL(poly p, lists l1)
Definition: pcv.cc:76
poly pcvCV2P(poly cv, int d0, int d1)
Definition: pcv.cc:297
lists pcvLAddL(lists l1, lists l2)
Definition: pcv.cc:31
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
poly p_DivRem(poly p, poly q, poly &rest, const ring r)
Definition: polys.cc:314
Compatiblity layer for legacy polynomial operations (over currRing)
#define pAdd(p, q)
Definition: polys.h:203
#define pDelete(p_ptr)
Definition: polys.h:186
#define pHead(p)
returns newly allocated copy of Lm(p), coef is copied, next=NULL, p might be NULL
Definition: polys.h:67
#define pLmDeleteAndNext(p)
like pLmDelete, returns pNext(p)
Definition: polys.h:78
#define ppJetW(p, m, iv)
Definition: polys.h:369
#define pDivideM(a, b)
Definition: polys.h:294
#define pPower(p, q)
Definition: polys.h:204
#define pMult(p, q)
Definition: polys.h:207
void pWrite(poly p)
Definition: polys.h:308
#define pGetExp(p, i)
Exponent.
Definition: polys.h:41
#define pIsPurePower(p)
Definition: polys.h:248
#define pDivisibleBy(a, b)
returns TRUE, if leading monom of a divides leading monom of b i.e., if there exists a expvector c > ...
Definition: polys.h:138
#define pCopy(p)
return a copy of the poly
Definition: polys.h:185
#define pOne()
Definition: polys.h:315
poly nc_rat_CreateSpoly(poly pp1, poly pp2, int ishift, const ring r)
Definition: ratgring.cc:340
int redRat(poly *h, poly *reducer, int *red_length, int rl, int ishift, ring r)
Definition: ratgring.cc:593
poly nc_rat_ReduceSpolyNew(const poly p1, poly p2, int ishift, const ring r)
Definition: ratgring.cc:465
void StringSetS(const char *st)
Definition: reporter.cc:128
const char feNotImplemented[]
Definition: reporter.cc:54
void PrintS(const char *s)
Definition: reporter.cc:284
char * StringEndS()
Definition: reporter.cc:151
void PrintLn()
Definition: reporter.cc:310
void Werror(const char *fmt,...)
Definition: reporter.cc:189
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:3492
void p_DebugPrint(poly p, const ring r)
Definition: ring.cc:4369
int rChar(ring r)
Definition: ring.cc:713
void rDebugPrint(const ring r)
Definition: ring.cc:4164
ring rOpposite(ring src)
Definition: ring.cc:5382
ring rEnvelope(ring R)
Definition: ring.cc:5772
void rSetSyzComp(int k, const ring r)
Definition: ring.cc:5166
static BOOLEAN rField_is_R(const ring r)
Definition: ring.h:519
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
Definition: ring.h:400
static BOOLEAN rField_is_long_C(const ring r)
Definition: ring.h:546
static int rBlocks(const ring r)
Definition: ring.h:569
@ ringorder_s
s?
Definition: ring.h:76
static BOOLEAN rField_is_Q(const ring r)
Definition: ring.h:507
static BOOLEAN rIsNCRing(const ring r)
Definition: ring.h:421
static BOOLEAN rField_is_long_R(const ring r)
Definition: ring.h:543
#define rField_is_Ring(R)
Definition: ring.h:486
poly ringNF(poly f, ideal G, ring r)
Definition: ringgb.cc:199
poly plain_spoly(poly f, poly g)
Definition: ringgb.cc:168
poly ringRedNF(poly f, ideal G, ring r)
Definition: ringgb.cc:117
int testGB(ideal I, ideal GI)
Definition: ringgb.cc:226
static short scaLastAltVar(ring r)
Definition: sca.h:25
static short scaFirstAltVar(ring r)
Definition: sca.h:18
VAR int sdb_flags
Definition: sdb.cc:31
void sdb_edit(procinfo *pi)
Definition: sdb.cc:109
int simpleipc_cmd(char *cmd, int id, int v)
Definition: semaphore.c:167
int status int fd
Definition: si_signals.h:59
ideal id_Vec2Ideal(poly vec, const ring R)
#define IDELEMS(i)
Definition: simpleideals.h:23
#define R
Definition: sirandom.c:27
VAR int siSeed
Definition: sirandom.c:30
#define M
Definition: sirandom.c:25
@ testHomog
Definition: structs.h:38
procinfo * procinfov
Definition: structs.h:60
BOOLEAN assumeStdFlag(leftv h)
Definition: subexpr.cc:1536
@ BIGINT_CMD
Definition: tok.h:38
@ CRING_CMD
Definition: tok.h:56
@ LIST_CMD
Definition: tok.h:118
@ INTVEC_CMD
Definition: tok.h:101
@ CMATRIX_CMD
Definition: tok.h:46
@ DEF_CMD
Definition: tok.h:58
@ LINK_CMD
Definition: tok.h:117
@ STRING_CMD
Definition: tok.h:185
@ INT_CMD
Definition: tok.h:96
#define NONE
Definition: tok.h:221
int dim(ideal I, ring r)
int M3ivSame(intvec *temp, intvec *u, intvec *v)
Definition: walk.cc:914
intvec * MivMatrixOrderlp(int nV)
Definition: walk.cc:1401
intvec * MivUnit(int nV)
Definition: walk.cc:1496
intvec * MivMatrixOrder(intvec *iv)
Definition: walk.cc:963
intvec * MkInterRedNextWeight(intvec *iva, intvec *ivb, ideal G)
Definition: walk.cc:2570
intvec * Mfpertvector(ideal G, intvec *ivtarget)
Definition: walk.cc:1512
ideal TranMImprovwalk(ideal G, intvec *curr_weight, intvec *target_tmp, int nP)
Definition: walk.cc:8396
ideal Mfwalk(ideal G, intvec *ivstart, intvec *ivtarget, int reduction, int printout)
Definition: walk.cc:8031
intvec * MPertVectors(ideal G, intvec *ivtarget, int pdeg)
Definition: walk.cc:1088
intvec * MPertVectorslp(ideal G, intvec *ivtarget, int pdeg)
Definition: walk.cc:1299
ideal Mprwalk(ideal Go, intvec *orig_M, intvec *target_M, int weight_rad, int op_deg, int tp_deg, int nP, int reduction, int printout)
Definition: walk.cc:6388
intvec * MivWeightOrderdp(intvec *ivstart)
Definition: walk.cc:1456
intvec * Mivdp(int nR)
Definition: walk.cc:1007
intvec * MivMatrixOrderdp(int nV)
Definition: walk.cc:1417
intvec * MivWeightOrderlp(intvec *ivstart)
Definition: walk.cc:1436
ideal MAltwalk2(ideal Go, intvec *curr_weight, intvec *target_weight)
Definition: walk.cc:4280
ideal MAltwalk1(ideal Go, int op_deg, int tp_deg, intvec *curr_weight, intvec *target_weight)
Definition: walk.cc:9671
ideal Mrwalk(ideal Go, intvec *orig_M, intvec *target_M, int weight_rad, int pert_deg, int reduction, int printout)
Definition: walk.cc:5603
ideal Mfrwalk(ideal G, intvec *ivstart, intvec *ivtarget, int weight_rad, int reduction, int printout)
Definition: walk.cc:8212
ideal Mwalk(ideal Go, intvec *orig_M, intvec *target_M, ring baseRing, int reduction, int printout)
Definition: walk.cc:5302
ideal Mpwalk(ideal Go, int op_deg, int tp_deg, intvec *curr_weight, intvec *target_weight, int nP, int reduction, int printout)
Definition: walk.cc:5947
int MivSame(intvec *u, intvec *v)
Definition: walk.cc:893
intvec * Mivlp(int nR)
Definition: walk.cc:1022
ideal MwalkInitialForm(ideal G, intvec *ivw)
Definition: walk.cc:761
intvec * MPertNextWeight(intvec *iva, ideal G, int deg)
intvec * MwalkNextWeight(intvec *curr_weight, intvec *target_weight, ideal G)
intvec * Mivperttarget(ideal G, int ndeg)
int * iv2array(intvec *iv, const ring R)
Definition: weight.cc:200
#define omPrintUsedTrackAddrs(F, max)
Definition: xalloc.h:266
#define omUpdateInfo()
Definition: xalloc.h:230