source: git/Singular/extra.cc @ 005d00a

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