source: git/Singular/extra.cc @ c5d8dd

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