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