source: git/Singular/extra.cc @ 210bd9

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