extra.cc
Go to the documentation of this file.
1 /*****************************************
2 * Computer Algebra System SINGULAR *
3 *****************************************/
4 /*
5 * ABSTRACT: general interface to internals of Singular ("system" command)
6 * jjSYSTEM: official commands, must be documented in the manual,
7 * #defines must be local to each command
8 * jjEXTENDED_SYSTEM: tests, temporary comands etc.
9 */
10 
11 #define HAVE_WALK 1
12 
13 #include <kernel/mod2.h>
14 #include <misc/sirandom.h>
15 #include <resources/omFindExec.h>
16 
17 #include <factory/factory.h>
18 
19 #include <stdlib.h>
20 #include <stdio.h>
21 #include <string.h>
22 #include <ctype.h>
23 #include <signal.h>
24 
25 #ifdef TIME_WITH_SYS_TIME
26 # include <time.h>
27 # ifdef HAVE_SYS_TIME_H
28 # include <sys/time.h>
29 # endif
30 #else
31 # ifdef HAVE_SYS_TIME_H
32 # include <sys/time.h>
33 # else
34 # include <time.h>
35 # endif
36 #endif
37 #ifdef HAVE_SYS_TIMES_H
38 #include <sys/times.h>
39 #endif
40 
41 #include <unistd.h>
42 
43 #include <misc/options.h>
44 
45 // #include <coeffs/ffields.h>
46 #include <coeffs/coeffs.h>
47 #include <coeffs/mpr_complex.h>
48 #include "coeffs/AE.h"
49 // #include "coeffs/OPAE.h"
50 #include "coeffs/AEp.h"
51 // #include "coeffs/OPAEp.h"
52 #include "coeffs/AEQ.h"
53 // #include "coeffs/OPAEQ.h"
54 
55 
56 #include <resources/feResource.h>
57 #include <polys/monomials/ring.h>
58 #include <kernel/polys.h>
59 
60 #include <polys/monomials/maps.h>
61 #include <polys/matpol.h>
62 
63 #include <polys/weight.h>
64 
65 #include <coeffs/bigintmat.h>
66 #include <kernel/fast_mult.h>
67 #include <kernel/digitech.h>
69 #include <kernel/ideals.h>
70 #include <kernel/GBEngine/kstd1.h>
71 #include <kernel/GBEngine/syz.h>
72 #include <kernel/GBEngine/kutil.h>
73 
76 
78 
79 // for tests of t-rep-GB
80 #include <kernel/GBEngine/tgb.h>
81 
83 
84 #include <numeric/mpr_base.h>
85 
86 #include "tok.h"
87 #include "ipid.h"
88 #include "lists.h"
89 #include "cntrlc.h"
90 #include "ipshell.h"
91 #include "sdb.h"
92 #include "feOpt.h"
93 #include "fehelp.h"
94 #include "distrib.h"
95 
96 #include "misc_ip.h"
97 
98 #include "attrib.h"
99 
100 #include "links/silink.h"
101 #include "links/ssiLink.h"
102 #include "walk.h"
103 #include <Singular/newstruct.h>
104 #include <Singular/blackbox.h>
105 #include <Singular/pyobject_setup.h>
106 
107 
108 #ifdef HAVE_RINGS
109 #include <kernel/GBEngine/ringgb.h>
110 #endif
111 
112 #ifdef HAVE_F5
113 #include <kernel/GBEngine/f5gb.h>
114 #endif
115 
116 #ifdef HAVE_WALK
117 #include "walk.h"
118 #endif
119 
120 #ifdef HAVE_SPECTRUM
122 #endif
123 
124 #ifdef HAVE_PLURAL
125 #include <polys/nc/nc.h>
126 #include <polys/nc/ncSAMult.h> // for CMultiplier etc classes
127 #include <polys/nc/sca.h>
128 #include <kernel/GBEngine/nc.h>
129 #include "ipconv.h"
130 #ifdef HAVE_RATGRING
132 #endif
133 #endif
134 
135 #ifdef __CYGWIN__ /* only for the DLLTest */
136 /* #include "WinDllTest.h" */
137 #ifdef HAVE_DL
138 #include <polys/mod_raw.h>
139 #endif
140 #endif
141 
142 // Define to enable many more system commands
143 //#undef MAKE_DISTRIBUTION
144 #ifndef MAKE_DISTRIBUTION
145 #define HAVE_EXTENDED_SYSTEM 1
146 #endif
147 
148 #include <polys/flintconv.h>
149 #include <polys/clapconv.h>
150 #include <kernel/GBEngine/kstdfac.h>
151 
152 #include <polys/clapsing.h>
153 
154 #ifdef HAVE_EIGENVAL
155 #include "eigenval_ip.h"
156 #endif
157 
158 #ifdef HAVE_GMS
159 #include "gms.h"
160 #endif
161 
162 #ifdef HAVE_SIMPLEIPC
164 #endif
165 
166 #ifdef HAVE_PCV
167 #include "pcv.h"
168 #endif
169 
170 
171 #ifdef __CYGWIN__
172 //#include <Python.h>
173 //#include <python_wrapper.h>
174 #endif
175 
176 #ifndef MAKE_DISTRIBUTION
178 #endif
179 
180 #ifdef __CYGWIN__ /* PySingular initialized? */
181 static int PyInitialized = 0;
182 #endif
183 
184 /* expects a SINGULAR square matrix with number entries
185  where currRing is expected to be over some field F_p;
186  returns a long** matrix with the "same", i.e.,
187  appropriately mapped entries;
188  leaves singularMatrix unmodified */
189 unsigned long** singularMatrixToLongMatrix(matrix singularMatrix)
190 {
191  int n = singularMatrix->rows();
192  assume(n == singularMatrix->cols());
193  unsigned long **longMatrix = 0;
194  longMatrix = new unsigned long *[n] ;
195  for (int i = 0 ; i < n; i++)
196  longMatrix[i] = new unsigned long [n];
197  number entry;
198  for (int r = 0; r < n; r++)
199  for (int c = 0; c < n; c++)
200  {
201  poly p=MATELEM(singularMatrix, r + 1, c + 1);
202  int entryAsInt;
203  if (p!=NULL)
204  {
205  entry = p_GetCoeff(p, currRing);
206  entryAsInt = n_Int(entry, currRing->cf);
207  if (entryAsInt < 0) entryAsInt += n_GetChar(currRing->cf);
208  }
209  else
210  entryAsInt=0;
211  longMatrix[r][c] = (unsigned long)entryAsInt;
212  }
213  return longMatrix;
214 }
215 
216 /* expects an array of unsigned longs with valid indices 0..degree;
217  returns the following poly, where x denotes the first ring variable
218  of currRing, and d = degree:
219  polyCoeffs[d] * x^d + polyCoeffs[d-1] * x^(d-1) + ... + polyCoeffs[0]
220  leaves polyCoeffs unmodified */
221 poly longCoeffsToSingularPoly(unsigned long *polyCoeffs, const int degree)
222 {
223  poly result = NULL;
224  for (int i = 0; i <= degree; i++)
225  {
226  if ((int)polyCoeffs[i] != 0)
227  {
228  poly term = p_ISet((int)polyCoeffs[i], currRing);
229  if (i > 0)
230  {
231  p_SetExp(term, 1, i, currRing);
232  p_Setm(term, currRing);
233  }
234  result = p_Add_q(result, term, currRing);
235  }
236  }
237  return result;
238 }
239 
240 //void emStart();
241 /*2
242 * the "system" command
243 */
245 {
246  if(args->Typ() == STRING_CMD)
247  {
248  const char *sys_cmd=(char *)(args->Data());
249  leftv h=args->next;
250 // ONLY documented system calls go here
251 // Undocumented system calls go down into jjEXTENDED_SYSTEM (#ifdef HAVE_EXTENDED_SYSTEM)
252 /*==================== nblocks ==================================*/
253  if (strcmp(sys_cmd, "nblocks") == 0)
254  {
255  ring r;
256  if (h == NULL)
257  {
258  if (currRingHdl != NULL)
259  {
260  r = IDRING(currRingHdl);
261  }
262  else
263  {
264  WerrorS("no ring active");
265  return TRUE;
266  }
267  }
268  else
269  {
270  if (h->Typ() != RING_CMD)
271  {
272  WerrorS("ring expected");
273  return TRUE;
274  }
275  r = (ring) h->Data();
276  }
277  res->rtyp = INT_CMD;
278  res->data = (void*) (long)(rBlocks(r) - 1);
279  return FALSE;
280  }
281 /*==================== version ==================================*/
282  if(strcmp(sys_cmd,"version")==0)
283  {
284  res->rtyp=INT_CMD;
285  res->data=(void *)SINGULAR_VERSION;
286  return FALSE;
287  }
288  else
289 /*==================== alarm ==================================*/
290  #ifdef unix
291  if(strcmp(sys_cmd,"alarm")==0)
292  {
293  if ((h!=NULL) &&(h->Typ()==INT_CMD))
294  {
295  // standard variant -> SIGALARM (standard: abort)
296  //alarm((unsigned)h->next->Data());
297  // process time (user +system): SIGVTALARM
298  struct itimerval t,o;
299  memset(&t,0,sizeof(t));
300  t.it_value.tv_sec =(unsigned)((unsigned long)h->Data());
301  setitimer(ITIMER_VIRTUAL,&t,&o);
302  return FALSE;
303  }
304  else
305  WerrorS("int expected");
306  }
307  else
308  #endif
309 /*==================== cpu ==================================*/
310  if(strcmp(sys_cmd,"cpu")==0)
311  {
312  long cpu=1; //feOptValue(FE_OPT_CPUS);
313  #ifdef _SC_NPROCESSORS_ONLN
314  cpu=sysconf(_SC_NPROCESSORS_ONLN);
315  #elif defined(_SC_NPROCESSORS_CONF)
316  cpu=sysconf(_SC_NPROCESSORS_CONF);
317  #endif
318  res->data=(void *)cpu;
319  res->rtyp=INT_CMD;
320  return FALSE;
321  }
322  else
323 /*==================== executable ==================================*/
324  if(strcmp(sys_cmd,"executable")==0)
325  {
326  if ((h!=NULL) && (h->Typ()==STRING_CMD))
327  {
328  char tbuf[MAXPATHLEN];
329  char *s=omFindExec((char*)h->Data(),tbuf);
330  if(s==NULL) s=(char*)"";
331  res->data=(void *)omStrDup(s);
332  res->rtyp=STRING_CMD;
333  return FALSE;
334  }
335  return TRUE;
336  }
337  else
338  /*==================== neworder =============================*/
339  if(strcmp(sys_cmd,"neworder")==0)
340  {
341  if ((h!=NULL) &&(h->Typ()==IDEAL_CMD))
342  {
343  res->rtyp=STRING_CMD;
344  res->data=(void *)singclap_neworder((ideal)h->Data(), currRing);
345  return FALSE;
346  }
347  else
348  WerrorS("ideal expected");
349  }
350  else
351 /*===== nc_hilb ===============================================*/
352  // Hilbert series of non-commutative monomial algebras
353  if(strcmp(sys_cmd,"nc_hilb") == 0)
354  {
355  ideal i; int lV;
356  bool ig = FALSE;
357  bool mgrad = FALSE;
358  bool autop = FALSE;
359  if((h != NULL)&&(h->Typ() == IDEAL_CMD))
360  i = (ideal)h->Data();
361  else
362  {
363  WerrorS("nc_Hilb:ideal expected");
364  return TRUE;
365  }
366  h = h->next;
367  if((h != NULL)&&(h->Typ() == INT_CMD))
368  lV = (int)(long)h->Data();
369  else
370  {
371  WerrorS("nc_Hilb:int expected");
372  return TRUE;
373  }
374  h = h->next;
375  while((h != NULL)&&(h->Typ() == INT_CMD))
376  {
377  if((int)(long)h->Data() == 1)
378  ig = TRUE;
379  else if((int)(long)h->Data() == 2)
380  mgrad = TRUE;
381  else if((int)(long)h->Data() == 3)
382  autop = TRUE;
383  h = h->next;
384  }
385  if(h != NULL)
386  {
387  WerrorS("nc_Hilb:int 1,2 or 3 are expected");
388  return TRUE;
389  }
390  HilbertSeries_OrbitData(i, lV, ig, mgrad, autop);
391  return(FALSE);
392  }
393  else
394 /*==================== sh ==================================*/
395  if(strcmp(sys_cmd,"sh")==0)
396  {
397  if (feOptValue(FE_OPT_NO_SHELL))
398  {
399  WerrorS("shell execution is disallowed in restricted mode");
400  return TRUE;
401  }
402  res->rtyp=INT_CMD;
403  if (h==NULL) res->data = (void *)(long) system("sh");
404  else if (h->Typ()==STRING_CMD)
405  res->data = (void*)(long) system((char*)(h->Data()));
406  else
407  WerrorS("string expected");
408  return FALSE;
409  }
410  else
411 /*========reduce procedure like the global one but with jet bounds=======*/
412  if(strcmp(sys_cmd,"reduce_bound")==0)
413  {
414  poly p;
415  ideal pid=NULL;
416  const short t1[]={3,POLY_CMD,IDEAL_CMD,INT_CMD};
417  const short t2[]={3,IDEAL_CMD,IDEAL_CMD,INT_CMD};
418  const short t3[]={3,VECTOR_CMD,MODUL_CMD,INT_CMD};
419  const short t4[]={3,MODUL_CMD,MODUL_CMD,INT_CMD};
420  if ((iiCheckTypes(h,t1,0))||((iiCheckTypes(h,t3,0))))
421  {
422  p = (poly)h->CopyD();
423  }
424  else if ((iiCheckTypes(h,t2,0))||(iiCheckTypes(h,t4,1)))
425  {
426  pid = (ideal)h->CopyD();
427  }
428  else return TRUE;
429  //int htype;
430  res->rtyp= h->Typ(); /*htype*/
431  ideal q = (ideal)h->next->CopyD();
432  int bound = (int)(long)h->next->next->Data();
433  if (pid==NULL) /*(htype == POLY_CMD || htype == VECTOR_CMD)*/
434  res->data = (char *)kNFBound(q,currRing->qideal,p,bound);
435  else /*(htype == IDEAL_CMD || htype == MODUL_CMD)*/
436  res->data = (char *)kNFBound(q,currRing->qideal,pid,bound);
437  return FALSE;
438  }
439  else
440 /*==================== uname ==================================*/
441  if(strcmp(sys_cmd,"uname")==0)
442  {
443  res->rtyp=STRING_CMD;
444  res->data = omStrDup(S_UNAME);
445  return FALSE;
446  }
447  else
448 /*==================== with ==================================*/
449  if(strcmp(sys_cmd,"with")==0)
450  {
451  if (h==NULL)
452  {
453  res->rtyp=STRING_CMD;
454  res->data=(void *)versionString();
455  return FALSE;
456  }
457  else if (h->Typ()==STRING_CMD)
458  {
459  #define TEST_FOR(A) if(strcmp(s,A)==0) res->data=(void *)1; else
460  char *s=(char *)h->Data();
461  res->rtyp=INT_CMD;
462  #ifdef HAVE_DBM
463  TEST_FOR("DBM")
464  #endif
465  #ifdef HAVE_DLD
466  TEST_FOR("DLD")
467  #endif
468  //TEST_FOR("factory")
469  //TEST_FOR("libfac")
470  #ifdef HAVE_READLINE
471  TEST_FOR("readline")
472  #endif
473  #ifdef TEST_MAC_ORDER
474  TEST_FOR("MAC_ORDER")
475  #endif
476  // unconditional since 3-1-0-6
477  TEST_FOR("Namespaces")
478  #ifdef HAVE_DYNAMIC_LOADING
479  TEST_FOR("DynamicLoading")
480  #endif
481  #ifdef HAVE_EIGENVAL
482  TEST_FOR("eigenval")
483  #endif
484  #ifdef HAVE_GMS
485  TEST_FOR("gms")
486  #endif
487  #ifdef OM_NDEBUG
488  TEST_FOR("om_ndebug")
489  #endif
490  #ifdef SING_NDEBUG
491  TEST_FOR("ndebug")
492  #endif
493  {};
494  return FALSE;
495  #undef TEST_FOR
496  }
497  return TRUE;
498  }
499  else
500  /*==================== browsers ==================================*/
501  if (strcmp(sys_cmd,"browsers")==0)
502  {
503  res->rtyp = STRING_CMD;
504  StringSetS("");
506  res->data = StringEndS();
507  return FALSE;
508  }
509  else
510  /*==================== pid ==================================*/
511  if (strcmp(sys_cmd,"pid")==0)
512  {
513  res->rtyp=INT_CMD;
514  res->data=(void *)(long) getpid();
515  return FALSE;
516  }
517  else
518  /*==================== getenv ==================================*/
519  if (strcmp(sys_cmd,"getenv")==0)
520  {
521  if ((h!=NULL) && (h->Typ()==STRING_CMD))
522  {
523  res->rtyp=STRING_CMD;
524  const char *r=getenv((char *)h->Data());
525  if (r==NULL) r="";
526  res->data=(void *)omStrDup(r);
527  return FALSE;
528  }
529  else
530  {
531  WerrorS("string expected");
532  return TRUE;
533  }
534  }
535  else
536  /*==================== setenv ==================================*/
537  if (strcmp(sys_cmd,"setenv")==0)
538  {
539  #ifdef HAVE_SETENV
540  const short t[]={2,STRING_CMD,STRING_CMD};
541  if (iiCheckTypes(h,t,1))
542  {
543  res->rtyp=STRING_CMD;
544  setenv((char *)h->Data(), (char *)h->next->Data(), 1);
545  res->data=(void *)omStrDup((char *)h->next->Data());
547  return FALSE;
548  }
549  else
550  {
551  return TRUE;
552  }
553  #else
554  WerrorS("setenv not supported on this platform");
555  return TRUE;
556  #endif
557  }
558  else
559  /*==================== Singular ==================================*/
560  if (strcmp(sys_cmd, "Singular") == 0)
561  {
562  res->rtyp=STRING_CMD;
563  const char *r=feResource("Singular");
564  if (r == NULL) r="";
565  res->data = (void*) omStrDup( r );
566  return FALSE;
567  }
568  else
569  if (strcmp(sys_cmd, "SingularLib") == 0)
570  {
571  res->rtyp=STRING_CMD;
572  const char *r=feResource("SearchPath");
573  if (r == NULL) r="";
574  res->data = (void*) omStrDup( r );
575  return FALSE;
576  }
577  else
578  /*==================== options ==================================*/
579  if (strstr(sys_cmd, "--") == sys_cmd)
580  {
581  if (strcmp(sys_cmd, "--") == 0)
582  {
584  return FALSE;
585  }
586  feOptIndex opt = feGetOptIndex(&sys_cmd[2]);
587  if (opt == FE_OPT_UNDEF)
588  {
589  Werror("Unknown option %s", sys_cmd);
590  WerrorS("Use 'system(\"--\");' for listing of available options");
591  return TRUE;
592  }
593  // for Untyped Options (help version),
594  // setting it just triggers action
595  if (feOptSpec[opt].type == feOptUntyped)
596  {
597  feSetOptValue(opt,0);
598  return FALSE;
599  }
600  if (h == NULL)
601  {
602  if (feOptSpec[opt].type == feOptString)
603  {
604  res->rtyp = STRING_CMD;
605  const char *r=(const char*)feOptSpec[opt].value;
606  if (r == NULL) r="";
607  res->data = omStrDup(r);
608  }
609  else
610  {
611  res->rtyp = INT_CMD;
612  res->data = feOptSpec[opt].value;
613  }
614  return FALSE;
615  }
616  if (h->Typ() != STRING_CMD &&
617  h->Typ() != INT_CMD)
618  {
619  WerrorS("Need string or int argument to set option value");
620  return TRUE;
621  }
622  const char* errormsg;
623  if (h->Typ() == INT_CMD)
624  {
625  if (feOptSpec[opt].type == feOptString)
626  {
627  Werror("Need string argument to set value of option %s", sys_cmd);
628  return TRUE;
629  }
630  errormsg = feSetOptValue(opt, (int)((long) h->Data()));
631  if (errormsg != NULL)
632  Werror("Option '--%s=%d' %s", sys_cmd, (int) ((long)h->Data()), errormsg);
633  }
634  else
635  {
636  errormsg = feSetOptValue(opt, (char*) h->Data());
637  if (errormsg != NULL)
638  Werror("Option '--%s=%s' %s", sys_cmd, (char*) h->Data(), errormsg);
639  }
640  if (errormsg != NULL) return TRUE;
641  return FALSE;
642  }
643  else
644  /*==================== HC ==================================*/
645  if (strcmp(sys_cmd,"HC")==0)
646  {
647  res->rtyp=INT_CMD;
648  res->data=(void *)(long) HCord;
649  return FALSE;
650  }
651  else
652  /*==================== random ==================================*/
653  if(strcmp(sys_cmd,"random")==0)
654  {
655  const short t[]={1,INT_CMD};
656  if (h!=NULL)
657  {
658  if (iiCheckTypes(h,t,1))
659  {
660  siRandomStart=(int)((long)h->Data());
663  return FALSE;
664  }
665  else
666  {
667  return TRUE;
668  }
669  }
670  res->rtyp=INT_CMD;
671  res->data=(void*)(long) siSeed;
672  return FALSE;
673  }
674  else
675  /*==================== std_syz =================*/
676  if (strcmp(sys_cmd, "std_syz") == 0)
677  {
678  ideal i1;
679  int i2;
680  if ((h!=NULL) && (h->Typ()==MODUL_CMD))
681  {
682  i1=(ideal)h->CopyD();
683  h=h->next;
684  }
685  else return TRUE;
686  if ((h!=NULL) && (h->Typ()==INT_CMD))
687  {
688  i2=(int)((long)h->Data());
689  }
690  else return TRUE;
691  res->rtyp=MODUL_CMD;
692  res->data=idXXX(i1,i2);
693  return FALSE;
694  }
695  else
696  /*======================= demon_list =====================*/
697  if (strcmp(sys_cmd,"denom_list")==0)
698  {
699  res->rtyp=LIST_CMD;
700  extern lists get_denom_list();
701  res->data=(lists)get_denom_list();
702  return FALSE;
703  }
704  else
705  /*==================== complexNearZero ======================*/
706  if(strcmp(sys_cmd,"complexNearZero")==0)
707  {
708  const short t[]={2,NUMBER_CMD,INT_CMD};
709  if (iiCheckTypes(h,t,1))
710  {
711  if ( !rField_is_long_C(currRing) )
712  {
713  WerrorS( "unsupported ground field!");
714  return TRUE;
715  }
716  else
717  {
718  res->rtyp=INT_CMD;
719  res->data=(void*)complexNearZero((gmp_complex*)h->Data(),
720  (int)((long)(h->next->Data())));
721  return FALSE;
722  }
723  }
724  else
725  {
726  return TRUE;
727  }
728  }
729  else
730  /*==================== getPrecDigits ======================*/
731  if(strcmp(sys_cmd,"getPrecDigits")==0)
732  {
733  if ( (currRing==NULL)
735  {
736  WerrorS( "unsupported ground field!");
737  return TRUE;
738  }
739  res->rtyp=INT_CMD;
740  res->data=(void*)(long)gmp_output_digits;
741  //if (gmp_output_digits!=getGMPFloatDigits())
742  //{ Print("%d, %d\n",getGMPFloatDigits(),gmp_output_digits);}
743  return FALSE;
744  }
745  else
746  /*==================== lduDecomp ======================*/
747  if(strcmp(sys_cmd, "lduDecomp")==0)
748  {
749  const short t[]={1,MATRIX_CMD};
750  if (iiCheckTypes(h,t,1))
751  {
752  matrix aMat = (matrix)h->Data();
753  matrix pMat; matrix lMat; matrix dMat; matrix uMat;
754  poly l; poly u; poly prodLU;
755  lduDecomp(aMat, pMat, lMat, dMat, uMat, l, u, prodLU);
757  L->Init(7);
758  L->m[0].rtyp = MATRIX_CMD; L->m[0].data=(void*)pMat;
759  L->m[1].rtyp = MATRIX_CMD; L->m[1].data=(void*)lMat;
760  L->m[2].rtyp = MATRIX_CMD; L->m[2].data=(void*)dMat;
761  L->m[3].rtyp = MATRIX_CMD; L->m[3].data=(void*)uMat;
762  L->m[4].rtyp = POLY_CMD; L->m[4].data=(void*)l;
763  L->m[5].rtyp = POLY_CMD; L->m[5].data=(void*)u;
764  L->m[6].rtyp = POLY_CMD; L->m[6].data=(void*)prodLU;
765  res->rtyp = LIST_CMD;
766  res->data = (char *)L;
767  return FALSE;
768  }
769  else
770  {
771  return TRUE;
772  }
773  }
774  else
775  /*==================== lduSolve ======================*/
776  if(strcmp(sys_cmd, "lduSolve")==0)
777  {
778  /* for solving a linear equation system A * x = b, via the
779  given LDU-decomposition of the matrix A;
780  There is one valid parametrisation:
781  1) exactly eight arguments P, L, D, U, l, u, lTimesU, b;
782  P, L, D, and U realise the LDU-decomposition of A, that is,
783  P * A = L * D^(-1) * U, and P, L, D, and U satisfy the
784  properties decribed in method 'luSolveViaLDUDecomp' in
785  linearAlgebra.h; see there;
786  l, u, and lTimesU are as described in the same location;
787  b is the right-hand side vector of the linear equation system;
788  The method will return a list of either 1 entry or three entries:
789  1) [0] if there is no solution to the system;
790  2) [1, x, H] if there is at least one solution;
791  x is any solution of the given linear system,
792  H is the matrix with column vectors spanning the homogeneous
793  solution space.
794  The method produces an error if matrix and vector sizes do not
795  fit. */
796  const short t[]={7,MATRIX_CMD,MATRIX_CMD,MATRIX_CMD,MATRIX_CMD,POLY_CMD,POLY_CMD,MATRIX_CMD};
797  if (!iiCheckTypes(h,t,1))
798  {
799  return TRUE;
800  }
802  {
803  WerrorS("field required");
804  return TRUE;
805  }
806  matrix pMat = (matrix)h->Data();
807  matrix lMat = (matrix)h->next->Data();
808  matrix dMat = (matrix)h->next->next->Data();
809  matrix uMat = (matrix)h->next->next->next->Data();
810  poly l = (poly) h->next->next->next->next->Data();
811  poly u = (poly) h->next->next->next->next->next->Data();
812  poly lTimesU = (poly) h->next->next->next->next->next->next->Data();
813  matrix bVec = (matrix)h->next->next->next->next->next->next->next->Data();
814  matrix xVec; int solvable; matrix homogSolSpace;
815  if (pMat->rows() != pMat->cols())
816  {
817  Werror("first matrix (%d x %d) is not quadratic",
818  pMat->rows(), pMat->cols());
819  return TRUE;
820  }
821  if (lMat->rows() != lMat->cols())
822  {
823  Werror("second matrix (%d x %d) is not quadratic",
824  lMat->rows(), lMat->cols());
825  return TRUE;
826  }
827  if (dMat->rows() != dMat->cols())
828  {
829  Werror("third matrix (%d x %d) is not quadratic",
830  dMat->rows(), dMat->cols());
831  return TRUE;
832  }
833  if (dMat->cols() != uMat->rows())
834  {
835  Werror("third matrix (%d x %d) and fourth matrix (%d x %d) %s",
836  dMat->rows(), dMat->cols(), uMat->rows(), uMat->cols(),
837  "do not t");
838  return TRUE;
839  }
840  if (uMat->rows() != bVec->rows())
841  {
842  Werror("fourth matrix (%d x %d) and vector (%d x 1) do not fit",
843  uMat->rows(), uMat->cols(), bVec->rows());
844  return TRUE;
845  }
846  solvable = luSolveViaLDUDecomp(pMat, lMat, dMat, uMat, l, u, lTimesU,
847  bVec, xVec, homogSolSpace);
848 
849  /* build the return structure; a list with either one or
850  three entries */
852  if (solvable)
853  {
854  ll->Init(3);
855  ll->m[0].rtyp=INT_CMD; ll->m[0].data=(void *)(long)solvable;
856  ll->m[1].rtyp=MATRIX_CMD; ll->m[1].data=(void *)xVec;
857  ll->m[2].rtyp=MATRIX_CMD; ll->m[2].data=(void *)homogSolSpace;
858  }
859  else
860  {
861  ll->Init(1);
862  ll->m[0].rtyp=INT_CMD; ll->m[0].data=(void *)(long)solvable;
863  }
864  res->rtyp = LIST_CMD;
865  res->data=(char*)ll;
866  return FALSE;
867  }
868  else
869  /*==== countedref: reference and shared ====*/
870  if (strcmp(sys_cmd, "shared") == 0)
871  {
872  #ifndef SI_COUNTEDREF_AUTOLOAD
873  void countedref_shared_load();
875  #endif
876  res->rtyp = NONE;
877  return FALSE;
878  }
879  else if (strcmp(sys_cmd, "reference") == 0)
880  {
881  #ifndef SI_COUNTEDREF_AUTOLOAD
884  #endif
885  res->rtyp = NONE;
886  return FALSE;
887  }
888  else
889 /*==================== semaphore =================*/
890 #ifdef HAVE_SIMPLEIPC
891  if (strcmp(sys_cmd,"semaphore")==0)
892  {
893  if((h!=NULL) && (h->Typ()==STRING_CMD) && (h->next!=NULL) && (h->next->Typ()==INT_CMD))
894  {
895  int v=1;
896  if ((h->next->next!=NULL)&& (h->next->next->Typ()==INT_CMD))
897  v=(int)(long)h->next->next->Data();
898  res->data=(char *)(long)simpleipc_cmd((char *)h->Data(),(int)(long)h->next->Data(),v);
899  res->rtyp=INT_CMD;
900  return FALSE;
901  }
902  else
903  {
904  WerrorS("Usage: system(\"semaphore\",<cmd>,int)");
905  return TRUE;
906  }
907  }
908  else
909 #endif
910 /*==================== reserved port =================*/
911  if (strcmp(sys_cmd,"reserve")==0)
912  {
913  int ssiReservePort(int clients);
914  const short t[]={1,INT_CMD};
915  if (iiCheckTypes(h,t,1))
916  {
917  res->rtyp=INT_CMD;
918  int p=ssiReservePort((int)(long)h->Data());
919  res->data=(void*)(long)p;
920  return (p==0);
921  }
922  return TRUE;
923  }
924  else
925 /*==================== reserved link =================*/
926  if (strcmp(sys_cmd,"reservedLink")==0)
927  {
928  res->rtyp=LINK_CMD;
930  res->data=(void*)p;
931  return (p==NULL);
932  }
933  else
934 /*==================== install newstruct =================*/
935  if (strcmp(sys_cmd,"install")==0)
936  {
937  const short t[]={4,STRING_CMD,STRING_CMD,PROC_CMD,INT_CMD};
938  if (iiCheckTypes(h,t,1))
939  {
940  return newstruct_set_proc((char*)h->Data(),(char*)h->next->Data(),
941  (int)(long)h->next->next->next->Data(),
942  (procinfov)h->next->next->Data());
943  }
944  return TRUE;
945  }
946  else
947 /*==================== newstruct =================*/
948  if (strcmp(sys_cmd,"newstruct")==0)
949  {
950  const short t[]={1,STRING_CMD};
951  if (iiCheckTypes(h,t,1))
952  {
953  int id=0;
954  char *n=(char*)h->Data();
955  blackboxIsCmd(n,id);
956  if (id>0)
957  {
958  blackbox *bb=getBlackboxStuff(id);
959  if (BB_LIKE_LIST(bb))
960  {
961  newstruct_desc desc=(newstruct_desc)bb->data;
962  newstructShow(desc);
963  return FALSE;
964  }
965  else Werror("'%s' is not a newstruct",n);
966  }
967  else Werror("'%s' is not a blackbox object",n);
968  }
969  return TRUE;
970  }
971  else
972 /*==================== blackbox =================*/
973  if (strcmp(sys_cmd,"blackbox")==0)
974  {
976  return FALSE;
977  }
978  else
979  /*================= absBiFact ======================*/
980  #ifdef HAVE_NTL
981  if (strcmp(sys_cmd, "absFact") == 0)
982  {
983  const short t[]={1,POLY_CMD};
984  if (iiCheckTypes(h,t,1)
985  && (currRing!=NULL)
986  && (getCoeffType(currRing->cf)==n_transExt))
987  {
988  res->rtyp=LIST_CMD;
989  intvec *v=NULL;
990  ideal mipos= NULL;
991  int n= 0;
992  ideal f=singclap_absFactorize((poly)(h->Data()), mipos, &v, n, currRing);
993  if (f==NULL) return TRUE;
994  ivTest(v);
996  l->Init(4);
997  l->m[0].rtyp=IDEAL_CMD;
998  l->m[0].data=(void *)f;
999  l->m[1].rtyp=INTVEC_CMD;
1000  l->m[1].data=(void *)v;
1001  l->m[2].rtyp=IDEAL_CMD;
1002  l->m[2].data=(void*) mipos;
1003  l->m[3].rtyp=INT_CMD;
1004  l->m[3].data=(void*) (long) n;
1005  res->data=(void *)l;
1006  return FALSE;
1007  }
1008  else return TRUE;
1009  }
1010  else
1011  #endif
1012  /* =================== LLL via NTL ==============================*/
1013  #ifdef HAVE_NTL
1014  if (strcmp(sys_cmd, "LLL") == 0)
1015  {
1016  if (h!=NULL)
1017  {
1018  res->rtyp=h->Typ();
1019  if (h->Typ()==MATRIX_CMD)
1020  {
1021  res->data=(char *)singntl_LLL((matrix)h->Data(), currRing);
1022  return FALSE;
1023  }
1024  else if (h->Typ()==INTMAT_CMD)
1025  {
1026  res->data=(char *)singntl_LLL((intvec*)h->Data());
1027  return FALSE;
1028  }
1029  else return TRUE;
1030  }
1031  else return TRUE;
1032  }
1033  else
1034  #endif
1035  /* =================== LLL via Flint ==============================*/
1036  #ifdef HAVE_FLINT
1037  #if __FLINT_RELEASE >= 20500
1038  if (strcmp(sys_cmd, "LLL_Flint") == 0)
1039  {
1040  if (h!=NULL)
1041  {
1042  if(h->next == NULL)
1043  {
1044  res->rtyp=h->Typ();
1045  if (h->Typ()==BIGINTMAT_CMD)
1046  {
1047  res->data=(char *)singflint_LLL((bigintmat*)h->Data(), NULL);
1048  return FALSE;
1049  }
1050  else if (h->Typ()==INTMAT_CMD)
1051  {
1052  res->data=(char *)singflint_LLL((intvec*)h->Data(), NULL);
1053  return FALSE;
1054  }
1055  else return TRUE;
1056  }
1057  if(h->next->Typ()!= INT_CMD)
1058  {
1059  WerrorS("matrix,int or bigint,int expected");
1060  return TRUE;
1061  }
1062  if(h->next->Typ()== INT_CMD)
1063  {
1064  if(((int)((long)(h->next->Data())) != 0) && (int)((long)(h->next->Data()) != 1))
1065  {
1066  WerrorS("int is different from 0, 1");
1067  return TRUE;
1068  }
1069  res->rtyp=h->Typ();
1070  if((long)(h->next->Data()) == 0)
1071  {
1072  if (h->Typ()==BIGINTMAT_CMD)
1073  {
1074  res->data=(char *)singflint_LLL((bigintmat*)h->Data(), NULL);
1075  return FALSE;
1076  }
1077  else if (h->Typ()==INTMAT_CMD)
1078  {
1079  res->data=(char *)singflint_LLL((intvec*)h->Data(), NULL);
1080  return FALSE;
1081  }
1082  else return TRUE;
1083  }
1084  // This will give also the transformation matrix U s.t. res = U * m
1085  if((long)(h->next->Data()) == 1)
1086  {
1087  if (h->Typ()==BIGINTMAT_CMD)
1088  {
1089  bigintmat* m = (bigintmat*)h->Data();
1090  bigintmat* T = new bigintmat(m->rows(),m->rows(),m->basecoeffs());
1091  for(int i = 1; i<=m->rows(); i++)
1092  {
1093  n_Delete(&(BIMATELEM(*T,i,i)),T->basecoeffs());
1094  BIMATELEM(*T,i,i)=n_Init(1, T->basecoeffs());
1095  }
1096  m = singflint_LLL(m,T);
1098  L->Init(2);
1099  L->m[0].rtyp = BIGINTMAT_CMD; L->m[0].data = (void*)m;
1100  L->m[1].rtyp = BIGINTMAT_CMD; L->m[1].data = (void*)T;
1101  res->data=L;
1102  res->rtyp=LIST_CMD;
1103  return FALSE;
1104  }
1105  else if (h->Typ()==INTMAT_CMD)
1106  {
1107  intvec* m = (intvec*)h->Data();
1108  intvec* T = new intvec(m->rows(),m->rows(),(int)0);
1109  for(int i = 1; i<=m->rows(); i++)
1110  IMATELEM(*T,i,i)=1;
1111  m = singflint_LLL(m,T);
1113  L->Init(2);
1114  L->m[0].rtyp = INTMAT_CMD; L->m[0].data = (void*)m;
1115  L->m[1].rtyp = INTMAT_CMD; L->m[1].data = (void*)T;
1116  res->data=L;
1117  res->rtyp=LIST_CMD;
1118  return FALSE;
1119  }
1120  else return TRUE;
1121  }
1122  }
1123 
1124  }
1125  else return TRUE;
1126  }
1127  else
1128  #endif
1129  #endif
1130  /*==================== shift-test for freeGB =================*/
1131  #ifdef HAVE_SHIFTBBA
1132  if (strcmp(sys_cmd, "stest") == 0)
1133  {
1134  const short t[]={4,POLY_CMD,INT_CMD,INT_CMD,INT_CMD};
1135  if (iiCheckTypes(h,t,1))
1136  {
1137  poly p=(poly)h->CopyD();
1138  h=h->next;
1139  int sh=(int)((long)(h->Data()));
1140  h=h->next;
1141  int uptodeg=(int)((long)(h->Data()));
1142  h=h->next;
1143  int lVblock=(int)((long)(h->Data()));
1144  if (sh<0)
1145  {
1146  WerrorS("negative shift for pLPshift");
1147  return TRUE;
1148  }
1149  int L = pmLastVblock(p,lVblock);
1150  if (L+sh-1 > uptodeg)
1151  {
1152  WerrorS("pLPshift: too big shift requested\n");
1153  return TRUE;
1154  }
1155  res->data = pLPshift(p,sh,uptodeg,lVblock);
1156  res->rtyp = POLY_CMD;
1157  return FALSE;
1158  }
1159  else return TRUE;
1160  }
1161  else
1162  #endif
1163  /*==================== block-test for freeGB =================*/
1164  #ifdef HAVE_SHIFTBBA
1165  if (strcmp(sys_cmd, "btest") == 0)
1166  {
1167  const short t[]={2,POLY_CMD,INT_CMD};
1168  if (iiCheckTypes(h,t,1))
1169  {
1170  poly p=(poly)h->CopyD();
1171  h=h->next;
1172  int lV=(int)((long)(h->Data()));
1173  res->rtyp = INT_CMD;
1174  res->data = (void*)(long)pLastVblock(p, lV);
1175  return FALSE;
1176  }
1177  else return TRUE;
1178  }
1179  else
1180  #endif
1181  /*==================== shrink-test for freeGB =================*/
1182  #ifdef HAVE_SHIFTBBA
1183  if (strcmp(sys_cmd, "shrinktest") == 0)
1184  {
1185  const short t[]={2,POLY_CMD,INT_CMD};
1186  if (iiCheckTypes(h,t,1))
1187  {
1188  poly p=(poly)h->Data();
1189  h=h->next;
1190  int lV=(int)((long)(h->Data()));
1191  res->rtyp = POLY_CMD;
1192  // res->data = p_mShrink(p, lV, currRing);
1193  // kStrategy strat=new skStrategy;
1194  // strat->tailRing = currRing;
1195  res->data = p_Shrink(p, lV, currRing);
1196  return FALSE;
1197  }
1198  else return TRUE;
1199  }
1200  else
1201  #endif
1202  /*==================== pcv ==================================*/
1203  #ifdef HAVE_PCV
1204  if(strcmp(sys_cmd,"pcvLAddL")==0)
1205  {
1206  return pcvLAddL(res,h);
1207  }
1208  else
1209  if(strcmp(sys_cmd,"pcvPMulL")==0)
1210  {
1211  return pcvPMulL(res,h);
1212  }
1213  else
1214  if(strcmp(sys_cmd,"pcvMinDeg")==0)
1215  {
1216  return pcvMinDeg(res,h);
1217  }
1218  else
1219  if(strcmp(sys_cmd,"pcvP2CV")==0)
1220  {
1221  return pcvP2CV(res,h);
1222  }
1223  else
1224  if(strcmp(sys_cmd,"pcvCV2P")==0)
1225  {
1226  return pcvCV2P(res,h);
1227  }
1228  else
1229  if(strcmp(sys_cmd,"pcvDim")==0)
1230  {
1231  return pcvDim(res,h);
1232  }
1233  else
1234  if(strcmp(sys_cmd,"pcvBasis")==0)
1235  {
1236  return pcvBasis(res,h);
1237  }
1238  else
1239  #endif
1240  /*==================== hessenberg/eigenvalues ==================================*/
1241  #ifdef HAVE_EIGENVAL
1242  if(strcmp(sys_cmd,"hessenberg")==0)
1243  {
1244  return evHessenberg(res,h);
1245  }
1246  else
1247  #endif
1248  /*==================== eigenvalues ==================================*/
1249  #ifdef HAVE_EIGENVAL
1250  if(strcmp(sys_cmd,"eigenvals")==0)
1251  {
1252  return evEigenvals(res,h);
1253  }
1254  else
1255  #endif
1256  /*==================== rowelim ==================================*/
1257  #ifdef HAVE_EIGENVAL
1258  if(strcmp(sys_cmd,"rowelim")==0)
1259  {
1260  return evRowElim(res,h);
1261  }
1262  else
1263  #endif
1264  /*==================== rowcolswap ==================================*/
1265  #ifdef HAVE_EIGENVAL
1266  if(strcmp(sys_cmd,"rowcolswap")==0)
1267  {
1268  return evSwap(res,h);
1269  }
1270  else
1271  #endif
1272  /*==================== Gauss-Manin system ==================================*/
1273  #ifdef HAVE_GMS
1274  if(strcmp(sys_cmd,"gmsnf")==0)
1275  {
1276  return gmsNF(res,h);
1277  }
1278  else
1279  #endif
1280  /*==================== contributors =============================*/
1281  if(strcmp(sys_cmd,"contributors") == 0)
1282  {
1283  res->rtyp=STRING_CMD;
1284  res->data=(void *)omStrDup(
1285  "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");
1286  return FALSE;
1287  }
1288  else
1289  /*==================== spectrum =============================*/
1290  #ifdef HAVE_SPECTRUM
1291  if(strcmp(sys_cmd,"spectrum") == 0)
1292  {
1293  if ((h==NULL) || (h->Typ()!=POLY_CMD))
1294  {
1295  WerrorS("poly expected");
1296  return TRUE;
1297  }
1298  if (h->next==NULL)
1299  return spectrumProc(res,h);
1300  if (h->next->Typ()!=INT_CMD)
1301  {
1302  WerrorS("poly,int expected");
1303  return TRUE;
1304  }
1305  if(((long)h->next->Data())==1L)
1306  return spectrumfProc(res,h);
1307  return spectrumProc(res,h);
1308  }
1309  else
1310  /*==================== semic =============================*/
1311  if(strcmp(sys_cmd,"semic") == 0)
1312  {
1313  if ((h->next!=NULL)
1314  && (h->Typ()==LIST_CMD)
1315  && (h->next->Typ()==LIST_CMD))
1316  {
1317  if (h->next->next==NULL)
1318  return semicProc(res,h,h->next);
1319  else if (h->next->next->Typ()==INT_CMD)
1320  return semicProc3(res,h,h->next,h->next->next);
1321  }
1322  return TRUE;
1323  }
1324  else
1325  /*==================== spadd =============================*/
1326  if(strcmp(sys_cmd,"spadd") == 0)
1327  {
1328  const short t[]={2,LIST_CMD,LIST_CMD};
1329  if (iiCheckTypes(h,t,1))
1330  {
1331  return spaddProc(res,h,h->next);
1332  }
1333  return TRUE;
1334  }
1335  else
1336  /*==================== spmul =============================*/
1337  if(strcmp(sys_cmd,"spmul") == 0)
1338  {
1339  const short t[]={2,LIST_CMD,INT_CMD};
1340  if (iiCheckTypes(h,t,1))
1341  {
1342  return spmulProc(res,h,h->next);
1343  }
1344  return TRUE;
1345  }
1346  else
1347  #endif
1348 /*==================== tensorModuleMult ========================= */
1349  #define HAVE_SHEAFCOH_TRICKS 1
1350 
1351  #ifdef HAVE_SHEAFCOH_TRICKS
1352  if(strcmp(sys_cmd,"tensorModuleMult")==0)
1353  {
1354  const short t[]={2,INT_CMD,MODUL_CMD};
1355  // WarnS("tensorModuleMult!");
1356  if (iiCheckTypes(h,t,1))
1357  {
1358  int m = (int)( (long)h->Data() );
1359  ideal M = (ideal)h->next->Data();
1360  res->rtyp=MODUL_CMD;
1361  res->data=(void *)id_TensorModuleMult(m, M, currRing);
1362  return FALSE;
1363  }
1364  return TRUE;
1365  }
1366  else
1367  #endif
1368  /*==================== twostd =================*/
1369  #ifdef HAVE_PLURAL
1370  if (strcmp(sys_cmd, "twostd") == 0)
1371  {
1372  ideal I;
1373  if ((h!=NULL) && (h->Typ()==IDEAL_CMD))
1374  {
1375  I=(ideal)h->CopyD();
1376  res->rtyp=IDEAL_CMD;
1377  if (rIsPluralRing(currRing)) res->data=twostd(I);
1378  else res->data=I;
1379  setFlag(res,FLAG_TWOSTD);
1380  setFlag(res,FLAG_STD);
1381  }
1382  else return TRUE;
1383  return FALSE;
1384  }
1385  else
1386  #endif
1387  /*==================== lie bracket =================*/
1388  #ifdef HAVE_PLURAL
1389  if (strcmp(sys_cmd, "bracket") == 0)
1390  {
1391  const short t[]={2,POLY_CMD,POLY_CMD};
1392  if (iiCheckTypes(h,t,1))
1393  {
1394  poly p=(poly)h->CopyD();
1395  h=h->next;
1396  poly q=(poly)h->Data();
1397  res->rtyp=POLY_CMD;
1399  return FALSE;
1400  }
1401  return TRUE;
1402  }
1403  else
1404  #endif
1405  /*==================== env ==================================*/
1406  #ifdef HAVE_PLURAL
1407  if (strcmp(sys_cmd, "env")==0)
1408  {
1409  if ((h!=NULL) && (h->Typ()==RING_CMD))
1410  {
1411  ring r = (ring)h->Data();
1412  res->data = rEnvelope(r);
1413  res->rtyp = RING_CMD;
1414  return FALSE;
1415  }
1416  else
1417  {
1418  WerrorS("`system(\"env\",<ring>)` expected");
1419  return TRUE;
1420  }
1421  }
1422  else
1423  #endif
1424 /* ============ opp ======================== */
1425  #ifdef HAVE_PLURAL
1426  if (strcmp(sys_cmd, "opp")==0)
1427  {
1428  if ((h!=NULL) && (h->Typ()==RING_CMD))
1429  {
1430  ring r=(ring)h->Data();
1431  res->data=rOpposite(r);
1432  res->rtyp=RING_CMD;
1433  return FALSE;
1434  }
1435  else
1436  {
1437  WerrorS("`system(\"opp\",<ring>)` expected");
1438  return TRUE;
1439  }
1440  }
1441  else
1442  #endif
1443  /*==================== oppose ==================================*/
1444  #ifdef HAVE_PLURAL
1445  if (strcmp(sys_cmd, "oppose")==0)
1446  {
1447  if ((h!=NULL) && (h->Typ()==RING_CMD)
1448  && (h->next!= NULL))
1449  {
1450  ring Rop = (ring)h->Data();
1451  h = h->next;
1452  idhdl w;
1453  if ((w=Rop->idroot->get(h->Name(),myynest))!=NULL)
1454  {
1455  poly p = (poly)IDDATA(w);
1456  res->data = pOppose(Rop, p, currRing); // into CurrRing?
1457  res->rtyp = POLY_CMD;
1458  return FALSE;
1459  }
1460  }
1461  else
1462  {
1463  WerrorS("`system(\"oppose\",<ring>,<poly>)` expected");
1464  return TRUE;
1465  }
1466  }
1467  else
1468  #endif
1469  /*==================== freeGB, twosided GB in free algebra =================*/
1470  #ifdef HAVE_PLURAL
1471  #ifdef HAVE_SHIFTBBA
1472  if (strcmp(sys_cmd, "freegb") == 0)
1473  {
1474  const short t[]={3,IDEAL_CMD,INT_CMD,INT_CMD};
1475  if (iiCheckTypes(h,t,1))
1476  {
1477  ideal I=(ideal)h->CopyD();
1478  h=h->next;
1479  int uptodeg=(int)((long)(h->Data()));
1480  h=h->next;
1481  int lVblock=(int)((long)(h->Data()));
1482  res->data = freegb(I,uptodeg,lVblock);
1483  if (res->data == NULL)
1484  {
1485  /* that is there were input errors */
1486  res->data = I;
1487  }
1488  res->rtyp = IDEAL_CMD;
1489  return FALSE;
1490  }
1491  else return TRUE;
1492  }
1493  else
1494  #endif /*SHIFTBBA*/
1495  #endif /*PLURAL*/
1496  /*==================== walk stuff =================*/
1497  /*==================== walkNextWeight =================*/
1498  #ifdef HAVE_WALK
1499  #ifdef OWNW
1500  if (strcmp(sys_cmd, "walkNextWeight") == 0)
1501  {
1502  const short t[]={3,INTVEC_CMD,INTVEC_CMD,IDEAL_CMD};
1503  if (!iiCheckTypes(h,t,1)) return TRUE;
1504  if (((intvec*) h->Data())->length() != currRing->N ||
1505  ((intvec*) h->next->Data())->length() != currRing->N)
1506  {
1507  Werror("system(\"walkNextWeight\" ...) intvecs not of length %d\n",
1508  currRing->N);
1509  return TRUE;
1510  }
1511  res->data = (void*) walkNextWeight(((intvec*) h->Data()),
1512  ((intvec*) h->next->Data()),
1513  (ideal) h->next->next->Data());
1514  if (res->data == NULL || res->data == (void*) 1L)
1515  {
1516  res->rtyp = INT_CMD;
1517  }
1518  else
1519  {
1520  res->rtyp = INTVEC_CMD;
1521  }
1522  return FALSE;
1523  }
1524  else
1525  #endif
1526  #endif
1527  /*==================== walkNextWeight =================*/
1528  #ifdef HAVE_WALK
1529  #ifdef OWNW
1530  if (strcmp(sys_cmd, "walkInitials") == 0)
1531  {
1532  if (h == NULL || h->Typ() != IDEAL_CMD)
1533  {
1534  WerrorS("system(\"walkInitials\", ideal) expected");
1535  return TRUE;
1536  }
1537  res->data = (void*) walkInitials((ideal) h->Data());
1538  res->rtyp = IDEAL_CMD;
1539  return FALSE;
1540  }
1541  else
1542  #endif
1543  #endif
1544  /*==================== walkAddIntVec =================*/
1545  #ifdef HAVE_WALK
1546  #ifdef WAIV
1547  if (strcmp(sys_cmd, "walkAddIntVec") == 0)
1548  {
1549  const short t[]={2,INTVEC_CMD,INTVEC_CMD};
1550  if (!iiCheckTypes(h,t,1)) return TRUE;
1551  intvec* arg1 = (intvec*) h->Data();
1552  intvec* arg2 = (intvec*) h->next->Data();
1553  res->data = (intvec*) walkAddIntVec(arg1, arg2);
1554  res->rtyp = INTVEC_CMD;
1555  return FALSE;
1556  }
1557  else
1558  #endif
1559  #endif
1560  /*==================== MwalkNextWeight =================*/
1561  #ifdef HAVE_WALK
1562  #ifdef MwaklNextWeight
1563  if (strcmp(sys_cmd, "MwalkNextWeight") == 0)
1564  {
1565  const short t[]={3,INTVEC_CMD,INTVEC_CMD,IDEAL_CMD};
1566  if (!iiCheckTypes(h,t,1)) return TRUE;
1567  if (((intvec*) h->Data())->length() != currRing->N ||
1568  ((intvec*) h->next->Data())->length() != currRing->N)
1569  {
1570  Werror("system(\"MwalkNextWeight\" ...) intvecs not of length %d\n",
1571  currRing->N);
1572  return TRUE;
1573  }
1574  intvec* arg1 = (intvec*) h->Data();
1575  intvec* arg2 = (intvec*) h->next->Data();
1576  ideal arg3 = (ideal) h->next->next->Data();
1577  intvec* result = (intvec*) MwalkNextWeight(arg1, arg2, arg3);
1578  res->rtyp = INTVEC_CMD;
1579  res->data = result;
1580  return FALSE;
1581  }
1582  else
1583  #endif //MWalkNextWeight
1584  #endif
1585  /*==================== Mivdp =================*/
1586  #ifdef HAVE_WALK
1587  if(strcmp(sys_cmd, "Mivdp") == 0)
1588  {
1589  if (h == NULL || h->Typ() != INT_CMD)
1590  {
1591  WerrorS("system(\"Mivdp\", int) expected");
1592  return TRUE;
1593  }
1594  if ((int) ((long)(h->Data())) != currRing->N)
1595  {
1596  Werror("system(\"Mivdp\" ...) intvecs not of length %d\n",
1597  currRing->N);
1598  return TRUE;
1599  }
1600  int arg1 = (int) ((long)(h->Data()));
1601  intvec* result = (intvec*) Mivdp(arg1);
1602  res->rtyp = INTVEC_CMD;
1603  res->data = result;
1604  return FALSE;
1605  }
1606  else
1607  #endif
1608  /*==================== Mivlp =================*/
1609  #ifdef HAVE_WALK
1610  if(strcmp(sys_cmd, "Mivlp") == 0)
1611  {
1612  if (h == NULL || h->Typ() != INT_CMD)
1613  {
1614  WerrorS("system(\"Mivlp\", int) expected");
1615  return TRUE;
1616  }
1617  if ((int) ((long)(h->Data())) != currRing->N)
1618  {
1619  Werror("system(\"Mivlp\" ...) intvecs not of length %d\n",
1620  currRing->N);
1621  return TRUE;
1622  }
1623  int arg1 = (int) ((long)(h->Data()));
1624  intvec* result = (intvec*) Mivlp(arg1);
1625  res->rtyp = INTVEC_CMD;
1626  res->data = result;
1627  return FALSE;
1628  }
1629  else
1630  #endif
1631  /*==================== MpDiv =================*/
1632  #ifdef HAVE_WALK
1633  #ifdef MpDiv
1634  if(strcmp(sys_cmd, "MpDiv") == 0)
1635  {
1636  const short t[]={2,POLY_CMD,POLY_CMD};
1637  if (!iiCheckTypes(h,t,1)) return TRUE;
1638  poly arg1 = (poly) h->Data();
1639  poly arg2 = (poly) h->next->Data();
1640  poly result = MpDiv(arg1, arg2);
1641  res->rtyp = POLY_CMD;
1642  res->data = result;
1643  return FALSE;
1644  }
1645  else
1646  #endif
1647  #endif
1648  /*==================== MpMult =================*/
1649  #ifdef HAVE_WALK
1650  #ifdef MpMult
1651  if(strcmp(sys_cmd, "MpMult") == 0)
1652  {
1653  const short t[]={2,POLY_CMD,POLY_CMD};
1654  if (!iiCheckTypes(h,t,1)) return TRUE;
1655  poly arg1 = (poly) h->Data();
1656  poly arg2 = (poly) h->next->Data();
1657  poly result = MpMult(arg1, arg2);
1658  res->rtyp = POLY_CMD;
1659  res->data = result;
1660  return FALSE;
1661  }
1662  else
1663  #endif
1664  #endif
1665  /*==================== MivSame =================*/
1666  #ifdef HAVE_WALK
1667  if (strcmp(sys_cmd, "MivSame") == 0)
1668  {
1669  const short t[]={2,INTVEC_CMD,INTVEC_CMD};
1670  if (!iiCheckTypes(h,t,1)) return TRUE;
1671  /*
1672  if (((intvec*) h->Data())->length() != currRing->N ||
1673  ((intvec*) h->next->Data())->length() != currRing->N)
1674  {
1675  Werror("system(\"MivSame\" ...) intvecs not of length %d\n",
1676  currRing->N);
1677  return TRUE;
1678  }
1679  */
1680  intvec* arg1 = (intvec*) h->Data();
1681  intvec* arg2 = (intvec*) h->next->Data();
1682  /*
1683  poly result = (poly) MivSame(arg1, arg2);
1684  res->rtyp = POLY_CMD;
1685  res->data = (poly) result;
1686  */
1687  res->rtyp = INT_CMD;
1688  res->data = (void*)(long) MivSame(arg1, arg2);
1689  return FALSE;
1690  }
1691  else
1692  #endif
1693  /*==================== M3ivSame =================*/
1694  #ifdef HAVE_WALK
1695  if (strcmp(sys_cmd, "M3ivSame") == 0)
1696  {
1697  const short t[]={3,INTVEC_CMD,INTVEC_CMD,INTVEC_CMD};
1698  if (!iiCheckTypes(h,t,1)) return TRUE;
1699  /*
1700  if (((intvec*) h->Data())->length() != currRing->N ||
1701  ((intvec*) h->next->Data())->length() != currRing->N ||
1702  ((intvec*) h->next->next->Data())->length() != currRing->N )
1703  {
1704  Werror("system(\"M3ivSame\" ...) intvecs not of length %d\n",
1705  currRing->N);
1706  return TRUE;
1707  }
1708  */
1709  intvec* arg1 = (intvec*) h->Data();
1710  intvec* arg2 = (intvec*) h->next->Data();
1711  intvec* arg3 = (intvec*) h->next->next->Data();
1712  /*
1713  poly result = (poly) M3ivSame(arg1, arg2, arg3);
1714  res->rtyp = POLY_CMD;
1715  res->data = (poly) result;
1716  */
1717  res->rtyp = INT_CMD;
1718  res->data = (void*)(long) M3ivSame(arg1, arg2, arg3);
1719  return FALSE;
1720  }
1721  else
1722  #endif
1723  /*==================== MwalkInitialForm =================*/
1724  #ifdef HAVE_WALK
1725  if(strcmp(sys_cmd, "MwalkInitialForm") == 0)
1726  {
1727  const short t[]={2,IDEAL_CMD,INTVEC_CMD};
1728  if (!iiCheckTypes(h,t,1)) return TRUE;
1729  if(((intvec*) h->next->Data())->length() != currRing->N)
1730  {
1731  Werror("system \"MwalkInitialForm\"...) intvec not of length %d\n",
1732  currRing->N);
1733  return TRUE;
1734  }
1735  ideal id = (ideal) h->Data();
1736  intvec* int_w = (intvec*) h->next->Data();
1737  ideal result = (ideal) MwalkInitialForm(id, int_w);
1738  res->rtyp = IDEAL_CMD;
1739  res->data = result;
1740  return FALSE;
1741  }
1742  else
1743  #endif
1744  /*==================== MivMatrixOrder =================*/
1745  #ifdef HAVE_WALK
1746  /************** Perturbation walk **********/
1747  if(strcmp(sys_cmd, "MivMatrixOrder") == 0)
1748  {
1749  if(h==NULL || h->Typ() != INTVEC_CMD)
1750  {
1751  WerrorS("system(\"MivMatrixOrder\",intvec) expected");
1752  return TRUE;
1753  }
1754  intvec* arg1 = (intvec*) h->Data();
1755  intvec* result = MivMatrixOrder(arg1);
1756  res->rtyp = INTVEC_CMD;
1757  res->data = result;
1758  return FALSE;
1759  }
1760  else
1761  #endif
1762  /*==================== MivMatrixOrderdp =================*/
1763  #ifdef HAVE_WALK
1764  if(strcmp(sys_cmd, "MivMatrixOrderdp") == 0)
1765  {
1766  if(h==NULL || h->Typ() != INT_CMD)
1767  {
1768  WerrorS("system(\"MivMatrixOrderdp\",intvec) expected");
1769  return TRUE;
1770  }
1771  int arg1 = (int) ((long)(h->Data()));
1772  intvec* result = (intvec*) MivMatrixOrderdp(arg1);
1773  res->rtyp = INTVEC_CMD;
1774  res->data = result;
1775  return FALSE;
1776  }
1777  else
1778  #endif
1779  /*==================== MPertVectors =================*/
1780  #ifdef HAVE_WALK
1781  if(strcmp(sys_cmd, "MPertVectors") == 0)
1782  {
1783  const short t[]={3,IDEAL_CMD,INTVEC_CMD,INT_CMD};
1784  if (!iiCheckTypes(h,t,1)) return TRUE;
1785  ideal arg1 = (ideal) h->Data();
1786  intvec* arg2 = (intvec*) h->next->Data();
1787  int arg3 = (int) ((long)(h->next->next->Data()));
1788  intvec* result = (intvec*) MPertVectors(arg1, arg2, arg3);
1789  res->rtyp = INTVEC_CMD;
1790  res->data = result;
1791  return FALSE;
1792  }
1793  else
1794  #endif
1795  /*==================== MPertVectorslp =================*/
1796  #ifdef HAVE_WALK
1797  if(strcmp(sys_cmd, "MPertVectorslp") == 0)
1798  {
1799  const short t[]={3,IDEAL_CMD,INTVEC_CMD,INT_CMD};
1800  if (!iiCheckTypes(h,t,1)) return TRUE;
1801  ideal arg1 = (ideal) h->Data();
1802  intvec* arg2 = (intvec*) h->next->Data();
1803  int arg3 = (int) ((long)(h->next->next->Data()));
1804  intvec* result = (intvec*) MPertVectorslp(arg1, arg2, arg3);
1805  res->rtyp = INTVEC_CMD;
1806  res->data = result;
1807  return FALSE;
1808  }
1809  else
1810  #endif
1811  /************** fractal walk **********/
1812  #ifdef HAVE_WALK
1813  if(strcmp(sys_cmd, "Mfpertvector") == 0)
1814  {
1815  const short t[]={2,IDEAL_CMD,INTVEC_CMD};
1816  if (!iiCheckTypes(h,t,1)) return TRUE;
1817  ideal arg1 = (ideal) h->Data();
1818  intvec* arg2 = (intvec*) h->next->Data();
1819  intvec* result = Mfpertvector(arg1, arg2);
1820  res->rtyp = INTVEC_CMD;
1821  res->data = result;
1822  return FALSE;
1823  }
1824  else
1825  #endif
1826  /*==================== MivUnit =================*/
1827  #ifdef HAVE_WALK
1828  if(strcmp(sys_cmd, "MivUnit") == 0)
1829  {
1830  const short t[]={1,INT_CMD};
1831  if (!iiCheckTypes(h,t,1)) return TRUE;
1832  int arg1 = (int) ((long)(h->Data()));
1833  intvec* result = (intvec*) MivUnit(arg1);
1834  res->rtyp = INTVEC_CMD;
1835  res->data = result;
1836  return FALSE;
1837  }
1838  else
1839  #endif
1840  /*==================== MivWeightOrderlp =================*/
1841  #ifdef HAVE_WALK
1842  if(strcmp(sys_cmd, "MivWeightOrderlp") == 0)
1843  {
1844  const short t[]={1,INTVEC_CMD};
1845  if (!iiCheckTypes(h,t,1)) return TRUE;
1846  intvec* arg1 = (intvec*) h->Data();
1847  intvec* result = MivWeightOrderlp(arg1);
1848  res->rtyp = INTVEC_CMD;
1849  res->data = result;
1850  return FALSE;
1851  }
1852  else
1853  #endif
1854  /*==================== MivWeightOrderdp =================*/
1855  #ifdef HAVE_WALK
1856  if(strcmp(sys_cmd, "MivWeightOrderdp") == 0)
1857  {
1858  if(h==NULL || h->Typ() != INTVEC_CMD)
1859  {
1860  WerrorS("system(\"MivWeightOrderdp\",intvec) expected");
1861  return TRUE;
1862  }
1863  intvec* arg1 = (intvec*) h->Data();
1864  //int arg2 = (int) h->next->Data();
1865  intvec* result = MivWeightOrderdp(arg1);
1866  res->rtyp = INTVEC_CMD;
1867  res->data = result;
1868  return FALSE;
1869  }
1870  else
1871  #endif
1872  /*==================== MivMatrixOrderlp =================*/
1873  #ifdef HAVE_WALK
1874  if(strcmp(sys_cmd, "MivMatrixOrderlp") == 0)
1875  {
1876  if(h==NULL || h->Typ() != INT_CMD)
1877  {
1878  WerrorS("system(\"MivMatrixOrderlp\",int) expected");
1879  return TRUE;
1880  }
1881  int arg1 = (int) ((long)(h->Data()));
1882  intvec* result = (intvec*) MivMatrixOrderlp(arg1);
1883  res->rtyp = INTVEC_CMD;
1884  res->data = result;
1885  return FALSE;
1886  }
1887  else
1888  #endif
1889  /*==================== MkInterRedNextWeight =================*/
1890  #ifdef HAVE_WALK
1891  if (strcmp(sys_cmd, "MkInterRedNextWeight") == 0)
1892  {
1893  const short t[]={3,INTVEC_CMD,INTVEC_CMD,IDEAL_CMD};
1894  if (!iiCheckTypes(h,t,1)) return TRUE;
1895  if (((intvec*) h->Data())->length() != currRing->N ||
1896  ((intvec*) h->next->Data())->length() != currRing->N)
1897  {
1898  Werror("system(\"MkInterRedNextWeight\" ...) intvecs not of length %d\n",
1899  currRing->N);
1900  return TRUE;
1901  }
1902  intvec* arg1 = (intvec*) h->Data();
1903  intvec* arg2 = (intvec*) h->next->Data();
1904  ideal arg3 = (ideal) h->next->next->Data();
1905  intvec* result = (intvec*) MkInterRedNextWeight(arg1, arg2, arg3);
1906  res->rtyp = INTVEC_CMD;
1907  res->data = result;
1908  return FALSE;
1909  }
1910  else
1911  #endif
1912  /*==================== MPertNextWeight =================*/
1913  #ifdef HAVE_WALK
1914  #ifdef MPertNextWeight
1915  if (strcmp(sys_cmd, "MPertNextWeight") == 0)
1916  {
1917  const short t[]={3,INTVEC_CMD,IDEAL_CMD,INT_CMD};
1918  if (!iiCheckTypes(h,t,1)) return TRUE;
1919  if (((intvec*) h->Data())->length() != currRing->N)
1920  {
1921  Werror("system(\"MPertNextWeight\" ...) intvecs not of length %d\n",
1922  currRing->N);
1923  return TRUE;
1924  }
1925  intvec* arg1 = (intvec*) h->Data();
1926  ideal arg2 = (ideal) h->next->Data();
1927  int arg3 = (int) h->next->next->Data();
1928  intvec* result = (intvec*) MPertNextWeight(arg1, arg2, arg3);
1929  res->rtyp = INTVEC_CMD;
1930  res->data = result;
1931  return FALSE;
1932  }
1933  else
1934  #endif //MPertNextWeight
1935  #endif
1936  /*==================== Mivperttarget =================*/
1937  #ifdef HAVE_WALK
1938  #ifdef Mivperttarget
1939  if (strcmp(sys_cmd, "Mivperttarget") == 0)
1940  {
1941  const short t[]={2,IDEAL_CMD,INT_CMD};
1942  if (!iiCheckTypes(h,t,1)) return TRUE;
1943  ideal arg1 = (ideal) h->Data();
1944  int arg2 = (int) h->next->Data();
1945  intvec* result = (intvec*) Mivperttarget(arg1, arg2);
1946  res->rtyp = INTVEC_CMD;
1947  res->data = result;
1948  return FALSE;
1949  }
1950  else
1951  #endif //Mivperttarget
1952  #endif
1953  /*==================== Mwalk =================*/
1954  #ifdef HAVE_WALK
1955  if (strcmp(sys_cmd, "Mwalk") == 0)
1956  {
1957  const short t[]={6,IDEAL_CMD,INTVEC_CMD,INTVEC_CMD,RING_CMD,INT_CMD,INT_CMD};
1958  if (!iiCheckTypes(h,t,1)) return TRUE;
1959  if (((intvec*) h->next->Data())->length() != currRing->N &&
1960  ((intvec*) h->next->next->Data())->length() != currRing->N )
1961  {
1962  Werror("system(\"Mwalk\" ...) intvecs not of length %d\n",
1963  currRing->N);
1964  return TRUE;
1965  }
1966  ideal arg1 = (ideal) h->CopyD();
1967  intvec* arg2 = (intvec*) h->next->Data();
1968  intvec* arg3 = (intvec*) h->next->next->Data();
1969  ring arg4 = (ring) h->next->next->next->Data();
1970  int arg5 = (int) (long) h->next->next->next->next->Data();
1971  int arg6 = (int) (long) h->next->next->next->next->next->Data();
1972  ideal result = (ideal) Mwalk(arg1, arg2, arg3, arg4, arg5, arg6);
1973  res->rtyp = IDEAL_CMD;
1974  res->data = result;
1975  return FALSE;
1976  }
1977  else
1978  #endif
1979  /*==================== Mpwalk =================*/
1980  #ifdef HAVE_WALK
1981  #ifdef MPWALK_ORIG
1982  if (strcmp(sys_cmd, "Mwalk") == 0)
1983  {
1984  const short t[]={4,IDEAL_CMD,INTVEC_CMD,INTVEC_CMD,RING_CMD};
1985  if (!iiCheckTypes(h,t,1)) return TRUE;
1986  if ((((intvec*) h->next->Data())->length() != currRing->N &&
1987  ((intvec*) h->next->next->Data())->length() != currRing->N ) &&
1988  (((intvec*) h->next->Data())->length() != (currRing->N)*(currRing->N) &&
1989  ((intvec*) h->next->next->Data())->length() != (currRing->N)*(currRing->N)))
1990  {
1991  Werror("system(\"Mwalk\" ...) intvecs not of length %d or %d\n",
1992  currRing->N,(currRing->N)*(currRing->N));
1993  return TRUE;
1994  }
1995  ideal arg1 = (ideal) h->Data();
1996  intvec* arg2 = (intvec*) h->next->Data();
1997  intvec* arg3 = (intvec*) h->next->next->Data();
1998  ring arg4 = (ring) h->next->next->next->Data();
1999  ideal result = (ideal) Mwalk(arg1, arg2, arg3,arg4);
2000  res->rtyp = IDEAL_CMD;
2001  res->data = result;
2002  return FALSE;
2003  }
2004  else
2005  #else
2006  if (strcmp(sys_cmd, "Mpwalk") == 0)
2007  {
2008  const short t[]={8,IDEAL_CMD,INT_CMD,INT_CMD,INTVEC_CMD,INTVEC_CMD,INT_CMD,INT_CMD,INT_CMD};
2009  if (!iiCheckTypes(h,t,1)) return TRUE;
2010  if(((intvec*) h->next->next->next->Data())->length() != currRing->N &&
2011  ((intvec*) h->next->next->next->next->Data())->length()!=currRing->N)
2012  {
2013  Werror("system(\"Mpwalk\" ...) intvecs not of length %d\n",currRing->N);
2014  return TRUE;
2015  }
2016  ideal arg1 = (ideal) h->Data();
2017  int arg2 = (int) (long) h->next->Data();
2018  int arg3 = (int) (long) h->next->next->Data();
2019  intvec* arg4 = (intvec*) h->next->next->next->Data();
2020  intvec* arg5 = (intvec*) h->next->next->next->next->Data();
2021  int arg6 = (int) (long) h->next->next->next->next->next->Data();
2022  int arg7 = (int) (long) h->next->next->next->next->next->next->Data();
2023  int arg8 = (int) (long) h->next->next->next->next->next->next->next->Data();
2024  ideal result = (ideal) Mpwalk(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
2025  res->rtyp = IDEAL_CMD;
2026  res->data = result;
2027  return FALSE;
2028  }
2029  else
2030  #endif
2031  #endif
2032  /*==================== Mrwalk =================*/
2033  #ifdef HAVE_WALK
2034  if (strcmp(sys_cmd, "Mrwalk") == 0)
2035  {
2036  const short t[]={7,IDEAL_CMD,INTVEC_CMD,INTVEC_CMD,INT_CMD,INT_CMD,INT_CMD,INT_CMD};
2037  if (!iiCheckTypes(h,t,1)) return TRUE;
2038  if(((intvec*) h->next->Data())->length() != currRing->N &&
2039  ((intvec*) h->next->Data())->length() != (currRing->N)*(currRing->N) &&
2040  ((intvec*) h->next->next->Data())->length() != currRing->N &&
2041  ((intvec*) h->next->next->Data())->length() != (currRing->N)*(currRing->N) )
2042  {
2043  Werror("system(\"Mrwalk\" ...) intvecs not of length %d or %d\n",
2044  currRing->N,(currRing->N)*(currRing->N));
2045  return TRUE;
2046  }
2047  ideal arg1 = (ideal) h->Data();
2048  intvec* arg2 = (intvec*) h->next->Data();
2049  intvec* arg3 = (intvec*) h->next->next->Data();
2050  int arg4 = (int)(long) h->next->next->next->Data();
2051  int arg5 = (int)(long) h->next->next->next->next->Data();
2052  int arg6 = (int)(long) h->next->next->next->next->next->Data();
2053  int arg7 = (int)(long) h->next->next->next->next->next->next->Data();
2054  ideal result = (ideal) Mrwalk(arg1, arg2, arg3, arg4, arg5, arg6, arg7);
2055  res->rtyp = IDEAL_CMD;
2056  res->data = result;
2057  return FALSE;
2058  }
2059  else
2060  #endif
2061  /*==================== MAltwalk1 =================*/
2062  #ifdef HAVE_WALK
2063  if (strcmp(sys_cmd, "MAltwalk1") == 0)
2064  {
2065  const short t[]={5,IDEAL_CMD,INT_CMD,INT_CMD,INTVEC_CMD,INTVEC_CMD};
2066  if (!iiCheckTypes(h,t,1)) return TRUE;
2067  if (((intvec*) h->next->next->next->Data())->length() != currRing->N &&
2068  ((intvec*) h->next->next->next->next->Data())->length()!=currRing->N)
2069  {
2070  Werror("system(\"MAltwalk1\" ...) intvecs not of length %d\n",
2071  currRing->N);
2072  return TRUE;
2073  }
2074  ideal arg1 = (ideal) h->Data();
2075  int arg2 = (int) ((long)(h->next->Data()));
2076  int arg3 = (int) ((long)(h->next->next->Data()));
2077  intvec* arg4 = (intvec*) h->next->next->next->Data();
2078  intvec* arg5 = (intvec*) h->next->next->next->next->Data();
2079  ideal result = (ideal) MAltwalk1(arg1, arg2, arg3, arg4, arg5);
2080  res->rtyp = IDEAL_CMD;
2081  res->data = result;
2082  return FALSE;
2083  }
2084  else
2085  #endif
2086  /*==================== MAltwalk1 =================*/
2087  #ifdef HAVE_WALK
2088  #ifdef MFWALK_ALT
2089  if (strcmp(sys_cmd, "Mfwalk_alt") == 0)
2090  {
2091  const short t[]={4,IDEAL_CMD,INTVEC_CMD,INTVEC_CMD,INT_CMD};
2092  if (!iiCheckTypes(h,t,1)) return TRUE;
2093  if (((intvec*) h->next->Data())->length() != currRing->N &&
2094  ((intvec*) h->next->next->Data())->length() != currRing->N )
2095  {
2096  Werror("system(\"Mfwalk\" ...) intvecs not of length %d\n",
2097  currRing->N);
2098  return TRUE;
2099  }
2100  ideal arg1 = (ideal) h->Data();
2101  intvec* arg2 = (intvec*) h->next->Data();
2102  intvec* arg3 = (intvec*) h->next->next->Data();
2103  int arg4 = (int) h->next->next->next->Data();
2104  ideal result = (ideal) Mfwalk_alt(arg1, arg2, arg3, arg4);
2105  res->rtyp = IDEAL_CMD;
2106  res->data = result;
2107  return FALSE;
2108  }
2109  else
2110  #endif
2111  #endif
2112  /*==================== Mfwalk =================*/
2113  #ifdef HAVE_WALK
2114  if (strcmp(sys_cmd, "Mfwalk") == 0)
2115  {
2116  const short t[]={5,IDEAL_CMD,INTVEC_CMD,INTVEC_CMD,INT_CMD,INT_CMD};
2117  if (!iiCheckTypes(h,t,1)) return TRUE;
2118  if (((intvec*) h->next->Data())->length() != currRing->N &&
2119  ((intvec*) h->next->next->Data())->length() != currRing->N )
2120  {
2121  Werror("system(\"Mfwalk\" ...) intvecs not of length %d\n",
2122  currRing->N);
2123  return TRUE;
2124  }
2125  ideal arg1 = (ideal) h->Data();
2126  intvec* arg2 = (intvec*) h->next->Data();
2127  intvec* arg3 = (intvec*) h->next->next->Data();
2128  int arg4 = (int)(long) h->next->next->next->Data();
2129  int arg5 = (int)(long) h->next->next->next->next->Data();
2130  ideal result = (ideal) Mfwalk(arg1, arg2, arg3, arg4, arg5);
2131  res->rtyp = IDEAL_CMD;
2132  res->data = result;
2133  return FALSE;
2134  }
2135  else
2136  #endif
2137  /*==================== Mfrwalk =================*/
2138  #ifdef HAVE_WALK
2139  if (strcmp(sys_cmd, "Mfrwalk") == 0)
2140  {
2141  const short t[]={6,IDEAL_CMD,INTVEC_CMD,INTVEC_CMD,INT_CMD,INT_CMD,INT_CMD};
2142  if (!iiCheckTypes(h,t,1)) return TRUE;
2143 /*
2144  if (((intvec*) h->next->Data())->length() != currRing->N &&
2145  ((intvec*) h->next->next->Data())->length() != currRing->N)
2146  {
2147  Werror("system(\"Mfrwalk\" ...) intvecs not of length %d\n",currRing->N);
2148  return TRUE;
2149  }
2150 */
2151  if((((intvec*) h->next->Data())->length() != currRing->N &&
2152  ((intvec*) h->next->next->Data())->length() != currRing->N ) &&
2153  (((intvec*) h->next->Data())->length() != (currRing->N)*(currRing->N) &&
2154  ((intvec*) h->next->next->Data())->length() != (currRing->N)*(currRing->N) ))
2155  {
2156  Werror("system(\"Mfrwalk\" ...) intvecs not of length %d or %d\n",
2157  currRing->N,(currRing->N)*(currRing->N));
2158  return TRUE;
2159  }
2160 
2161  ideal arg1 = (ideal) h->Data();
2162  intvec* arg2 = (intvec*) h->next->Data();
2163  intvec* arg3 = (intvec*) h->next->next->Data();
2164  int arg4 = (int)(long) h->next->next->next->Data();
2165  int arg5 = (int)(long) h->next->next->next->next->Data();
2166  int arg6 = (int)(long) h->next->next->next->next->next->Data();
2167  ideal result = (ideal) Mfrwalk(arg1, arg2, arg3, arg4, arg5, arg6);
2168  res->rtyp = IDEAL_CMD;
2169  res->data = result;
2170  return FALSE;
2171  }
2172  else
2173  /*==================== Mprwalk =================*/
2174  if (strcmp(sys_cmd, "Mprwalk") == 0)
2175  {
2176  const short t[]={9,IDEAL_CMD,INTVEC_CMD,INTVEC_CMD,INT_CMD,INT_CMD,INT_CMD,INT_CMD,INT_CMD,INT_CMD};
2177  if (!iiCheckTypes(h,t,1)) return TRUE;
2178  if((((intvec*) h->next->Data())->length() != currRing->N &&
2179  ((intvec*) h->next->next->Data())->length() != currRing->N ) &&
2180  (((intvec*) h->next->Data())->length() != (currRing->N)*(currRing->N) &&
2181  ((intvec*) h->next->next->Data())->length() != (currRing->N)*(currRing->N) ))
2182  {
2183  Werror("system(\"Mrwalk\" ...) intvecs not of length %d or %d\n",
2184  currRing->N,(currRing->N)*(currRing->N));
2185  return TRUE;
2186  }
2187  ideal arg1 = (ideal) h->Data();
2188  intvec* arg2 = (intvec*) h->next->Data();
2189  intvec* arg3 = (intvec*) h->next->next->Data();
2190  int arg4 = (int)(long) h->next->next->next->Data();
2191  int arg5 = (int)(long) h->next->next->next->next->Data();
2192  int arg6 = (int)(long) h->next->next->next->next->next->Data();
2193  int arg7 = (int)(long) h->next->next->next->next->next->next->Data();
2194  int arg8 = (int)(long) h->next->next->next->next->next->next->next->Data();
2195  int arg9 = (int)(long) h->next->next->next->next->next->next->next->next->Data();
2196  ideal result = (ideal) Mprwalk(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
2197  res->rtyp = IDEAL_CMD;
2198  res->data = result;
2199  return FALSE;
2200  }
2201  else
2202  #endif
2203  /*==================== TranMImprovwalk =================*/
2204  #ifdef HAVE_WALK
2205  #ifdef TRAN_Orig
2206  if (strcmp(sys_cmd, "TranMImprovwalk") == 0)
2207  {
2208  const short t[]={3,IDEAL_CMD,INTVEC_CMD,INTVEC_CMD};
2209  if (!iiCheckTypes(h,t,1)) return TRUE;
2210  if (((intvec*) h->next->Data())->length() != currRing->N &&
2211  ((intvec*) h->next->next->Data())->length() != currRing->N )
2212  {
2213  Werror("system(\"TranMImprovwalk\" ...) intvecs not of length %d\n",
2214  currRing->N);
2215  return TRUE;
2216  }
2217  ideal arg1 = (ideal) h->Data();
2218  intvec* arg2 = (intvec*) h->next->Data();
2219  intvec* arg3 = (intvec*) h->next->next->Data();
2220  ideal result = (ideal) TranMImprovwalk(arg1, arg2, arg3);
2221  res->rtyp = IDEAL_CMD;
2222  res->data = result;
2223  return FALSE;
2224  }
2225  else
2226  #endif
2227  #endif
2228  /*==================== MAltwalk2 =================*/
2229  #ifdef HAVE_WALK
2230  if (strcmp(sys_cmd, "MAltwalk2") == 0)
2231  {
2232  const short t[]={3,IDEAL_CMD,INTVEC_CMD,INTVEC_CMD};
2233  if (!iiCheckTypes(h,t,1)) return TRUE;
2234  if (((intvec*) h->next->Data())->length() != currRing->N &&
2235  ((intvec*) h->next->next->Data())->length() != currRing->N )
2236  {
2237  Werror("system(\"MAltwalk2\" ...) intvecs not of length %d\n",
2238  currRing->N);
2239  return TRUE;
2240  }
2241  ideal arg1 = (ideal) h->Data();
2242  intvec* arg2 = (intvec*) h->next->Data();
2243  intvec* arg3 = (intvec*) h->next->next->Data();
2244  ideal result = (ideal) MAltwalk2(arg1, arg2, arg3);
2245  res->rtyp = IDEAL_CMD;
2246  res->data = result;
2247  return FALSE;
2248  }
2249  else
2250  #endif
2251  /*==================== MAltwalk2 =================*/
2252  #ifdef HAVE_WALK
2253  if (strcmp(sys_cmd, "TranMImprovwalk") == 0)
2254  {
2255  const short t[]={4,IDEAL_CMD,INTVEC_CMD,INTVEC_CMD,INT_CMD};
2256  if (!iiCheckTypes(h,t,1)) return TRUE;
2257  if (((intvec*) h->next->Data())->length() != currRing->N &&
2258  ((intvec*) h->next->next->Data())->length() != currRing->N )
2259  {
2260  Werror("system(\"TranMImprovwalk\" ...) intvecs not of length %d\n",
2261  currRing->N);
2262  return TRUE;
2263  }
2264  ideal arg1 = (ideal) h->Data();
2265  intvec* arg2 = (intvec*) h->next->Data();
2266  intvec* arg3 = (intvec*) h->next->next->Data();
2267  int arg4 = (int) ((long)(h->next->next->next->Data()));
2268  ideal result = (ideal) TranMImprovwalk(arg1, arg2, arg3, arg4);
2269  res->rtyp = IDEAL_CMD;
2270  res->data = result;
2271  return FALSE;
2272  }
2273  else
2274  #endif
2275  /*==================== TranMrImprovwalk =================*/
2276  #if 0
2277  #ifdef HAVE_WALK
2278  if (strcmp(sys_cmd, "TranMrImprovwalk") == 0)
2279  {
2280  if (h == NULL || h->Typ() != IDEAL_CMD ||
2281  h->next == NULL || h->next->Typ() != INTVEC_CMD ||
2282  h->next->next == NULL || h->next->next->Typ() != INTVEC_CMD ||
2283  h->next->next->next == NULL || h->next->next->next->Typ() != INT_CMD ||
2284  h->next->next->next == NULL || h->next->next->next->next->Typ() != INT_CMD ||
2285  h->next->next->next == NULL || h->next->next->next->next->next->Typ() != INT_CMD)
2286  {
2287  WerrorS("system(\"TranMrImprovwalk\", ideal, intvec, intvec) expected");
2288  return TRUE;
2289  }
2290  if (((intvec*) h->next->Data())->length() != currRing->N &&
2291  ((intvec*) h->next->next->Data())->length() != currRing->N )
2292  {
2293  Werror("system(\"TranMrImprovwalk\" ...) intvecs not of length %d\n", currRing->N);
2294  return TRUE;
2295  }
2296  ideal arg1 = (ideal) h->Data();
2297  intvec* arg2 = (intvec*) h->next->Data();
2298  intvec* arg3 = (intvec*) h->next->next->Data();
2299  int arg4 = (int)(long) h->next->next->next->Data();
2300  int arg5 = (int)(long) h->next->next->next->next->Data();
2301  int arg6 = (int)(long) h->next->next->next->next->next->Data();
2302  ideal result = (ideal) TranMrImprovwalk(arg1, arg2, arg3, arg4, arg5, arg6);
2303  res->rtyp = IDEAL_CMD;
2304  res->data = result;
2305  return FALSE;
2306  }
2307  else
2308  #endif
2309  #endif
2310  /*================= Extended system call ========================*/
2311  {
2312  #ifndef MAKE_DISTRIBUTION
2313  return(jjEXTENDED_SYSTEM(res, args));
2314  #else
2315  Werror( "system(\"%s\",...) %s", sys_cmd, feNotImplemented );
2316  #endif
2317  }
2318  } /* typ==string */
2319  return TRUE;
2320 }
2321 
2322 
2323 #ifdef HAVE_EXTENDED_SYSTEM
2324  // You can put your own system calls here
2325 # include <kernel/fglm/fglm.h>
2326 # ifdef HAVE_NEWTON
2327 # include <hc_newton.h>
2328 # endif
2329 # include <polys/mod_raw.h>
2330 # include <polys/monomials/ring.h>
2331 # include <kernel/GBEngine/shiftgb.h>
2332 # include <kernel/GBEngine/kutil.h>
2333 
2335 {
2336  if(h->Typ() == STRING_CMD)
2337  {
2338  char *sys_cmd=(char *)(h->Data());
2339  h=h->next;
2340  /*==================== test syz strat =================*/
2341  if (strcmp(sys_cmd, "syz") == 0)
2342  {
2343  if ((h!=NULL) && (h->Typ()==STRING_CMD))
2344  {
2345  const char *s=(const char *)h->Data();
2346  if (strcmp(s,"posInT_EcartFDegpLength")==0)
2348  else if (strcmp(s,"posInT_FDegpLength")==0)
2350  else if (strcmp(s,"posInT_pLength")==0)
2352  else if (strcmp(s,"posInT0")==0)
2354  else if (strcmp(s,"posInT1")==0)
2356  else if (strcmp(s,"posInT2")==0)
2358  else if (strcmp(s,"posInT11")==0)
2360  else if (strcmp(s,"posInT110")==0)
2362  else if (strcmp(s,"posInT13")==0)
2364  else if (strcmp(s,"posInT15")==0)
2366  else if (strcmp(s,"posInT17")==0)
2368  else if (strcmp(s,"posInT17_c")==0)
2370  else if (strcmp(s,"posInT19")==0)
2372  else PrintS("valid posInT:0,1,2,11,110,13,15,17,17_c,19,_EcartFDegpLength,_FDegpLength,_pLength,_EcartpLength\n");
2373  }
2374  else
2375  {
2376  test_PosInT=NULL;
2377  test_PosInL=NULL;
2378  }
2379  si_opt_2|=Sy_bit(23);
2380  return FALSE;
2381  }
2382  else
2383  /*==================== locNF ======================================*/
2384  if(strcmp(sys_cmd,"locNF")==0)
2385  {
2386  const short t[]={4,VECTOR_CMD,MODUL_CMD,INT_CMD,INTVEC_CMD};
2387  if (iiCheckTypes(h,t,1))
2388  {
2389  poly f=(poly)h->Data();
2390  h=h->next;
2391  ideal m=(ideal)h->Data();
2392  assumeStdFlag(h);
2393  h=h->next;
2394  int n=(int)((long)h->Data());
2395  h=h->next;
2396  intvec *v=(intvec *)h->Data();
2397 
2398  /* == now the work starts == */
2399 
2400  short * iv=iv2array(v, currRing);
2401  poly r=0;
2402  poly hp=ppJetW(f,n,iv);
2403  int s=MATCOLS(m);
2404  int j=0;
2405  matrix T=mp_InitI(s,1,0, currRing);
2406 
2407  while (hp != NULL)
2408  {
2409  if (pDivisibleBy(m->m[j],hp))
2410  {
2411  if (MATELEM(T,j+1,1)==0)
2412  {
2413  MATELEM(T,j+1,1)=pDivideM(pHead(hp),pHead(m->m[j]));
2414  }
2415  else
2416  {
2417  pAdd(MATELEM(T,j+1,1),pDivideM(pHead(hp),pHead(m->m[j])));
2418  }
2419  hp=ppJetW(ksOldSpolyRed(m->m[j],hp,0),n,iv);
2420  j=0;
2421  }
2422  else
2423  {
2424  if (j==s-1)
2425  {
2426  r=pAdd(r,pHead(hp));
2427  hp=pLmDeleteAndNext(hp); /* hp=pSub(hp,pHead(hp));*/
2428  j=0;
2429  }
2430  else
2431  {
2432  j++;
2433  }
2434  }
2435  }
2436 
2439  for (int k=1;k<=MATROWS(Temp);k++)
2440  {
2441  MATELEM(R,k,1)=MATELEM(Temp,k,1);
2442  }
2443 
2445  L->Init(2);
2446  L->m[0].rtyp=MATRIX_CMD; L->m[0].data=(void *)R;
2447  L->m[1].rtyp=MATRIX_CMD; L->m[1].data=(void *)T;
2448  res->data=L;
2449  res->rtyp=LIST_CMD;
2450  // iv aufraeumen
2451  omFree(iv);
2452  return FALSE;
2453  }
2454  else
2455  return TRUE;
2456  }
2457  else
2458  /*==================== poly debug ==================================*/
2459  if(strcmp(sys_cmd,"p")==0)
2460  {
2461 # ifdef RDEBUG
2462  p_DebugPrint((poly)h->Data(), currRing);
2463 # else
2464  Warn("Sorry: not available for release build!");
2465 # endif
2466  return FALSE;
2467  }
2468  else
2469  /*==================== setsyzcomp ==================================*/
2470  if(strcmp(sys_cmd,"setsyzcomp")==0)
2471  {
2472  if ((h!=NULL) && (h->Typ()==INT_CMD))
2473  {
2474  int k = (int)(long)h->Data();
2475  if ( currRing->order[0] == ringorder_s )
2476  {
2477  rSetSyzComp(k, currRing);
2478  }
2479  }
2480  }
2481  /*==================== ring debug ==================================*/
2482  if(strcmp(sys_cmd,"r")==0)
2483  {
2484 # ifdef RDEBUG
2485  rDebugPrint((ring)h->Data());
2486 # else
2487  Warn("Sorry: not available for release build!");
2488 # endif
2489  return FALSE;
2490  }
2491  else
2492  /*==================== changeRing ========================*/
2493  /* The following code changes the names of the variables in the
2494  current ring to "x1", "x2", ..., "xN", where N is the number
2495  of variables in the current ring.
2496  The purpose of this rewriting is to eliminate indexed variables,
2497  as they may cause problems when generating scripts for Magma,
2498  Maple, or Macaulay2. */
2499  if(strcmp(sys_cmd,"changeRing")==0)
2500  {
2501  int varN = currRing->N;
2502  char h[12];
2503  for (int i = 1; i <= varN; i++)
2504  {
2505  omFree(currRing->names[i - 1]);
2506  sprintf(h, "x%d", i);
2507  currRing->names[i - 1] = omStrDup(h);
2508  }
2510  res->rtyp = INT_CMD;
2511  res->data = (void*)0L;
2512  return FALSE;
2513  }
2514  else
2515  /*==================== mtrack ==================================*/
2516  if(strcmp(sys_cmd,"mtrack")==0)
2517  {
2518  #ifdef OM_TRACK
2519  om_Opts.MarkAsStatic = 1;
2520  FILE *fd = NULL;
2521  int max = 5;
2522  while (h != NULL)
2523  {
2524  omMarkAsStaticAddr(h);
2525  if (fd == NULL && h->Typ()==STRING_CMD)
2526  {
2527  fd = fopen((char*) h->Data(), "w");
2528  if (fd == NULL)
2529  Warn("Can not open %s for writing og mtrack. Using stdout"); // %s ???
2530  }
2531  if (h->Typ() == INT_CMD)
2532  {
2533  max = (int)(long)h->Data();
2534  }
2535  h = h->Next();
2536  }
2537  omPrintUsedTrackAddrs((fd == NULL ? stdout : fd), max);
2538  if (fd != NULL) fclose(fd);
2539  om_Opts.MarkAsStatic = 0;
2540  return FALSE;
2541  #endif
2542  }
2543  /*==================== mtrack_all ==================================*/
2544  if(strcmp(sys_cmd,"mtrack_all")==0)
2545  {
2546  #ifdef OM_TRACK
2547  om_Opts.MarkAsStatic = 1;
2548  FILE *fd = NULL;
2549  if ((h!=NULL) &&(h->Typ()==STRING_CMD))
2550  {
2551  fd = fopen((char*) h->Data(), "w");
2552  if (fd == NULL)
2553  Warn("Can not open %s for writing og mtrack. Using stdout");
2554  omMarkAsStaticAddr(h);
2555  }
2556  // OB: TBC print to fd
2557  omPrintUsedAddrs((fd == NULL ? stdout : fd), 5);
2558  if (fd != NULL) fclose(fd);
2559  om_Opts.MarkAsStatic = 0;
2560  return FALSE;
2561  #endif
2562  }
2563  else
2564  /*==================== backtrace ==================================*/
2565  #ifndef OM_NDEBUG
2566  if(strcmp(sys_cmd,"backtrace")==0)
2567  {
2568  omPrintCurrentBackTrace(stdout);
2569  return FALSE;
2570  }
2571  else
2572  #endif
2573 
2574 #if !defined(OM_NDEBUG)
2575  /*==================== omMemoryTest ==================================*/
2576  if (strcmp(sys_cmd,"omMemoryTest")==0)
2577  {
2578 
2579 #ifdef OM_STATS_H
2580  PrintS("\n[om_Info]: \n");
2581  omUpdateInfo();
2582 #define OM_PRINT(name) Print(" %-22s : %10ld \n", #name, om_Info . name)
2583  OM_PRINT(MaxBytesSystem);
2584  OM_PRINT(CurrentBytesSystem);
2585  OM_PRINT(MaxBytesSbrk);
2586  OM_PRINT(CurrentBytesSbrk);
2587  OM_PRINT(MaxBytesMmap);
2588  OM_PRINT(CurrentBytesMmap);
2589  OM_PRINT(UsedBytes);
2590  OM_PRINT(AvailBytes);
2591  OM_PRINT(UsedBytesMalloc);
2592  OM_PRINT(AvailBytesMalloc);
2593  OM_PRINT(MaxBytesFromMalloc);
2594  OM_PRINT(CurrentBytesFromMalloc);
2595  OM_PRINT(MaxBytesFromValloc);
2596  OM_PRINT(CurrentBytesFromValloc);
2597  OM_PRINT(UsedBytesFromValloc);
2598  OM_PRINT(AvailBytesFromValloc);
2599  OM_PRINT(MaxPages);
2600  OM_PRINT(UsedPages);
2601  OM_PRINT(AvailPages);
2602  OM_PRINT(MaxRegionsAlloc);
2603  OM_PRINT(CurrentRegionsAlloc);
2604 #undef OM_PRINT
2605 #endif
2606 
2607 #ifdef OM_OPTS_H
2608  PrintS("\n[om_Opts]: \n");
2609 #define OM_PRINT(format, name) Print(" %-22s : %10" format"\n", #name, om_Opts . name)
2610  OM_PRINT("d", MinTrack);
2611  OM_PRINT("d", MinCheck);
2612  OM_PRINT("d", MaxTrack);
2613  OM_PRINT("d", MaxCheck);
2614  OM_PRINT("d", Keep);
2615  OM_PRINT("d", HowToReportErrors);
2616  OM_PRINT("d", MarkAsStatic);
2617  OM_PRINT("u", PagesPerRegion);
2618  OM_PRINT("p", OutOfMemoryFunc);
2619  OM_PRINT("p", MemoryLowFunc);
2620  OM_PRINT("p", ErrorHook);
2621 #undef OM_PRINT
2622 #endif
2623 
2624 #ifdef OM_ERROR_H
2625  Print("\n\n[om_ErrorStatus] : '%s' (%s)\n",
2628  Print("[om_InternalErrorStatus]: '%s' (%s)\n",
2631 
2632 #endif
2633 
2634 // omTestMemory(1);
2635 // omtTestErrors();
2636  return FALSE;
2637  }
2638  else
2639 #endif
2640  /*==================== pDivStat =============================*/
2641  #if defined(PDEBUG) || defined(PDIV_DEBUG)
2642  if(strcmp(sys_cmd,"pDivStat")==0)
2643  {
2644  extern void pPrintDivisbleByStat();
2646  return FALSE;
2647  }
2648  else
2649  #endif
2650  /*==================== red =============================*/
2651  #if 0
2652  if(strcmp(sys_cmd,"red")==0)
2653  {
2654  if ((h!=NULL) &&(h->Typ()==IDEAL_CMD))
2655  {
2656  res->rtyp=IDEAL_CMD;
2657  res->data=(void *)kStdred((ideal)h->Data(),NULL,testHomog,NULL);
2658  setFlag(res,FLAG_STD);
2659  return FALSE;
2660  }
2661  else
2662  WerrorS("ideal expected");
2663  }
2664  else
2665  #endif
2666  /*==================== fastcomb =============================*/
2667  if(strcmp(sys_cmd,"fastcomb")==0)
2668  {
2669  if ((h!=NULL) &&(h->Typ()==IDEAL_CMD))
2670  {
2671  if (h->next!=NULL)
2672  {
2673  if (h->next->Typ()!=POLY_CMD)
2674  {
2675  Warn("Wrong types for poly= comb(ideal,poly)");
2676  }
2677  }
2678  res->rtyp=POLY_CMD;
2679  res->data=(void *) fglmLinearCombination(
2680  (ideal)h->Data(),(poly)h->next->Data());
2681  return FALSE;
2682  }
2683  else
2684  WerrorS("ideal expected");
2685  }
2686  else
2687  /*==================== comb =============================*/
2688  if(strcmp(sys_cmd,"comb")==0)
2689  {
2690  if ((h!=NULL) &&(h->Typ()==IDEAL_CMD))
2691  {
2692  if (h->next!=NULL)
2693  {
2694  if (h->next->Typ()!=POLY_CMD)
2695  {
2696  Warn("Wrong types for poly= comb(ideal,poly)");
2697  }
2698  }
2699  res->rtyp=POLY_CMD;
2700  res->data=(void *)fglmNewLinearCombination(
2701  (ideal)h->Data(),(poly)h->next->Data());
2702  return FALSE;
2703  }
2704  else
2705  WerrorS("ideal expected");
2706  }
2707  else
2708  #if 0 /* debug only */
2709  /*==================== listall ===================================*/
2710  if(strcmp(sys_cmd,"listall")==0)
2711  {
2712  void listall(int showproc);
2713  int showproc=0;
2714  if ((h!=NULL) && (h->Typ()==INT_CMD)) showproc=(int)((long)h->Data());
2715  listall(showproc);
2716  return FALSE;
2717  }
2718  else
2719  #endif
2720  #if 0 /* debug only */
2721  /*==================== proclist =================================*/
2722  if(strcmp(sys_cmd,"proclist")==0)
2723  {
2724  void piShowProcList();
2725  piShowProcList();
2726  return FALSE;
2727  }
2728  else
2729  #endif
2730  /* ==================== newton ================================*/
2731  #ifdef HAVE_NEWTON
2732  if(strcmp(sys_cmd,"newton")==0)
2733  {
2734  if ((h->Typ()!=POLY_CMD)
2735  || (h->next->Typ()!=INT_CMD)
2736  || (h->next->next->Typ()!=INT_CMD))
2737  {
2738  WerrorS("system(\"newton\",<poly>,<int>,<int>) expected");
2739  return TRUE;
2740  }
2741  poly p=(poly)(h->Data());
2742  int l=pLength(p);
2743  short *points=(short *)omAlloc(currRing->N*l*sizeof(short));
2744  int i,j,k;
2745  k=0;
2746  poly pp=p;
2747  for (i=0;pp!=NULL;i++)
2748  {
2749  for(j=1;j<=currRing->N;j++)
2750  {
2751  points[k]=pGetExp(pp,j);
2752  k++;
2753  }
2754  pIter(pp);
2755  }
2756  hc_ERG r=hc_KOENIG(currRing->N, // dimension
2757  l, // number of points
2758  (short*) points, // points: x_1, y_1,z_1, x_2,y_2,z2,...
2759  currRing->OrdSgn==-1,
2760  (int) (h->next->Data()), // 1: Milnor, 0: Newton
2761  (int) (h->next->next->Data()) // debug
2762  );
2763  //----<>---Output-----------------------
2764 
2765 
2766  // PrintS("Bin jetzt in extra.cc bei der Auswertung.\n"); // **********
2767 
2768 
2770  L->Init(6);
2771  L->m[0].rtyp=STRING_CMD; // newtonnumber;
2772  L->m[0].data=(void *)omStrDup(r.nZahl);
2773  L->m[1].rtyp=INT_CMD;
2774  L->m[1].data=(void *)(long)r.achse; // flag for unoccupied axes
2775  L->m[2].rtyp=INT_CMD;
2776  L->m[2].data=(void *)(long)r.deg; // #degenerations
2777  if ( r.deg != 0) // only if degenerations exist
2778  {
2779  L->m[3].rtyp=INT_CMD;
2780  L->m[3].data=(void *)(long)r.anz_punkte; // #points
2781  //---<>--number of points------
2782  int anz = r.anz_punkte; // number of points
2783  int dim = (currRing->N); // dimension
2784  intvec* v = new intvec( anz*dim );
2785  for (i=0; i<anz*dim; i++) // copy points
2786  (*v)[i] = r.pu[i];
2787  L->m[4].rtyp=INTVEC_CMD;
2788  L->m[4].data=(void *)v;
2789  //---<>--degenerations---------
2790  int deg = r.deg; // number of points
2791  intvec* w = new intvec( r.speicher ); // necessary memory
2792  i=0; // start copying
2793  do
2794  {
2795  (*w)[i] = r.deg_tab[i];
2796  i++;
2797  }
2798  while (r.deg_tab[i-1] != -2); // mark for end of list
2799  L->m[5].rtyp=INTVEC_CMD;
2800  L->m[5].data=(void *)w;
2801  }
2802  else
2803  {
2804  L->m[3].rtyp=INT_CMD; L->m[3].data=(char *)0;
2805  L->m[4].rtyp=DEF_CMD;
2806  L->m[5].rtyp=DEF_CMD;
2807  }
2808 
2809  res->data=(void *)L;
2810  res->rtyp=LIST_CMD;
2811  // free all pointer in r:
2812  delete[] r.nZahl;
2813  delete[] r.pu;
2814  delete[] r.deg_tab; // Ist das ein Problem??
2815 
2816  omFreeSize((ADDRESS)points,currRing->N*l*sizeof(short));
2817  return FALSE;
2818  }
2819  else
2820  #endif
2821  /*==== connection to Sebastian Jambor's code ======*/
2822  /* This code connects Sebastian Jambor's code for
2823  computing the minimal polynomial of an (n x n) matrix
2824  with entries in F_p to SINGULAR. Two conversion methods
2825  are needed; see further up in this file:
2826  (1) conversion of a matrix with long entries to
2827  a SINGULAR matrix with number entries, where
2828  the numbers are coefficients in currRing;
2829  (2) conversion of an array of longs (encoding the
2830  coefficients of the minimal polynomial) to a
2831  SINGULAR poly living in currRing. */
2832  if (strcmp(sys_cmd, "minpoly") == 0)
2833  {
2834  if ((h == NULL) || (h->Typ() != MATRIX_CMD) || h->next != NULL)
2835  {
2836  Werror("expected exactly one argument: %s",
2837  "a square matrix with number entries");
2838  return TRUE;
2839  }
2840  else
2841  {
2842  matrix m = (matrix)h->Data();
2843  int n = m->rows();
2844  unsigned long p = (unsigned long)n_GetChar(currRing->cf);
2845  if (n != m->cols())
2846  {
2847  WerrorS("expected exactly one argument: "
2848  "a square matrix with number entries");
2849  return TRUE;
2850  }
2851  unsigned long** ml = singularMatrixToLongMatrix(m);
2852  unsigned long* polyCoeffs = computeMinimalPolynomial(ml, n, p);
2853  poly theMinPoly = longCoeffsToSingularPoly(polyCoeffs, n);
2854  res->rtyp = POLY_CMD;
2855  res->data = (void *)theMinPoly;
2856  for (int i = 0; i < n; i++) delete[] ml[i];
2857  delete[] ml;
2858  delete[] polyCoeffs;
2859  return FALSE;
2860  }
2861  }
2862  else
2863  /*==================== sdb_flags =================*/
2864  #ifdef HAVE_SDB
2865  if (strcmp(sys_cmd, "sdb_flags") == 0)
2866  {
2867  if ((h!=NULL) && (h->Typ()==INT_CMD))
2868  {
2869  sdb_flags=(int)((long)h->Data());
2870  }
2871  else
2872  {
2873  WerrorS("system(\"sdb_flags\",`int`) expected");
2874  return TRUE;
2875  }
2876  return FALSE;
2877  }
2878  else
2879  #endif
2880  /*==================== sdb_edit =================*/
2881  #ifdef HAVE_SDB
2882  if (strcmp(sys_cmd, "sdb_edit") == 0)
2883  {
2884  if ((h!=NULL) && (h->Typ()==PROC_CMD))
2885  {
2886  procinfov p=(procinfov)h->Data();
2887  sdb_edit(p);
2888  }
2889  else
2890  {
2891  WerrorS("system(\"sdb_edit\",`proc`) expected");
2892  return TRUE;
2893  }
2894  return FALSE;
2895  }
2896  else
2897  #endif
2898  /*==================== GF =================*/
2899  #if 0 // for testing only
2900  if (strcmp(sys_cmd, "GF") == 0)
2901  {
2902  if ((h!=NULL) && (h->Typ()==POLY_CMD))
2903  {
2904  int c=rChar(currRing);
2905  setCharacteristic( c,nfMinPoly[0], currRing->parameter[0][0] );
2906  CanonicalForm F( convSingGFFactoryGF( (poly)h->Data(), currRing ) );
2907  res->rtyp=POLY_CMD;
2908  res->data=convFactoryGFSingGF( F, currRing );
2909  return FALSE;
2910  }
2911  else { WerrorS("wrong typ"); return TRUE;}
2912  }
2913  else
2914  #endif
2915  /*==================== SVD =================*/
2916  #ifdef HAVE_SVD
2917  if (strcmp(sys_cmd, "svd") == 0)
2918  {
2919  extern lists testsvd(matrix M);
2920  res->rtyp=LIST_CMD;
2921  res->data=(char*)(testsvd((matrix)h->Data()));
2922  eturn FALSE;
2923  }
2924  else
2925  #endif
2926 
2927 
2928  /*==================== DLL =================*/
2929  #ifdef __CYGWIN__
2930  #ifdef HAVE_DL
2931  /* testing the DLL functionality under Win32 */
2932  if (strcmp(sys_cmd, "DLL") == 0)
2933  {
2934  typedef void (*Void_Func)();
2935  typedef int (*Int_Func)(int);
2936  void *hh=dynl_open("WinDllTest.dll");
2937  if ((h!=NULL) && (h->Typ()==INT_CMD))
2938  {
2939  int (*f)(int);
2940  if (hh!=NULL)
2941  {
2942  int (*f)(int);
2943  f=(Int_Func)dynl_sym(hh,"PlusDll");
2944  int i=10;
2945  if (f!=NULL) printf("%d\n",f(i));
2946  else PrintS("cannot find PlusDll\n");
2947  }
2948  }
2949  else
2950  {
2951  void (*f)();
2952  f= (Void_Func)dynl_sym(hh,"TestDll");
2953  if (f!=NULL) f();
2954  else PrintS("cannot find TestDll\n");
2955  }
2956  return FALSE;
2957  }
2958  else
2959  #endif
2960  #endif
2961  #ifdef HAVE_RING2TOM
2962  /*==================== ring-GB ==================================*/
2963  if (strcmp(sys_cmd, "findZeroPoly")==0)
2964  {
2965  ring r = currRing;
2966  poly f = (poly) h->Data();
2967  res->rtyp=POLY_CMD;
2968  res->data=(poly) kFindZeroPoly(f, r, r);
2969  return(FALSE);
2970  }
2971  else
2972  /*==================== Creating zero polynomials =================*/
2973  #ifdef HAVE_VANIDEAL
2974  if (strcmp(sys_cmd, "createG0")==0)
2975  {
2976  /* long exp[50];
2977  int N = 0;
2978  while (h != NULL)
2979  {
2980  N += 1;
2981  exp[N] = (long) h->Data();
2982  // if (exp[i] % 2 != 0) exp[i] -= 1;
2983  h = h->next;
2984  }
2985  for (int k = 1; N + k <= currRing->N; k++) exp[k] = 0;
2986 
2987  poly t_p;
2988  res->rtyp=POLY_CMD;
2989  res->data= (poly) kCreateZeroPoly(exp, -1, &t_p, currRing, currRing);
2990  return(FALSE); */
2991 
2992  res->rtyp = IDEAL_CMD;
2993  res->data = (ideal) createG0();
2994  return(FALSE);
2995  }
2996  else
2997  #endif
2998  /*==================== redNF_ring =================*/
2999  if (strcmp(sys_cmd, "redNF_ring")==0)
3000  {
3001  ring r = currRing;
3002  poly f = (poly) h->Data();
3003  h = h->next;
3004  ideal G = (ideal) h->Data();
3005  res->rtyp=POLY_CMD;
3006  res->data=(poly) ringRedNF(f, G, r);
3007  return(FALSE);
3008  }
3009  else
3010  #endif
3011  /*==================== Roune Hilb =================*/
3012  if (strcmp(sys_cmd, "hilbroune") == 0)
3013  {
3014  ideal I;
3015  if ((h!=NULL) && (h->Typ()==IDEAL_CMD))
3016  {
3017  I=(ideal)h->CopyD();
3018  slicehilb(I);
3019  }
3020  else return TRUE;
3021  return FALSE;
3022  }
3023  else
3024  /*==================== F5 Implementation =================*/
3025  #ifdef HAVE_F5
3026  if (strcmp(sys_cmd, "f5")==0)
3027  {
3028  if (h->Typ()!=IDEAL_CMD)
3029  {
3030  WerrorS("ideal expected");
3031  return TRUE;
3032  }
3033 
3034  ring r = currRing;
3035  ideal G = (ideal) h->Data();
3036  h = h->next;
3037  int opt;
3038  if(h != NULL) {
3039  opt = (int) (long) h->Data();
3040  }
3041  else {
3042  opt = 2;
3043  }
3044  h = h->next;
3045  int plus;
3046  if(h != NULL) {
3047  plus = (int) (long) h->Data();
3048  }
3049  else {
3050  plus = 0;
3051  }
3052  h = h->next;
3053  int termination;
3054  if(h != NULL) {
3055  termination = (int) (long) h->Data();
3056  }
3057  else {
3058  termination = 0;
3059  }
3060  res->rtyp=IDEAL_CMD;
3061  res->data=(ideal) F5main(G,r,opt,plus,termination);
3062  return FALSE;
3063  }
3064  else
3065  #endif
3066  /*==================== Testing groebner basis =================*/
3067  #ifdef HAVE_RINGS
3068  if (strcmp(sys_cmd, "NF_ring")==0)
3069  {
3070  ring r = currRing;
3071  poly f = (poly) h->Data();
3072  h = h->next;
3073  ideal G = (ideal) h->Data();
3074  res->rtyp=POLY_CMD;
3075  res->data=(poly) ringNF(f, G, r);
3076  return(FALSE);
3077  }
3078  else
3079  if (strcmp(sys_cmd, "spoly")==0)
3080  {
3081  poly f = pCopy((poly) h->Data());
3082  h = h->next;
3083  poly g = pCopy((poly) h->Data());
3084 
3085  res->rtyp=POLY_CMD;
3086  res->data=(poly) plain_spoly(f,g);
3087  return(FALSE);
3088  }
3089  else
3090  if (strcmp(sys_cmd, "testGB")==0)
3091  {
3092  ideal I = (ideal) h->Data();
3093  h = h->next;
3094  ideal GI = (ideal) h->Data();
3095  res->rtyp = INT_CMD;
3096  res->data = (void *)(long) testGB(I, GI);
3097  return(FALSE);
3098  }
3099  else
3100  #endif
3101  /*==================== sca:AltVar ==================================*/
3102  #ifdef HAVE_PLURAL
3103  if ( (strcmp(sys_cmd, "AltVarStart") == 0) || (strcmp(sys_cmd, "AltVarEnd") == 0) )
3104  {
3105  ring r = currRing;
3106 
3107  if((h!=NULL) && (h->Typ()==RING_CMD)) r = (ring)h->Data(); else
3108  {
3109  WerrorS("`system(\"AltVarStart/End\"[,<ring>])` expected");
3110  return TRUE;
3111  }
3112 
3113  res->rtyp=INT_CMD;
3114 
3115  if (rIsSCA(r))
3116  {
3117  if(strcmp(sys_cmd, "AltVarStart") == 0)
3118  res->data = (void*)(long)scaFirstAltVar(r);
3119  else
3120  res->data = (void*)(long)scaLastAltVar(r);
3121  return FALSE;
3122  }
3123 
3124  WerrorS("`system(\"AltVarStart/End\",<ring>) requires a SCA ring");
3125  return TRUE;
3126  }
3127  else
3128  #endif
3129  /*==================== RatNF, noncomm rational coeffs =================*/
3130  #ifdef HAVE_RATGRING
3131  if (strcmp(sys_cmd, "intratNF") == 0)
3132  {
3133  poly p;
3134  poly *q;
3135  ideal I;
3136  int is, k, id;
3137  if ((h!=NULL) && (h->Typ()==POLY_CMD))
3138  {
3139  p=(poly)h->CopyD();
3140  h=h->next;
3141  // PrintS("poly is done\n");
3142  }
3143  else return TRUE;
3144  if ((h!=NULL) && (h->Typ()==IDEAL_CMD))
3145  {
3146  I=(ideal)h->CopyD();
3147  q = I->m;
3148  h=h->next;
3149  // PrintS("ideal is done\n");
3150  }
3151  else return TRUE;
3152  if ((h!=NULL) && (h->Typ()==INT_CMD))
3153  {
3154  is=(int)((long)(h->Data()));
3155  // res->rtyp=INT_CMD;
3156  // PrintS("int is done\n");
3157  // res->rtyp=IDEAL_CMD;
3158  if (rIsPluralRing(currRing))
3159  {
3160  id = IDELEMS(I);
3161  int *pl=(int*)omAlloc0(IDELEMS(I)*sizeof(int));
3162  for(k=0; k < id; k++)
3163  {
3164  pl[k] = pLength(I->m[k]);
3165  }
3166  PrintS("starting redRat\n");
3167  //res->data = (char *)
3168  redRat(&p, q, pl, (int)IDELEMS(I),is,currRing);
3169  res->data=p;
3170  res->rtyp=POLY_CMD;
3171  // res->data = ncGCD(p,q,currRing);
3172  }
3173  else
3174  {
3175  res->rtyp=POLY_CMD;
3176  res->data=p;
3177  }
3178  }
3179  else return TRUE;
3180  return FALSE;
3181  }
3182  else
3183  /*==================== RatNF, noncomm rational coeffs =================*/
3184  if (strcmp(sys_cmd, "ratNF") == 0)
3185  {
3186  poly p,q;
3187  int is, htype;
3188  if ((h!=NULL) && ( (h->Typ()==POLY_CMD) || (h->Typ()==VECTOR_CMD) ) )
3189  {
3190  p=(poly)h->CopyD();
3191  h=h->next;
3192  htype = h->Typ();
3193  }
3194  else return TRUE;
3195  if ((h!=NULL) && ( (h->Typ()==POLY_CMD) || (h->Typ()==VECTOR_CMD) ) )
3196  {
3197  q=(poly)h->CopyD();
3198  h=h->next;
3199  }
3200  else return TRUE;
3201  if ((h!=NULL) && (h->Typ()==INT_CMD))
3202  {
3203  is=(int)((long)(h->Data()));
3204  res->rtyp=htype;
3205  // res->rtyp=IDEAL_CMD;
3206  if (rIsPluralRing(currRing))
3207  {
3208  res->data = nc_rat_ReduceSpolyNew(q,p,is, currRing);
3209  // res->data = ncGCD(p,q,currRing);
3210  }
3211  else res->data=p;
3212  }
3213  else return TRUE;
3214  return FALSE;
3215  }
3216  else
3217  /*==================== RatSpoly, noncomm rational coeffs =================*/
3218  if (strcmp(sys_cmd, "ratSpoly") == 0)
3219  {
3220  poly p,q;
3221  int is;
3222  if ((h!=NULL) && (h->Typ()==POLY_CMD))
3223  {
3224  p=(poly)h->CopyD();
3225  h=h->next;
3226  }
3227  else return TRUE;
3228  if ((h!=NULL) && (h->Typ()==POLY_CMD))
3229  {
3230  q=(poly)h->CopyD();
3231  h=h->next;
3232  }
3233  else return TRUE;
3234  if ((h!=NULL) && (h->Typ()==INT_CMD))
3235  {
3236  is=(int)((long)(h->Data()));
3237  res->rtyp=POLY_CMD;
3238  // res->rtyp=IDEAL_CMD;
3239  if (rIsPluralRing(currRing))
3240  {
3241  res->data = nc_rat_CreateSpoly(p,q,is,currRing);
3242  // res->data = ncGCD(p,q,currRing);
3243  }
3244  else res->data=p;
3245  }
3246  else return TRUE;
3247  return FALSE;
3248  }
3249  else
3250  #endif // HAVE_RATGRING
3251  /*==================== Rat def =================*/
3252  if (strcmp(sys_cmd, "ratVar") == 0)
3253  {
3254  int start,end;
3255  if ((h!=NULL) && (h->Typ()==POLY_CMD))
3256  {
3257  start=pIsPurePower((poly)h->Data());
3258  h=h->next;
3259  }
3260  else return TRUE;
3261  if ((h!=NULL) && (h->Typ()==POLY_CMD))
3262  {
3263  end=pIsPurePower((poly)h->Data());
3264  h=h->next;
3265  }
3266  else return TRUE;
3267  currRing->real_var_start=start;
3268  currRing->real_var_end=end;
3269  return (start==0)||(end==0)||(start>end);
3270  }
3271  else
3272  /*==================== t-rep-GB ==================================*/
3273  if (strcmp(sys_cmd, "unifastmult")==0)
3274  {
3275  poly f = (poly)h->Data();
3276  h=h->next;
3277  poly g=(poly)h->Data();
3278  res->rtyp=POLY_CMD;
3279  res->data=unifastmult(f,g,currRing);
3280  return(FALSE);
3281  }
3282  else
3283  if (strcmp(sys_cmd, "multifastmult")==0)
3284  {
3285  poly f = (poly)h->Data();
3286  h=h->next;
3287  poly g=(poly)h->Data();
3288  res->rtyp=POLY_CMD;
3289  res->data=multifastmult(f,g,currRing);
3290  return(FALSE);
3291  }
3292  else
3293  if (strcmp(sys_cmd, "mults")==0)
3294  {
3295  res->rtyp=INT_CMD ;
3296  res->data=(void*)(long) Mults();
3297  return(FALSE);
3298  }
3299  else
3300  if (strcmp(sys_cmd, "fastpower")==0)
3301  {
3302  ring r = currRing;
3303  poly f = (poly)h->Data();
3304  h=h->next;
3305  int n=(int)((long)h->Data());
3306  res->rtyp=POLY_CMD ;
3307  res->data=(void*) pFastPower(f,n,r);
3308  return(FALSE);
3309  }
3310  else
3311  if (strcmp(sys_cmd, "normalpower")==0)
3312  {
3313  poly f = (poly)h->Data();
3314  h=h->next;
3315  int n=(int)((long)h->Data());
3316  res->rtyp=POLY_CMD ;
3317  res->data=(void*) pPower(pCopy(f),n);
3318  return(FALSE);
3319  }
3320  else
3321  if (strcmp(sys_cmd, "MCpower")==0)
3322  {
3323  ring r = currRing;
3324  poly f = (poly)h->Data();
3325  h=h->next;
3326  int n=(int)((long)h->Data());
3327  res->rtyp=POLY_CMD ;
3328  res->data=(void*) pFastPowerMC(f,n,r);
3329  return(FALSE);
3330  }
3331  else
3332  if (strcmp(sys_cmd, "bit_subst")==0)
3333  {
3334  ring r = currRing;
3335  poly outer = (poly)h->Data();
3336  h=h->next;
3337  poly inner=(poly)h->Data();
3338  res->rtyp=POLY_CMD ;
3339  res->data=(void*) uni_subst_bits(outer, inner,r);
3340  return(FALSE);
3341  }
3342  else
3343  /*==================== gcd-varianten =================*/
3344  if (strcmp(sys_cmd, "gcd") == 0)
3345  {
3346  if (h==NULL)
3347  {
3348  Print("EZGCD:%d (use EZGCD for gcd of polynomials in char 0)\n",isOn(SW_USE_EZGCD));
3349  Print("EZGCD_P:%d (use EZGCD_P for gcd of polynomials in char p)\n",isOn(SW_USE_EZGCD_P));
3350  Print("CRGCD:%d (use chinese Remainder for gcd of polynomials in char 0)\n",isOn(SW_USE_CHINREM_GCD));
3351  Print("QGCD:%d (use QGCD for gcd of polynomials in alg. ext.)\n",isOn(SW_USE_QGCD));
3352  Print("homog:%d (use homog. test for factorization of polynomials)\n",singular_homog_flag);
3353  return FALSE;
3354  }
3355  else
3356  if ((h!=NULL) && (h->Typ()==STRING_CMD)
3357  && (h->next!=NULL) && (h->next->Typ()==INT_CMD))
3358  {
3359  int d=(int)(long)h->next->Data();
3360  char *s=(char *)h->Data();
3361 #ifdef HAVE_PLURAL
3362  if (strcmp(s,"EZGCD")==0) { if (d) On(SW_USE_EZGCD); else Off(SW_USE_EZGCD); } else
3363  if (strcmp(s,"EZGCD_P")==0) { if (d) On(SW_USE_EZGCD_P); else Off(SW_USE_EZGCD_P); } else
3364  if (strcmp(s,"CRGCD")==0) { if (d) On(SW_USE_CHINREM_GCD); else Off(SW_USE_CHINREM_GCD); } else
3365  if (strcmp(s,"QGCD")==0) { if (d) On(SW_USE_QGCD); else Off(SW_USE_QGCD); } else
3366 #endif
3367  if (strcmp(s,"homog")==0) { if (d) singular_homog_flag=1; else singular_homog_flag=0; } else
3368  return TRUE;
3369  return FALSE;
3370  }
3371  else return TRUE;
3372  }
3373  else
3374  /*==================== subring =================*/
3375  if (strcmp(sys_cmd, "subring") == 0)
3376  {
3377  if (h!=NULL)
3378  {
3379  extern ring rSubring(ring r,leftv v); /* ipshell.cc*/
3380  res->data=(char *)rSubring(currRing,h);
3381  res->rtyp=RING_CMD;
3382  return res->data==NULL;
3383  }
3384  else return TRUE;
3385  }
3386  else
3387  /*==================== HNF =================*/
3388  #ifdef HAVE_NTL
3389  if (strcmp(sys_cmd, "HNF") == 0)
3390  {
3391  if (h!=NULL)
3392  {
3393  res->rtyp=h->Typ();
3394  if (h->Typ()==MATRIX_CMD)
3395  {
3396  res->data=(char *)singntl_HNF((matrix)h->Data(), currRing);
3397  return FALSE;
3398  }
3399  else if (h->Typ()==INTMAT_CMD)
3400  {
3401  res->data=(char *)singntl_HNF((intvec*)h->Data());
3402  return FALSE;
3403  }
3404  else if (h->Typ()==INTMAT_CMD)
3405  {
3406  res->data=(char *)singntl_HNF((intvec*)h->Data());
3407  return FALSE;
3408  }
3409  else
3410  {
3411  WerrorS("expected `system(\"HNF\",<matrix|intmat|bigintmat>)`");
3412  return TRUE;
3413  }
3414  }
3415  else return TRUE;
3416  }
3417  else
3418  /*================= probIrredTest ======================*/
3419  if (strcmp (sys_cmd, "probIrredTest") == 0)
3420  {
3421  if (h!=NULL && (h->Typ()== POLY_CMD) && ((h->next != NULL) && h->next->Typ() == STRING_CMD))
3422  {
3424  char *s=(char *)h->next->Data();
3425  double error= atof (s);
3426  int irred= probIrredTest (F, error);
3427  res->rtyp= INT_CMD;
3428  res->data= (void*)(long)irred;
3429  return FALSE;
3430  }
3431  else return TRUE;
3432  }
3433  else
3434  #endif
3435  #ifdef __CYGWIN__
3436  /*==================== Python Singular =================*/
3437  if (strcmp(sys_cmd, "python") == 0)
3438  {
3439  const char* c;
3440  if ((h!=NULL) && (h->Typ()==STRING_CMD))
3441  {
3442  c=(const char*)h->Data();
3443  if (!PyInitialized) {
3444  PyInitialized = 1;
3445  // Py_Initialize();
3446  // initPySingular();
3447  }
3448  // PyRun_SimpleString(c);
3449  return FALSE;
3450  }
3451  else return TRUE;
3452  }
3453  else
3454  /*==================== Python Singular =================
3455  if (strcmp(sys_cmd, "ipython") == 0)
3456  {
3457  const char* c;
3458  {
3459  if (!PyInitialized)
3460  {
3461  PyInitialized = 1;
3462  Py_Initialize();
3463  initPySingular();
3464  }
3465  PyRun_SimpleString(
3466  "try: \n\
3467  __IPYTHON__ \n\
3468  except NameError: \n\
3469  argv = [''] \n\
3470  banner = exit_msg = '' \n\
3471  else: \n\
3472  # Command-line options for IPython (a list like sys.argv) \n\
3473  argv = ['-pi1','In <\\#>:','-pi2',' .\\D.:','-po','Out<\\#>:'] \n\
3474  banner = '*** Nested interpreter ***' \n\
3475  exit_msg = '*** Back in main IPython ***' \n\
3476  \n\
3477  # First import the embeddable shell class \n\
3478  from IPython.Shell import IPShellEmbed \n\
3479  # Now create the IPython shell instance. Put ipshell() anywhere in your code \n\
3480  # where you want it to open. \n\
3481  ipshell = IPShellEmbed(argv,banner=banner,exit_msg=exit_msg) \n\
3482  ipshell()");
3483  return FALSE;
3484  }
3485  }
3486  else
3487  */
3488 
3489  #endif
3490  /*==================== mpz_t loader ======================*/
3491  if(strcmp(sys_cmd, "GNUmpLoad")==0)
3492  {
3493  if ((h != NULL) && (h->Typ() == STRING_CMD))
3494  {
3495  char* filename = (char*)h->Data();
3496  FILE* f = fopen(filename, "r");
3497  if (f == NULL)
3498  {
3499  WerrorS( "invalid file name (in paths use '/')");
3500  return FALSE;
3501  }
3502  mpz_t m; mpz_init(m);
3503  mpz_inp_str(m, f, 10);
3504  fclose(f);
3505  number n = n_InitMPZ(m, coeffs_BIGINT);
3506  res->rtyp = BIGINT_CMD;
3507  res->data = (void*)n;
3508  return FALSE;
3509  }
3510  else
3511  {
3512  WerrorS( "expected valid file name as a string");
3513  return TRUE;
3514  }
3515  }
3516  else
3517  /*==================== intvec matching ======================*/
3518  /* Given two non-empty intvecs, the call
3519  'system("intvecMatchingSegments", ivec, jvec);'
3520  computes all occurences of jvec in ivec, i.e., it returns
3521  a list of int indices k such that ivec[k..size(jvec)+k-1] = jvec.
3522  If no such k exists (e.g. when ivec is shorter than jvec), an
3523  intvec with the single entry 0 is being returned. */
3524  if(strcmp(sys_cmd, "intvecMatchingSegments")==0)
3525  {
3526  if ((h != NULL) && (h->Typ() == INTVEC_CMD) &&
3527  (h->next != NULL) && (h->next->Typ() == INTVEC_CMD) &&
3528  (h->next->next == NULL))
3529  {
3530  intvec* ivec = (intvec*)h->Data();
3531  intvec* jvec = (intvec*)h->next->Data();
3532  intvec* r = new intvec(1); (*r)[0] = 0;
3533  int validEntries = 0;
3534  for (int k = 0; k <= ivec->rows() - jvec->rows(); k++)
3535  {
3536  if (memcmp(&(*ivec)[k], &(*jvec)[0],
3537  sizeof(int) * jvec->rows()) == 0)
3538  {
3539  if (validEntries == 0)
3540  (*r)[0] = k + 1;
3541  else
3542  {
3543  r->resize(validEntries + 1);
3544  (*r)[validEntries] = k + 1;
3545  }
3546  validEntries++;
3547  }
3548  }
3549  res->rtyp = INTVEC_CMD;
3550  res->data = (void*)r;
3551  return FALSE;
3552  }
3553  else
3554  {
3555  WerrorS("expected two non-empty intvecs as arguments");
3556  return TRUE;
3557  }
3558  }
3559  else
3560  /* ================== intvecOverlap ======================= */
3561  /* Given two non-empty intvecs, the call
3562  'system("intvecOverlap", ivec, jvec);'
3563  computes the longest intvec kvec such that ivec ends with kvec
3564  and jvec starts with kvec. The length of this overlap is being
3565  returned. If there is no overlap at all, then 0 is being returned. */
3566  if(strcmp(sys_cmd, "intvecOverlap")==0)
3567  {
3568  if ((h != NULL) && (h->Typ() == INTVEC_CMD) &&
3569  (h->next != NULL) && (h->next->Typ() == INTVEC_CMD) &&
3570  (h->next->next == NULL))
3571  {
3572  intvec* ivec = (intvec*)h->Data();
3573  intvec* jvec = (intvec*)h->next->Data();
3574  int ir = ivec->rows(); int jr = jvec->rows();
3575  int r = jr; if (ir < jr) r = ir; /* r = min{ir, jr} */
3576  while ((r >= 1) && (memcmp(&(*ivec)[ir - r], &(*jvec)[0],
3577  sizeof(int) * r) != 0))
3578  r--;
3579  res->rtyp = INT_CMD;
3580  res->data = (void*)(long)r;
3581  return FALSE;
3582  }
3583  else
3584  {
3585  WerrorS("expected two non-empty intvecs as arguments");
3586  return TRUE;
3587  }
3588  }
3589  else
3590  /*==================== Hensel's lemma ======================*/
3591  if(strcmp(sys_cmd, "henselfactors")==0)
3592  {
3593  if ((h != NULL) && (h->Typ() == INT_CMD) &&
3594  (h->next != NULL) && (h->next->Typ() == INT_CMD) &&
3595  (h->next->next != NULL) && (h->next->next->Typ() == POLY_CMD) &&
3596  (h->next->next->next != NULL) &&
3597  (h->next->next->next->Typ() == POLY_CMD) &&
3598  (h->next->next->next->next != NULL) &&
3599  (h->next->next->next->next->Typ() == POLY_CMD) &&
3600  (h->next->next->next->next->next != NULL) &&
3601  (h->next->next->next->next->next->Typ() == INT_CMD) &&
3602  (h->next->next->next->next->next->next == NULL))
3603  {
3604  int xIndex = (int)(long)h->Data();
3605  int yIndex = (int)(long)h->next->Data();
3606  poly hh = (poly)h->next->next->Data();
3607  poly f0 = (poly)h->next->next->next->Data();
3608  poly g0 = (poly)h->next->next->next->next->Data();
3609  int d = (int)(long)h->next->next->next->next->next->Data();
3610  poly f; poly g;
3611  henselFactors(xIndex, yIndex, hh, f0, g0, d, f, g);
3613  L->Init(2);
3614  L->m[0].rtyp = POLY_CMD; L->m[0].data=(void*)f;
3615  L->m[1].rtyp = POLY_CMD; L->m[1].data=(void*)g;
3616  res->rtyp = LIST_CMD;
3617  res->data = (char *)L;
3618  return FALSE;
3619  }
3620  else
3621  {
3622  WerrorS( "expected argument list (int, int, poly, poly, poly, int)");
3623  return TRUE;
3624  }
3625  }
3626  else
3627  /*==================== Approx_Step =================*/
3628  #ifdef HAVE_PLURAL
3629  if (strcmp(sys_cmd, "astep") == 0)
3630  {
3631  ideal I;
3632  if ((h!=NULL) && (h->Typ()==IDEAL_CMD))
3633  {
3634  I=(ideal)h->CopyD();
3635  res->rtyp=IDEAL_CMD;
3636  if (rIsPluralRing(currRing)) res->data=Approx_Step(I);
3637  else res->data=I;
3638  setFlag(res,FLAG_STD);
3639  }
3640  else return TRUE;
3641  return FALSE;
3642  }
3643  else
3644  #endif
3645  /*==================== PrintMat =================*/
3646  #ifdef HAVE_PLURAL
3647  if (strcmp(sys_cmd, "PrintMat") == 0)
3648  {
3649  int a;
3650  int b;
3651  ring r;
3652  int metric;
3653  if (h!=NULL)
3654  {
3655  if (h->Typ()==INT_CMD)
3656  {
3657  a=(int)((long)(h->Data()));
3658  h=h->next;
3659  }
3660  else if (h->Typ()==INT_CMD)
3661  {
3662  b=(int)((long)(h->Data()));
3663  h=h->next;
3664  }
3665  else if (h->Typ()==RING_CMD)
3666  {
3667  r=(ring)h->Data();
3668  h=h->next;
3669  }
3670  else
3671  return TRUE;
3672  }
3673  else
3674  return TRUE;
3675  if ((h!=NULL) && (h->Typ()==INT_CMD))
3676  {
3677  metric=(int)((long)(h->Data()));
3678  }
3679  res->rtyp=MATRIX_CMD;
3680  if (rIsPluralRing(r)) res->data=nc_PrintMat(a,b,r,metric);
3681  else res->data=NULL;
3682  return FALSE;
3683  }
3684  else
3685  #endif
3686 /* ============ NCUseExtensions ======================== */
3687  #ifdef HAVE_PLURAL
3688  if(strcmp(sys_cmd,"NCUseExtensions")==0)
3689  {
3690  if ((h!=NULL) && (h->Typ()==INT_CMD))
3691  res->data=(void *)(long)setNCExtensions( (int)((long)(h->Data())) );
3692  else
3693  res->data=(void *)(long)getNCExtensions();
3694  res->rtyp=INT_CMD;
3695  return FALSE;
3696  }
3697  else
3698  #endif
3699 /* ============ NCGetType ======================== */
3700  #ifdef HAVE_PLURAL
3701  if(strcmp(sys_cmd,"NCGetType")==0)
3702  {
3703  res->rtyp=INT_CMD;
3704  if( rIsPluralRing(currRing) )
3705  res->data=(void *)(long)ncRingType(currRing);
3706  else
3707  res->data=(void *)(-1L);
3708  return FALSE;
3709  }
3710  else
3711  #endif
3712 /* ============ ForceSCA ======================== */
3713  #ifdef HAVE_PLURAL
3714  if(strcmp(sys_cmd,"ForceSCA")==0)
3715  {
3716  if( !rIsPluralRing(currRing) )
3717  return TRUE;
3718  int b, e;
3719  if ((h!=NULL) && (h->Typ()==INT_CMD))
3720  {
3721  b = (int)((long)(h->Data()));
3722  h=h->next;
3723  }
3724  else return TRUE;
3725  if ((h!=NULL) && (h->Typ()==INT_CMD))
3726  {
3727  e = (int)((long)(h->Data()));
3728  }
3729  else return TRUE;
3730  if( !sca_Force(currRing, b, e) )
3731  return TRUE;
3732  return FALSE;
3733  }
3734  else
3735  #endif
3736 /* ============ ForceNewNCMultiplication ======================== */
3737  #ifdef HAVE_PLURAL
3738  if(strcmp(sys_cmd,"ForceNewNCMultiplication")==0)
3739  {
3740  if( !rIsPluralRing(currRing) )
3741  return TRUE;
3742  if( !ncInitSpecialPairMultiplication(currRing) ) // No Plural!
3743  return TRUE;
3744  return FALSE;
3745  }
3746  else
3747  #endif
3748 /* ============ ForceNewOldNCMultiplication ======================== */
3749  #ifdef HAVE_PLURAL
3750  if(strcmp(sys_cmd,"ForceNewOldNCMultiplication")==0)
3751  {
3752  if( !rIsPluralRing(currRing) )
3753  return TRUE;
3754  if( !ncInitSpecialPowersMultiplication(currRing) ) // Enable Formula for Plural (depends on swiches)!
3755  return TRUE;
3756  return FALSE;
3757  }
3758  else
3759  #endif
3760 /*==================== test64 =================*/
3761  #if 0
3762  if(strcmp(sys_cmd,"test64")==0)
3763  {
3764  long l=8;int i;
3765  for(i=1;i<62;i++)
3766  {
3767  l=l<<1;
3768  number n=n_Init(l,coeffs_BIGINT);
3769  Print("%ld= ",l);n_Print(n,coeffs_BIGINT);
3771  n_Delete(&n,coeffs_BIGINT);
3773  PrintS(" F:");
3775  PrintLn();
3776  n_Delete(&n,coeffs_BIGINT);
3777  }
3778  Print("SIZEOF_LONG=%d\n",SIZEOF_LONG);
3779  return FALSE;
3780  }
3781  else
3782  #endif
3783 /*==================== n_SwitchChinRem =================*/
3784  if(strcmp(sys_cmd,"cache_chinrem")==0)
3785  {
3786  extern int n_SwitchChinRem;
3787  Print("caching inverse in chines remainder:%d\n",n_SwitchChinRem);
3788  if ((h!=NULL)&&(h->Typ()==INT_CMD))
3789  n_SwitchChinRem=(int)(long)h->Data();
3790  return FALSE;
3791  }
3792  else
3793 /*==================== LU for bigintmat =================*/
3794 #ifdef SINGULAR_4_2
3795  if(strcmp(sys_cmd,"LU")==0)
3796  {
3797  if ((h!=NULL) && (h->Typ()==CMATRIX_CMD))
3798  {
3799  // get the argument:
3800  bigintmat *b=(bigintmat *)h->Data();
3801  // just for tests: simply transpose
3802  bigintmat *bb=b->transpose();
3803  // return the result:
3804  res->rtyp=CMATRIX_CMD;
3805  res->data=(char*)bb;
3806  return FALSE;
3807  }
3808  else
3809  {
3810  WerrorS("system(\"LU\",<cmatrix>) expected");
3811  return TRUE;
3812  }
3813  }
3814  else
3815 #endif
3816 /*==================== sort =================*/
3817  if(strcmp(sys_cmd,"sort")==0)
3818  {
3819  extern BOOLEAN jjSORTLIST(leftv,leftv);
3820  if (h->Typ()==LIST_CMD)
3821  return jjSORTLIST(res,h);
3822  else
3823  return TRUE;
3824  }
3825  else
3826 /*==================== uniq =================*/
3827  if(strcmp(sys_cmd,"uniq")==0)
3828  {
3829  extern BOOLEAN jjUNIQLIST(leftv, leftv);
3830  if (h->Typ()==LIST_CMD)
3831  return jjUNIQLIST(res,h);
3832  else
3833  return TRUE;
3834  }
3835  else
3836 /*==================== tensor =================*/
3837  if(strcmp(sys_cmd,"tensor")==0)
3838  {
3839  const short t[]={2,MODUL_CMD,MODUL_CMD};
3840  if (iiCheckTypes(h,t,1))
3841  {
3842  res->data=(void*)mp_Tensor((ideal)h->Data(),(ideal)h->next->Data(),currRing);
3843  res->rtyp=MODUL_CMD;
3844  return FALSE;
3845  }
3846  else
3847  return TRUE;
3848  }
3849  else
3850 /*==================== power* ==================================*/
3851  #if 0
3852  if(strcmp(sys_cmd,"power1")==0)
3853  {
3854  res->rtyp=POLY_CMD;
3855  poly f=(poly)h->CopyD();
3856  poly g=pPower(f,2000);
3857  res->data=(void *)g;
3858  return FALSE;
3859  }
3860  else
3861  if(strcmp(sys_cmd,"power2")==0)
3862  {
3863  res->rtyp=POLY_CMD;
3864  poly f=(poly)h->Data();
3865  poly g=pOne();
3866  for(int i=0;i<2000;i++)
3867  g=pMult(g,pCopy(f));
3868  res->data=(void *)g;
3869  return FALSE;
3870  }
3871  if(strcmp(sys_cmd,"power3")==0)
3872  {
3873  res->rtyp=POLY_CMD;
3874  poly f=(poly)h->Data();
3875  poly p2=pMult(pCopy(f),pCopy(f));
3876  poly p4=pMult(pCopy(p2),pCopy(p2));
3877  poly p8=pMult(pCopy(p4),pCopy(p4));
3878  poly p16=pMult(pCopy(p8),pCopy(p8));
3879  poly p32=pMult(pCopy(p16),pCopy(p16));
3880  poly p64=pMult(pCopy(p32),pCopy(p32));
3881  poly p128=pMult(pCopy(p64),pCopy(p64));
3882  poly p256=pMult(pCopy(p128),pCopy(p128));
3883  poly p512=pMult(pCopy(p256),pCopy(p256));
3884  poly p1024=pMult(pCopy(p512),pCopy(p512));
3885  poly p1536=pMult(p1024,p512);
3886  poly p1792=pMult(p1536,p256);
3887  poly p1920=pMult(p1792,p128);
3888  poly p1984=pMult(p1920,p64);
3889  poly p2000=pMult(p1984,p16);
3890  res->data=(void *)p2000;
3891  pDelete(&p2);
3892  pDelete(&p4);
3893  pDelete(&p8);
3894  //pDelete(&p16);
3895  pDelete(&p32);
3896  //pDelete(&p64);
3897  //pDelete(&p128);
3898  //pDelete(&p256);
3899  //pDelete(&p512);
3900  //pDelete(&p1024);
3901  //pDelete(&p1536);
3902  //pDelete(&p1792);
3903  //pDelete(&p1920);
3904  //pDelete(&p1984);
3905  return FALSE;
3906  }
3907  else
3908  #endif
3909 /*==================== Error =================*/
3910  Werror( "(extended) system(\"%s\",...) %s", sys_cmd, feNotImplemented );
3911  }
3912  return TRUE;
3913 }
3914 
3915 #endif // HAVE_EXTENDED_SYSTEM
3916 
3917 
feOptIndex
Definition: feOptGen.h:15
bigintmat * transpose()
Definition: bigintmat.cc:38
int & rows()
Definition: matpol.h:24
lists get_denom_list()
Definition: denom_list.cc:8
int status int fd
Definition: si_signals.h:59
poly pOppose(ring Rop_src, poly p, const ring Rop_dst)
opposes a vector p from Rop to currRing (dst!)
Definition: old.gring.cc:3373
#define omAllocBin(bin)
Definition: omAllocDecl.h:205
int posInT_pLength(const TSet set, const int length, LObject &p)
Definition: kutil.cc:11766
#define pIsPurePower(p)
Definition: polys.h:231
const CanonicalForm int s
Definition: facAbsFact.cc:55
This file provides miscellaneous functionality.
ring rEnvelope(ring R)
Definition: ring.cc:5519
sleftv * m
Definition: lists.h:45
poly pFastPower(poly f, int n, ring r)
Definition: fast_mult.cc:342
intvec * MivMatrixOrder(intvec *iv)
Definition: walk.cc:972
poly nc_p_Bracket_qq(poly p, const poly q, const ring r)
returns [p,q], destroys p
Definition: old.gring.cc:2254
void p_DebugPrint(poly p, const ring r)
Definition: ring.cc:4217
void factoryseed(int s)
random seed initializer
Definition: cf_random.cc:176
Class used for (list of) interpreter objects.
Definition: subexpr.h:82
const char * omError2String(omError_t error)
Definition: omError.c:52
#define MAXPATHLEN
Definition: omRet2Info.c:22
ring rSubring(ring org_ring, sleftv *rv)
Definition: ipshell.cc:5895
void resize(int new_length)
Definition: intvec.cc:107
const poly a
Definition: syzextra.cc:212
int sdb_flags
Definition: sdb.cc:32
int HCord
Definition: kutil.cc:235
void PrintLn()
Definition: reporter.cc:310
static CanonicalForm bound(const CFMatrix &M)
Definition: cf_linsys.cc:460
int posInT2(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5363
#define Print
Definition: emacs.cc:83
matrix singntl_LLL(matrix m, const ring s)
Definition: clapsing.cc:1726
BOOLEAN jjSORTLIST(leftv, leftv arg)
Definition: iparith.cc:9396
intvec * Mfpertvector(ideal G, intvec *ivtarget)
Definition: walk.cc:1521
Definition: tok.h:95
#define pAdd(p, q)
Definition: polys.h:186
static void * feOptValue(feOptIndex opt)
Definition: feOpt.h:40
void Off(int sw)
switches
matrix evRowElim(matrix M, int i, int j, int k)
Definition: eigenval.cc:47
Definition: lists.h:22
ideal Mpwalk(ideal Go, int op_deg, int tp_deg, intvec *curr_weight, intvec *target_weight, int nP, int reduction, int printout)
Definition: walk.cc:5956
Definition: int_poly.h:33
void henselFactors(const int xIndex, const int yIndex, const poly h, const poly f0, const poly g0, const int d, poly &f, poly &g)
Computes a factorization of a polynomial h(x, y) in K[[x]][y] up to a certain degree in x...
used for all transcendental extensions, i.e., the top-most extension in an extension tower is transce...
Definition: coeffs.h:39
char * versionString()
Definition: misc_ip.cc:778
#define FALSE
Definition: auxiliary.h:94
Compatiblity layer for legacy polynomial operations (over currRing)
int posInT1(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5335
Definition: tok.h:38
return P p
Definition: myNF.cc:203
intvec * MivWeightOrderlp(intvec *ivstart)
Definition: walk.cc:1445
short * iv2array(intvec *iv, const ring R)
Definition: weight.cc:208
BOOLEAN semicProc3(leftv res, leftv u, leftv v, leftv w)
Definition: ipshell.cc:4437
Matrices of numbers.
Definition: bigintmat.h:51
number n_convFactoryNSingN(const CanonicalForm n, const coeffs r)
Definition: numbers.cc:587
lists testsvd(matrix M)
Definition: calcSVD.cc:27
void sdb_edit(procinfo *pi)
Definition: sdb.cc:110
#define SINGULAR_VERSION
Definition: mod2.h:86
void slicehilb(ideal I)
Definition: hilb.cc:1105
static char * feResource(feResourceConfig config, int warn)
Definition: feResource.cc:258
This file is work in progress and currently not part of the official Singular.
int rows() const
Definition: bigintmat.h:146
int & getNCExtensions()
Definition: old.gring.cc:87
lists pcvPMulL(poly p, lists l1)
Definition: pcv.cc:56
static const int SW_USE_EZGCD_P
set to 1 to use EZGCD over F_q
Definition: cf_defs.h:34
int setNCExtensions(int iMask)
Definition: old.gring.cc:92
int n_SwitchChinRem
Definition: longrat.cc:2937
void error(const char *fmt,...)
Definition: emacs.cc:58
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition: coeffs.h:542
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
int rows() const
Definition: intvec.h:88
int rChar(ring r)
Definition: ring.cc:688
ring rOpposite(ring src)
Definition: ring.cc:5189
poly pFastPowerMC(poly f, int n, ring r)
Definition: fast_mult.cc:588
unsigned long ** singularMatrixToLongMatrix(matrix singularMatrix)
Definition: extra.cc:189
#define BB_LIKE_LIST(B)
Definition: blackbox.h:54
omError_t om_InternalErrorStatus
Definition: omError.c:12
poly nc_rat_ReduceSpolyNew(const poly p1, poly p2, int ishift, const ring r)
Definition: ratgring.cc:466
int siRandomStart
Definition: cntrlc.cc:102
ideal id_TensorModuleMult(const int m, const ideal M, const ring rRing)
void HilbertSeries_OrbitData(ideal S, int lV, bool IG_CASE, bool mgrad, bool odp)
Definition: hilb.cc:1861
char * getenv()
BOOLEAN spectrumProc(leftv result, leftv first)
Definition: ipshell.cc:4059
static FORCE_INLINE int n_GetChar(const coeffs r)
Return the characteristic of the coeff. domain.
Definition: coeffs.h:448
factory&#39;s main class
Definition: canonicalform.h:75
#define TRUE
Definition: auxiliary.h:98
int MivSame(intvec *u, intvec *v)
Definition: walk.cc:902
void * ADDRESS
Definition: auxiliary.h:115
intvec * MivWeightOrderdp(intvec *ivstart)
Definition: walk.cc:1465
static coordinates * points
void * dynl_sym(void *handle, const char *symbol)
Definition: mod_raw.cc:167
BOOLEAN spmulProc(leftv result, leftv first, leftv second)
Definition: ipshell.cc:4396
void * value
Definition: fegetopt.h:93
const char * feSetOptValue(feOptIndex opt, char *optarg)
Definition: feOpt.cc:153
g
Definition: cfModGcd.cc:4031
void WerrorS(const char *s)
Definition: feFopen.cc:24
int k
Definition: cfEzgcd.cc:93
gmp_complex numbers based on
Definition: mpr_complex.h:178
char * StringEndS()
Definition: reporter.cc:151
bool complexNearZero(gmp_complex *c, int digits)
Definition: mpr_complex.cc:767
BOOLEAN jjSYSTEM(leftv res, leftv args)
Definition: extra.cc:244
void lduDecomp(const matrix aMat, matrix &pMat, matrix &lMat, matrix &dMat, matrix &uMat, poly &l, poly &u, poly &lTimesU)
LU-decomposition of a given (m x n)-matrix with performing only those divisions that yield zero remai...
int testGB(ideal I, ideal GI)
Definition: ringgb.cc:230
static TreeM * G
Definition: janet.cc:38
int posInT15(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5703
coeffs coeffs_BIGINT
Definition: ipid.cc:54
int Typ()
Definition: subexpr.cc:995
#define omAlloc(size)
Definition: omAllocDecl.h:210
#define Sy_bit(x)
Definition: options.h:30
ideal mp_Tensor(ideal A, ideal B, const ring r)
Definition: matpol.cc:1757
void setCharacteristic(int c)
Definition: cf_char.cc:23
const char * Name()
Definition: subexpr.h:120
CanonicalForm n_convSingNFactoryN(number n, BOOLEAN setChar, const coeffs r)
Definition: numbers.cc:592
matrix evSwap(matrix M, int i, int j)
Definition: eigenval.cc:25
int posInT0(const TSet, const int length, LObject &)
Definition: kutil.cc:5324
Definition: idrec.h:34
poly pp
Definition: myNF.cc:296
void * dynl_open(char *filename)
Definition: mod_raw.cc:153
#define ivTest(v)
Definition: intvec.h:149
idhdl get(const char *s, int lev)
Definition: ipid.cc:90
intvec * MPertVectorslp(ideal G, intvec *ivtarget, int pdeg)
Definition: walk.cc:1308
omOpts_t om_Opts
Definition: omOpts.c:11
void * data
Definition: subexpr.h:88
void printBlackboxTypes()
list all defined type (for debugging)
Definition: blackbox.cc:208
void feStringAppendBrowsers(int warn)
Definition: fehelp.cc:354
ideal Mfwalk(ideal G, intvec *ivstart, intvec *ivtarget, int reduction, int printout)
Definition: walk.cc:8040
#define pIter(p)
Definition: monomials.h:44
poly res
Definition: myNF.cc:322
matrix mp_Transp(matrix a, const ring R)
Definition: matpol.cc:264
poly p_Shrink(poly p, int lV, const ring r)
Definition: shiftgb.cc:373
int myynest
Definition: febase.cc:46
bool sca_Force(ring rGR, int b, int e)
Definition: sca.cc:1174
#define M
Definition: sirandom.c:24
unsigned long * computeMinimalPolynomial(unsigned long **matrix, unsigned n, unsigned long p)
Definition: minpoly.cc:430
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:10
#define pGetExp(p, i)
Exponent.
Definition: polys.h:41
int posInT11(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5393
static int rBlocks(ring r)
Definition: ring.h:559
int posInT17_c(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5905
const ring r
Definition: syzextra.cc:208
Coefficient rings, fields and other domains suitable for Singular polynomials.
ideal MAltwalk1(ideal Go, int op_deg, int tp_deg, intvec *curr_weight, intvec *target_weight)
Definition: walk.cc:9680
#define FLAG_TWOSTD
Definition: ipid.h:107
Definition: intvec.h:14
static FORCE_INLINE long n_Int(number &n, const coeffs r)
conversion of n to an int; 0 if not possible in Z/pZ: the representing int lying in (-p/2 ...
Definition: coeffs.h:551
int pcvDim(int d0, int d1)
Definition: pcv.cc:361
BOOLEAN rComplete(ring r, int force)
this needs to be called whenever a new ring is created: new fields in ring are created (like VarOffse...
Definition: ring.cc:3365
leftv Next()
Definition: subexpr.h:136
matrix nc_PrintMat(int a, int b, ring r, int metric)
returns matrix with the info on noncomm multiplication
Definition: old.gring.cc:2405
int j
Definition: myNF.cc:70
static int max(int a, int b)
Definition: fast_mult.cc:264
Definition: tok.h:58
void newstructShow(newstruct_desc d)
Definition: newstruct.cc:830
poly uni_subst_bits(poly outer_uni, poly inner_multi, ring r)
Definition: digitech.cc:47
#define omFree(addr)
Definition: omAllocDecl.h:261
#define assume(x)
Definition: mod2.h:394
poly multifastmult(poly f, poly g, ring r)
Definition: fast_mult.cc:290
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
Definition: ring.h:404
omError_t om_ErrorStatus
Definition: omError.c:11
void StringSetS(const char *st)
Definition: reporter.cc:128
#define pLPshift(p, sh, uptodeg, lV)
Definition: shiftgb.h:30
int Mults()
Definition: fast_mult.cc:14
static BOOLEAN jjEXTENDED_SYSTEM(leftv res, leftv h)
Definition: extra.cc:2334
#define pDivideM(a, b)
Definition: polys.h:276
#define pmLastVblock(p, lV)
Definition: shiftgb.h:35
int M3ivSame(intvec *temp, intvec *u, intvec *v)
Definition: walk.cc:923
const ring R
Definition: DebugPrint.cc:36
const char feNotImplemented[]
Definition: reporter.cc:54
BOOLEAN jjUNIQLIST(leftv, leftv arg)
Definition: iparith.cc:9405
struct fe_option feOptSpec[]
const char * omError2Serror(omError_t error)
Definition: omError.c:63
intvec * MwalkNextWeight(intvec *curr_weight, intvec *target_weight, ideal G)
ideal Mwalk(ideal Go, intvec *orig_M, intvec *target_M, ring baseRing, int reduction, int printout)
Definition: walk.cc:5311
ip_smatrix * matrix
intvec * MPertNextWeight(intvec *iva, ideal G, int deg)
void system(sys)
static FORCE_INLINE number n_InitMPZ(mpz_t n, const coeffs r)
conversion of a GMP integer to number
Definition: coeffs.h:546
idhdl currRingHdl
Definition: ipid.cc:65
#define setFlag(A, F)
Definition: ipid.h:110
int simpleipc_cmd(char *cmd, int id, int v)
Definition: semaphore.c:167
int m
Definition: cfEzgcd.cc:119
void fePrintOptValues()
Definition: feOpt.cc:319
bool isOn(int sw)
switches
poly nc_rat_CreateSpoly(poly pp1, poly pp2, int ishift, const ring r)
Definition: ratgring.cc:341
void On(int sw)
switches
poly pcvCV2P(poly cv, int d0, int d1)
Definition: pcv.cc:263
int dim(ideal I, ring r)
void rDebugPrint(const ring r)
Definition: ring.cc:4012
FILE * f
Definition: checklibs.c:9
BOOLEAN assumeStdFlag(leftv h)
Definition: subexpr.cc:1474
poly longCoeffsToSingularPoly(unsigned long *polyCoeffs, const int degree)
Definition: extra.cc:221
int i
Definition: cfEzgcd.cc:123
intvec * Mivperttarget(ideal G, int ndeg)
void PrintS(const char *s)
Definition: reporter.cc:284
BOOLEAN spectrumfProc(leftv result, leftv first)
Definition: ipshell.cc:4110
lists pcvLAddL(lists l1, lists l2)
Definition: pcv.cc:31
#define pOne()
Definition: polys.h:297
int pcvBasis(lists b, int i, poly m, int d, int n)
Definition: pcv.cc:391
int posInT17(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5798
static const int SW_USE_CHINREM_GCD
set to 1 to use modular gcd over Z
Definition: cf_defs.h:38
static unsigned pLength(poly a)
Definition: p_polys.h:189
intvec * MPertVectors(ideal G, intvec *ivtarget, int pdeg)
Definition: walk.cc:1097
#define pHead(p)
returns newly allocated copy of Lm(p), coef is copied, next=NULL, p might be NULL ...
Definition: polys.h:67
#define IDELEMS(i)
Definition: simpleideals.h:24
matrix singntl_HNF(matrix m, const ring s)
Definition: clapsing.cc:1628
poly kNFBound(ideal F, ideal Q, poly p, int bound, int syzComp, int lazyReduce)
Definition: kstd1.cc:3017
static short scaFirstAltVar(ring r)
Definition: sca.h:18
poly ringRedNF(poly f, ideal G, ring r)
Definition: ringgb.cc:121
int singular_homog_flag
Definition: cf_factor.cc:377
ideal freegb(ideal I, int uptodeg, int lVblock)
Definition: kstd2.cc:4371
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425
#define FLAG_STD
Definition: ipid.h:106
poly kFindZeroPoly(poly input_p, ring leadRing, ring tailRing)
Definition: kstd2.cc:318
leftv next
Definition: subexpr.h:86
static BOOLEAN rField_is_long_C(const ring r)
Definition: ring.h:537
void rSetSyzComp(int k, const ring r)
Definition: ring.cc:4989
ideal Approx_Step(ideal L)
Ann: ???
Definition: nc.cc:253
intvec * Mivdp(int nR)
Definition: walk.cc:1016
#define BIMATELEM(M, I, J)
Definition: bigintmat.h:134
poly plain_spoly(poly f, poly g)
Definition: ringgb.cc:172
INLINE_THIS void Init(int l=0)
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:44
int posInT_EcartFDegpLength(const TSet set, const int length, LObject &p)
Definition: kutil.cc:11675
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
matrix evHessenberg(matrix M)
Definition: eigenval.cc:100
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent : VarOffset encodes the position in p->exp
Definition: p_polys.h:483
int & cols()
Definition: matpol.h:25
matrix mp_InitI(int r, int c, int v, const ring R)
make it a v * unit matrix
Definition: matpol.cc:136
#define pLastVblock(p, lV)
Definition: shiftgb.h:33
#define MATCOLS(i)
Definition: matpol.h:28
Definition: tok.h:116
lists evEigenvals(matrix M)
Definition: eigenval_ip.cc:118
static BOOLEAN rField_is_Ring(const ring r)
Definition: ring.h:477
#define NULL
Definition: omList.c:10
CanonicalForm convSingPFactoryP(poly p, const ring r)
Definition: clapconv.cc:88
#define pDivisibleBy(a, b)
returns TRUE, if leading monom of a divides leading monom of b i.e., if there exists a expvector c > ...
Definition: polys.h:138
slists * lists
Definition: mpr_numeric.h:146
BOOLEAN semicProc(leftv res, leftv u, leftv v)
Definition: ipshell.cc:4477
int siSeed
Definition: sirandom.c:29
poly fglmLinearCombination(ideal source, poly monset)
Definition: fglmcomb.cc:417
bool luSolveViaLDUDecomp(const matrix pMat, const matrix lMat, const matrix dMat, const matrix uMat, const poly l, const poly u, const poly lTimesU, const matrix bVec, matrix &xVec, matrix &H)
Solves the linear system A * x = b, where A is an (m x n)-matrix which is given by its LDU-decomposit...
ideal TranMImprovwalk(ideal G, intvec *curr_weight, intvec *target_tmp, int nP)
Definition: walk.cc:8405
#define pMult(p, q)
Definition: polys.h:190
int probIrredTest(const CanonicalForm &F, double error)
given some error probIrredTest detects irreducibility or reducibility of F with confidence level 1-er...
Definition: facIrredTest.cc:63
BOOLEAN iiCheckTypes(leftv args, const short *type_list, int report)
check a list of arguemys against a given field of types return TRUE if the types match return FALSE (...
Definition: ipshell.cc:6466
int posInT110(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5546
coeffs basecoeffs() const
Definition: bigintmat.h:147
static const int SW_USE_QGCD
set to 1 to use Encarnacion GCD over Q(a)
Definition: cf_defs.h:40
void omUpdateInfo()
Definition: omStats.c:24
static BOOLEAN rField_is_long_R(const ring r)
Definition: ring.h:534
static const int SW_USE_EZGCD
set to 1 to use EZGCD over Z
Definition: cf_defs.h:32
#define IDRING(a)
Definition: ipid.h:124
int blackboxIsCmd(const char *n, int &tok)
used by scanner: returns ROOT_DECL for known types (and the type number in tok)
Definition: blackbox.cc:191
const CanonicalForm & w
Definition: facAbsFact.cc:55
#define pDelete(p_ptr)
Definition: polys.h:169
static short scaLastAltVar(ring r)
Definition: sca.h:25
intvec * MivMatrixOrderdp(int nV)
Definition: walk.cc:1426
int rtyp
Definition: subexpr.h:91
static bool rIsSCA(const ring r)
Definition: nc.h:206
#define TEST_FOR(A)
void * Data()
Definition: subexpr.cc:1137
BOOLEAN ncInitSpecialPairMultiplication(ring r)
Definition: ncSAMult.cc:266
ideal MAltwalk2(ideal Go, intvec *curr_weight, intvec *target_weight)
Definition: walk.cc:4289
ideal Mrwalk(ideal Go, intvec *orig_M, intvec *target_M, int weight_rad, int pert_deg, int reduction, int printout)
Definition: walk.cc:5612
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:228
CFList int bool & irred
[in,out] Is A irreducible?
Definition: facFactorize.h:31
bool ncInitSpecialPowersMultiplication(ring r)
Definition: ncSAFormula.cc:50
poly pcvP2CV(poly p, int d0, int d1)
Definition: pcv.cc:246
Definition: tok.h:117
#define p_GetCoeff(p, r)
Definition: monomials.h:57
int(* test_PosInT)(const TSet T, const int tl, LObject &h)
Definition: kstd2.cc:82
#define omPrintCurrentBackTrace(fd)
Definition: omRet2Info.h:39
static nc_type & ncRingType(nc_struct *p)
Definition: nc.h:175
KINLINE poly ksOldSpolyRed(poly p1, poly p2, poly spNoether)
Definition: kInline.h:1053
int redRat(poly *h, poly *reducer, int *red_length, int rl, int ishift, ring r)
Definition: ratgring.cc:594
char * omFindExec(const char *name, char *exec)
Definition: omFindExec.c:252
#define pLmDeleteAndNext(p)
like pLmDelete, returns pNext(p)
Definition: polys.h:78
omBin slists_bin
Definition: lists.cc:23
void pPrintDivisbleByStat()
Definition: pDebug.cc:412
BOOLEAN spaddProc(leftv result, leftv first, leftv second)
Definition: ipshell.cc:4354
intvec * MivUnit(int nV)
Definition: walk.cc:1505
ideal idXXX(ideal h1, int k)
Definition: ideals.cc:703
ideal singclap_absFactorize(poly f, ideal &mipos, intvec **exps, int &numFactors, const ring r)
Definition: clapsing.cc:1782
void omPrintUsedTrackAddrs(FILE *fd, int max_frames)
Definition: omDebugCheck.c:568
#define pPower(p, q)
Definition: polys.h:187
BOOLEAN newstruct_set_proc(const char *bbname, const char *func, int args, procinfov pr)
Definition: newstruct.cc:850
void omMarkAsStaticAddr(void *addr)
size_t gmp_output_digits
Definition: mpr_complex.cc:44
ideal Mprwalk(ideal Go, intvec *orig_M, intvec *target_M, int weight_rad, int op_deg, int tp_deg, int nP, int reduction, int printout)
Definition: walk.cc:6397
END_NAMESPACE const void * p2
Definition: syzextra.cc:202
void omPrintUsedAddrs(FILE *fd, int max_frames)
Definition: omDebugCheck.c:557
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:459
int posInT19(const TSet set, const int length, LObject &p)
Definition: kutil.cc:6032
int(* test_PosInL)(const LSet set, const int length, LObject *L, const kStrategy strat)
Definition: kstd2.cc:83
#define MATROWS(i)
Definition: matpol.h:27
lists gmsNF(ideal p, ideal g, matrix B, int D, int K)
Definition: gms.cc:22
ideal createG0()
Definition: kutil.cc:4535
int degree(const CanonicalForm &f)
ideal id_Vec2Ideal(poly vec, const ring R)
feOptIndex feGetOptIndex(const char *name)
Definition: feOpt.cc:104
void countedref_reference_load()
Initialize blackbox types &#39;reference&#39; and &#39;shared&#39;, or both.
Definition: countedref.cc:700
static jList * T
Definition: janet.cc:37
polyrec * poly
Definition: hilb.h:10
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:877
#define IDDATA(a)
Definition: ipid.h:123
char * singclap_neworder(ideal I, const ring r)
Definition: clapsing.cc:1476
poly ringNF(poly f, ideal G, ring r)
Definition: ringgb.cc:203
ideal MwalkInitialForm(ideal G, intvec *ivw)
Definition: walk.cc:770
int posInT_FDegpLength(const TSet set, const int length, LObject &p)
Definition: kutil.cc:11729
ideal Mfrwalk(ideal G, intvec *ivstart, intvec *ivtarget, int weight_rad, int reduction, int printout)
Definition: walk.cc:8221
unsigned si_opt_2
Definition: options.c:6
poly fglmNewLinearCombination(ideal source, poly monset)
Definition: fglmcomb.cc:154
static Poly * h
Definition: janet.cc:978
s?
Definition: ring.h:84
int BOOLEAN
Definition: auxiliary.h:85
#define IMATELEM(M, I, J)
Definition: intvec.h:77
const poly b
Definition: syzextra.cc:213
#define NONE
Definition: tok.h:216
#define ppJetW(p, m, iv)
Definition: polys.h:351
void feReInitResources()
Definition: feResource.cc:207
poly p_ISet(long i, const ring r)
returns the poly representing the integer i
Definition: p_polys.cc:1298
void Werror(const char *fmt,...)
Definition: reporter.cc:189
intvec * MivMatrixOrderlp(int nV)
Definition: walk.cc:1410
void * CopyD(int t)
Definition: subexpr.cc:707
int pcvMinDeg(poly p)
Definition: pcv.cc:108
void countedref_shared_load()
Definition: countedref.cc:724
#define omAlloc0(size)
Definition: omAllocDecl.h:211
int l
Definition: cfEzgcd.cc:94
return result
Definition: facAbsBiFact.cc:76
static int nfMinPoly[16]
Definition: ffields.cc:528
intvec * Mivlp(int nR)
Definition: walk.cc:1031
procinfo * procinfov
Definition: structs.h:63
int posInT13(const TSet set, const int length, LObject &p)
Definition: kutil.cc:5635
poly unifastmult(poly f, poly g, ring r)
Definition: fast_mult.cc:272
#define pCopy(p)
return a copy of the poly
Definition: polys.h:168
#define MATELEM(mat, i, j)
Definition: matpol.h:29
void n_Print(number &a, const coeffs r)
print a number (BEWARE of string buffers!) mostly for debugging
Definition: numbers.cc:576
blackbox * getBlackboxStuff(const int t)
return the structure to the type given by t
Definition: blackbox.cc:16
intvec * MkInterRedNextWeight(intvec *iva, intvec *ivb, ideal G)
Definition: walk.cc:2579
#define Warn
Definition: emacs.cc:80
ideal twostd(ideal I)
Compute two-sided GB:
Definition: nc.cc:21
#define omStrDup(s)
Definition: omAllocDecl.h:263
ideal F5main(ideal id, ring r, int opt, int plus, int termination)
Definition: f5gb.cc:1893