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