source: git/Singular/extra.cc @ a425ec4

spielwiese
Last change on this file since a425ec4 was a425ec4, checked in by Hans Schönemann <hannes@…>, 15 years ago
*hannes:freegb moved git-svn-id: file:///usr/local/Singular/svn/trunk@11095 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 80.2 KB
Line 
1/*****************************************
2*  Computer Algebra System SINGULAR      *
3*****************************************/
4/* $Id: extra.cc,v 1.283 2008-10-02 12:02:36 Singular Exp $ */
5/*
6* ABSTRACT: general interface to internals of Singular ("system" command)
7*/
8
9#define HAVE_WALK 1
10
11#include <stdlib.h>
12#include <stdio.h>
13#include <string.h>
14#include <ctype.h>
15#include <signal.h>
16#include "mod2.h"
17
18#ifdef TIME_WITH_SYS_TIME
19# include <time.h>
20# ifdef HAVE_SYS_TIME_H
21#   include <sys/time.h>
22# endif
23#else
24# ifdef HAVE_SYS_TIME_H
25#   include <sys/time.h>
26# else
27#   include <time.h>
28# endif
29#endif
30#ifdef HAVE_SYS_TIMES_H
31#include <sys/times.h>
32#endif
33
34#include <unistd.h>
35
36#include "tok.h"
37#include "ipid.h"
38#include "polys.h"
39#include "lists.h"
40#include "kutil.h"
41#include "cntrlc.h"
42#include "stairc.h"
43#include "ipshell.h"
44#include "modulop.h"
45#include "febase.h"
46#include "matpol.h"
47#include "longalg.h"
48#include "ideals.h"
49#include "kstd1.h"
50#include "syz.h"
51#include "sdb.h"
52#include "feOpt.h"
53#include "distrib.h"
54#include "prCopy.h"
55#include "mpr_complex.h"
56
57#ifdef HAVE_RINGS
58#include "ringgb.h"
59#endif
60
61
62#ifdef HAVE_F5
63#include "f5gb.h"
64#endif
65
66#ifdef HAVE_WALK
67#include "walk.h"
68#endif
69
70#include "weight.h"
71#include "fast_mult.h"
72#include "digitech.h"
73
74#ifdef HAVE_SPECTRUM
75#include "spectrum.h"
76#endif
77
78#ifdef HAVE_BIFAC
79#include <bifac.h>
80#endif
81
82#if defined(HPUX_10) || defined(HPUX_9)
83extern "C" int setenv(const char *name, const char *value, int overwrite);
84#endif
85
86#ifdef HAVE_PLURAL
87#include "ring.h"
88#include "gring.h"
89#include "sca.h"
90#include <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      const 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) ) // No Plural!
840        return TRUE;
841
842      return FALSE;
843    }
844
845    if(strcmp(sys_cmd,"ForceNewOldNCMultiplication")==0)
846    {
847      if( !rIsPluralRing(currRing) )
848        return TRUE;
849
850      if( !ncInitSpecialPowersMultiplication(currRing) ) // Enable Formula for Plural (depends on swiches)!
851        return TRUE;
852
853      return FALSE;
854    }
855   
856    /*==================== PLURAL =================*/
857/*==================== opp ==================================*/
858    if (strcmp(sys_cmd, "opp")==0)
859    {
860      if ((h!=NULL) && (h->Typ()==RING_CMD))
861      {
862        ring r=(ring)h->Data();
863        res->data=rOpposite(r);
864        res->rtyp=RING_CMD;
865        return FALSE;
866      }
867      else
868      {
869        WerrorS("`system(\"opp\",<ring>)` expected");
870        return TRUE;
871      }
872    }
873    else
874/*==================== env ==================================*/
875    if (strcmp(sys_cmd, "env")==0)
876    {
877      if ((h!=NULL) && (h->Typ()==RING_CMD))
878      {
879        ring r = (ring)h->Data();
880        res->data = rEnvelope(r);
881        res->rtyp = RING_CMD;
882        return FALSE;
883      }
884      else
885      {
886        WerrorS("`system(\"env\",<ring>)` expected");
887        return TRUE;
888      }
889    }
890    else
891/*==================== oppose ==================================*/
892    if (strcmp(sys_cmd, "oppose")==0)
893    {
894      ring Rop;
895      if ((h!=NULL) && (h->Typ()==RING_CMD))
896      {
897        Rop = (ring)h->Data();
898        h   = h->next;
899      }
900      if ((h!=NULL))
901      {
902        idhdl w;
903        if ((w=Rop->idroot->get(h->Name(),myynest))!=NULL)
904        {
905          poly p = (poly)IDDATA(w);
906          res->data = pOppose(Rop,p);
907          res->rtyp = POLY_CMD;
908          return FALSE;
909        }
910       }
911      else
912      {
913        WerrorS("`system(\"oppose\",<ring>,<poly>)` expected");
914        return TRUE;
915      }
916    }
917    else
918/*==================== freeGB, twosided GB in free algebra =================*/
919#ifdef HAVE_SHIFTBBA
920    if (strcmp(sys_cmd, "freegb") == 0)
921    {
922      ideal I;
923      int uptodeg, lVblock;
924      if ((h!=NULL) && (h->Typ()==IDEAL_CMD))
925      {
926        I=(ideal)h->CopyD();
927        h=h->next;
928      }
929      else return TRUE;
930      if ((h!=NULL) && (h->Typ()==INT_CMD))
931      {
932        uptodeg=(int)((long)(h->Data()));
933        h=h->next;
934      }
935      else return TRUE;
936      if ((h!=NULL) && (h->Typ()==INT_CMD))
937      {
938        lVblock=(int)((long)(h->Data()));
939        res->data = freegb(I,uptodeg,lVblock);
940        if (res->data == NULL)
941        {
942          /* that is there were input errors */
943          res->data = I;
944        }
945        res->rtyp = IDEAL_CMD;
946      }
947      else return TRUE;
948      return FALSE;
949    }
950    else
951#endif /*SHIFTBBA*/
952#endif /*PLURAL*/
953#ifdef HAVE_WALK
954/*==================== walk stuff =================*/
955#ifdef OWNW
956    if (strcmp(sys_cmd, "walkNextWeight") == 0)
957    {
958      if (h == NULL || h->Typ() != INTVEC_CMD ||
959          h->next == NULL || h->next->Typ() != INTVEC_CMD ||
960          h->next->next == NULL || h->next->next->Typ() != IDEAL_CMD)
961      {
962        Werror("system(\"walkNextWeight\", intvec, intvec, ideal) expected");
963        return TRUE;
964      }
965
966      if (((intvec*) h->Data())->length() != currRing->N ||
967          ((intvec*) h->next->Data())->length() != currRing->N)
968      {
969        Werror("system(\"walkNextWeight\" ...) intvecs not of length %d\n",
970               currRing->N);
971        return TRUE;
972      }
973      res->data = (void*) walkNextWeight(((intvec*) h->Data()),
974                                         ((intvec*) h->next->Data()),
975                                         (ideal) h->next->next->Data());
976      if (res->data == (void*) 0 || res->data == (void*) 1)
977      {
978        res->rtyp = INT_CMD;
979      }
980      else
981      {
982        res->rtyp = INTVEC_CMD;
983      }
984      return FALSE;
985    }
986    else if (strcmp(sys_cmd, "walkInitials") == 0)
987    {
988      if (h == NULL || h->Typ() != IDEAL_CMD)
989      {
990        WerrorS("system(\"walkInitials\", ideal) expected");
991        return TRUE;
992      }
993
994      res->data = (void*) walkInitials((ideal) h->Data());
995      res->rtyp = IDEAL_CMD;
996      return FALSE;
997    }
998    else
999#endif
1000#ifdef WAIV
1001    if (strcmp(sys_cmd, "walkAddIntVec") == 0)
1002    {
1003      if (h == NULL || h->Typ() != INTVEC_CMD ||
1004          h->next == NULL || h->next->Typ() != INTVEC_CMD)
1005      {
1006        WerrorS("system(\"walkAddIntVec\", intvec, intvec) expected");
1007        return TRUE;
1008      }
1009      intvec* arg1 = (intvec*) h->Data();
1010      intvec* arg2 = (intvec*) h->next->Data();
1011
1012
1013      res->data = (intvec*) walkAddIntVec(arg1, arg2);
1014      res->rtyp = INTVEC_CMD;
1015      return FALSE;
1016    }
1017    else
1018#endif
1019#ifdef MwaklNextWeight
1020    if (strcmp(sys_cmd, "MwalkNextWeight") == 0)
1021    {
1022      if (h == NULL || h->Typ() != INTVEC_CMD ||
1023          h->next == NULL || h->next->Typ() != INTVEC_CMD ||
1024          h->next->next == NULL || h->next->next->Typ() != IDEAL_CMD)
1025      {
1026        Werror("system(\"MwalkNextWeight\", intvec, intvec, ideal) expected");
1027        return TRUE;
1028      }
1029
1030      if (((intvec*) h->Data())->length() != currRing->N ||
1031          ((intvec*) h->next->Data())->length() != currRing->N)
1032      {
1033        Werror("system(\"MwalkNextWeight\" ...) intvecs not of length %d\n",
1034               currRing->N);
1035        return TRUE;
1036      }
1037      intvec* arg1 = (intvec*) h->Data();
1038      intvec* arg2 = (intvec*) h->next->Data();
1039      ideal arg3   =   (ideal) h->next->next->Data();
1040
1041      intvec* result = (intvec*) MwalkNextWeight(arg1, arg2, arg3);
1042
1043      res->rtyp = INTVEC_CMD;
1044      res->data =  result;
1045
1046      return FALSE;
1047    }
1048    else
1049#endif //MWalkNextWeight
1050    if(strcmp(sys_cmd, "Mivdp") == 0)
1051    {
1052      if (h == NULL || h->Typ() != INT_CMD)
1053      {
1054        Werror("system(\"Mivdp\", int) expected");
1055        return TRUE;
1056      }
1057      if ((int) ((long)(h->Data())) != currRing->N)
1058      {
1059        Werror("system(\"Mivdp\" ...) intvecs not of length %d\n",
1060               currRing->N);
1061        return TRUE;
1062      }
1063      int arg1 = (int) ((long)(h->Data()));
1064
1065      intvec* result = (intvec*) Mivdp(arg1);
1066
1067      res->rtyp = INTVEC_CMD;
1068      res->data =  result;
1069
1070      return FALSE;
1071    }
1072
1073    else if(strcmp(sys_cmd, "Mivlp") == 0)
1074    {
1075      if (h == NULL || h->Typ() != INT_CMD)
1076      {
1077        Werror("system(\"Mivlp\", int) expected");
1078        return TRUE;
1079      }
1080      if ((int) ((long)(h->Data())) != currRing->N)
1081      {
1082        Werror("system(\"Mivlp\" ...) intvecs not of length %d\n",
1083               currRing->N);
1084        return TRUE;
1085      }
1086      int arg1 = (int) ((long)(h->Data()));
1087
1088      intvec* result = (intvec*) Mivlp(arg1);
1089
1090      res->rtyp = INTVEC_CMD;
1091      res->data =  result;
1092
1093      return FALSE;
1094    }
1095   else
1096#ifdef MpDiv
1097      if(strcmp(sys_cmd, "MpDiv") == 0)
1098      {
1099        if(h==NULL || h->Typ() != POLY_CMD ||
1100           h->next == NULL || h->next->Typ() != POLY_CMD)
1101        {
1102          Werror("system(\"MpDiv\",poly, poly) expected");
1103          return TRUE;
1104        }
1105        poly arg1 = (poly) h->Data();
1106        poly arg2 = (poly) h->next->Data();
1107
1108        poly result = MpDiv(arg1, arg2);
1109
1110        res->rtyp = POLY_CMD;
1111        res->data = result;
1112        return FALSE;
1113      }
1114    else
1115#endif
1116#ifdef MpMult
1117      if(strcmp(sys_cmd, "MpMult") == 0)
1118      {
1119        if(h==NULL || h->Typ() != POLY_CMD ||
1120           h->next == NULL || h->next->Typ() != POLY_CMD)
1121        {
1122          Werror("system(\"MpMult\",poly, poly) expected");
1123          return TRUE;
1124        }
1125        poly arg1 = (poly) h->Data();
1126        poly arg2 = (poly) h->next->Data();
1127
1128        poly result = MpMult(arg1, arg2);
1129        res->rtyp = POLY_CMD;
1130        res->data = result;
1131        return FALSE;
1132      }
1133  else
1134#endif
1135   if (strcmp(sys_cmd, "MivSame") == 0)
1136    {
1137      if(h == NULL || h->Typ() != INTVEC_CMD ||
1138         h->next == NULL || h->next->Typ() != INTVEC_CMD )
1139      {
1140        Werror("system(\"MivSame\", intvec, intvec) expected");
1141        return TRUE;
1142      }
1143      /*
1144      if (((intvec*) h->Data())->length() != currRing->N ||
1145          ((intvec*) h->next->Data())->length() != currRing->N)
1146      {
1147        Werror("system(\"MivSame\" ...) intvecs not of length %d\n",
1148               currRing->N);
1149        return TRUE;
1150      }
1151      */
1152      intvec* arg1 = (intvec*) h->Data();
1153      intvec* arg2 = (intvec*) h->next->Data();
1154      /*
1155      poly result = (poly) MivSame(arg1, arg2);
1156
1157      res->rtyp = POLY_CMD;
1158      res->data =  (poly) result;
1159      */
1160      res->rtyp = INT_CMD;
1161      res->data = (void*)(long) MivSame(arg1, arg2);
1162      return FALSE;
1163    }
1164  else
1165   if (strcmp(sys_cmd, "M3ivSame") == 0)
1166    {
1167      if(h == NULL || h->Typ() != INTVEC_CMD ||
1168         h->next == NULL || h->next->Typ() != INTVEC_CMD ||
1169         h->next->next == NULL || h->next->next->Typ() != INTVEC_CMD  )
1170      {
1171        Werror("system(\"M3ivSame\", intvec, intvec, intvec) expected");
1172        return TRUE;
1173      }
1174      /*
1175      if (((intvec*) h->Data())->length() != currRing->N ||
1176          ((intvec*) h->next->Data())->length() != currRing->N ||
1177          ((intvec*) h->next->next->Data())->length() != currRing->N )
1178      {
1179        Werror("system(\"M3ivSame\" ...) intvecs not of length %d\n",
1180               currRing->N);
1181        return TRUE;
1182      }
1183      */
1184      intvec* arg1 = (intvec*) h->Data();
1185      intvec* arg2 = (intvec*) h->next->Data();
1186      intvec* arg3 = (intvec*) h->next->next->Data();
1187      /*
1188      poly result = (poly) M3ivSame(arg1, arg2, arg3);
1189
1190      res->rtyp = POLY_CMD;
1191      res->data =  (poly) result;
1192      */
1193      res->rtyp = INT_CMD;
1194      res->data = (void*)(long) M3ivSame(arg1, arg2, arg3);
1195      return FALSE;
1196    }
1197  else
1198      if(strcmp(sys_cmd, "MwalkInitialForm") == 0)
1199      {
1200        if(h == NULL || h->Typ() != IDEAL_CMD ||
1201           h->next == NULL || h->next->Typ() != INTVEC_CMD)
1202        {
1203          Werror("system(\"MwalkInitialForm\", ideal, intvec) expected");
1204          return TRUE;
1205        }
1206        if(((intvec*) h->next->Data())->length() != currRing->N)
1207        {
1208          Werror("system \"MwalkInitialForm\"...) intvec not of length %d\n",
1209                 currRing->N);
1210          return TRUE;
1211        }
1212        ideal id      = (ideal) h->Data();
1213        intvec* int_w = (intvec*) h->next->Data();
1214        ideal result  = (ideal) MwalkInitialForm(id, int_w);
1215
1216        res->rtyp = IDEAL_CMD;
1217        res->data = result;
1218        return FALSE;
1219      }
1220  else
1221    /************** Perturbation walk **********/
1222     if(strcmp(sys_cmd, "MivMatrixOrder") == 0)
1223      {
1224        if(h==NULL || h->Typ() != INTVEC_CMD)
1225        {
1226          Werror("system(\"MivMatrixOrder\",intvec) expected");
1227          return TRUE;
1228        }
1229        intvec* arg1 = (intvec*) h->Data();
1230
1231        intvec* result = MivMatrixOrder(arg1);
1232
1233        res->rtyp = INTVEC_CMD;
1234        res->data =  result;
1235        return FALSE;
1236      }
1237    else
1238     if(strcmp(sys_cmd, "MivMatrixOrderdp") == 0)
1239      {
1240        if(h==NULL || h->Typ() != INT_CMD)
1241        {
1242          Werror("system(\"MivMatrixOrderdp\",intvec) expected");
1243          return TRUE;
1244        }
1245        int arg1 = (int) ((long)(h->Data()));
1246
1247        intvec* result = (intvec*) MivMatrixOrderdp(arg1);
1248
1249        res->rtyp = INTVEC_CMD;
1250        res->data =  result;
1251        return FALSE;
1252      }
1253    else
1254    if(strcmp(sys_cmd, "MPertVectors") == 0)
1255      {
1256
1257        if(h==NULL || h->Typ() != IDEAL_CMD ||
1258           h->next == NULL || h->next->Typ() != INTVEC_CMD ||
1259           h->next->next == NULL || h->next->next->Typ() != INT_CMD)
1260        {
1261          Werror("system(\"MPertVectors\",ideal, intvec, int) expected");
1262          return TRUE;
1263        }
1264
1265        ideal arg1 = (ideal) h->Data();
1266        intvec* arg2 = (intvec*) h->next->Data();
1267        int arg3 = (int) ((long)(h->next->next->Data()));
1268
1269        intvec* result = (intvec*) MPertVectors(arg1, arg2, arg3);
1270
1271        res->rtyp = INTVEC_CMD;
1272        res->data =  result;
1273        return FALSE;
1274      }
1275    else
1276    if(strcmp(sys_cmd, "MPertVectorslp") == 0)
1277      {
1278
1279        if(h==NULL || h->Typ() != IDEAL_CMD ||
1280           h->next == NULL || h->next->Typ() != INTVEC_CMD ||
1281           h->next->next == NULL || h->next->next->Typ() != INT_CMD)
1282        {
1283          Werror("system(\"MPertVectorslp\",ideal, intvec, int) expected");
1284          return TRUE;
1285        }
1286
1287        ideal arg1 = (ideal) h->Data();
1288        intvec* arg2 = (intvec*) h->next->Data();
1289        int arg3 = (int) ((long)(h->next->next->Data()));
1290
1291        intvec* result = (intvec*) MPertVectorslp(arg1, arg2, arg3);
1292
1293        res->rtyp = INTVEC_CMD;
1294        res->data =  result;
1295        return FALSE;
1296      }
1297        /************** fractal walk **********/
1298    else
1299      if(strcmp(sys_cmd, "Mfpertvector") == 0)
1300      {
1301        if(h==NULL || h->Typ() != IDEAL_CMD ||
1302          h->next==NULL || h->next->Typ() != INTVEC_CMD  )
1303        {
1304          Werror("system(\"Mfpertvector\", ideal,intvec) expected");
1305          return TRUE;
1306        }
1307        ideal arg1 = (ideal) h->Data();
1308        intvec* arg2 = (intvec*) h->next->Data();
1309        intvec* result = Mfpertvector(arg1, arg2);
1310
1311        res->rtyp = INTVEC_CMD;
1312        res->data =  result;
1313        return FALSE;
1314      }
1315    else
1316     if(strcmp(sys_cmd, "MivUnit") == 0)
1317      {
1318        int arg1 = (int) ((long)(h->Data()));
1319
1320        intvec* result = (intvec*) MivUnit(arg1);
1321
1322        res->rtyp = INTVEC_CMD;
1323        res->data =  result;
1324        return FALSE;
1325      }
1326     else
1327       if(strcmp(sys_cmd, "MivWeightOrderlp") == 0)
1328       {
1329        if(h==NULL || h->Typ() != INTVEC_CMD)
1330        {
1331          Werror("system(\"MivWeightOrderlp\",intvec) expected");
1332          return TRUE;
1333        }
1334        intvec* arg1 = (intvec*) h->Data();
1335        intvec* result = MivWeightOrderlp(arg1);
1336
1337        res->rtyp = INTVEC_CMD;
1338        res->data =  result;
1339        return FALSE;
1340      }
1341     else
1342    if(strcmp(sys_cmd, "MivWeightOrderdp") == 0)
1343      {
1344        if(h==NULL || h->Typ() != INTVEC_CMD)
1345        {
1346          Werror("system(\"MivWeightOrderdp\",intvec) expected");
1347          return TRUE;
1348        }
1349        intvec* arg1 = (intvec*) h->Data();
1350        //int arg2 = (int) h->next->Data();
1351
1352        intvec* result = MivWeightOrderdp(arg1);
1353
1354        res->rtyp = INTVEC_CMD;
1355        res->data =  result;
1356        return FALSE;
1357      }
1358    else
1359     if(strcmp(sys_cmd, "MivMatrixOrderlp") == 0)
1360      {
1361        if(h==NULL || h->Typ() != INT_CMD)
1362        {
1363          Werror("system(\"MivMatrixOrderlp\",int) expected");
1364          return TRUE;
1365        }
1366        int arg1 = (int) ((long)(h->Data()));
1367
1368        intvec* result = (intvec*) MivMatrixOrderlp(arg1);
1369
1370        res->rtyp = INTVEC_CMD;
1371        res->data =  result;
1372        return FALSE;
1373      }
1374    else
1375    if (strcmp(sys_cmd, "MkInterRedNextWeight") == 0)
1376    {
1377      if (h == NULL || h->Typ() != INTVEC_CMD ||
1378          h->next == NULL || h->next->Typ() != INTVEC_CMD ||
1379          h->next->next == NULL || h->next->next->Typ() != IDEAL_CMD)
1380      {
1381        Werror("system(\"MkInterRedNextWeight\", intvec, intvec, ideal) expected");
1382        return TRUE;
1383      }
1384
1385      if (((intvec*) h->Data())->length() != currRing->N ||
1386          ((intvec*) h->next->Data())->length() != currRing->N)
1387      {
1388        Werror("system(\"MkInterRedNextWeight\" ...) intvecs not of length %d\n",
1389               currRing->N);
1390        return TRUE;
1391      }
1392      intvec* arg1 = (intvec*) h->Data();
1393      intvec* arg2 = (intvec*) h->next->Data();
1394      ideal arg3   =   (ideal) h->next->next->Data();
1395
1396      intvec* result = (intvec*) MkInterRedNextWeight(arg1, arg2, arg3);
1397
1398      res->rtyp = INTVEC_CMD;
1399      res->data =  result;
1400
1401      return FALSE;
1402    }
1403    else
1404#ifdef MPertNextWeight
1405    if (strcmp(sys_cmd, "MPertNextWeight") == 0)
1406    {
1407      if (h == NULL || h->Typ() != INTVEC_CMD ||
1408          h->next == NULL || h->next->Typ() != IDEAL_CMD ||
1409          h->next->next == NULL || h->next->next->Typ() != INT_CMD)
1410      {
1411        Werror("system(\"MPertNextWeight\", intvec, ideal, int) expected");
1412        return TRUE;
1413      }
1414
1415      if (((intvec*) h->Data())->length() != currRing->N)
1416      {
1417        Werror("system(\"MPertNextWeight\" ...) intvecs not of length %d\n",
1418               currRing->N);
1419        return TRUE;
1420      }
1421      intvec* arg1 = (intvec*) h->Data();
1422      ideal arg2 = (ideal) h->next->Data();
1423      int arg3   =   (int) h->next->next->Data();
1424
1425      intvec* result = (intvec*) MPertNextWeight(arg1, arg2, arg3);
1426
1427      res->rtyp = INTVEC_CMD;
1428      res->data =  result;
1429
1430      return FALSE;
1431    }
1432    else
1433#endif //MPertNextWeight
1434#ifdef Mivperttarget
1435  if (strcmp(sys_cmd, "Mivperttarget") == 0)
1436    {
1437      if (h == NULL || h->Typ() != IDEAL_CMD ||
1438          h->next == NULL || h->next->Typ() != INT_CMD )
1439      {
1440        Werror("system(\"Mivperttarget\", ideal, int) expected");
1441        return TRUE;
1442      }
1443
1444      ideal arg1 = (ideal) h->Data();
1445      int arg2 = (int) h->next->Data();
1446
1447      intvec* result = (intvec*) Mivperttarget(arg1, arg2);
1448
1449      res->rtyp = INTVEC_CMD;
1450      res->data =  result;
1451
1452      return FALSE;
1453    }
1454    else
1455#endif //Mivperttarget
1456    if (strcmp(sys_cmd, "Mwalk") == 0)
1457    {
1458      if (h == NULL || h->Typ() != IDEAL_CMD ||
1459          h->next == NULL || h->next->Typ() != INTVEC_CMD ||
1460          h->next->next == NULL || h->next->next->Typ() != INTVEC_CMD)
1461      {
1462        Werror("system(\"Mwalk\", ideal, intvec, intvec) expected");
1463        return TRUE;
1464      }
1465
1466      if (((intvec*) h->next->Data())->length() != currRing->N &&
1467          ((intvec*) h->next->next->Data())->length() != currRing->N )
1468      {
1469        Werror("system(\"Mwalk\" ...) intvecs not of length %d\n",
1470               currRing->N);
1471        return TRUE;
1472      }
1473      ideal arg1 = (ideal) h->Data();
1474      intvec* arg2 = (intvec*) h->next->Data();
1475      intvec* arg3   =  (intvec*) h->next->next->Data();
1476
1477
1478      ideal result = (ideal) Mwalk(arg1, arg2, arg3);
1479
1480      res->rtyp = IDEAL_CMD;
1481      res->data =  result;
1482
1483      return FALSE;
1484    }
1485    else
1486#ifdef MPWALK_ORIG
1487    if (strcmp(sys_cmd, "Mpwalk") == 0)
1488    {
1489      if (h == NULL || h->Typ() != IDEAL_CMD ||
1490          h->next == NULL || h->next->Typ() != INT_CMD ||
1491          h->next->next == NULL || h->next->next->Typ() != INT_CMD ||
1492          h->next->next->next == NULL ||
1493            h->next->next->next->Typ() != INTVEC_CMD ||
1494          h->next->next->next->next == NULL ||
1495            h->next->next->next->next->Typ() != INTVEC_CMD)
1496      {
1497        Werror("system(\"Mpwalk\", ideal, int, int, intvec, intvec) expected");
1498        return TRUE;
1499      }
1500
1501      if (((intvec*) h->next->next->next->Data())->length() != currRing->N &&
1502          ((intvec*) h->next->next->next->next->Data())->length()!=currRing->N)
1503      {
1504        Werror("system(\"Mpwalk\" ...) intvecs not of length %d\n",
1505               currRing->N);
1506        return TRUE;
1507      }
1508      ideal arg1 = (ideal) h->Data();
1509      int arg2 = (int) h->next->Data();
1510      int arg3 = (int) h->next->next->Data();
1511      intvec* arg4 = (intvec*) h->next->next->next->Data();
1512      intvec* arg5   =  (intvec*) h->next->next->next->next->Data();
1513
1514
1515      ideal result = (ideal) Mpwalk(arg1, arg2, arg3, arg4, arg5);
1516
1517      res->rtyp = IDEAL_CMD;
1518      res->data =  result;
1519
1520      return FALSE;
1521    }
1522    else
1523#endif
1524    if (strcmp(sys_cmd, "Mpwalk") == 0)
1525    {
1526      if (h == NULL || h->Typ() != IDEAL_CMD ||
1527          h->next == NULL || h->next->Typ() != INT_CMD ||
1528          h->next->next == NULL || h->next->next->Typ() != INT_CMD ||
1529          h->next->next->next == NULL ||
1530            h->next->next->next->Typ() != INTVEC_CMD ||
1531          h->next->next->next->next == NULL ||
1532            h->next->next->next->next->Typ() != INTVEC_CMD||
1533          h->next->next->next->next->next == NULL ||
1534            h->next->next->next->next->next->Typ() != INT_CMD)
1535      {
1536        Werror("system(\"Mpwalk\", ideal, int, int, intvec, intvec, int) expected");
1537        return TRUE;
1538      }
1539
1540      if (((intvec*) h->next->next->next->Data())->length() != currRing->N &&
1541          ((intvec*) h->next->next->next->next->Data())->length()!=currRing->N)
1542      {
1543        Werror("system(\"Mpwalk\" ...) intvecs not of length %d\n",
1544               currRing->N);
1545        return TRUE;
1546      }
1547      ideal arg1 = (ideal) h->Data();
1548      int arg2 = (int) ((long)(h->next->Data()));
1549      int arg3 = (int) ((long)(h->next->next->Data()));
1550      intvec* arg4 = (intvec*) h->next->next->next->Data();
1551      intvec* arg5   =  (intvec*) h->next->next->next->next->Data();
1552      int arg6   =  (int) ((long)(h->next->next->next->next->next->Data()));
1553
1554
1555      ideal result = (ideal) Mpwalk(arg1, arg2, arg3, arg4, arg5, arg6);
1556
1557      res->rtyp = IDEAL_CMD;
1558      res->data =  result;
1559
1560      return FALSE;
1561    }
1562    else
1563    if (strcmp(sys_cmd, "MAltwalk1") == 0)
1564    {
1565      if (h == NULL || h->Typ() != IDEAL_CMD ||
1566          h->next == NULL || h->next->Typ() != INT_CMD ||
1567          h->next->next == NULL || h->next->next->Typ() != INT_CMD ||
1568          h->next->next->next == NULL ||
1569            h->next->next->next->Typ() != INTVEC_CMD ||
1570          h->next->next->next->next == NULL ||
1571            h->next->next->next->next->Typ() != INTVEC_CMD)
1572      {
1573        Werror("system(\"MAltwalk1\", ideal, int, int, intvec, intvec) expected");
1574        return TRUE;
1575      }
1576
1577      if (((intvec*) h->next->next->next->Data())->length() != currRing->N &&
1578          ((intvec*) h->next->next->next->next->Data())->length()!=currRing->N)
1579      {
1580        Werror("system(\"MAltwalk1\" ...) intvecs not of length %d\n",
1581               currRing->N);
1582        return TRUE;
1583      }
1584      ideal arg1 = (ideal) h->Data();
1585      int arg2 = (int) ((long)(h->next->Data()));
1586      int arg3 = (int) ((long)(h->next->next->Data()));
1587      intvec* arg4 = (intvec*) h->next->next->next->Data();
1588      intvec* arg5   =  (intvec*) h->next->next->next->next->Data();
1589
1590
1591      ideal result = (ideal) MAltwalk1(arg1, arg2, arg3, arg4, arg5);
1592
1593      res->rtyp = IDEAL_CMD;
1594      res->data =  result;
1595
1596      return FALSE;
1597    }
1598#ifdef MFWALK_ALT
1599    else
1600    if (strcmp(sys_cmd, "Mfwalk_alt") == 0)
1601    {
1602      if (h == NULL || h->Typ() != IDEAL_CMD ||
1603          h->next == NULL || h->next->Typ() != INTVEC_CMD ||
1604          h->next->next == NULL || h->next->next->Typ() != INTVEC_CMD ||
1605          h->next->next->next == NULL || h->next->next->next->Typ() !=INT_CMD)
1606      {
1607        Werror("system(\"Mfwalk\", ideal, intvec, intvec,int) expected");
1608        return TRUE;
1609      }
1610
1611      if (((intvec*) h->next->Data())->length() != currRing->N &&
1612          ((intvec*) h->next->next->Data())->length() != currRing->N )
1613      {
1614        Werror("system(\"Mfwalk\" ...) intvecs not of length %d\n",
1615               currRing->N);
1616        return TRUE;
1617      }
1618      ideal arg1 = (ideal) h->Data();
1619      intvec* arg2 = (intvec*) h->next->Data();
1620      intvec* arg3   =  (intvec*) h->next->next->Data();
1621      int arg4 = (int) h->next->next->next->Data();
1622
1623      ideal result = (ideal) Mfwalk_alt(arg1, arg2, arg3, arg4);
1624
1625      res->rtyp = IDEAL_CMD;
1626      res->data =  result;
1627
1628      return FALSE;
1629    }
1630#endif
1631    else
1632    if (strcmp(sys_cmd, "Mfwalk") == 0)
1633    {
1634      if (h == NULL || h->Typ() != IDEAL_CMD ||
1635          h->next == NULL || h->next->Typ() != INTVEC_CMD ||
1636          h->next->next == NULL || h->next->next->Typ() != INTVEC_CMD)
1637      {
1638        Werror("system(\"Mfwalk\", ideal, intvec, intvec) expected");
1639        return TRUE;
1640      }
1641
1642      if (((intvec*) h->next->Data())->length() != currRing->N &&
1643          ((intvec*) h->next->next->Data())->length() != currRing->N )
1644      {
1645        Werror("system(\"Mfwalk\" ...) intvecs not of length %d\n",
1646               currRing->N);
1647        return TRUE;
1648      }
1649      ideal arg1 = (ideal) h->Data();
1650      intvec* arg2 = (intvec*) h->next->Data();
1651      intvec* arg3   =  (intvec*) h->next->next->Data();
1652
1653      ideal result = (ideal) Mfwalk(arg1, arg2, arg3);
1654
1655      res->rtyp = IDEAL_CMD;
1656      res->data =  result;
1657
1658      return FALSE;
1659    }
1660    else
1661
1662#ifdef TRAN_Orig
1663    if (strcmp(sys_cmd, "TranMImprovwalk") == 0)
1664    {
1665      if (h == NULL || h->Typ() != IDEAL_CMD ||
1666          h->next == NULL || h->next->Typ() != INTVEC_CMD ||
1667          h->next->next == NULL || h->next->next->Typ() != INTVEC_CMD)
1668      {
1669        Werror("system(\"TranMImprovwalk\", ideal, intvec, intvec) expected");
1670        return TRUE;
1671      }
1672
1673      if (((intvec*) h->next->Data())->length() != currRing->N &&
1674          ((intvec*) h->next->next->Data())->length() != currRing->N )
1675      {
1676        Werror("system(\"TranMImprovwalk\" ...) intvecs not of length %d\n",
1677               currRing->N);
1678        return TRUE;
1679      }
1680      ideal arg1 = (ideal) h->Data();
1681      intvec* arg2 = (intvec*) h->next->Data();
1682      intvec* arg3   =  (intvec*) h->next->next->Data();
1683
1684
1685      ideal result = (ideal) TranMImprovwalk(arg1, arg2, arg3);
1686
1687      res->rtyp = IDEAL_CMD;
1688      res->data =  result;
1689
1690      return FALSE;
1691    }
1692    else
1693#endif
1694    if (strcmp(sys_cmd, "MAltwalk2") == 0)
1695      {
1696      if (h == NULL || h->Typ() != IDEAL_CMD ||
1697          h->next == NULL || h->next->Typ() != INTVEC_CMD ||
1698          h->next->next == NULL || h->next->next->Typ() != INTVEC_CMD)
1699      {
1700        Werror("system(\"MAltwalk2\", ideal, intvec, intvec) expected");
1701        return TRUE;
1702      }
1703
1704      if (((intvec*) h->next->Data())->length() != currRing->N &&
1705          ((intvec*) h->next->next->Data())->length() != currRing->N )
1706      {
1707        Werror("system(\"MAltwalk2\" ...) intvecs not of length %d\n",
1708               currRing->N);
1709        return TRUE;
1710      }
1711      ideal arg1 = (ideal) h->Data();
1712      intvec* arg2 = (intvec*) h->next->Data();
1713      intvec* arg3   =  (intvec*) h->next->next->Data();
1714
1715
1716      ideal result = (ideal) MAltwalk2(arg1, arg2, arg3);
1717
1718      res->rtyp = IDEAL_CMD;
1719      res->data =  result;
1720
1721      return FALSE;
1722    }
1723    else
1724    if (strcmp(sys_cmd, "TranMImprovwalk") == 0)
1725    {
1726      if (h == NULL || h->Typ() != IDEAL_CMD ||
1727          h->next == NULL || h->next->Typ() != INTVEC_CMD ||
1728          h->next->next == NULL || h->next->next->Typ() != INTVEC_CMD||
1729          h->next->next->next == NULL || h->next->next->next->Typ() != INT_CMD)
1730      {
1731        Werror("system(\"TranMImprovwalk\", ideal, intvec, intvec, int) expected");
1732        return TRUE;
1733      }
1734
1735      if (((intvec*) h->next->Data())->length() != currRing->N &&
1736          ((intvec*) h->next->next->Data())->length() != currRing->N )
1737      {
1738        Werror("system(\"TranMImprovwalk\" ...) intvecs not of length %d\n",
1739               currRing->N);
1740        return TRUE;
1741      }
1742      ideal arg1 = (ideal) h->Data();
1743      intvec* arg2 = (intvec*) h->next->Data();
1744      intvec* arg3   =  (intvec*) h->next->next->Data();
1745      int arg4   =  (int) ((long)(h->next->next->next->Data()));
1746
1747      ideal result = (ideal) TranMImprovwalk(arg1, arg2, arg3, arg4);
1748
1749      res->rtyp = IDEAL_CMD;
1750      res->data =  result;
1751
1752      return FALSE;
1753    }
1754    else
1755#endif
1756/*================= Extended system call ========================*/
1757   {
1758     #ifndef MAKE_DISTRIBUTION
1759     return(jjEXTENDED_SYSTEM(res, args));
1760     #else
1761     Werror( "system(\"%s\",...) %s", sys_cmd, feNotImplemented );
1762     #endif
1763   }
1764  } /* typ==string */
1765  return TRUE;
1766}
1767
1768
1769#ifdef HAVE_EXTENDED_SYSTEM
1770// You can put your own system calls here
1771#include "../kernel/fglmcomb.cc"
1772#include "fglm.h"
1773#ifdef HAVE_NEWTON
1774#include <hc_newton.h>
1775#endif
1776#include "mpsr.h"
1777#include "mod_raw.h"
1778#include "ratgring.h"
1779#include "shiftgb.h"
1780
1781static BOOLEAN jjEXTENDED_SYSTEM(leftv res, leftv h)
1782{
1783  if(h->Typ() == STRING_CMD)
1784  {
1785    char *sys_cmd=(char *)(h->Data());
1786    h=h->next;
1787/*==================== locNF ======================================*/
1788    if(strcmp(sys_cmd,"locNF")==0)
1789    {
1790      if (h != NULL && h->Typ() == VECTOR_CMD)
1791      {
1792        poly f=(poly)h->Data();
1793        h=h->next;
1794        if (h != NULL && h->Typ() == MODUL_CMD)
1795        {
1796          ideal m=(ideal)h->Data();
1797          assumeStdFlag(h);
1798          h=h->next;
1799          if (h != NULL && h->Typ() == INT_CMD)
1800          {
1801            int n=(int)((long)h->Data());
1802            h=h->next;
1803            if (h != NULL && h->Typ() == INTVEC_CMD)
1804            {
1805              intvec *v=(intvec *)h->Data();
1806
1807              /* == now the work starts == */
1808
1809              short * iv=iv2array(v);
1810              poly r=0;
1811              poly hp=ppJetW(f,n,iv);
1812              int s=MATCOLS(m);
1813              int j=0;
1814              matrix T=mpInitI(s,1,0);
1815
1816              while (hp != NULL)
1817              {
1818                if (pDivisibleBy(m->m[j],hp))
1819                  {
1820                    if (MATELEM(T,j+1,1)==0)
1821                    {
1822                      MATELEM(T,j+1,1)=pDivideM(pHead(hp),pHead(m->m[j]));
1823                    }
1824                    else
1825                    {
1826                      pAdd(MATELEM(T,j+1,1),pDivideM(pHead(hp),pHead(m->m[j])));
1827                    }
1828                    hp=ppJetW(ksOldSpolyRed(m->m[j],hp,0),n,iv);
1829                    j=0;
1830                  }
1831                else
1832                {
1833                  if (j==s-1)
1834                  {
1835                    r=pAdd(r,pHead(hp));
1836                    hp=pLmDeleteAndNext(hp); /* hp=pSub(hp,pHead(hp));*/
1837                    j=0;
1838                  }
1839                  else
1840                  {
1841                    j++;
1842                  }
1843                }
1844              }
1845
1846              matrix Temp=mpTransp((matrix) idVec2Ideal(r));
1847              matrix R=mpNew(MATCOLS((matrix) idVec2Ideal(f)),1);
1848              for (int k=1;k<=MATROWS(Temp);k++)
1849              {
1850                MATELEM(R,k,1)=MATELEM(Temp,k,1);
1851              }
1852
1853              lists L=(lists)omAllocBin(slists_bin);
1854              L->Init(2);
1855              L->m[0].rtyp=MATRIX_CMD;   L->m[0].data=(void *)R;
1856              L->m[1].rtyp=MATRIX_CMD;   L->m[1].data=(void *)T;
1857              res->data=L;
1858              res->rtyp=LIST_CMD;
1859              // iv aufraeumen
1860              omFree(iv);
1861            }
1862            else
1863            {
1864              Warn ("4th argument: must be an intvec!");
1865            }
1866          }
1867          else
1868          {
1869            Warn("3rd argument must be an int!!");
1870          }
1871        }
1872        else
1873        {
1874          Warn("2nd argument must be a module!");
1875        }
1876      }
1877      else
1878      {
1879        Warn("1st argument must be a vector!");
1880      }
1881      return FALSE;
1882    }
1883    else
1884/*==================== interred ==================================*/
1885    #if 0
1886    if(strcmp(sys_cmd,"interred")==0)
1887    {
1888      res->data=(char *)kIR((ideal)h->Data(),currQuotient);
1889      res->rtyp=h->Typ();
1890      return ((h->Typ()!=IDEAL_CMD) && (h->Typ()!=MODUL_CMD));
1891    }
1892    else
1893    #endif
1894#ifdef RDEBUG
1895/*==================== poly debug ==================================*/
1896    if(strcmp(sys_cmd,"p")==0)
1897    {
1898      pDebugPrint((poly)h->Data());
1899      return FALSE;
1900    }
1901    else
1902/*==================== ring debug ==================================*/
1903    if(strcmp(sys_cmd,"r")==0)
1904    {
1905      rDebugPrint((ring)h->Data());
1906      return FALSE;
1907    }
1908    else
1909#endif
1910/*==================== mtrack ==================================*/
1911    if(strcmp(sys_cmd,"mtrack")==0)
1912    {
1913#ifdef OM_TRACK
1914      om_Opts.MarkAsStatic = 1;
1915      FILE *fd = NULL;
1916      int max = 5;
1917      while (h != NULL)
1918      {
1919        omMarkAsStaticAddr(h);
1920        if (fd == NULL && h->Typ()==STRING_CMD)
1921        {
1922          fd = fopen((char*) h->Data(), "w");
1923          if (fd == NULL)
1924            Warn("Can not open %s for writing og mtrack. Using stdout");
1925        }
1926        if (h->Typ() == INT_CMD)
1927        {
1928          max = (int)(long)h->Data();
1929        }
1930        h = h->Next();
1931      }
1932      omPrintUsedTrackAddrs((fd == NULL ? stdout : fd), max);
1933      if (fd != NULL) fclose(fd);
1934      om_Opts.MarkAsStatic = 0;
1935      return FALSE;
1936#else
1937     WerrorS("mtrack not supported without OM_TRACK");
1938     return TRUE;
1939#endif
1940    }
1941/*==================== mtrack_all ==================================*/
1942    if(strcmp(sys_cmd,"mtrack_all")==0)
1943    {
1944#ifdef OM_TRACK
1945      om_Opts.MarkAsStatic = 1;
1946      FILE *fd = NULL;
1947      if ((h!=NULL) &&(h->Typ()==STRING_CMD))
1948      {
1949        fd = fopen((char*) h->Data(), "w");
1950        if (fd == NULL)
1951          Warn("Can not open %s for writing og mtrack. Using stdout");
1952        omMarkAsStaticAddr(h);
1953      }
1954      // OB: TBC print to fd
1955      omPrintUsedAddrs((fd == NULL ? stdout : fd), 5);
1956      if (fd != NULL) fclose(fd);
1957      om_Opts.MarkAsStatic = 0;
1958      return FALSE;
1959#else
1960     WerrorS("mtrack not supported without OM_TRACK");
1961     return TRUE;
1962#endif
1963    }
1964    else
1965/*==================== backtrace ==================================*/
1966    if(strcmp(sys_cmd,"backtrace")==0)
1967    {
1968#ifndef OM_NDEBUG
1969      omPrintCurrentBackTrace(stdout);
1970      return FALSE;
1971#else
1972     WerrorS("btrack not supported without OM_TRACK");
1973     return TRUE;
1974#endif
1975    }
1976    else
1977/*==================== naIdeal ==================================*/
1978    if(strcmp(sys_cmd,"naIdeal")==0)
1979    {
1980      if ((h!=NULL) &&(h->Typ()==IDEAL_CMD))
1981      {
1982        naSetIdeal((ideal)h->Data());
1983        return FALSE;
1984      }
1985      else
1986         WerrorS("ideal expected");
1987    }
1988    else
1989/*==================== isSqrFree =============================*/
1990#ifdef HAVE_FACTORY
1991    if(strcmp(sys_cmd,"isSqrFree")==0)
1992    {
1993      if ((h!=NULL) &&(h->Typ()==POLY_CMD))
1994      {
1995        res->rtyp=INT_CMD;
1996        res->data=(void *)(long) singclap_isSqrFree((poly)h->Data());
1997        return FALSE;
1998      }
1999      else
2000        WerrorS("poly expected");
2001    }
2002    else
2003#endif
2004/*==================== pDivStat =============================*/
2005#if defined(PDEBUG) || defined(PDIV_DEBUG)
2006    if(strcmp(sys_cmd,"pDivStat")==0)
2007    {
2008      extern void pPrintDivisbleByStat();
2009      pPrintDivisbleByStat();
2010      return FALSE;
2011    }
2012    else
2013#endif
2014/*==================== alarm ==================================*/
2015#ifdef unix
2016    if(strcmp(sys_cmd,"alarm")==0)
2017    {
2018      if ((h!=NULL) &&(h->Typ()==INT_CMD))
2019      {
2020        // standard variant -> SIGALARM (standard: abort)
2021        //alarm((unsigned)h->next->Data());
2022        // process time (user +system): SIGVTALARM
2023        struct itimerval t,o;
2024        memset(&t,0,sizeof(t));
2025        t.it_value.tv_sec     =(unsigned)((unsigned long)h->Data());
2026        setitimer(ITIMER_VIRTUAL,&t,&o);
2027        return FALSE;
2028      }
2029      else
2030        WerrorS("int expected");
2031    }
2032    else
2033#endif
2034/*==================== red =============================*/
2035#if 0
2036    if(strcmp(sys_cmd,"red")==0)
2037    {
2038      if ((h!=NULL) &&(h->Typ()==IDEAL_CMD))
2039      {
2040        res->rtyp=IDEAL_CMD;
2041        res->data=(void *)kStdred((ideal)h->Data(),NULL,testHomog,NULL);
2042        setFlag(res,FLAG_STD);
2043        return FALSE;
2044      }
2045      else
2046        WerrorS("ideal expected");
2047    }
2048    else
2049#endif
2050#ifdef HAVE_FACTORY
2051/*==================== fastcomb =============================*/
2052    if(strcmp(sys_cmd,"fastcomb")==0)
2053    {
2054      if ((h!=NULL) &&(h->Typ()==IDEAL_CMD))
2055      {
2056        int i=0;
2057        if (h->next!=NULL)
2058        {
2059          if (h->next->Typ()!=POLY_CMD)
2060          {
2061            Warn("Wrong types for poly= comb(ideal,poly)");
2062          }
2063        }
2064        res->rtyp=POLY_CMD;
2065        res->data=(void *) fglmLinearCombination(
2066                           (ideal)h->Data(),(poly)h->next->Data());
2067        return FALSE;
2068      }
2069      else
2070        WerrorS("ideal expected");
2071    }
2072    else
2073/*==================== comb =============================*/
2074    if(strcmp(sys_cmd,"comb")==0)
2075    {
2076      if ((h!=NULL) &&(h->Typ()==IDEAL_CMD))
2077      {
2078        int i=0;
2079        if (h->next!=NULL)
2080        {
2081          if (h->next->Typ()!=POLY_CMD)
2082          {
2083              Warn("Wrong types for poly= comb(ideal,poly)");
2084          }
2085        }
2086        res->rtyp=POLY_CMD;
2087        res->data=(void *)fglmNewLinearCombination(
2088                            (ideal)h->Data(),(poly)h->next->Data());
2089        return FALSE;
2090      }
2091      else
2092        WerrorS("ideal expected");
2093    }
2094    else
2095#endif
2096#ifdef FACTORY_GCD_TEST
2097/*=======================gcd Testerei ================================*/
2098    if ( ! strcmp( sys_cmd, "setgcd" ) ) {
2099        if ( (h != NULL) && (h->Typ() == INT_CMD) ) {
2100            CFPrimitiveGcdUtil::setAlgorithm( (int)h->Data() );
2101            return FALSE;
2102        } else
2103            WerrorS("int expected");
2104    }
2105    else
2106#endif
2107
2108#ifdef FACTORY_GCD_TIMING
2109    if ( ! strcmp( sys_cmd, "gcdtime" ) ) {
2110        TIMING_PRINT( contentTimer, "time used for content: " );
2111        TIMING_PRINT( algContentTimer, "time used for algContent: " );
2112        TIMING_PRINT( algLcmTimer, "time used for algLcm: " );
2113        TIMING_RESET( contentTimer );
2114        TIMING_RESET( algContentTimer );
2115        TIMING_RESET( algLcmTimer );
2116        return FALSE;
2117    }
2118    else
2119#endif
2120
2121#ifdef FACTORY_GCD_STAT
2122    if ( ! strcmp( sys_cmd, "gcdstat" ) ) {
2123        printGcdTotal();
2124        printContTotal();
2125        resetGcdTotal();
2126        resetContTotal();
2127        return FALSE;
2128    }
2129    else
2130#endif
2131#if !defined(HAVE_NS)
2132/*==================== lib ==================================*/
2133    if(strcmp(sys_cmd,"LIB")==0)
2134    {
2135      idhdl hh=idroot->get((char*)h->Data(),0);
2136      if ((hh!=NULL)&&(IDTYP(hh)==PROC_CMD))
2137      {
2138        res->rtyp=STRING_CMD;
2139        char *r=iiGetLibName(IDPROC(hh));
2140        if (r==NULL) r="";
2141        res->data=omStrDup(r);
2142        return FALSE;
2143      }
2144      else
2145        Warn("`%s` not found",(char*)h->Data());
2146    }
2147    else
2148#endif
2149/*==================== listall ===================================*/
2150    if(strcmp(sys_cmd,"listall")==0)
2151    {
2152      int showproc=0;
2153      if ((h!=NULL) && (h->Typ()==INT_CMD)) showproc=(int)((long)h->Data());
2154#ifdef HAVE_NS
2155      listall(showproc);
2156#else
2157      idhdl hh=IDROOT;
2158      while (hh!=NULL)
2159      {
2160        if (IDDATA(hh)==(void *)currRing) PrintS("(R)");
2161        else PrintS("   ");
2162        Print("::%s, typ %s level %d\n",
2163               IDID(hh),Tok2Cmdname(IDTYP(hh)),IDLEV(hh));
2164        hh=IDNEXT(hh);
2165      }
2166      hh=IDROOT;
2167      while (hh!=NULL)
2168      {
2169        if ((IDTYP(hh)==RING_CMD)
2170        || (IDTYP(hh)==QRING_CMD)
2171        || (IDTYP(hh)==PACKAGE_CMD))
2172        {
2173          idhdl h2=IDRING(hh)->idroot;
2174          while (h2!=NULL)
2175          {
2176            if (IDDATA(h2)==(void *)currRing) PrintS("(R)");
2177            else PrintS("   ");
2178            Print("%s::%s, typ %s level %d\n",
2179            IDID(hh),IDID(h2),Tok2Cmdname(IDTYP(h2)),IDLEV(h2));
2180            h2=IDNEXT(h2);
2181          }
2182        }
2183        hh=IDNEXT(hh);
2184      }
2185#endif /* HAVE_NS */
2186      return FALSE;
2187    }
2188    else
2189/*==================== proclist =================================*/
2190    if(strcmp(sys_cmd,"proclist")==0)
2191    {
2192      piShowProcList();
2193      return FALSE;
2194    }
2195    else
2196/* ==================== newton ================================*/
2197#ifdef HAVE_NEWTON
2198    if(strcmp(sys_cmd,"newton")==0)
2199    {
2200      if ((h->Typ()!=POLY_CMD)
2201      || (h->next->Typ()!=INT_CMD)
2202      || (h->next->next->Typ()!=INT_CMD))
2203      {
2204        WerrorS("system(\"newton\",<poly>,<int>,<int>) expected");
2205        return TRUE;
2206      }
2207      poly  p=(poly)(h->Data());
2208      int l=pLength(p);
2209      short *points=(short *)omAlloc(currRing->N*l*sizeof(short));
2210      int i,j,k;
2211      k=0;
2212      poly pp=p;
2213      for (i=0;pp!=NULL;i++)
2214      {
2215        for(j=1;j<=currRing->N;j++)
2216        {
2217          points[k]=pGetExp(pp,j);
2218          k++;
2219        }
2220        pIter(pp);
2221      }
2222      hc_ERG r=hc_KOENIG(currRing->N,      // dimension
2223                l,      // number of points
2224                (short*) points,   // points: x_1, y_1,z_1, x_2,y_2,z2,...
2225                currRing->OrdSgn==-1,
2226                (int) (h->next->Data()),      // 1: Milnor, 0: Newton
2227                (int) (h->next->next->Data()) // debug
2228               );
2229      //----<>---Output-----------------------
2230
2231
2232//  PrintS("Bin jetzt in extra.cc bei der Auswertung.\n"); // **********
2233
2234
2235      lists L=(lists)omAllocBin(slists_bin);
2236      L->Init(6);
2237      L->m[0].rtyp=STRING_CMD;               // newtonnumber;
2238      L->m[0].data=(void *)omStrDup(r.nZahl);
2239      L->m[1].rtyp=INT_CMD;
2240      L->m[1].data=(void *)r.achse;          // flag for unoccupied axes
2241      L->m[2].rtyp=INT_CMD;
2242      L->m[2].data=(void *)r.deg;            // #degenerations
2243      if ( r.deg != 0)              // only if degenerations exist
2244      {
2245        L->m[3].rtyp=INT_CMD;
2246        L->m[3].data=(void *)r.anz_punkte;     // #points
2247        //---<>--number of points------
2248        int anz = r.anz_punkte;    // number of points
2249        int dim = (currRing->N);     // dimension
2250        intvec* v = new intvec( anz*dim );
2251        for (i=0; i<anz*dim; i++)    // copy points
2252          (*v)[i] = r.pu[i];
2253        L->m[4].rtyp=INTVEC_CMD;
2254        L->m[4].data=(void *)v;
2255        //---<>--degenerations---------
2256        int deg = r.deg;    // number of points
2257        intvec* w = new intvec( r.speicher );  // necessary memeory
2258        i=0;               // start copying
2259        do
2260        {
2261          (*w)[i] = r.deg_tab[i];
2262          i++;
2263        }
2264        while (r.deg_tab[i-1] != -2);   // mark for end of list
2265        L->m[5].rtyp=INTVEC_CMD;
2266        L->m[5].data=(void *)w;
2267      }
2268      else
2269      {
2270        L->m[3].rtyp=INT_CMD; L->m[3].data=(char *)0;
2271        L->m[4].rtyp=DEF_CMD;
2272        L->m[5].rtyp=DEF_CMD;
2273      }
2274
2275      res->data=(void *)L;
2276      res->rtyp=LIST_CMD;
2277      // free all pointer in r:
2278      delete[] r.nZahl;
2279      delete[] r.pu;
2280      delete[] r.deg_tab;      // Ist das ein Problem??
2281
2282      omFreeSize((ADDRESS)points,currRing->N*l*sizeof(short));
2283      return FALSE;
2284    }
2285    else
2286#endif
2287/*==================== sdb_flags =================*/
2288#ifdef HAVE_SDB
2289    if (strcmp(sys_cmd, "sdb_flags") == 0)
2290    {
2291      if ((h!=NULL) && (h->Typ()==INT_CMD))
2292      {
2293        sdb_flags=(int)((long)h->Data());
2294      }
2295      else
2296      {
2297        WerrorS("system(\"sdb_flags\",`int`) expected");
2298        return TRUE;
2299      }
2300      return FALSE;
2301    }
2302    else
2303/*==================== sdb_edit =================*/
2304    if (strcmp(sys_cmd, "sdb_edit") == 0)
2305    {
2306      if ((h!=NULL) && (h->Typ()==PROC_CMD))
2307      {
2308        procinfov p=(procinfov)h->Data();
2309        sdb_edit(p);
2310      }
2311      else
2312      {
2313        WerrorS("system(\"sdb_edit\",`proc`) expected");
2314        return TRUE;
2315      }
2316      return FALSE;
2317    }
2318    else
2319#endif
2320/*==================== GF =================*/
2321#if 0
2322    if (strcmp(sys_cmd, "GF") == 0)
2323    {
2324      int c=rChar(currRing);
2325      setCharacteristic( c, 2);
2326      CanonicalForm F( convSingGFClapGF( (poly)h->Data() ) );
2327      res->rtyp=POLY_CMD;
2328      res->data=convClapGFSingGF( F );
2329      return FALSE;
2330    }
2331    else
2332#endif
2333/*==================== stdX =================*/
2334    if (strcmp(sys_cmd, "std") == 0)
2335    {
2336      ideal i1;
2337      int i2;
2338      if ((h!=NULL) && (h->Typ()==MODUL_CMD))
2339      {
2340        i1=(ideal)h->CopyD();
2341        h=h->next;
2342      }
2343      else return TRUE;
2344      if ((h!=NULL) && (h->Typ()==INT_CMD))
2345      {
2346        i2=(int)((long)h->Data());
2347      }
2348      else return TRUE;
2349      res->rtyp=MODUL_CMD;
2350      res->data=idXXX(i1,i2);
2351      return FALSE;
2352    }
2353    else
2354/*==================== SVD =================*/
2355#ifdef HAVE_SVD
2356     if (strcmp(sys_cmd, "svd") == 0)
2357     {
2358          extern lists testsvd(matrix M);
2359            res->rtyp=LIST_CMD;
2360          res->data=(char*)(testsvd((matrix)h->Data()));
2361          return FALSE;
2362     }
2363     else
2364#endif
2365#ifdef ix86_Win
2366#ifdef HAVE_DL
2367/*==================== DLL =================*/
2368/* testing the DLL functionality under Win32 */
2369      if (strcmp(sys_cmd, "DLL") == 0)
2370      {
2371        typedef void  (*Void_Func)();
2372        typedef int  (*Int_Func)(int);
2373        void *hh=dynl_open("WinDllTest.dll");
2374        if ((h!=NULL) && (h->Typ()==INT_CMD))
2375        {
2376          int (*f)(int);
2377          if (hh!=NULL)
2378          {
2379            int (*f)(int);
2380            f=(Int_Func)dynl_sym(hh,"PlusDll");
2381            int i=10;
2382            if (f!=NULL) printf("%d\n",f(i));
2383            else PrintS("cannot find PlusDll\n");
2384          }
2385        }
2386        else
2387        {
2388          void (*f)();
2389          f= (Void_Func)dynl_sym(hh,"TestDll");
2390          if (f!=NULL) f();
2391          else PrintS("cannot find TestDll\n");
2392        }
2393        return FALSE;
2394      }
2395      else
2396#endif
2397#endif
2398/*==================== eigenvalues ==================================*/
2399#ifdef HAVE_EIGENVAL
2400    if(strcmp(sys_cmd,"eigenvals")==0)
2401    {
2402      return evEigenvals(res,h);
2403    }
2404    else
2405#endif
2406/*==================== Gauss-Manin system ==================================*/
2407#ifdef HAVE_GMS
2408    if(strcmp(sys_cmd,"gmsnf")==0)
2409    {
2410      return gmsNF(res,h);
2411    }
2412    else
2413#endif
2414/*==================== facstd_debug ==================================*/
2415#if !defined(NDEBUG)
2416    if(strcmp(sys_cmd,"facstd")==0)
2417    {
2418      extern int strat_nr;
2419      extern int strat_fac_debug;
2420      strat_fac_debug=(int)(long)h->Data();
2421      strat_nr=0;
2422      return FALSE;
2423    }
2424    else
2425#endif
2426#ifdef HAVE_RING2TOM
2427/*==================== ring-GB ==================================*/
2428    if (strcmp(sys_cmd, "findZeroPoly")==0)
2429    {
2430      ring r = currRing;
2431      poly f = (poly) h->Data();
2432      res->rtyp=POLY_CMD;
2433      res->data=(poly) kFindZeroPoly(f, r, r);
2434      return(FALSE);
2435    }
2436    else
2437#ifdef HAVE_VANIDEAL
2438/*==================== Creating zero polynomials =================*/
2439    if (strcmp(sys_cmd, "createG0")==0)
2440    {
2441      /* long exp[50];
2442      int N = 0;
2443      while (h != NULL)
2444      {
2445        N += 1;
2446        exp[N] = (long) h->Data();
2447        // if (exp[i] % 2 != 0) exp[i] -= 1;
2448        h = h->next;
2449      }
2450      for (int k = 1; N + k <= currRing->N; k++) exp[k] = 0;
2451
2452      poly t_p;
2453      res->rtyp=POLY_CMD;
2454      res->data= (poly) kCreateZeroPoly(exp, -1, &t_p, currRing, currRing);
2455      return(FALSE); */
2456
2457      res->rtyp = IDEAL_CMD;
2458      res->data = (ideal) createG0();
2459      return(FALSE);
2460    }
2461    else
2462#endif
2463    if (strcmp(sys_cmd, "redNF_ring")==0)
2464    {
2465      ring r = currRing;
2466      poly f = (poly) h->Data();
2467      h = h->next;
2468      ideal G = (ideal) h->Data();
2469      res->rtyp=POLY_CMD;
2470      res->data=(poly) ringRedNF(f, G, r);
2471      return(FALSE);
2472    }
2473    else
2474#endif
2475#ifdef HAVE_F5
2476/*==================== F5 Implementation =================*/
2477    if (strcmp(sys_cmd, "f5")==0)
2478    {
2479      if (h->Typ()!=IDEAL_CMD)
2480      {
2481        WerrorS("ideal expected");
2482        return TRUE;
2483      } 
2484     
2485      ring r = currRing;
2486      ideal G = (ideal) h->Data();
2487      res->rtyp=IDEAL_CMD;
2488      res->data=(ideal) F5main(G,r);
2489      return TRUE;
2490    }
2491    else
2492#endif
2493#ifdef HAVE_RINGS
2494/*==================== Testing groebner basis =================*/
2495    if (strcmp(sys_cmd, "NF_ring")==0)
2496    {
2497      ring r = currRing;
2498      poly f = (poly) h->Data();
2499      h = h->next;
2500      ideal G = (ideal) h->Data();
2501      res->rtyp=POLY_CMD;
2502      res->data=(poly) ringNF(f, G, r);
2503      return(FALSE);
2504    }
2505    else
2506    if (strcmp(sys_cmd, "spoly")==0)
2507    {
2508      poly f = pCopy((poly) h->Data());
2509      h = h->next;
2510      poly g = pCopy((poly) h->Data());
2511
2512      res->rtyp=POLY_CMD;
2513      res->data=(poly) plain_spoly(f,g);
2514      return(FALSE);
2515    }
2516    else
2517    if (strcmp(sys_cmd, "testGB")==0)
2518    {
2519      ideal I = (ideal) h->Data();
2520      h = h->next;
2521      ideal GI = (ideal) h->Data();
2522      res->rtyp = INT_CMD;
2523      res->data = (void *) testGB(I, GI);
2524      return(FALSE);
2525    }
2526    else
2527#endif
2528#ifdef HAVE_PLURAL
2529/*==================== sca?AltVar ==================================*/
2530    if ( (strcmp(sys_cmd, "AltVarStart") == 0) || (strcmp(sys_cmd, "AltVarEnd") == 0) )
2531    {
2532      ring r = currRing;
2533
2534      if((h!=NULL) && (h->Typ()==RING_CMD)) r = (ring)h->Data(); else
2535      {
2536        WerrorS("`system(\"AltVarStart/End\"[,<ring>])` expected");
2537        return TRUE;
2538      }
2539
2540      res->rtyp=INT_CMD;
2541
2542      if (rIsSCA(r))
2543      {
2544        if(strcmp(sys_cmd, "AltVarStart") == 0)
2545          res->data = (void*)scaFirstAltVar(r);
2546        else
2547          res->data = (void*)scaLastAltVar(r);
2548        return FALSE;
2549      }
2550
2551      WerrorS("`system(\"AltVarStart/End\",<ring>) requires a SCA ring");
2552      return TRUE;
2553    }
2554    else
2555#endif
2556#ifdef HAVE_PLURAL
2557#ifdef HAVE_RATGRING
2558/*==================== RatNF, noncomm rational coeffs =================*/
2559    if (strcmp(sys_cmd, "intratNF") == 0)
2560    {
2561      poly p;
2562      poly *q;
2563      ideal I;
2564      int is, k, id;
2565      if ((h!=NULL) && (h->Typ()==POLY_CMD))
2566      {
2567        p=(poly)h->CopyD();
2568        h=h->next;
2569        //      Print("poly is done\n");
2570      }
2571      else return TRUE;
2572      if ((h!=NULL) && (h->Typ()==IDEAL_CMD))
2573      {
2574        I=(ideal)h->CopyD();
2575        q = I->m;
2576        h=h->next;
2577        //      Print("ideal is done\n");
2578      }
2579      else return TRUE;
2580      if ((h!=NULL) && (h->Typ()==INT_CMD))
2581      {
2582        is=(int)((long)(h->Data()));
2583        //      res->rtyp=INT_CMD;
2584        //      Print("int is done\n");
2585        //      res->rtyp=IDEAL_CMD;
2586        if (rIsPluralRing(currRing))
2587        { 
2588          id = IDELEMS(I);
2589          int *pl=(int*)omAlloc0(IDELEMS(I)*sizeof(int));
2590          for(k=0; k < id; k++)
2591          {
2592            pl[k] = pLength(I->m[k]);
2593          }
2594          Print("starting redRat\n");
2595          //res->data = (char *)
2596          redRat(&p, q, pl, (int)IDELEMS(I),is,currRing);
2597          res->data=p;
2598          res->rtyp=POLY_CMD;
2599          //    res->data = ncGCD(p,q,currRing);       
2600        }
2601        else 
2602        {
2603          res->rtyp=POLY_CMD;
2604          res->data=p;
2605        }
2606      }
2607      else return TRUE;
2608      return FALSE;
2609    }
2610    else
2611/*==================== RatNF, noncomm rational coeffs =================*/
2612    if (strcmp(sys_cmd, "ratNF") == 0)
2613    {
2614      poly p,q;
2615      int is;
2616      if ((h!=NULL) && (h->Typ()==POLY_CMD))
2617      {
2618        p=(poly)h->CopyD();
2619        h=h->next;
2620      }
2621      else return TRUE;
2622      if ((h!=NULL) && (h->Typ()==POLY_CMD))
2623      {
2624        q=(poly)h->CopyD();
2625        h=h->next;
2626      }
2627      else return TRUE;
2628      if ((h!=NULL) && (h->Typ()==INT_CMD))
2629      {
2630        is=(int)((long)(h->Data()));
2631        res->rtyp=POLY_CMD;
2632        //      res->rtyp=IDEAL_CMD;
2633        if (rIsPluralRing(currRing))
2634        { 
2635          res->data = nc_rat_ReduceSpolyNew(q,p,is, currRing);
2636          //    res->data = ncGCD(p,q,currRing);       
2637        }
2638        else res->data=p;
2639      }
2640      else return TRUE;
2641      return FALSE;
2642    }
2643    else
2644#endif // HAVE_RATGRING
2645/*==================== Rat def =================*/
2646    if (strcmp(sys_cmd, "ratVar") == 0)
2647    {
2648      int start,end;
2649      int is;
2650      if ((h!=NULL) && (h->Typ()==POLY_CMD))
2651      {
2652        start=pIsPurePower((poly)h->Data());
2653        h=h->next;
2654      }
2655      else return TRUE;
2656      if ((h!=NULL) && (h->Typ()==POLY_CMD))
2657      {
2658        end=pIsPurePower((poly)h->Data());
2659        h=h->next;
2660      }
2661      else return TRUE;
2662      currRing->real_var_start=start;
2663      currRing->real_var_end=end;
2664      return (start==0)||(end==0)||(start>end);
2665    }
2666    else
2667/*==================== shift-test for freeGB  =================*/
2668#ifdef HAVE_SHIFTBBA
2669    if (strcmp(sys_cmd, "stest") == 0)
2670    {
2671      poly p;
2672      int sh,uptodeg, lVblock;
2673      if ((h!=NULL) && (h->Typ()==POLY_CMD))
2674      {
2675        p=(poly)h->CopyD();
2676        h=h->next;
2677      }
2678      else return TRUE;
2679      if ((h!=NULL) && (h->Typ()==INT_CMD))
2680      {
2681        sh=(int)((long)(h->Data()));
2682        h=h->next;
2683      }
2684      else return TRUE;
2685
2686      if ((h!=NULL) && (h->Typ()==INT_CMD))
2687      {
2688        uptodeg=(int)((long)(h->Data()));
2689        h=h->next;
2690      }
2691      else return TRUE;
2692      if ((h!=NULL) && (h->Typ()==INT_CMD))
2693      {
2694        lVblock=(int)((long)(h->Data()));
2695        res->data = pLPshift(p,sh,uptodeg,lVblock);
2696        res->rtyp = POLY_CMD;
2697      }
2698      else return TRUE;
2699      return FALSE;
2700    }
2701    else
2702#endif
2703/*==================== block-test for freeGB  =================*/
2704#ifdef HAVE_SHIFTBBA
2705    if (strcmp(sys_cmd, "btest") == 0)
2706    {
2707      poly p;
2708      int lV;
2709      if ((h!=NULL) && (h->Typ()==POLY_CMD))
2710      {
2711        p=(poly)h->CopyD();
2712        h=h->next;
2713      }
2714      else return TRUE;
2715      if ((h!=NULL) && (h->Typ()==INT_CMD))
2716      {
2717        lV=(int)((long)(h->Data()));
2718        res->rtyp = INT_CMD;
2719        res->data = (void*)pLastVblock(p, lV);
2720      }
2721      else return TRUE;
2722      return FALSE;
2723    }
2724    else
2725/*==================== shrink-test for freeGB  =================*/
2726    if (strcmp(sys_cmd, "shrinktest") == 0)
2727    {
2728      poly p;
2729      int lV;
2730      if ((h!=NULL) && (h->Typ()==POLY_CMD))
2731      {
2732        p=(poly)h->CopyD();
2733        h=h->next;
2734      }
2735      else return TRUE;
2736      if ((h!=NULL) && (h->Typ()==INT_CMD))
2737      {
2738        lV=(int)((long)(h->Data()));
2739        res->rtyp = POLY_CMD;
2740        //      res->data = p_mShrink(p, lV, currRing);
2741        //      kStrategy strat=new skStrategy;
2742        //      strat->tailRing = currRing;
2743        res->data = p_Shrink(p, lV, currRing);
2744      }
2745      else return TRUE;
2746      return FALSE;
2747    }
2748    else
2749#endif
2750#endif
2751/*==================== t-rep-GB ==================================*/
2752    if (strcmp(sys_cmd, "unifastmult")==0)
2753    {
2754      ring r = currRing;
2755      poly f = (poly)h->Data();
2756      h=h->next;
2757      poly g=(poly)h->Data();
2758      res->rtyp=POLY_CMD;
2759      res->data=unifastmult(f,g,currRing);
2760      return(FALSE);
2761    }
2762    else
2763    if (strcmp(sys_cmd, "multifastmult")==0)
2764    {
2765      ring r = currRing;
2766      poly f = (poly)h->Data();
2767      h=h->next;
2768      poly g=(poly)h->Data();
2769      res->rtyp=POLY_CMD;
2770      res->data=multifastmult(f,g,currRing);
2771      return(FALSE);
2772    }
2773    else
2774    if (strcmp(sys_cmd, "mults")==0)
2775    {
2776      res->rtyp=INT_CMD ;
2777      res->data=(void*)(long) Mults();
2778      return(FALSE);
2779    }
2780    else
2781    if (strcmp(sys_cmd, "fastpower")==0)
2782    {
2783      ring r = currRing;
2784      poly f = (poly)h->Data();
2785      h=h->next;
2786      int n=(int)((long)h->Data());
2787      res->rtyp=POLY_CMD ;
2788      res->data=(void*) pFastPower(f,n,r);
2789      return(FALSE);
2790    }
2791    else
2792    if (strcmp(sys_cmd, "normalpower")==0)
2793    {
2794      ring r = currRing;
2795      poly f = (poly)h->Data();
2796      h=h->next;
2797      int n=(int)((long)h->Data());
2798      res->rtyp=POLY_CMD ;
2799      res->data=(void*) pPower(pCopy(f),n);
2800      return(FALSE);
2801    }
2802    else
2803    if (strcmp(sys_cmd, "MCpower")==0)
2804    {
2805      ring r = currRing;
2806      poly f = (poly)h->Data();
2807      h=h->next;
2808      int n=(int)((long)h->Data());
2809      res->rtyp=POLY_CMD ;
2810      res->data=(void*) pFastPowerMC(f,n,r);
2811      return(FALSE);
2812    }
2813    else
2814    if (strcmp(sys_cmd, "bit_subst")==0)
2815    {
2816      ring r = currRing;
2817      poly outer = (poly)h->Data();
2818      h=h->next;
2819      poly inner=(poly)h->Data();
2820      res->rtyp=POLY_CMD ;
2821      res->data=(void*) uni_subst_bits(outer, inner,r);
2822      return(FALSE);
2823    }
2824    else
2825/*==================== bifac =================*/
2826#ifdef HAVE_BIFAC
2827    if (strcmp(sys_cmd, "bifac")==0)
2828    {
2829      if (h->Typ()!=POLY_CMD)
2830      {
2831        WerrorS("`system(\"bifac\",<poly>) expected");
2832        return TRUE;
2833      }
2834      if (!rField_is_Q())
2835      {
2836        WerrorS("coeff field must be Q");
2837        return TRUE;
2838      }
2839      BIFAC B;
2840      CFFList C;
2841      int sw_rat=isOn(SW_RATIONAL);
2842      On(SW_RATIONAL);
2843      CanonicalForm F( convSingPClapP((poly)(h->Data())));
2844      B.bifac(F, 1);
2845      CFFList L=B.getFactors();
2846      // construct the ring ==============================================
2847      int i;
2848      int lev=ExtensionLevel();
2849      char **names=(char**)omAlloc0(lev*sizeof(char_ptr));
2850      for(i=1;i<=lev; i++)
2851      {
2852        StringSetS("");
2853        names[i-1]=omStrDup(StringAppend("a(%d)",i));
2854      }
2855      ring alg_ring=rDefault(0,lev,names);
2856      ring new_ring=rCopy0(currRing); // all variable names, ordering etc.
2857      new_ring->P=lev;
2858      new_ring->parameter=names;
2859      new_ring->algring=alg_ring;
2860      new_ring->ch=1;
2861      rComplete(new_ring,TRUE);
2862      // set the mipo ===============================================
2863      ring save_currRing=currRing; idhdl save_currRingHdl=currRingHdl;
2864      rChangeCurrRing(alg_ring);
2865      ideal mipo_id=idInit(lev,1);
2866      for (i=lev; i>0;i--)
2867      {
2868        CanonicalForm Mipo=getMipo(Variable(-i),Variable(i));
2869        mipo_id->m[i-1]=convClapPSingP(Mipo);
2870      }
2871      idShow(mipo_id);
2872      alg_ring->qideal=mipo_id;
2873      rChangeCurrRing(new_ring);
2874      for (i=lev-1; i>=0;i--)
2875      {
2876        poly p=pOne();
2877        lnumber n=(lnumber)pGetCoeff(p);
2878        // no need to delete nac 1
2879        n->z=(napoly)mipo_id->m[i];
2880        mipo_id->m[i]=p;
2881      }
2882      new_ring->minideal=id_Copy(alg_ring->qideal,new_ring);
2883      // convert factors =============================================
2884      ideal fac_id=idInit(L.length(),1);
2885      CFFListIterator J=L;
2886      i=0;
2887      intvec *v = new intvec( L.length() );
2888      for ( ; J.hasItem(); J++,i++ )
2889      {
2890        fac_id->m[i]=convClapAPSingAP( J.getItem().factor() );
2891        (*v)[i]=J.getItem().exp();
2892      }
2893      idhdl hh=enterid("factors",0,LIST_CMD,&(currRing->idroot),FALSE);
2894      lists LL=(lists)omAllocBin( slists_bin);
2895      LL->Init(2);
2896      LL->m[0].rtyp=IDEAL_CMD;
2897      LL->m[0].data=(char *)fac_id;
2898      LL->m[1].rtyp=INTVEC_CMD;
2899      LL->m[1].data=(char *)v;
2900      IDDATA(hh)=(char *)LL;
2901
2902      rChangeCurrRing(save_currRing);
2903      currRingHdl=save_currRingHdl;
2904      if (!sw_rat) Off(SW_RATIONAL);
2905
2906      res->data=new_ring;
2907      res->rtyp=RING_CMD;
2908      return FALSE;
2909    }
2910    else
2911#endif
2912/*==================== gcd-varianten =================*/
2913    if (strcmp(sys_cmd, "gcd") == 0)
2914    {
2915      if (h==NULL)
2916      {
2917        Print("NTL_0:%d (use NTL for gcd of polynomials in char 0)\n",isOn(SW_USE_NTL_GCD_0));
2918        Print("NTL_p:%d (use NTL for gcd of polynomials in char p)\n",isOn(SW_USE_NTL_GCD_P));
2919        Print("EZGCD:%d (use EZGCD for gcd of polynomials in char 0)\n",isOn(SW_USE_EZGCD));
2920        Print("EZGCD_P:%d (use EZGCD_P for gcd of polynomials in char p)\n",isOn(SW_USE_EZGCD_P));
2921        Print("CRGCD:%d (use chinese Remainder for gcd of polynomials in char 0)\n",isOn(SW_USE_CHINREM_GCD));
2922        Print("SPARSEMOD:%d (use SPARSEMOD for gcd of polynomials in char 0)\n",isOn(SW_USE_SPARSEMOD));
2923        Print("QGCD:%d (use QGCD for gcd of polynomials in alg. ext.)\n",isOn(SW_USE_QGCD));
2924        Print("FGCD:%d (use fieldGCD for gcd of polynomials in Z/p)\n",isOn(SW_USE_fieldGCD));
2925        Print("homog:%d (use homog. test for factorization of polynomials)\n",singular_homog_flag);
2926        return FALSE;
2927      }
2928      else
2929      if ((h!=NULL) && (h->Typ()==STRING_CMD)
2930      && (h->next!=NULL) && (h->next->Typ()==INT_CMD))
2931      {
2932        int d=(int)(long)h->next->Data();
2933        char *s=(char *)h->Data();
2934        if (strcmp(s,"NTL_0")==0) { if (d) On(SW_USE_NTL_GCD_0); else Off(SW_USE_NTL_GCD_0); } else
2935        if (strcmp(s,"NTL_p")==0) { if (d) On(SW_USE_NTL_GCD_P); else Off(SW_USE_NTL_GCD_P); } else
2936        if (strcmp(s,"EZGCD")==0) { if (d) On(SW_USE_EZGCD); else Off(SW_USE_EZGCD); } else
2937        if (strcmp(s,"EZGCD_P")==0) { if (d) On(SW_USE_EZGCD_P); else Off(SW_USE_EZGCD_P); } else
2938        if (strcmp(s,"CRGCD")==0) { if (d) On(SW_USE_CHINREM_GCD); else Off(SW_USE_CHINREM_GCD); } else
2939        if (strcmp(s,"SPARSEMOD")==0) { if (d) On(SW_USE_SPARSEMOD); else Off(SW_USE_SPARSEMOD); } else
2940        if (strcmp(s,"QGCD")==0) { if (d) On(SW_USE_QGCD); else Off(SW_USE_QGCD); } else
2941        if (strcmp(s,"FGCD")==0) { if (d) On(SW_USE_fieldGCD); else Off(SW_USE_fieldGCD); } else
2942        if (strcmp(s,"homog")==0) { if (d) singular_homog_flag=1; else singular_homog_flag=0; } else
2943        return TRUE;
2944        return FALSE;
2945      }
2946      else return TRUE;
2947    }
2948    else
2949#if 0
2950/*==================== gcd-test =================*/
2951    if (strcmp(sys_cmd, "GCD") == 0)
2952    {
2953      if ((h!=NULL) && (h->Typ()==POLY_CMD)
2954      && (h->next!=NULL) && (h->next->Typ()==POLY_CMD))
2955      {
2956        poly f=(poly)h->Data();
2957        poly g=(poly)h->next->Data();
2958        res->rtyp=POLY_CMD;
2959        res->data=(char*)id_GCD(f,g,currRing);
2960        return FALSE;
2961      }
2962      else return TRUE;
2963    }
2964    else
2965#endif
2966/*==================== subring =================*/
2967    if (strcmp(sys_cmd, "subring") == 0)
2968    {
2969      if (h!=NULL)
2970      {
2971        extern ring rSubring(ring r,leftv v); /* ipshell.cc*/
2972        res->data=(char *)rSubring(currRing,h);
2973        res->rtyp=RING_CMD;
2974        return res->data==NULL;
2975      }
2976      else return TRUE;
2977    }
2978    else
2979#ifdef ix86_Win
2980/*==================== Python Singular =================*/
2981    if (strcmp(sys_cmd, "python") == 0)
2982    {
2983      const char* c;
2984      if ((h!=NULL) && (h->Typ()==STRING_CMD))
2985      {
2986        c=(const char*)h->Data();
2987        if (!PyInitialized) {
2988          PyInitialized = 1;
2989//          Py_Initialize();
2990//          initPySingular();
2991        }
2992//      PyRun_SimpleString(c);
2993        return FALSE;
2994      }
2995      else return TRUE;
2996    }
2997    else
2998/*==================== Python Singular =================
2999    if (strcmp(sys_cmd, "ipython") == 0)
3000    {
3001      const char* c;
3002      {
3003        if (!PyInitialized) {
3004          PyInitialized = 1;
3005          Py_Initialize();
3006          initPySingular();
3007        }
3008  PyRun_SimpleString(
3009"try:                                                                                       \n\
3010    __IPYTHON__                                                                             \n\
3011except NameError:                                                                           \n\
3012    argv = ['']                                                                             \n\
3013    banner = exit_msg = ''                                                                  \n\
3014else:                                                                                       \n\
3015    # Command-line options for IPython (a list like sys.argv)                               \n\
3016    argv = ['-pi1','In <\\#>:','-pi2','   .\\D.:','-po','Out<\\#>:']                        \n\
3017    banner = '*** Nested interpreter ***'                                                   \n\
3018    exit_msg = '*** Back in main IPython ***'                                               \n\
3019                          \n\
3020# First import the embeddable shell class                                                   \n\
3021from IPython.Shell import IPShellEmbed                                                      \n\
3022# Now create the IPython shell instance. Put ipshell() anywhere in your code                \n\
3023# where you want it to open.                                                                \n\
3024ipshell = IPShellEmbed(argv,banner=banner,exit_msg=exit_msg)                                \n\
3025ipshell()");
3026        return FALSE;
3027      }
3028    }
3029    else
3030              */
3031
3032
3033#endif
3034/*==================== Error =================*/
3035      Werror( "system(\"%s\",...) %s", sys_cmd, feNotImplemented );
3036  }
3037  return TRUE;
3038}
3039#endif // HAVE_EXTENDED_SYSTEM
3040
Note: See TracBrowser for help on using the repository browser.