source: git/Singular/extra.cc @ 706c95

fieker-DuValspielwiese
Last change on this file since 706c95 was bd2b93, checked in by Wilfred Pohl <pohl@…>, 25 years ago
exclude barstep git-svn-id: file:///usr/local/Singular/svn/trunk@3262 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 24.4 KB
Line 
1/*****************************************
2*  Computer Algebra System SINGULAR      *
3*****************************************/
4/* $Id: extra.cc,v 1.96 1999-07-12 11:05:57 pohl Exp $ */
5/*
6* ABSTRACT: general interface to internals of Singular ("system" command)
7*/
8
9#include <stdlib.h>
10#include <stdio.h>
11#include <string.h>
12#include <ctype.h>
13#include "mod2.h"
14
15#ifndef __MWERKS__
16#ifdef TIME_WITH_SYS_TIME
17# include <time.h>
18# ifdef HAVE_SYS_TIME_H
19#   include <sys/time.h>
20# endif
21#else
22# ifdef HAVE_SYS_TIME_H
23#   include <sys/time.h>
24# else
25#   include <time.h>
26# endif
27#endif
28#ifdef HAVE_SYS_TIMES_H
29#include <sys/times.h>
30#endif
31
32#endif
33#include <unistd.h>
34
35#include "tok.h"
36#include "ipid.h"
37#include "polys.h"
38#include "kutil.h"
39#include "cntrlc.h"
40#include "stairc.h"
41#include "ipshell.h"
42#include "algmap.h"
43#include "modulop.h"
44#include "febase.h"
45#include "matpol.h"
46#include "longalg.h"
47#include "ideals.h"
48#include "kstd1.h"
49#include "syz.h"
50#include "sdb.h"
51
52// Define to enable many more system commands
53#define HAVE_EXTENDED_SYSTEM
54
55#ifdef STDTRACE
56//#include "comm.h"
57#endif
58
59#ifdef HAVE_FACTORY
60#define SI_DONT_HAVE_GLOBAL_VARS
61#include "clapsing.h"
62#include "clapconv.h"
63#include "kstdfac.h"
64#endif
65
66#include "silink.h"
67#ifdef HAVE_MPSR
68#include "mpsr.h"
69#include "MPT_GP.h"
70#endif
71
72/*
73 *   New function/system-calls that will be included as dynamic module
74 * should be inserted here.
75 * - without HAVE_DYNAMIC_LOADING: these functions comes as system("....");
76 * - with    HAVE_DYNAMIC_LOADING: these functions are loaded as module.
77 */
78#ifndef HAVE_DYNAMIC_LOADING
79#ifdef HAVE_PCV
80#include "pcv.h"
81#endif
82#endif /* not HAVE_DYNAMIC_LOADING */
83
84// see clapsing.cc for a description of the `FACTORY_*' options
85
86#ifdef FACTORY_GCD_STAT
87#include "gcd_stat.h"
88#endif
89
90#ifdef FACTORY_GCD_TIMING
91#define TIMING
92#include "timing.h"
93TIMING_DEFINE_PRINTPROTO( contentTimer );
94TIMING_DEFINE_PRINTPROTO( algContentTimer );
95TIMING_DEFINE_PRINTPROTO( algLcmTimer );
96#endif
97
98void piShowProcList();
99static BOOLEAN jjEXTENDED_SYSTEM(leftv res, leftv h);
100
101
102//void emStart();
103/*2
104*  the "system" command
105*/
106BOOLEAN jjSYSTEM(leftv res, leftv args)
107{
108  if(args->Typ() == STRING_CMD)
109  {
110    const char *sys_cmd=(char *)(args->Data());
111    leftv h=args->next;
112// ONLY documented system calls go here
113// Undocumented system calls go down into #ifdef HAVE_EXTENDED_SYSTEM
114/*==================== nblocks ==================================*/
115    if (strcmp(sys_cmd, "nblocks") == 0)
116    {
117      ring r;
118      if (h == NULL)
119      {
120        if (currRingHdl != NULL)
121        {
122          r = IDRING(currRingHdl);
123        }
124        else
125        {
126          WerrorS("no ring active");
127          return TRUE;
128        }
129      }
130      else
131      {
132        if (h->Typ() != RING_CMD)
133        {
134          WerrorS("ring expected");
135          return TRUE;
136        }
137        r = (ring) h->Data();
138      }
139      res->rtyp = INT_CMD;
140      res->data = (void*) (rBlocks(r) - 1);
141      return FALSE;
142    }
143/*==================== version ==================================*/
144    if(strcmp(sys_cmd,"version")==0)
145    {
146      res->rtyp=INT_CMD;
147      res->data=(void *)SINGULAR_VERSION;
148      return FALSE;
149    }
150    else
151/*==================== gen ==================================*/
152    if(strcmp(sys_cmd,"gen")==0)
153    {
154      res->rtyp=INT_CMD;
155      res->data=(void *)npGen;
156      return FALSE;
157    }
158    else
159/*==================== sh ==================================*/
160    if(strcmp(sys_cmd,"sh")==0)
161    {
162      res->rtyp=INT_CMD;
163      #ifndef __MWERKS__
164      if (h==NULL) res->data = (void *)system("sh");
165      else if (h->Typ()==STRING_CMD)
166        res->data = (void*) system((char*)(h->Data()));
167      else
168        WerrorS("string expected");
169      #else
170      res->data=(void *)0;
171      #endif
172      return FALSE;
173    }
174    else
175/*==================== with ==================================*/
176    if(strcmp(sys_cmd,"with")==0)
177    {
178      if (h==NULL)
179      {
180        res->rtyp=STRING_CMD;
181        res->data=(void *)mstrdup(versionString());
182        return FALSE;
183      }
184      else if (h->Typ()==STRING_CMD)
185      {
186        #define TEST_FOR(A) if(strcmp(s,A)==0) res->data=(void *)1; else
187        char *s=(char *)h->Data();
188        res->rtyp=INT_CMD;
189        #ifdef DRING
190          TEST_FOR("DRING")
191        #endif
192        #ifdef HAVE_DBM
193          TEST_FOR("DBM")
194        #endif
195        #ifdef HAVE_DLD
196          TEST_FOR("DLD")
197        #endif
198        #ifdef HAVE_FACTORY
199          TEST_FOR("factory")
200        #endif
201        #ifdef HAVE_LIBFAC_P
202          TEST_FOR("libfac")
203        #endif
204        #ifdef HAVE_MPSR
205          TEST_FOR("MP")
206        #endif
207        #ifdef HAVE_READLINE
208          TEST_FOR("readline")
209        #endif
210        #ifdef HAVE_TCL
211          TEST_FOR("tcl")
212        #endif
213        #ifdef SRING
214          TEST_FOR("SRING")
215        #endif
216        #ifdef TEST_MAC_ORDER
217          TEST_FOR("MAC_ORDER");
218        #endif
219        #ifdef HAVE_NAMESPACES
220          TEST_FOR("Namespaces");
221        #endif
222        #ifdef HAVE_DYNAMIC_LOADING
223          TEST_FOR("DynamicLoading");
224        #endif
225          ;
226        return FALSE;
227        #undef TEST_FOR
228      }
229      return TRUE;
230    }
231    else
232/*==================== pid ==================================*/
233    if (strcmp(sys_cmd,"pid")==0)
234    {
235      res->rtyp=INT_CMD;
236    #ifndef MSDOS
237    #ifndef __MWERKS__
238      res->data=(void *)getpid();
239    #else
240      res->data=(void *)1;
241    #endif
242    #else
243      res->data=(void *)1;
244    #endif
245      return FALSE;
246    }
247    else
248/*==================== getenv ==================================*/
249    if (strcmp(sys_cmd,"getenv")==0)
250    {
251      if ((h!=NULL) && (h->Typ()==STRING_CMD))
252      {
253        res->rtyp=STRING_CMD;
254        char *r=getenv((char *)h->Data());
255        if (r==NULL) r="";
256        res->data=(void *)mstrdup(r);
257        return FALSE;
258      }
259      else
260      {
261        WerrorS("string expected");
262      }
263    }
264    else
265/*==================== tty ==================================*/
266    #ifndef __MWERKS__
267    #ifndef MSDOS
268    #if defined(HAVE_FEREAD) || defined(HAVE_READLINE)
269    if (strcmp(sys_cmd,"tty")==0)
270    {
271      #if defined(HAVE_READLINE) || defined(HAVE_FEREAD)
272      system("stty sane");
273      #endif
274      if ((h!=NULL)&&(h->Typ()==INT_CMD))
275      {
276        fe_use_fgets=(int)h->Data();
277      }
278      return FALSE;
279    }
280    else
281    #endif
282    #endif
283    #endif
284/*==================== Singular ==================================*/
285#ifndef __MWERKS__
286    if (strcmp(sys_cmd, "Singular") == 0)
287    {
288      res->rtyp=STRING_CMD;
289      char *r=feGetExpandedExecutable();
290      if (r != NULL)
291        res->data = (void*) mstrdup( r );
292      else
293        res->data = (void*) mstrdup("");
294      return FALSE;
295    }
296    else
297#endif
298/*==================== options ==================================*/
299    if (strstr(sys_cmd, "--") == sys_cmd)
300    {
301      BOOLEAN mainGetSingOptionValue(const char* name, char** result);
302      char* val;
303
304      if (mainGetSingOptionValue(&(sys_cmd)[2], &val))
305      {
306        if ((unsigned int) val > 1)
307        {
308          res->rtyp=STRING_CMD;
309          res->data = (void*) mstrdup( val );
310        }
311        else
312        {
313          res->rtyp=INT_CMD;
314          res->data=(void *)val;
315        }
316        return FALSE;
317      }
318      else
319      {
320        Werror("Unknown option %s\n", sys_cmd);
321        return TRUE;
322      }
323    }
324    else
325/*==================== HC ==================================*/
326    if (strcmp(sys_cmd,"HC")==0)
327    {
328      res->rtyp=INT_CMD;
329      res->data=(void *)HCord;
330      return FALSE;
331    }
332    else
333/*==================== random ==================================*/
334    if(strcmp(sys_cmd,"random")==0)
335    {
336      if ((h!=NULL) &&(h->Typ()==INT_CMD))
337      {
338        siRandomStart=(int)h->Data();
339#ifdef buildin_rand
340        siSeed=siRandomStart;
341#else
342        srand((unsigned int)siRandomStart);
343#endif
344        return FALSE;
345      }
346      else if (h != NULL)
347      {
348        WerrorS("int expected");
349        return TRUE;
350      }
351      res->rtyp=INT_CMD;
352      res->data=(void*) siRandomStart;
353      return FALSE;
354    }
355/*==================== neworder =============================*/
356// should go below
357#ifdef HAVE_LIBFAC_P
358    if(strcmp(sys_cmd,"neworder")==0)
359    {
360      if ((h!=NULL) &&(h->Typ()==IDEAL_CMD))
361      {
362        res->rtyp=STRING_CMD;
363        res->data=(void *)singclap_neworder((ideal)h->Data());
364        return FALSE;
365      }
366      else
367        WerrorS("ideal expected");
368    }
369    else
370#endif
371/*==================== contributors =============================*/
372   if(strcmp(sys_cmd,"contributors") == 0)
373   {
374     res->rtyp=STRING_CMD;
375     res->data=(void *)mstrdup(
376       "Olaf Bachmann, Hubert Grassmann, Kai Krueger, Wolfgang Neumann, Thomas Nuessler, Wilfred Pohl, Thomas Siebert, Ruediger Stobbe, Tim Wichmann");
377     return FALSE;
378   }
379   else
380   {
381/*================= Extended system call ========================*/
382#ifdef HAVE_EXTENDED_SYSTEM
383     return(jjEXTENDED_SYSTEM(res, args));
384#else
385     Werror( "system(\"%s\",...) %s", sys_cmd, feNotImplemented );
386#endif
387   }
388  } /* typ==string */
389  return TRUE;
390}
391
392
393
394#ifdef HAVE_EXTENDED_SYSTEM
395// You can put your own system calls here
396#include "fglmcomb.cc"
397#include "fglm.h"
398#ifdef HAVE_NEWTON
399#include <hc_newton.h>
400#endif
401#include "mpsr.h"
402
403#include "mpr_complex.h"
404
405static BOOLEAN jjEXTENDED_SYSTEM(leftv res, leftv h)
406{
407  if(h->Typ() == STRING_CMD)
408  {
409    char *sys_cmd=(char *)(h->Data());
410    h=h->next;
411/*==================== pcv ==================================*/
412#ifndef HAVE_DYNAMIC_LOADING
413#ifdef HAVE_PCV
414    if(strcmp(sys_cmd,"pcvLAddL")==0)
415    {
416      return pcvLAddL(res,h);
417    }
418    else
419    if(strcmp(sys_cmd,"pcvPMulL")==0)
420    {
421      return pcvPMulL(res,h);
422    }
423    else
424    if(strcmp(sys_cmd,"pcvMinDeg")==0)
425    {
426      return pcvMinDeg(res,h);
427    }
428    else
429    if(strcmp(sys_cmd,"pcvP2CV")==0)
430    {
431      return pcvP2CV(res,h);
432    }
433    else
434    if(strcmp(sys_cmd,"pcvCV2P")==0)
435    {
436      return pcvCV2P(res,h);
437    }
438    else
439    if(strcmp(sys_cmd,"pcvDim")==0)
440    {
441      return pcvDim(res,h);
442    }
443    else
444    if(strcmp(sys_cmd,"pcvBasis")==0)
445    {
446      return pcvBasis(res,h);
447    }
448    else
449#endif
450#endif /* HAVE_DYNAMIC_LOADING */
451/*==================== naIdeal ==================================*/
452    if(strcmp(sys_cmd,"naIdeal")==0)
453    {
454      if ((h!=NULL) &&(h->Typ()==IDEAL_CMD))
455      {
456        naSetIdeal((ideal)h->Data());
457        return FALSE;
458      }
459      else
460         WerrorS("ideal expected");
461    }
462    else
463/*==================== isSqrFree =============================*/
464#ifdef HAVE_FACTORY
465    if(strcmp(sys_cmd,"isSqrFree")==0)
466    {
467      if ((h!=NULL) &&(h->Typ()==POLY_CMD))
468      {
469        res->rtyp=INT_CMD;
470        res->data=(void *)singclap_isSqrFree((poly)h->Data());
471        return FALSE;
472      }
473      else
474        WerrorS("poly expected");
475    }
476    else
477#endif
478/*==================== alarm ==================================*/
479#ifndef __MWERKS__
480#ifndef MSDOS
481#ifndef atarist
482#ifdef unix
483    if(strcmp(sys_cmd,"alarm")==0)
484    {
485      if ((h!=NULL) &&(h->Typ()==INT_CMD))
486      {
487        // standard variant -> SIGALARM (standard: abort)
488        //alarm((unsigned)h->next->Data());
489        // process time (user +system): SIGVTALARM
490        struct itimerval t,o;
491        memset(&t,0,sizeof(t));
492        t.it_value.tv_sec     =(unsigned)h->Data();
493        setitimer(ITIMER_VIRTUAL,&t,&o);
494        return FALSE;
495      }
496      else
497        WerrorS("int expected");
498    }
499    else
500#endif
501#endif
502#endif
503#endif
504/*==================== red =============================*/
505#if 0
506    if(strcmp(sys_cmd,"red")==0)
507    {
508      if ((h!=NULL) &&(h->Typ()==IDEAL_CMD))
509      {
510        res->rtyp=IDEAL_CMD;
511        res->data=(void *)kStdred((ideal)h->Data(),NULL,testHomog,NULL);
512        setFlag(res,FLAG_STD);
513        return FALSE;
514      }
515      else
516        WerrorS("ideal expected");
517    }
518    else
519#endif
520/*==================== algfetch =====================*/
521    if (strcmp(sys_cmd,"algfetch")==0)
522    {
523      int k;
524      idhdl w;
525      ideal i0, i1;
526      ring r0=(ring)h->Data();
527      leftv v = h->next;
528      w = r0->idroot->get(v->Name(),myynest);
529      i0 = IDIDEAL(w);
530      i1 = idInit(IDELEMS(i0),i0->rank);
531      for (k=0; k<IDELEMS(i1); k++)
532      {
533        i1->m[k] = maAlgpolyFetch(r0, i0->m[k]);
534      }
535      res->rtyp = IDEAL_CMD;
536      res->data = (void*)i1;
537      return FALSE;
538    }
539    else
540/*==================== algmap =======================*/
541    if (strcmp(sys_cmd,"algmap")==0)
542    {
543      int k;
544      idhdl w;
545      ideal i0, i1, i, j;
546      ring r0=(ring)h->Data();
547      leftv v = h->next;
548      w = r0->idroot->get(v->Name(),myynest);
549      i0 = IDIDEAL(w);
550      v = v->next;
551      i = (ideal)v->Data();
552      v = v->next;
553      j = (ideal)v->Data();
554      i1 = idInit(IDELEMS(i0),i0->rank);
555      for (k=0; k<IDELEMS(i1); k++)
556      {
557        i1->m[k] = maAlgpolyMap(r0, i0->m[k], i, j);
558      }
559      res->rtyp = IDEAL_CMD;
560      res->data = (void*)i1;
561      return FALSE;
562    }
563    else
564    /*==================== trace =============================*/
565#ifdef STDTRACE
566    /* Parameter : Ideal, Liste mit Links. */
567    if(strcmp(sys_cmd,"stdtrace")==0)
568    {
569      if ((h!=NULL) &&(h->Typ()==IDEAL_CMD))
570      {
571        leftv root  = NULL,
572              ptr   = NULL,
573              lv    = NULL;
574        lists l     = NULL;
575        ideal I     = (ideal)(h->Data());
576        lists links = (lists)(h->next->Data());
577        tHomog hom  = testHomog;
578        int rw      = (int)(h->next->next->Data());
579
580        if(I==NULL)
581          PrintS("I==NULL\n");
582        for(int i=0; i <= links->nr ; i++)
583        {
584          lv = (leftv)Alloc0(sizeof(sleftv));
585          lv->Copy(&(links->m[i]));
586          if(root==NULL)
587          root=lv;
588          if(ptr==NULL)
589          {
590            ptr=lv;
591            ptr->next=NULL;
592          }
593          else
594          {
595            ptr->next=lv;
596            ptr=lv;
597          }
598        }
599        ptr->next=NULL;
600        l=TraceStd(root,rw,I,currQuotient,testHomog,NULL);
601        idSkipZeroes(((ideal)l->m[0].Data()));
602        res->rtyp=LIST_CMD;
603        res->data=(void *) l;
604        res->next=NULL;
605        root->CleanUp();
606        Free(root,sizeof(sleftv));
607        return FALSE;
608      }
609      else
610         WerrorS("ideal expected");
611    }
612    else
613#endif
614#ifdef HAVE_FACTORY
615/*==================== fastcomb =============================*/
616    if(strcmp(sys_cmd,"fastcomb")==0)
617    {
618      if ((h!=NULL) &&(h->Typ()==IDEAL_CMD))
619      {
620        int i=0;
621        if (h->next!=NULL)
622        {
623          if (h->next->Typ()!=POLY_CMD)
624          {
625            Warn("Wrong types for poly= comb(ideal,poly)");
626          }
627        }
628        res->rtyp=POLY_CMD;
629        res->data=(void *) fglmLinearCombination(
630                           (ideal)h->Data(),(poly)h->next->Data());
631        return FALSE;
632      }
633      else
634        WerrorS("ideal expected");
635    }
636    else
637/*==================== comb =============================*/
638    if(strcmp(sys_cmd,"comb")==0)
639    {
640      if ((h!=NULL) &&(h->Typ()==IDEAL_CMD))
641      {
642        int i=0;
643        if (h->next!=NULL)
644        {
645          if (h->next->Typ()!=POLY_CMD)
646          {
647              Warn("Wrong types for poly= comb(ideal,poly)");
648          }
649        }
650        res->rtyp=POLY_CMD;
651        res->data=(void *)fglmNewLinearCombination(
652                            (ideal)h->Data(),(poly)h->next->Data());
653        return FALSE;
654      }
655      else
656        WerrorS("ideal expected");
657    }
658    else
659#endif
660#ifdef FACTORY_GCD_TEST
661/*=======================gcd Testerei ================================*/
662    if ( ! strcmp( sys_cmd, "setgcd" ) ) {
663        if ( (h != NULL) && (h->Typ() == INT_CMD) ) {
664            CFPrimitiveGcdUtil::setAlgorithm( (int)h->Data() );
665            return FALSE;
666        } else
667            WerrorS("int expected");
668    }
669    else
670#endif
671
672#ifdef FACTORY_GCD_TIMING
673    if ( ! strcmp( sys_cmd, "gcdtime" ) ) {
674        TIMING_PRINT( contentTimer, "time used for content: " );
675        TIMING_PRINT( algContentTimer, "time used for algContent: " );
676        TIMING_PRINT( algLcmTimer, "time used for algLcm: " );
677        TIMING_RESET( contentTimer );
678        TIMING_RESET( algContentTimer );
679        TIMING_RESET( algLcmTimer );
680        return FALSE;
681    }
682    else
683#endif
684
685#ifdef FACTORY_GCD_STAT
686    if ( ! strcmp( sys_cmd, "gcdstat" ) ) {
687        printGcdTotal();
688        printContTotal();
689        resetGcdTotal();
690        resetContTotal();
691        return FALSE;
692    }
693    else
694#endif
695/*==================== lib ==================================*/
696    if(strcmp(sys_cmd,"LIB")==0)
697    {
698#ifdef HAVE_NAMESPACES
699      idhdl hh=namespaceroot->get((char*)h->Data(),0);
700#else /* HAVE_NAMESPACES */
701      idhdl hh=idroot->get((char*)h->Data(),0);
702#endif /* HAVE_NAMESPACES */
703      if ((hh!=NULL)&&(IDTYP(hh)==PROC_CMD))
704      {
705        res->rtyp=STRING_CMD;
706        char *r=iiGetLibName(IDPROC(hh));
707        if (r==NULL) r="";
708        res->data=mstrdup(r);
709        return FALSE;
710      }
711      else
712        Warn("`%s` not found",(char*)h->Data());
713    }
714    else
715#ifdef HAVE_NAMESPACES
716/*==================== nspush ===================================*/
717    if(strcmp(sys_cmd,"nspush")==0)
718    {
719      if (h->Typ()==PACKAGE_CMD)
720      {
721        idhdl hh=(idhdl)h->data;
722        namespaceroot = namespaceroot->push(IDPACKAGE(hh), IDID(hh));
723        return FALSE;
724      }
725      else
726        Warn("argument 2 is not a package");
727    }
728    else
729/*==================== nspop ====================================*/
730    if(strcmp(sys_cmd,"nspop")==0)
731    {
732      namespaceroot->pop();
733      return FALSE;
734    }
735    else
736#endif /* HAVE_NAMESPACES */
737/*==================== nsstack ===================================*/
738    if(strcmp(sys_cmd,"nsstack")==0)
739    {
740      namehdl nshdl = namespaceroot;
741      for( ; nshdl->isroot != TRUE; nshdl = nshdl->next) {
742        Print("NSstack: %s:%d, nesting=%d\n", nshdl->name, nshdl->lev, nshdl->myynest);
743      }
744      Print("NSstack: %s:%d, nesting=%d\n", nshdl->name, nshdl->lev, nshdl->myynest);
745      return FALSE;
746    }
747    else
748/*==================== proclist =================================*/
749    if(strcmp(sys_cmd,"proclist")==0)
750    {
751      piShowProcList();
752      return FALSE;
753    }
754    else
755/* ==================== newton ================================*/
756#ifdef HAVE_NEWTON
757    if(strcmp(sys_cmd,"newton")==0)
758    {
759      if ((h->Typ()!=POLY_CMD)
760      || (h->next->Typ()!=INT_CMD)
761      || (h->next->next->Typ()!=INT_CMD))
762      {
763        WerrorS("system(\"newton\",<poly>,<int>,<int>) expected");
764        return TRUE;
765      }
766      poly  p=(poly)(h->Data());
767      int l=pLength(p);
768      short *points=(short *)Alloc(currRing->N*l*sizeof(short));
769      int i,j,k;
770      k=0;
771      poly pp=p;
772      for (i=0;pp!=NULL;i++)
773      {
774        for(j=1;j<=currRing->N;j++)
775        {
776          points[k]=pGetExp(pp,j);
777          k++;
778        }
779        pIter(pp);
780      }
781      hc_ERG r=hc_KOENIG(currRing->N,      // dimension
782                l,      // number of points
783                (short*) points,   // points: x_1, y_1,z_1, x_2,y_2,z2,...
784                currRing->OrdSgn==-1,
785                (int) (h->next->Data()),      // 1: Milnor, 0: Newton
786                (int) (h->next->next->Data()) // debug
787               );
788      //----<>---Output-----------------------
789
790
791//  PrintS("Bin jetzt in extra.cc bei der Auswertung.\n"); // **********
792
793
794      lists L=(lists)Alloc(sizeof(slists));
795      L->Init(6);
796      L->m[0].rtyp=STRING_CMD;               // newtonnumber;
797      L->m[0].data=(void *)mstrdup(r.nZahl);
798      L->m[1].rtyp=INT_CMD;
799      L->m[1].data=(void *)r.achse;          // flag for unoccupied axes
800      L->m[2].rtyp=INT_CMD;
801      L->m[2].data=(void *)r.deg;            // #degenerations
802      if ( r.deg != 0)              // only if degenerations exist
803      {
804        L->m[3].rtyp=INT_CMD;
805        L->m[3].data=(void *)r.anz_punkte;     // #points
806        //---<>--number of points------
807        int anz = r.anz_punkte;    // number of points
808        int dim = (currRing->N);     // dimension
809        intvec* v = new intvec( anz*dim );
810        for (i=0; i<anz*dim; i++)    // copy points
811          (*v)[i] = r.pu[i];
812        L->m[4].rtyp=INTVEC_CMD;
813        L->m[4].data=(void *)v;
814        //---<>--degenerations---------
815        int deg = r.deg;    // number of points
816        intvec* w = new intvec( r.speicher );  // necessary memeory
817        i=0;               // start copying
818        do
819        {
820          (*w)[i] = r.deg_tab[i];
821          i++;
822        }
823        while (r.deg_tab[i-1] != -2);   // mark for end of list
824        L->m[5].rtyp=INTVEC_CMD;
825        L->m[5].data=(void *)w;
826      }
827      else
828      {
829        L->m[3].rtyp=INT_CMD; L->m[3].data=(char *)0;
830        L->m[4].rtyp=DEF_CMD;
831        L->m[5].rtyp=DEF_CMD;
832      }
833
834      res->data=(void *)L;
835      res->rtyp=LIST_CMD;
836      // free all pointer in r:
837      delete[] r.nZahl;
838      delete[] r.pu;
839      delete[] r.deg_tab;      // Ist das ein Problem??
840
841      Free((ADDRESS)points,currRing->N*l*sizeof(short));
842      return FALSE;
843    }
844    else
845#endif
846/*==================== gp =================*/
847#ifdef HAVE_MPSR
848     if (strcmp(sys_cmd, "gp") == 0)
849    {
850      if (h->Typ() != LINK_CMD)
851      {
852        WerrorS("No Link arg");
853        return FALSE;
854      }
855      si_link l = (si_link) h->Data();
856      if (strcmp(l->m->type, "MPfile") != 0)
857      {
858        WerrorS("No MPfile link");
859        return TRUE;
860      }
861      if( ! SI_LINK_R_OPEN_P(l)) // open r ?
862      {
863        if (slOpen(l, SI_LINK_READ)) return TRUE;
864      }
865
866      MP_Link_pt link = (MP_Link_pt) l->data;
867      if (MP_InitMsg(link) != MP_Success)
868      {
869        WerrorS("Can not Init");
870      }
871      MPT_Tree_pt tree = NULL;
872      if (MPT_GetTree(link, &tree) != MPT_Success)
873      {
874        WerrorS("Can not get tree");
875        return TRUE;
876      }
877      MPT_GP_pt gp_tree = MPT_GetGP(tree);
878      if (gp_tree == NULL || ! gp_tree->IsOk(gp_tree))
879      {
880        WerrorS("gp error");
881        return TRUE;
882      }
883      delete gp_tree;
884      MPT_DeleteTree(tree);
885      return FALSE;
886    }
887    else
888#endif
889/*==================== sdb-debugger =================*/
890    if (strcmp(sys_cmd, "breakpoint") == 0)
891    {
892      if ((h!=NULL) && (h->Typ()==PROC_CMD))
893      {
894        procinfov p=(procinfov)h->Data();
895        if (p->language!=LANG_SINGULAR)
896        {
897          WerrorS("set breakpoints only in Singular procedures");
898          return TRUE;
899        }
900        int lineno=p->data.s.body_lineno;
901        if ((h->next!=NULL) && (h->next->Typ()==INT_CMD))
902        {
903          lineno=(int)h->next->Data();
904        }
905        int i;
906        if (lineno== -1)
907        {
908          i=p->trace_flag;
909          p->trace_flag &=1;
910          Print("breakpoints in %s deleted(%#x)\n",p->procname,i &255);
911          return FALSE;
912        }
913        i=0;
914        while((i<7) && (sdb_lines[i]!=-1)) i++;
915        if (sdb_lines[i]!= -1)
916        {
917          PrintS("too many breakpoints set, max is 7\n");
918          return FALSE;
919        }
920        else
921        {
922          sdb_lines[i]=lineno;
923          sdb_files[i]=p->libname;
924          i++;
925          Print("breakpoint %d, at line %d in %s\n",i,lineno,p->procname);
926          p->trace_flag|=(1<<i);
927        }
928      }
929      else
930      {
931        WerrorS("system(\"breakpoint\",`proc`,`int`) expected");
932        return TRUE;
933      }
934      return FALSE;
935    }
936    else
937/*==================== sdb_flags =================*/
938    if (strcmp(sys_cmd, "sdb_flags") == 0)
939    {
940      if ((h!=NULL) && (h->Typ()==INT_CMD))
941      {
942        sdb_flags=(int)h->Data();
943      }
944      else
945      {
946        WerrorS("system(\"sdb_flags\",`int`) expected");
947        return TRUE;
948      }
949      return FALSE;
950    }
951    else
952/*==================== sdb_edit =================*/
953    if (strcmp(sys_cmd, "sdb_edit") == 0)
954    {
955      if ((h!=NULL) && (h->Typ()==PROC_CMD))
956      {
957        procinfov p=(procinfov)h->Data();
958        sdb_edit(p);
959      }
960      else
961      {
962        WerrorS("system(\"sdb_edit\",`proc`) expected");
963        return TRUE;
964      }
965      return FALSE;
966    }
967    else
968/*==================== print all option values =================*/
969#ifndef NDEBUG
970    if (strcmp(sys_cmd, "options") == 0)
971    {
972      void mainOptionValues();
973      mainOptionValues();
974      return FALSE;
975    }
976    else
977#endif
978/*==================== GF =================*/
979#if 0
980    if (strcmp(sys_cmd, "GF") == 0)
981    {
982      int c=rChar(currRing);
983      setCharacteristic( c, 2);
984      CanonicalForm F( convSingGFClapGF( (poly)h->Data() ) );
985      res->rtyp=POLY_CMD;
986      res->data=convClapGFSingGF( F );
987      return FALSE;
988    }
989    else
990#endif
991/*============================================================*/
992      Werror( "system(\"%s\",...) %s", sys_cmd, feNotImplemented );
993  }
994  return TRUE;
995}
996#endif // HAVE_EXTENDED_SYSTEM
Note: See TracBrowser for help on using the repository browser.