source: git/Singular/extra.cc @ a388ae

spielwiese
Last change on this file since a388ae was a388ae, checked in by Frank Seelisch <seelisch@…>, 15 years ago
added doxygen-like comments git-svn-id: file:///usr/local/Singular/svn/trunk@12198 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 97.6 KB
Line 
1/*****************************************
2*  Computer Algebra System SINGULAR      *
3*****************************************/
4/* $Id: extra.cc,v 1.327 2009-10-21 15:36:00 seelisch Exp $ */
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 == NULL))
2200        {
2201          const matrix m           = (const matrix)h->Data();
2202          const int k              = (const int)(long)h->next->Data();
2203          const int strategies     = (const int)(long)h->next->next->Data();
2204          const int cacheEntries   = (const int)(long)h->next->next->next->Data();
2205          const int cacheWeight    = (const int)(long)h->next->next->next->next->Data();
2206          const int dumpMinors     = (const int)(long)h->next->next->next->next->next->Data();
2207          const int dumpResults    = (const int)(long)h->next->next->next->next->next->next->Data();
2208          const int dumpComplete   = (const int)(long)h->next->next->next->next->next->next->next->Data();
2209          const int dumpConsole    = (const int)(long)h->next->next->next->next->next->next->next->next->Data();
2210          testAllPolyMinors(m, k, strategies, cacheEntries, cacheWeight, dumpMinors, dumpResults, dumpComplete, dumpConsole);
2211            /* starts the computation of all (k x k)-minors in the
2212               provided matrix m (which is assumed to have polynomial
2213               entries) using a cache with a maximum number of
2214               'cacheEntries' entries and a maximum weight of 'cacheWeight'
2215               (The weight is the number of cached monomials, counted over
2216               all cached polynomials.);
2217               when calling this method, a ring must have been declared before;
2218               strategy = "310" means that the code is run first without a
2219               cache ("0") and then afterwards with the caching strategies
2220               "1" and "3" */
2221        }
2222        else if (h->Typ() == POLY_CMD)
2223        { /* for quick tests with a single polynomial */
2224          const poly p = (const poly)h->Data();
2225          testStuff(p);
2226        }
2227        return FALSE;
2228      }
2229      else
2230      if(strcmp(sys_cmd,"changeRing")==0)
2231      {
2232        if ((h->Typ() == INT_CMD) &&
2233            (h->next->Typ() == INT_CMD))
2234        {
2235          const int fc     = (const int)(long)h->Data();
2236          const int varN   = (const int)(long)h->next->Data();
2237          {
2238            /* The following code creates and returns a ring with characteristic fc,
2239               order dp and varN variables with the names "x1", "x2", ..., "x4711"
2240               (in the case varN = 4711).
2241               The purpose of this rewriting is to eliminate indexed variables,
2242               as they may cause problems when generating scripts for Magma,
2243               Maple, or Macaulay2. */
2244            ring newRing = (ring) omAlloc0Bin(sip_sring_bin);
2245            newRing->ch = fc;
2246            newRing->N = varN;
2247            char h[10];
2248            newRing->names = (char **) omAlloc0(varN * sizeof(char_ptr));
2249            for (int i = 1; i <= varN; i++)
2250            {
2251              sprintf(h, "x%d", i);
2252              newRing->names[i - 1] = omStrDup(h);
2253            }
2254            newRing->wvhdl = (int **)omAlloc0(2 * sizeof(int_ptr));
2255            newRing->order = (int *)omAlloc(2* sizeof(int *));
2256            newRing->block0 = (int *)omAlloc0(2 * sizeof(int *));
2257            newRing->block1 = (int *)omAlloc0(2 * sizeof(int *));
2258            newRing->order[0] = ringorder_dp;
2259            newRing->block0[0] = 1;
2260            newRing->block1[0] = varN;
2261            newRing->order[1]  = 0;
2262            newRing->OrdSgn    = 1;
2263            rComplete(newRing);
2264            res->rtyp = RING_CMD;
2265            res->data = (void *)newRing;
2266            return FALSE;
2267          }
2268        } 
2269      }
2270      else
2271#endif
2272/* HAVE_MINOR */
2273/*==================== generic debug ==================================*/
2274#ifdef PDEBUG
2275      if(strcmp(sys_cmd,"DetailedPrint")==0)
2276      {
2277        if( h == NULL )
2278        {
2279          WarnS("DetailedPrint needs arguments...");
2280          return TRUE;
2281        }
2282       
2283        if( h->Typ() == RING_CMD)
2284        {
2285          const ring r = (const ring)h->Data();
2286          rWrite(r);
2287          PrintLn();
2288#ifdef RDEBUG
2289          rDebugPrint(r);
2290#endif
2291        }
2292        else
2293        if( h->Typ() == POLY_CMD || h->Typ() == VECTOR_CMD)
2294        {
2295          const int nTerms = 3;
2296          const poly p = (const poly)h->Data();
2297          p_DebugPrint(p, currRing, currRing, nTerms);
2298        }
2299        else
2300        if( h->Typ() == IDEAL_CMD || h->Typ() == MODUL_CMD)
2301        {
2302          const ideal id = (const ideal)h->Data();
2303         
2304          h = h->Next();
2305         
2306          int nTerms = 3;
2307
2308          if( h!= NULL && h->Typ() == INT_CMD )
2309          {
2310            int n = (int)(long)(h->Data());
2311            if( n < 0 )
2312            {
2313              Warn("Negative int argument: %d", n);
2314            }
2315            else
2316              nTerms = n;
2317          }
2318         
2319          idShow(id, currRing, currRing, nTerms);
2320        }
2321
2322        return FALSE;
2323      }
2324      else
2325#endif
2326/*==================== mtrack ==================================*/
2327    if(strcmp(sys_cmd,"mtrack")==0)
2328    {
2329#ifdef OM_TRACK
2330      om_Opts.MarkAsStatic = 1;
2331      FILE *fd = NULL;
2332      int max = 5;
2333      while (h != NULL)
2334      {
2335        omMarkAsStaticAddr(h);
2336        if (fd == NULL && h->Typ()==STRING_CMD)
2337        {
2338          fd = fopen((char*) h->Data(), "w");
2339          if (fd == NULL)
2340            Warn("Can not open %s for writing og mtrack. Using stdout"); // %s  ???
2341        }
2342        if (h->Typ() == INT_CMD)
2343        {
2344          max = (int)(long)h->Data();
2345        }
2346        h = h->Next();
2347      }
2348      omPrintUsedTrackAddrs((fd == NULL ? stdout : fd), max);
2349      if (fd != NULL) fclose(fd);
2350      om_Opts.MarkAsStatic = 0;
2351      return FALSE;
2352#else
2353     WerrorS("mtrack not supported without OM_TRACK");
2354     return TRUE;
2355#endif
2356    }
2357/*==================== mtrack_all ==================================*/
2358    if(strcmp(sys_cmd,"mtrack_all")==0)
2359    {
2360#ifdef OM_TRACK
2361      om_Opts.MarkAsStatic = 1;
2362      FILE *fd = NULL;
2363      if ((h!=NULL) &&(h->Typ()==STRING_CMD))
2364      {
2365        fd = fopen((char*) h->Data(), "w");
2366        if (fd == NULL)
2367          Warn("Can not open %s for writing og mtrack. Using stdout");
2368        omMarkAsStaticAddr(h);
2369      }
2370      // OB: TBC print to fd
2371      omPrintUsedAddrs((fd == NULL ? stdout : fd), 5);
2372      if (fd != NULL) fclose(fd);
2373      om_Opts.MarkAsStatic = 0;
2374      return FALSE;
2375#else
2376     WerrorS("mtrack not supported without OM_TRACK");
2377     return TRUE;
2378#endif
2379    }
2380    else
2381/*==================== backtrace ==================================*/
2382#ifndef OM_NDEBUG
2383    if(strcmp(sys_cmd,"backtrace")==0)
2384    {
2385      omPrintCurrentBackTrace(stdout);
2386      return FALSE;
2387    }
2388    else
2389#endif
2390/*==================== naIdeal ==================================*/
2391    if(strcmp(sys_cmd,"naIdeal")==0)
2392    {
2393      if ((h!=NULL) &&(h->Typ()==IDEAL_CMD))
2394      {
2395        naSetIdeal((ideal)h->Data());
2396        return FALSE;
2397      }
2398      else
2399         WerrorS("ideal expected");
2400    }
2401    else
2402/*==================== isSqrFree =============================*/
2403#ifdef HAVE_FACTORY
2404    if(strcmp(sys_cmd,"isSqrFree")==0)
2405    {
2406      if ((h!=NULL) &&(h->Typ()==POLY_CMD))
2407      {
2408        res->rtyp=INT_CMD;
2409        res->data=(void *)(long) singclap_isSqrFree((poly)h->Data());
2410        return FALSE;
2411      }
2412      else
2413        WerrorS("poly expected");
2414    }
2415    else
2416#endif
2417/*==================== pDivStat =============================*/
2418#if defined(PDEBUG) || defined(PDIV_DEBUG)
2419    if(strcmp(sys_cmd,"pDivStat")==0)
2420    {
2421      extern void pPrintDivisbleByStat();
2422      pPrintDivisbleByStat();
2423      return FALSE;
2424    }
2425    else
2426#endif
2427/*==================== alarm ==================================*/
2428#ifdef unix
2429    if(strcmp(sys_cmd,"alarm")==0)
2430    {
2431      if ((h!=NULL) &&(h->Typ()==INT_CMD))
2432      {
2433        // standard variant -> SIGALARM (standard: abort)
2434        //alarm((unsigned)h->next->Data());
2435        // process time (user +system): SIGVTALARM
2436        struct itimerval t,o;
2437        memset(&t,0,sizeof(t));
2438        t.it_value.tv_sec     =(unsigned)((unsigned long)h->Data());
2439        setitimer(ITIMER_VIRTUAL,&t,&o);
2440        return FALSE;
2441      }
2442      else
2443        WerrorS("int expected");
2444    }
2445    else
2446#endif
2447/*==================== red =============================*/
2448#if 0
2449    if(strcmp(sys_cmd,"red")==0)
2450    {
2451      if ((h!=NULL) &&(h->Typ()==IDEAL_CMD))
2452      {
2453        res->rtyp=IDEAL_CMD;
2454        res->data=(void *)kStdred((ideal)h->Data(),NULL,testHomog,NULL);
2455        setFlag(res,FLAG_STD);
2456        return FALSE;
2457      }
2458      else
2459        WerrorS("ideal expected");
2460    }
2461    else
2462#endif
2463#ifdef HAVE_FACTORY
2464/*==================== fastcomb =============================*/
2465    if(strcmp(sys_cmd,"fastcomb")==0)
2466    {
2467      if ((h!=NULL) &&(h->Typ()==IDEAL_CMD))
2468      {
2469        int i=0;
2470        if (h->next!=NULL)
2471        {
2472          if (h->next->Typ()!=POLY_CMD)
2473          {
2474            Warn("Wrong types for poly= comb(ideal,poly)");
2475          }
2476        }
2477        res->rtyp=POLY_CMD;
2478        res->data=(void *) fglmLinearCombination(
2479                           (ideal)h->Data(),(poly)h->next->Data());
2480        return FALSE;
2481      }
2482      else
2483        WerrorS("ideal expected");
2484    }
2485    else
2486/*==================== comb =============================*/
2487    if(strcmp(sys_cmd,"comb")==0)
2488    {
2489      if ((h!=NULL) &&(h->Typ()==IDEAL_CMD))
2490      {
2491        int i=0;
2492        if (h->next!=NULL)
2493        {
2494          if (h->next->Typ()!=POLY_CMD)
2495          {
2496              Warn("Wrong types for poly= comb(ideal,poly)");
2497          }
2498        }
2499        res->rtyp=POLY_CMD;
2500        res->data=(void *)fglmNewLinearCombination(
2501                            (ideal)h->Data(),(poly)h->next->Data());
2502        return FALSE;
2503      }
2504      else
2505        WerrorS("ideal expected");
2506    }
2507    else
2508#endif
2509/*==================== listall ===================================*/
2510    if(strcmp(sys_cmd,"listall")==0)
2511    {
2512      int showproc=0;
2513      if ((h!=NULL) && (h->Typ()==INT_CMD)) showproc=(int)((long)h->Data());
2514      listall(showproc);
2515      return FALSE;
2516    }
2517    else
2518/*==================== proclist =================================*/
2519    if(strcmp(sys_cmd,"proclist")==0)
2520    {
2521      piShowProcList();
2522      return FALSE;
2523    }
2524    else
2525/* ==================== newton ================================*/
2526#ifdef HAVE_NEWTON
2527    if(strcmp(sys_cmd,"newton")==0)
2528    {
2529      if ((h->Typ()!=POLY_CMD)
2530      || (h->next->Typ()!=INT_CMD)
2531      || (h->next->next->Typ()!=INT_CMD))
2532      {
2533        WerrorS("system(\"newton\",<poly>,<int>,<int>) expected");
2534        return TRUE;
2535      }
2536      poly  p=(poly)(h->Data());
2537      int l=pLength(p);
2538      short *points=(short *)omAlloc(currRing->N*l*sizeof(short));
2539      int i,j,k;
2540      k=0;
2541      poly pp=p;
2542      for (i=0;pp!=NULL;i++)
2543      {
2544        for(j=1;j<=currRing->N;j++)
2545        {
2546          points[k]=pGetExp(pp,j);
2547          k++;
2548        }
2549        pIter(pp);
2550      }
2551      hc_ERG r=hc_KOENIG(currRing->N,      // dimension
2552                l,      // number of points
2553                (short*) points,   // points: x_1, y_1,z_1, x_2,y_2,z2,...
2554                currRing->OrdSgn==-1,
2555                (int) (h->next->Data()),      // 1: Milnor, 0: Newton
2556                (int) (h->next->next->Data()) // debug
2557               );
2558      //----<>---Output-----------------------
2559
2560
2561//  PrintS("Bin jetzt in extra.cc bei der Auswertung.\n"); // **********
2562
2563
2564      lists L=(lists)omAllocBin(slists_bin);
2565      L->Init(6);
2566      L->m[0].rtyp=STRING_CMD;               // newtonnumber;
2567      L->m[0].data=(void *)omStrDup(r.nZahl);
2568      L->m[1].rtyp=INT_CMD;
2569      L->m[1].data=(void *)r.achse;          // flag for unoccupied axes
2570      L->m[2].rtyp=INT_CMD;
2571      L->m[2].data=(void *)r.deg;            // #degenerations
2572      if ( r.deg != 0)              // only if degenerations exist
2573      {
2574        L->m[3].rtyp=INT_CMD;
2575        L->m[3].data=(void *)r.anz_punkte;     // #points
2576        //---<>--number of points------
2577        int anz = r.anz_punkte;    // number of points
2578        int dim = (currRing->N);     // dimension
2579        intvec* v = new intvec( anz*dim );
2580        for (i=0; i<anz*dim; i++)    // copy points
2581          (*v)[i] = r.pu[i];
2582        L->m[4].rtyp=INTVEC_CMD;
2583        L->m[4].data=(void *)v;
2584        //---<>--degenerations---------
2585        int deg = r.deg;    // number of points
2586        intvec* w = new intvec( r.speicher );  // necessary memeory
2587        i=0;               // start copying
2588        do
2589        {
2590          (*w)[i] = r.deg_tab[i];
2591          i++;
2592        }
2593        while (r.deg_tab[i-1] != -2);   // mark for end of list
2594        L->m[5].rtyp=INTVEC_CMD;
2595        L->m[5].data=(void *)w;
2596      }
2597      else
2598      {
2599        L->m[3].rtyp=INT_CMD; L->m[3].data=(char *)0;
2600        L->m[4].rtyp=DEF_CMD;
2601        L->m[5].rtyp=DEF_CMD;
2602      }
2603
2604      res->data=(void *)L;
2605      res->rtyp=LIST_CMD;
2606      // free all pointer in r:
2607      delete[] r.nZahl;
2608      delete[] r.pu;
2609      delete[] r.deg_tab;      // Ist das ein Problem??
2610
2611      omFreeSize((ADDRESS)points,currRing->N*l*sizeof(short));
2612      return FALSE;
2613    }
2614    else
2615#endif
2616/*==================== sdb_flags =================*/
2617#ifdef HAVE_SDB
2618    if (strcmp(sys_cmd, "sdb_flags") == 0)
2619    {
2620      if ((h!=NULL) && (h->Typ()==INT_CMD))
2621      {
2622        sdb_flags=(int)((long)h->Data());
2623      }
2624      else
2625      {
2626        WerrorS("system(\"sdb_flags\",`int`) expected");
2627        return TRUE;
2628      }
2629      return FALSE;
2630    }
2631    else
2632#endif
2633/*==================== sdb_edit =================*/
2634#ifdef HAVE_SDB
2635    if (strcmp(sys_cmd, "sdb_edit") == 0)
2636    {
2637      if ((h!=NULL) && (h->Typ()==PROC_CMD))
2638      {
2639        procinfov p=(procinfov)h->Data();
2640        sdb_edit(p);
2641      }
2642      else
2643      {
2644        WerrorS("system(\"sdb_edit\",`proc`) expected");
2645        return TRUE;
2646      }
2647      return FALSE;
2648    }
2649    else
2650#endif
2651/*==================== GF =================*/
2652#if 0 // for testing only
2653    if (strcmp(sys_cmd, "GF") == 0)
2654    {
2655      if ((h!=NULL) && (h->Typ()==POLY_CMD))
2656      {
2657        int c=rChar(currRing);
2658        setCharacteristic( c,nfMinPoly[0], currRing->parameter[0][0] );
2659        CanonicalForm F( convSingGFFactoryGF( (poly)h->Data() ) );
2660        res->rtyp=POLY_CMD;
2661        res->data=convFactoryGFSingGF( F );
2662        return FALSE;
2663      }
2664      else { Werror("wrong typ"); return TRUE;}
2665    }
2666    else
2667#endif
2668/*==================== stdX =================*/
2669    if (strcmp(sys_cmd, "std") == 0)
2670    {
2671      ideal i1;
2672      int i2;
2673      if ((h!=NULL) && (h->Typ()==MODUL_CMD))
2674      {
2675        i1=(ideal)h->CopyD();
2676        h=h->next;
2677      }
2678      else return TRUE;
2679      if ((h!=NULL) && (h->Typ()==INT_CMD))
2680      {
2681        i2=(int)((long)h->Data());
2682      }
2683      else return TRUE;
2684      res->rtyp=MODUL_CMD;
2685      res->data=idXXX(i1,i2);
2686      return FALSE;
2687    }
2688    else
2689/*==================== SVD =================*/
2690#ifdef HAVE_SVD
2691     if (strcmp(sys_cmd, "svd") == 0)
2692     {
2693          extern lists testsvd(matrix M);
2694            res->rtyp=LIST_CMD;
2695          res->data=(char*)(testsvd((matrix)h->Data()));
2696          return FALSE;
2697     }
2698     else
2699#endif
2700/*==================== DLL =================*/
2701#ifdef ix86_Win
2702#ifdef HAVE_DL
2703/* testing the DLL functionality under Win32 */
2704      if (strcmp(sys_cmd, "DLL") == 0)
2705      {
2706        typedef void  (*Void_Func)();
2707        typedef int  (*Int_Func)(int);
2708        void *hh=dynl_open("WinDllTest.dll");
2709        if ((h!=NULL) && (h->Typ()==INT_CMD))
2710        {
2711          int (*f)(int);
2712          if (hh!=NULL)
2713          {
2714            int (*f)(int);
2715            f=(Int_Func)dynl_sym(hh,"PlusDll");
2716            int i=10;
2717            if (f!=NULL) printf("%d\n",f(i));
2718            else PrintS("cannot find PlusDll\n");
2719          }
2720        }
2721        else
2722        {
2723          void (*f)();
2724          f= (Void_Func)dynl_sym(hh,"TestDll");
2725          if (f!=NULL) f();
2726          else PrintS("cannot find TestDll\n");
2727        }
2728        return FALSE;
2729      }
2730      else
2731#endif
2732#endif
2733/*==================== eigenvalues ==================================*/
2734#ifdef HAVE_EIGENVAL
2735    if(strcmp(sys_cmd,"eigenvals")==0)
2736    {
2737      return evEigenvals(res,h);
2738    }
2739    else
2740#endif
2741/*==================== Gauss-Manin system ==================================*/
2742#ifdef HAVE_GMS
2743    if(strcmp(sys_cmd,"gmsnf")==0)
2744    {
2745      return gmsNF(res,h);
2746    }
2747    else
2748#endif
2749/*==================== facstd_debug ==================================*/
2750#if !defined(NDEBUG)
2751    if(strcmp(sys_cmd,"facstd")==0)
2752    {
2753      extern int strat_nr;
2754      extern int strat_fac_debug;
2755      strat_fac_debug=(int)(long)h->Data();
2756      strat_nr=0;
2757      return FALSE;
2758    }
2759    else
2760#endif
2761#ifdef HAVE_RING2TOM
2762/*==================== ring-GB ==================================*/
2763    if (strcmp(sys_cmd, "findZeroPoly")==0)
2764    {
2765      ring r = currRing;
2766      poly f = (poly) h->Data();
2767      res->rtyp=POLY_CMD;
2768      res->data=(poly) kFindZeroPoly(f, r, r);
2769      return(FALSE);
2770    }
2771    else
2772/*==================== Creating zero polynomials =================*/
2773#ifdef HAVE_VANIDEAL
2774    if (strcmp(sys_cmd, "createG0")==0)
2775    {
2776      /* long exp[50];
2777      int N = 0;
2778      while (h != NULL)
2779      {
2780        N += 1;
2781        exp[N] = (long) h->Data();
2782        // if (exp[i] % 2 != 0) exp[i] -= 1;
2783        h = h->next;
2784      }
2785      for (int k = 1; N + k <= currRing->N; k++) exp[k] = 0;
2786
2787      poly t_p;
2788      res->rtyp=POLY_CMD;
2789      res->data= (poly) kCreateZeroPoly(exp, -1, &t_p, currRing, currRing);
2790      return(FALSE); */
2791
2792      res->rtyp = IDEAL_CMD;
2793      res->data = (ideal) createG0();
2794      return(FALSE);
2795    }
2796    else
2797#endif
2798/*==================== redNF_ring =================*/
2799    if (strcmp(sys_cmd, "redNF_ring")==0)
2800    {
2801      ring r = currRing;
2802      poly f = (poly) h->Data();
2803      h = h->next;
2804      ideal G = (ideal) h->Data();
2805      res->rtyp=POLY_CMD;
2806      res->data=(poly) ringRedNF(f, G, r);
2807      return(FALSE);
2808    }
2809    else
2810#endif
2811/*==================== minor =================*/
2812    if (strcmp(sys_cmd, "minor")==0)
2813    {
2814      ring r = currRing;
2815      matrix a = (matrix) h->Data();
2816      h = h->next;
2817      int ar = (int)(long) h->Data();
2818      h = h->next;
2819      int which = (int)(long) h->Data();
2820      h = h->next;
2821      ideal R = NULL;
2822      if (h != NULL)
2823      {
2824        R = (ideal) h->Data();
2825      }
2826      res->data=(poly) idMinor(a, ar, (unsigned long) which, R);
2827      if (res->data == (poly) 1)
2828      {
2829        res->rtyp=INT_CMD;
2830        res->data = 0;
2831      }
2832      else
2833      {
2834        res->rtyp=POLY_CMD;
2835      }
2836      return(FALSE);
2837    }
2838    else
2839/*==================== F5 Implementation =================*/
2840#ifdef HAVE_F5
2841    if (strcmp(sys_cmd, "f5")==0)
2842    {
2843      if (h->Typ()!=IDEAL_CMD)
2844      {
2845        WerrorS("ideal expected");
2846        return TRUE;
2847      }
2848
2849      ring r = currRing;
2850      ideal G = (ideal) h->Data();
2851      h = h->next;
2852      int opt;
2853      if(h != NULL) {
2854        opt = (int) (long) h->Data();
2855      }
2856      else {
2857        opt = 2;
2858      }
2859      res->rtyp=IDEAL_CMD;
2860      res->data=(ideal) F5main(G,r,opt);
2861      return FALSE;
2862    }
2863    else
2864#endif
2865/*==================== F5C Implementation =================*/
2866#ifdef HAVE_F5C
2867    if (strcmp(sys_cmd, "f5c")==0)
2868    {
2869      if (h->Typ()!=IDEAL_CMD)
2870      {
2871        WerrorS("ideal expected");
2872        return TRUE;
2873      }
2874
2875      ring r = currRing;
2876      ideal G = (ideal) h->Data();
2877      res->rtyp=IDEAL_CMD;
2878      res->data=(ideal) f5cMain(G,r);
2879      return FALSE;
2880    }
2881    else
2882#endif
2883/*==================== Testing groebner basis =================*/
2884#ifdef HAVE_RINGS
2885    if (strcmp(sys_cmd, "NF_ring")==0)
2886    {
2887      ring r = currRing;
2888      poly f = (poly) h->Data();
2889      h = h->next;
2890      ideal G = (ideal) h->Data();
2891      res->rtyp=POLY_CMD;
2892      res->data=(poly) ringNF(f, G, r);
2893      return(FALSE);
2894    }
2895    else
2896    if (strcmp(sys_cmd, "spoly")==0)
2897    {
2898      poly f = pCopy((poly) h->Data());
2899      h = h->next;
2900      poly g = pCopy((poly) h->Data());
2901
2902      res->rtyp=POLY_CMD;
2903      res->data=(poly) plain_spoly(f,g);
2904      return(FALSE);
2905    }
2906    else
2907    if (strcmp(sys_cmd, "testGB")==0)
2908    {
2909      ideal I = (ideal) h->Data();
2910      h = h->next;
2911      ideal GI = (ideal) h->Data();
2912      res->rtyp = INT_CMD;
2913      res->data = (void *) testGB(I, GI);
2914      return(FALSE);
2915    }
2916    else
2917#endif
2918/*==================== sca?AltVar ==================================*/
2919#ifdef HAVE_PLURAL
2920    if ( (strcmp(sys_cmd, "AltVarStart") == 0) || (strcmp(sys_cmd, "AltVarEnd") == 0) )
2921    {
2922      ring r = currRing;
2923
2924      if((h!=NULL) && (h->Typ()==RING_CMD)) r = (ring)h->Data(); else
2925      {
2926        WerrorS("`system(\"AltVarStart/End\"[,<ring>])` expected");
2927        return TRUE;
2928      }
2929
2930      res->rtyp=INT_CMD;
2931
2932      if (rIsSCA(r))
2933      {
2934        if(strcmp(sys_cmd, "AltVarStart") == 0)
2935          res->data = (void*)scaFirstAltVar(r);
2936        else
2937          res->data = (void*)scaLastAltVar(r);
2938        return FALSE;
2939      }
2940
2941      WerrorS("`system(\"AltVarStart/End\",<ring>) requires a SCA ring");
2942      return TRUE;
2943    }
2944    else
2945#endif
2946/*==================== RatNF, noncomm rational coeffs =================*/
2947#ifdef HAVE_PLURAL
2948#ifdef HAVE_RATGRING
2949    if (strcmp(sys_cmd, "intratNF") == 0)
2950    {
2951      poly p;
2952      poly *q;
2953      ideal I;
2954      int is, k, id;
2955      if ((h!=NULL) && (h->Typ()==POLY_CMD))
2956      {
2957        p=(poly)h->CopyD();
2958        h=h->next;
2959        //        Print("poly is done\n");
2960      }
2961      else return TRUE;
2962      if ((h!=NULL) && (h->Typ()==IDEAL_CMD))
2963      {
2964        I=(ideal)h->CopyD();
2965        q = I->m;
2966        h=h->next;
2967        //        Print("ideal is done\n");
2968      }
2969      else return TRUE;
2970      if ((h!=NULL) && (h->Typ()==INT_CMD))
2971      {
2972        is=(int)((long)(h->Data()));
2973        //        res->rtyp=INT_CMD;
2974        //        Print("int is done\n");
2975        //        res->rtyp=IDEAL_CMD;
2976        if (rIsPluralRing(currRing))
2977        {
2978          id = IDELEMS(I);
2979                 int *pl=(int*)omAlloc0(IDELEMS(I)*sizeof(int));
2980          for(k=0; k < id; k++)
2981          {
2982            pl[k] = pLength(I->m[k]);
2983          }
2984          Print("starting redRat\n");
2985          //res->data = (char *)
2986          redRat(&p, q, pl, (int)IDELEMS(I),is,currRing);
2987          res->data=p;
2988          res->rtyp=POLY_CMD;
2989          //        res->data = ncGCD(p,q,currRing);
2990        }
2991        else
2992        {
2993          res->rtyp=POLY_CMD;
2994          res->data=p;
2995        }
2996      }
2997      else return TRUE;
2998      return FALSE;
2999    }
3000    else
3001/*==================== RatNF, noncomm rational coeffs =================*/
3002    if (strcmp(sys_cmd, "ratNF") == 0)
3003    {
3004      poly p,q;
3005      int is, htype;
3006      if ((h!=NULL) && ( (h->Typ()==POLY_CMD) || (h->Typ()==VECTOR_CMD) ) )
3007      {
3008        p=(poly)h->CopyD();
3009        h=h->next;
3010        htype = h->Typ();
3011      }
3012      else return TRUE;
3013      if ((h!=NULL) && ( (h->Typ()==POLY_CMD) || (h->Typ()==VECTOR_CMD) ) )
3014      {
3015        q=(poly)h->CopyD();
3016        h=h->next;
3017      }
3018      else return TRUE;
3019      if ((h!=NULL) && (h->Typ()==INT_CMD))
3020      {
3021        is=(int)((long)(h->Data()));
3022        res->rtyp=htype;
3023        //        res->rtyp=IDEAL_CMD;
3024        if (rIsPluralRing(currRing))
3025        {
3026          res->data = nc_rat_ReduceSpolyNew(q,p,is, currRing);
3027          //        res->data = ncGCD(p,q,currRing);
3028        }
3029        else res->data=p;
3030      }
3031      else return TRUE;
3032      return FALSE;
3033    }
3034    else
3035/*==================== RatSpoly, noncomm rational coeffs =================*/
3036    if (strcmp(sys_cmd, "ratSpoly") == 0)
3037    {
3038      poly p,q;
3039      int is;
3040      if ((h!=NULL) && (h->Typ()==POLY_CMD))
3041      {
3042        p=(poly)h->CopyD();
3043        h=h->next;
3044      }
3045      else return TRUE;
3046      if ((h!=NULL) && (h->Typ()==POLY_CMD))
3047      {
3048        q=(poly)h->CopyD();
3049        h=h->next;
3050      }
3051      else return TRUE;
3052      if ((h!=NULL) && (h->Typ()==INT_CMD))
3053      {
3054        is=(int)((long)(h->Data()));
3055        res->rtyp=POLY_CMD;
3056        //        res->rtyp=IDEAL_CMD;
3057        if (rIsPluralRing(currRing))
3058        {
3059          res->data = nc_rat_CreateSpoly(p,q,is,currRing);
3060          //        res->data = ncGCD(p,q,currRing);
3061        }
3062        else res->data=p;
3063      }
3064      else return TRUE;
3065      return FALSE;
3066    }
3067    else
3068#endif // HAVE_RATGRING
3069/*==================== Rat def =================*/
3070    if (strcmp(sys_cmd, "ratVar") == 0)
3071    {
3072      int start,end;
3073      int is;
3074      if ((h!=NULL) && (h->Typ()==POLY_CMD))
3075      {
3076        start=pIsPurePower((poly)h->Data());
3077        h=h->next;
3078      }
3079      else return TRUE;
3080      if ((h!=NULL) && (h->Typ()==POLY_CMD))
3081      {
3082        end=pIsPurePower((poly)h->Data());
3083        h=h->next;
3084      }
3085      else return TRUE;
3086      currRing->real_var_start=start;
3087      currRing->real_var_end=end;
3088      return (start==0)||(end==0)||(start>end);
3089    }
3090    else
3091/*==================== shift-test for freeGB  =================*/
3092#ifdef HAVE_SHIFTBBA
3093    if (strcmp(sys_cmd, "stest") == 0)
3094    {
3095      poly p;
3096      int sh,uptodeg, lVblock;
3097      if ((h!=NULL) && (h->Typ()==POLY_CMD))
3098      {
3099        p=(poly)h->CopyD();
3100        h=h->next;
3101      }
3102      else return TRUE;
3103      if ((h!=NULL) && (h->Typ()==INT_CMD))
3104      {
3105        sh=(int)((long)(h->Data()));
3106        h=h->next;
3107      }
3108      else return TRUE;
3109
3110      if ((h!=NULL) && (h->Typ()==INT_CMD))
3111      {
3112        uptodeg=(int)((long)(h->Data()));
3113        h=h->next;
3114      }
3115      else return TRUE;
3116      if ((h!=NULL) && (h->Typ()==INT_CMD))
3117      {
3118        lVblock=(int)((long)(h->Data()));
3119        res->data = pLPshift(p,sh,uptodeg,lVblock);
3120        res->rtyp = POLY_CMD;
3121      }
3122      else return TRUE;
3123      return FALSE;
3124    }
3125    else
3126#endif
3127/*==================== block-test for freeGB  =================*/
3128#ifdef HAVE_SHIFTBBA
3129    if (strcmp(sys_cmd, "btest") == 0)
3130    {
3131      poly p;
3132      int lV;
3133      if ((h!=NULL) && (h->Typ()==POLY_CMD))
3134      {
3135        p=(poly)h->CopyD();
3136        h=h->next;
3137      }
3138      else return TRUE;
3139      if ((h!=NULL) && (h->Typ()==INT_CMD))
3140      {
3141        lV=(int)((long)(h->Data()));
3142        res->rtyp = INT_CMD;
3143        res->data = (void*)pLastVblock(p, lV);
3144      }
3145      else return TRUE;
3146      return FALSE;
3147    }
3148    else
3149/*==================== shrink-test for freeGB  =================*/
3150    if (strcmp(sys_cmd, "shrinktest") == 0)
3151    {
3152      poly p;
3153      int lV;
3154      if ((h!=NULL) && (h->Typ()==POLY_CMD))
3155      {
3156        p=(poly)h->CopyD();
3157        h=h->next;
3158      }
3159      else return TRUE;
3160      if ((h!=NULL) && (h->Typ()==INT_CMD))
3161      {
3162        lV=(int)((long)(h->Data()));
3163        res->rtyp = POLY_CMD;
3164        //        res->data = p_mShrink(p, lV, currRing);
3165        //        kStrategy strat=new skStrategy;
3166        //        strat->tailRing = currRing;
3167        res->data = p_Shrink(p, lV, currRing);
3168      }
3169      else return TRUE;
3170      return FALSE;
3171    }
3172    else
3173#endif
3174#endif
3175/*==================== t-rep-GB ==================================*/
3176    if (strcmp(sys_cmd, "unifastmult")==0)
3177    {
3178      ring r = currRing;
3179      poly f = (poly)h->Data();
3180      h=h->next;
3181      poly g=(poly)h->Data();
3182      res->rtyp=POLY_CMD;
3183      res->data=unifastmult(f,g,currRing);
3184      return(FALSE);
3185    }
3186    else
3187    if (strcmp(sys_cmd, "multifastmult")==0)
3188    {
3189      ring r = currRing;
3190      poly f = (poly)h->Data();
3191      h=h->next;
3192      poly g=(poly)h->Data();
3193      res->rtyp=POLY_CMD;
3194      res->data=multifastmult(f,g,currRing);
3195      return(FALSE);
3196    }
3197    else
3198    if (strcmp(sys_cmd, "mults")==0)
3199    {
3200      res->rtyp=INT_CMD ;
3201      res->data=(void*)(long) Mults();
3202      return(FALSE);
3203    }
3204    else
3205    if (strcmp(sys_cmd, "fastpower")==0)
3206    {
3207      ring r = currRing;
3208      poly f = (poly)h->Data();
3209      h=h->next;
3210      int n=(int)((long)h->Data());
3211      res->rtyp=POLY_CMD ;
3212      res->data=(void*) pFastPower(f,n,r);
3213      return(FALSE);
3214    }
3215    else
3216    if (strcmp(sys_cmd, "normalpower")==0)
3217    {
3218      ring r = currRing;
3219      poly f = (poly)h->Data();
3220      h=h->next;
3221      int n=(int)((long)h->Data());
3222      res->rtyp=POLY_CMD ;
3223      res->data=(void*) pPower(pCopy(f),n);
3224      return(FALSE);
3225    }
3226    else
3227    if (strcmp(sys_cmd, "MCpower")==0)
3228    {
3229      ring r = currRing;
3230      poly f = (poly)h->Data();
3231      h=h->next;
3232      int n=(int)((long)h->Data());
3233      res->rtyp=POLY_CMD ;
3234      res->data=(void*) pFastPowerMC(f,n,r);
3235      return(FALSE);
3236    }
3237    else
3238    if (strcmp(sys_cmd, "bit_subst")==0)
3239    {
3240      ring r = currRing;
3241      poly outer = (poly)h->Data();
3242      h=h->next;
3243      poly inner=(poly)h->Data();
3244      res->rtyp=POLY_CMD ;
3245      res->data=(void*) uni_subst_bits(outer, inner,r);
3246      return(FALSE);
3247    }
3248    else
3249/*==================== bifac =================*/
3250#ifdef HAVE_BIFAC
3251    if (strcmp(sys_cmd, "bifac")==0)
3252    {
3253      if (h->Typ()!=POLY_CMD)
3254      {
3255        WerrorS("`system(\"bifac\",<poly>) expected");
3256        return TRUE;
3257      }
3258      if (!rField_is_Q())
3259      {
3260        WerrorS("coeff field must be Q");
3261        return TRUE;
3262      }
3263      BIFAC B;
3264      CFFList C;
3265      int sw_rat=isOn(SW_RATIONAL);
3266      On(SW_RATIONAL);
3267      CanonicalForm F( convSingPClapP((poly)(h->Data())));
3268      B.bifac(F, 1);
3269      CFFList L=B.getFactors();
3270      // construct the ring ==============================================
3271      int i;
3272      int lev=ExtensionLevel();
3273      char **names=(char**)omAlloc0(lev*sizeof(char_ptr));
3274      for(i=1;i<=lev; i++)
3275      {
3276        StringSetS("");
3277        names[i-1]=omStrDup(StringAppend("a(%d)",i));
3278      }
3279      ring alg_ring=rDefault(0,lev,names);
3280      ring new_ring=rCopy0(currRing); // all variable names, ordering etc.
3281      new_ring->P=lev;
3282      new_ring->parameter=names;
3283      new_ring->algring=alg_ring;
3284      new_ring->ch=1;
3285      rComplete(new_ring,TRUE);
3286      // set the mipo ===============================================
3287      ring save_currRing=currRing; idhdl save_currRingHdl=currRingHdl;
3288      rChangeCurrRing(alg_ring);
3289      ideal mipo_id=idInit(lev,1);
3290      for (i=lev; i>0;i--)
3291      {
3292        CanonicalForm Mipo=getMipo(Variable(-i),Variable(i));
3293        mipo_id->m[i-1]=convClapPSingP(Mipo);
3294      }
3295      idShow(mipo_id);
3296      alg_ring->qideal=mipo_id;
3297      rChangeCurrRing(new_ring);
3298      for (i=lev-1; i>=0;i--)
3299      {
3300        poly p=pOne();
3301        lnumber n=(lnumber)pGetCoeff(p);
3302        // no need to delete nac 1
3303        n->z=(napoly)mipo_id->m[i];
3304        mipo_id->m[i]=p;
3305      }
3306      new_ring->minideal=id_Copy(alg_ring->qideal,new_ring);
3307      // convert factors =============================================
3308      ideal fac_id=idInit(L.length(),1);
3309      CFFListIterator J=L;
3310      i=0;
3311      intvec *v = new intvec( L.length() );
3312      for ( ; J.hasItem(); J++,i++ )
3313      {
3314        fac_id->m[i]=convClapAPSingAP( J.getItem().factor() );
3315        (*v)[i]=J.getItem().exp();
3316      }
3317      idhdl hh=enterid("factors",0,LIST_CMD,&(currRing->idroot),FALSE);
3318      lists LL=(lists)omAllocBin( slists_bin);
3319      LL->Init(2);
3320      LL->m[0].rtyp=IDEAL_CMD;
3321      LL->m[0].data=(char *)fac_id;
3322      LL->m[1].rtyp=INTVEC_CMD;
3323      LL->m[1].data=(char *)v;
3324      IDDATA(hh)=(char *)LL;
3325
3326      rChangeCurrRing(save_currRing);
3327      currRingHdl=save_currRingHdl;
3328      if (!sw_rat) Off(SW_RATIONAL);
3329
3330      res->data=new_ring;
3331      res->rtyp=RING_CMD;
3332      return FALSE;
3333    }
3334    else
3335#endif
3336/*==================== gcd-varianten =================*/
3337    if (strcmp(sys_cmd, "gcd") == 0)
3338    {
3339      if (h==NULL)
3340      {
3341        Print("NTL_0:%d (use NTL for gcd of polynomials in char 0)\n",isOn(SW_USE_NTL_GCD_0));
3342        Print("NTL_p:%d (use NTL for gcd of polynomials in char p)\n",isOn(SW_USE_NTL_GCD_P));
3343        Print("EZGCD:%d (use EZGCD for gcd of polynomials in char 0)\n",isOn(SW_USE_EZGCD));
3344        Print("EZGCD_P:%d (use EZGCD_P for gcd of polynomials in char p)\n",isOn(SW_USE_EZGCD_P));
3345        Print("CRGCD:%d (use chinese Remainder for gcd of polynomials in char 0)\n",isOn(SW_USE_CHINREM_GCD));
3346        Print("SPARSEMOD:%d (use SPARSEMOD for gcd of polynomials in char 0)\n",isOn(SW_USE_SPARSEMOD));
3347        Print("QGCD:%d (use QGCD for gcd of polynomials in alg. ext.)\n",isOn(SW_USE_QGCD));
3348        Print("FGCD:%d (use fieldGCD for gcd of polynomials in Z/p)\n",isOn(SW_USE_fieldGCD));
3349        Print("homog:%d (use homog. test for factorization of polynomials)\n",singular_homog_flag);
3350        return FALSE;
3351      }
3352      else
3353      if ((h!=NULL) && (h->Typ()==STRING_CMD)
3354      && (h->next!=NULL) && (h->next->Typ()==INT_CMD))
3355      {
3356        int d=(int)(long)h->next->Data();
3357        char *s=(char *)h->Data();
3358        if (strcmp(s,"NTL_0")==0) { if (d) On(SW_USE_NTL_GCD_0); else Off(SW_USE_NTL_GCD_0); } else
3359        if (strcmp(s,"NTL_p")==0) { if (d) On(SW_USE_NTL_GCD_P); else Off(SW_USE_NTL_GCD_P); } else
3360        if (strcmp(s,"EZGCD")==0) { if (d) On(SW_USE_EZGCD); else Off(SW_USE_EZGCD); } else
3361        if (strcmp(s,"EZGCD_P")==0) { if (d) On(SW_USE_EZGCD_P); else Off(SW_USE_EZGCD_P); } else
3362        if (strcmp(s,"CRGCD")==0) { if (d) On(SW_USE_CHINREM_GCD); else Off(SW_USE_CHINREM_GCD); } else
3363        if (strcmp(s,"SPARSEMOD")==0) { if (d) On(SW_USE_SPARSEMOD); else Off(SW_USE_SPARSEMOD); } else
3364        if (strcmp(s,"QGCD")==0) { if (d) On(SW_USE_QGCD); else Off(SW_USE_QGCD); } else
3365        if (strcmp(s,"FGCD")==0) { if (d) On(SW_USE_fieldGCD); else Off(SW_USE_fieldGCD); } else
3366        if (strcmp(s,"homog")==0) { if (d) singular_homog_flag=1; else singular_homog_flag=0; } else
3367        return TRUE;
3368        return FALSE;
3369      }
3370      else return TRUE;
3371    }
3372    else
3373#if 0
3374/*==================== gcd-test =================*/
3375    if (strcmp(sys_cmd, "GCD") == 0)
3376    {
3377      if ((h!=NULL) && (h->Typ()==POLY_CMD)
3378      && (h->next!=NULL) && (h->next->Typ()==POLY_CMD))
3379      {
3380        poly f=(poly)h->Data();
3381        poly g=(poly)h->next->Data();
3382        res->rtyp=POLY_CMD;
3383        res->data=(char*)id_GCD(f,g,currRing);
3384        return FALSE;
3385      }
3386      else return TRUE;
3387    }
3388    else
3389#endif
3390/*==================== subring =================*/
3391    if (strcmp(sys_cmd, "subring") == 0)
3392    {
3393      if (h!=NULL)
3394      {
3395        extern ring rSubring(ring r,leftv v); /* ipshell.cc*/
3396        res->data=(char *)rSubring(currRing,h);
3397        res->rtyp=RING_CMD;
3398        return res->data==NULL;
3399      }
3400      else return TRUE;
3401    }
3402    else
3403#ifdef ix86_Win
3404/*==================== Python Singular =================*/
3405    if (strcmp(sys_cmd, "python") == 0)
3406    {
3407      const char* c;
3408      if ((h!=NULL) && (h->Typ()==STRING_CMD))
3409      {
3410        c=(const char*)h->Data();
3411        if (!PyInitialized) {
3412          PyInitialized = 1;
3413//          Py_Initialize();
3414//          initPySingular();
3415        }
3416//      PyRun_SimpleString(c);
3417        return FALSE;
3418      }
3419      else return TRUE;
3420    }
3421    else
3422/*==================== Python Singular =================
3423    if (strcmp(sys_cmd, "ipython") == 0)
3424    {
3425      const char* c;
3426      {
3427        if (!PyInitialized) {
3428          PyInitialized = 1;
3429          Py_Initialize();
3430          initPySingular();
3431        }
3432  PyRun_SimpleString(
3433"try:                                                                                       \n\
3434    __IPYTHON__                                                                             \n\
3435except NameError:                                                                           \n\
3436    argv = ['']                                                                             \n\
3437    banner = exit_msg = ''                                                                  \n\
3438else:                                                                                       \n\
3439    # Command-line options for IPython (a list like sys.argv)                               \n\
3440    argv = ['-pi1','In <\\#>:','-pi2','   .\\D.:','-po','Out<\\#>:']                        \n\
3441    banner = '*** Nested interpreter ***'                                                   \n\
3442    exit_msg = '*** Back in main IPython ***'                                               \n\
3443                          \n\
3444# First import the embeddable shell class                                                   \n\
3445from IPython.Shell import IPShellEmbed                                                      \n\
3446# Now create the IPython shell instance. Put ipshell() anywhere in your code                \n\
3447# where you want it to open.                                                                \n\
3448ipshell = IPShellEmbed(argv,banner=banner,exit_msg=exit_msg)                                \n\
3449ipshell()");
3450        return FALSE;
3451      }
3452    }
3453    else
3454              */
3455
3456#endif
3457
3458// TODO: What about a dynamic module instead? Only Linux?
3459#ifdef HAVE_SINGULAR_PLUS_PLUS
3460  if (strcmp(sys_cmd,"Singular++")==0)
3461  {
3462//    using namespace SINGULAR_NS;
3463    extern BOOLEAN Main(leftv res, leftv h); // FALSE = Ok, TRUE = Error!
3464    return Main(res, h);
3465  }                           
3466  else
3467#endif // HAVE_SINGULAR_PLUS_PLUS
3468
3469    if (strcmp(sys_cmd,"FrankTest")==0)
3470  {
3471    PrintS("Hell Or Word!");
3472    return FALSE;
3473  };
3474
3475#ifdef HAVE_GFAN
3476/*======== GFAN ==============*/
3477/*
3478WILL HAVE TO CHANGE RETURN TYPE TO LIST_CMD
3479*/
3480if (strcmp(sys_cmd,"gfan")==0)
3481{
3482        if ((h==NULL) || (h!=NULL && h->Typ()!=IDEAL_CMD))
3483        {
3484                Werror("system(\"gfan\"...) Ideal expected");
3485                return TRUE; //Ooooops
3486        }
3487ideal I=((ideal)h->Data());
3488res->rtyp=IDEAL_CMD;
3489res->data=(ideal) gfan(I);
3490//res->rtyp=LIST_CMD;
3491//res->data= ???
3492
3493return FALSE; //Everything went fine
3494}
3495else
3496#endif
3497/*==================== Error =================*/
3498      Werror( "(extended) system(\"%s\",...) %s", sys_cmd, feNotImplemented );
3499  }
3500  return TRUE;
3501}
3502
3503#endif // HAVE_EXTENDED_SYSTEM
3504
3505
Note: See TracBrowser for help on using the repository browser.