source: git/Singular/extra.cc @ bb503c7

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