source: git/Singular/extra.cc @ 5476e83

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