source: git/Singular/extra.cc @ 9c0b20a

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