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