source: git/Singular/extra.cc @ d8bea6a

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