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