1 | /***************************************** |
---|
2 | * Computer Algebra System SINGULAR * |
---|
3 | *****************************************/ |
---|
4 | /* $Id: extra.cc,v 1.238 2006-01-16 03:28:10 wienand Exp $ */ |
---|
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 | |
---|
57 | #ifdef HAVE_RING2TOM |
---|
58 | #include "ringgb.h" |
---|
59 | #endif |
---|
60 | |
---|
61 | #ifdef HAVE_WALK |
---|
62 | #include "walk.h" |
---|
63 | #endif |
---|
64 | |
---|
65 | #include "weight.h" |
---|
66 | #include "fast_mult.h" |
---|
67 | #include "digitech.h" |
---|
68 | |
---|
69 | #ifdef HAVE_SPECTRUM |
---|
70 | #include "spectrum.h" |
---|
71 | #endif |
---|
72 | |
---|
73 | #ifdef HAVE_BIFAC |
---|
74 | #include <bifac.h> |
---|
75 | #endif |
---|
76 | |
---|
77 | #if defined(HPUX_10) || defined(HPUX_9) |
---|
78 | extern "C" int setenv(const char *name, const char *value, int overwrite); |
---|
79 | #endif |
---|
80 | |
---|
81 | #ifdef HAVE_PLURAL |
---|
82 | #include "ring.h" |
---|
83 | #include "gring.h" |
---|
84 | #include "ipconv.h" |
---|
85 | #endif |
---|
86 | |
---|
87 | #ifdef ix86_Win /* only for the DLLTest */ |
---|
88 | /* #include "WinDllTest.h" */ |
---|
89 | #ifdef HAVE_DL |
---|
90 | #include "mod_raw.h" |
---|
91 | #endif |
---|
92 | #endif |
---|
93 | |
---|
94 | // for tests of t-rep-GB |
---|
95 | #include "tgb.h" |
---|
96 | |
---|
97 | // Define to enable many more system commands |
---|
98 | #undef MAKE_DISTRIBUTION |
---|
99 | #ifndef MAKE_DISTRIBUTION |
---|
100 | #define HAVE_EXTENDED_SYSTEM 1 |
---|
101 | #endif |
---|
102 | |
---|
103 | #ifdef HAVE_FACTORY |
---|
104 | #define SI_DONT_HAVE_GLOBAL_VARS |
---|
105 | #include "clapsing.h" |
---|
106 | #include "clapconv.h" |
---|
107 | #include "kstdfac.h" |
---|
108 | #endif |
---|
109 | |
---|
110 | #include "silink.h" |
---|
111 | #include "walk.h" |
---|
112 | |
---|
113 | #include "fast_maps.h" |
---|
114 | |
---|
115 | #ifdef HAVE_EIGENVAL |
---|
116 | #include "eigenval_ip.h" |
---|
117 | #endif |
---|
118 | |
---|
119 | #ifdef HAVE_GMS |
---|
120 | #include "gms.h" |
---|
121 | #endif |
---|
122 | |
---|
123 | /* |
---|
124 | * New function/system-calls that will be included as dynamic module |
---|
125 | * should be inserted here. |
---|
126 | * - without HAVE_DYNAMIC_LOADING: these functions comes as system("...."); |
---|
127 | * - with HAVE_DYNAMIC_LOADING: these functions are loaded as module. |
---|
128 | */ |
---|
129 | //#ifndef HAVE_DYNAMIC_LOADING |
---|
130 | |
---|
131 | #ifdef HAVE_PCV |
---|
132 | #include "pcv.h" |
---|
133 | #endif |
---|
134 | |
---|
135 | //#endif /* not HAVE_DYNAMIC_LOADING */ |
---|
136 | |
---|
137 | #ifdef ix86_Win |
---|
138 | //#include <Python.h> |
---|
139 | //#include <python_wrapper.h> |
---|
140 | #endif |
---|
141 | |
---|
142 | |
---|
143 | // see clapsing.cc for a description of the `FACTORY_*' options |
---|
144 | |
---|
145 | #ifdef FACTORY_GCD_STAT |
---|
146 | #include "gcd_stat.h" |
---|
147 | #endif |
---|
148 | |
---|
149 | #ifdef FACTORY_GCD_TIMING |
---|
150 | #define TIMING |
---|
151 | #include "timing.h" |
---|
152 | TIMING_DEFINE_PRINTPROTO( contentTimer ); |
---|
153 | TIMING_DEFINE_PRINTPROTO( algContentTimer ); |
---|
154 | TIMING_DEFINE_PRINTPROTO( algLcmTimer ); |
---|
155 | #endif |
---|
156 | |
---|
157 | void piShowProcList(); |
---|
158 | #ifndef MAKE_DISTRIBUTION |
---|
159 | static BOOLEAN jjEXTENDED_SYSTEM(leftv res, leftv h); |
---|
160 | #endif |
---|
161 | |
---|
162 | extern BOOLEAN jjJanetBasis(leftv res, leftv v); |
---|
163 | |
---|
164 | #ifdef ix86_Win /* PySingular initialized? */ |
---|
165 | static int PyInitialized = 0; |
---|
166 | #endif |
---|
167 | |
---|
168 | int singular_homog_flag=1; |
---|
169 | |
---|
170 | //void emStart(); |
---|
171 | /*2 |
---|
172 | * the "system" command |
---|
173 | */ |
---|
174 | BOOLEAN jjSYSTEM(leftv res, leftv args) |
---|
175 | { |
---|
176 | if(args->Typ() == STRING_CMD) |
---|
177 | { |
---|
178 | const char *sys_cmd=(char *)(args->Data()); |
---|
179 | leftv h=args->next; |
---|
180 | // ONLY documented system calls go here |
---|
181 | // Undocumented system calls go down into #ifdef HAVE_EXTENDED_SYSTEM |
---|
182 | /*==================== nblocks ==================================*/ |
---|
183 | if (strcmp(sys_cmd, "nblocks") == 0) |
---|
184 | { |
---|
185 | ring r; |
---|
186 | if (h == NULL) |
---|
187 | { |
---|
188 | if (currRingHdl != NULL) |
---|
189 | { |
---|
190 | r = IDRING(currRingHdl); |
---|
191 | } |
---|
192 | else |
---|
193 | { |
---|
194 | WerrorS("no ring active"); |
---|
195 | return TRUE; |
---|
196 | } |
---|
197 | } |
---|
198 | else |
---|
199 | { |
---|
200 | if (h->Typ() != RING_CMD) |
---|
201 | { |
---|
202 | WerrorS("ring expected"); |
---|
203 | return TRUE; |
---|
204 | } |
---|
205 | r = (ring) h->Data(); |
---|
206 | } |
---|
207 | res->rtyp = INT_CMD; |
---|
208 | res->data = (void*) (rBlocks(r) - 1); |
---|
209 | return FALSE; |
---|
210 | } |
---|
211 | /*==================== version ==================================*/ |
---|
212 | if(strcmp(sys_cmd,"version")==0) |
---|
213 | { |
---|
214 | res->rtyp=INT_CMD; |
---|
215 | res->data=(void *)SINGULAR_VERSION; |
---|
216 | return FALSE; |
---|
217 | } |
---|
218 | else |
---|
219 | /*==================== gen ==================================*/ |
---|
220 | if(strcmp(sys_cmd,"gen")==0) |
---|
221 | { |
---|
222 | res->rtyp=INT_CMD; |
---|
223 | res->data=(void *)npGen; |
---|
224 | return FALSE; |
---|
225 | } |
---|
226 | else |
---|
227 | /*==================== sh ==================================*/ |
---|
228 | if(strcmp(sys_cmd,"sh")==0) |
---|
229 | { |
---|
230 | res->rtyp=INT_CMD; |
---|
231 | if (h==NULL) res->data = (void *)system("sh"); |
---|
232 | else if (h->Typ()==STRING_CMD) |
---|
233 | res->data = (void*) system((char*)(h->Data())); |
---|
234 | else |
---|
235 | WerrorS("string expected"); |
---|
236 | return FALSE; |
---|
237 | } |
---|
238 | else |
---|
239 | /*==================== uname ==================================*/ |
---|
240 | if(strcmp(sys_cmd,"uname")==0) |
---|
241 | { |
---|
242 | res->rtyp=STRING_CMD; |
---|
243 | res->data = omStrDup(S_UNAME); |
---|
244 | return FALSE; |
---|
245 | } |
---|
246 | else |
---|
247 | /*==================== with ==================================*/ |
---|
248 | if(strcmp(sys_cmd,"with")==0) |
---|
249 | { |
---|
250 | if (h==NULL) |
---|
251 | { |
---|
252 | res->rtyp=STRING_CMD; |
---|
253 | res->data=(void *)omStrDup(versionString()); |
---|
254 | return FALSE; |
---|
255 | } |
---|
256 | else if (h->Typ()==STRING_CMD) |
---|
257 | { |
---|
258 | #define TEST_FOR(A) if(strcmp(s,A)==0) res->data=(void *)1; else |
---|
259 | char *s=(char *)h->Data(); |
---|
260 | res->rtyp=INT_CMD; |
---|
261 | #ifdef HAVE_DBM |
---|
262 | TEST_FOR("DBM") |
---|
263 | #endif |
---|
264 | #ifdef HAVE_DLD |
---|
265 | TEST_FOR("DLD") |
---|
266 | #endif |
---|
267 | #ifdef HAVE_FACTORY |
---|
268 | TEST_FOR("factory") |
---|
269 | #endif |
---|
270 | #ifdef HAVE_LIBFAC_P |
---|
271 | TEST_FOR("libfac") |
---|
272 | #endif |
---|
273 | #ifdef HAVE_MPSR |
---|
274 | TEST_FOR("MP") |
---|
275 | #endif |
---|
276 | #ifdef HAVE_READLINE |
---|
277 | TEST_FOR("readline") |
---|
278 | #endif |
---|
279 | #ifdef HAVE_TCL |
---|
280 | TEST_FOR("tcl") |
---|
281 | #endif |
---|
282 | #ifdef TEST_MAC_ORDER |
---|
283 | TEST_FOR("MAC_ORDER"); |
---|
284 | #endif |
---|
285 | #ifdef HAVE_NS |
---|
286 | TEST_FOR("Namespaces"); |
---|
287 | #endif |
---|
288 | #ifdef HAVE_DYNAMIC_LOADING |
---|
289 | TEST_FOR("DynamicLoading"); |
---|
290 | #endif |
---|
291 | #ifdef HAVE_EIGENVAL |
---|
292 | TEST_FOR("eigenval"); |
---|
293 | #endif |
---|
294 | #ifdef HAVE_GMS |
---|
295 | TEST_FOR("gms"); |
---|
296 | #endif |
---|
297 | ; |
---|
298 | return FALSE; |
---|
299 | #undef TEST_FOR |
---|
300 | } |
---|
301 | return TRUE; |
---|
302 | } |
---|
303 | else |
---|
304 | /*==================== browsers ==================================*/ |
---|
305 | if (strcmp(sys_cmd,"browsers")==0) |
---|
306 | { |
---|
307 | res->rtyp = STRING_CMD; |
---|
308 | char* b = StringSetS(""); |
---|
309 | feStringAppendBrowsers(0); |
---|
310 | res->data = omStrDup(b); |
---|
311 | return FALSE; |
---|
312 | } |
---|
313 | else |
---|
314 | /*==================== pid ==================================*/ |
---|
315 | if (strcmp(sys_cmd,"pid")==0) |
---|
316 | { |
---|
317 | res->rtyp=INT_CMD; |
---|
318 | #ifndef MSDOS |
---|
319 | res->data=(void *)getpid(); |
---|
320 | #else |
---|
321 | res->data=(void *)1; |
---|
322 | #endif |
---|
323 | return FALSE; |
---|
324 | } |
---|
325 | else |
---|
326 | /*==================== getenv ==================================*/ |
---|
327 | if (strcmp(sys_cmd,"getenv")==0) |
---|
328 | { |
---|
329 | if ((h!=NULL) && (h->Typ()==STRING_CMD)) |
---|
330 | { |
---|
331 | res->rtyp=STRING_CMD; |
---|
332 | char *r=getenv((char *)h->Data()); |
---|
333 | if (r==NULL) r=""; |
---|
334 | res->data=(void *)omStrDup(r); |
---|
335 | return FALSE; |
---|
336 | } |
---|
337 | else |
---|
338 | { |
---|
339 | WerrorS("string expected"); |
---|
340 | return TRUE; |
---|
341 | } |
---|
342 | } |
---|
343 | else |
---|
344 | /*==================== setenv ==================================*/ |
---|
345 | if (strcmp(sys_cmd,"setenv")==0) |
---|
346 | { |
---|
347 | #ifdef HAVE_SETENV |
---|
348 | if (h!=NULL && h->Typ()==STRING_CMD && h->Data() != NULL && |
---|
349 | h->next != NULL && h->next->Typ() == STRING_CMD |
---|
350 | && h->next->Data() != NULL) |
---|
351 | { |
---|
352 | res->rtyp=STRING_CMD; |
---|
353 | setenv((char *)h->Data(), (char *)h->next->Data(), 1); |
---|
354 | res->data=(void *)omStrDup((char *)h->next->Data()); |
---|
355 | feReInitResources(); |
---|
356 | return FALSE; |
---|
357 | } |
---|
358 | else |
---|
359 | { |
---|
360 | WerrorS("two strings expected"); |
---|
361 | return TRUE; |
---|
362 | } |
---|
363 | #else |
---|
364 | WerrorS("setenv not supported on this platform"); |
---|
365 | return TRUE; |
---|
366 | #endif |
---|
367 | } |
---|
368 | else |
---|
369 | /*==================== Singular ==================================*/ |
---|
370 | if (strcmp(sys_cmd, "Singular") == 0) |
---|
371 | { |
---|
372 | res->rtyp=STRING_CMD; |
---|
373 | char *r=feResource("Singular"); |
---|
374 | if (r != NULL) |
---|
375 | res->data = (void*) omStrDup( r ); |
---|
376 | else |
---|
377 | res->data = (void*) omStrDup(""); |
---|
378 | return FALSE; |
---|
379 | } |
---|
380 | else |
---|
381 | /*==================== options ==================================*/ |
---|
382 | if (strstr(sys_cmd, "--") == sys_cmd) |
---|
383 | { |
---|
384 | if (strcmp(sys_cmd, "--") == 0) |
---|
385 | { |
---|
386 | fePrintOptValues(); |
---|
387 | return FALSE; |
---|
388 | } |
---|
389 | |
---|
390 | feOptIndex opt = feGetOptIndex(&sys_cmd[2]); |
---|
391 | if (opt == FE_OPT_UNDEF) |
---|
392 | { |
---|
393 | Werror("Unknown option %s", sys_cmd); |
---|
394 | Werror("Use 'system(\"--\");' for listing of available options"); |
---|
395 | return TRUE; |
---|
396 | } |
---|
397 | |
---|
398 | // for Untyped Options (help version), |
---|
399 | // setting it just triggers action |
---|
400 | if (feOptSpec[opt].type == feOptUntyped) |
---|
401 | { |
---|
402 | feSetOptValue(opt,0); |
---|
403 | return FALSE; |
---|
404 | } |
---|
405 | |
---|
406 | if (h == NULL) |
---|
407 | { |
---|
408 | if (feOptSpec[opt].type == feOptString) |
---|
409 | { |
---|
410 | res->rtyp = STRING_CMD; |
---|
411 | if (feOptSpec[opt].value != NULL) |
---|
412 | res->data = omStrDup((char*) feOptSpec[opt].value); |
---|
413 | else |
---|
414 | res->data = omStrDup(""); |
---|
415 | } |
---|
416 | else |
---|
417 | { |
---|
418 | res->rtyp = INT_CMD; |
---|
419 | res->data = feOptSpec[opt].value; |
---|
420 | } |
---|
421 | return FALSE; |
---|
422 | } |
---|
423 | |
---|
424 | if (h->Typ() != STRING_CMD && |
---|
425 | h->Typ() != INT_CMD) |
---|
426 | { |
---|
427 | Werror("Need string or int argument to set option value"); |
---|
428 | return TRUE; |
---|
429 | } |
---|
430 | char* errormsg; |
---|
431 | if (h->Typ() == INT_CMD) |
---|
432 | { |
---|
433 | if (feOptSpec[opt].type == feOptString) |
---|
434 | { |
---|
435 | Werror("Need string argument to set value of option %s", sys_cmd); |
---|
436 | return TRUE; |
---|
437 | } |
---|
438 | errormsg = feSetOptValue(opt, (int)((long) h->Data())); |
---|
439 | if (errormsg != NULL) |
---|
440 | Werror("Option '--%s=%d' %s", sys_cmd, (int) ((long)h->Data()), errormsg); |
---|
441 | } |
---|
442 | else |
---|
443 | { |
---|
444 | errormsg = feSetOptValue(opt, (char*) h->Data()); |
---|
445 | if (errormsg != NULL) |
---|
446 | Werror("Option '--%s=%s' %s", sys_cmd, (char*) h->Data(), errormsg); |
---|
447 | } |
---|
448 | if (errormsg != NULL) return TRUE; |
---|
449 | return FALSE; |
---|
450 | } |
---|
451 | else |
---|
452 | /*==================== HC ==================================*/ |
---|
453 | if (strcmp(sys_cmd,"HC")==0) |
---|
454 | { |
---|
455 | res->rtyp=INT_CMD; |
---|
456 | res->data=(void *)HCord; |
---|
457 | return FALSE; |
---|
458 | } |
---|
459 | else |
---|
460 | /*==================== random ==================================*/ |
---|
461 | if(strcmp(sys_cmd,"random")==0) |
---|
462 | { |
---|
463 | if ((h!=NULL) &&(h->Typ()==INT_CMD)) |
---|
464 | { |
---|
465 | siRandomStart=(int)((long)h->Data()); |
---|
466 | #ifdef buildin_rand |
---|
467 | siSeed=siRandomStart; |
---|
468 | #else |
---|
469 | srand((unsigned int)siRandomStart); |
---|
470 | #endif |
---|
471 | #ifdef HAVE_FACTORY |
---|
472 | factoryseed(siRandomStart); |
---|
473 | #endif |
---|
474 | return FALSE; |
---|
475 | } |
---|
476 | else if (h != NULL) |
---|
477 | { |
---|
478 | WerrorS("int expected"); |
---|
479 | return TRUE; |
---|
480 | } |
---|
481 | res->rtyp=INT_CMD; |
---|
482 | res->data=(void*) siRandomStart; |
---|
483 | return FALSE; |
---|
484 | } |
---|
485 | /*==================== complexNearZero ======================*/ |
---|
486 | if(strcmp(sys_cmd,"complexNearZero")==0) |
---|
487 | { |
---|
488 | if (h->Typ()==NUMBER_CMD ) |
---|
489 | { |
---|
490 | if ( h->next!=NULL && h->next->Typ()==INT_CMD ) |
---|
491 | { |
---|
492 | if ( !rField_is_long_C() ) |
---|
493 | { |
---|
494 | Werror( "unsupported ground field!"); |
---|
495 | return TRUE; |
---|
496 | } |
---|
497 | else |
---|
498 | { |
---|
499 | res->rtyp=INT_CMD; |
---|
500 | res->data=(void*)complexNearZero((gmp_complex*)h->Data(), |
---|
501 | (int)((long)(h->next->Data()))); |
---|
502 | return FALSE; |
---|
503 | } |
---|
504 | } |
---|
505 | else |
---|
506 | { |
---|
507 | Werror( "expected <int> as third parameter!"); |
---|
508 | return TRUE; |
---|
509 | } |
---|
510 | } |
---|
511 | else |
---|
512 | { |
---|
513 | Werror( "expected <number> as second parameter!"); |
---|
514 | return TRUE; |
---|
515 | } |
---|
516 | } |
---|
517 | /*==================== getPrecDigits ======================*/ |
---|
518 | if(strcmp(sys_cmd,"getPrecDigits")==0) |
---|
519 | { |
---|
520 | if ( !rField_is_long_C() && !rField_is_long_R() ) |
---|
521 | { |
---|
522 | Werror( "unsupported ground field!"); |
---|
523 | return TRUE; |
---|
524 | } |
---|
525 | res->rtyp=INT_CMD; |
---|
526 | res->data=(void*)getGMPFloatDigits(); |
---|
527 | return FALSE; |
---|
528 | } |
---|
529 | /*==================== neworder =============================*/ |
---|
530 | // should go below |
---|
531 | #ifdef HAVE_LIBFAC_P |
---|
532 | if(strcmp(sys_cmd,"neworder")==0) |
---|
533 | { |
---|
534 | if ((h!=NULL) &&(h->Typ()==IDEAL_CMD)) |
---|
535 | { |
---|
536 | res->rtyp=STRING_CMD; |
---|
537 | res->data=(void *)singclap_neworder((ideal)h->Data()); |
---|
538 | return FALSE; |
---|
539 | } |
---|
540 | else |
---|
541 | WerrorS("ideal expected"); |
---|
542 | } |
---|
543 | else |
---|
544 | #endif |
---|
545 | //#ifndef HAVE_DYNAMIC_LOADING |
---|
546 | /*==================== pcv ==================================*/ |
---|
547 | #ifdef HAVE_PCV |
---|
548 | if(strcmp(sys_cmd,"pcvLAddL")==0) |
---|
549 | { |
---|
550 | return pcvLAddL(res,h); |
---|
551 | } |
---|
552 | else |
---|
553 | if(strcmp(sys_cmd,"pcvPMulL")==0) |
---|
554 | { |
---|
555 | return pcvPMulL(res,h); |
---|
556 | } |
---|
557 | else |
---|
558 | if(strcmp(sys_cmd,"pcvMinDeg")==0) |
---|
559 | { |
---|
560 | return pcvMinDeg(res,h); |
---|
561 | } |
---|
562 | else |
---|
563 | if(strcmp(sys_cmd,"pcvP2CV")==0) |
---|
564 | { |
---|
565 | return pcvP2CV(res,h); |
---|
566 | } |
---|
567 | else |
---|
568 | if(strcmp(sys_cmd,"pcvCV2P")==0) |
---|
569 | { |
---|
570 | return pcvCV2P(res,h); |
---|
571 | } |
---|
572 | else |
---|
573 | if(strcmp(sys_cmd,"pcvDim")==0) |
---|
574 | { |
---|
575 | return pcvDim(res,h); |
---|
576 | } |
---|
577 | else |
---|
578 | if(strcmp(sys_cmd,"pcvBasis")==0) |
---|
579 | { |
---|
580 | return pcvBasis(res,h); |
---|
581 | } |
---|
582 | else |
---|
583 | #endif |
---|
584 | /*==================== eigenvalues ==================================*/ |
---|
585 | #ifdef HAVE_EIGENVAL |
---|
586 | if(strcmp(sys_cmd,"hessenberg")==0) |
---|
587 | { |
---|
588 | return evHessenberg(res,h); |
---|
589 | } |
---|
590 | else |
---|
591 | if(strcmp(sys_cmd,"eigenvals")==0) |
---|
592 | { |
---|
593 | return evEigenvals(res,h); |
---|
594 | } |
---|
595 | else |
---|
596 | #endif |
---|
597 | /*==================== Gauss-Manin system ==================================*/ |
---|
598 | #ifdef HAVE_GMS |
---|
599 | if(strcmp(sys_cmd,"gmsnf")==0) |
---|
600 | { |
---|
601 | return gmsNF(res,h); |
---|
602 | } |
---|
603 | else |
---|
604 | #endif |
---|
605 | //#endif /* HAVE_DYNAMIC_LOADING */ |
---|
606 | /*==================== contributors =============================*/ |
---|
607 | if(strcmp(sys_cmd,"contributors") == 0) |
---|
608 | { |
---|
609 | res->rtyp=STRING_CMD; |
---|
610 | res->data=(void *)omStrDup( |
---|
611 | "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"); |
---|
612 | return FALSE; |
---|
613 | } |
---|
614 | else |
---|
615 | /*==================== spectrum =============================*/ |
---|
616 | #ifdef HAVE_SPECTRUM |
---|
617 | if(strcmp(sys_cmd,"spectrum") == 0) |
---|
618 | { |
---|
619 | if (h->Typ()!=POLY_CMD) |
---|
620 | { |
---|
621 | WerrorS("poly expected"); |
---|
622 | return TRUE; |
---|
623 | } |
---|
624 | if (h->next==NULL) |
---|
625 | return spectrumProc(res,h); |
---|
626 | if (h->next->Typ()!=INT_CMD) |
---|
627 | { |
---|
628 | WerrorS("poly,int expected"); |
---|
629 | return TRUE; |
---|
630 | } |
---|
631 | if(((long)h->next->Data())==1L) |
---|
632 | return spectrumfProc(res,h); |
---|
633 | return spectrumProc(res,h); |
---|
634 | } |
---|
635 | else |
---|
636 | /*==================== semic =============================*/ |
---|
637 | if(strcmp(sys_cmd,"semic") == 0) |
---|
638 | { |
---|
639 | if ((h->next!=NULL) |
---|
640 | && (h->Typ()==LIST_CMD) |
---|
641 | && (h->next->Typ()==LIST_CMD)) |
---|
642 | { |
---|
643 | if (h->next->next==NULL) |
---|
644 | return semicProc(res,h,h->next); |
---|
645 | else if (h->next->next->Typ()==INT_CMD) |
---|
646 | return semicProc3(res,h,h->next,h->next->next); |
---|
647 | } |
---|
648 | return TRUE; |
---|
649 | } |
---|
650 | else |
---|
651 | /*==================== spadd =============================*/ |
---|
652 | if(strcmp(sys_cmd,"spadd") == 0) |
---|
653 | { |
---|
654 | if ((h->next!=NULL) |
---|
655 | && (h->Typ()==LIST_CMD) |
---|
656 | && (h->next->Typ()==LIST_CMD)) |
---|
657 | { |
---|
658 | if (h->next->next==NULL) |
---|
659 | return spaddProc(res,h,h->next); |
---|
660 | } |
---|
661 | return TRUE; |
---|
662 | } |
---|
663 | else |
---|
664 | /*==================== spmul =============================*/ |
---|
665 | if(strcmp(sys_cmd,"spmul") == 0) |
---|
666 | { |
---|
667 | if ((h->next!=NULL) |
---|
668 | && (h->Typ()==LIST_CMD) |
---|
669 | && (h->next->Typ()==INT_CMD)) |
---|
670 | { |
---|
671 | if (h->next->next==NULL) |
---|
672 | return spmulProc(res,h,h->next); |
---|
673 | } |
---|
674 | return TRUE; |
---|
675 | } |
---|
676 | else |
---|
677 | #endif |
---|
678 | #ifdef HAVE_PLURAL |
---|
679 | /*==================== Approx_Step =================*/ |
---|
680 | if (strcmp(sys_cmd, "astep") == 0) |
---|
681 | { |
---|
682 | ideal I; |
---|
683 | if ((h!=NULL) && (h->Typ()==IDEAL_CMD)) |
---|
684 | { |
---|
685 | I=(ideal)h->CopyD(); |
---|
686 | res->rtyp=IDEAL_CMD; |
---|
687 | if (rIsPluralRing(currRing)) res->data=Approx_Step(I); |
---|
688 | else res->data=I; |
---|
689 | setFlag(res,FLAG_STD); |
---|
690 | } |
---|
691 | else return TRUE; |
---|
692 | return FALSE; |
---|
693 | } |
---|
694 | /*==================== PrintMat =================*/ |
---|
695 | if (strcmp(sys_cmd, "PrintMat") == 0) |
---|
696 | { |
---|
697 | int a; |
---|
698 | int b; |
---|
699 | ring r; |
---|
700 | int metric; |
---|
701 | if ((h!=NULL) && (h->Typ()==INT_CMD)) |
---|
702 | { |
---|
703 | a=(int)((long)(h->Data())); |
---|
704 | h=h->next; |
---|
705 | } |
---|
706 | else return TRUE; |
---|
707 | if ((h!=NULL) && (h->Typ()==INT_CMD)) |
---|
708 | { |
---|
709 | b=(int)((long)(h->Data())); |
---|
710 | h=h->next; |
---|
711 | } |
---|
712 | else return TRUE; |
---|
713 | if ((h!=NULL) && (h->Typ()==RING_CMD)) |
---|
714 | { |
---|
715 | r=(ring)h->Data(); |
---|
716 | h=h->next; |
---|
717 | } |
---|
718 | else return TRUE; |
---|
719 | if ((h!=NULL) && (h->Typ()==INT_CMD)) |
---|
720 | { |
---|
721 | metric=(int)((long)(h->Data())); |
---|
722 | } |
---|
723 | res->rtyp=MATRIX_CMD; |
---|
724 | if (rIsPluralRing(r)) res->data=nc_PrintMat(a,b,r,metric); |
---|
725 | else res->data=NULL; |
---|
726 | return FALSE; |
---|
727 | } |
---|
728 | /*==================== twostd =================*/ |
---|
729 | if (strcmp(sys_cmd, "twostd") == 0) |
---|
730 | { |
---|
731 | ideal I; |
---|
732 | if ((h!=NULL) && (h->Typ()==IDEAL_CMD)) |
---|
733 | { |
---|
734 | I=(ideal)h->CopyD(); |
---|
735 | res->rtyp=IDEAL_CMD; |
---|
736 | if (rIsPluralRing(currRing)) res->data=twostd(I); |
---|
737 | else res->data=I; |
---|
738 | setFlag(res,FLAG_TWOSTD); |
---|
739 | setFlag(res,FLAG_STD); |
---|
740 | } |
---|
741 | else return TRUE; |
---|
742 | return FALSE; |
---|
743 | } |
---|
744 | /*==================== lie bracket =================*/ |
---|
745 | if (strcmp(sys_cmd, "bracket") == 0) |
---|
746 | { |
---|
747 | poly p; |
---|
748 | poly q; |
---|
749 | if ((h!=NULL) && (h->Typ()==POLY_CMD)) |
---|
750 | { |
---|
751 | p=(poly)h->CopyD(); |
---|
752 | h=h->next; |
---|
753 | } |
---|
754 | else return TRUE; |
---|
755 | if ((h!=NULL) && (h->Typ()==POLY_CMD)) |
---|
756 | { |
---|
757 | q=(poly)h->Data(); |
---|
758 | } |
---|
759 | else return TRUE; |
---|
760 | res->rtyp=POLY_CMD; |
---|
761 | if (rIsPluralRing(currRing)) res->data=nc_p_Bracket_qq(p,q); |
---|
762 | else res->data=NULL; |
---|
763 | return FALSE; |
---|
764 | } |
---|
765 | /*==================== PLURAL =================*/ |
---|
766 | if (strcmp(sys_cmd, "PLURAL") == 0) |
---|
767 | { |
---|
768 | matrix C; |
---|
769 | matrix D; |
---|
770 | number nN; |
---|
771 | poly pN; |
---|
772 | int i,j; |
---|
773 | sleftv tmp_v; |
---|
774 | memset(&tmp_v,0,sizeof(tmp_v)); |
---|
775 | |
---|
776 | if (currRing->nc==NULL) |
---|
777 | { |
---|
778 | currRing->nc=(nc_struct *)omAlloc0(sizeof(nc_struct)); |
---|
779 | currRing->nc->ref=1; |
---|
780 | currRing->nc->basering=currRing; |
---|
781 | } |
---|
782 | else |
---|
783 | { |
---|
784 | WarnS("redefining algebra structure"); |
---|
785 | if (currRing->nc->ref>1) // in use by somebody else |
---|
786 | currRing->nc->ref--; |
---|
787 | else |
---|
788 | ncKill(currRing); /* kill the previous nc data */ |
---|
789 | currRing->nc=(nc_struct *)omAlloc0(sizeof(nc_struct)); |
---|
790 | currRing->nc->ref=1; |
---|
791 | currRing->nc->basering=currRing; |
---|
792 | } |
---|
793 | currRing->nc->type=nc_general; |
---|
794 | /* C is either a poly (coeff - an int or a number) or a matrix */ |
---|
795 | if (h==NULL) return TRUE; |
---|
796 | leftv hh=h->next; |
---|
797 | h->next=NULL; |
---|
798 | switch(h->Typ()) |
---|
799 | { |
---|
800 | case MATRIX_CMD: { C=(matrix)h->CopyD(); break; } |
---|
801 | |
---|
802 | case INT_CMD: case NUMBER_CMD: |
---|
803 | { |
---|
804 | i=iiTestConvert(h->Typ(), POLY_CMD); |
---|
805 | if (i==0) |
---|
806 | { |
---|
807 | Werror("cannot convert to poly"); |
---|
808 | return TRUE; |
---|
809 | } |
---|
810 | iiConvert(h->Typ(), POLY_CMD, i, h, &tmp_v); |
---|
811 | pN=(poly)tmp_v.Data(); |
---|
812 | break; |
---|
813 | } |
---|
814 | |
---|
815 | case POLY_CMD: {pN=(poly)h->Data(); break;} |
---|
816 | |
---|
817 | default: return TRUE; |
---|
818 | } |
---|
819 | if (h->Typ()==MATRIX_CMD) |
---|
820 | { |
---|
821 | currRing->nc->type=nc_undef; /* to analyze later ! */ |
---|
822 | // currRing->nc->IsSkewConstant=NULL; |
---|
823 | } |
---|
824 | else |
---|
825 | { |
---|
826 | nN=pGetCoeff(pN); // pN is not NULL anyway |
---|
827 | if (nIsZero(nN)) |
---|
828 | { |
---|
829 | Werror("zero coefficients are not allowed"); |
---|
830 | return TRUE; |
---|
831 | } |
---|
832 | if (nIsOne(nN)) currRing->nc->type=nc_lie; |
---|
833 | else currRing->nc->type=nc_skew; |
---|
834 | currRing->nc->IsSkewConstant=1; |
---|
835 | /* create matrix C */ |
---|
836 | C=mpNew(currRing->N,currRing->N); |
---|
837 | for(i=1;i<currRing->N;i++) |
---|
838 | { |
---|
839 | for(j=i+1;j<=currRing->N;j++) |
---|
840 | { |
---|
841 | MATELEM(C,i,j) = nc_p_CopyPut(pN,currRing); |
---|
842 | // MATELEM(C,i,j)=pCopy(pN); |
---|
843 | } |
---|
844 | } |
---|
845 | } |
---|
846 | pN=NULL; |
---|
847 | h=hh; |
---|
848 | /* D is either a poly or a matrix */ |
---|
849 | if (h==NULL) { pN=NULL;} /* D is zero matrix */ |
---|
850 | else |
---|
851 | { |
---|
852 | switch(h->Typ()) |
---|
853 | { |
---|
854 | case MATRIX_CMD: { D=(matrix)h->CopyD(); break;} |
---|
855 | |
---|
856 | case INT_CMD: case NUMBER_CMD: |
---|
857 | { |
---|
858 | i=iiTestConvert(h->Typ(), POLY_CMD); |
---|
859 | if (i==0) |
---|
860 | { |
---|
861 | Werror("cannot convert to poly"); |
---|
862 | return TRUE; |
---|
863 | } |
---|
864 | iiConvert(h->Typ(), POLY_CMD, i, h, &tmp_v); |
---|
865 | pN=(poly)tmp_v.Data(); |
---|
866 | break; |
---|
867 | } |
---|
868 | |
---|
869 | case POLY_CMD: { pN=(poly)h->Data();break;} |
---|
870 | |
---|
871 | default: return TRUE; |
---|
872 | } |
---|
873 | } /* end else h==NULL */ |
---|
874 | if (pN==NULL) |
---|
875 | { |
---|
876 | if (currRing->nc->type==nc_lie) |
---|
877 | { |
---|
878 | currRing->nc->type=nc_skew; /* even commutative! */ |
---|
879 | } |
---|
880 | } |
---|
881 | else |
---|
882 | { |
---|
883 | if (currRing->nc->type==nc_skew) currRing->nc->type=nc_general; |
---|
884 | } /* end pN==NULL */ |
---|
885 | if (h==NULL) |
---|
886 | { |
---|
887 | WerrorS("expected `system(\"PLURAL\",<matrix>,<matrix>)`"); |
---|
888 | idDelete((ideal *)&(currRing->nc->C)); |
---|
889 | omFreeSize((ADDRESS)currRing->nc,sizeof(nc_struct)); |
---|
890 | currRing->nc=NULL; |
---|
891 | return TRUE; |
---|
892 | } |
---|
893 | if (h->Typ()!=MATRIX_CMD) |
---|
894 | { |
---|
895 | D=mpNew(currRing->N,currRing->N); |
---|
896 | /* create matrix D */ |
---|
897 | for(i=1;i<currRing->N;i++) |
---|
898 | { |
---|
899 | for(j=i+1;j<=currRing->N;j++) |
---|
900 | { |
---|
901 | MATELEM(D,i,j) = nc_p_CopyPut(pN,currRing); |
---|
902 | // MATELEM(D,i,j)=pCopy(pN); |
---|
903 | } |
---|
904 | } |
---|
905 | } |
---|
906 | else currRing->nc->type=nc_undef; |
---|
907 | tmp_v.CleanUp(); |
---|
908 | pN=NULL; |
---|
909 | /* Now we proceed with C and D */ |
---|
910 | matrix COM; |
---|
911 | currRing->nc->MT=(matrix *)omAlloc0(currRing->N*(currRing->N-1)/2*sizeof(matrix)); |
---|
912 | currRing->nc->MTsize=(int *)omAlloc0(currRing->N*(currRing->N-1)/2*sizeof(int)); |
---|
913 | currRing->nc->C=C; |
---|
914 | currRing->nc->D=D; |
---|
915 | COM=mpCopy(currRing->nc->C); |
---|
916 | poly p; |
---|
917 | short DefMTsize=7; |
---|
918 | int tmpIsSkewConstant=1; |
---|
919 | int IsNonComm=0; |
---|
920 | pN=nc_p_CopyGet(MATELEM(currRing->nc->C,1,2),currRing); |
---|
921 | // pN=MATELEM(currRing->nc->C,1,2); |
---|
922 | |
---|
923 | for(i=1;i<currRing->N;i++) |
---|
924 | { |
---|
925 | for(j=i+1;j<=currRing->N;j++) |
---|
926 | { |
---|
927 | if (MATELEM(currRing->nc->C,i,j)==NULL) |
---|
928 | { |
---|
929 | Werror("Incorrect input : matrix of coefficients contains zeros in the upper triangle!"); |
---|
930 | return TRUE; |
---|
931 | } |
---|
932 | if (!nEqual(pGetCoeff(pN),pGetCoeff(MATELEM(currRing->nc->C,i,j)))) tmpIsSkewConstant=0; |
---|
933 | if (MATELEM(currRing->nc->D,i,j)==NULL) /* quasicommutative case */ |
---|
934 | { |
---|
935 | currRing->nc->MTsize[UPMATELEM(i,j,currRing->N)]=1; |
---|
936 | /* 1x1 mult.matrix */ |
---|
937 | currRing->nc->MT[UPMATELEM(i,j,currRing->N)]=mpNew(1,1); |
---|
938 | } |
---|
939 | else /* pure noncommutative case*/ |
---|
940 | { |
---|
941 | IsNonComm=1; |
---|
942 | MATELEM(COM,i,j)=NULL; |
---|
943 | currRing->nc->MTsize[UPMATELEM(i,j,currRing->N)]=DefMTsize; /* default sizes */ |
---|
944 | currRing->nc->MT[UPMATELEM(i,j,currRing->N)]=mpNew(DefMTsize,DefMTsize); |
---|
945 | } |
---|
946 | p=pOne(); |
---|
947 | pSetCoeff(p,nCopy(pGetCoeff(MATELEM(currRing->nc->C,i,j)))); |
---|
948 | pSetExp(p,i,1); |
---|
949 | pSetExp(p,j,1); |
---|
950 | pSetm(p); |
---|
951 | // p=pAdd(p,pCopy(MATELEM(currRing->nc->D,i,j))); |
---|
952 | p=pAdd(p,nc_p_CopyGet(MATELEM(currRing->nc->D,i,j),currRing)); |
---|
953 | // MATELEM(currRing->nc->MT[UPMATELEM(i,j,currRing->N)],1,1)=p; |
---|
954 | MATELEM(currRing->nc->MT[UPMATELEM(i,j,currRing->N)],1,1)=nc_p_CopyPut(p,currRing); |
---|
955 | pDelete(&p); |
---|
956 | p=NULL; |
---|
957 | } |
---|
958 | /* set MT[i,j,1,1] to c_i_j*x_i*x_j + D_i_j */ |
---|
959 | } |
---|
960 | if (currRing->nc->type==nc_undef) |
---|
961 | { |
---|
962 | if (IsNonComm==1) |
---|
963 | { |
---|
964 | assume(pN!=NULL); |
---|
965 | if ((tmpIsSkewConstant==1) && (nIsOne(pGetCoeff(pN)))) currRing->nc->type=nc_lie; |
---|
966 | else currRing->nc->type=nc_general; |
---|
967 | } |
---|
968 | if (IsNonComm==0) |
---|
969 | { |
---|
970 | currRing->nc->type=nc_skew; /* could be also commutative */ |
---|
971 | currRing->nc->IsSkewConstant=tmpIsSkewConstant; |
---|
972 | } |
---|
973 | } |
---|
974 | currRing->nc->COM=COM; |
---|
975 | return FALSE; |
---|
976 | } |
---|
977 | else |
---|
978 | /*==================== opp ==================================*/ |
---|
979 | if (strcmp(sys_cmd, "opp")==0) |
---|
980 | { |
---|
981 | if ((h!=NULL) && (h->Typ()==RING_CMD)) |
---|
982 | { |
---|
983 | ring r=(ring)h->Data(); |
---|
984 | res->data=rOpposite(r); |
---|
985 | res->rtyp=RING_CMD; |
---|
986 | return FALSE; |
---|
987 | } |
---|
988 | else |
---|
989 | { |
---|
990 | WerrorS("`system(\"opp\",<ring>)` expected"); |
---|
991 | return TRUE; |
---|
992 | } |
---|
993 | } |
---|
994 | else |
---|
995 | /*==================== env ==================================*/ |
---|
996 | if (strcmp(sys_cmd, "env")==0) |
---|
997 | { |
---|
998 | if ((h!=NULL) && (h->Typ()==RING_CMD)) |
---|
999 | { |
---|
1000 | ring r = (ring)h->Data(); |
---|
1001 | res->data = rEnvelope(r); |
---|
1002 | res->rtyp = RING_CMD; |
---|
1003 | return FALSE; |
---|
1004 | } |
---|
1005 | else |
---|
1006 | { |
---|
1007 | WerrorS("`system(\"env\",<ring>)` expected"); |
---|
1008 | return TRUE; |
---|
1009 | } |
---|
1010 | } |
---|
1011 | else |
---|
1012 | /*==================== oppose ==================================*/ |
---|
1013 | if (strcmp(sys_cmd, "oppose")==0) |
---|
1014 | { |
---|
1015 | ring Rop; |
---|
1016 | if ((h!=NULL) && (h->Typ()==RING_CMD)) |
---|
1017 | { |
---|
1018 | Rop = (ring)h->Data(); |
---|
1019 | h = h->next; |
---|
1020 | } |
---|
1021 | if ((h!=NULL)) |
---|
1022 | { |
---|
1023 | idhdl w; |
---|
1024 | if ((w=Rop->idroot->get(h->Name(),myynest))!=NULL) |
---|
1025 | { |
---|
1026 | poly p = (poly)IDDATA(w); |
---|
1027 | res->data = pOppose(Rop,p); |
---|
1028 | res->rtyp = POLY_CMD; |
---|
1029 | return FALSE; |
---|
1030 | } |
---|
1031 | } |
---|
1032 | else |
---|
1033 | { |
---|
1034 | WerrorS("`system(\"oppose\",<ring>,<poly>)` expected"); |
---|
1035 | return TRUE; |
---|
1036 | } |
---|
1037 | } |
---|
1038 | else |
---|
1039 | #endif |
---|
1040 | #ifdef HAVE_WALK |
---|
1041 | /*==================== walk stuff =================*/ |
---|
1042 | #ifdef OWNW |
---|
1043 | if (strcmp(sys_cmd, "walkNextWeight") == 0) |
---|
1044 | { |
---|
1045 | if (h == NULL || h->Typ() != INTVEC_CMD || |
---|
1046 | h->next == NULL || h->next->Typ() != INTVEC_CMD || |
---|
1047 | h->next->next == NULL || h->next->next->Typ() != IDEAL_CMD) |
---|
1048 | { |
---|
1049 | Werror("system(\"walkNextWeight\", intvec, intvec, ideal) expected"); |
---|
1050 | return TRUE; |
---|
1051 | } |
---|
1052 | |
---|
1053 | if (((intvec*) h->Data())->length() != currRing->N || |
---|
1054 | ((intvec*) h->next->Data())->length() != currRing->N) |
---|
1055 | { |
---|
1056 | Werror("system(\"walkNextWeight\" ...) intvecs not of length %d\n", |
---|
1057 | currRing->N); |
---|
1058 | return TRUE; |
---|
1059 | } |
---|
1060 | res->data = (void*) walkNextWeight(((intvec*) h->Data()), |
---|
1061 | ((intvec*) h->next->Data()), |
---|
1062 | (ideal) h->next->next->Data()); |
---|
1063 | if (res->data == (void*) 0 || res->data == (void*) 1) |
---|
1064 | { |
---|
1065 | res->rtyp = INT_CMD; |
---|
1066 | } |
---|
1067 | else |
---|
1068 | { |
---|
1069 | res->rtyp = INTVEC_CMD; |
---|
1070 | } |
---|
1071 | return FALSE; |
---|
1072 | } |
---|
1073 | else if (strcmp(sys_cmd, "walkInitials") == 0) |
---|
1074 | { |
---|
1075 | if (h == NULL || h->Typ() != IDEAL_CMD) |
---|
1076 | { |
---|
1077 | WerrorS("system(\"walkInitials\", ideal) expected"); |
---|
1078 | return TRUE; |
---|
1079 | } |
---|
1080 | |
---|
1081 | res->data = (void*) walkInitials((ideal) h->Data()); |
---|
1082 | res->rtyp = IDEAL_CMD; |
---|
1083 | return FALSE; |
---|
1084 | } |
---|
1085 | else |
---|
1086 | #endif |
---|
1087 | #ifdef WAIV |
---|
1088 | if (strcmp(sys_cmd, "walkAddIntVec") == 0) |
---|
1089 | { |
---|
1090 | if (h == NULL || h->Typ() != INTVEC_CMD || |
---|
1091 | h->next == NULL || h->next->Typ() != INTVEC_CMD) |
---|
1092 | { |
---|
1093 | WerrorS("system(\"walkAddIntVec\", intvec, intvec) expected"); |
---|
1094 | return TRUE; |
---|
1095 | } |
---|
1096 | intvec* arg1 = (intvec*) h->Data(); |
---|
1097 | intvec* arg2 = (intvec*) h->next->Data(); |
---|
1098 | |
---|
1099 | |
---|
1100 | res->data = (intvec*) walkAddIntVec(arg1, arg2); |
---|
1101 | res->rtyp = INTVEC_CMD; |
---|
1102 | return FALSE; |
---|
1103 | } |
---|
1104 | else |
---|
1105 | #endif |
---|
1106 | #ifdef MwaklNextWeight |
---|
1107 | if (strcmp(sys_cmd, "MwalkNextWeight") == 0) |
---|
1108 | { |
---|
1109 | if (h == NULL || h->Typ() != INTVEC_CMD || |
---|
1110 | h->next == NULL || h->next->Typ() != INTVEC_CMD || |
---|
1111 | h->next->next == NULL || h->next->next->Typ() != IDEAL_CMD) |
---|
1112 | { |
---|
1113 | Werror("system(\"MwalkNextWeight\", intvec, intvec, ideal) expected"); |
---|
1114 | return TRUE; |
---|
1115 | } |
---|
1116 | |
---|
1117 | if (((intvec*) h->Data())->length() != currRing->N || |
---|
1118 | ((intvec*) h->next->Data())->length() != currRing->N) |
---|
1119 | { |
---|
1120 | Werror("system(\"MwalkNextWeight\" ...) intvecs not of length %d\n", |
---|
1121 | currRing->N); |
---|
1122 | return TRUE; |
---|
1123 | } |
---|
1124 | intvec* arg1 = (intvec*) h->Data(); |
---|
1125 | intvec* arg2 = (intvec*) h->next->Data(); |
---|
1126 | ideal arg3 = (ideal) h->next->next->Data(); |
---|
1127 | |
---|
1128 | intvec* result = (intvec*) MwalkNextWeight(arg1, arg2, arg3); |
---|
1129 | |
---|
1130 | res->rtyp = INTVEC_CMD; |
---|
1131 | res->data = result; |
---|
1132 | |
---|
1133 | return FALSE; |
---|
1134 | } |
---|
1135 | else |
---|
1136 | #endif //MWalkNextWeight |
---|
1137 | if(strcmp(sys_cmd, "Mivdp") == 0) |
---|
1138 | { |
---|
1139 | if (h == NULL || h->Typ() != INT_CMD) |
---|
1140 | { |
---|
1141 | Werror("system(\"Mivdp\", int) expected"); |
---|
1142 | return TRUE; |
---|
1143 | } |
---|
1144 | if ((int) ((long)(h->Data())) != currRing->N) |
---|
1145 | { |
---|
1146 | Werror("system(\"Mivdp\" ...) intvecs not of length %d\n", |
---|
1147 | currRing->N); |
---|
1148 | return TRUE; |
---|
1149 | } |
---|
1150 | int arg1 = (int) ((long)(h->Data())); |
---|
1151 | |
---|
1152 | intvec* result = (intvec*) Mivdp(arg1); |
---|
1153 | |
---|
1154 | res->rtyp = INTVEC_CMD; |
---|
1155 | res->data = result; |
---|
1156 | |
---|
1157 | return FALSE; |
---|
1158 | } |
---|
1159 | |
---|
1160 | else if(strcmp(sys_cmd, "Mivlp") == 0) |
---|
1161 | { |
---|
1162 | if (h == NULL || h->Typ() != INT_CMD) |
---|
1163 | { |
---|
1164 | Werror("system(\"Mivlp\", int) expected"); |
---|
1165 | return TRUE; |
---|
1166 | } |
---|
1167 | if ((int) ((long)(h->Data())) != currRing->N) |
---|
1168 | { |
---|
1169 | Werror("system(\"Mivlp\" ...) intvecs not of length %d\n", |
---|
1170 | currRing->N); |
---|
1171 | return TRUE; |
---|
1172 | } |
---|
1173 | int arg1 = (int) ((long)(h->Data())); |
---|
1174 | |
---|
1175 | intvec* result = (intvec*) Mivlp(arg1); |
---|
1176 | |
---|
1177 | res->rtyp = INTVEC_CMD; |
---|
1178 | res->data = result; |
---|
1179 | |
---|
1180 | return FALSE; |
---|
1181 | } |
---|
1182 | else |
---|
1183 | #ifdef MpDiv |
---|
1184 | if(strcmp(sys_cmd, "MpDiv") == 0) |
---|
1185 | { |
---|
1186 | if(h==NULL || h->Typ() != POLY_CMD || |
---|
1187 | h->next == NULL || h->next->Typ() != POLY_CMD) |
---|
1188 | { |
---|
1189 | Werror("system(\"MpDiv\",poly, poly) expected"); |
---|
1190 | return TRUE; |
---|
1191 | } |
---|
1192 | poly arg1 = (poly) h->Data(); |
---|
1193 | poly arg2 = (poly) h->next->Data(); |
---|
1194 | |
---|
1195 | poly result = MpDiv(arg1, arg2); |
---|
1196 | |
---|
1197 | res->rtyp = POLY_CMD; |
---|
1198 | res->data = result; |
---|
1199 | return FALSE; |
---|
1200 | } |
---|
1201 | else |
---|
1202 | #endif |
---|
1203 | #ifdef MpMult |
---|
1204 | if(strcmp(sys_cmd, "MpMult") == 0) |
---|
1205 | { |
---|
1206 | if(h==NULL || h->Typ() != POLY_CMD || |
---|
1207 | h->next == NULL || h->next->Typ() != POLY_CMD) |
---|
1208 | { |
---|
1209 | Werror("system(\"MpMult\",poly, poly) expected"); |
---|
1210 | return TRUE; |
---|
1211 | } |
---|
1212 | poly arg1 = (poly) h->Data(); |
---|
1213 | poly arg2 = (poly) h->next->Data(); |
---|
1214 | |
---|
1215 | poly result = MpMult(arg1, arg2); |
---|
1216 | res->rtyp = POLY_CMD; |
---|
1217 | res->data = result; |
---|
1218 | return FALSE; |
---|
1219 | } |
---|
1220 | else |
---|
1221 | #endif |
---|
1222 | if (strcmp(sys_cmd, "MivSame") == 0) |
---|
1223 | { |
---|
1224 | if(h == NULL || h->Typ() != INTVEC_CMD || |
---|
1225 | h->next == NULL || h->next->Typ() != INTVEC_CMD ) |
---|
1226 | { |
---|
1227 | Werror("system(\"MivSame\", intvec, intvec) expected"); |
---|
1228 | return TRUE; |
---|
1229 | } |
---|
1230 | /* |
---|
1231 | if (((intvec*) h->Data())->length() != currRing->N || |
---|
1232 | ((intvec*) h->next->Data())->length() != currRing->N) |
---|
1233 | { |
---|
1234 | Werror("system(\"MivSame\" ...) intvecs not of length %d\n", |
---|
1235 | currRing->N); |
---|
1236 | return TRUE; |
---|
1237 | } |
---|
1238 | */ |
---|
1239 | intvec* arg1 = (intvec*) h->Data(); |
---|
1240 | intvec* arg2 = (intvec*) h->next->Data(); |
---|
1241 | /* |
---|
1242 | poly result = (poly) MivSame(arg1, arg2); |
---|
1243 | |
---|
1244 | res->rtyp = POLY_CMD; |
---|
1245 | res->data = (poly) result; |
---|
1246 | */ |
---|
1247 | res->rtyp = INT_CMD; res->data = (void*) MivSame(arg1, arg2); |
---|
1248 | return FALSE; |
---|
1249 | } |
---|
1250 | else |
---|
1251 | if (strcmp(sys_cmd, "M3ivSame") == 0) |
---|
1252 | { |
---|
1253 | if(h == NULL || h->Typ() != INTVEC_CMD || |
---|
1254 | h->next == NULL || h->next->Typ() != INTVEC_CMD || |
---|
1255 | h->next->next == NULL || h->next->next->Typ() != INTVEC_CMD ) |
---|
1256 | { |
---|
1257 | Werror("system(\"M3ivSame\", intvec, intvec, intvec) expected"); |
---|
1258 | return TRUE; |
---|
1259 | } |
---|
1260 | /* |
---|
1261 | if (((intvec*) h->Data())->length() != currRing->N || |
---|
1262 | ((intvec*) h->next->Data())->length() != currRing->N || |
---|
1263 | ((intvec*) h->next->next->Data())->length() != currRing->N ) |
---|
1264 | { |
---|
1265 | Werror("system(\"M3ivSame\" ...) intvecs not of length %d\n", |
---|
1266 | currRing->N); |
---|
1267 | return TRUE; |
---|
1268 | } |
---|
1269 | */ |
---|
1270 | intvec* arg1 = (intvec*) h->Data(); |
---|
1271 | intvec* arg2 = (intvec*) h->next->Data(); |
---|
1272 | intvec* arg3 = (intvec*) h->next->next->Data(); |
---|
1273 | /* |
---|
1274 | poly result = (poly) M3ivSame(arg1, arg2, arg3); |
---|
1275 | |
---|
1276 | res->rtyp = POLY_CMD; |
---|
1277 | res->data = (poly) result; |
---|
1278 | */ |
---|
1279 | res->rtyp = INT_CMD;res->data = (void*) M3ivSame(arg1, arg2, arg3); |
---|
1280 | return FALSE; |
---|
1281 | } |
---|
1282 | else |
---|
1283 | if(strcmp(sys_cmd, "MwalkInitialForm") == 0) |
---|
1284 | { |
---|
1285 | if(h == NULL || h->Typ() != IDEAL_CMD || |
---|
1286 | h->next == NULL || h->next->Typ() != INTVEC_CMD) |
---|
1287 | { |
---|
1288 | Werror("system(\"MwalkInitialForm\", ideal, intvec) expected"); |
---|
1289 | return TRUE; |
---|
1290 | } |
---|
1291 | if(((intvec*) h->next->Data())->length() != currRing->N) |
---|
1292 | { |
---|
1293 | Werror("system \"MwalkInitialForm\"...) intvec not of length %d\n", |
---|
1294 | currRing->N); |
---|
1295 | return TRUE; |
---|
1296 | } |
---|
1297 | ideal id = (ideal) h->Data(); |
---|
1298 | intvec* int_w = (intvec*) h->next->Data(); |
---|
1299 | ideal result = (ideal) MwalkInitialForm(id, int_w); |
---|
1300 | |
---|
1301 | res->rtyp = IDEAL_CMD; |
---|
1302 | res->data = result; |
---|
1303 | return FALSE; |
---|
1304 | } |
---|
1305 | else |
---|
1306 | /************** Perturbation walk **********/ |
---|
1307 | if(strcmp(sys_cmd, "MivMatrixOrder") == 0) |
---|
1308 | { |
---|
1309 | if(h==NULL || h->Typ() != INTVEC_CMD) |
---|
1310 | { |
---|
1311 | Werror("system(\"MivMatrixOrder\",intvec) expected"); |
---|
1312 | return TRUE; |
---|
1313 | } |
---|
1314 | intvec* arg1 = (intvec*) h->Data(); |
---|
1315 | |
---|
1316 | intvec* result = MivMatrixOrder(arg1); |
---|
1317 | |
---|
1318 | res->rtyp = INTVEC_CMD; |
---|
1319 | res->data = result; |
---|
1320 | return FALSE; |
---|
1321 | } |
---|
1322 | else |
---|
1323 | if(strcmp(sys_cmd, "MivMatrixOrderdp") == 0) |
---|
1324 | { |
---|
1325 | if(h==NULL || h->Typ() != INT_CMD) |
---|
1326 | { |
---|
1327 | Werror("system(\"MivMatrixOrderdp\",intvec) expected"); |
---|
1328 | return TRUE; |
---|
1329 | } |
---|
1330 | int arg1 = (int) ((long)(h->Data())); |
---|
1331 | |
---|
1332 | intvec* result = (intvec*) MivMatrixOrderdp(arg1); |
---|
1333 | |
---|
1334 | res->rtyp = INTVEC_CMD; |
---|
1335 | res->data = result; |
---|
1336 | return FALSE; |
---|
1337 | } |
---|
1338 | else |
---|
1339 | if(strcmp(sys_cmd, "MPertVectors") == 0) |
---|
1340 | { |
---|
1341 | |
---|
1342 | if(h==NULL || h->Typ() != IDEAL_CMD || |
---|
1343 | h->next == NULL || h->next->Typ() != INTVEC_CMD || |
---|
1344 | h->next->next == NULL || h->next->next->Typ() != INT_CMD) |
---|
1345 | { |
---|
1346 | Werror("system(\"MPertVectors\",ideal, intvec, int) expected"); |
---|
1347 | return TRUE; |
---|
1348 | } |
---|
1349 | |
---|
1350 | ideal arg1 = (ideal) h->Data(); |
---|
1351 | intvec* arg2 = (intvec*) h->next->Data(); |
---|
1352 | int arg3 = (int) ((long)(h->next->next->Data())); |
---|
1353 | |
---|
1354 | intvec* result = (intvec*) MPertVectors(arg1, arg2, arg3); |
---|
1355 | |
---|
1356 | res->rtyp = INTVEC_CMD; |
---|
1357 | res->data = result; |
---|
1358 | return FALSE; |
---|
1359 | } |
---|
1360 | else |
---|
1361 | if(strcmp(sys_cmd, "MPertVectorslp") == 0) |
---|
1362 | { |
---|
1363 | |
---|
1364 | if(h==NULL || h->Typ() != IDEAL_CMD || |
---|
1365 | h->next == NULL || h->next->Typ() != INTVEC_CMD || |
---|
1366 | h->next->next == NULL || h->next->next->Typ() != INT_CMD) |
---|
1367 | { |
---|
1368 | Werror("system(\"MPertVectorslp\",ideal, intvec, int) expected"); |
---|
1369 | return TRUE; |
---|
1370 | } |
---|
1371 | |
---|
1372 | ideal arg1 = (ideal) h->Data(); |
---|
1373 | intvec* arg2 = (intvec*) h->next->Data(); |
---|
1374 | int arg3 = (int) ((long)(h->next->next->Data())); |
---|
1375 | |
---|
1376 | intvec* result = (intvec*) MPertVectorslp(arg1, arg2, arg3); |
---|
1377 | |
---|
1378 | res->rtyp = INTVEC_CMD; |
---|
1379 | res->data = result; |
---|
1380 | return FALSE; |
---|
1381 | } |
---|
1382 | /************** fractal walk **********/ |
---|
1383 | else |
---|
1384 | if(strcmp(sys_cmd, "Mfpertvector") == 0) |
---|
1385 | { |
---|
1386 | if(h==NULL || h->Typ() != IDEAL_CMD || |
---|
1387 | h->next==NULL || h->next->Typ() != INTVEC_CMD ) |
---|
1388 | { |
---|
1389 | Werror("system(\"Mfpertvector\", ideal,intvec) expected"); |
---|
1390 | return TRUE; |
---|
1391 | } |
---|
1392 | ideal arg1 = (ideal) h->Data(); |
---|
1393 | intvec* arg2 = (intvec*) h->next->Data(); |
---|
1394 | intvec* result = Mfpertvector(arg1, arg2); |
---|
1395 | |
---|
1396 | res->rtyp = INTVEC_CMD; |
---|
1397 | res->data = result; |
---|
1398 | return FALSE; |
---|
1399 | } |
---|
1400 | else |
---|
1401 | if(strcmp(sys_cmd, "MivUnit") == 0) |
---|
1402 | { |
---|
1403 | int arg1 = (int) ((long)(h->Data())); |
---|
1404 | |
---|
1405 | intvec* result = (intvec*) MivUnit(arg1); |
---|
1406 | |
---|
1407 | res->rtyp = INTVEC_CMD; |
---|
1408 | res->data = result; |
---|
1409 | return FALSE; |
---|
1410 | } |
---|
1411 | else |
---|
1412 | if(strcmp(sys_cmd, "MivWeightOrderlp") == 0) |
---|
1413 | { |
---|
1414 | if(h==NULL || h->Typ() != INTVEC_CMD) |
---|
1415 | { |
---|
1416 | Werror("system(\"MivWeightOrderlp\",intvec) expected"); |
---|
1417 | return TRUE; |
---|
1418 | } |
---|
1419 | intvec* arg1 = (intvec*) h->Data(); |
---|
1420 | intvec* result = MivWeightOrderlp(arg1); |
---|
1421 | |
---|
1422 | res->rtyp = INTVEC_CMD; |
---|
1423 | res->data = result; |
---|
1424 | return FALSE; |
---|
1425 | } |
---|
1426 | else |
---|
1427 | if(strcmp(sys_cmd, "MivWeightOrderdp") == 0) |
---|
1428 | { |
---|
1429 | if(h==NULL || h->Typ() != INTVEC_CMD) |
---|
1430 | { |
---|
1431 | Werror("system(\"MivWeightOrderdp\",intvec) expected"); |
---|
1432 | return TRUE; |
---|
1433 | } |
---|
1434 | intvec* arg1 = (intvec*) h->Data(); |
---|
1435 | //int arg2 = (int) h->next->Data(); |
---|
1436 | |
---|
1437 | intvec* result = MivWeightOrderdp(arg1); |
---|
1438 | |
---|
1439 | res->rtyp = INTVEC_CMD; |
---|
1440 | res->data = result; |
---|
1441 | return FALSE; |
---|
1442 | } |
---|
1443 | else |
---|
1444 | if(strcmp(sys_cmd, "MivMatrixOrderlp") == 0) |
---|
1445 | { |
---|
1446 | if(h==NULL || h->Typ() != INT_CMD) |
---|
1447 | { |
---|
1448 | Werror("system(\"MivMatrixOrderlp\",int) expected"); |
---|
1449 | return TRUE; |
---|
1450 | } |
---|
1451 | int arg1 = (int) ((long)(h->Data())); |
---|
1452 | |
---|
1453 | intvec* result = (intvec*) MivMatrixOrderlp(arg1); |
---|
1454 | |
---|
1455 | res->rtyp = INTVEC_CMD; |
---|
1456 | res->data = result; |
---|
1457 | return FALSE; |
---|
1458 | } |
---|
1459 | else |
---|
1460 | if (strcmp(sys_cmd, "MkInterRedNextWeight") == 0) |
---|
1461 | { |
---|
1462 | if (h == NULL || h->Typ() != INTVEC_CMD || |
---|
1463 | h->next == NULL || h->next->Typ() != INTVEC_CMD || |
---|
1464 | h->next->next == NULL || h->next->next->Typ() != IDEAL_CMD) |
---|
1465 | { |
---|
1466 | Werror("system(\"MkInterRedNextWeight\", intvec, intvec, ideal) expected"); |
---|
1467 | return TRUE; |
---|
1468 | } |
---|
1469 | |
---|
1470 | if (((intvec*) h->Data())->length() != currRing->N || |
---|
1471 | ((intvec*) h->next->Data())->length() != currRing->N) |
---|
1472 | { |
---|
1473 | Werror("system(\"MkInterRedNextWeight\" ...) intvecs not of length %d\n", |
---|
1474 | currRing->N); |
---|
1475 | return TRUE; |
---|
1476 | } |
---|
1477 | intvec* arg1 = (intvec*) h->Data(); |
---|
1478 | intvec* arg2 = (intvec*) h->next->Data(); |
---|
1479 | ideal arg3 = (ideal) h->next->next->Data(); |
---|
1480 | |
---|
1481 | intvec* result = (intvec*) MkInterRedNextWeight(arg1, arg2, arg3); |
---|
1482 | |
---|
1483 | res->rtyp = INTVEC_CMD; |
---|
1484 | res->data = result; |
---|
1485 | |
---|
1486 | return FALSE; |
---|
1487 | } |
---|
1488 | else |
---|
1489 | #ifdef MPertNextWeight |
---|
1490 | if (strcmp(sys_cmd, "MPertNextWeight") == 0) |
---|
1491 | { |
---|
1492 | if (h == NULL || h->Typ() != INTVEC_CMD || |
---|
1493 | h->next == NULL || h->next->Typ() != IDEAL_CMD || |
---|
1494 | h->next->next == NULL || h->next->next->Typ() != INT_CMD) |
---|
1495 | { |
---|
1496 | Werror("system(\"MPertNextWeight\", intvec, ideal, int) expected"); |
---|
1497 | return TRUE; |
---|
1498 | } |
---|
1499 | |
---|
1500 | if (((intvec*) h->Data())->length() != currRing->N) |
---|
1501 | { |
---|
1502 | Werror("system(\"MPertNextWeight\" ...) intvecs not of length %d\n", |
---|
1503 | currRing->N); |
---|
1504 | return TRUE; |
---|
1505 | } |
---|
1506 | intvec* arg1 = (intvec*) h->Data(); |
---|
1507 | ideal arg2 = (ideal) h->next->Data(); |
---|
1508 | int arg3 = (int) h->next->next->Data(); |
---|
1509 | |
---|
1510 | intvec* result = (intvec*) MPertNextWeight(arg1, arg2, arg3); |
---|
1511 | |
---|
1512 | res->rtyp = INTVEC_CMD; |
---|
1513 | res->data = result; |
---|
1514 | |
---|
1515 | return FALSE; |
---|
1516 | } |
---|
1517 | else |
---|
1518 | #endif //MPertNextWeight |
---|
1519 | #ifdef Mivperttarget |
---|
1520 | if (strcmp(sys_cmd, "Mivperttarget") == 0) |
---|
1521 | { |
---|
1522 | if (h == NULL || h->Typ() != IDEAL_CMD || |
---|
1523 | h->next == NULL || h->next->Typ() != INT_CMD ) |
---|
1524 | { |
---|
1525 | Werror("system(\"Mivperttarget\", ideal, int) expected"); |
---|
1526 | return TRUE; |
---|
1527 | } |
---|
1528 | |
---|
1529 | ideal arg1 = (ideal) h->Data(); |
---|
1530 | int arg2 = (int) h->next->Data(); |
---|
1531 | |
---|
1532 | intvec* result = (intvec*) Mivperttarget(arg1, arg2); |
---|
1533 | |
---|
1534 | res->rtyp = INTVEC_CMD; |
---|
1535 | res->data = result; |
---|
1536 | |
---|
1537 | return FALSE; |
---|
1538 | } |
---|
1539 | else |
---|
1540 | #endif //Mivperttarget |
---|
1541 | if (strcmp(sys_cmd, "Mwalk") == 0) |
---|
1542 | { |
---|
1543 | if (h == NULL || h->Typ() != IDEAL_CMD || |
---|
1544 | h->next == NULL || h->next->Typ() != INTVEC_CMD || |
---|
1545 | h->next->next == NULL || h->next->next->Typ() != INTVEC_CMD) |
---|
1546 | { |
---|
1547 | Werror("system(\"Mwalk\", ideal, intvec, intvec) expected"); |
---|
1548 | return TRUE; |
---|
1549 | } |
---|
1550 | |
---|
1551 | if (((intvec*) h->next->Data())->length() != currRing->N && |
---|
1552 | ((intvec*) h->next->next->Data())->length() != currRing->N ) |
---|
1553 | { |
---|
1554 | Werror("system(\"Mwalk\" ...) intvecs not of length %d\n", |
---|
1555 | currRing->N); |
---|
1556 | return TRUE; |
---|
1557 | } |
---|
1558 | ideal arg1 = (ideal) h->Data(); |
---|
1559 | intvec* arg2 = (intvec*) h->next->Data(); |
---|
1560 | intvec* arg3 = (intvec*) h->next->next->Data(); |
---|
1561 | |
---|
1562 | |
---|
1563 | ideal result = (ideal) Mwalk(arg1, arg2, arg3); |
---|
1564 | |
---|
1565 | res->rtyp = IDEAL_CMD; |
---|
1566 | res->data = result; |
---|
1567 | |
---|
1568 | return FALSE; |
---|
1569 | } |
---|
1570 | else |
---|
1571 | #ifdef MPWALK_ORIG |
---|
1572 | if (strcmp(sys_cmd, "Mpwalk") == 0) |
---|
1573 | { |
---|
1574 | if (h == NULL || h->Typ() != IDEAL_CMD || |
---|
1575 | h->next == NULL || h->next->Typ() != INT_CMD || |
---|
1576 | h->next->next == NULL || h->next->next->Typ() != INT_CMD || |
---|
1577 | h->next->next->next == NULL || |
---|
1578 | h->next->next->next->Typ() != INTVEC_CMD || |
---|
1579 | h->next->next->next->next == NULL || |
---|
1580 | h->next->next->next->next->Typ() != INTVEC_CMD) |
---|
1581 | { |
---|
1582 | Werror("system(\"Mpwalk\", ideal, int, int, intvec, intvec) expected"); |
---|
1583 | return TRUE; |
---|
1584 | } |
---|
1585 | |
---|
1586 | if (((intvec*) h->next->next->next->Data())->length() != currRing->N && |
---|
1587 | ((intvec*) h->next->next->next->next->Data())->length()!=currRing->N) |
---|
1588 | { |
---|
1589 | Werror("system(\"Mpwalk\" ...) intvecs not of length %d\n", |
---|
1590 | currRing->N); |
---|
1591 | return TRUE; |
---|
1592 | } |
---|
1593 | ideal arg1 = (ideal) h->Data(); |
---|
1594 | int arg2 = (int) h->next->Data(); |
---|
1595 | int arg3 = (int) h->next->next->Data(); |
---|
1596 | intvec* arg4 = (intvec*) h->next->next->next->Data(); |
---|
1597 | intvec* arg5 = (intvec*) h->next->next->next->next->Data(); |
---|
1598 | |
---|
1599 | |
---|
1600 | ideal result = (ideal) Mpwalk(arg1, arg2, arg3, arg4, arg5); |
---|
1601 | |
---|
1602 | res->rtyp = IDEAL_CMD; |
---|
1603 | res->data = result; |
---|
1604 | |
---|
1605 | return FALSE; |
---|
1606 | } |
---|
1607 | else |
---|
1608 | #endif |
---|
1609 | if (strcmp(sys_cmd, "Mpwalk") == 0) |
---|
1610 | { |
---|
1611 | if (h == NULL || h->Typ() != IDEAL_CMD || |
---|
1612 | h->next == NULL || h->next->Typ() != INT_CMD || |
---|
1613 | h->next->next == NULL || h->next->next->Typ() != INT_CMD || |
---|
1614 | h->next->next->next == NULL || |
---|
1615 | h->next->next->next->Typ() != INTVEC_CMD || |
---|
1616 | h->next->next->next->next == NULL || |
---|
1617 | h->next->next->next->next->Typ() != INTVEC_CMD|| |
---|
1618 | h->next->next->next->next->next == NULL || |
---|
1619 | h->next->next->next->next->next->Typ() != INT_CMD) |
---|
1620 | { |
---|
1621 | Werror("system(\"Mpwalk\", ideal, int, int, intvec, intvec, int) expected"); |
---|
1622 | return TRUE; |
---|
1623 | } |
---|
1624 | |
---|
1625 | if (((intvec*) h->next->next->next->Data())->length() != currRing->N && |
---|
1626 | ((intvec*) h->next->next->next->next->Data())->length()!=currRing->N) |
---|
1627 | { |
---|
1628 | Werror("system(\"Mpwalk\" ...) intvecs not of length %d\n", |
---|
1629 | currRing->N); |
---|
1630 | return TRUE; |
---|
1631 | } |
---|
1632 | ideal arg1 = (ideal) h->Data(); |
---|
1633 | int arg2 = (int) ((long)(h->next->Data())); |
---|
1634 | int arg3 = (int) ((long)(h->next->next->Data())); |
---|
1635 | intvec* arg4 = (intvec*) h->next->next->next->Data(); |
---|
1636 | intvec* arg5 = (intvec*) h->next->next->next->next->Data(); |
---|
1637 | int arg6 = (int) ((long)(h->next->next->next->next->next->Data())); |
---|
1638 | |
---|
1639 | |
---|
1640 | ideal result = (ideal) Mpwalk(arg1, arg2, arg3, arg4, arg5, arg6); |
---|
1641 | |
---|
1642 | res->rtyp = IDEAL_CMD; |
---|
1643 | res->data = result; |
---|
1644 | |
---|
1645 | return FALSE; |
---|
1646 | } |
---|
1647 | else |
---|
1648 | if (strcmp(sys_cmd, "MAltwalk1") == 0) |
---|
1649 | { |
---|
1650 | if (h == NULL || h->Typ() != IDEAL_CMD || |
---|
1651 | h->next == NULL || h->next->Typ() != INT_CMD || |
---|
1652 | h->next->next == NULL || h->next->next->Typ() != INT_CMD || |
---|
1653 | h->next->next->next == NULL || |
---|
1654 | h->next->next->next->Typ() != INTVEC_CMD || |
---|
1655 | h->next->next->next->next == NULL || |
---|
1656 | h->next->next->next->next->Typ() != INTVEC_CMD) |
---|
1657 | { |
---|
1658 | Werror("system(\"MAltwalk1\", ideal, int, int, intvec, intvec) expected"); |
---|
1659 | return TRUE; |
---|
1660 | } |
---|
1661 | |
---|
1662 | if (((intvec*) h->next->next->next->Data())->length() != currRing->N && |
---|
1663 | ((intvec*) h->next->next->next->next->Data())->length()!=currRing->N) |
---|
1664 | { |
---|
1665 | Werror("system(\"MAltwalk1\" ...) intvecs not of length %d\n", |
---|
1666 | currRing->N); |
---|
1667 | return TRUE; |
---|
1668 | } |
---|
1669 | ideal arg1 = (ideal) h->Data(); |
---|
1670 | int arg2 = (int) ((long)(h->next->Data())); |
---|
1671 | int arg3 = (int) ((long)(h->next->next->Data())); |
---|
1672 | intvec* arg4 = (intvec*) h->next->next->next->Data(); |
---|
1673 | intvec* arg5 = (intvec*) h->next->next->next->next->Data(); |
---|
1674 | |
---|
1675 | |
---|
1676 | ideal result = (ideal) MAltwalk1(arg1, arg2, arg3, arg4, arg5); |
---|
1677 | |
---|
1678 | res->rtyp = IDEAL_CMD; |
---|
1679 | res->data = result; |
---|
1680 | |
---|
1681 | return FALSE; |
---|
1682 | } |
---|
1683 | #ifdef MFWALK_ALT |
---|
1684 | else |
---|
1685 | if (strcmp(sys_cmd, "Mfwalk_alt") == 0) |
---|
1686 | { |
---|
1687 | if (h == NULL || h->Typ() != IDEAL_CMD || |
---|
1688 | h->next == NULL || h->next->Typ() != INTVEC_CMD || |
---|
1689 | h->next->next == NULL || h->next->next->Typ() != INTVEC_CMD || |
---|
1690 | h->next->next->next == NULL || h->next->next->next->Typ() !=INT_CMD) |
---|
1691 | { |
---|
1692 | Werror("system(\"Mfwalk\", ideal, intvec, intvec,int) expected"); |
---|
1693 | return TRUE; |
---|
1694 | } |
---|
1695 | |
---|
1696 | if (((intvec*) h->next->Data())->length() != currRing->N && |
---|
1697 | ((intvec*) h->next->next->Data())->length() != currRing->N ) |
---|
1698 | { |
---|
1699 | Werror("system(\"Mfwalk\" ...) intvecs not of length %d\n", |
---|
1700 | currRing->N); |
---|
1701 | return TRUE; |
---|
1702 | } |
---|
1703 | ideal arg1 = (ideal) h->Data(); |
---|
1704 | intvec* arg2 = (intvec*) h->next->Data(); |
---|
1705 | intvec* arg3 = (intvec*) h->next->next->Data(); |
---|
1706 | int arg4 = (int) h->next->next->next->Data(); |
---|
1707 | |
---|
1708 | ideal result = (ideal) Mfwalk_alt(arg1, arg2, arg3, arg4); |
---|
1709 | |
---|
1710 | res->rtyp = IDEAL_CMD; |
---|
1711 | res->data = result; |
---|
1712 | |
---|
1713 | return FALSE; |
---|
1714 | } |
---|
1715 | #endif |
---|
1716 | else |
---|
1717 | if (strcmp(sys_cmd, "Mfwalk") == 0) |
---|
1718 | { |
---|
1719 | if (h == NULL || h->Typ() != IDEAL_CMD || |
---|
1720 | h->next == NULL || h->next->Typ() != INTVEC_CMD || |
---|
1721 | h->next->next == NULL || h->next->next->Typ() != INTVEC_CMD) |
---|
1722 | { |
---|
1723 | Werror("system(\"Mfwalk\", ideal, intvec, intvec) expected"); |
---|
1724 | return TRUE; |
---|
1725 | } |
---|
1726 | |
---|
1727 | if (((intvec*) h->next->Data())->length() != currRing->N && |
---|
1728 | ((intvec*) h->next->next->Data())->length() != currRing->N ) |
---|
1729 | { |
---|
1730 | Werror("system(\"Mfwalk\" ...) intvecs not of length %d\n", |
---|
1731 | currRing->N); |
---|
1732 | return TRUE; |
---|
1733 | } |
---|
1734 | ideal arg1 = (ideal) h->Data(); |
---|
1735 | intvec* arg2 = (intvec*) h->next->Data(); |
---|
1736 | intvec* arg3 = (intvec*) h->next->next->Data(); |
---|
1737 | |
---|
1738 | ideal result = (ideal) Mfwalk(arg1, arg2, arg3); |
---|
1739 | |
---|
1740 | res->rtyp = IDEAL_CMD; |
---|
1741 | res->data = result; |
---|
1742 | |
---|
1743 | return FALSE; |
---|
1744 | } |
---|
1745 | else |
---|
1746 | |
---|
1747 | #ifdef TRAN_Orig |
---|
1748 | if (strcmp(sys_cmd, "TranMImprovwalk") == 0) |
---|
1749 | { |
---|
1750 | if (h == NULL || h->Typ() != IDEAL_CMD || |
---|
1751 | h->next == NULL || h->next->Typ() != INTVEC_CMD || |
---|
1752 | h->next->next == NULL || h->next->next->Typ() != INTVEC_CMD) |
---|
1753 | { |
---|
1754 | Werror("system(\"TranMImprovwalk\", ideal, intvec, intvec) expected"); |
---|
1755 | return TRUE; |
---|
1756 | } |
---|
1757 | |
---|
1758 | if (((intvec*) h->next->Data())->length() != currRing->N && |
---|
1759 | ((intvec*) h->next->next->Data())->length() != currRing->N ) |
---|
1760 | { |
---|
1761 | Werror("system(\"TranMImprovwalk\" ...) intvecs not of length %d\n", |
---|
1762 | currRing->N); |
---|
1763 | return TRUE; |
---|
1764 | } |
---|
1765 | ideal arg1 = (ideal) h->Data(); |
---|
1766 | intvec* arg2 = (intvec*) h->next->Data(); |
---|
1767 | intvec* arg3 = (intvec*) h->next->next->Data(); |
---|
1768 | |
---|
1769 | |
---|
1770 | ideal result = (ideal) TranMImprovwalk(arg1, arg2, arg3); |
---|
1771 | |
---|
1772 | res->rtyp = IDEAL_CMD; |
---|
1773 | res->data = result; |
---|
1774 | |
---|
1775 | return FALSE; |
---|
1776 | } |
---|
1777 | else |
---|
1778 | #endif |
---|
1779 | if (strcmp(sys_cmd, "MAltwalk2") == 0) |
---|
1780 | { |
---|
1781 | if (h == NULL || h->Typ() != IDEAL_CMD || |
---|
1782 | h->next == NULL || h->next->Typ() != INTVEC_CMD || |
---|
1783 | h->next->next == NULL || h->next->next->Typ() != INTVEC_CMD) |
---|
1784 | { |
---|
1785 | Werror("system(\"MAltwalk2\", ideal, intvec, intvec) expected"); |
---|
1786 | return TRUE; |
---|
1787 | } |
---|
1788 | |
---|
1789 | if (((intvec*) h->next->Data())->length() != currRing->N && |
---|
1790 | ((intvec*) h->next->next->Data())->length() != currRing->N ) |
---|
1791 | { |
---|
1792 | Werror("system(\"MAltwalk2\" ...) intvecs not of length %d\n", |
---|
1793 | currRing->N); |
---|
1794 | return TRUE; |
---|
1795 | } |
---|
1796 | ideal arg1 = (ideal) h->Data(); |
---|
1797 | intvec* arg2 = (intvec*) h->next->Data(); |
---|
1798 | intvec* arg3 = (intvec*) h->next->next->Data(); |
---|
1799 | |
---|
1800 | |
---|
1801 | ideal result = (ideal) MAltwalk2(arg1, arg2, arg3); |
---|
1802 | |
---|
1803 | res->rtyp = IDEAL_CMD; |
---|
1804 | res->data = result; |
---|
1805 | |
---|
1806 | return FALSE; |
---|
1807 | } |
---|
1808 | else |
---|
1809 | if (strcmp(sys_cmd, "TranMImprovwalk") == 0) |
---|
1810 | { |
---|
1811 | if (h == NULL || h->Typ() != IDEAL_CMD || |
---|
1812 | h->next == NULL || h->next->Typ() != INTVEC_CMD || |
---|
1813 | h->next->next == NULL || h->next->next->Typ() != INTVEC_CMD|| |
---|
1814 | h->next->next->next == NULL || h->next->next->next->Typ() != INT_CMD) |
---|
1815 | { |
---|
1816 | Werror("system(\"TranMImprovwalk\", ideal, intvec, intvec, int) expected"); |
---|
1817 | return TRUE; |
---|
1818 | } |
---|
1819 | |
---|
1820 | if (((intvec*) h->next->Data())->length() != currRing->N && |
---|
1821 | ((intvec*) h->next->next->Data())->length() != currRing->N ) |
---|
1822 | { |
---|
1823 | Werror("system(\"TranMImprovwalk\" ...) intvecs not of length %d\n", |
---|
1824 | currRing->N); |
---|
1825 | return TRUE; |
---|
1826 | } |
---|
1827 | ideal arg1 = (ideal) h->Data(); |
---|
1828 | intvec* arg2 = (intvec*) h->next->Data(); |
---|
1829 | intvec* arg3 = (intvec*) h->next->next->Data(); |
---|
1830 | int arg4 = (int) ((long)(h->next->next->next->Data())); |
---|
1831 | |
---|
1832 | ideal result = (ideal) TranMImprovwalk(arg1, arg2, arg3, arg4); |
---|
1833 | |
---|
1834 | res->rtyp = IDEAL_CMD; |
---|
1835 | res->data = result; |
---|
1836 | |
---|
1837 | return FALSE; |
---|
1838 | } |
---|
1839 | else |
---|
1840 | #endif |
---|
1841 | /*================= Extended system call ========================*/ |
---|
1842 | { |
---|
1843 | #ifndef MAKE_DISTRIBUTION |
---|
1844 | return(jjEXTENDED_SYSTEM(res, args)); |
---|
1845 | #else |
---|
1846 | Werror( "system(\"%s\",...) %s", sys_cmd, feNotImplemented ); |
---|
1847 | #endif |
---|
1848 | } |
---|
1849 | } /* typ==string */ |
---|
1850 | return TRUE; |
---|
1851 | } |
---|
1852 | |
---|
1853 | |
---|
1854 | #ifdef HAVE_EXTENDED_SYSTEM |
---|
1855 | // You can put your own system calls here |
---|
1856 | #include "fglmcomb.cc" |
---|
1857 | #include "fglm.h" |
---|
1858 | #ifdef HAVE_NEWTON |
---|
1859 | #include <hc_newton.h> |
---|
1860 | #endif |
---|
1861 | #include "mpsr.h" |
---|
1862 | #include "mod_raw.h" |
---|
1863 | |
---|
1864 | static BOOLEAN jjEXTENDED_SYSTEM(leftv res, leftv h) |
---|
1865 | { |
---|
1866 | if(h->Typ() == STRING_CMD) |
---|
1867 | { |
---|
1868 | char *sys_cmd=(char *)(h->Data()); |
---|
1869 | h=h->next; |
---|
1870 | /*==================== locNF ======================================*/ |
---|
1871 | if(strcmp(sys_cmd,"locNF")==0) |
---|
1872 | { |
---|
1873 | if (h != NULL && h->Typ() == VECTOR_CMD) |
---|
1874 | { |
---|
1875 | poly f=(poly)h->Data(); |
---|
1876 | h=h->next; |
---|
1877 | if (h != NULL && h->Typ() == MODUL_CMD) |
---|
1878 | { |
---|
1879 | ideal m=(ideal)h->Data(); |
---|
1880 | assumeStdFlag(h); |
---|
1881 | h=h->next; |
---|
1882 | if (h != NULL && h->Typ() == INT_CMD) |
---|
1883 | { |
---|
1884 | int n=(int)((long)h->Data()); |
---|
1885 | h=h->next; |
---|
1886 | if (h != NULL && h->Typ() == INTVEC_CMD) |
---|
1887 | { |
---|
1888 | intvec *v=(intvec *)h->Data(); |
---|
1889 | |
---|
1890 | /* == now the work starts == */ |
---|
1891 | |
---|
1892 | short * iv=iv2array(v); |
---|
1893 | poly r=0; |
---|
1894 | poly hp=ppJetW(f,n,iv); |
---|
1895 | int s=MATCOLS(m); |
---|
1896 | int j=0; |
---|
1897 | matrix T=mpInitI(s,1,0); |
---|
1898 | |
---|
1899 | while (hp != NULL) |
---|
1900 | { |
---|
1901 | if (pDivisibleBy(m->m[j],hp)) |
---|
1902 | { |
---|
1903 | if (MATELEM(T,j+1,1)==0) |
---|
1904 | { |
---|
1905 | MATELEM(T,j+1,1)=pDivideM(pHead(hp),pHead(m->m[j])); |
---|
1906 | } |
---|
1907 | else |
---|
1908 | { |
---|
1909 | pAdd(MATELEM(T,j+1,1),pDivideM(pHead(hp),pHead(m->m[j]))); |
---|
1910 | } |
---|
1911 | hp=ppJetW(ksOldSpolyRed(m->m[j],hp,0),n,iv); |
---|
1912 | j=0; |
---|
1913 | } |
---|
1914 | else |
---|
1915 | { |
---|
1916 | if (j==s-1) |
---|
1917 | { |
---|
1918 | r=pAdd(r,pHead(hp)); |
---|
1919 | hp=pLmDeleteAndNext(hp); /* hp=pSub(hp,pHead(hp));*/ |
---|
1920 | j=0; |
---|
1921 | } |
---|
1922 | else |
---|
1923 | { |
---|
1924 | j++; |
---|
1925 | } |
---|
1926 | } |
---|
1927 | } |
---|
1928 | |
---|
1929 | matrix Temp=mpTransp((matrix) idVec2Ideal(r)); |
---|
1930 | matrix R=mpNew(MATCOLS((matrix) idVec2Ideal(f)),1); |
---|
1931 | for (int k=1;k<=MATROWS(Temp);k++) |
---|
1932 | { |
---|
1933 | MATELEM(R,k,1)=MATELEM(Temp,k,1); |
---|
1934 | } |
---|
1935 | |
---|
1936 | lists L=(lists)omAllocBin(slists_bin); |
---|
1937 | L->Init(2); |
---|
1938 | L->m[0].rtyp=MATRIX_CMD; L->m[0].data=(void *)R; |
---|
1939 | L->m[1].rtyp=MATRIX_CMD; L->m[1].data=(void *)T; |
---|
1940 | res->data=L; |
---|
1941 | res->rtyp=LIST_CMD; |
---|
1942 | // iv aufraeumen |
---|
1943 | omFree(iv); |
---|
1944 | } |
---|
1945 | else |
---|
1946 | { |
---|
1947 | Warn ("4th argument: must be an intvec!"); |
---|
1948 | } |
---|
1949 | } |
---|
1950 | else |
---|
1951 | { |
---|
1952 | Warn("3rd argument must be an int!!"); |
---|
1953 | } |
---|
1954 | } |
---|
1955 | else |
---|
1956 | { |
---|
1957 | Warn("2nd argument must be a module!"); |
---|
1958 | } |
---|
1959 | } |
---|
1960 | else |
---|
1961 | { |
---|
1962 | Warn("1st argument must be a vector!"); |
---|
1963 | } |
---|
1964 | return FALSE; |
---|
1965 | } |
---|
1966 | else |
---|
1967 | /*==================== interred ==================================*/ |
---|
1968 | #if 0 |
---|
1969 | if(strcmp(sys_cmd,"interred")==0) |
---|
1970 | { |
---|
1971 | res->data=(char *)kIR((ideal)h->Data(),currQuotient); |
---|
1972 | res->rtyp=h->Typ(); |
---|
1973 | return ((h->Typ()!=IDEAL_CMD) && (h->Typ()!=MODUL_CMD)); |
---|
1974 | } |
---|
1975 | else |
---|
1976 | #endif |
---|
1977 | #ifdef RDEBUG |
---|
1978 | /*==================== poly debug ==================================*/ |
---|
1979 | if(strcmp(sys_cmd,"p")==0) |
---|
1980 | { |
---|
1981 | pDebugPrint((poly)h->Data()); |
---|
1982 | return FALSE; |
---|
1983 | } |
---|
1984 | else |
---|
1985 | /*==================== ring debug ==================================*/ |
---|
1986 | if(strcmp(sys_cmd,"r")==0) |
---|
1987 | { |
---|
1988 | rDebugPrint((ring)h->Data()); |
---|
1989 | return FALSE; |
---|
1990 | } |
---|
1991 | else |
---|
1992 | #endif |
---|
1993 | /*==================== mtrack ==================================*/ |
---|
1994 | if(strcmp(sys_cmd,"mtrack")==0) |
---|
1995 | { |
---|
1996 | #ifdef OM_TRACK |
---|
1997 | om_Opts.MarkAsStatic = 1; |
---|
1998 | FILE *fd = NULL; |
---|
1999 | int max = 5; |
---|
2000 | while (h != NULL) |
---|
2001 | { |
---|
2002 | omMarkAsStaticAddr(h); |
---|
2003 | if (fd == NULL && h->Typ()==STRING_CMD) |
---|
2004 | { |
---|
2005 | fd = fopen((char*) h->Data(), "w"); |
---|
2006 | if (fd == NULL) |
---|
2007 | Warn("Can not open %s for writing og mtrack. Using stdout"); |
---|
2008 | } |
---|
2009 | if (h->Typ() == INT_CMD) |
---|
2010 | { |
---|
2011 | max = (int)(long)h->Data(); |
---|
2012 | } |
---|
2013 | h = h->Next(); |
---|
2014 | } |
---|
2015 | omPrintUsedTrackAddrs((fd == NULL ? stdout : fd), max); |
---|
2016 | if (fd != NULL) fclose(fd); |
---|
2017 | om_Opts.MarkAsStatic = 0; |
---|
2018 | return FALSE; |
---|
2019 | #else |
---|
2020 | WerrorS("mtrack not supported without OM_TRACK"); |
---|
2021 | return TRUE; |
---|
2022 | #endif |
---|
2023 | } |
---|
2024 | /*==================== mtrack_all ==================================*/ |
---|
2025 | if(strcmp(sys_cmd,"mtrack_all")==0) |
---|
2026 | { |
---|
2027 | #ifdef OM_TRACK |
---|
2028 | om_Opts.MarkAsStatic = 1; |
---|
2029 | FILE *fd = NULL; |
---|
2030 | if ((h!=NULL) &&(h->Typ()==STRING_CMD)) |
---|
2031 | { |
---|
2032 | fd = fopen((char*) h->Data(), "w"); |
---|
2033 | if (fd == NULL) |
---|
2034 | Warn("Can not open %s for writing og mtrack. Using stdout"); |
---|
2035 | omMarkAsStaticAddr(h); |
---|
2036 | } |
---|
2037 | // OB: TBC print to fd |
---|
2038 | omPrintUsedAddrs((fd == NULL ? stdout : fd), 5); |
---|
2039 | if (fd != NULL) fclose(fd); |
---|
2040 | om_Opts.MarkAsStatic = 0; |
---|
2041 | return FALSE; |
---|
2042 | #else |
---|
2043 | WerrorS("mtrack not supported without OM_TRACK"); |
---|
2044 | return TRUE; |
---|
2045 | #endif |
---|
2046 | } |
---|
2047 | else |
---|
2048 | /*==================== backtrace ==================================*/ |
---|
2049 | if(strcmp(sys_cmd,"backtrace")==0) |
---|
2050 | { |
---|
2051 | #ifndef OM_NDEBUG |
---|
2052 | omPrintCurrentBackTrace(stdout); |
---|
2053 | return FALSE; |
---|
2054 | #else |
---|
2055 | WerrorS("btrack not supported without OM_TRACK"); |
---|
2056 | return TRUE; |
---|
2057 | #endif |
---|
2058 | } |
---|
2059 | else |
---|
2060 | /*==================== naIdeal ==================================*/ |
---|
2061 | if(strcmp(sys_cmd,"naIdeal")==0) |
---|
2062 | { |
---|
2063 | if ((h!=NULL) &&(h->Typ()==IDEAL_CMD)) |
---|
2064 | { |
---|
2065 | naSetIdeal((ideal)h->Data()); |
---|
2066 | return FALSE; |
---|
2067 | } |
---|
2068 | else |
---|
2069 | WerrorS("ideal expected"); |
---|
2070 | } |
---|
2071 | else |
---|
2072 | /*==================== isSqrFree =============================*/ |
---|
2073 | #ifdef HAVE_FACTORY |
---|
2074 | if(strcmp(sys_cmd,"isSqrFree")==0) |
---|
2075 | { |
---|
2076 | if ((h!=NULL) &&(h->Typ()==POLY_CMD)) |
---|
2077 | { |
---|
2078 | res->rtyp=INT_CMD; |
---|
2079 | res->data=(void *)singclap_isSqrFree((poly)h->Data()); |
---|
2080 | return FALSE; |
---|
2081 | } |
---|
2082 | else |
---|
2083 | WerrorS("poly expected"); |
---|
2084 | } |
---|
2085 | else |
---|
2086 | #endif |
---|
2087 | /*==================== pDivStat =============================*/ |
---|
2088 | #if defined(PDEBUG) || defined(PDIV_DEBUG) |
---|
2089 | if(strcmp(sys_cmd,"pDivStat")==0) |
---|
2090 | { |
---|
2091 | extern void pPrintDivisbleByStat(); |
---|
2092 | pPrintDivisbleByStat(); |
---|
2093 | return FALSE; |
---|
2094 | } |
---|
2095 | else |
---|
2096 | #endif |
---|
2097 | /*==================== alarm ==================================*/ |
---|
2098 | #ifndef MSDOS |
---|
2099 | #ifndef atarist |
---|
2100 | #ifdef unix |
---|
2101 | if(strcmp(sys_cmd,"alarm")==0) |
---|
2102 | { |
---|
2103 | if ((h!=NULL) &&(h->Typ()==INT_CMD)) |
---|
2104 | { |
---|
2105 | // standard variant -> SIGALARM (standard: abort) |
---|
2106 | //alarm((unsigned)h->next->Data()); |
---|
2107 | // process time (user +system): SIGVTALARM |
---|
2108 | struct itimerval t,o; |
---|
2109 | memset(&t,0,sizeof(t)); |
---|
2110 | t.it_value.tv_sec =(unsigned)((unsigned long)h->Data()); |
---|
2111 | setitimer(ITIMER_VIRTUAL,&t,&o); |
---|
2112 | return FALSE; |
---|
2113 | } |
---|
2114 | else |
---|
2115 | WerrorS("int expected"); |
---|
2116 | } |
---|
2117 | else |
---|
2118 | #endif |
---|
2119 | #endif |
---|
2120 | #endif |
---|
2121 | /*==================== red =============================*/ |
---|
2122 | #if 0 |
---|
2123 | if(strcmp(sys_cmd,"red")==0) |
---|
2124 | { |
---|
2125 | if ((h!=NULL) &&(h->Typ()==IDEAL_CMD)) |
---|
2126 | { |
---|
2127 | res->rtyp=IDEAL_CMD; |
---|
2128 | res->data=(void *)kStdred((ideal)h->Data(),NULL,testHomog,NULL); |
---|
2129 | setFlag(res,FLAG_STD); |
---|
2130 | return FALSE; |
---|
2131 | } |
---|
2132 | else |
---|
2133 | WerrorS("ideal expected"); |
---|
2134 | } |
---|
2135 | else |
---|
2136 | #endif |
---|
2137 | #ifdef HAVE_FACTORY |
---|
2138 | /*==================== fastcomb =============================*/ |
---|
2139 | if(strcmp(sys_cmd,"fastcomb")==0) |
---|
2140 | { |
---|
2141 | if ((h!=NULL) &&(h->Typ()==IDEAL_CMD)) |
---|
2142 | { |
---|
2143 | int i=0; |
---|
2144 | if (h->next!=NULL) |
---|
2145 | { |
---|
2146 | if (h->next->Typ()!=POLY_CMD) |
---|
2147 | { |
---|
2148 | Warn("Wrong types for poly= comb(ideal,poly)"); |
---|
2149 | } |
---|
2150 | } |
---|
2151 | res->rtyp=POLY_CMD; |
---|
2152 | res->data=(void *) fglmLinearCombination( |
---|
2153 | (ideal)h->Data(),(poly)h->next->Data()); |
---|
2154 | return FALSE; |
---|
2155 | } |
---|
2156 | else |
---|
2157 | WerrorS("ideal expected"); |
---|
2158 | } |
---|
2159 | else |
---|
2160 | /*==================== comb =============================*/ |
---|
2161 | if(strcmp(sys_cmd,"comb")==0) |
---|
2162 | { |
---|
2163 | if ((h!=NULL) &&(h->Typ()==IDEAL_CMD)) |
---|
2164 | { |
---|
2165 | int i=0; |
---|
2166 | if (h->next!=NULL) |
---|
2167 | { |
---|
2168 | if (h->next->Typ()!=POLY_CMD) |
---|
2169 | { |
---|
2170 | Warn("Wrong types for poly= comb(ideal,poly)"); |
---|
2171 | } |
---|
2172 | } |
---|
2173 | res->rtyp=POLY_CMD; |
---|
2174 | res->data=(void *)fglmNewLinearCombination( |
---|
2175 | (ideal)h->Data(),(poly)h->next->Data()); |
---|
2176 | return FALSE; |
---|
2177 | } |
---|
2178 | else |
---|
2179 | WerrorS("ideal expected"); |
---|
2180 | } |
---|
2181 | else |
---|
2182 | #endif |
---|
2183 | #ifdef FACTORY_GCD_TEST |
---|
2184 | /*=======================gcd Testerei ================================*/ |
---|
2185 | if ( ! strcmp( sys_cmd, "setgcd" ) ) { |
---|
2186 | if ( (h != NULL) && (h->Typ() == INT_CMD) ) { |
---|
2187 | CFPrimitiveGcdUtil::setAlgorithm( (int)h->Data() ); |
---|
2188 | return FALSE; |
---|
2189 | } else |
---|
2190 | WerrorS("int expected"); |
---|
2191 | } |
---|
2192 | else |
---|
2193 | #endif |
---|
2194 | |
---|
2195 | #ifdef FACTORY_GCD_TIMING |
---|
2196 | if ( ! strcmp( sys_cmd, "gcdtime" ) ) { |
---|
2197 | TIMING_PRINT( contentTimer, "time used for content: " ); |
---|
2198 | TIMING_PRINT( algContentTimer, "time used for algContent: " ); |
---|
2199 | TIMING_PRINT( algLcmTimer, "time used for algLcm: " ); |
---|
2200 | TIMING_RESET( contentTimer ); |
---|
2201 | TIMING_RESET( algContentTimer ); |
---|
2202 | TIMING_RESET( algLcmTimer ); |
---|
2203 | return FALSE; |
---|
2204 | } |
---|
2205 | else |
---|
2206 | #endif |
---|
2207 | |
---|
2208 | #ifdef FACTORY_GCD_STAT |
---|
2209 | if ( ! strcmp( sys_cmd, "gcdstat" ) ) { |
---|
2210 | printGcdTotal(); |
---|
2211 | printContTotal(); |
---|
2212 | resetGcdTotal(); |
---|
2213 | resetContTotal(); |
---|
2214 | return FALSE; |
---|
2215 | } |
---|
2216 | else |
---|
2217 | #endif |
---|
2218 | #if !defined(HAVE_NS) |
---|
2219 | /*==================== lib ==================================*/ |
---|
2220 | if(strcmp(sys_cmd,"LIB")==0) |
---|
2221 | { |
---|
2222 | idhdl hh=idroot->get((char*)h->Data(),0); |
---|
2223 | if ((hh!=NULL)&&(IDTYP(hh)==PROC_CMD)) |
---|
2224 | { |
---|
2225 | res->rtyp=STRING_CMD; |
---|
2226 | char *r=iiGetLibName(IDPROC(hh)); |
---|
2227 | if (r==NULL) r=""; |
---|
2228 | res->data=omStrDup(r); |
---|
2229 | return FALSE; |
---|
2230 | } |
---|
2231 | else |
---|
2232 | Warn("`%s` not found",(char*)h->Data()); |
---|
2233 | } |
---|
2234 | else |
---|
2235 | #endif |
---|
2236 | /*==================== listall ===================================*/ |
---|
2237 | if(strcmp(sys_cmd,"listall")==0) |
---|
2238 | { |
---|
2239 | int showproc=0; |
---|
2240 | if ((h!=NULL) && (h->Typ()==INT_CMD)) showproc=(int)((long)h->Data()); |
---|
2241 | #ifdef HAVE_NS |
---|
2242 | listall(showproc); |
---|
2243 | #else |
---|
2244 | idhdl hh=IDROOT; |
---|
2245 | while (hh!=NULL) |
---|
2246 | { |
---|
2247 | if (IDDATA(hh)==(void *)currRing) PrintS("(R)"); |
---|
2248 | else PrintS(" "); |
---|
2249 | Print("::%s, typ %s level %d\n", |
---|
2250 | IDID(hh),Tok2Cmdname(IDTYP(hh)),IDLEV(hh)); |
---|
2251 | hh=IDNEXT(hh); |
---|
2252 | } |
---|
2253 | hh=IDROOT; |
---|
2254 | while (hh!=NULL) |
---|
2255 | { |
---|
2256 | if ((IDTYP(hh)==RING_CMD) |
---|
2257 | || (IDTYP(hh)==QRING_CMD) |
---|
2258 | || (IDTYP(hh)==PACKAGE_CMD)) |
---|
2259 | { |
---|
2260 | idhdl h2=IDRING(hh)->idroot; |
---|
2261 | while (h2!=NULL) |
---|
2262 | { |
---|
2263 | if (IDDATA(h2)==(void *)currRing) PrintS("(R)"); |
---|
2264 | else PrintS(" "); |
---|
2265 | Print("%s::%s, typ %s level %d\n", |
---|
2266 | IDID(hh),IDID(h2),Tok2Cmdname(IDTYP(h2)),IDLEV(h2)); |
---|
2267 | h2=IDNEXT(h2); |
---|
2268 | } |
---|
2269 | } |
---|
2270 | hh=IDNEXT(hh); |
---|
2271 | } |
---|
2272 | #endif /* HAVE_NS */ |
---|
2273 | return FALSE; |
---|
2274 | } |
---|
2275 | else |
---|
2276 | /*==================== proclist =================================*/ |
---|
2277 | if(strcmp(sys_cmd,"proclist")==0) |
---|
2278 | { |
---|
2279 | piShowProcList(); |
---|
2280 | return FALSE; |
---|
2281 | } |
---|
2282 | else |
---|
2283 | /* ==================== newton ================================*/ |
---|
2284 | #ifdef HAVE_NEWTON |
---|
2285 | if(strcmp(sys_cmd,"newton")==0) |
---|
2286 | { |
---|
2287 | if ((h->Typ()!=POLY_CMD) |
---|
2288 | || (h->next->Typ()!=INT_CMD) |
---|
2289 | || (h->next->next->Typ()!=INT_CMD)) |
---|
2290 | { |
---|
2291 | WerrorS("system(\"newton\",<poly>,<int>,<int>) expected"); |
---|
2292 | return TRUE; |
---|
2293 | } |
---|
2294 | poly p=(poly)(h->Data()); |
---|
2295 | int l=pLength(p); |
---|
2296 | short *points=(short *)omAlloc(currRing->N*l*sizeof(short)); |
---|
2297 | int i,j,k; |
---|
2298 | k=0; |
---|
2299 | poly pp=p; |
---|
2300 | for (i=0;pp!=NULL;i++) |
---|
2301 | { |
---|
2302 | for(j=1;j<=currRing->N;j++) |
---|
2303 | { |
---|
2304 | points[k]=pGetExp(pp,j); |
---|
2305 | k++; |
---|
2306 | } |
---|
2307 | pIter(pp); |
---|
2308 | } |
---|
2309 | hc_ERG r=hc_KOENIG(currRing->N, // dimension |
---|
2310 | l, // number of points |
---|
2311 | (short*) points, // points: x_1, y_1,z_1, x_2,y_2,z2,... |
---|
2312 | currRing->OrdSgn==-1, |
---|
2313 | (int) (h->next->Data()), // 1: Milnor, 0: Newton |
---|
2314 | (int) (h->next->next->Data()) // debug |
---|
2315 | ); |
---|
2316 | //----<>---Output----------------------- |
---|
2317 | |
---|
2318 | |
---|
2319 | // PrintS("Bin jetzt in extra.cc bei der Auswertung.\n"); // ********** |
---|
2320 | |
---|
2321 | |
---|
2322 | lists L=(lists)omAllocBin(slists_bin); |
---|
2323 | L->Init(6); |
---|
2324 | L->m[0].rtyp=STRING_CMD; // newtonnumber; |
---|
2325 | L->m[0].data=(void *)omStrDup(r.nZahl); |
---|
2326 | L->m[1].rtyp=INT_CMD; |
---|
2327 | L->m[1].data=(void *)r.achse; // flag for unoccupied axes |
---|
2328 | L->m[2].rtyp=INT_CMD; |
---|
2329 | L->m[2].data=(void *)r.deg; // #degenerations |
---|
2330 | if ( r.deg != 0) // only if degenerations exist |
---|
2331 | { |
---|
2332 | L->m[3].rtyp=INT_CMD; |
---|
2333 | L->m[3].data=(void *)r.anz_punkte; // #points |
---|
2334 | //---<>--number of points------ |
---|
2335 | int anz = r.anz_punkte; // number of points |
---|
2336 | int dim = (currRing->N); // dimension |
---|
2337 | intvec* v = new intvec( anz*dim ); |
---|
2338 | for (i=0; i<anz*dim; i++) // copy points |
---|
2339 | (*v)[i] = r.pu[i]; |
---|
2340 | L->m[4].rtyp=INTVEC_CMD; |
---|
2341 | L->m[4].data=(void *)v; |
---|
2342 | //---<>--degenerations--------- |
---|
2343 | int deg = r.deg; // number of points |
---|
2344 | intvec* w = new intvec( r.speicher ); // necessary memeory |
---|
2345 | i=0; // start copying |
---|
2346 | do |
---|
2347 | { |
---|
2348 | (*w)[i] = r.deg_tab[i]; |
---|
2349 | i++; |
---|
2350 | } |
---|
2351 | while (r.deg_tab[i-1] != -2); // mark for end of list |
---|
2352 | L->m[5].rtyp=INTVEC_CMD; |
---|
2353 | L->m[5].data=(void *)w; |
---|
2354 | } |
---|
2355 | else |
---|
2356 | { |
---|
2357 | L->m[3].rtyp=INT_CMD; L->m[3].data=(char *)0; |
---|
2358 | L->m[4].rtyp=DEF_CMD; |
---|
2359 | L->m[5].rtyp=DEF_CMD; |
---|
2360 | } |
---|
2361 | |
---|
2362 | res->data=(void *)L; |
---|
2363 | res->rtyp=LIST_CMD; |
---|
2364 | // free all pointer in r: |
---|
2365 | delete[] r.nZahl; |
---|
2366 | delete[] r.pu; |
---|
2367 | delete[] r.deg_tab; // Ist das ein Problem?? |
---|
2368 | |
---|
2369 | omFreeSize((ADDRESS)points,currRing->N*l*sizeof(short)); |
---|
2370 | return FALSE; |
---|
2371 | } |
---|
2372 | else |
---|
2373 | #endif |
---|
2374 | /*==================== sdb_flags =================*/ |
---|
2375 | #ifdef HAVE_SDB |
---|
2376 | if (strcmp(sys_cmd, "sdb_flags") == 0) |
---|
2377 | { |
---|
2378 | if ((h!=NULL) && (h->Typ()==INT_CMD)) |
---|
2379 | { |
---|
2380 | sdb_flags=(int)((long)h->Data()); |
---|
2381 | } |
---|
2382 | else |
---|
2383 | { |
---|
2384 | WerrorS("system(\"sdb_flags\",`int`) expected"); |
---|
2385 | return TRUE; |
---|
2386 | } |
---|
2387 | return FALSE; |
---|
2388 | } |
---|
2389 | else |
---|
2390 | /*==================== sdb_edit =================*/ |
---|
2391 | if (strcmp(sys_cmd, "sdb_edit") == 0) |
---|
2392 | { |
---|
2393 | if ((h!=NULL) && (h->Typ()==PROC_CMD)) |
---|
2394 | { |
---|
2395 | procinfov p=(procinfov)h->Data(); |
---|
2396 | sdb_edit(p); |
---|
2397 | } |
---|
2398 | else |
---|
2399 | { |
---|
2400 | WerrorS("system(\"sdb_edit\",`proc`) expected"); |
---|
2401 | return TRUE; |
---|
2402 | } |
---|
2403 | return FALSE; |
---|
2404 | } |
---|
2405 | else |
---|
2406 | #endif |
---|
2407 | /*==================== GF =================*/ |
---|
2408 | #if 0 |
---|
2409 | if (strcmp(sys_cmd, "GF") == 0) |
---|
2410 | { |
---|
2411 | int c=rChar(currRing); |
---|
2412 | setCharacteristic( c, 2); |
---|
2413 | CanonicalForm F( convSingGFClapGF( (poly)h->Data() ) ); |
---|
2414 | res->rtyp=POLY_CMD; |
---|
2415 | res->data=convClapGFSingGF( F ); |
---|
2416 | return FALSE; |
---|
2417 | } |
---|
2418 | else |
---|
2419 | #endif |
---|
2420 | /*==================== stdX =================*/ |
---|
2421 | if (strcmp(sys_cmd, "std") == 0) |
---|
2422 | { |
---|
2423 | ideal i1; |
---|
2424 | int i2; |
---|
2425 | if ((h!=NULL) && (h->Typ()==MODUL_CMD)) |
---|
2426 | { |
---|
2427 | i1=(ideal)h->CopyD(); |
---|
2428 | h=h->next; |
---|
2429 | } |
---|
2430 | else return TRUE; |
---|
2431 | if ((h!=NULL) && (h->Typ()==INT_CMD)) |
---|
2432 | { |
---|
2433 | i2=(int)((long)h->Data()); |
---|
2434 | } |
---|
2435 | else return TRUE; |
---|
2436 | res->rtyp=MODUL_CMD; |
---|
2437 | res->data=idXXX(i1,i2); |
---|
2438 | return FALSE; |
---|
2439 | } |
---|
2440 | else |
---|
2441 | #ifdef ix86_Win |
---|
2442 | #ifdef HAVE_DL |
---|
2443 | /*==================== DLL =================*/ |
---|
2444 | /* testing the DLL functionality under Win32 */ |
---|
2445 | if (strcmp(sys_cmd, "DLL") == 0) |
---|
2446 | { |
---|
2447 | typedef void (*Void_Func)(); |
---|
2448 | typedef int (*Int_Func)(int); |
---|
2449 | void *hh=dynl_open("WinDllTest.dll"); |
---|
2450 | if ((h!=NULL) && (h->Typ()==INT_CMD)) |
---|
2451 | { |
---|
2452 | int (*f)(int); |
---|
2453 | if (hh!=NULL) |
---|
2454 | { |
---|
2455 | int (*f)(int); |
---|
2456 | f=(Int_Func)dynl_sym(hh,"PlusDll"); |
---|
2457 | int i=10; |
---|
2458 | if (f!=NULL) printf("%d\n",f(i)); |
---|
2459 | else PrintS("cannot find PlusDll\n"); |
---|
2460 | } |
---|
2461 | } |
---|
2462 | else |
---|
2463 | { |
---|
2464 | void (*f)(); |
---|
2465 | f= (Void_Func)dynl_sym(hh,"TestDll"); |
---|
2466 | if (f!=NULL) f(); |
---|
2467 | else PrintS("cannot find TestDll\n"); |
---|
2468 | } |
---|
2469 | return FALSE; |
---|
2470 | } |
---|
2471 | else |
---|
2472 | #endif |
---|
2473 | #endif |
---|
2474 | /*==================== eigenvalues ==================================*/ |
---|
2475 | #ifdef HAVE_EIGENVAL |
---|
2476 | if(strcmp(sys_cmd,"eigenvals")==0) |
---|
2477 | { |
---|
2478 | return evEigenvals(res,h); |
---|
2479 | } |
---|
2480 | else |
---|
2481 | #endif |
---|
2482 | /*==================== Gauss-Manin system ==================================*/ |
---|
2483 | #ifdef HAVE_GMS |
---|
2484 | if(strcmp(sys_cmd,"gmsnf")==0) |
---|
2485 | { |
---|
2486 | return gmsNF(res,h); |
---|
2487 | } |
---|
2488 | else |
---|
2489 | #endif |
---|
2490 | /*==================== facstd_debug ==================================*/ |
---|
2491 | #if !defined(NDEBUG) |
---|
2492 | if(strcmp(sys_cmd,"facstd")==0) |
---|
2493 | { |
---|
2494 | extern int strat_nr; |
---|
2495 | extern int strat_fac_debug; |
---|
2496 | strat_fac_debug=(int)(long)h->Data(); |
---|
2497 | strat_nr=0; |
---|
2498 | return FALSE; |
---|
2499 | } |
---|
2500 | else |
---|
2501 | #endif |
---|
2502 | #ifdef HAVE_RING2TOM |
---|
2503 | /*==================== ring-GB ==================================*/ |
---|
2504 | if (strcmp(sys_cmd, "findZeroPoly")==0) |
---|
2505 | { |
---|
2506 | ring r = currRing; |
---|
2507 | poly f = (poly) h->Data(); |
---|
2508 | res->rtyp=POLY_CMD; |
---|
2509 | res->data=(poly) kFindZeroPoly(f, r, r); |
---|
2510 | return(FALSE); |
---|
2511 | } |
---|
2512 | else |
---|
2513 | if (strcmp(sys_cmd, "NF_ring")==0) |
---|
2514 | { |
---|
2515 | ring r = currRing; |
---|
2516 | poly f = (poly) h->Data(); |
---|
2517 | h = h->next; |
---|
2518 | ideal G = (ideal) h->Data(); |
---|
2519 | res->rtyp=POLY_CMD; |
---|
2520 | res->data=(poly) ringNF(f, G, r); |
---|
2521 | return(FALSE); |
---|
2522 | } |
---|
2523 | else |
---|
2524 | if (strcmp(sys_cmd, "redNF_ring")==0) |
---|
2525 | { |
---|
2526 | ring r = currRing; |
---|
2527 | poly f = (poly) h->Data(); |
---|
2528 | h = h->next; |
---|
2529 | ideal G = (ideal) h->Data(); |
---|
2530 | res->rtyp=POLY_CMD; |
---|
2531 | res->data=(poly) ringRedNF(f, G, r); |
---|
2532 | return(FALSE); |
---|
2533 | } |
---|
2534 | else |
---|
2535 | if (strcmp(sys_cmd, "reduce_fct")==0) |
---|
2536 | { |
---|
2537 | ring r = currRing; |
---|
2538 | poly f = (poly)h->Data(); |
---|
2539 | res->rtyp=POLY_CMD; |
---|
2540 | res->data=NULL; |
---|
2541 | return(FALSE); |
---|
2542 | } |
---|
2543 | else |
---|
2544 | #endif |
---|
2545 | /*==================== t-rep-GB ==================================*/ |
---|
2546 | if (strcmp(sys_cmd, "unifastmult")==0) |
---|
2547 | { |
---|
2548 | ring r = currRing; |
---|
2549 | poly f = (poly)h->Data(); |
---|
2550 | h=h->next; |
---|
2551 | poly g=(poly)h->Data(); |
---|
2552 | res->rtyp=POLY_CMD; |
---|
2553 | res->data=unifastmult(f,g,currRing); |
---|
2554 | return(FALSE); |
---|
2555 | } |
---|
2556 | else |
---|
2557 | if (strcmp(sys_cmd, "multifastmult")==0) |
---|
2558 | { |
---|
2559 | ring r = currRing; |
---|
2560 | poly f = (poly)h->Data(); |
---|
2561 | h=h->next; |
---|
2562 | poly g=(poly)h->Data(); |
---|
2563 | res->rtyp=POLY_CMD; |
---|
2564 | res->data=multifastmult(f,g,currRing); |
---|
2565 | return(FALSE); |
---|
2566 | } |
---|
2567 | else |
---|
2568 | if (strcmp(sys_cmd, "mults")==0) |
---|
2569 | { |
---|
2570 | res->rtyp=INT_CMD ; |
---|
2571 | res->data=(void*) Mults(); |
---|
2572 | return(FALSE); |
---|
2573 | } |
---|
2574 | else |
---|
2575 | if (strcmp(sys_cmd, "fastpower")==0) |
---|
2576 | { |
---|
2577 | ring r = currRing; |
---|
2578 | poly f = (poly)h->Data(); |
---|
2579 | h=h->next; |
---|
2580 | int n=(int)((long)h->Data()); |
---|
2581 | res->rtyp=POLY_CMD ; |
---|
2582 | res->data=(void*) pFastPower(f,n,r); |
---|
2583 | return(FALSE); |
---|
2584 | } |
---|
2585 | else |
---|
2586 | if (strcmp(sys_cmd, "normalpower")==0) |
---|
2587 | { |
---|
2588 | ring r = currRing; |
---|
2589 | poly f = (poly)h->Data(); |
---|
2590 | h=h->next; |
---|
2591 | int n=(int)((long)h->Data()); |
---|
2592 | res->rtyp=POLY_CMD ; |
---|
2593 | res->data=(void*) pPower(pCopy(f),n); |
---|
2594 | return(FALSE); |
---|
2595 | } |
---|
2596 | else |
---|
2597 | if (strcmp(sys_cmd, "MCpower")==0) |
---|
2598 | { |
---|
2599 | ring r = currRing; |
---|
2600 | poly f = (poly)h->Data(); |
---|
2601 | h=h->next; |
---|
2602 | int n=(int)((long)h->Data()); |
---|
2603 | res->rtyp=POLY_CMD ; |
---|
2604 | res->data=(void*) pFastPowerMC(f,n,r); |
---|
2605 | return(FALSE); |
---|
2606 | } |
---|
2607 | else |
---|
2608 | if (strcmp(sys_cmd, "bit_subst")==0) |
---|
2609 | { |
---|
2610 | ring r = currRing; |
---|
2611 | poly outer = (poly)h->Data(); |
---|
2612 | h=h->next; |
---|
2613 | poly inner=(poly)h->Data(); |
---|
2614 | res->rtyp=POLY_CMD ; |
---|
2615 | res->data=(void*) uni_subst_bits(outer, inner,r); |
---|
2616 | return(FALSE); |
---|
2617 | } |
---|
2618 | else |
---|
2619 | /*==================== bifac =================*/ |
---|
2620 | #ifdef HAVE_BIFAC |
---|
2621 | if (strcmp(sys_cmd, "bifac")==0) |
---|
2622 | { |
---|
2623 | if (h->Typ()!=POLY_CMD) |
---|
2624 | { |
---|
2625 | WerrorS("`system(\"bifac\",<poly>) expected"); |
---|
2626 | return TRUE; |
---|
2627 | } |
---|
2628 | if (!rField_is_Q()) |
---|
2629 | { |
---|
2630 | WerrorS("coeff field must be Q"); |
---|
2631 | return TRUE; |
---|
2632 | } |
---|
2633 | BIFAC B; |
---|
2634 | CFFList C; |
---|
2635 | int sw_rat=isOn(SW_RATIONAL); |
---|
2636 | On(SW_RATIONAL); |
---|
2637 | CanonicalForm F( convSingPClapP((poly)(h->Data()))); |
---|
2638 | B.bifac(F, 1); |
---|
2639 | CFFList L=B.getFactors(); |
---|
2640 | // construct the ring ============================================== |
---|
2641 | int i; |
---|
2642 | int lev=ExtensionLevel(); |
---|
2643 | char **names=(char**)omAlloc0(lev*sizeof(char_ptr)); |
---|
2644 | for(i=1;i<=lev; i++) |
---|
2645 | { |
---|
2646 | StringSetS(""); |
---|
2647 | names[i-1]=omStrDup(StringAppend("a(%d)",i)); |
---|
2648 | } |
---|
2649 | ring alg_ring=rDefault(0,lev,names); |
---|
2650 | ring new_ring=rCopy0(currRing); // all variable names, ordering etc. |
---|
2651 | new_ring->P=lev; |
---|
2652 | new_ring->parameter=names; |
---|
2653 | new_ring->algring=alg_ring; |
---|
2654 | new_ring->ch=1; |
---|
2655 | rComplete(new_ring,TRUE); |
---|
2656 | // set the mipo =============================================== |
---|
2657 | ring save_currRing=currRing; idhdl save_currRingHdl=currRingHdl; |
---|
2658 | rChangeCurrRing(alg_ring); |
---|
2659 | ideal mipo_id=idInit(lev,1); |
---|
2660 | for (i=lev; i>0;i--) |
---|
2661 | { |
---|
2662 | CanonicalForm Mipo=getMipo(Variable(-i),Variable(i)); |
---|
2663 | mipo_id->m[i-1]=convClapPSingP(Mipo); |
---|
2664 | } |
---|
2665 | idShow(mipo_id); |
---|
2666 | alg_ring->qideal=mipo_id; |
---|
2667 | rChangeCurrRing(new_ring); |
---|
2668 | for (i=lev-1; i>=0;i--) |
---|
2669 | { |
---|
2670 | poly p=pOne(); |
---|
2671 | lnumber n=(lnumber)pGetCoeff(p); |
---|
2672 | // no need to delete nac 1 |
---|
2673 | n->z=(napoly)mipo_id->m[i]; |
---|
2674 | mipo_id->m[i]=p; |
---|
2675 | } |
---|
2676 | new_ring->minideal=id_Copy(alg_ring->qideal,new_ring); |
---|
2677 | // convert factors ============================================= |
---|
2678 | ideal fac_id=idInit(L.length(),1); |
---|
2679 | CFFListIterator J=L; |
---|
2680 | i=0; |
---|
2681 | intvec *v = new intvec( L.length() ); |
---|
2682 | for ( ; J.hasItem(); J++,i++ ) |
---|
2683 | { |
---|
2684 | fac_id->m[i]=convClapAPSingAP( J.getItem().factor() ); |
---|
2685 | (*v)[i]=J.getItem().exp(); |
---|
2686 | } |
---|
2687 | idhdl hh=enterid("factors",0,LIST_CMD,&(currRing->idroot),FALSE); |
---|
2688 | lists LL=(lists)omAllocBin( slists_bin); |
---|
2689 | LL->Init(2); |
---|
2690 | LL->m[0].rtyp=IDEAL_CMD; |
---|
2691 | LL->m[0].data=(char *)fac_id; |
---|
2692 | LL->m[1].rtyp=INTVEC_CMD; |
---|
2693 | LL->m[1].data=(char *)v; |
---|
2694 | IDDATA(hh)=(char *)LL; |
---|
2695 | |
---|
2696 | rChangeCurrRing(save_currRing); |
---|
2697 | currRingHdl=save_currRingHdl; |
---|
2698 | if (!sw_rat) Off(SW_RATIONAL); |
---|
2699 | |
---|
2700 | res->data=new_ring; |
---|
2701 | res->rtyp=RING_CMD; |
---|
2702 | return FALSE; |
---|
2703 | } |
---|
2704 | else |
---|
2705 | #endif |
---|
2706 | /*==================== gcd-varianten =================*/ |
---|
2707 | if (strcmp(sys_cmd, "gcd") == 0) |
---|
2708 | { |
---|
2709 | if (h==NULL) |
---|
2710 | { |
---|
2711 | Print("NTL_0:%d (use NTL for gcd of polynomials in char 0)\n",isOn(SW_USE_NTL_GCD_0)); |
---|
2712 | Print("NTL_p:%d (use NTL for gcd of polynomials in char p)\n",isOn(SW_USE_NTL_GCD_P)); |
---|
2713 | Print("EZGCD:%d (use EZGCD for gcd of polynomials in char 0)\n",isOn(SW_USE_EZGCD)); |
---|
2714 | Print("SPARSEMOD:%d (use SPARSEMOD for gcd of polynomials in char 0)\n",isOn(SW_USE_SPARSEMOD)); |
---|
2715 | Print("homog:%d (use homog. test for factorization of polynomials)\n",singular_homog_flag); |
---|
2716 | return FALSE; |
---|
2717 | } |
---|
2718 | else |
---|
2719 | if ((h!=NULL) && (h->Typ()==STRING_CMD) |
---|
2720 | && (h->next!=NULL) && (h->next->Typ()==INT_CMD)) |
---|
2721 | { |
---|
2722 | int d=(int)(long)h->next->Data(); |
---|
2723 | char *s=(char *)h->Data(); |
---|
2724 | if (strcmp(s,"NTL_0")==0) { if (d) On(SW_USE_NTL_GCD_0); else Off(SW_USE_NTL_GCD_0); } else |
---|
2725 | if (strcmp(s,"NTL_p")==0) { if (d) On(SW_USE_NTL_GCD_P); else Off(SW_USE_NTL_GCD_P); } else |
---|
2726 | if (strcmp(s,"EZGCD")==0) { if (d) On(SW_USE_EZGCD); else Off(SW_USE_EZGCD); } else |
---|
2727 | if (strcmp(s,"SPARSEMOD")==0) { if (d) On(SW_USE_SPARSEMOD); else Off(SW_USE_SPARSEMOD); } else |
---|
2728 | if (strcmp(s,"homog")==0) { if (d) singular_homog_flag=1; else singular_homog_flag=0; } else |
---|
2729 | return TRUE; |
---|
2730 | return FALSE; |
---|
2731 | } |
---|
2732 | else return TRUE; |
---|
2733 | } |
---|
2734 | else |
---|
2735 | #ifdef ix86_Win |
---|
2736 | /*==================== Python Singular =================*/ |
---|
2737 | if (strcmp(sys_cmd, "python") == 0) |
---|
2738 | { |
---|
2739 | const char* c; |
---|
2740 | if ((h!=NULL) && (h->Typ()==STRING_CMD)) |
---|
2741 | { |
---|
2742 | c=(const char*)h->Data(); |
---|
2743 | if (!PyInitialized) { |
---|
2744 | PyInitialized = 1; |
---|
2745 | // Py_Initialize(); |
---|
2746 | // initPySingular(); |
---|
2747 | } |
---|
2748 | // PyRun_SimpleString(c); |
---|
2749 | return FALSE; |
---|
2750 | } |
---|
2751 | else return TRUE; |
---|
2752 | } |
---|
2753 | else |
---|
2754 | /*==================== Python Singular ================= |
---|
2755 | if (strcmp(sys_cmd, "ipython") == 0) |
---|
2756 | { |
---|
2757 | const char* c; |
---|
2758 | { |
---|
2759 | if (!PyInitialized) { |
---|
2760 | PyInitialized = 1; |
---|
2761 | Py_Initialize(); |
---|
2762 | initPySingular(); |
---|
2763 | } |
---|
2764 | PyRun_SimpleString( |
---|
2765 | "try: \n\ |
---|
2766 | __IPYTHON__ \n\ |
---|
2767 | except NameError: \n\ |
---|
2768 | argv = [''] \n\ |
---|
2769 | banner = exit_msg = '' \n\ |
---|
2770 | else: \n\ |
---|
2771 | # Command-line options for IPython (a list like sys.argv) \n\ |
---|
2772 | argv = ['-pi1','In <\\#>:','-pi2',' .\\D.:','-po','Out<\\#>:'] \n\ |
---|
2773 | banner = '*** Nested interpreter ***' \n\ |
---|
2774 | exit_msg = '*** Back in main IPython ***' \n\ |
---|
2775 | \n\ |
---|
2776 | # First import the embeddable shell class \n\ |
---|
2777 | from IPython.Shell import IPShellEmbed \n\ |
---|
2778 | # Now create the IPython shell instance. Put ipshell() anywhere in your code \n\ |
---|
2779 | # where you want it to open. \n\ |
---|
2780 | ipshell = IPShellEmbed(argv,banner=banner,exit_msg=exit_msg) \n\ |
---|
2781 | ipshell()"); |
---|
2782 | return FALSE; |
---|
2783 | } |
---|
2784 | } |
---|
2785 | else |
---|
2786 | */ |
---|
2787 | #endif |
---|
2788 | /*==================== Error =================*/ |
---|
2789 | Werror( "system(\"%s\",...) %s", sys_cmd, feNotImplemented ); |
---|
2790 | } |
---|
2791 | return TRUE; |
---|
2792 | } |
---|
2793 | #endif // HAVE_EXTENDED_SYSTEM |
---|
2794 | |
---|