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