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