source: git/Singular/extra.cc @ c16aa0

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