source: git/Singular/extra.cc @ b40eaa0

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