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