source: git/Singular/extra.cc @ 9dd25c

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