source: git/Singular/extra.cc @ 60da76

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