source: git/Singular/extra.cc @ 037df4

spielwiese
Last change on this file since 037df4 was 037df4, checked in by Hans Schönemann <hannes@…>, 15 years ago
*hannes: HAVE_SHIFTBBA git-svn-id: file:///usr/local/Singular/svn/trunk@10850 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 78.4 KB
Line 
1/*****************************************
2*  Computer Algebra System SINGULAR      *
3*****************************************/
4/* $Id: extra.cc,v 1.275 2008-07-08 13:03:18 Singular 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
57#ifdef HAVE_RINGS
58#include "ringgb.h"
59#endif
60
61
62#ifdef HAVE_F5
63#include "f5gb.h"
64#endif
65
66#ifdef HAVE_WALK
67#include "walk.h"
68#endif
69
70#include "weight.h"
71#include "fast_mult.h"
72#include "digitech.h"
73
74#ifdef HAVE_SPECTRUM
75#include "spectrum.h"
76#endif
77
78#ifdef HAVE_BIFAC
79#include <bifac.h>
80#endif
81
82#if defined(HPUX_10) || defined(HPUX_9)
83extern "C" int setenv(const char *name, const char *value, int overwrite);
84#endif
85
86#ifdef HAVE_PLURAL
87#include "ring.h"
88#include "gring.h"
89#include "sca.h"
90#include "ipconv.h"
91#include "ratgring.h"
92#endif
93
94#ifdef ix86_Win /* only for the DLLTest */
95/* #include "WinDllTest.h" */
96#ifdef HAVE_DL
97#include "mod_raw.h"
98#endif
99#endif
100
101// for tests of t-rep-GB
102#include "tgb.h"
103
104// Define to enable many more system commands
105#undef MAKE_DISTRIBUTION
106#ifndef MAKE_DISTRIBUTION
107#define HAVE_EXTENDED_SYSTEM 1
108#endif
109
110#ifdef HAVE_FACTORY
111#define SI_DONT_HAVE_GLOBAL_VARS
112#include "clapsing.h"
113#include "clapconv.h"
114#include "kstdfac.h"
115#endif
116
117#include "silink.h"
118#include "walk.h"
119
120#include "fast_maps.h"
121
122#include "shiftgb.h"
123
124#ifdef HAVE_EIGENVAL
125#include "eigenval_ip.h"
126#endif
127
128#ifdef HAVE_GMS
129#include "gms.h"
130#endif
131
132/*
133 *   New function/system-calls that will be included as dynamic module
134 * should be inserted here.
135 * - without HAVE_DYNAMIC_LOADING: these functions comes as system("....");
136 * - with    HAVE_DYNAMIC_LOADING: these functions are loaded as module.
137 */
138//#ifndef HAVE_DYNAMIC_LOADING
139
140#ifdef HAVE_PCV
141#include "pcv.h"
142#endif
143
144//#endif /* not HAVE_DYNAMIC_LOADING */
145
146#ifdef ix86_Win
147//#include <Python.h>
148//#include <python_wrapper.h>
149#endif
150
151
152// see clapsing.cc for a description of the `FACTORY_*' options
153
154#ifdef FACTORY_GCD_STAT
155#include "gcd_stat.h"
156#endif
157
158#ifdef FACTORY_GCD_TIMING
159#define TIMING
160#include "timing.h"
161TIMING_DEFINE_PRINTPROTO( contentTimer );
162TIMING_DEFINE_PRINTPROTO( algContentTimer );
163TIMING_DEFINE_PRINTPROTO( algLcmTimer );
164#endif
165
166void piShowProcList();
167#ifndef MAKE_DISTRIBUTION
168static BOOLEAN jjEXTENDED_SYSTEM(leftv res, leftv h);
169#endif
170
171extern BOOLEAN jjJanetBasis(leftv res, leftv v);
172
173#ifdef ix86_Win  /* PySingular initialized? */
174static int PyInitialized = 0;
175#endif
176
177int singular_homog_flag=1;
178
179//void emStart();
180/*2
181*  the "system" command
182*/
183BOOLEAN jjSYSTEM(leftv res, leftv args)
184{
185  if(args->Typ() == STRING_CMD)
186  {
187    const char *sys_cmd=(char *)(args->Data());
188    leftv h=args->next;
189// ONLY documented system calls go here
190// Undocumented system calls go down into #ifdef HAVE_EXTENDED_SYSTEM
191/*==================== nblocks ==================================*/
192    if (strcmp(sys_cmd, "nblocks") == 0)
193    {
194      ring r;
195      if (h == NULL)
196      {
197        if (currRingHdl != NULL)
198        {
199          r = IDRING(currRingHdl);
200        }
201        else
202        {
203          WerrorS("no ring active");
204          return TRUE;
205        }
206      }
207      else
208      {
209        if (h->Typ() != RING_CMD)
210        {
211          WerrorS("ring expected");
212          return TRUE;
213        }
214        r = (ring) h->Data();
215      }
216      res->rtyp = INT_CMD;
217      res->data = (void*) (long)(rBlocks(r) - 1);
218      return FALSE;
219    }
220/*==================== version ==================================*/
221    if(strcmp(sys_cmd,"version")==0)
222    {
223      res->rtyp=INT_CMD;
224      res->data=(void *)SINGULAR_VERSION;
225      return FALSE;
226    }
227    else
228
229
230
231
232/*==================== gen ==================================*/
233    if(strcmp(sys_cmd,"gen")==0)
234    {
235      res->rtyp=INT_CMD;
236      res->data=(void *)(long)npGen;
237      return FALSE;
238    }
239    else
240/*==================== sh ==================================*/
241    if(strcmp(sys_cmd,"sh")==0)
242    {
243      res->rtyp=INT_CMD;
244      if (h==NULL) res->data = (void *)(long) system("sh");
245      else if (h->Typ()==STRING_CMD)
246        res->data = (void*)(long) system((char*)(h->Data()));
247      else
248        WerrorS("string expected");
249      return FALSE;
250    }
251    else
252/*==================== uname ==================================*/
253    if(strcmp(sys_cmd,"uname")==0)
254    {
255      res->rtyp=STRING_CMD;
256      res->data = omStrDup(S_UNAME);
257      return FALSE;
258    }
259    else
260/*==================== with ==================================*/
261    if(strcmp(sys_cmd,"with")==0)
262    {
263      if (h==NULL)
264      {
265        res->rtyp=STRING_CMD;
266        res->data=(void *)omStrDup(versionString());
267        return FALSE;
268      }
269      else if (h->Typ()==STRING_CMD)
270      {
271        #define TEST_FOR(A) if(strcmp(s,A)==0) res->data=(void *)1; else
272        char *s=(char *)h->Data();
273        res->rtyp=INT_CMD;
274        #ifdef HAVE_DBM
275          TEST_FOR("DBM")
276        #endif
277        #ifdef HAVE_DLD
278          TEST_FOR("DLD")
279        #endif
280        #ifdef HAVE_FACTORY
281          TEST_FOR("factory")
282        #endif
283        #ifdef HAVE_LIBFAC_P
284          TEST_FOR("libfac")
285        #endif
286        #ifdef HAVE_MPSR
287          TEST_FOR("MP")
288        #endif
289        #ifdef HAVE_READLINE
290          TEST_FOR("readline")
291        #endif
292        #ifdef HAVE_TCL
293          TEST_FOR("tcl")
294        #endif
295        #ifdef TEST_MAC_ORDER
296          TEST_FOR("MAC_ORDER");
297        #endif
298        #ifdef HAVE_NS
299          TEST_FOR("Namespaces");
300        #endif
301        #ifdef HAVE_DYNAMIC_LOADING
302          TEST_FOR("DynamicLoading");
303        #endif
304        #ifdef HAVE_EIGENVAL
305          TEST_FOR("eigenval");
306        #endif
307        #ifdef HAVE_GMS
308          TEST_FOR("gms");
309        #endif
310          ;
311        return FALSE;
312        #undef TEST_FOR
313      }
314      return TRUE;
315    }
316    else
317/*==================== browsers ==================================*/
318    if (strcmp(sys_cmd,"browsers")==0)
319    {
320      res->rtyp = STRING_CMD;
321      char* b = StringSetS("");
322      feStringAppendBrowsers(0);
323      res->data = omStrDup(b);
324      return FALSE;
325    }
326    else
327/*==================== pid ==================================*/
328    if (strcmp(sys_cmd,"pid")==0)
329    {
330      res->rtyp=INT_CMD;
331      res->data=(void *)(long) getpid();
332      return FALSE;
333    }
334    else
335/*==================== getenv ==================================*/
336    if (strcmp(sys_cmd,"getenv")==0)
337    {
338      if ((h!=NULL) && (h->Typ()==STRING_CMD))
339      {
340        res->rtyp=STRING_CMD;
341        const char *r=getenv((char *)h->Data());
342        if (r==NULL) r="";
343        res->data=(void *)omStrDup(r);
344        return FALSE;
345      }
346      else
347      {
348        WerrorS("string expected");
349        return TRUE;
350      }
351    }
352    else
353/*==================== setenv ==================================*/
354    if (strcmp(sys_cmd,"setenv")==0)
355    {
356#ifdef HAVE_SETENV
357      if (h!=NULL && h->Typ()==STRING_CMD && h->Data() != NULL &&
358          h->next != NULL && h->next->Typ() == STRING_CMD
359          && h->next->Data() != NULL)
360      {
361        res->rtyp=STRING_CMD;
362        setenv((char *)h->Data(), (char *)h->next->Data(), 1);
363        res->data=(void *)omStrDup((char *)h->next->Data());
364        feReInitResources();
365        return FALSE;
366      }
367      else
368      {
369        WerrorS("two strings expected");
370        return TRUE;
371      }
372#else
373      WerrorS("setenv not supported on this platform");
374      return TRUE;
375#endif
376    }
377    else
378/*==================== Singular ==================================*/
379    if (strcmp(sys_cmd, "Singular") == 0)
380    {
381      res->rtyp=STRING_CMD;
382      const char *r=feResource("Singular");
383      if (r == NULL) r="";
384      res->data = (void*) omStrDup( r );
385      return FALSE;
386    }
387    else
388    if (strcmp(sys_cmd, "SingularLib") == 0)
389    {
390      res->rtyp=STRING_CMD;
391      const char *r=feResource("SearchPath");
392      if (r == NULL) r="";
393      res->data = (void*) omStrDup( r );
394      return FALSE;
395    }
396    else
397/*==================== options ==================================*/
398    if (strstr(sys_cmd, "--") == sys_cmd)
399    {
400      if (strcmp(sys_cmd, "--") == 0)
401      {
402        fePrintOptValues();
403        return FALSE;
404      }
405
406      feOptIndex opt = feGetOptIndex(&sys_cmd[2]);
407      if (opt == FE_OPT_UNDEF)
408      {
409        Werror("Unknown option %s", sys_cmd);
410        Werror("Use 'system(\"--\");' for listing of available options");
411        return TRUE;
412      }
413
414      // for Untyped Options (help version),
415      // setting it just triggers action
416      if (feOptSpec[opt].type == feOptUntyped)
417      {
418        feSetOptValue(opt,0);
419        return FALSE;
420      }
421
422      if (h == NULL)
423      {
424        if (feOptSpec[opt].type == feOptString)
425        {
426          res->rtyp = STRING_CMD;
427          const char *r=(const char*)feOptSpec[opt].value;
428          if (r == NULL) r="";
429          res->data = omStrDup(r);
430        }
431        else
432        {
433          res->rtyp = INT_CMD;
434          res->data = feOptSpec[opt].value;
435        }
436        return FALSE;
437      }
438
439      if (h->Typ() != STRING_CMD &&
440          h->Typ() != INT_CMD)
441      {
442        Werror("Need string or int argument to set option value");
443        return TRUE;
444      }
445      char* errormsg;
446      if (h->Typ() == INT_CMD)
447      {
448        if (feOptSpec[opt].type == feOptString)
449        {
450          Werror("Need string argument to set value of option %s", sys_cmd);
451          return TRUE;
452        }
453        errormsg = feSetOptValue(opt, (int)((long) h->Data()));
454        if (errormsg != NULL)
455          Werror("Option '--%s=%d' %s", sys_cmd, (int) ((long)h->Data()), errormsg);
456      }
457      else
458      {
459        errormsg = feSetOptValue(opt, (char*) h->Data());
460        if (errormsg != NULL)
461          Werror("Option '--%s=%s' %s", sys_cmd, (char*) h->Data(), errormsg);
462      }
463      if (errormsg != NULL) return TRUE;
464      return FALSE;
465    }
466    else
467/*==================== HC ==================================*/
468    if (strcmp(sys_cmd,"HC")==0)
469    {
470      res->rtyp=INT_CMD;
471      res->data=(void *)(long) HCord;
472      return FALSE;
473    }
474    else
475/*==================== random ==================================*/
476    if(strcmp(sys_cmd,"random")==0)
477    {
478      if ((h!=NULL) &&(h->Typ()==INT_CMD))
479      {
480        siRandomStart=(int)((long)h->Data());
481#ifdef buildin_rand
482        siSeed=siRandomStart;
483#else
484        srand((unsigned int)siRandomStart);
485#endif
486#ifdef HAVE_FACTORY
487        factoryseed(siRandomStart);
488#endif
489        return FALSE;
490      }
491      else if (h != NULL)
492      {
493        WerrorS("int expected");
494        return TRUE;
495      }
496      res->rtyp=INT_CMD;
497      res->data=(void*)(long) siRandomStart;
498      return FALSE;
499    }
500/*==================== complexNearZero ======================*/
501    if(strcmp(sys_cmd,"complexNearZero")==0)
502    {
503      if (h->Typ()==NUMBER_CMD )
504      {
505        if ( h->next!=NULL && h->next->Typ()==INT_CMD )
506        {
507          if ( !rField_is_long_C() )
508            {
509              Werror( "unsupported ground field!");
510              return TRUE;
511            }
512          else
513            {
514              res->rtyp=INT_CMD;
515              res->data=(void*)complexNearZero((gmp_complex*)h->Data(),
516                             (int)((long)(h->next->Data())));
517              return FALSE;
518            }
519        }
520        else
521        {
522          Werror( "expected <int> as third parameter!");
523          return TRUE;
524        }
525      }
526      else
527      {
528        Werror( "expected <number> as second parameter!");
529        return TRUE;
530      }
531    }
532/*==================== getPrecDigits ======================*/
533    if(strcmp(sys_cmd,"getPrecDigits")==0)
534    {
535      if ( !rField_is_long_C() && !rField_is_long_R() )
536      {
537        Werror( "unsupported ground field!");
538        return TRUE;
539      }
540      res->rtyp=INT_CMD;
541      res->data=(void*)getGMPFloatDigits();
542      return FALSE;
543    }
544/*==================== neworder =============================*/
545// should go below
546#ifdef HAVE_LIBFAC_P
547    if(strcmp(sys_cmd,"neworder")==0)
548    {
549      if ((h!=NULL) &&(h->Typ()==IDEAL_CMD))
550      {
551        res->rtyp=STRING_CMD;
552        res->data=(void *)singclap_neworder((ideal)h->Data());
553        return FALSE;
554      }
555      else
556        WerrorS("ideal expected");
557    }
558    else
559#endif
560//#ifndef HAVE_DYNAMIC_LOADING
561/*==================== pcv ==================================*/
562#ifdef HAVE_PCV
563    if(strcmp(sys_cmd,"pcvLAddL")==0)
564    {
565      return pcvLAddL(res,h);
566    }
567    else
568    if(strcmp(sys_cmd,"pcvPMulL")==0)
569    {
570      return pcvPMulL(res,h);
571    }
572    else
573    if(strcmp(sys_cmd,"pcvMinDeg")==0)
574    {
575      return pcvMinDeg(res,h);
576    }
577    else
578    if(strcmp(sys_cmd,"pcvP2CV")==0)
579    {
580      return pcvP2CV(res,h);
581    }
582    else
583    if(strcmp(sys_cmd,"pcvCV2P")==0)
584    {
585      return pcvCV2P(res,h);
586    }
587    else
588    if(strcmp(sys_cmd,"pcvDim")==0)
589    {
590      return pcvDim(res,h);
591    }
592    else
593    if(strcmp(sys_cmd,"pcvBasis")==0)
594    {
595      return pcvBasis(res,h);
596    }
597    else
598#endif
599/*==================== eigenvalues ==================================*/
600#ifdef HAVE_EIGENVAL
601    if(strcmp(sys_cmd,"hessenberg")==0)
602    {
603      return evHessenberg(res,h);
604    }
605    else
606    if(strcmp(sys_cmd,"eigenvals")==0)
607    {
608      return evEigenvals(res,h);
609    }
610    else
611#endif
612/*==================== Gauss-Manin system ==================================*/
613#ifdef HAVE_GMS
614    if(strcmp(sys_cmd,"gmsnf")==0)
615    {
616      return gmsNF(res,h);
617    }
618    else
619#endif
620//#endif /* HAVE_DYNAMIC_LOADING */
621/*==================== contributors =============================*/
622   if(strcmp(sys_cmd,"contributors") == 0)
623   {
624     res->rtyp=STRING_CMD;
625     res->data=(void *)omStrDup(
626       "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");
627     return FALSE;
628   }
629   else
630/*==================== spectrum =============================*/
631   #ifdef HAVE_SPECTRUM
632   if(strcmp(sys_cmd,"spectrum") == 0)
633   {
634     if (h->Typ()!=POLY_CMD)
635     {
636       WerrorS("poly expected");
637       return TRUE;
638     }
639     if (h->next==NULL)
640       return spectrumProc(res,h);
641     if (h->next->Typ()!=INT_CMD)
642     {
643       WerrorS("poly,int expected");
644       return TRUE;
645     }
646     if(((long)h->next->Data())==1L)
647       return spectrumfProc(res,h);
648     return spectrumProc(res,h);
649   }
650   else
651/*==================== semic =============================*/
652   if(strcmp(sys_cmd,"semic") == 0)
653   {
654     if ((h->next!=NULL)
655     && (h->Typ()==LIST_CMD)
656     && (h->next->Typ()==LIST_CMD))
657     {
658       if (h->next->next==NULL)
659         return semicProc(res,h,h->next);
660       else if (h->next->next->Typ()==INT_CMD)
661         return semicProc3(res,h,h->next,h->next->next);
662     }
663     return TRUE;
664   }
665   else
666/*==================== spadd =============================*/
667   if(strcmp(sys_cmd,"spadd") == 0)
668   {
669     if ((h->next!=NULL)
670     && (h->Typ()==LIST_CMD)
671     && (h->next->Typ()==LIST_CMD))
672     {
673       if (h->next->next==NULL)
674         return spaddProc(res,h,h->next);
675     }
676     return TRUE;
677   }
678   else
679/*==================== spmul =============================*/
680   if(strcmp(sys_cmd,"spmul") == 0)
681   {
682     if ((h->next!=NULL)
683     && (h->Typ()==LIST_CMD)
684     && (h->next->Typ()==INT_CMD))
685     {
686       if (h->next->next==NULL)
687         return spmulProc(res,h,h->next);
688     }
689     return TRUE;
690   }
691   else
692#endif
693#ifdef HAVE_PLURAL
694/*==================== Approx_Step  =================*/
695     if (strcmp(sys_cmd, "astep") == 0)
696     {
697       ideal I;
698       if ((h!=NULL) && (h->Typ()==IDEAL_CMD))
699       {
700         I=(ideal)h->CopyD();
701         res->rtyp=IDEAL_CMD;
702         if (rIsPluralRing(currRing)) res->data=Approx_Step(I);
703         else res->data=I;
704         setFlag(res,FLAG_STD);
705       }
706       else return TRUE;
707       return FALSE;
708     }
709/*==================== PrintMat  =================*/
710    if (strcmp(sys_cmd, "PrintMat") == 0)
711    {
712        int a;
713        int b;
714        ring r;
715        int metric;
716        if ((h!=NULL) && (h->Typ()==INT_CMD))
717        {
718          a=(int)((long)(h->Data()));
719          h=h->next;
720        }
721        else return TRUE;
722        if ((h!=NULL) && (h->Typ()==INT_CMD))
723        {
724          b=(int)((long)(h->Data()));
725          h=h->next;
726        }
727        else return TRUE;
728        if ((h!=NULL) && (h->Typ()==RING_CMD))
729        {
730          r=(ring)h->Data();
731          h=h->next;
732        }
733        else return TRUE;
734        if ((h!=NULL) && (h->Typ()==INT_CMD))
735        {
736          metric=(int)((long)(h->Data()));
737        }
738        res->rtyp=MATRIX_CMD;
739        if (rIsPluralRing(r)) res->data=nc_PrintMat(a,b,r,metric);
740        else res->data=NULL;
741        return FALSE;
742      }
743/*==================== twostd  =================*/
744      if (strcmp(sys_cmd, "twostd") == 0)
745      {
746        ideal I;
747        if ((h!=NULL) && (h->Typ()==IDEAL_CMD))
748        {
749          I=(ideal)h->CopyD();
750          res->rtyp=IDEAL_CMD;
751          if (rIsPluralRing(currRing)) res->data=twostd(I);
752          else res->data=I;
753          setFlag(res,FLAG_TWOSTD);
754          setFlag(res,FLAG_STD);
755        }
756        else return TRUE;
757        return FALSE;
758      }
759/*==================== lie bracket =================*/
760    if (strcmp(sys_cmd, "bracket") == 0)
761    {
762      poly p;
763      poly q;
764      if ((h!=NULL) && (h->Typ()==POLY_CMD))
765      {
766        p=(poly)h->CopyD();
767        h=h->next;
768      }
769      else return TRUE;
770      if ((h!=NULL) && (h->Typ()==POLY_CMD))
771      {
772        q=(poly)h->Data();
773      }
774      else return TRUE;
775      res->rtyp=POLY_CMD;
776      if (rIsPluralRing(currRing))  res->data=nc_p_Bracket_qq(p,q);
777      else res->data=NULL;
778      return FALSE;
779    }
780    if(strcmp(sys_cmd,"NCUseExtensions")==0)
781    {
782      extern bool bUseExtensions;
783      res->rtyp=INT_CMD;
784      res->data=(void *)bUseExtensions;
785     
786      if ((h!=NULL) && (h->Typ()==INT_CMD))
787        bUseExtensions = (bool)((long)(h->Data()));
788     
789      return FALSE;
790    }   
791    if(strcmp(sys_cmd,"NCGetType")==0)
792    {
793      res->rtyp=INT_CMD;
794     
795      if( rIsPluralRing(currRing) )
796        res->data=(void *)ncRingType(currRing);
797      else
798        res->data=(void *)(-1);
799     
800      return FALSE;
801    }
802
803    if(strcmp(sys_cmd,"ForceSCA")==0)
804    {
805      if( !rIsPluralRing(currRing) )
806        return TRUE;
807
808      int b, e;
809     
810      if ((h!=NULL) && (h->Typ()==INT_CMD))
811      {
812        b = (int)((long)(h->Data()));
813        h=h->next;
814      } 
815      else return TRUE;
816 
817      if ((h!=NULL) && (h->Typ()==INT_CMD))
818      {
819        e = (int)((long)(h->Data()));
820      } 
821      else return TRUE;
822
823
824      if( !sca_Force(currRing, b, e) )
825        return TRUE;
826
827      return FALSE;
828    }
829/*==================== PLURAL =================*/
830/*==================== opp ==================================*/
831    if (strcmp(sys_cmd, "opp")==0)
832    {
833      if ((h!=NULL) && (h->Typ()==RING_CMD))
834      {
835        ring r=(ring)h->Data();
836        res->data=rOpposite(r);
837        res->rtyp=RING_CMD;
838        return FALSE;
839      }
840      else
841      {
842        WerrorS("`system(\"opp\",<ring>)` expected");
843        return TRUE;
844      }
845    }
846    else
847/*==================== env ==================================*/
848    if (strcmp(sys_cmd, "env")==0)
849    {
850      if ((h!=NULL) && (h->Typ()==RING_CMD))
851      {
852        ring r = (ring)h->Data();
853        res->data = rEnvelope(r);
854        res->rtyp = RING_CMD;
855        return FALSE;
856      }
857      else
858      {
859        WerrorS("`system(\"env\",<ring>)` expected");
860        return TRUE;
861      }
862    }
863    else
864/*==================== oppose ==================================*/
865    if (strcmp(sys_cmd, "oppose")==0)
866    {
867      ring Rop;
868      if ((h!=NULL) && (h->Typ()==RING_CMD))
869      {
870        Rop = (ring)h->Data();
871        h   = h->next;
872      }
873      if ((h!=NULL))
874      {
875        idhdl w;
876        if ((w=Rop->idroot->get(h->Name(),myynest))!=NULL)
877        {
878          poly p = (poly)IDDATA(w);
879          res->data = pOppose(Rop,p);
880          res->rtyp = POLY_CMD;
881          return FALSE;
882        }
883       }
884      else
885      {
886        WerrorS("`system(\"oppose\",<ring>,<poly>)` expected");
887        return TRUE;
888      }
889    }
890    else
891#endif
892#ifdef HAVE_WALK
893/*==================== walk stuff =================*/
894#ifdef OWNW
895    if (strcmp(sys_cmd, "walkNextWeight") == 0)
896    {
897      if (h == NULL || h->Typ() != INTVEC_CMD ||
898          h->next == NULL || h->next->Typ() != INTVEC_CMD ||
899          h->next->next == NULL || h->next->next->Typ() != IDEAL_CMD)
900      {
901        Werror("system(\"walkNextWeight\", intvec, intvec, ideal) expected");
902        return TRUE;
903      }
904
905      if (((intvec*) h->Data())->length() != currRing->N ||
906          ((intvec*) h->next->Data())->length() != currRing->N)
907      {
908        Werror("system(\"walkNextWeight\" ...) intvecs not of length %d\n",
909               currRing->N);
910        return TRUE;
911      }
912      res->data = (void*) walkNextWeight(((intvec*) h->Data()),
913                                         ((intvec*) h->next->Data()),
914                                         (ideal) h->next->next->Data());
915      if (res->data == (void*) 0 || res->data == (void*) 1)
916      {
917        res->rtyp = INT_CMD;
918      }
919      else
920      {
921        res->rtyp = INTVEC_CMD;
922      }
923      return FALSE;
924    }
925    else if (strcmp(sys_cmd, "walkInitials") == 0)
926    {
927      if (h == NULL || h->Typ() != IDEAL_CMD)
928      {
929        WerrorS("system(\"walkInitials\", ideal) expected");
930        return TRUE;
931      }
932
933      res->data = (void*) walkInitials((ideal) h->Data());
934      res->rtyp = IDEAL_CMD;
935      return FALSE;
936    }
937    else
938#endif
939#ifdef WAIV
940    if (strcmp(sys_cmd, "walkAddIntVec") == 0)
941    {
942      if (h == NULL || h->Typ() != INTVEC_CMD ||
943          h->next == NULL || h->next->Typ() != INTVEC_CMD)
944      {
945        WerrorS("system(\"walkAddIntVec\", intvec, intvec) expected");
946        return TRUE;
947      }
948      intvec* arg1 = (intvec*) h->Data();
949      intvec* arg2 = (intvec*) h->next->Data();
950
951
952      res->data = (intvec*) walkAddIntVec(arg1, arg2);
953      res->rtyp = INTVEC_CMD;
954      return FALSE;
955    }
956    else
957#endif
958#ifdef MwaklNextWeight
959    if (strcmp(sys_cmd, "MwalkNextWeight") == 0)
960    {
961      if (h == NULL || h->Typ() != INTVEC_CMD ||
962          h->next == NULL || h->next->Typ() != INTVEC_CMD ||
963          h->next->next == NULL || h->next->next->Typ() != IDEAL_CMD)
964      {
965        Werror("system(\"MwalkNextWeight\", intvec, intvec, ideal) expected");
966        return TRUE;
967      }
968
969      if (((intvec*) h->Data())->length() != currRing->N ||
970          ((intvec*) h->next->Data())->length() != currRing->N)
971      {
972        Werror("system(\"MwalkNextWeight\" ...) intvecs not of length %d\n",
973               currRing->N);
974        return TRUE;
975      }
976      intvec* arg1 = (intvec*) h->Data();
977      intvec* arg2 = (intvec*) h->next->Data();
978      ideal arg3   =   (ideal) h->next->next->Data();
979
980      intvec* result = (intvec*) MwalkNextWeight(arg1, arg2, arg3);
981
982      res->rtyp = INTVEC_CMD;
983      res->data =  result;
984
985      return FALSE;
986    }
987    else
988#endif //MWalkNextWeight
989    if(strcmp(sys_cmd, "Mivdp") == 0)
990    {
991      if (h == NULL || h->Typ() != INT_CMD)
992      {
993        Werror("system(\"Mivdp\", int) expected");
994        return TRUE;
995      }
996      if ((int) ((long)(h->Data())) != currRing->N)
997      {
998        Werror("system(\"Mivdp\" ...) intvecs not of length %d\n",
999               currRing->N);
1000        return TRUE;
1001      }
1002      int arg1 = (int) ((long)(h->Data()));
1003
1004      intvec* result = (intvec*) Mivdp(arg1);
1005
1006      res->rtyp = INTVEC_CMD;
1007      res->data =  result;
1008
1009      return FALSE;
1010    }
1011
1012    else if(strcmp(sys_cmd, "Mivlp") == 0)
1013    {
1014      if (h == NULL || h->Typ() != INT_CMD)
1015      {
1016        Werror("system(\"Mivlp\", int) expected");
1017        return TRUE;
1018      }
1019      if ((int) ((long)(h->Data())) != currRing->N)
1020      {
1021        Werror("system(\"Mivlp\" ...) intvecs not of length %d\n",
1022               currRing->N);
1023        return TRUE;
1024      }
1025      int arg1 = (int) ((long)(h->Data()));
1026
1027      intvec* result = (intvec*) Mivlp(arg1);
1028
1029      res->rtyp = INTVEC_CMD;
1030      res->data =  result;
1031
1032      return FALSE;
1033    }
1034   else
1035#ifdef MpDiv
1036      if(strcmp(sys_cmd, "MpDiv") == 0)
1037      {
1038        if(h==NULL || h->Typ() != POLY_CMD ||
1039           h->next == NULL || h->next->Typ() != POLY_CMD)
1040        {
1041          Werror("system(\"MpDiv\",poly, poly) expected");
1042          return TRUE;
1043        }
1044        poly arg1 = (poly) h->Data();
1045        poly arg2 = (poly) h->next->Data();
1046
1047        poly result = MpDiv(arg1, arg2);
1048
1049        res->rtyp = POLY_CMD;
1050        res->data = result;
1051        return FALSE;
1052      }
1053    else
1054#endif
1055#ifdef MpMult
1056      if(strcmp(sys_cmd, "MpMult") == 0)
1057      {
1058        if(h==NULL || h->Typ() != POLY_CMD ||
1059           h->next == NULL || h->next->Typ() != POLY_CMD)
1060        {
1061          Werror("system(\"MpMult\",poly, poly) expected");
1062          return TRUE;
1063        }
1064        poly arg1 = (poly) h->Data();
1065        poly arg2 = (poly) h->next->Data();
1066
1067        poly result = MpMult(arg1, arg2);
1068        res->rtyp = POLY_CMD;
1069        res->data = result;
1070        return FALSE;
1071      }
1072  else
1073#endif
1074   if (strcmp(sys_cmd, "MivSame") == 0)
1075    {
1076      if(h == NULL || h->Typ() != INTVEC_CMD ||
1077         h->next == NULL || h->next->Typ() != INTVEC_CMD )
1078      {
1079        Werror("system(\"MivSame\", intvec, intvec) expected");
1080        return TRUE;
1081      }
1082      /*
1083      if (((intvec*) h->Data())->length() != currRing->N ||
1084          ((intvec*) h->next->Data())->length() != currRing->N)
1085      {
1086        Werror("system(\"MivSame\" ...) intvecs not of length %d\n",
1087               currRing->N);
1088        return TRUE;
1089      }
1090      */
1091      intvec* arg1 = (intvec*) h->Data();
1092      intvec* arg2 = (intvec*) h->next->Data();
1093      /*
1094      poly result = (poly) MivSame(arg1, arg2);
1095
1096      res->rtyp = POLY_CMD;
1097      res->data =  (poly) result;
1098      */
1099      res->rtyp = INT_CMD;
1100      res->data = (void*)(long) MivSame(arg1, arg2);
1101      return FALSE;
1102    }
1103  else
1104   if (strcmp(sys_cmd, "M3ivSame") == 0)
1105    {
1106      if(h == NULL || h->Typ() != INTVEC_CMD ||
1107         h->next == NULL || h->next->Typ() != INTVEC_CMD ||
1108         h->next->next == NULL || h->next->next->Typ() != INTVEC_CMD  )
1109      {
1110        Werror("system(\"M3ivSame\", intvec, intvec, intvec) expected");
1111        return TRUE;
1112      }
1113      /*
1114      if (((intvec*) h->Data())->length() != currRing->N ||
1115          ((intvec*) h->next->Data())->length() != currRing->N ||
1116          ((intvec*) h->next->next->Data())->length() != currRing->N )
1117      {
1118        Werror("system(\"M3ivSame\" ...) intvecs not of length %d\n",
1119               currRing->N);
1120        return TRUE;
1121      }
1122      */
1123      intvec* arg1 = (intvec*) h->Data();
1124      intvec* arg2 = (intvec*) h->next->Data();
1125      intvec* arg3 = (intvec*) h->next->next->Data();
1126      /*
1127      poly result = (poly) M3ivSame(arg1, arg2, arg3);
1128
1129      res->rtyp = POLY_CMD;
1130      res->data =  (poly) result;
1131      */
1132      res->rtyp = INT_CMD;
1133      res->data = (void*)(long) M3ivSame(arg1, arg2, arg3);
1134      return FALSE;
1135    }
1136  else
1137      if(strcmp(sys_cmd, "MwalkInitialForm") == 0)
1138      {
1139        if(h == NULL || h->Typ() != IDEAL_CMD ||
1140           h->next == NULL || h->next->Typ() != INTVEC_CMD)
1141        {
1142          Werror("system(\"MwalkInitialForm\", ideal, intvec) expected");
1143          return TRUE;
1144        }
1145        if(((intvec*) h->next->Data())->length() != currRing->N)
1146        {
1147          Werror("system \"MwalkInitialForm\"...) intvec not of length %d\n",
1148                 currRing->N);
1149          return TRUE;
1150        }
1151        ideal id      = (ideal) h->Data();
1152        intvec* int_w = (intvec*) h->next->Data();
1153        ideal result  = (ideal) MwalkInitialForm(id, int_w);
1154
1155        res->rtyp = IDEAL_CMD;
1156        res->data = result;
1157        return FALSE;
1158      }
1159  else
1160    /************** Perturbation walk **********/
1161     if(strcmp(sys_cmd, "MivMatrixOrder") == 0)
1162      {
1163        if(h==NULL || h->Typ() != INTVEC_CMD)
1164        {
1165          Werror("system(\"MivMatrixOrder\",intvec) expected");
1166          return TRUE;
1167        }
1168        intvec* arg1 = (intvec*) h->Data();
1169
1170        intvec* result = MivMatrixOrder(arg1);
1171
1172        res->rtyp = INTVEC_CMD;
1173        res->data =  result;
1174        return FALSE;
1175      }
1176    else
1177     if(strcmp(sys_cmd, "MivMatrixOrderdp") == 0)
1178      {
1179        if(h==NULL || h->Typ() != INT_CMD)
1180        {
1181          Werror("system(\"MivMatrixOrderdp\",intvec) expected");
1182          return TRUE;
1183        }
1184        int arg1 = (int) ((long)(h->Data()));
1185
1186        intvec* result = (intvec*) MivMatrixOrderdp(arg1);
1187
1188        res->rtyp = INTVEC_CMD;
1189        res->data =  result;
1190        return FALSE;
1191      }
1192    else
1193    if(strcmp(sys_cmd, "MPertVectors") == 0)
1194      {
1195
1196        if(h==NULL || h->Typ() != IDEAL_CMD ||
1197           h->next == NULL || h->next->Typ() != INTVEC_CMD ||
1198           h->next->next == NULL || h->next->next->Typ() != INT_CMD)
1199        {
1200          Werror("system(\"MPertVectors\",ideal, intvec, int) expected");
1201          return TRUE;
1202        }
1203
1204        ideal arg1 = (ideal) h->Data();
1205        intvec* arg2 = (intvec*) h->next->Data();
1206        int arg3 = (int) ((long)(h->next->next->Data()));
1207
1208        intvec* result = (intvec*) MPertVectors(arg1, arg2, arg3);
1209
1210        res->rtyp = INTVEC_CMD;
1211        res->data =  result;
1212        return FALSE;
1213      }
1214    else
1215    if(strcmp(sys_cmd, "MPertVectorslp") == 0)
1216      {
1217
1218        if(h==NULL || h->Typ() != IDEAL_CMD ||
1219           h->next == NULL || h->next->Typ() != INTVEC_CMD ||
1220           h->next->next == NULL || h->next->next->Typ() != INT_CMD)
1221        {
1222          Werror("system(\"MPertVectorslp\",ideal, intvec, int) expected");
1223          return TRUE;
1224        }
1225
1226        ideal arg1 = (ideal) h->Data();
1227        intvec* arg2 = (intvec*) h->next->Data();
1228        int arg3 = (int) ((long)(h->next->next->Data()));
1229
1230        intvec* result = (intvec*) MPertVectorslp(arg1, arg2, arg3);
1231
1232        res->rtyp = INTVEC_CMD;
1233        res->data =  result;
1234        return FALSE;
1235      }
1236        /************** fractal walk **********/
1237    else
1238      if(strcmp(sys_cmd, "Mfpertvector") == 0)
1239      {
1240        if(h==NULL || h->Typ() != IDEAL_CMD ||
1241          h->next==NULL || h->next->Typ() != INTVEC_CMD  )
1242        {
1243          Werror("system(\"Mfpertvector\", ideal,intvec) expected");
1244          return TRUE;
1245        }
1246        ideal arg1 = (ideal) h->Data();
1247        intvec* arg2 = (intvec*) h->next->Data();
1248        intvec* result = Mfpertvector(arg1, arg2);
1249
1250        res->rtyp = INTVEC_CMD;
1251        res->data =  result;
1252        return FALSE;
1253      }
1254    else
1255     if(strcmp(sys_cmd, "MivUnit") == 0)
1256      {
1257        int arg1 = (int) ((long)(h->Data()));
1258
1259        intvec* result = (intvec*) MivUnit(arg1);
1260
1261        res->rtyp = INTVEC_CMD;
1262        res->data =  result;
1263        return FALSE;
1264      }
1265     else
1266       if(strcmp(sys_cmd, "MivWeightOrderlp") == 0)
1267       {
1268        if(h==NULL || h->Typ() != INTVEC_CMD)
1269        {
1270          Werror("system(\"MivWeightOrderlp\",intvec) expected");
1271          return TRUE;
1272        }
1273        intvec* arg1 = (intvec*) h->Data();
1274        intvec* result = MivWeightOrderlp(arg1);
1275
1276        res->rtyp = INTVEC_CMD;
1277        res->data =  result;
1278        return FALSE;
1279      }
1280     else
1281    if(strcmp(sys_cmd, "MivWeightOrderdp") == 0)
1282      {
1283        if(h==NULL || h->Typ() != INTVEC_CMD)
1284        {
1285          Werror("system(\"MivWeightOrderdp\",intvec) expected");
1286          return TRUE;
1287        }
1288        intvec* arg1 = (intvec*) h->Data();
1289        //int arg2 = (int) h->next->Data();
1290
1291        intvec* result = MivWeightOrderdp(arg1);
1292
1293        res->rtyp = INTVEC_CMD;
1294        res->data =  result;
1295        return FALSE;
1296      }
1297    else
1298     if(strcmp(sys_cmd, "MivMatrixOrderlp") == 0)
1299      {
1300        if(h==NULL || h->Typ() != INT_CMD)
1301        {
1302          Werror("system(\"MivMatrixOrderlp\",int) expected");
1303          return TRUE;
1304        }
1305        int arg1 = (int) ((long)(h->Data()));
1306
1307        intvec* result = (intvec*) MivMatrixOrderlp(arg1);
1308
1309        res->rtyp = INTVEC_CMD;
1310        res->data =  result;
1311        return FALSE;
1312      }
1313    else
1314    if (strcmp(sys_cmd, "MkInterRedNextWeight") == 0)
1315    {
1316      if (h == NULL || h->Typ() != INTVEC_CMD ||
1317          h->next == NULL || h->next->Typ() != INTVEC_CMD ||
1318          h->next->next == NULL || h->next->next->Typ() != IDEAL_CMD)
1319      {
1320        Werror("system(\"MkInterRedNextWeight\", intvec, intvec, ideal) expected");
1321        return TRUE;
1322      }
1323
1324      if (((intvec*) h->Data())->length() != currRing->N ||
1325          ((intvec*) h->next->Data())->length() != currRing->N)
1326      {
1327        Werror("system(\"MkInterRedNextWeight\" ...) intvecs not of length %d\n",
1328               currRing->N);
1329        return TRUE;
1330      }
1331      intvec* arg1 = (intvec*) h->Data();
1332      intvec* arg2 = (intvec*) h->next->Data();
1333      ideal arg3   =   (ideal) h->next->next->Data();
1334
1335      intvec* result = (intvec*) MkInterRedNextWeight(arg1, arg2, arg3);
1336
1337      res->rtyp = INTVEC_CMD;
1338      res->data =  result;
1339
1340      return FALSE;
1341    }
1342    else
1343#ifdef MPertNextWeight
1344    if (strcmp(sys_cmd, "MPertNextWeight") == 0)
1345    {
1346      if (h == NULL || h->Typ() != INTVEC_CMD ||
1347          h->next == NULL || h->next->Typ() != IDEAL_CMD ||
1348          h->next->next == NULL || h->next->next->Typ() != INT_CMD)
1349      {
1350        Werror("system(\"MPertNextWeight\", intvec, ideal, int) expected");
1351        return TRUE;
1352      }
1353
1354      if (((intvec*) h->Data())->length() != currRing->N)
1355      {
1356        Werror("system(\"MPertNextWeight\" ...) intvecs not of length %d\n",
1357               currRing->N);
1358        return TRUE;
1359      }
1360      intvec* arg1 = (intvec*) h->Data();
1361      ideal arg2 = (ideal) h->next->Data();
1362      int arg3   =   (int) h->next->next->Data();
1363
1364      intvec* result = (intvec*) MPertNextWeight(arg1, arg2, arg3);
1365
1366      res->rtyp = INTVEC_CMD;
1367      res->data =  result;
1368
1369      return FALSE;
1370    }
1371    else
1372#endif //MPertNextWeight
1373#ifdef Mivperttarget
1374  if (strcmp(sys_cmd, "Mivperttarget") == 0)
1375    {
1376      if (h == NULL || h->Typ() != IDEAL_CMD ||
1377          h->next == NULL || h->next->Typ() != INT_CMD )
1378      {
1379        Werror("system(\"Mivperttarget\", ideal, int) expected");
1380        return TRUE;
1381      }
1382
1383      ideal arg1 = (ideal) h->Data();
1384      int arg2 = (int) h->next->Data();
1385
1386      intvec* result = (intvec*) Mivperttarget(arg1, arg2);
1387
1388      res->rtyp = INTVEC_CMD;
1389      res->data =  result;
1390
1391      return FALSE;
1392    }
1393    else
1394#endif //Mivperttarget
1395    if (strcmp(sys_cmd, "Mwalk") == 0)
1396    {
1397      if (h == NULL || h->Typ() != IDEAL_CMD ||
1398          h->next == NULL || h->next->Typ() != INTVEC_CMD ||
1399          h->next->next == NULL || h->next->next->Typ() != INTVEC_CMD)
1400      {
1401        Werror("system(\"Mwalk\", ideal, intvec, intvec) expected");
1402        return TRUE;
1403      }
1404
1405      if (((intvec*) h->next->Data())->length() != currRing->N &&
1406          ((intvec*) h->next->next->Data())->length() != currRing->N )
1407      {
1408        Werror("system(\"Mwalk\" ...) intvecs not of length %d\n",
1409               currRing->N);
1410        return TRUE;
1411      }
1412      ideal arg1 = (ideal) h->Data();
1413      intvec* arg2 = (intvec*) h->next->Data();
1414      intvec* arg3   =  (intvec*) h->next->next->Data();
1415
1416
1417      ideal result = (ideal) Mwalk(arg1, arg2, arg3);
1418
1419      res->rtyp = IDEAL_CMD;
1420      res->data =  result;
1421
1422      return FALSE;
1423    }
1424    else
1425#ifdef MPWALK_ORIG
1426    if (strcmp(sys_cmd, "Mpwalk") == 0)
1427    {
1428      if (h == NULL || h->Typ() != IDEAL_CMD ||
1429          h->next == NULL || h->next->Typ() != INT_CMD ||
1430          h->next->next == NULL || h->next->next->Typ() != INT_CMD ||
1431          h->next->next->next == NULL ||
1432            h->next->next->next->Typ() != INTVEC_CMD ||
1433          h->next->next->next->next == NULL ||
1434            h->next->next->next->next->Typ() != INTVEC_CMD)
1435      {
1436        Werror("system(\"Mpwalk\", ideal, int, int, intvec, intvec) expected");
1437        return TRUE;
1438      }
1439
1440      if (((intvec*) h->next->next->next->Data())->length() != currRing->N &&
1441          ((intvec*) h->next->next->next->next->Data())->length()!=currRing->N)
1442      {
1443        Werror("system(\"Mpwalk\" ...) intvecs not of length %d\n",
1444               currRing->N);
1445        return TRUE;
1446      }
1447      ideal arg1 = (ideal) h->Data();
1448      int arg2 = (int) h->next->Data();
1449      int arg3 = (int) h->next->next->Data();
1450      intvec* arg4 = (intvec*) h->next->next->next->Data();
1451      intvec* arg5   =  (intvec*) h->next->next->next->next->Data();
1452
1453
1454      ideal result = (ideal) Mpwalk(arg1, arg2, arg3, arg4, arg5);
1455
1456      res->rtyp = IDEAL_CMD;
1457      res->data =  result;
1458
1459      return FALSE;
1460    }
1461    else
1462#endif
1463    if (strcmp(sys_cmd, "Mpwalk") == 0)
1464    {
1465      if (h == NULL || h->Typ() != IDEAL_CMD ||
1466          h->next == NULL || h->next->Typ() != INT_CMD ||
1467          h->next->next == NULL || h->next->next->Typ() != INT_CMD ||
1468          h->next->next->next == NULL ||
1469            h->next->next->next->Typ() != INTVEC_CMD ||
1470          h->next->next->next->next == NULL ||
1471            h->next->next->next->next->Typ() != INTVEC_CMD||
1472          h->next->next->next->next->next == NULL ||
1473            h->next->next->next->next->next->Typ() != INT_CMD)
1474      {
1475        Werror("system(\"Mpwalk\", ideal, int, int, intvec, intvec, int) expected");
1476        return TRUE;
1477      }
1478
1479      if (((intvec*) h->next->next->next->Data())->length() != currRing->N &&
1480          ((intvec*) h->next->next->next->next->Data())->length()!=currRing->N)
1481      {
1482        Werror("system(\"Mpwalk\" ...) intvecs not of length %d\n",
1483               currRing->N);
1484        return TRUE;
1485      }
1486      ideal arg1 = (ideal) h->Data();
1487      int arg2 = (int) ((long)(h->next->Data()));
1488      int arg3 = (int) ((long)(h->next->next->Data()));
1489      intvec* arg4 = (intvec*) h->next->next->next->Data();
1490      intvec* arg5   =  (intvec*) h->next->next->next->next->Data();
1491      int arg6   =  (int) ((long)(h->next->next->next->next->next->Data()));
1492
1493
1494      ideal result = (ideal) Mpwalk(arg1, arg2, arg3, arg4, arg5, arg6);
1495
1496      res->rtyp = IDEAL_CMD;
1497      res->data =  result;
1498
1499      return FALSE;
1500    }
1501    else
1502    if (strcmp(sys_cmd, "MAltwalk1") == 0)
1503    {
1504      if (h == NULL || h->Typ() != IDEAL_CMD ||
1505          h->next == NULL || h->next->Typ() != INT_CMD ||
1506          h->next->next == NULL || h->next->next->Typ() != INT_CMD ||
1507          h->next->next->next == NULL ||
1508            h->next->next->next->Typ() != INTVEC_CMD ||
1509          h->next->next->next->next == NULL ||
1510            h->next->next->next->next->Typ() != INTVEC_CMD)
1511      {
1512        Werror("system(\"MAltwalk1\", ideal, int, int, intvec, intvec) expected");
1513        return TRUE;
1514      }
1515
1516      if (((intvec*) h->next->next->next->Data())->length() != currRing->N &&
1517          ((intvec*) h->next->next->next->next->Data())->length()!=currRing->N)
1518      {
1519        Werror("system(\"MAltwalk1\" ...) intvecs not of length %d\n",
1520               currRing->N);
1521        return TRUE;
1522      }
1523      ideal arg1 = (ideal) h->Data();
1524      int arg2 = (int) ((long)(h->next->Data()));
1525      int arg3 = (int) ((long)(h->next->next->Data()));
1526      intvec* arg4 = (intvec*) h->next->next->next->Data();
1527      intvec* arg5   =  (intvec*) h->next->next->next->next->Data();
1528
1529
1530      ideal result = (ideal) MAltwalk1(arg1, arg2, arg3, arg4, arg5);
1531
1532      res->rtyp = IDEAL_CMD;
1533      res->data =  result;
1534
1535      return FALSE;
1536    }
1537#ifdef MFWALK_ALT
1538    else
1539    if (strcmp(sys_cmd, "Mfwalk_alt") == 0)
1540    {
1541      if (h == NULL || h->Typ() != IDEAL_CMD ||
1542          h->next == NULL || h->next->Typ() != INTVEC_CMD ||
1543          h->next->next == NULL || h->next->next->Typ() != INTVEC_CMD ||
1544          h->next->next->next == NULL || h->next->next->next->Typ() !=INT_CMD)
1545      {
1546        Werror("system(\"Mfwalk\", ideal, intvec, intvec,int) expected");
1547        return TRUE;
1548      }
1549
1550      if (((intvec*) h->next->Data())->length() != currRing->N &&
1551          ((intvec*) h->next->next->Data())->length() != currRing->N )
1552      {
1553        Werror("system(\"Mfwalk\" ...) intvecs not of length %d\n",
1554               currRing->N);
1555        return TRUE;
1556      }
1557      ideal arg1 = (ideal) h->Data();
1558      intvec* arg2 = (intvec*) h->next->Data();
1559      intvec* arg3   =  (intvec*) h->next->next->Data();
1560      int arg4 = (int) h->next->next->next->Data();
1561
1562      ideal result = (ideal) Mfwalk_alt(arg1, arg2, arg3, arg4);
1563
1564      res->rtyp = IDEAL_CMD;
1565      res->data =  result;
1566
1567      return FALSE;
1568    }
1569#endif
1570    else
1571    if (strcmp(sys_cmd, "Mfwalk") == 0)
1572    {
1573      if (h == NULL || h->Typ() != IDEAL_CMD ||
1574          h->next == NULL || h->next->Typ() != INTVEC_CMD ||
1575          h->next->next == NULL || h->next->next->Typ() != INTVEC_CMD)
1576      {
1577        Werror("system(\"Mfwalk\", ideal, intvec, intvec) expected");
1578        return TRUE;
1579      }
1580
1581      if (((intvec*) h->next->Data())->length() != currRing->N &&
1582          ((intvec*) h->next->next->Data())->length() != currRing->N )
1583      {
1584        Werror("system(\"Mfwalk\" ...) intvecs not of length %d\n",
1585               currRing->N);
1586        return TRUE;
1587      }
1588      ideal arg1 = (ideal) h->Data();
1589      intvec* arg2 = (intvec*) h->next->Data();
1590      intvec* arg3   =  (intvec*) h->next->next->Data();
1591
1592      ideal result = (ideal) Mfwalk(arg1, arg2, arg3);
1593
1594      res->rtyp = IDEAL_CMD;
1595      res->data =  result;
1596
1597      return FALSE;
1598    }
1599    else
1600
1601#ifdef TRAN_Orig
1602    if (strcmp(sys_cmd, "TranMImprovwalk") == 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(\"TranMImprovwalk\", 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(\"TranMImprovwalk\" ...) 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) TranMImprovwalk(arg1, arg2, arg3);
1625
1626      res->rtyp = IDEAL_CMD;
1627      res->data =  result;
1628
1629      return FALSE;
1630    }
1631    else
1632#endif
1633    if (strcmp(sys_cmd, "MAltwalk2") == 0)
1634      {
1635      if (h == NULL || h->Typ() != IDEAL_CMD ||
1636          h->next == NULL || h->next->Typ() != INTVEC_CMD ||
1637          h->next->next == NULL || h->next->next->Typ() != INTVEC_CMD)
1638      {
1639        Werror("system(\"MAltwalk2\", ideal, intvec, intvec) expected");
1640        return TRUE;
1641      }
1642
1643      if (((intvec*) h->next->Data())->length() != currRing->N &&
1644          ((intvec*) h->next->next->Data())->length() != currRing->N )
1645      {
1646        Werror("system(\"MAltwalk2\" ...) intvecs not of length %d\n",
1647               currRing->N);
1648        return TRUE;
1649      }
1650      ideal arg1 = (ideal) h->Data();
1651      intvec* arg2 = (intvec*) h->next->Data();
1652      intvec* arg3   =  (intvec*) h->next->next->Data();
1653
1654
1655      ideal result = (ideal) MAltwalk2(arg1, arg2, arg3);
1656
1657      res->rtyp = IDEAL_CMD;
1658      res->data =  result;
1659
1660      return FALSE;
1661    }
1662    else
1663    if (strcmp(sys_cmd, "TranMImprovwalk") == 0)
1664    {
1665      if (h == NULL || h->Typ() != IDEAL_CMD ||
1666          h->next == NULL || h->next->Typ() != INTVEC_CMD ||
1667          h->next->next == NULL || h->next->next->Typ() != INTVEC_CMD||
1668          h->next->next->next == NULL || h->next->next->next->Typ() != INT_CMD)
1669      {
1670        Werror("system(\"TranMImprovwalk\", ideal, intvec, intvec, int) expected");
1671        return TRUE;
1672      }
1673
1674      if (((intvec*) h->next->Data())->length() != currRing->N &&
1675          ((intvec*) h->next->next->Data())->length() != currRing->N )
1676      {
1677        Werror("system(\"TranMImprovwalk\" ...) intvecs not of length %d\n",
1678               currRing->N);
1679        return TRUE;
1680      }
1681      ideal arg1 = (ideal) h->Data();
1682      intvec* arg2 = (intvec*) h->next->Data();
1683      intvec* arg3   =  (intvec*) h->next->next->Data();
1684      int arg4   =  (int) ((long)(h->next->next->next->Data()));
1685
1686      ideal result = (ideal) TranMImprovwalk(arg1, arg2, arg3, arg4);
1687
1688      res->rtyp = IDEAL_CMD;
1689      res->data =  result;
1690
1691      return FALSE;
1692    }
1693    else
1694#endif
1695/*================= Extended system call ========================*/
1696   {
1697     #ifndef MAKE_DISTRIBUTION
1698     return(jjEXTENDED_SYSTEM(res, args));
1699     #else
1700     Werror( "system(\"%s\",...) %s", sys_cmd, feNotImplemented );
1701     #endif
1702   }
1703  } /* typ==string */
1704  return TRUE;
1705}
1706
1707
1708#ifdef HAVE_EXTENDED_SYSTEM
1709// You can put your own system calls here
1710#include "../kernel/fglmcomb.cc"
1711#include "fglm.h"
1712#ifdef HAVE_NEWTON
1713#include <hc_newton.h>
1714#endif
1715#include "mpsr.h"
1716#include "mod_raw.h"
1717#include "ratgring.h"
1718#include "shiftgb.h"
1719
1720static BOOLEAN jjEXTENDED_SYSTEM(leftv res, leftv h)
1721{
1722  if(h->Typ() == STRING_CMD)
1723  {
1724    char *sys_cmd=(char *)(h->Data());
1725    h=h->next;
1726/*==================== locNF ======================================*/
1727    if(strcmp(sys_cmd,"locNF")==0)
1728    {
1729      if (h != NULL && h->Typ() == VECTOR_CMD)
1730      {
1731        poly f=(poly)h->Data();
1732        h=h->next;
1733        if (h != NULL && h->Typ() == MODUL_CMD)
1734        {
1735          ideal m=(ideal)h->Data();
1736          assumeStdFlag(h);
1737          h=h->next;
1738          if (h != NULL && h->Typ() == INT_CMD)
1739          {
1740            int n=(int)((long)h->Data());
1741            h=h->next;
1742            if (h != NULL && h->Typ() == INTVEC_CMD)
1743            {
1744              intvec *v=(intvec *)h->Data();
1745
1746              /* == now the work starts == */
1747
1748              short * iv=iv2array(v);
1749              poly r=0;
1750              poly hp=ppJetW(f,n,iv);
1751              int s=MATCOLS(m);
1752              int j=0;
1753              matrix T=mpInitI(s,1,0);
1754
1755              while (hp != NULL)
1756              {
1757                if (pDivisibleBy(m->m[j],hp))
1758                  {
1759                    if (MATELEM(T,j+1,1)==0)
1760                    {
1761                      MATELEM(T,j+1,1)=pDivideM(pHead(hp),pHead(m->m[j]));
1762                    }
1763                    else
1764                    {
1765                      pAdd(MATELEM(T,j+1,1),pDivideM(pHead(hp),pHead(m->m[j])));
1766                    }
1767                    hp=ppJetW(ksOldSpolyRed(m->m[j],hp,0),n,iv);
1768                    j=0;
1769                  }
1770                else
1771                {
1772                  if (j==s-1)
1773                  {
1774                    r=pAdd(r,pHead(hp));
1775                    hp=pLmDeleteAndNext(hp); /* hp=pSub(hp,pHead(hp));*/
1776                    j=0;
1777                  }
1778                  else
1779                  {
1780                    j++;
1781                  }
1782                }
1783              }
1784
1785              matrix Temp=mpTransp((matrix) idVec2Ideal(r));
1786              matrix R=mpNew(MATCOLS((matrix) idVec2Ideal(f)),1);
1787              for (int k=1;k<=MATROWS(Temp);k++)
1788              {
1789                MATELEM(R,k,1)=MATELEM(Temp,k,1);
1790              }
1791
1792              lists L=(lists)omAllocBin(slists_bin);
1793              L->Init(2);
1794              L->m[0].rtyp=MATRIX_CMD;   L->m[0].data=(void *)R;
1795              L->m[1].rtyp=MATRIX_CMD;   L->m[1].data=(void *)T;
1796              res->data=L;
1797              res->rtyp=LIST_CMD;
1798              // iv aufraeumen
1799              omFree(iv);
1800            }
1801            else
1802            {
1803              Warn ("4th argument: must be an intvec!");
1804            }
1805          }
1806          else
1807          {
1808            Warn("3rd argument must be an int!!");
1809          }
1810        }
1811        else
1812        {
1813          Warn("2nd argument must be a module!");
1814        }
1815      }
1816      else
1817      {
1818        Warn("1st argument must be a vector!");
1819      }
1820      return FALSE;
1821    }
1822    else
1823/*==================== interred ==================================*/
1824    #if 0
1825    if(strcmp(sys_cmd,"interred")==0)
1826    {
1827      res->data=(char *)kIR((ideal)h->Data(),currQuotient);
1828      res->rtyp=h->Typ();
1829      return ((h->Typ()!=IDEAL_CMD) && (h->Typ()!=MODUL_CMD));
1830    }
1831    else
1832    #endif
1833#ifdef RDEBUG
1834/*==================== poly debug ==================================*/
1835    if(strcmp(sys_cmd,"p")==0)
1836    {
1837      pDebugPrint((poly)h->Data());
1838      return FALSE;
1839    }
1840    else
1841/*==================== ring debug ==================================*/
1842    if(strcmp(sys_cmd,"r")==0)
1843    {
1844      rDebugPrint((ring)h->Data());
1845      return FALSE;
1846    }
1847    else
1848#endif
1849/*==================== mtrack ==================================*/
1850    if(strcmp(sys_cmd,"mtrack")==0)
1851    {
1852#ifdef OM_TRACK
1853      om_Opts.MarkAsStatic = 1;
1854      FILE *fd = NULL;
1855      int max = 5;
1856      while (h != NULL)
1857      {
1858        omMarkAsStaticAddr(h);
1859        if (fd == NULL && h->Typ()==STRING_CMD)
1860        {
1861          fd = fopen((char*) h->Data(), "w");
1862          if (fd == NULL)
1863            Warn("Can not open %s for writing og mtrack. Using stdout");
1864        }
1865        if (h->Typ() == INT_CMD)
1866        {
1867          max = (int)(long)h->Data();
1868        }
1869        h = h->Next();
1870      }
1871      omPrintUsedTrackAddrs((fd == NULL ? stdout : fd), max);
1872      if (fd != NULL) fclose(fd);
1873      om_Opts.MarkAsStatic = 0;
1874      return FALSE;
1875#else
1876     WerrorS("mtrack not supported without OM_TRACK");
1877     return TRUE;
1878#endif
1879    }
1880/*==================== mtrack_all ==================================*/
1881    if(strcmp(sys_cmd,"mtrack_all")==0)
1882    {
1883#ifdef OM_TRACK
1884      om_Opts.MarkAsStatic = 1;
1885      FILE *fd = NULL;
1886      if ((h!=NULL) &&(h->Typ()==STRING_CMD))
1887      {
1888        fd = fopen((char*) h->Data(), "w");
1889        if (fd == NULL)
1890          Warn("Can not open %s for writing og mtrack. Using stdout");
1891        omMarkAsStaticAddr(h);
1892      }
1893      // OB: TBC print to fd
1894      omPrintUsedAddrs((fd == NULL ? stdout : fd), 5);
1895      if (fd != NULL) fclose(fd);
1896      om_Opts.MarkAsStatic = 0;
1897      return FALSE;
1898#else
1899     WerrorS("mtrack not supported without OM_TRACK");
1900     return TRUE;
1901#endif
1902    }
1903    else
1904/*==================== backtrace ==================================*/
1905    if(strcmp(sys_cmd,"backtrace")==0)
1906    {
1907#ifndef OM_NDEBUG
1908      omPrintCurrentBackTrace(stdout);
1909      return FALSE;
1910#else
1911     WerrorS("btrack not supported without OM_TRACK");
1912     return TRUE;
1913#endif
1914    }
1915    else
1916/*==================== naIdeal ==================================*/
1917    if(strcmp(sys_cmd,"naIdeal")==0)
1918    {
1919      if ((h!=NULL) &&(h->Typ()==IDEAL_CMD))
1920      {
1921        naSetIdeal((ideal)h->Data());
1922        return FALSE;
1923      }
1924      else
1925         WerrorS("ideal expected");
1926    }
1927    else
1928/*==================== isSqrFree =============================*/
1929#ifdef HAVE_FACTORY
1930    if(strcmp(sys_cmd,"isSqrFree")==0)
1931    {
1932      if ((h!=NULL) &&(h->Typ()==POLY_CMD))
1933      {
1934        res->rtyp=INT_CMD;
1935        res->data=(void *)(long) singclap_isSqrFree((poly)h->Data());
1936        return FALSE;
1937      }
1938      else
1939        WerrorS("poly expected");
1940    }
1941    else
1942#endif
1943/*==================== pDivStat =============================*/
1944#if defined(PDEBUG) || defined(PDIV_DEBUG)
1945    if(strcmp(sys_cmd,"pDivStat")==0)
1946    {
1947      extern void pPrintDivisbleByStat();
1948      pPrintDivisbleByStat();
1949      return FALSE;
1950    }
1951    else
1952#endif
1953/*==================== alarm ==================================*/
1954#ifdef unix
1955    if(strcmp(sys_cmd,"alarm")==0)
1956    {
1957      if ((h!=NULL) &&(h->Typ()==INT_CMD))
1958      {
1959        // standard variant -> SIGALARM (standard: abort)
1960        //alarm((unsigned)h->next->Data());
1961        // process time (user +system): SIGVTALARM
1962        struct itimerval t,o;
1963        memset(&t,0,sizeof(t));
1964        t.it_value.tv_sec     =(unsigned)((unsigned long)h->Data());
1965        setitimer(ITIMER_VIRTUAL,&t,&o);
1966        return FALSE;
1967      }
1968      else
1969        WerrorS("int expected");
1970    }
1971    else
1972#endif
1973/*==================== red =============================*/
1974#if 0
1975    if(strcmp(sys_cmd,"red")==0)
1976    {
1977      if ((h!=NULL) &&(h->Typ()==IDEAL_CMD))
1978      {
1979        res->rtyp=IDEAL_CMD;
1980        res->data=(void *)kStdred((ideal)h->Data(),NULL,testHomog,NULL);
1981        setFlag(res,FLAG_STD);
1982        return FALSE;
1983      }
1984      else
1985        WerrorS("ideal expected");
1986    }
1987    else
1988#endif
1989#ifdef HAVE_FACTORY
1990/*==================== fastcomb =============================*/
1991    if(strcmp(sys_cmd,"fastcomb")==0)
1992    {
1993      if ((h!=NULL) &&(h->Typ()==IDEAL_CMD))
1994      {
1995        int i=0;
1996        if (h->next!=NULL)
1997        {
1998          if (h->next->Typ()!=POLY_CMD)
1999          {
2000            Warn("Wrong types for poly= comb(ideal,poly)");
2001          }
2002        }
2003        res->rtyp=POLY_CMD;
2004        res->data=(void *) fglmLinearCombination(
2005                           (ideal)h->Data(),(poly)h->next->Data());
2006        return FALSE;
2007      }
2008      else
2009        WerrorS("ideal expected");
2010    }
2011    else
2012/*==================== comb =============================*/
2013    if(strcmp(sys_cmd,"comb")==0)
2014    {
2015      if ((h!=NULL) &&(h->Typ()==IDEAL_CMD))
2016      {
2017        int i=0;
2018        if (h->next!=NULL)
2019        {
2020          if (h->next->Typ()!=POLY_CMD)
2021          {
2022              Warn("Wrong types for poly= comb(ideal,poly)");
2023          }
2024        }
2025        res->rtyp=POLY_CMD;
2026        res->data=(void *)fglmNewLinearCombination(
2027                            (ideal)h->Data(),(poly)h->next->Data());
2028        return FALSE;
2029      }
2030      else
2031        WerrorS("ideal expected");
2032    }
2033    else
2034#endif
2035#ifdef FACTORY_GCD_TEST
2036/*=======================gcd Testerei ================================*/
2037    if ( ! strcmp( sys_cmd, "setgcd" ) ) {
2038        if ( (h != NULL) && (h->Typ() == INT_CMD) ) {
2039            CFPrimitiveGcdUtil::setAlgorithm( (int)h->Data() );
2040            return FALSE;
2041        } else
2042            WerrorS("int expected");
2043    }
2044    else
2045#endif
2046
2047#ifdef FACTORY_GCD_TIMING
2048    if ( ! strcmp( sys_cmd, "gcdtime" ) ) {
2049        TIMING_PRINT( contentTimer, "time used for content: " );
2050        TIMING_PRINT( algContentTimer, "time used for algContent: " );
2051        TIMING_PRINT( algLcmTimer, "time used for algLcm: " );
2052        TIMING_RESET( contentTimer );
2053        TIMING_RESET( algContentTimer );
2054        TIMING_RESET( algLcmTimer );
2055        return FALSE;
2056    }
2057    else
2058#endif
2059
2060#ifdef FACTORY_GCD_STAT
2061    if ( ! strcmp( sys_cmd, "gcdstat" ) ) {
2062        printGcdTotal();
2063        printContTotal();
2064        resetGcdTotal();
2065        resetContTotal();
2066        return FALSE;
2067    }
2068    else
2069#endif
2070#if !defined(HAVE_NS)
2071/*==================== lib ==================================*/
2072    if(strcmp(sys_cmd,"LIB")==0)
2073    {
2074      idhdl hh=idroot->get((char*)h->Data(),0);
2075      if ((hh!=NULL)&&(IDTYP(hh)==PROC_CMD))
2076      {
2077        res->rtyp=STRING_CMD;
2078        char *r=iiGetLibName(IDPROC(hh));
2079        if (r==NULL) r="";
2080        res->data=omStrDup(r);
2081        return FALSE;
2082      }
2083      else
2084        Warn("`%s` not found",(char*)h->Data());
2085    }
2086    else
2087#endif
2088/*==================== listall ===================================*/
2089    if(strcmp(sys_cmd,"listall")==0)
2090    {
2091      int showproc=0;
2092      if ((h!=NULL) && (h->Typ()==INT_CMD)) showproc=(int)((long)h->Data());
2093#ifdef HAVE_NS
2094      listall(showproc);
2095#else
2096      idhdl hh=IDROOT;
2097      while (hh!=NULL)
2098      {
2099        if (IDDATA(hh)==(void *)currRing) PrintS("(R)");
2100        else PrintS("   ");
2101        Print("::%s, typ %s level %d\n",
2102               IDID(hh),Tok2Cmdname(IDTYP(hh)),IDLEV(hh));
2103        hh=IDNEXT(hh);
2104      }
2105      hh=IDROOT;
2106      while (hh!=NULL)
2107      {
2108        if ((IDTYP(hh)==RING_CMD)
2109        || (IDTYP(hh)==QRING_CMD)
2110        || (IDTYP(hh)==PACKAGE_CMD))
2111        {
2112          idhdl h2=IDRING(hh)->idroot;
2113          while (h2!=NULL)
2114          {
2115            if (IDDATA(h2)==(void *)currRing) PrintS("(R)");
2116            else PrintS("   ");
2117            Print("%s::%s, typ %s level %d\n",
2118            IDID(hh),IDID(h2),Tok2Cmdname(IDTYP(h2)),IDLEV(h2));
2119            h2=IDNEXT(h2);
2120          }
2121        }
2122        hh=IDNEXT(hh);
2123      }
2124#endif /* HAVE_NS */
2125      return FALSE;
2126    }
2127    else
2128/*==================== proclist =================================*/
2129    if(strcmp(sys_cmd,"proclist")==0)
2130    {
2131      piShowProcList();
2132      return FALSE;
2133    }
2134    else
2135/* ==================== newton ================================*/
2136#ifdef HAVE_NEWTON
2137    if(strcmp(sys_cmd,"newton")==0)
2138    {
2139      if ((h->Typ()!=POLY_CMD)
2140      || (h->next->Typ()!=INT_CMD)
2141      || (h->next->next->Typ()!=INT_CMD))
2142      {
2143        WerrorS("system(\"newton\",<poly>,<int>,<int>) expected");
2144        return TRUE;
2145      }
2146      poly  p=(poly)(h->Data());
2147      int l=pLength(p);
2148      short *points=(short *)omAlloc(currRing->N*l*sizeof(short));
2149      int i,j,k;
2150      k=0;
2151      poly pp=p;
2152      for (i=0;pp!=NULL;i++)
2153      {
2154        for(j=1;j<=currRing->N;j++)
2155        {
2156          points[k]=pGetExp(pp,j);
2157          k++;
2158        }
2159        pIter(pp);
2160      }
2161      hc_ERG r=hc_KOENIG(currRing->N,      // dimension
2162                l,      // number of points
2163                (short*) points,   // points: x_1, y_1,z_1, x_2,y_2,z2,...
2164                currRing->OrdSgn==-1,
2165                (int) (h->next->Data()),      // 1: Milnor, 0: Newton
2166                (int) (h->next->next->Data()) // debug
2167               );
2168      //----<>---Output-----------------------
2169
2170
2171//  PrintS("Bin jetzt in extra.cc bei der Auswertung.\n"); // **********
2172
2173
2174      lists L=(lists)omAllocBin(slists_bin);
2175      L->Init(6);
2176      L->m[0].rtyp=STRING_CMD;               // newtonnumber;
2177      L->m[0].data=(void *)omStrDup(r.nZahl);
2178      L->m[1].rtyp=INT_CMD;
2179      L->m[1].data=(void *)r.achse;          // flag for unoccupied axes
2180      L->m[2].rtyp=INT_CMD;
2181      L->m[2].data=(void *)r.deg;            // #degenerations
2182      if ( r.deg != 0)              // only if degenerations exist
2183      {
2184        L->m[3].rtyp=INT_CMD;
2185        L->m[3].data=(void *)r.anz_punkte;     // #points
2186        //---<>--number of points------
2187        int anz = r.anz_punkte;    // number of points
2188        int dim = (currRing->N);     // dimension
2189        intvec* v = new intvec( anz*dim );
2190        for (i=0; i<anz*dim; i++)    // copy points
2191          (*v)[i] = r.pu[i];
2192        L->m[4].rtyp=INTVEC_CMD;
2193        L->m[4].data=(void *)v;
2194        //---<>--degenerations---------
2195        int deg = r.deg;    // number of points
2196        intvec* w = new intvec( r.speicher );  // necessary memeory
2197        i=0;               // start copying
2198        do
2199        {
2200          (*w)[i] = r.deg_tab[i];
2201          i++;
2202        }
2203        while (r.deg_tab[i-1] != -2);   // mark for end of list
2204        L->m[5].rtyp=INTVEC_CMD;
2205        L->m[5].data=(void *)w;
2206      }
2207      else
2208      {
2209        L->m[3].rtyp=INT_CMD; L->m[3].data=(char *)0;
2210        L->m[4].rtyp=DEF_CMD;
2211        L->m[5].rtyp=DEF_CMD;
2212      }
2213
2214      res->data=(void *)L;
2215      res->rtyp=LIST_CMD;
2216      // free all pointer in r:
2217      delete[] r.nZahl;
2218      delete[] r.pu;
2219      delete[] r.deg_tab;      // Ist das ein Problem??
2220
2221      omFreeSize((ADDRESS)points,currRing->N*l*sizeof(short));
2222      return FALSE;
2223    }
2224    else
2225#endif
2226/*==================== sdb_flags =================*/
2227#ifdef HAVE_SDB
2228    if (strcmp(sys_cmd, "sdb_flags") == 0)
2229    {
2230      if ((h!=NULL) && (h->Typ()==INT_CMD))
2231      {
2232        sdb_flags=(int)((long)h->Data());
2233      }
2234      else
2235      {
2236        WerrorS("system(\"sdb_flags\",`int`) expected");
2237        return TRUE;
2238      }
2239      return FALSE;
2240    }
2241    else
2242/*==================== sdb_edit =================*/
2243    if (strcmp(sys_cmd, "sdb_edit") == 0)
2244    {
2245      if ((h!=NULL) && (h->Typ()==PROC_CMD))
2246      {
2247        procinfov p=(procinfov)h->Data();
2248        sdb_edit(p);
2249      }
2250      else
2251      {
2252        WerrorS("system(\"sdb_edit\",`proc`) expected");
2253        return TRUE;
2254      }
2255      return FALSE;
2256    }
2257    else
2258#endif
2259/*==================== GF =================*/
2260#if 0
2261    if (strcmp(sys_cmd, "GF") == 0)
2262    {
2263      int c=rChar(currRing);
2264      setCharacteristic( c, 2);
2265      CanonicalForm F( convSingGFClapGF( (poly)h->Data() ) );
2266      res->rtyp=POLY_CMD;
2267      res->data=convClapGFSingGF( F );
2268      return FALSE;
2269    }
2270    else
2271#endif
2272/*==================== stdX =================*/
2273    if (strcmp(sys_cmd, "std") == 0)
2274    {
2275      ideal i1;
2276      int i2;
2277      if ((h!=NULL) && (h->Typ()==MODUL_CMD))
2278      {
2279        i1=(ideal)h->CopyD();
2280        h=h->next;
2281      }
2282      else return TRUE;
2283      if ((h!=NULL) && (h->Typ()==INT_CMD))
2284      {
2285        i2=(int)((long)h->Data());
2286      }
2287      else return TRUE;
2288      res->rtyp=MODUL_CMD;
2289      res->data=idXXX(i1,i2);
2290      return FALSE;
2291    }
2292    else
2293/*==================== SVD =================*/
2294#ifdef HAVE_SVD
2295     if (strcmp(sys_cmd, "svd") == 0)
2296     {
2297          extern lists testsvd(matrix M);
2298            res->rtyp=LIST_CMD;
2299          res->data=(char*)(testsvd((matrix)h->Data()));
2300          return FALSE;
2301     }
2302     else
2303#endif
2304#ifdef ix86_Win
2305#ifdef HAVE_DL
2306/*==================== DLL =================*/
2307/* testing the DLL functionality under Win32 */
2308      if (strcmp(sys_cmd, "DLL") == 0)
2309      {
2310        typedef void  (*Void_Func)();
2311        typedef int  (*Int_Func)(int);
2312        void *hh=dynl_open("WinDllTest.dll");
2313        if ((h!=NULL) && (h->Typ()==INT_CMD))
2314        {
2315          int (*f)(int);
2316          if (hh!=NULL)
2317          {
2318            int (*f)(int);
2319            f=(Int_Func)dynl_sym(hh,"PlusDll");
2320            int i=10;
2321            if (f!=NULL) printf("%d\n",f(i));
2322            else PrintS("cannot find PlusDll\n");
2323          }
2324        }
2325        else
2326        {
2327          void (*f)();
2328          f= (Void_Func)dynl_sym(hh,"TestDll");
2329          if (f!=NULL) f();
2330          else PrintS("cannot find TestDll\n");
2331        }
2332        return FALSE;
2333      }
2334      else
2335#endif
2336#endif
2337/*==================== eigenvalues ==================================*/
2338#ifdef HAVE_EIGENVAL
2339    if(strcmp(sys_cmd,"eigenvals")==0)
2340    {
2341      return evEigenvals(res,h);
2342    }
2343    else
2344#endif
2345/*==================== Gauss-Manin system ==================================*/
2346#ifdef HAVE_GMS
2347    if(strcmp(sys_cmd,"gmsnf")==0)
2348    {
2349      return gmsNF(res,h);
2350    }
2351    else
2352#endif
2353/*==================== facstd_debug ==================================*/
2354#if !defined(NDEBUG)
2355    if(strcmp(sys_cmd,"facstd")==0)
2356    {
2357      extern int strat_nr;
2358      extern int strat_fac_debug;
2359      strat_fac_debug=(int)(long)h->Data();
2360      strat_nr=0;
2361      return FALSE;
2362    }
2363    else
2364#endif
2365#ifdef HAVE_RING2TOM
2366/*==================== ring-GB ==================================*/
2367    if (strcmp(sys_cmd, "findZeroPoly")==0)
2368    {
2369      ring r = currRing;
2370      poly f = (poly) h->Data();
2371      res->rtyp=POLY_CMD;
2372      res->data=(poly) kFindZeroPoly(f, r, r);
2373      return(FALSE);
2374    }
2375    else
2376#ifdef HAVE_VANIDEAL
2377/*==================== Creating zero polynomials =================*/
2378    if (strcmp(sys_cmd, "createG0")==0)
2379    {
2380      /* long exp[50];
2381      int N = 0;
2382      while (h != NULL)
2383      {
2384        N += 1;
2385        exp[N] = (long) h->Data();
2386        // if (exp[i] % 2 != 0) exp[i] -= 1;
2387        h = h->next;
2388      }
2389      for (int k = 1; N + k <= currRing->N; k++) exp[k] = 0;
2390
2391      poly t_p;
2392      res->rtyp=POLY_CMD;
2393      res->data= (poly) kCreateZeroPoly(exp, -1, &t_p, currRing, currRing);
2394      return(FALSE); */
2395
2396      res->rtyp = IDEAL_CMD;
2397      res->data = (ideal) createG0();
2398      return(FALSE);
2399    }
2400    else
2401#endif
2402    if (strcmp(sys_cmd, "redNF_ring")==0)
2403    {
2404      ring r = currRing;
2405      poly f = (poly) h->Data();
2406      h = h->next;
2407      ideal G = (ideal) h->Data();
2408      res->rtyp=POLY_CMD;
2409      res->data=(poly) ringRedNF(f, G, r);
2410      return(FALSE);
2411    }
2412    else
2413#endif
2414#ifdef HAVE_F5
2415/*==================== F5 Implementation =================*/
2416    if (strcmp(sys_cmd, "f5")==0)
2417    {
2418      if (h->Typ()!=IDEAL_CMD)
2419      {
2420        WerrorS("ideal expected");
2421        return TRUE;
2422      } 
2423     
2424      ring r = currRing;
2425      ideal G = (ideal) h->Data();
2426      res->rtyp=IDEAL_CMD;
2427      res->data=(ideal) F5main(G,r);
2428      return TRUE;
2429    }
2430    else
2431#endif
2432#ifdef HAVE_RINGS
2433/*==================== Testing groebner basis =================*/
2434    if (strcmp(sys_cmd, "NF_ring")==0)
2435    {
2436      ring r = currRing;
2437      poly f = (poly) h->Data();
2438      h = h->next;
2439      ideal G = (ideal) h->Data();
2440      res->rtyp=POLY_CMD;
2441      res->data=(poly) ringNF(f, G, r);
2442      return(FALSE);
2443    }
2444    else
2445    if (strcmp(sys_cmd, "spoly")==0)
2446    {
2447      poly f = pCopy((poly) h->Data());
2448      h = h->next;
2449      poly g = pCopy((poly) h->Data());
2450
2451      res->rtyp=POLY_CMD;
2452      res->data=(poly) plain_spoly(f,g);
2453      return(FALSE);
2454    }
2455    else
2456    if (strcmp(sys_cmd, "testGB")==0)
2457    {
2458      ideal I = (ideal) h->Data();
2459      h = h->next;
2460      ideal GI = (ideal) h->Data();
2461      res->rtyp = INT_CMD;
2462      res->data = (void *) testGB(I, GI);
2463      return(FALSE);
2464    }
2465    else
2466#endif
2467#ifdef HAVE_PLURAL
2468/*==================== sca?AltVar ==================================*/
2469    if ( (strcmp(sys_cmd, "AltVarStart") == 0) || (strcmp(sys_cmd, "AltVarEnd") == 0) )
2470    {
2471      ring r = currRing;
2472
2473      if((h!=NULL) && (h->Typ()==RING_CMD)) r = (ring)h->Data(); else
2474      {
2475        WerrorS("`system(\"AltVarStart/End\"[,<ring>])` expected");
2476        return TRUE;
2477      }
2478
2479      res->rtyp=INT_CMD;
2480
2481      if (rIsSCA(r))
2482      {
2483        if(strcmp(sys_cmd, "AltVarStart") == 0)
2484          res->data = (void*)scaFirstAltVar(r);
2485        else
2486          res->data = (void*)scaLastAltVar(r);
2487        return FALSE;
2488      }
2489
2490      WerrorS("`system(\"AltVarStart/End\",<ring>) requires a SCA ring");
2491      return TRUE;
2492    }
2493    else
2494#endif
2495#ifdef HAVE_PLURAL
2496#ifdef HAVE_RATGRING
2497/*==================== RatNF, noncomm rational coeffs =================*/
2498    if (strcmp(sys_cmd, "intratNF") == 0)
2499    {
2500      poly p;
2501      poly *q;
2502      ideal I;
2503      int is, k, id;
2504      if ((h!=NULL) && (h->Typ()==POLY_CMD))
2505      {
2506        p=(poly)h->CopyD();
2507        h=h->next;
2508        //      Print("poly is done\n");
2509      }
2510      else return TRUE;
2511      if ((h!=NULL) && (h->Typ()==IDEAL_CMD))
2512      {
2513        I=(ideal)h->CopyD();
2514        q = I->m;
2515        h=h->next;
2516        //      Print("ideal is done\n");
2517      }
2518      else return TRUE;
2519      if ((h!=NULL) && (h->Typ()==INT_CMD))
2520      {
2521        is=(int)((long)(h->Data()));
2522        //      res->rtyp=INT_CMD;
2523        //      Print("int is done\n");
2524        //      res->rtyp=IDEAL_CMD;
2525        if (rIsPluralRing(currRing))
2526        { 
2527          id = IDELEMS(I);
2528          int *pl=(int*)omAlloc0(IDELEMS(I)*sizeof(int));
2529          for(k=0; k < id; k++)
2530          {
2531            pl[k] = pLength(I->m[k]);
2532          }
2533          Print("starting redRat\n");
2534          //res->data = (char *)
2535          redRat(&p, q, pl, (int)IDELEMS(I),is,currRing);
2536          res->data=p;
2537          res->rtyp=POLY_CMD;
2538          //    res->data = ncGCD(p,q,currRing);       
2539        }
2540        else 
2541        {
2542          res->rtyp=POLY_CMD;
2543          res->data=p;
2544        }
2545      }
2546      else return TRUE;
2547      return FALSE;
2548    }
2549    else
2550/*==================== RatNF, noncomm rational coeffs =================*/
2551    if (strcmp(sys_cmd, "ratNF") == 0)
2552    {
2553      poly p,q;
2554      int is;
2555      if ((h!=NULL) && (h->Typ()==POLY_CMD))
2556      {
2557        p=(poly)h->CopyD();
2558        h=h->next;
2559      }
2560      else return TRUE;
2561      if ((h!=NULL) && (h->Typ()==POLY_CMD))
2562      {
2563        q=(poly)h->CopyD();
2564        h=h->next;
2565      }
2566      else return TRUE;
2567      if ((h!=NULL) && (h->Typ()==INT_CMD))
2568      {
2569        is=(int)((long)(h->Data()));
2570        res->rtyp=POLY_CMD;
2571        //      res->rtyp=IDEAL_CMD;
2572        if (rIsPluralRing(currRing))
2573        { 
2574          res->data = nc_rat_ReduceSpolyNew(q,p,is, currRing);
2575          //    res->data = ncGCD(p,q,currRing);       
2576        }
2577        else res->data=p;
2578      }
2579      else return TRUE;
2580      return FALSE;
2581    }
2582    else
2583#endif // HAVE_RATGRING
2584/*==================== freeGB, twosided GB in free algebra =================*/
2585#ifdef HAVE_SHIFTBBA
2586    if (strcmp(sys_cmd, "freegb") == 0)
2587    {
2588      ideal I;
2589      int uptodeg, lVblock;
2590      if ((h!=NULL) && (h->Typ()==IDEAL_CMD))
2591      {
2592        I=(ideal)h->CopyD();
2593        h=h->next;
2594      }
2595      else return TRUE;
2596      if ((h!=NULL) && (h->Typ()==INT_CMD))
2597      {
2598        uptodeg=(int)((long)(h->Data()));
2599        h=h->next;
2600      }
2601      else return TRUE;
2602      if ((h!=NULL) && (h->Typ()==INT_CMD))
2603      {
2604        lVblock=(int)((long)(h->Data()));
2605        res->data = freegb(I,uptodeg,lVblock);
2606        res->rtyp = IDEAL_CMD;
2607      }
2608      else return TRUE;
2609      return FALSE;
2610    }
2611    else
2612#endif
2613/*==================== shift-test for freeGB  =================*/
2614#ifdef HAVE_SHIFTBBA
2615    if (strcmp(sys_cmd, "stest") == 0)
2616    {
2617      poly p;
2618      int sh,uptodeg, lVblock;
2619      if ((h!=NULL) && (h->Typ()==POLY_CMD))
2620      {
2621        p=(poly)h->CopyD();
2622        h=h->next;
2623      }
2624      else return TRUE;
2625      if ((h!=NULL) && (h->Typ()==INT_CMD))
2626      {
2627        sh=(int)((long)(h->Data()));
2628        h=h->next;
2629      }
2630      else return TRUE;
2631
2632      if ((h!=NULL) && (h->Typ()==INT_CMD))
2633      {
2634        uptodeg=(int)((long)(h->Data()));
2635        h=h->next;
2636      }
2637      else return TRUE;
2638      if ((h!=NULL) && (h->Typ()==INT_CMD))
2639      {
2640        lVblock=(int)((long)(h->Data()));
2641        res->data = pLPshift(p,sh,uptodeg,lVblock);
2642        res->rtyp = POLY_CMD;
2643      }
2644      else return TRUE;
2645      return FALSE;
2646    }
2647    else
2648#endif
2649/*==================== block-test for freeGB  =================*/
2650#ifdef HAVE_SHIFTBBA
2651    if (strcmp(sys_cmd, "btest") == 0)
2652    {
2653      poly p;
2654      int lV;
2655      if ((h!=NULL) && (h->Typ()==POLY_CMD))
2656      {
2657        p=(poly)h->CopyD();
2658        h=h->next;
2659      }
2660      else return TRUE;
2661      if ((h!=NULL) && (h->Typ()==INT_CMD))
2662      {
2663        lV=(int)((long)(h->Data()));
2664        res->rtyp = INT_CMD;
2665        res->data = (void*)pLastVblock(p, lV);
2666      }
2667      else return TRUE;
2668      return FALSE;
2669    }
2670    else
2671#endif
2672#endif
2673/*==================== t-rep-GB ==================================*/
2674    if (strcmp(sys_cmd, "unifastmult")==0)
2675    {
2676      ring r = currRing;
2677      poly f = (poly)h->Data();
2678      h=h->next;
2679      poly g=(poly)h->Data();
2680      res->rtyp=POLY_CMD;
2681      res->data=unifastmult(f,g,currRing);
2682      return(FALSE);
2683    }
2684    else
2685    if (strcmp(sys_cmd, "multifastmult")==0)
2686    {
2687      ring r = currRing;
2688      poly f = (poly)h->Data();
2689      h=h->next;
2690      poly g=(poly)h->Data();
2691      res->rtyp=POLY_CMD;
2692      res->data=multifastmult(f,g,currRing);
2693      return(FALSE);
2694    }
2695    else
2696    if (strcmp(sys_cmd, "mults")==0)
2697    {
2698      res->rtyp=INT_CMD ;
2699      res->data=(void*)(long) Mults();
2700      return(FALSE);
2701    }
2702    else
2703    if (strcmp(sys_cmd, "fastpower")==0)
2704    {
2705      ring r = currRing;
2706      poly f = (poly)h->Data();
2707      h=h->next;
2708      int n=(int)((long)h->Data());
2709      res->rtyp=POLY_CMD ;
2710      res->data=(void*) pFastPower(f,n,r);
2711      return(FALSE);
2712    }
2713    else
2714    if (strcmp(sys_cmd, "normalpower")==0)
2715    {
2716      ring r = currRing;
2717      poly f = (poly)h->Data();
2718      h=h->next;
2719      int n=(int)((long)h->Data());
2720      res->rtyp=POLY_CMD ;
2721      res->data=(void*) pPower(pCopy(f),n);
2722      return(FALSE);
2723    }
2724    else
2725    if (strcmp(sys_cmd, "MCpower")==0)
2726    {
2727      ring r = currRing;
2728      poly f = (poly)h->Data();
2729      h=h->next;
2730      int n=(int)((long)h->Data());
2731      res->rtyp=POLY_CMD ;
2732      res->data=(void*) pFastPowerMC(f,n,r);
2733      return(FALSE);
2734    }
2735    else
2736    if (strcmp(sys_cmd, "bit_subst")==0)
2737    {
2738      ring r = currRing;
2739      poly outer = (poly)h->Data();
2740      h=h->next;
2741      poly inner=(poly)h->Data();
2742      res->rtyp=POLY_CMD ;
2743      res->data=(void*) uni_subst_bits(outer, inner,r);
2744      return(FALSE);
2745    }
2746    else
2747/*==================== bifac =================*/
2748#ifdef HAVE_BIFAC
2749    if (strcmp(sys_cmd, "bifac")==0)
2750    {
2751      if (h->Typ()!=POLY_CMD)
2752      {
2753        WerrorS("`system(\"bifac\",<poly>) expected");
2754        return TRUE;
2755      }
2756      if (!rField_is_Q())
2757      {
2758        WerrorS("coeff field must be Q");
2759        return TRUE;
2760      }
2761      BIFAC B;
2762      CFFList C;
2763      int sw_rat=isOn(SW_RATIONAL);
2764      On(SW_RATIONAL);
2765      CanonicalForm F( convSingPClapP((poly)(h->Data())));
2766      B.bifac(F, 1);
2767      CFFList L=B.getFactors();
2768      // construct the ring ==============================================
2769      int i;
2770      int lev=ExtensionLevel();
2771      char **names=(char**)omAlloc0(lev*sizeof(char_ptr));
2772      for(i=1;i<=lev; i++)
2773      {
2774        StringSetS("");
2775        names[i-1]=omStrDup(StringAppend("a(%d)",i));
2776      }
2777      ring alg_ring=rDefault(0,lev,names);
2778      ring new_ring=rCopy0(currRing); // all variable names, ordering etc.
2779      new_ring->P=lev;
2780      new_ring->parameter=names;
2781      new_ring->algring=alg_ring;
2782      new_ring->ch=1;
2783      rComplete(new_ring,TRUE);
2784      // set the mipo ===============================================
2785      ring save_currRing=currRing; idhdl save_currRingHdl=currRingHdl;
2786      rChangeCurrRing(alg_ring);
2787      ideal mipo_id=idInit(lev,1);
2788      for (i=lev; i>0;i--)
2789      {
2790        CanonicalForm Mipo=getMipo(Variable(-i),Variable(i));
2791        mipo_id->m[i-1]=convClapPSingP(Mipo);
2792      }
2793      idShow(mipo_id);
2794      alg_ring->qideal=mipo_id;
2795      rChangeCurrRing(new_ring);
2796      for (i=lev-1; i>=0;i--)
2797      {
2798        poly p=pOne();
2799        lnumber n=(lnumber)pGetCoeff(p);
2800        // no need to delete nac 1
2801        n->z=(napoly)mipo_id->m[i];
2802        mipo_id->m[i]=p;
2803      }
2804      new_ring->minideal=id_Copy(alg_ring->qideal,new_ring);
2805      // convert factors =============================================
2806      ideal fac_id=idInit(L.length(),1);
2807      CFFListIterator J=L;
2808      i=0;
2809      intvec *v = new intvec( L.length() );
2810      for ( ; J.hasItem(); J++,i++ )
2811      {
2812        fac_id->m[i]=convClapAPSingAP( J.getItem().factor() );
2813        (*v)[i]=J.getItem().exp();
2814      }
2815      idhdl hh=enterid("factors",0,LIST_CMD,&(currRing->idroot),FALSE);
2816      lists LL=(lists)omAllocBin( slists_bin);
2817      LL->Init(2);
2818      LL->m[0].rtyp=IDEAL_CMD;
2819      LL->m[0].data=(char *)fac_id;
2820      LL->m[1].rtyp=INTVEC_CMD;
2821      LL->m[1].data=(char *)v;
2822      IDDATA(hh)=(char *)LL;
2823
2824      rChangeCurrRing(save_currRing);
2825      currRingHdl=save_currRingHdl;
2826      if (!sw_rat) Off(SW_RATIONAL);
2827
2828      res->data=new_ring;
2829      res->rtyp=RING_CMD;
2830      return FALSE;
2831    }
2832    else
2833#endif
2834/*==================== gcd-varianten =================*/
2835    if (strcmp(sys_cmd, "gcd") == 0)
2836    {
2837      if (h==NULL)
2838      {
2839        Print("NTL_0:%d (use NTL for gcd of polynomials in char 0)\n",isOn(SW_USE_NTL_GCD_0));
2840        Print("NTL_p:%d (use NTL for gcd of polynomials in char p)\n",isOn(SW_USE_NTL_GCD_P));
2841        Print("EZGCD:%d (use EZGCD for gcd of polynomials in char 0)\n",isOn(SW_USE_EZGCD));
2842        Print("EZGCD_P:%d (use EZGCD_P for gcd of polynomials in char p)\n",isOn(SW_USE_EZGCD_P));
2843        Print("CRGCD:%d (use chinese Remainder for gcd of polynomials in char 0)\n",isOn(SW_USE_CHINREM_GCD));
2844        Print("SPARSEMOD:%d (use SPARSEMOD for gcd of polynomials in char 0)\n",isOn(SW_USE_SPARSEMOD));
2845        Print("QGCD:%d (use QGCD for gcd of polynomials in alg. ext.)\n",isOn(SW_USE_QGCD));
2846        Print("FGCD:%d (use fieldGCD for gcd of polynomials in Z/p)\n",isOn(SW_USE_fieldGCD));
2847        Print("homog:%d (use homog. test for factorization of polynomials)\n",singular_homog_flag);
2848        return FALSE;
2849      }
2850      else
2851      if ((h!=NULL) && (h->Typ()==STRING_CMD)
2852      && (h->next!=NULL) && (h->next->Typ()==INT_CMD))
2853      {
2854        int d=(int)(long)h->next->Data();
2855        char *s=(char *)h->Data();
2856        if (strcmp(s,"NTL_0")==0) { if (d) On(SW_USE_NTL_GCD_0); else Off(SW_USE_NTL_GCD_0); } else
2857        if (strcmp(s,"NTL_p")==0) { if (d) On(SW_USE_NTL_GCD_P); else Off(SW_USE_NTL_GCD_P); } else
2858        if (strcmp(s,"EZGCD")==0) { if (d) On(SW_USE_EZGCD); else Off(SW_USE_EZGCD); } else
2859        if (strcmp(s,"EZGCD_P")==0) { if (d) On(SW_USE_EZGCD_P); else Off(SW_USE_EZGCD_P); } else
2860        if (strcmp(s,"CRGCD")==0) { if (d) On(SW_USE_CHINREM_GCD); else Off(SW_USE_CHINREM_GCD); } else
2861        if (strcmp(s,"SPARSEMOD")==0) { if (d) On(SW_USE_SPARSEMOD); else Off(SW_USE_SPARSEMOD); } else
2862        if (strcmp(s,"QGCD")==0) { if (d) On(SW_USE_QGCD); else Off(SW_USE_QGCD); } else
2863        if (strcmp(s,"FGCD")==0) { if (d) On(SW_USE_fieldGCD); else Off(SW_USE_fieldGCD); } else
2864        if (strcmp(s,"homog")==0) { if (d) singular_homog_flag=1; else singular_homog_flag=0; } else
2865        return TRUE;
2866        return FALSE;
2867      }
2868      else return TRUE;
2869    }
2870    else
2871#if 0
2872/*==================== gcd-test =================*/
2873    if (strcmp(sys_cmd, "GCD") == 0)
2874    {
2875      if ((h!=NULL) && (h->Typ()==POLY_CMD)
2876      && (h->next!=NULL) && (h->next->Typ()==POLY_CMD))
2877      {
2878        poly f=(poly)h->Data();
2879        poly g=(poly)h->next->Data();
2880        res->rtyp=POLY_CMD;
2881        res->data=(char*)id_GCD(f,g,currRing);
2882        return FALSE;
2883      }
2884      else return TRUE;
2885    }
2886    else
2887#endif
2888/*==================== subring =================*/
2889    if (strcmp(sys_cmd, "subring") == 0)
2890    {
2891      if (h!=NULL)
2892      {
2893        extern ring rSubring(ring r,leftv v); /* ipshell.cc*/
2894        res->data=(char *)rSubring(currRing,h);
2895        res->rtyp=RING_CMD;
2896        return res->data==NULL;
2897      }
2898      else return TRUE;
2899    }
2900    else
2901#ifdef ix86_Win
2902/*==================== Python Singular =================*/
2903    if (strcmp(sys_cmd, "python") == 0)
2904    {
2905      const char* c;
2906      if ((h!=NULL) && (h->Typ()==STRING_CMD))
2907      {
2908        c=(const char*)h->Data();
2909        if (!PyInitialized) {
2910          PyInitialized = 1;
2911//          Py_Initialize();
2912//          initPySingular();
2913        }
2914//      PyRun_SimpleString(c);
2915        return FALSE;
2916      }
2917      else return TRUE;
2918    }
2919    else
2920/*==================== Python Singular =================
2921    if (strcmp(sys_cmd, "ipython") == 0)
2922    {
2923      const char* c;
2924      {
2925        if (!PyInitialized) {
2926          PyInitialized = 1;
2927          Py_Initialize();
2928          initPySingular();
2929        }
2930  PyRun_SimpleString(
2931"try:                                                                                       \n\
2932    __IPYTHON__                                                                             \n\
2933except NameError:                                                                           \n\
2934    argv = ['']                                                                             \n\
2935    banner = exit_msg = ''                                                                  \n\
2936else:                                                                                       \n\
2937    # Command-line options for IPython (a list like sys.argv)                               \n\
2938    argv = ['-pi1','In <\\#>:','-pi2','   .\\D.:','-po','Out<\\#>:']                        \n\
2939    banner = '*** Nested interpreter ***'                                                   \n\
2940    exit_msg = '*** Back in main IPython ***'                                               \n\
2941                          \n\
2942# First import the embeddable shell class                                                   \n\
2943from IPython.Shell import IPShellEmbed                                                      \n\
2944# Now create the IPython shell instance. Put ipshell() anywhere in your code                \n\
2945# where you want it to open.                                                                \n\
2946ipshell = IPShellEmbed(argv,banner=banner,exit_msg=exit_msg)                                \n\
2947ipshell()");
2948        return FALSE;
2949      }
2950    }
2951    else
2952              */
2953
2954
2955#endif
2956/*==================== Error =================*/
2957      Werror( "system(\"%s\",...) %s", sys_cmd, feNotImplemented );
2958  }
2959  return TRUE;
2960}
2961#endif // HAVE_EXTENDED_SYSTEM
2962
Note: See TracBrowser for help on using the repository browser.