source: git/Singular/extra.cc @ 0df59c8

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