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

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