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