source: git/Singular/extra.cc @ 776f0e

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