source: git/Singular/extra.cc @ ea6e16e

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