1 | /***************************************** |
---|
2 | * Computer Algebra System SINGULAR * |
---|
3 | *****************************************/ |
---|
4 | /* $Id: extra.cc,v 1.31 1998-03-27 15:43:27 obachman Exp $ */ |
---|
5 | /* |
---|
6 | * ABSTRACT: general interface to internals of Singular ("system" command) |
---|
7 | */ |
---|
8 | |
---|
9 | #include <stdlib.h> |
---|
10 | #include <stdio.h> |
---|
11 | #include <string.h> |
---|
12 | #include <ctype.h> |
---|
13 | #include "mod2.h" |
---|
14 | |
---|
15 | #ifndef macintosh |
---|
16 | #ifdef TIME_WITH_SYS_TIME |
---|
17 | # include <time.h> |
---|
18 | # ifdef HAVE_SYS_TIME_H |
---|
19 | # include <sys/time.h> |
---|
20 | # endif |
---|
21 | #else |
---|
22 | # ifdef HAVE_SYS_TIME_H |
---|
23 | # include <sys/time.h> |
---|
24 | # else |
---|
25 | # include <time.h> |
---|
26 | # endif |
---|
27 | #endif |
---|
28 | #ifdef HAVE_SYS_TIMES_H |
---|
29 | #include <sys/times.h> |
---|
30 | #endif |
---|
31 | |
---|
32 | #include <unistd.h> |
---|
33 | #endif |
---|
34 | |
---|
35 | #include "tok.h" |
---|
36 | #include "ipid.h" |
---|
37 | #include "polys.h" |
---|
38 | #include "kutil.h" |
---|
39 | #include "cntrlc.h" |
---|
40 | #include "stairc.h" |
---|
41 | #include "ipshell.h" |
---|
42 | #include "algmap.h" |
---|
43 | #include "modulop.h" |
---|
44 | #include "febase.h" |
---|
45 | #include "matpol.h" |
---|
46 | #include "longalg.h" |
---|
47 | #include "ideals.h" |
---|
48 | #include "kstd1.h" |
---|
49 | #include "syz.h" |
---|
50 | #include "polys.h" |
---|
51 | |
---|
52 | #ifdef STDTRACE |
---|
53 | //#include "comm.h" |
---|
54 | #endif |
---|
55 | |
---|
56 | #ifdef HAVE_FACTORY |
---|
57 | #define SI_DONT_HAVE_GLOBAL_VARS |
---|
58 | #include "clapsing.h" |
---|
59 | #include "clapconv.h" |
---|
60 | #include "kstdfac.h" |
---|
61 | #include "fglmcomb.cc" |
---|
62 | #include "fglm.h" |
---|
63 | #endif |
---|
64 | |
---|
65 | #include "silink.h" |
---|
66 | #include "mpsr.h" |
---|
67 | |
---|
68 | //void emStart(); |
---|
69 | /*2 |
---|
70 | * the "system" command |
---|
71 | */ |
---|
72 | BOOLEAN jjSYSTEM(leftv res, leftv h) |
---|
73 | { |
---|
74 | if(h->Typ() == STRING_CMD) |
---|
75 | { |
---|
76 | /*==================== test ==================================*/ |
---|
77 | if(strcmp((char*)(h->Data()),"x")==0) |
---|
78 | { |
---|
79 | int i=3; |
---|
80 | int j=2; |
---|
81 | j=i/(j-j); |
---|
82 | res->data=(void *)j; |
---|
83 | return FALSE; |
---|
84 | } |
---|
85 | else |
---|
86 | /*==================== lib ==================================*/ |
---|
87 | if(strcmp((char*)(h->Data()),"LIB")==0) |
---|
88 | { |
---|
89 | idhdl hh=idroot->get((char*)h->next->Data(),0); |
---|
90 | if ((hh!=NULL)&&(IDTYP(hh)==PROC_CMD)) |
---|
91 | { |
---|
92 | res->rtyp=STRING_CMD; |
---|
93 | res->data=mstrdup(iiGetLibName(IDPROC(hh))); |
---|
94 | if (res->data==NULL) res->data=mstrdup(""); |
---|
95 | return FALSE; |
---|
96 | } |
---|
97 | else |
---|
98 | Warn("`%s` not found",(char*)h->next->Data()); |
---|
99 | } |
---|
100 | else |
---|
101 | /*==================== proclist =================================*/ |
---|
102 | if(strcmp((char*)(h->Data()),"proclist")==0) |
---|
103 | { |
---|
104 | int piShowProcList(); |
---|
105 | res->rtyp=STRING_CMD; |
---|
106 | res->data=(void *)mstrdup(""); |
---|
107 | piShowProcList(); |
---|
108 | return FALSE; |
---|
109 | } |
---|
110 | else |
---|
111 | /*==================== version ==================================*/ |
---|
112 | if(strcmp((char*)(h->Data()),"version")==0) |
---|
113 | { |
---|
114 | res->rtyp=INT_CMD; |
---|
115 | res->data=(void *)SINGULAR_VERSION; |
---|
116 | return FALSE; |
---|
117 | } |
---|
118 | else |
---|
119 | /*==================== gen ==================================*/ |
---|
120 | if(strcmp((char*)(h->Data()),"gen")==0) |
---|
121 | { |
---|
122 | res->rtyp=INT_CMD; |
---|
123 | res->data=(void *)npGen; |
---|
124 | return FALSE; |
---|
125 | } |
---|
126 | else |
---|
127 | /*==================== sh ==================================*/ |
---|
128 | #ifndef macintosh |
---|
129 | if(strcmp((char*)(h->Data()),"sh")==0) |
---|
130 | { |
---|
131 | #ifndef MSDOS |
---|
132 | #ifdef HAVE_FEREAD |
---|
133 | fe_temp_reset(); |
---|
134 | #endif |
---|
135 | #endif |
---|
136 | res->rtyp=INT_CMD; |
---|
137 | if (h->next==NULL) res->data = (void *)system("/bin/sh"); |
---|
138 | else res->data = (void*) system((char*)(h->next->Data())); |
---|
139 | #ifndef MSDOS |
---|
140 | #ifdef HAVE_FEREAD |
---|
141 | fe_temp_set(); |
---|
142 | #endif |
---|
143 | #endif |
---|
144 | return FALSE; |
---|
145 | } |
---|
146 | else |
---|
147 | #endif |
---|
148 | /*==================== with ==================================*/ |
---|
149 | if(strcmp((char*)(h->Data()),"with")==0) |
---|
150 | { |
---|
151 | if (h->next==NULL) |
---|
152 | { |
---|
153 | res->rtyp=STRING_CMD; |
---|
154 | res->data=(void *)mstrdup(versionString()); |
---|
155 | return FALSE; |
---|
156 | } |
---|
157 | else if (h->next->Typ()==STRING_CMD) |
---|
158 | { |
---|
159 | #define TEST_FOR(A) if(strcmp(s,A)==0) res->data=(void *)1; else |
---|
160 | char *s=(char *)h->next->Data(); |
---|
161 | res->rtyp=INT_CMD; |
---|
162 | #ifdef DRING |
---|
163 | TEST_FOR("DRING") |
---|
164 | #endif |
---|
165 | #ifdef HAVE_DBM |
---|
166 | TEST_FOR("DBM") |
---|
167 | #endif |
---|
168 | #ifdef HAVE_DLD |
---|
169 | TEST_FOR("DLD") |
---|
170 | #endif |
---|
171 | #ifdef HAVE_GMP |
---|
172 | TEST_FOR("gmp") |
---|
173 | #endif |
---|
174 | #ifdef HAVE_FACTORY |
---|
175 | TEST_FOR("factory") |
---|
176 | #endif |
---|
177 | #ifdef HAVE_LIBFAC_P |
---|
178 | TEST_FOR("libfac") |
---|
179 | #endif |
---|
180 | #ifdef HAVE_MPSR |
---|
181 | TEST_FOR("MP") |
---|
182 | #endif |
---|
183 | #ifdef HAVE_READLINE |
---|
184 | TEST_FOR("readline") |
---|
185 | #endif |
---|
186 | #ifdef HAVE_TCL |
---|
187 | TEST_FOR("tcl") |
---|
188 | #endif |
---|
189 | #ifdef SRING |
---|
190 | TEST_FOR("SRING") |
---|
191 | #endif |
---|
192 | #ifdef TEST_MAC_ORDER |
---|
193 | TEST_FOR("MAC_ORDER"); |
---|
194 | #endif |
---|
195 | ; |
---|
196 | return FALSE; |
---|
197 | #undef TEST_FOR |
---|
198 | } |
---|
199 | return TRUE; |
---|
200 | } |
---|
201 | else |
---|
202 | /*==================== pid ==================================*/ |
---|
203 | #ifndef MSDOS |
---|
204 | #ifndef macintosh |
---|
205 | if (strcmp((char*)(h->Data()),"pid")==0) |
---|
206 | { |
---|
207 | res->rtyp=INT_CMD; |
---|
208 | res->data=(void *)getpid(); |
---|
209 | return FALSE; |
---|
210 | } |
---|
211 | else |
---|
212 | #endif |
---|
213 | #endif |
---|
214 | /*==================== getenv ==================================*/ |
---|
215 | if (strcmp((char*)(h->Data()),"getenv")==0) |
---|
216 | { |
---|
217 | if ((h->next!=NULL) && (h->next->Typ()==STRING_CMD)) |
---|
218 | { |
---|
219 | res->rtyp=STRING_CMD; |
---|
220 | char *r=getenv((char *)h->next->Data()); |
---|
221 | if (r==NULL) r=""; |
---|
222 | res->data=(void *)mstrdup(r); |
---|
223 | return FALSE; |
---|
224 | } |
---|
225 | else |
---|
226 | { |
---|
227 | WerrorS("string expected"); |
---|
228 | } |
---|
229 | } |
---|
230 | else |
---|
231 | /*==================== tty ==================================*/ |
---|
232 | #ifndef macintosh |
---|
233 | #ifndef MSDOS |
---|
234 | #if defined(HAVE_FEREAD) || defined(HAVE_READLINE) |
---|
235 | if (strcmp((char*)(h->Data()),"tty")==0) |
---|
236 | { |
---|
237 | #ifdef HAVE_FEREAD |
---|
238 | #ifdef HAVE_ATEXIT |
---|
239 | fe_reset_input_mode(); |
---|
240 | #else |
---|
241 | fe_reset_input_mode(0,NULL); |
---|
242 | #endif |
---|
243 | #elif defined(HAVE_READLINE) |
---|
244 | system("stty sane"); |
---|
245 | #endif |
---|
246 | if ((h->next!=NULL)&&(h->next->Typ()==INT_CMD)) |
---|
247 | { |
---|
248 | fe_use_fgets=(int)h->next->Data(); |
---|
249 | fe_set_input_mode(); |
---|
250 | } |
---|
251 | return FALSE; |
---|
252 | } |
---|
253 | else |
---|
254 | #endif |
---|
255 | #endif |
---|
256 | #endif |
---|
257 | /*==================== HC ==================================*/ |
---|
258 | if (strcmp((char*)(h->data),"HC")==0) |
---|
259 | { |
---|
260 | res->rtyp=INT_CMD; |
---|
261 | res->data=(void *)HCord; |
---|
262 | return FALSE; |
---|
263 | } |
---|
264 | else |
---|
265 | /*==================== random ==================================*/ |
---|
266 | if(strcmp((char*)(h->Data()),"random")==0) |
---|
267 | { |
---|
268 | if ((h->next!=NULL) &&(h->next->Typ()==INT_CMD)) |
---|
269 | { |
---|
270 | siRandomStart=(int)h->next->Data(); |
---|
271 | #ifdef buildin_rand |
---|
272 | siSeed=siRandomStart; |
---|
273 | #else |
---|
274 | srand((unsigned int)siRandomStart); |
---|
275 | #endif |
---|
276 | return FALSE; |
---|
277 | } |
---|
278 | else |
---|
279 | WerrorS("int expected"); |
---|
280 | } |
---|
281 | else |
---|
282 | /*==================== LaScala ==================================*/ |
---|
283 | if(strcmp((char*)(h->Data()),"LaScala")==0) |
---|
284 | { |
---|
285 | if ((h->next!=NULL) |
---|
286 | &&((h->next->Typ()==IDEAL_CMD)||(h->next->Typ()==MODUL_CMD))) |
---|
287 | { |
---|
288 | int dummy; |
---|
289 | res->data=(void *)syLaScala3((ideal)h->next->Data(),&dummy); |
---|
290 | mmTest(res->data,sizeof(ssyStrategy)); |
---|
291 | syStrategy s=(syStrategy)res->data; |
---|
292 | for (int i=s->length;i>=0;i--) |
---|
293 | { |
---|
294 | if (s->res[i]!=NULL) |
---|
295 | idTest(s->res[i]); |
---|
296 | } |
---|
297 | res->rtyp=RESOLUTION_CMD; |
---|
298 | return FALSE; |
---|
299 | } |
---|
300 | else |
---|
301 | WerrorS("ideal/module expected"); |
---|
302 | } |
---|
303 | else |
---|
304 | /*==================== naIdeal ==================================*/ |
---|
305 | if(strcmp((char*)(h->Data()),"naIdeal")==0) |
---|
306 | { |
---|
307 | if ((h->next!=NULL) &&(h->next->Typ()==IDEAL_CMD)) |
---|
308 | { |
---|
309 | naSetIdeal((ideal)h->next->Data()); |
---|
310 | return FALSE; |
---|
311 | } |
---|
312 | else |
---|
313 | WerrorS("ideal expected"); |
---|
314 | } |
---|
315 | else |
---|
316 | /*==================== isSqrFree =============================*/ |
---|
317 | #ifdef HAVE_FACTORY |
---|
318 | if(strcmp((char*)(h->Data()),"isSqrFree")==0) |
---|
319 | { |
---|
320 | if ((h->next!=NULL) &&(h->next->Typ()==POLY_CMD)) |
---|
321 | { |
---|
322 | res->rtyp=INT_CMD; |
---|
323 | res->data=(void *)singclap_isSqrFree((poly)h->next->Data()); |
---|
324 | return FALSE; |
---|
325 | } |
---|
326 | else |
---|
327 | WerrorS("poly expected"); |
---|
328 | } |
---|
329 | else |
---|
330 | #endif |
---|
331 | /*==================== neworder =============================*/ |
---|
332 | #ifdef HAVE_LIBFAC_P |
---|
333 | if(strcmp((char*)(h->Data()),"neworder")==0) |
---|
334 | { |
---|
335 | if ((h->next!=NULL) &&(h->next->Typ()==IDEAL_CMD)) |
---|
336 | { |
---|
337 | res->rtyp=STRING_CMD; |
---|
338 | res->data=(void *)singclap_neworder((ideal)h->next->Data()); |
---|
339 | return FALSE; |
---|
340 | } |
---|
341 | else |
---|
342 | WerrorS("ideal expected"); |
---|
343 | } |
---|
344 | else |
---|
345 | #endif |
---|
346 | /*==================== alarm ==================================*/ |
---|
347 | #ifndef macintosh |
---|
348 | #ifndef MSDOS |
---|
349 | #ifndef atarist |
---|
350 | #ifdef unix |
---|
351 | if(strcmp((char*)(h->Data()),"alarm")==0) |
---|
352 | { |
---|
353 | if ((h->next!=NULL) &&(h->next->Typ()==INT_CMD)) |
---|
354 | { |
---|
355 | // standard variant -> SIGALARM (standard: abort) |
---|
356 | //alarm((unsigned)h->next->Data()); |
---|
357 | // process time (user +system): SIGVTALARM |
---|
358 | struct itimerval t,o; |
---|
359 | memset(&t,0,sizeof(t)); |
---|
360 | t.it_value.tv_sec =(unsigned)h->next->Data(); |
---|
361 | setitimer(ITIMER_VIRTUAL,&t,&o); |
---|
362 | return FALSE; |
---|
363 | } |
---|
364 | else |
---|
365 | WerrorS("int expected"); |
---|
366 | } |
---|
367 | else |
---|
368 | #endif |
---|
369 | #endif |
---|
370 | #endif |
---|
371 | #endif |
---|
372 | /*==================== red =============================*/ |
---|
373 | #if 0 |
---|
374 | if(strcmp((char*)(h->Data()),"red")==0) |
---|
375 | { |
---|
376 | if ((h->next!=NULL) &&(h->next->Typ()==IDEAL_CMD)) |
---|
377 | { |
---|
378 | res->rtyp=IDEAL_CMD; |
---|
379 | res->data=(void *)stdred((ideal)h->next->Data(),NULL,testHomog,NULL); |
---|
380 | setFlag(res,FLAG_STD); |
---|
381 | return FALSE; |
---|
382 | } |
---|
383 | else |
---|
384 | WerrorS("ideal expected"); |
---|
385 | } |
---|
386 | else |
---|
387 | #endif |
---|
388 | /*==================== writemat ==================================*/ |
---|
389 | // if(strcmp((char*)(h->Data()),"writemat")==0) |
---|
390 | // { |
---|
391 | // if (h->next!=NULL) |
---|
392 | // { |
---|
393 | // leftv v=h->next; |
---|
394 | // if (v->Typ() == STRING_CMD) |
---|
395 | // { |
---|
396 | // char *filename = (char *)v->Data(); |
---|
397 | // v = v->next; |
---|
398 | // if (v->Typ()==MATRIX_CMD) |
---|
399 | // { |
---|
400 | // FILE *outfile = fopen(filename,"a"); |
---|
401 | // if (outfile==NULL) |
---|
402 | // { |
---|
403 | // Werror("cannot write to file %s",filename); |
---|
404 | // return TRUE; |
---|
405 | // } |
---|
406 | // matrix m=(matrix)v->Data(); |
---|
407 | // fprintf(outfile,"%d\n%d\n",MATROWS(m),MATCOLS(m)); |
---|
408 | // char *s = iiStringMatrix(m,2); |
---|
409 | // fprintf(outfile,"%s\n",s); |
---|
410 | // FreeL((ADDRESS)s); |
---|
411 | // fclose(outfile); |
---|
412 | // return FALSE; |
---|
413 | // } |
---|
414 | // else |
---|
415 | // { |
---|
416 | // WerrorS("matrix expected"); |
---|
417 | // } |
---|
418 | // } |
---|
419 | // else |
---|
420 | // { |
---|
421 | // WerrorS("string expected"); |
---|
422 | // } |
---|
423 | // } |
---|
424 | // else |
---|
425 | // WerrorS("matrix expected"); |
---|
426 | // } |
---|
427 | // else |
---|
428 | #ifdef HAVE_FACTORY |
---|
429 | /*==================== pdivide ====================*/ |
---|
430 | if (strcmp((char*)(h->Data()),"pdivide")==0) |
---|
431 | { |
---|
432 | if (h->next!=NULL && h->next->next!=NULL && |
---|
433 | h->next->Typ()==POLY_CMD && h->next->next->Typ()==POLY_CMD) |
---|
434 | { |
---|
435 | res->rtyp=POLY_CMD; |
---|
436 | res->data=(void*)(singclap_pdivide((poly)(h->next->Data()), |
---|
437 | (poly)(h->next->next->Data()))); |
---|
438 | return FALSE; |
---|
439 | } |
---|
440 | else |
---|
441 | WerrorS("poly expected"); |
---|
442 | } |
---|
443 | else |
---|
444 | #endif |
---|
445 | /*==================== algfetch =====================*/ |
---|
446 | if (strcmp((char*)(h->Data()),"algfetch")==0) |
---|
447 | { |
---|
448 | int k; |
---|
449 | idhdl w; |
---|
450 | ideal i0, i1; |
---|
451 | leftv v=h->next; |
---|
452 | ring r0=(ring)v->Data(); |
---|
453 | v = v->next; |
---|
454 | w = r0->idroot->get(v->Name(),myynest); |
---|
455 | i0 = IDIDEAL(w); |
---|
456 | i1 = idInit(IDELEMS(i0),i0->rank); |
---|
457 | for (k=0; k<IDELEMS(i1); k++) |
---|
458 | { |
---|
459 | i1->m[k] = maAlgpolyFetch(r0, i0->m[k]); |
---|
460 | } |
---|
461 | res->rtyp = IDEAL_CMD; |
---|
462 | res->data = (void*)i1; |
---|
463 | return FALSE; |
---|
464 | } |
---|
465 | else |
---|
466 | /*==================== algmap =======================*/ |
---|
467 | if (strcmp((char*)(h->Data()),"algmap")==0) |
---|
468 | { |
---|
469 | int k; |
---|
470 | idhdl w; |
---|
471 | ideal i0, i1, i, j; |
---|
472 | leftv v=h->next; |
---|
473 | ring r0=(ring)v->Data(); |
---|
474 | v = v->next; |
---|
475 | w = r0->idroot->get(v->Name(),myynest); |
---|
476 | i0 = IDIDEAL(w); |
---|
477 | v = v->next; |
---|
478 | i = (ideal)v->Data(); |
---|
479 | v = v->next; |
---|
480 | j = (ideal)v->Data(); |
---|
481 | i1 = idInit(IDELEMS(i0),i0->rank); |
---|
482 | for (k=0; k<IDELEMS(i1); k++) |
---|
483 | { |
---|
484 | i1->m[k] = maAlgpolyMap(r0, i0->m[k], i, j); |
---|
485 | } |
---|
486 | res->rtyp = IDEAL_CMD; |
---|
487 | res->data = (void*)i1; |
---|
488 | return FALSE; |
---|
489 | } |
---|
490 | else |
---|
491 | /*==================== indsetall =============================*/ |
---|
492 | if(strcmp((char*)(h->Data()),"indsetall")==0) |
---|
493 | { |
---|
494 | if ((h->next!=NULL) &&(h->next->Typ()==IDEAL_CMD)) |
---|
495 | { |
---|
496 | int i=0; |
---|
497 | if (h->next->next!=NULL) |
---|
498 | { |
---|
499 | if (h->next->next->Typ()==INT_CMD) |
---|
500 | i=(int)h->next->next->Data(); |
---|
501 | else |
---|
502 | { |
---|
503 | Warn("int expected"); |
---|
504 | } |
---|
505 | } |
---|
506 | res->rtyp=LIST_CMD; |
---|
507 | res->data=(void *)scIndIndset((ideal)h->next->Data(),i,currQuotient); |
---|
508 | return FALSE; |
---|
509 | } |
---|
510 | else |
---|
511 | WerrorS("ideal expected"); |
---|
512 | } |
---|
513 | else |
---|
514 | #ifdef STDTRACE |
---|
515 | /*==================== trace =============================*/ |
---|
516 | /* Parameter : Ideal, Liste mit Links. */ |
---|
517 | if(strcmp((char*)(h->Data()),"stdtrace")==0) |
---|
518 | { |
---|
519 | if ((h->next!=NULL) &&(h->next->Typ()==IDEAL_CMD)) |
---|
520 | { |
---|
521 | leftv root = NULL, |
---|
522 | ptr = NULL, |
---|
523 | lv = NULL; |
---|
524 | lists l = NULL; |
---|
525 | ideal I = (ideal)(h->next->Data()); |
---|
526 | lists links = (lists)(h->next->next->Data()); |
---|
527 | tHomog hom = testHomog; |
---|
528 | int rw = (int)(h->next->next->next->Data()); |
---|
529 | |
---|
530 | if(I==NULL) |
---|
531 | PrintS("I==NULL\n"); |
---|
532 | for(int i=0; i <= links->nr ; i++) |
---|
533 | { |
---|
534 | lv = (leftv)Alloc0(sizeof(sleftv)); |
---|
535 | lv->Copy(&(links->m[i])); |
---|
536 | if(root==NULL) |
---|
537 | root=lv; |
---|
538 | if(ptr==NULL) |
---|
539 | { |
---|
540 | ptr=lv; |
---|
541 | ptr->next=NULL; |
---|
542 | } |
---|
543 | else |
---|
544 | { |
---|
545 | ptr->next=lv; |
---|
546 | ptr=lv; |
---|
547 | } |
---|
548 | } |
---|
549 | ptr->next=NULL; |
---|
550 | l=TraceStd(root,rw,I,currQuotient,testHomog,NULL); |
---|
551 | idSkipZeroes(((ideal)l->m[0].Data())); |
---|
552 | res->rtyp=LIST_CMD; |
---|
553 | res->data=(void *) l; |
---|
554 | res->next=NULL; |
---|
555 | root->CleanUp(); |
---|
556 | Free(root,sizeof(sleftv)); |
---|
557 | return FALSE; |
---|
558 | } |
---|
559 | else |
---|
560 | WerrorS("ideal expected"); |
---|
561 | } |
---|
562 | else |
---|
563 | #endif |
---|
564 | #ifdef HAVE_FACTORY |
---|
565 | /*==================== fastcomb =============================*/ |
---|
566 | if(strcmp((char*)(h->Data()),"fastcomb")==0) |
---|
567 | { |
---|
568 | if ((h->next!=NULL) &&(h->next->Typ()==IDEAL_CMD)) |
---|
569 | { |
---|
570 | int i=0; |
---|
571 | if (h->next->next!=NULL) |
---|
572 | { |
---|
573 | if (h->next->next->Typ()!=POLY_CMD) |
---|
574 | { |
---|
575 | Warn("Wrong types for poly= comb(ideal,poly)"); |
---|
576 | } |
---|
577 | } |
---|
578 | res->rtyp=POLY_CMD; |
---|
579 | res->data=(void *)fglmLinearCombination((ideal)h->next->Data(),(poly)h->next->next->Data()); |
---|
580 | return FALSE; |
---|
581 | } |
---|
582 | else |
---|
583 | WerrorS("ideal expected"); |
---|
584 | } |
---|
585 | else |
---|
586 | /*==================== comb =============================*/ |
---|
587 | if(strcmp((char*)(h->Data()),"comb")==0) |
---|
588 | { |
---|
589 | if ((h->next!=NULL) &&(h->next->Typ()==IDEAL_CMD)) |
---|
590 | { |
---|
591 | int i=0; |
---|
592 | if (h->next->next!=NULL) |
---|
593 | { |
---|
594 | if (h->next->next->Typ()!=POLY_CMD) |
---|
595 | { |
---|
596 | Warn("Wrong types for poly= comb(ideal,poly)"); |
---|
597 | } |
---|
598 | } |
---|
599 | res->rtyp=POLY_CMD; |
---|
600 | res->data=(void *)fglmNewLinearCombination((ideal)h->next->Data(),(poly)h->next->next->Data()); |
---|
601 | return FALSE; |
---|
602 | } |
---|
603 | else |
---|
604 | WerrorS("ideal expected"); |
---|
605 | } |
---|
606 | else |
---|
607 | /*==================== finduni =============================*/ |
---|
608 | if(strcmp((char*)(h->Data()),"finduni")==0) |
---|
609 | { |
---|
610 | if ((h->next!=NULL) &&(h->next->Typ()==IDEAL_CMD)) |
---|
611 | { |
---|
612 | res->rtyp=IDEAL_CMD; |
---|
613 | res->data=(void *)FindUnivariateWrapper((ideal)h->next->Data()); |
---|
614 | return FALSE; |
---|
615 | } |
---|
616 | else |
---|
617 | WerrorS("ideal expected"); |
---|
618 | } |
---|
619 | else |
---|
620 | #endif |
---|
621 | /*==================== divcount & mcount =============================*/ |
---|
622 | #ifdef MONOM_COUNT |
---|
623 | if (strcmp((char*)(h->Data()),"mcount")==0) |
---|
624 | { |
---|
625 | extern void OutputMonomCount(); |
---|
626 | OutputMonomCount(); |
---|
627 | return FALSE; |
---|
628 | } |
---|
629 | else if (strcmp((char*)(h->Data()),"mreset")==0) |
---|
630 | { |
---|
631 | extern void ResetMonomCount(); |
---|
632 | ResetMonomCount(); |
---|
633 | return FALSE; |
---|
634 | } |
---|
635 | else |
---|
636 | #endif |
---|
637 | #ifdef DIV_COUNT |
---|
638 | if (strcmp((char*)(h->Data()),"dcount")==0) |
---|
639 | { |
---|
640 | extern void OutputDivCount(); |
---|
641 | OutputDivCount(); |
---|
642 | return FALSE; |
---|
643 | } |
---|
644 | else if (strcmp((char*)(h->Data()),"dreset")==0) |
---|
645 | { |
---|
646 | extern void ResetDivCount(); |
---|
647 | ResetDivCount(); |
---|
648 | return FALSE; |
---|
649 | } |
---|
650 | else |
---|
651 | #endif |
---|
652 | /*==================== barstep =============================*/ |
---|
653 | if(strcmp((char*)(h->Data()),"barstep")==0) |
---|
654 | { |
---|
655 | if ((h->next!=NULL) &&(h->next->Typ()==MATRIX_CMD)) |
---|
656 | { |
---|
657 | if (h->next->next!=NULL) |
---|
658 | { |
---|
659 | if (h->next->next->Typ()!=POLY_CMD) |
---|
660 | { |
---|
661 | Warn("Wrong types for barstep(matrix,poly)"); |
---|
662 | } |
---|
663 | } |
---|
664 | int r,c; |
---|
665 | poly div=(poly)h->next->next->Data(); |
---|
666 | res->rtyp=MATRIX_CMD; |
---|
667 | res->data=(void *)mpOneStepBareiss((matrix)h->next->Data(), |
---|
668 | &div,&r,&c); |
---|
669 | Print("div: ");pWrite(div); |
---|
670 | Print("rows: %d, cols: %d\n",r,c); |
---|
671 | pDelete(&div); |
---|
672 | return FALSE; |
---|
673 | } |
---|
674 | else |
---|
675 | WerrorS("matrix expected"); |
---|
676 | } |
---|
677 | } |
---|
678 | |
---|
679 | /*============================================================*/ |
---|
680 | WerrorS("not implemented\n"); |
---|
681 | return TRUE; |
---|
682 | } |
---|