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