source: git/Singular/extra.cc @ f414c0

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