[0e1846] | 1 | /***************************************** |
---|
| 2 | * Computer Algebra System SINGULAR * |
---|
| 3 | *****************************************/ |
---|
[fdca1c0] | 4 | /* $Id: extra.cc,v 1.150 2000-11-13 14:50:21 levandov Exp $ */ |
---|
[0e1846] | 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> |
---|
[9e9288] | 13 | #include <signal.h> |
---|
[b85a6c] | 14 | #include "mod2.h" |
---|
[0e1846] | 15 | |
---|
[03b1cd1] | 16 | #ifndef __MWERKS__ |
---|
[b85a6c] | 17 | #ifdef TIME_WITH_SYS_TIME |
---|
[40edb03] | 18 | # include <time.h> |
---|
[b85a6c] | 19 | # ifdef HAVE_SYS_TIME_H |
---|
| 20 | # include <sys/time.h> |
---|
| 21 | # endif |
---|
[40edb03] | 22 | #else |
---|
[b85a6c] | 23 | # ifdef HAVE_SYS_TIME_H |
---|
| 24 | # include <sys/time.h> |
---|
[40edb03] | 25 | # else |
---|
| 26 | # include <time.h> |
---|
| 27 | # endif |
---|
| 28 | #endif |
---|
[b85a6c] | 29 | #ifdef HAVE_SYS_TIMES_H |
---|
| 30 | #include <sys/times.h> |
---|
| 31 | #endif |
---|
[40edb03] | 32 | |
---|
[0e1846] | 33 | #endif |
---|
[12310e] | 34 | #include <unistd.h> |
---|
[0e1846] | 35 | |
---|
| 36 | #include "tok.h" |
---|
| 37 | #include "ipid.h" |
---|
[4dd74d] | 38 | #include "polys.h" |
---|
[0e1846] | 39 | #include "kutil.h" |
---|
| 40 | #include "cntrlc.h" |
---|
| 41 | #include "stairc.h" |
---|
| 42 | #include "ipshell.h" |
---|
| 43 | #include "algmap.h" |
---|
| 44 | #include "modulop.h" |
---|
| 45 | #include "febase.h" |
---|
| 46 | #include "matpol.h" |
---|
| 47 | #include "longalg.h" |
---|
| 48 | #include "ideals.h" |
---|
| 49 | #include "kstd1.h" |
---|
[dfc6b54] | 50 | #include "syz.h" |
---|
[8dd3ac] | 51 | #include "sdb.h" |
---|
[c06a32] | 52 | #include "feOpt.h" |
---|
| 53 | #include "distrib.h" |
---|
[704325e] | 54 | #include "prCopy.h" |
---|
[80bc9a] | 55 | #include "mpr_complex.h" |
---|
| 56 | |
---|
[847242] | 57 | #include "walk.h" |
---|
| 58 | |
---|
[5d32fd] | 59 | #ifdef HAVE_SPECTRUM |
---|
| 60 | #include "spectrum.h" |
---|
| 61 | #endif |
---|
| 62 | |
---|
[fdca1c0] | 63 | #ifdef HAVE_PLURAL |
---|
| 64 | #include "gring.h" |
---|
| 65 | #endif |
---|
[51c163] | 66 | |
---|
[6e9a1c] | 67 | // Define to enable many more system commands |
---|
[726d50] | 68 | #ifndef MAKE_DISTRIBUTION |
---|
[f7ac05] | 69 | #define HAVE_EXTENDED_SYSTEM |
---|
[726d50] | 70 | #endif |
---|
[6e9a1c] | 71 | |
---|
[40edb03] | 72 | #ifdef HAVE_FACTORY |
---|
[0e1846] | 73 | #define SI_DONT_HAVE_GLOBAL_VARS |
---|
| 74 | #include "clapsing.h" |
---|
| 75 | #include "clapconv.h" |
---|
| 76 | #include "kstdfac.h" |
---|
| 77 | #endif |
---|
| 78 | |
---|
[5615cd9] | 79 | #include "silink.h" |
---|
[7dc74a] | 80 | #ifdef HAVE_MPSR |
---|
[5615cd9] | 81 | #include "mpsr.h" |
---|
[82dbf50] | 82 | #include "MPT_GP.h" |
---|
[7dc74a] | 83 | #endif |
---|
[7d423e] | 84 | #include "walk.h" |
---|
[5615cd9] | 85 | |
---|
[cd6b45] | 86 | /* |
---|
| 87 | * New function/system-calls that will be included as dynamic module |
---|
| 88 | * should be inserted here. |
---|
| 89 | * - without HAVE_DYNAMIC_LOADING: these functions comes as system("...."); |
---|
| 90 | * - with HAVE_DYNAMIC_LOADING: these functions are loaded as module. |
---|
| 91 | */ |
---|
| 92 | #ifndef HAVE_DYNAMIC_LOADING |
---|
[b7e7b6] | 93 | #ifdef HAVE_PCV |
---|
| 94 | #include "pcv.h" |
---|
| 95 | #endif |
---|
[cd6b45] | 96 | #endif /* not HAVE_DYNAMIC_LOADING */ |
---|
[b7e7b6] | 97 | |
---|
[54c713] | 98 | // see clapsing.cc for a description of the `FACTORY_*' options |
---|
| 99 | |
---|
| 100 | #ifdef FACTORY_GCD_STAT |
---|
[a6cbe4] | 101 | #include "gcd_stat.h" |
---|
[54c713] | 102 | #endif |
---|
| 103 | |
---|
| 104 | #ifdef FACTORY_GCD_TIMING |
---|
| 105 | #define TIMING |
---|
| 106 | #include "timing.h" |
---|
| 107 | TIMING_DEFINE_PRINTPROTO( contentTimer ); |
---|
| 108 | TIMING_DEFINE_PRINTPROTO( algContentTimer ); |
---|
| 109 | TIMING_DEFINE_PRINTPROTO( algLcmTimer ); |
---|
| 110 | #endif |
---|
| 111 | |
---|
[48ef1b7] | 112 | void piShowProcList(); |
---|
[8542c2] | 113 | #ifndef MAKE_DISTRIBUTION |
---|
[371d05] | 114 | static BOOLEAN jjEXTENDED_SYSTEM(leftv res, leftv h); |
---|
[8542c2] | 115 | #endif |
---|
[53bb688] | 116 | |
---|
[48ef1b7] | 117 | |
---|
[0e1846] | 118 | //void emStart(); |
---|
| 119 | /*2 |
---|
| 120 | * the "system" command |
---|
| 121 | */ |
---|
[483400] | 122 | BOOLEAN jjSYSTEM(leftv res, leftv args) |
---|
[0e1846] | 123 | { |
---|
[483400] | 124 | if(args->Typ() == STRING_CMD) |
---|
[0e1846] | 125 | { |
---|
[483400] | 126 | const char *sys_cmd=(char *)(args->Data()); |
---|
| 127 | leftv h=args->next; |
---|
[6e9a1c] | 128 | // ONLY documented system calls go here |
---|
| 129 | // Undocumented system calls go down into #ifdef HAVE_EXTENDED_SYSTEM |
---|
[50abaf2] | 130 | /*==================== nblocks ==================================*/ |
---|
[483400] | 131 | if (strcmp(sys_cmd, "nblocks") == 0) |
---|
[50abaf2] | 132 | { |
---|
| 133 | ring r; |
---|
[483400] | 134 | if (h == NULL) |
---|
[50abaf2] | 135 | { |
---|
| 136 | if (currRingHdl != NULL) |
---|
| 137 | { |
---|
| 138 | r = IDRING(currRingHdl); |
---|
| 139 | } |
---|
| 140 | else |
---|
| 141 | { |
---|
| 142 | WerrorS("no ring active"); |
---|
| 143 | return TRUE; |
---|
| 144 | } |
---|
| 145 | } |
---|
| 146 | else |
---|
| 147 | { |
---|
[483400] | 148 | if (h->Typ() != RING_CMD) |
---|
[50abaf2] | 149 | { |
---|
| 150 | WerrorS("ring expected"); |
---|
| 151 | return TRUE; |
---|
| 152 | } |
---|
[483400] | 153 | r = (ring) h->Data(); |
---|
[50abaf2] | 154 | } |
---|
| 155 | res->rtyp = INT_CMD; |
---|
[9c9981] | 156 | res->data = (void*) (rBlocks(r) - 1); |
---|
[50abaf2] | 157 | return FALSE; |
---|
| 158 | } |
---|
[0e1846] | 159 | /*==================== version ==================================*/ |
---|
[483400] | 160 | if(strcmp(sys_cmd,"version")==0) |
---|
[0e1846] | 161 | { |
---|
| 162 | res->rtyp=INT_CMD; |
---|
[cb0e67b] | 163 | res->data=(void *)SINGULAR_VERSION; |
---|
[0e1846] | 164 | return FALSE; |
---|
| 165 | } |
---|
| 166 | else |
---|
| 167 | /*==================== gen ==================================*/ |
---|
[483400] | 168 | if(strcmp(sys_cmd,"gen")==0) |
---|
[0e1846] | 169 | { |
---|
| 170 | res->rtyp=INT_CMD; |
---|
| 171 | res->data=(void *)npGen; |
---|
| 172 | return FALSE; |
---|
| 173 | } |
---|
| 174 | else |
---|
| 175 | /*==================== sh ==================================*/ |
---|
[483400] | 176 | if(strcmp(sys_cmd,"sh")==0) |
---|
[0e1846] | 177 | { |
---|
[57f078] | 178 | res->rtyp=INT_CMD; |
---|
[483400] | 179 | #ifndef __MWERKS__ |
---|
| 180 | if (h==NULL) res->data = (void *)system("sh"); |
---|
| 181 | else if (h->Typ()==STRING_CMD) |
---|
| 182 | res->data = (void*) system((char*)(h->Data())); |
---|
| 183 | else |
---|
| 184 | WerrorS("string expected"); |
---|
| 185 | #else |
---|
| 186 | res->data=(void *)0; |
---|
| 187 | #endif |
---|
[0e1846] | 188 | return FALSE; |
---|
| 189 | } |
---|
| 190 | else |
---|
[a70441f] | 191 | /*==================== uname ==================================*/ |
---|
| 192 | if(strcmp(sys_cmd,"uname")==0) |
---|
| 193 | { |
---|
| 194 | res->rtyp=STRING_CMD; |
---|
[c232af] | 195 | res->data = omStrDup(S_UNAME); |
---|
[a70441f] | 196 | return FALSE; |
---|
| 197 | } |
---|
| 198 | else |
---|
[592f6b] | 199 | /*==================== with ==================================*/ |
---|
[483400] | 200 | if(strcmp(sys_cmd,"with")==0) |
---|
[592f6b] | 201 | { |
---|
[483400] | 202 | if (h==NULL) |
---|
[592f6b] | 203 | { |
---|
[cb0e67b] | 204 | res->rtyp=STRING_CMD; |
---|
[c232af] | 205 | res->data=(void *)omStrDup(versionString()); |
---|
[592f6b] | 206 | return FALSE; |
---|
[07dacd] | 207 | } |
---|
[483400] | 208 | else if (h->Typ()==STRING_CMD) |
---|
[592f6b] | 209 | { |
---|
| 210 | #define TEST_FOR(A) if(strcmp(s,A)==0) res->data=(void *)1; else |
---|
[483400] | 211 | char *s=(char *)h->Data(); |
---|
[592f6b] | 212 | res->rtyp=INT_CMD; |
---|
| 213 | #ifdef HAVE_DBM |
---|
| 214 | TEST_FOR("DBM") |
---|
| 215 | #endif |
---|
| 216 | #ifdef HAVE_DLD |
---|
| 217 | TEST_FOR("DLD") |
---|
| 218 | #endif |
---|
| 219 | #ifdef HAVE_FACTORY |
---|
| 220 | TEST_FOR("factory") |
---|
| 221 | #endif |
---|
| 222 | #ifdef HAVE_LIBFAC_P |
---|
| 223 | TEST_FOR("libfac") |
---|
| 224 | #endif |
---|
| 225 | #ifdef HAVE_MPSR |
---|
| 226 | TEST_FOR("MP") |
---|
| 227 | #endif |
---|
| 228 | #ifdef HAVE_READLINE |
---|
| 229 | TEST_FOR("readline") |
---|
| 230 | #endif |
---|
| 231 | #ifdef HAVE_TCL |
---|
| 232 | TEST_FOR("tcl") |
---|
| 233 | #endif |
---|
[38cfbb] | 234 | #ifdef TEST_MAC_ORDER |
---|
| 235 | TEST_FOR("MAC_ORDER"); |
---|
[46d09b] | 236 | #endif |
---|
| 237 | #ifdef HAVE_NAMESPACES |
---|
| 238 | TEST_FOR("Namespaces"); |
---|
| 239 | #endif |
---|
| 240 | #ifdef HAVE_DYNAMIC_LOADING |
---|
| 241 | TEST_FOR("DynamicLoading"); |
---|
[592f6b] | 242 | #endif |
---|
| 243 | ; |
---|
| 244 | return FALSE; |
---|
| 245 | #undef TEST_FOR |
---|
| 246 | } |
---|
| 247 | return TRUE; |
---|
| 248 | } |
---|
| 249 | else |
---|
[09f0ee] | 250 | /*==================== browsers ==================================*/ |
---|
| 251 | if (strcmp(sys_cmd,"browsers")==0) |
---|
| 252 | { |
---|
| 253 | res->rtyp = STRING_CMD; |
---|
| 254 | char* b = StringSetS(""); |
---|
[c06a32] | 255 | feStringAppendBrowsers(0); |
---|
[c232af] | 256 | res->data = omStrDup(b); |
---|
[09f0ee] | 257 | return FALSE; |
---|
| 258 | } |
---|
| 259 | else |
---|
[0e1846] | 260 | /*==================== pid ==================================*/ |
---|
[483400] | 261 | if (strcmp(sys_cmd,"pid")==0) |
---|
[0e1846] | 262 | { |
---|
| 263 | res->rtyp=INT_CMD; |
---|
[483400] | 264 | #ifndef MSDOS |
---|
| 265 | #ifndef __MWERKS__ |
---|
[0e1846] | 266 | res->data=(void *)getpid(); |
---|
[483400] | 267 | #else |
---|
| 268 | res->data=(void *)1; |
---|
| 269 | #endif |
---|
| 270 | #else |
---|
| 271 | res->data=(void *)1; |
---|
| 272 | #endif |
---|
[0e1846] | 273 | return FALSE; |
---|
| 274 | } |
---|
| 275 | else |
---|
| 276 | /*==================== getenv ==================================*/ |
---|
[483400] | 277 | if (strcmp(sys_cmd,"getenv")==0) |
---|
[0e1846] | 278 | { |
---|
[483400] | 279 | if ((h!=NULL) && (h->Typ()==STRING_CMD)) |
---|
[0e1846] | 280 | { |
---|
| 281 | res->rtyp=STRING_CMD; |
---|
[483400] | 282 | char *r=getenv((char *)h->Data()); |
---|
[0e1846] | 283 | if (r==NULL) r=""; |
---|
[c232af] | 284 | res->data=(void *)omStrDup(r); |
---|
[0e1846] | 285 | return FALSE; |
---|
| 286 | } |
---|
| 287 | else |
---|
| 288 | { |
---|
| 289 | WerrorS("string expected"); |
---|
[726d50] | 290 | return TRUE; |
---|
[0e1846] | 291 | } |
---|
| 292 | } |
---|
| 293 | else |
---|
[726d50] | 294 | /*==================== setenv ==================================*/ |
---|
| 295 | if (strcmp(sys_cmd,"setenv")==0) |
---|
| 296 | { |
---|
| 297 | #ifdef HAVE_SETENV |
---|
| 298 | if (h!=NULL && h->Typ()==STRING_CMD && h->Data() != NULL && |
---|
[de99f75] | 299 | h->next != NULL && h->next->Typ() == STRING_CMD |
---|
[726d50] | 300 | && h->next->Data() != NULL) |
---|
| 301 | { |
---|
| 302 | res->rtyp=STRING_CMD; |
---|
| 303 | setenv((char *)h->Data(), (char *)h->next->Data(), 1); |
---|
[c232af] | 304 | res->data=(void *)omStrDup((char *)h->next->Data()); |
---|
[726d50] | 305 | feReInitResources(); |
---|
| 306 | return FALSE; |
---|
| 307 | } |
---|
| 308 | else |
---|
| 309 | { |
---|
| 310 | WerrorS("two strings expected"); |
---|
| 311 | return TRUE; |
---|
| 312 | } |
---|
| 313 | #else |
---|
[de99f75] | 314 | WerrorS("setenv not supported on this platform"); |
---|
[726d50] | 315 | return TRUE; |
---|
[de99f75] | 316 | #endif |
---|
[726d50] | 317 | } |
---|
| 318 | else |
---|
[6a69ce] | 319 | /*==================== Singular ==================================*/ |
---|
[483400] | 320 | if (strcmp(sys_cmd, "Singular") == 0) |
---|
[6a69ce] | 321 | { |
---|
| 322 | res->rtyp=STRING_CMD; |
---|
[9c35ef] | 323 | char *r=feResource("Singular"); |
---|
[6a69ce] | 324 | if (r != NULL) |
---|
[c232af] | 325 | res->data = (void*) omStrDup( r ); |
---|
[6a69ce] | 326 | else |
---|
[c232af] | 327 | res->data = (void*) omStrDup(""); |
---|
[6a69ce] | 328 | return FALSE; |
---|
| 329 | } |
---|
| 330 | else |
---|
[eea2b0] | 331 | /*==================== options ==================================*/ |
---|
[483400] | 332 | if (strstr(sys_cmd, "--") == sys_cmd) |
---|
[eea2b0] | 333 | { |
---|
[c06a32] | 334 | if (strcmp(sys_cmd, "--") == 0) |
---|
| 335 | { |
---|
| 336 | fePrintOptValues(); |
---|
| 337 | return FALSE; |
---|
| 338 | } |
---|
[87cf50] | 339 | |
---|
[c06a32] | 340 | feOptIndex opt = feGetOptIndex(&sys_cmd[2]); |
---|
| 341 | if (opt == FE_OPT_UNDEF) |
---|
| 342 | { |
---|
| 343 | Werror("Unknown option %s", sys_cmd); |
---|
| 344 | Werror("Use 'system(\"--\");' for listing of available options"); |
---|
| 345 | return TRUE; |
---|
| 346 | } |
---|
[87cf50] | 347 | |
---|
| 348 | // for Untyped Options (help version), |
---|
[b6f537] | 349 | // setting it just triggers action |
---|
| 350 | if (feOptSpec[opt].type == feOptUntyped) |
---|
| 351 | { |
---|
| 352 | feSetOptValue(opt,NULL); |
---|
| 353 | return FALSE; |
---|
| 354 | } |
---|
[87cf50] | 355 | |
---|
[c06a32] | 356 | if (h == NULL) |
---|
[9c35ef] | 357 | { |
---|
[c06a32] | 358 | if (feOptSpec[opt].type == feOptString) |
---|
[9c35ef] | 359 | { |
---|
[c06a32] | 360 | res->rtyp = STRING_CMD; |
---|
| 361 | if (feOptSpec[opt].value != NULL) |
---|
[c232af] | 362 | res->data = omStrDup((char*) feOptSpec[opt].value); |
---|
[9c35ef] | 363 | else |
---|
[c232af] | 364 | res->data = omStrDup(""); |
---|
[9c35ef] | 365 | } |
---|
| 366 | else |
---|
| 367 | { |
---|
[c06a32] | 368 | res->rtyp = INT_CMD; |
---|
| 369 | res->data = feOptSpec[opt].value; |
---|
[9c35ef] | 370 | } |
---|
[c06a32] | 371 | return FALSE; |
---|
[9c35ef] | 372 | } |
---|
[87cf50] | 373 | |
---|
| 374 | if (h->Typ() != STRING_CMD && |
---|
[c06a32] | 375 | h->Typ() != INT_CMD) |
---|
[eea2b0] | 376 | { |
---|
[c06a32] | 377 | Werror("Need string or int argument to set option value"); |
---|
| 378 | return TRUE; |
---|
| 379 | } |
---|
| 380 | char* errormsg; |
---|
| 381 | if (h->Typ() == INT_CMD) |
---|
| 382 | { |
---|
| 383 | if (feOptSpec[opt].type == feOptString) |
---|
[ebb5ccf] | 384 | { |
---|
[c06a32] | 385 | Werror("Need string argument to set value of option %s", sys_cmd); |
---|
| 386 | return TRUE; |
---|
[ebb5ccf] | 387 | } |
---|
[c06a32] | 388 | errormsg = feSetOptValue(opt, (int) h->Data()); |
---|
[87cf50] | 389 | if (errormsg != NULL) |
---|
[c06a32] | 390 | Werror("Option '--%s=%d' %s", sys_cmd, (int) h->Data(), errormsg); |
---|
[eea2b0] | 391 | } |
---|
| 392 | else |
---|
| 393 | { |
---|
[c06a32] | 394 | errormsg = feSetOptValue(opt, (char*) h->Data()); |
---|
| 395 | if (errormsg != NULL) |
---|
| 396 | Werror("Option '--%s=%s' %s", sys_cmd, (char*) h->Data(), errormsg); |
---|
[eea2b0] | 397 | } |
---|
[c06a32] | 398 | if (errormsg != NULL) return TRUE; |
---|
| 399 | return FALSE; |
---|
[eea2b0] | 400 | } |
---|
| 401 | else |
---|
[0e1846] | 402 | /*==================== HC ==================================*/ |
---|
[483400] | 403 | if (strcmp(sys_cmd,"HC")==0) |
---|
[0e1846] | 404 | { |
---|
| 405 | res->rtyp=INT_CMD; |
---|
| 406 | res->data=(void *)HCord; |
---|
| 407 | return FALSE; |
---|
| 408 | } |
---|
| 409 | else |
---|
| 410 | /*==================== random ==================================*/ |
---|
[483400] | 411 | if(strcmp(sys_cmd,"random")==0) |
---|
[0e1846] | 412 | { |
---|
[483400] | 413 | if ((h!=NULL) &&(h->Typ()==INT_CMD)) |
---|
[0e1846] | 414 | { |
---|
[483400] | 415 | siRandomStart=(int)h->Data(); |
---|
[0e1846] | 416 | #ifdef buildin_rand |
---|
| 417 | siSeed=siRandomStart; |
---|
| 418 | #else |
---|
| 419 | srand((unsigned int)siRandomStart); |
---|
[c232af] | 420 | #endif |
---|
| 421 | #ifdef HAVE_FACTORY |
---|
| 422 | factoryseed(siRandomStart); |
---|
[0e1846] | 423 | #endif |
---|
| 424 | return FALSE; |
---|
| 425 | } |
---|
[483400] | 426 | else if (h != NULL) |
---|
[6e9a1c] | 427 | { |
---|
[0e1846] | 428 | WerrorS("int expected"); |
---|
[6e9a1c] | 429 | return TRUE; |
---|
| 430 | } |
---|
| 431 | res->rtyp=INT_CMD; |
---|
| 432 | res->data=(void*) siRandomStart; |
---|
| 433 | return FALSE; |
---|
[0e1846] | 434 | } |
---|
[d6049b] | 435 | /*==================== complexNearZero ======================*/ |
---|
| 436 | if(strcmp(sys_cmd,"complexNearZero")==0) |
---|
| 437 | { |
---|
| 438 | if (h->Typ()==NUMBER_CMD ) |
---|
| 439 | { |
---|
| 440 | if ( h->next!=NULL && h->next->Typ()==INT_CMD ) |
---|
| 441 | { |
---|
| 442 | if ( !rField_is_long_C() ) |
---|
| 443 | { |
---|
| 444 | Werror( "unsupported ground field!"); |
---|
| 445 | return TRUE; |
---|
| 446 | } |
---|
| 447 | else |
---|
| 448 | { |
---|
| 449 | res->rtyp=INT_CMD; |
---|
| 450 | res->data=(void*)complexNearZero((gmp_complex*)h->Data(),(int)h->next->Data()); |
---|
| 451 | return FALSE; |
---|
| 452 | } |
---|
| 453 | } |
---|
| 454 | else |
---|
| 455 | { |
---|
| 456 | Werror( "expected <int> as third parameter!"); |
---|
| 457 | return TRUE; |
---|
| 458 | } |
---|
| 459 | } |
---|
| 460 | else |
---|
| 461 | { |
---|
| 462 | Werror( "expected <number> as second parameter!"); |
---|
| 463 | return TRUE; |
---|
| 464 | } |
---|
| 465 | } |
---|
| 466 | /*==================== getPrecDigits ======================*/ |
---|
| 467 | if(strcmp(sys_cmd,"getPrecDigits")==0) |
---|
| 468 | { |
---|
| 469 | if ( !rField_is_long_C() && !rField_is_long_R() ) |
---|
| 470 | { |
---|
| 471 | Werror( "unsupported ground field!"); |
---|
| 472 | return TRUE; |
---|
| 473 | } |
---|
| 474 | res->rtyp=INT_CMD; |
---|
| 475 | res->data=(void*)getGMPFloatDigits(); |
---|
| 476 | return FALSE; |
---|
| 477 | } |
---|
[62aecd] | 478 | /*==================== neworder =============================*/ |
---|
| 479 | // should go below |
---|
| 480 | #ifdef HAVE_LIBFAC_P |
---|
[483400] | 481 | if(strcmp(sys_cmd,"neworder")==0) |
---|
[62aecd] | 482 | { |
---|
[483400] | 483 | if ((h!=NULL) &&(h->Typ()==IDEAL_CMD)) |
---|
[62aecd] | 484 | { |
---|
| 485 | res->rtyp=STRING_CMD; |
---|
[483400] | 486 | res->data=(void *)singclap_neworder((ideal)h->Data()); |
---|
[62aecd] | 487 | return FALSE; |
---|
| 488 | } |
---|
| 489 | else |
---|
| 490 | WerrorS("ideal expected"); |
---|
| 491 | } |
---|
| 492 | else |
---|
| 493 | #endif |
---|
[4b72f6] | 494 | /*==================== pcv ==================================*/ |
---|
| 495 | #ifndef HAVE_DYNAMIC_LOADING |
---|
| 496 | #ifdef HAVE_PCV |
---|
| 497 | if(strcmp(sys_cmd,"pcvLAddL")==0) |
---|
| 498 | { |
---|
| 499 | return pcvLAddL(res,h); |
---|
| 500 | } |
---|
| 501 | else |
---|
| 502 | if(strcmp(sys_cmd,"pcvPMulL")==0) |
---|
| 503 | { |
---|
| 504 | return pcvPMulL(res,h); |
---|
| 505 | } |
---|
| 506 | else |
---|
| 507 | if(strcmp(sys_cmd,"pcvMinDeg")==0) |
---|
| 508 | { |
---|
| 509 | return pcvMinDeg(res,h); |
---|
| 510 | } |
---|
| 511 | else |
---|
| 512 | if(strcmp(sys_cmd,"pcvP2CV")==0) |
---|
| 513 | { |
---|
| 514 | return pcvP2CV(res,h); |
---|
| 515 | } |
---|
| 516 | else |
---|
| 517 | if(strcmp(sys_cmd,"pcvCV2P")==0) |
---|
| 518 | { |
---|
| 519 | return pcvCV2P(res,h); |
---|
| 520 | } |
---|
| 521 | else |
---|
| 522 | if(strcmp(sys_cmd,"pcvDim")==0) |
---|
| 523 | { |
---|
| 524 | return pcvDim(res,h); |
---|
| 525 | } |
---|
| 526 | else |
---|
| 527 | if(strcmp(sys_cmd,"pcvBasis")==0) |
---|
| 528 | { |
---|
| 529 | return pcvBasis(res,h); |
---|
| 530 | } |
---|
| 531 | else |
---|
| 532 | #endif |
---|
| 533 | #endif /* HAVE_DYNAMIC_LOADING */ |
---|
[27b799] | 534 | /*==================== contributors =============================*/ |
---|
[483400] | 535 | if(strcmp(sys_cmd,"contributors") == 0) |
---|
[a915fe0] | 536 | { |
---|
| 537 | res->rtyp=STRING_CMD; |
---|
[c232af] | 538 | res->data=(void *)omStrDup( |
---|
[2272c33] | 539 | "Olaf Bachmann, Hubert Grassmann, Kai Krueger, Wolfgang Neumann, Thomas Nuessler, Wilfred Pohl, Jens Schmidt, Thomas Siebert, Ruediger Stobbe, Moritz Wenk, Tim Wichmann"); |
---|
[a915fe0] | 540 | return FALSE; |
---|
| 541 | } |
---|
[53bb688] | 542 | else |
---|
[5d32fd] | 543 | /*==================== spectrum =============================*/ |
---|
| 544 | #ifdef HAVE_SPECTRUM |
---|
| 545 | if(strcmp(sys_cmd,"spectrum") == 0) |
---|
| 546 | { |
---|
| 547 | if (h->Typ()!=POLY_CMD) |
---|
| 548 | { |
---|
| 549 | WerrorS("poly expected"); |
---|
| 550 | return TRUE; |
---|
| 551 | } |
---|
| 552 | if (h->next==NULL) |
---|
| 553 | return spectrumProc(res,h); |
---|
| 554 | if (h->next->Typ()!=INT_CMD) |
---|
| 555 | { |
---|
| 556 | WerrorS("poly,int expected"); |
---|
| 557 | return TRUE; |
---|
| 558 | } |
---|
| 559 | if(((int)h->next->Data())==1) |
---|
| 560 | return spectrumfProc(res,h); |
---|
| 561 | return spectrumProc(res,h); |
---|
| 562 | } |
---|
| 563 | else |
---|
[87cf50] | 564 | /*==================== semic =============================*/ |
---|
| 565 | if(strcmp(sys_cmd,"semic") == 0) |
---|
| 566 | { |
---|
| 567 | if ((h->next!=NULL) |
---|
| 568 | && (h->Typ()==LIST_CMD) |
---|
| 569 | && (h->next->Typ()==LIST_CMD)) |
---|
| 570 | { |
---|
| 571 | if (h->next->next==NULL) |
---|
| 572 | return semicProc(res,h,h->next); |
---|
| 573 | else if (h->next->next->Typ()==INT_CMD) |
---|
| 574 | return semicProc3(res,h,h->next,h->next->next); |
---|
| 575 | } |
---|
| 576 | return TRUE; |
---|
| 577 | } |
---|
| 578 | else |
---|
[130c85] | 579 | /*==================== spadd =============================*/ |
---|
| 580 | if(strcmp(sys_cmd,"spadd") == 0) |
---|
| 581 | { |
---|
| 582 | if ((h->next!=NULL) |
---|
| 583 | && (h->Typ()==LIST_CMD) |
---|
| 584 | && (h->next->Typ()==LIST_CMD)) |
---|
| 585 | { |
---|
| 586 | if (h->next->next==NULL) |
---|
| 587 | return spaddProc(res,h,h->next); |
---|
| 588 | } |
---|
| 589 | return TRUE; |
---|
| 590 | } |
---|
| 591 | else |
---|
| 592 | /*==================== spmul =============================*/ |
---|
| 593 | if(strcmp(sys_cmd,"spmul") == 0) |
---|
[87cf50] | 594 | { |
---|
[130c85] | 595 | if ((h->next!=NULL) |
---|
| 596 | && (h->Typ()==LIST_CMD) |
---|
| 597 | && (h->next->Typ()==INT_CMD)) |
---|
| 598 | { |
---|
| 599 | if (h->next->next==NULL) |
---|
| 600 | return spmulProc(res,h,h->next); |
---|
| 601 | } |
---|
| 602 | return TRUE; |
---|
| 603 | } |
---|
| 604 | else |
---|
[5d32fd] | 605 | #endif |
---|
[53bb688] | 606 | /*================= Extended system call ========================*/ |
---|
[130c85] | 607 | { |
---|
| 608 | #ifndef MAKE_DISTRIBUTION |
---|
[483400] | 609 | return(jjEXTENDED_SYSTEM(res, args)); |
---|
[130c85] | 610 | #else |
---|
[483400] | 611 | Werror( "system(\"%s\",...) %s", sys_cmd, feNotImplemented ); |
---|
[130c85] | 612 | #endif |
---|
[371d05] | 613 | } |
---|
[53bb688] | 614 | } /* typ==string */ |
---|
| 615 | return TRUE; |
---|
| 616 | } |
---|
| 617 | |
---|
[371d05] | 618 | |
---|
[53bb688] | 619 | |
---|
[6e9a1c] | 620 | #ifdef HAVE_EXTENDED_SYSTEM |
---|
| 621 | // You can put your own system calls here |
---|
[53bb688] | 622 | #include "fglmcomb.cc" |
---|
| 623 | #include "fglm.h" |
---|
[9cf7815] | 624 | #ifdef HAVE_NEWTON |
---|
| 625 | #include <hc_newton.h> |
---|
| 626 | #endif |
---|
[4a8d95] | 627 | #include "mpsr.h" |
---|
| 628 | |
---|
[3a1db5] | 629 | |
---|
[371d05] | 630 | static BOOLEAN jjEXTENDED_SYSTEM(leftv res, leftv h) |
---|
[53bb688] | 631 | { |
---|
| 632 | if(h->Typ() == STRING_CMD) |
---|
| 633 | { |
---|
[483400] | 634 | char *sys_cmd=(char *)(h->Data()); |
---|
| 635 | h=h->next; |
---|
[9d72fe] | 636 | #ifdef RDEBUG |
---|
[09d74fe] | 637 | /*==================== poly debug ==================================*/ |
---|
[7d423e] | 638 | if(strcmp(sys_cmd,"p")==0) |
---|
| 639 | { |
---|
[09d74fe] | 640 | pDebugPrint((poly)h->Data()); |
---|
[7d423e] | 641 | return FALSE; |
---|
| 642 | } |
---|
| 643 | else |
---|
[09d74fe] | 644 | /*==================== ring debug ==================================*/ |
---|
[7d423e] | 645 | if(strcmp(sys_cmd,"r")==0) |
---|
| 646 | { |
---|
[09d74fe] | 647 | rDebugPrint((ring)h->Data()); |
---|
[7d423e] | 648 | return FALSE; |
---|
| 649 | } |
---|
| 650 | else |
---|
[9d72fe] | 651 | #endif |
---|
[5c187b] | 652 | /*==================== mtrack ==================================*/ |
---|
| 653 | if(strcmp(sys_cmd,"mtrack")==0) |
---|
| 654 | { |
---|
[c232af] | 655 | #ifdef OM_TRACK |
---|
| 656 | om_Opts.MarkAsStatic = 1; |
---|
[87cf50] | 657 | FILE *fd = NULL; |
---|
[512a2b] | 658 | int max = 5; |
---|
| 659 | while (h != NULL) |
---|
[5c187b] | 660 | { |
---|
[ec7aac] | 661 | omMarkAsStaticAddr(h); |
---|
[512a2b] | 662 | if (fd == NULL && h->Typ()==STRING_CMD) |
---|
| 663 | { |
---|
| 664 | fd = fopen((char*) h->Data(), "w"); |
---|
| 665 | if (fd == NULL) |
---|
| 666 | Warn("Can not open %s for writing og mtrack. Using stdout"); |
---|
| 667 | } |
---|
| 668 | if (h->Typ() == INT_CMD) |
---|
| 669 | { |
---|
| 670 | max = (int) h->Data(); |
---|
| 671 | } |
---|
| 672 | h = h->Next(); |
---|
[5c187b] | 673 | } |
---|
[512a2b] | 674 | omPrintUsedTrackAddrs((fd == NULL ? stdout : fd), max); |
---|
[5c187b] | 675 | if (fd != NULL) fclose(fd); |
---|
[c232af] | 676 | om_Opts.MarkAsStatic = 0; |
---|
| 677 | return FALSE; |
---|
| 678 | #else |
---|
| 679 | WerrorS("mtrack not supported without OM_TRACK"); |
---|
| 680 | return TRUE; |
---|
| 681 | #endif |
---|
| 682 | } |
---|
| 683 | /*==================== mtrack_all ==================================*/ |
---|
| 684 | if(strcmp(sys_cmd,"mtrack_all")==0) |
---|
| 685 | { |
---|
| 686 | #ifdef OM_TRACK |
---|
| 687 | om_Opts.MarkAsStatic = 1; |
---|
| 688 | FILE *fd = NULL; |
---|
| 689 | if ((h!=NULL) &&(h->Typ()==STRING_CMD)) |
---|
| 690 | { |
---|
| 691 | fd = fopen((char*) h->Data(), "w"); |
---|
| 692 | if (fd == NULL) |
---|
| 693 | Warn("Can not open %s for writing og mtrack. Using stdout"); |
---|
[ec7aac] | 694 | omMarkAsStaticAddr(h); |
---|
[c232af] | 695 | } |
---|
| 696 | // OB: TBC print to fd |
---|
[512a2b] | 697 | omPrintUsedAddrs((fd == NULL ? stdout : fd), 5); |
---|
[c232af] | 698 | if (fd != NULL) fclose(fd); |
---|
| 699 | om_Opts.MarkAsStatic = 0; |
---|
| 700 | return FALSE; |
---|
| 701 | #else |
---|
| 702 | WerrorS("mtrack not supported without OM_TRACK"); |
---|
| 703 | return TRUE; |
---|
| 704 | #endif |
---|
| 705 | } |
---|
| 706 | else |
---|
| 707 | /*==================== backtrace ==================================*/ |
---|
| 708 | if(strcmp(sys_cmd,"backtrace")==0) |
---|
| 709 | { |
---|
| 710 | #ifndef OM_NDEBUG |
---|
| 711 | omPrintCurrentBackTrace(stdout); |
---|
[5c187b] | 712 | return FALSE; |
---|
| 713 | #else |
---|
[c232af] | 714 | WerrorS("btrack not supported without OM_TRACK"); |
---|
[5c187b] | 715 | return TRUE; |
---|
[87cf50] | 716 | #endif |
---|
[5c187b] | 717 | } |
---|
| 718 | else |
---|
[0e1846] | 719 | /*==================== naIdeal ==================================*/ |
---|
[483400] | 720 | if(strcmp(sys_cmd,"naIdeal")==0) |
---|
[0e1846] | 721 | { |
---|
[483400] | 722 | if ((h!=NULL) &&(h->Typ()==IDEAL_CMD)) |
---|
[0e1846] | 723 | { |
---|
[483400] | 724 | naSetIdeal((ideal)h->Data()); |
---|
[0e1846] | 725 | return FALSE; |
---|
| 726 | } |
---|
| 727 | else |
---|
| 728 | WerrorS("ideal expected"); |
---|
| 729 | } |
---|
| 730 | else |
---|
| 731 | /*==================== isSqrFree =============================*/ |
---|
[40edb03] | 732 | #ifdef HAVE_FACTORY |
---|
[483400] | 733 | if(strcmp(sys_cmd,"isSqrFree")==0) |
---|
[0e1846] | 734 | { |
---|
[483400] | 735 | if ((h!=NULL) &&(h->Typ()==POLY_CMD)) |
---|
[0e1846] | 736 | { |
---|
| 737 | res->rtyp=INT_CMD; |
---|
[483400] | 738 | res->data=(void *)singclap_isSqrFree((poly)h->Data()); |
---|
[0e1846] | 739 | return FALSE; |
---|
| 740 | } |
---|
| 741 | else |
---|
| 742 | WerrorS("poly expected"); |
---|
| 743 | } |
---|
| 744 | else |
---|
| 745 | #endif |
---|
[b7b08c] | 746 | /*==================== pDivStat =============================*/ |
---|
[1aa55bf] | 747 | #if defined(PDEBUG) || defined(PDIV_DEBUG) |
---|
[b7b08c] | 748 | if(strcmp(sys_cmd,"pDivStat")==0) |
---|
| 749 | { |
---|
| 750 | extern void pPrintDivisbleByStat(); |
---|
| 751 | pPrintDivisbleByStat(); |
---|
| 752 | return FALSE; |
---|
| 753 | } |
---|
| 754 | else |
---|
[a6a239] | 755 | #endif |
---|
[0e1846] | 756 | /*==================== alarm ==================================*/ |
---|
[03b1cd1] | 757 | #ifndef __MWERKS__ |
---|
[0e1846] | 758 | #ifndef MSDOS |
---|
| 759 | #ifndef atarist |
---|
[3bf67ab] | 760 | #ifdef unix |
---|
[483400] | 761 | if(strcmp(sys_cmd,"alarm")==0) |
---|
[0e1846] | 762 | { |
---|
[483400] | 763 | if ((h!=NULL) &&(h->Typ()==INT_CMD)) |
---|
[0e1846] | 764 | { |
---|
| 765 | // standard variant -> SIGALARM (standard: abort) |
---|
| 766 | //alarm((unsigned)h->next->Data()); |
---|
| 767 | // process time (user +system): SIGVTALARM |
---|
| 768 | struct itimerval t,o; |
---|
| 769 | memset(&t,0,sizeof(t)); |
---|
[483400] | 770 | t.it_value.tv_sec =(unsigned)h->Data(); |
---|
[0e1846] | 771 | setitimer(ITIMER_VIRTUAL,&t,&o); |
---|
| 772 | return FALSE; |
---|
| 773 | } |
---|
| 774 | else |
---|
| 775 | WerrorS("int expected"); |
---|
| 776 | } |
---|
| 777 | else |
---|
| 778 | #endif |
---|
| 779 | #endif |
---|
| 780 | #endif |
---|
[3bf67ab] | 781 | #endif |
---|
[0e1846] | 782 | /*==================== red =============================*/ |
---|
| 783 | #if 0 |
---|
[483400] | 784 | if(strcmp(sys_cmd,"red")==0) |
---|
[0e1846] | 785 | { |
---|
[483400] | 786 | if ((h!=NULL) &&(h->Typ()==IDEAL_CMD)) |
---|
[0e1846] | 787 | { |
---|
| 788 | res->rtyp=IDEAL_CMD; |
---|
[483400] | 789 | res->data=(void *)kStdred((ideal)h->Data(),NULL,testHomog,NULL); |
---|
[0e1846] | 790 | setFlag(res,FLAG_STD); |
---|
| 791 | return FALSE; |
---|
| 792 | } |
---|
| 793 | else |
---|
| 794 | WerrorS("ideal expected"); |
---|
| 795 | } |
---|
| 796 | else |
---|
| 797 | #endif |
---|
| 798 | /*==================== algfetch =====================*/ |
---|
[483400] | 799 | if (strcmp(sys_cmd,"algfetch")==0) |
---|
[0e1846] | 800 | { |
---|
| 801 | int k; |
---|
| 802 | idhdl w; |
---|
| 803 | ideal i0, i1; |
---|
[483400] | 804 | ring r0=(ring)h->Data(); |
---|
| 805 | leftv v = h->next; |
---|
[0e1846] | 806 | w = r0->idroot->get(v->Name(),myynest); |
---|
[83adc4] | 807 | if (w!=NULL) |
---|
[0e1846] | 808 | { |
---|
[83adc4] | 809 | if (IDTYP(w)==IDEAL_CMD) |
---|
| 810 | { |
---|
| 811 | i0 = IDIDEAL(w); |
---|
| 812 | i1 = idInit(IDELEMS(i0),i0->rank); |
---|
| 813 | for (k=0; k<IDELEMS(i1); k++) |
---|
| 814 | { |
---|
| 815 | i1->m[k] = maAlgpolyFetch(r0, i0->m[k]); |
---|
| 816 | } |
---|
| 817 | res->rtyp = IDEAL_CMD; |
---|
| 818 | res->data = (void*)i1; |
---|
| 819 | return FALSE; |
---|
| 820 | } |
---|
| 821 | else if (IDTYP(w)==POLY_CMD) |
---|
| 822 | { |
---|
| 823 | res->rtyp = POLY_CMD; |
---|
| 824 | res->data = (void*)maAlgpolyFetch(r0,IDPOLY(w)); |
---|
| 825 | return FALSE; |
---|
| 826 | } |
---|
| 827 | else |
---|
| 828 | WerrorS("`system(\"algfetch\",<ideal>/<poly>)` expected"); |
---|
[0e1846] | 829 | } |
---|
[83adc4] | 830 | else |
---|
| 831 | Werror("`%s` not found in `%s`",v->Name(),h->Name()); |
---|
[0e1846] | 832 | } |
---|
| 833 | else |
---|
| 834 | /*==================== algmap =======================*/ |
---|
[483400] | 835 | if (strcmp(sys_cmd,"algmap")==0) |
---|
[0e1846] | 836 | { |
---|
| 837 | int k; |
---|
| 838 | idhdl w; |
---|
| 839 | ideal i0, i1, i, j; |
---|
[483400] | 840 | ring r0=(ring)h->Data(); |
---|
| 841 | leftv v = h->next; |
---|
[0e1846] | 842 | w = r0->idroot->get(v->Name(),myynest); |
---|
| 843 | i0 = IDIDEAL(w); |
---|
| 844 | v = v->next; |
---|
| 845 | i = (ideal)v->Data(); |
---|
| 846 | v = v->next; |
---|
| 847 | j = (ideal)v->Data(); |
---|
| 848 | i1 = idInit(IDELEMS(i0),i0->rank); |
---|
| 849 | for (k=0; k<IDELEMS(i1); k++) |
---|
| 850 | { |
---|
| 851 | i1->m[k] = maAlgpolyMap(r0, i0->m[k], i, j); |
---|
| 852 | } |
---|
| 853 | res->rtyp = IDEAL_CMD; |
---|
| 854 | res->data = (void*)i1; |
---|
| 855 | return FALSE; |
---|
| 856 | } |
---|
| 857 | else |
---|
[1a2bd8] | 858 | #ifdef HAVE_FACTORY |
---|
[d37f27] | 859 | /*==================== fastcomb =============================*/ |
---|
[483400] | 860 | if(strcmp(sys_cmd,"fastcomb")==0) |
---|
[d37f27] | 861 | { |
---|
[483400] | 862 | if ((h!=NULL) &&(h->Typ()==IDEAL_CMD)) |
---|
[d37f27] | 863 | { |
---|
| 864 | int i=0; |
---|
[483400] | 865 | if (h->next!=NULL) |
---|
[d37f27] | 866 | { |
---|
[483400] | 867 | if (h->next->Typ()!=POLY_CMD) |
---|
[d37f27] | 868 | { |
---|
[483400] | 869 | Warn("Wrong types for poly= comb(ideal,poly)"); |
---|
[d37f27] | 870 | } |
---|
| 871 | } |
---|
| 872 | res->rtyp=POLY_CMD; |
---|
[9c9981] | 873 | res->data=(void *) fglmLinearCombination( |
---|
[483400] | 874 | (ideal)h->Data(),(poly)h->next->Data()); |
---|
[d37f27] | 875 | return FALSE; |
---|
| 876 | } |
---|
| 877 | else |
---|
| 878 | WerrorS("ideal expected"); |
---|
| 879 | } |
---|
| 880 | else |
---|
| 881 | /*==================== comb =============================*/ |
---|
[483400] | 882 | if(strcmp(sys_cmd,"comb")==0) |
---|
[d37f27] | 883 | { |
---|
[483400] | 884 | if ((h!=NULL) &&(h->Typ()==IDEAL_CMD)) |
---|
[d37f27] | 885 | { |
---|
| 886 | int i=0; |
---|
[483400] | 887 | if (h->next!=NULL) |
---|
[d37f27] | 888 | { |
---|
[483400] | 889 | if (h->next->Typ()!=POLY_CMD) |
---|
[d37f27] | 890 | { |
---|
[886606] | 891 | Warn("Wrong types for poly= comb(ideal,poly)"); |
---|
[d37f27] | 892 | } |
---|
| 893 | } |
---|
| 894 | res->rtyp=POLY_CMD; |
---|
[9c9981] | 895 | res->data=(void *)fglmNewLinearCombination( |
---|
[483400] | 896 | (ideal)h->Data(),(poly)h->next->Data()); |
---|
[d37f27] | 897 | return FALSE; |
---|
| 898 | } |
---|
| 899 | else |
---|
| 900 | WerrorS("ideal expected"); |
---|
| 901 | } |
---|
| 902 | else |
---|
[c0ad89] | 903 | #endif |
---|
[54c713] | 904 | #ifdef FACTORY_GCD_TEST |
---|
| 905 | /*=======================gcd Testerei ================================*/ |
---|
[483400] | 906 | if ( ! strcmp( sys_cmd, "setgcd" ) ) { |
---|
| 907 | if ( (h != NULL) && (h->Typ() == INT_CMD) ) { |
---|
| 908 | CFPrimitiveGcdUtil::setAlgorithm( (int)h->Data() ); |
---|
[886606] | 909 | return FALSE; |
---|
| 910 | } else |
---|
| 911 | WerrorS("int expected"); |
---|
[54c713] | 912 | } |
---|
| 913 | else |
---|
| 914 | #endif |
---|
| 915 | |
---|
| 916 | #ifdef FACTORY_GCD_TIMING |
---|
[483400] | 917 | if ( ! strcmp( sys_cmd, "gcdtime" ) ) { |
---|
[886606] | 918 | TIMING_PRINT( contentTimer, "time used for content: " ); |
---|
| 919 | TIMING_PRINT( algContentTimer, "time used for algContent: " ); |
---|
| 920 | TIMING_PRINT( algLcmTimer, "time used for algLcm: " ); |
---|
| 921 | TIMING_RESET( contentTimer ); |
---|
| 922 | TIMING_RESET( algContentTimer ); |
---|
| 923 | TIMING_RESET( algLcmTimer ); |
---|
| 924 | return FALSE; |
---|
[54c713] | 925 | } |
---|
| 926 | else |
---|
| 927 | #endif |
---|
[886606] | 928 | |
---|
[a6cbe4] | 929 | #ifdef FACTORY_GCD_STAT |
---|
[483400] | 930 | if ( ! strcmp( sys_cmd, "gcdstat" ) ) { |
---|
[886606] | 931 | printGcdTotal(); |
---|
| 932 | printContTotal(); |
---|
| 933 | resetGcdTotal(); |
---|
| 934 | resetContTotal(); |
---|
| 935 | return FALSE; |
---|
[a6cbe4] | 936 | } |
---|
| 937 | else |
---|
| 938 | #endif |
---|
[6e9a1c] | 939 | /*==================== lib ==================================*/ |
---|
[483400] | 940 | if(strcmp(sys_cmd,"LIB")==0) |
---|
[6e9a1c] | 941 | { |
---|
| 942 | #ifdef HAVE_NAMESPACES |
---|
[483400] | 943 | idhdl hh=namespaceroot->get((char*)h->Data(),0); |
---|
[6e9a1c] | 944 | #else /* HAVE_NAMESPACES */ |
---|
[483400] | 945 | idhdl hh=idroot->get((char*)h->Data(),0); |
---|
[6e9a1c] | 946 | #endif /* HAVE_NAMESPACES */ |
---|
| 947 | if ((hh!=NULL)&&(IDTYP(hh)==PROC_CMD)) |
---|
| 948 | { |
---|
| 949 | res->rtyp=STRING_CMD; |
---|
[9c9981] | 950 | char *r=iiGetLibName(IDPROC(hh)); |
---|
[ebb5ccf] | 951 | if (r==NULL) r=""; |
---|
[c232af] | 952 | res->data=omStrDup(r); |
---|
[6e9a1c] | 953 | return FALSE; |
---|
| 954 | } |
---|
| 955 | else |
---|
[483400] | 956 | Warn("`%s` not found",(char*)h->Data()); |
---|
[6e9a1c] | 957 | } |
---|
| 958 | else |
---|
[7df4ee] | 959 | #ifdef HAVE_NAMESPACES |
---|
[6e9a1c] | 960 | /*==================== nspush ===================================*/ |
---|
[483400] | 961 | if(strcmp(sys_cmd,"nspush")==0) |
---|
[6e9a1c] | 962 | { |
---|
[0a3ddd] | 963 | if (h->Typ()==PACKAGE_CMD) |
---|
[6e9a1c] | 964 | { |
---|
[0a3ddd] | 965 | idhdl hh=(idhdl)h->data; |
---|
[886606] | 966 | namespaceroot = namespaceroot->push(IDPACKAGE(hh), IDID(hh)); |
---|
| 967 | return FALSE; |
---|
| 968 | } |
---|
| 969 | else |
---|
[0a3ddd] | 970 | Warn("argument 2 is not a package"); |
---|
[6e9a1c] | 971 | } |
---|
| 972 | else |
---|
| 973 | /*==================== nspop ====================================*/ |
---|
[483400] | 974 | if(strcmp(sys_cmd,"nspop")==0) |
---|
[6e9a1c] | 975 | { |
---|
| 976 | namespaceroot->pop(); |
---|
| 977 | return FALSE; |
---|
| 978 | } |
---|
| 979 | else |
---|
[77ff8e] | 980 | #endif /* HAVE_NAMESPACES */ |
---|
[6e9a1c] | 981 | /*==================== nsstack ===================================*/ |
---|
[483400] | 982 | if(strcmp(sys_cmd,"nsstack")==0) |
---|
[6e9a1c] | 983 | { |
---|
| 984 | namehdl nshdl = namespaceroot; |
---|
| 985 | for( ; nshdl->isroot != TRUE; nshdl = nshdl->next) { |
---|
[77ff8e] | 986 | Print("NSstack: %s:%d, nesting=%d\n", nshdl->name, nshdl->lev, nshdl->myynest); |
---|
[6e9a1c] | 987 | } |
---|
[77ff8e] | 988 | Print("NSstack: %s:%d, nesting=%d\n", nshdl->name, nshdl->lev, nshdl->myynest); |
---|
[6e9a1c] | 989 | return FALSE; |
---|
| 990 | } |
---|
| 991 | else |
---|
| 992 | /*==================== proclist =================================*/ |
---|
[483400] | 993 | if(strcmp(sys_cmd,"proclist")==0) |
---|
[6e9a1c] | 994 | { |
---|
| 995 | piShowProcList(); |
---|
| 996 | return FALSE; |
---|
| 997 | } |
---|
| 998 | else |
---|
[9cf7815] | 999 | /* ==================== newton ================================*/ |
---|
| 1000 | #ifdef HAVE_NEWTON |
---|
[483400] | 1001 | if(strcmp(sys_cmd,"newton")==0) |
---|
[9cf7815] | 1002 | { |
---|
[483400] | 1003 | if ((h->Typ()!=POLY_CMD) |
---|
| 1004 | || (h->next->Typ()!=INT_CMD) |
---|
| 1005 | || (h->next->next->Typ()!=INT_CMD)) |
---|
[9cf7815] | 1006 | { |
---|
| 1007 | WerrorS("system(\"newton\",<poly>,<int>,<int>) expected"); |
---|
| 1008 | return TRUE; |
---|
| 1009 | } |
---|
[483400] | 1010 | poly p=(poly)(h->Data()); |
---|
[9cf7815] | 1011 | int l=pLength(p); |
---|
[c232af] | 1012 | short *points=(short *)omAlloc(currRing->N*l*sizeof(short)); |
---|
[9cf7815] | 1013 | int i,j,k; |
---|
| 1014 | k=0; |
---|
| 1015 | poly pp=p; |
---|
| 1016 | for (i=0;pp!=NULL;i++) |
---|
| 1017 | { |
---|
| 1018 | for(j=1;j<=currRing->N;j++) |
---|
| 1019 | { |
---|
| 1020 | points[k]=pGetExp(pp,j); |
---|
| 1021 | k++; |
---|
| 1022 | } |
---|
| 1023 | pIter(pp); |
---|
| 1024 | } |
---|
| 1025 | hc_ERG r=hc_KOENIG(currRing->N, // dimension |
---|
| 1026 | l, // number of points |
---|
| 1027 | (short*) points, // points: x_1, y_1,z_1, x_2,y_2,z2,... |
---|
| 1028 | currRing->OrdSgn==-1, |
---|
[483400] | 1029 | (int) (h->next->Data()), // 1: Milnor, 0: Newton |
---|
| 1030 | (int) (h->next->next->Data()) // debug |
---|
[9cf7815] | 1031 | ); |
---|
| 1032 | //----<>---Output----------------------- |
---|
| 1033 | |
---|
| 1034 | |
---|
| 1035 | // PrintS("Bin jetzt in extra.cc bei der Auswertung.\n"); // ********** |
---|
[9c9981] | 1036 | |
---|
[9cf7815] | 1037 | |
---|
[c232af] | 1038 | lists L=(lists)omAllocBin(slists_bin); |
---|
[9cf7815] | 1039 | L->Init(6); |
---|
| 1040 | L->m[0].rtyp=STRING_CMD; // newtonnumber; |
---|
[c232af] | 1041 | L->m[0].data=(void *)omStrDup(r.nZahl); |
---|
[9cf7815] | 1042 | L->m[1].rtyp=INT_CMD; |
---|
| 1043 | L->m[1].data=(void *)r.achse; // flag for unoccupied axes |
---|
| 1044 | L->m[2].rtyp=INT_CMD; |
---|
| 1045 | L->m[2].data=(void *)r.deg; // #degenerations |
---|
| 1046 | if ( r.deg != 0) // only if degenerations exist |
---|
| 1047 | { |
---|
[9c9981] | 1048 | L->m[3].rtyp=INT_CMD; |
---|
| 1049 | L->m[3].data=(void *)r.anz_punkte; // #points |
---|
| 1050 | //---<>--number of points------ |
---|
| 1051 | int anz = r.anz_punkte; // number of points |
---|
| 1052 | int dim = (currRing->N); // dimension |
---|
[c232af] | 1053 | intvec* v = new intvec( anz*dim ); |
---|
[9c9981] | 1054 | for (i=0; i<anz*dim; i++) // copy points |
---|
| 1055 | (*v)[i] = r.pu[i]; |
---|
| 1056 | L->m[4].rtyp=INTVEC_CMD; |
---|
| 1057 | L->m[4].data=(void *)v; |
---|
| 1058 | //---<>--degenerations--------- |
---|
| 1059 | int deg = r.deg; // number of points |
---|
[c232af] | 1060 | intvec* w = new intvec( r.speicher ); // necessary memeory |
---|
[9c9981] | 1061 | i=0; // start copying |
---|
| 1062 | do |
---|
| 1063 | { |
---|
| 1064 | (*w)[i] = r.deg_tab[i]; |
---|
| 1065 | i++; |
---|
| 1066 | } |
---|
| 1067 | while (r.deg_tab[i-1] != -2); // mark for end of list |
---|
| 1068 | L->m[5].rtyp=INTVEC_CMD; |
---|
| 1069 | L->m[5].data=(void *)w; |
---|
[9cf7815] | 1070 | } |
---|
| 1071 | else |
---|
| 1072 | { |
---|
[9c9981] | 1073 | L->m[3].rtyp=INT_CMD; L->m[3].data=(char *)0; |
---|
| 1074 | L->m[4].rtyp=DEF_CMD; |
---|
| 1075 | L->m[5].rtyp=DEF_CMD; |
---|
[9cf7815] | 1076 | } |
---|
| 1077 | |
---|
| 1078 | res->data=(void *)L; |
---|
| 1079 | res->rtyp=LIST_CMD; |
---|
| 1080 | // free all pointer in r: |
---|
| 1081 | delete[] r.nZahl; |
---|
| 1082 | delete[] r.pu; |
---|
| 1083 | delete[] r.deg_tab; // Ist das ein Problem?? |
---|
| 1084 | |
---|
[c232af] | 1085 | omFreeSize((ADDRESS)points,currRing->N*l*sizeof(short)); |
---|
[9cf7815] | 1086 | return FALSE; |
---|
| 1087 | } |
---|
| 1088 | else |
---|
| 1089 | #endif |
---|
[4a8d95] | 1090 | /*==================== gp =================*/ |
---|
[7dc74a] | 1091 | #ifdef HAVE_MPSR |
---|
[7d423e] | 1092 | if (strcmp(sys_cmd, "gp") == 0) |
---|
[4a8d95] | 1093 | { |
---|
| 1094 | if (h->Typ() != LINK_CMD) |
---|
| 1095 | { |
---|
| 1096 | WerrorS("No Link arg"); |
---|
| 1097 | return FALSE; |
---|
| 1098 | } |
---|
| 1099 | si_link l = (si_link) h->Data(); |
---|
| 1100 | if (strcmp(l->m->type, "MPfile") != 0) |
---|
| 1101 | { |
---|
| 1102 | WerrorS("No MPfile link"); |
---|
| 1103 | return TRUE; |
---|
| 1104 | } |
---|
| 1105 | if( ! SI_LINK_R_OPEN_P(l)) // open r ? |
---|
| 1106 | { |
---|
| 1107 | if (slOpen(l, SI_LINK_READ)) return TRUE; |
---|
| 1108 | } |
---|
[3eccafa] | 1109 | |
---|
[4a8d95] | 1110 | MP_Link_pt link = (MP_Link_pt) l->data; |
---|
[3eccafa] | 1111 | if (MP_InitMsg(link) != MP_Success) |
---|
[4a8d95] | 1112 | { |
---|
| 1113 | WerrorS("Can not Init"); |
---|
| 1114 | } |
---|
| 1115 | MPT_Tree_pt tree = NULL; |
---|
| 1116 | if (MPT_GetTree(link, &tree) != MPT_Success) |
---|
| 1117 | { |
---|
| 1118 | WerrorS("Can not get tree"); |
---|
| 1119 | return TRUE; |
---|
| 1120 | } |
---|
[82dbf50] | 1121 | MPT_GP_pt gp_tree = MPT_GetGP(tree); |
---|
| 1122 | if (gp_tree == NULL || ! gp_tree->IsOk(gp_tree)) |
---|
| 1123 | { |
---|
| 1124 | WerrorS("gp error"); |
---|
| 1125 | return TRUE; |
---|
| 1126 | } |
---|
| 1127 | delete gp_tree; |
---|
[4a8d95] | 1128 | MPT_DeleteTree(tree); |
---|
| 1129 | return FALSE; |
---|
| 1130 | } |
---|
| 1131 | else |
---|
[7dc74a] | 1132 | #endif |
---|
[ad4bc9] | 1133 | /*==================== sdb_flags =================*/ |
---|
| 1134 | if (strcmp(sys_cmd, "sdb_flags") == 0) |
---|
| 1135 | { |
---|
| 1136 | if ((h!=NULL) && (h->Typ()==INT_CMD)) |
---|
| 1137 | { |
---|
| 1138 | sdb_flags=(int)h->Data(); |
---|
| 1139 | } |
---|
| 1140 | else |
---|
| 1141 | { |
---|
| 1142 | WerrorS("system(\"sdb_flags\",`int`) expected"); |
---|
| 1143 | return TRUE; |
---|
| 1144 | } |
---|
| 1145 | return FALSE; |
---|
| 1146 | } |
---|
| 1147 | else |
---|
| 1148 | /*==================== sdb_edit =================*/ |
---|
| 1149 | if (strcmp(sys_cmd, "sdb_edit") == 0) |
---|
| 1150 | { |
---|
| 1151 | if ((h!=NULL) && (h->Typ()==PROC_CMD)) |
---|
| 1152 | { |
---|
| 1153 | procinfov p=(procinfov)h->Data(); |
---|
| 1154 | sdb_edit(p); |
---|
| 1155 | } |
---|
| 1156 | else |
---|
| 1157 | { |
---|
| 1158 | WerrorS("system(\"sdb_edit\",`proc`) expected"); |
---|
| 1159 | return TRUE; |
---|
| 1160 | } |
---|
| 1161 | return FALSE; |
---|
| 1162 | } |
---|
| 1163 | else |
---|
[8838ab] | 1164 | /*==================== GF =================*/ |
---|
| 1165 | #if 0 |
---|
| 1166 | if (strcmp(sys_cmd, "GF") == 0) |
---|
| 1167 | { |
---|
| 1168 | int c=rChar(currRing); |
---|
| 1169 | setCharacteristic( c, 2); |
---|
| 1170 | CanonicalForm F( convSingGFClapGF( (poly)h->Data() ) ); |
---|
| 1171 | res->rtyp=POLY_CMD; |
---|
| 1172 | res->data=convClapGFSingGF( F ); |
---|
| 1173 | return FALSE; |
---|
| 1174 | } |
---|
| 1175 | else |
---|
| 1176 | #endif |
---|
[568bc8] | 1177 | /*==================== stdX =================*/ |
---|
| 1178 | if (strcmp(sys_cmd, "std") == 0) |
---|
| 1179 | { |
---|
| 1180 | ideal i1; |
---|
| 1181 | int i2; |
---|
| 1182 | if ((h!=NULL) && (h->Typ()==MODUL_CMD)) |
---|
| 1183 | { |
---|
| 1184 | i1=(ideal)h->CopyD(); |
---|
[fdca1c0] | 1185 | h=h->next; |
---|
[568bc8] | 1186 | } |
---|
| 1187 | else return TRUE; |
---|
| 1188 | if ((h!=NULL) && (h->Typ()==INT_CMD)) |
---|
| 1189 | { |
---|
| 1190 | i2=(int)h->Data(); |
---|
| 1191 | } |
---|
| 1192 | else return TRUE; |
---|
| 1193 | res->rtyp=MODUL_CMD; |
---|
| 1194 | res->data=idXXX(i1,i2); |
---|
| 1195 | return FALSE; |
---|
| 1196 | } |
---|
| 1197 | else |
---|
[fdca1c0] | 1198 | #ifdef HAVE_PLURAL |
---|
| 1199 | /*==================== PLURAL =================*/ |
---|
| 1200 | if (strcmp(sys_cmd, "PLURAL") == 0) |
---|
| 1201 | { |
---|
| 1202 | matrix C; |
---|
| 1203 | matrix D; |
---|
| 1204 | |
---|
| 1205 | if ((h!=NULL) && (h->Typ()==MATRIX_CMD)) |
---|
| 1206 | { |
---|
| 1207 | C=(matrix)h->CopyD(); |
---|
| 1208 | h=h->next; |
---|
| 1209 | } |
---|
| 1210 | else return TRUE; |
---|
| 1211 | if ((h!=NULL) && (h->Typ()==MATRIX_CMD)) |
---|
| 1212 | { |
---|
| 1213 | D=(matrix)h->CopyD(); |
---|
| 1214 | } |
---|
| 1215 | else return TRUE; |
---|
| 1216 | if (currRing->nc==NULL) |
---|
| 1217 | { |
---|
| 1218 | currRing->nc=(nc_struct *)omAlloc0(sizeof(nc_struct)); |
---|
| 1219 | currRing->nc->MT=(matrix *)omAlloc0(pVariables*(pVariables-1)/2*sizeof(matrix)); |
---|
| 1220 | currRing->nc->MTsize=(int *)omAlloc0(pVariables*(pVariables-1)/2*sizeof(int)); |
---|
| 1221 | } |
---|
| 1222 | else |
---|
| 1223 | { |
---|
| 1224 | WarnS("redefining algebra structure"); |
---|
| 1225 | } |
---|
| 1226 | currRing->nc->type=nc_general; |
---|
| 1227 | currRing->nc->C=C; |
---|
| 1228 | currRing->nc->D=D; |
---|
| 1229 | { |
---|
| 1230 | int i,j; |
---|
| 1231 | poly p; |
---|
| 1232 | short DefMTsize=7; |
---|
| 1233 | int nv=pVariables; |
---|
| 1234 | for(i=1;i<nv;i++) |
---|
| 1235 | { |
---|
| 1236 | for(j=i+1;j<=nv;j++) |
---|
| 1237 | { |
---|
| 1238 | currRing->nc->MTsize[UPMATELEM(i,j)]=DefMTsize; /* default sizes */ |
---|
| 1239 | currRing->nc->MT[UPMATELEM(i,j)]=mpNew(DefMTsize,DefMTsize); |
---|
| 1240 | p=pOne(); |
---|
| 1241 | pSetCoeff(p,nCopy(pGetCoeff(MATELEM(currRing->nc->C,i,j)))); |
---|
| 1242 | pSetExp(p,i,1); |
---|
| 1243 | pSetExp(p,j,1); |
---|
| 1244 | pSetm(p); |
---|
| 1245 | p=pAdd(p,pCopy(MATELEM(currRing->nc->D,i,j))); |
---|
| 1246 | MATELEM(currRing->nc->MT[UPMATELEM(i,j)],1,1)=p; |
---|
| 1247 | /* set MT[i,j,1,1] to c_i_j*x_i*x_j + D_i_j */ |
---|
| 1248 | } |
---|
| 1249 | } |
---|
| 1250 | } |
---|
| 1251 | // set p_Procs: |
---|
| 1252 | // currRing->p_Procs->pp_Mult_mm =nc_pp_Mult_mm; |
---|
| 1253 | // currRing->p_Procs->p_Mult_mm =nc_p_Mult_mm; |
---|
| 1254 | // currRing->p_Procs->p_Minus_mm_Mult_qq =nc_p_Minus_mm_Mult_qq; |
---|
| 1255 | |
---|
| 1256 | return FALSE; |
---|
| 1257 | } |
---|
| 1258 | else |
---|
| 1259 | #endif |
---|
[dc65509] | 1260 | #ifdef HAVE_WALK |
---|
[7d423e] | 1261 | /*==================== walk stuff =================*/ |
---|
| 1262 | if (strcmp(sys_cmd, "walkNextWeight") == 0) |
---|
| 1263 | { |
---|
| 1264 | if (h == NULL || h->Typ() != INTVEC_CMD || |
---|
| 1265 | h->next == NULL || h->next->Typ() != INTVEC_CMD || |
---|
| 1266 | h->next->next == NULL || h->next->next->Typ() != IDEAL_CMD) |
---|
| 1267 | { |
---|
| 1268 | Werror("system(\"walkNextWeight\", intvec, intvec, ideal) expected"); |
---|
| 1269 | return TRUE; |
---|
| 1270 | } |
---|
| 1271 | |
---|
| 1272 | if (((intvec*) h->Data())->length() != currRing->N || |
---|
| 1273 | ((intvec*) h->next->Data())->length() != currRing->N) |
---|
| 1274 | { |
---|
| 1275 | Werror("system(\"walkNextWeight\" ...) intvecs not of length %d\n", |
---|
| 1276 | currRing->N); |
---|
| 1277 | return TRUE; |
---|
| 1278 | } |
---|
| 1279 | res->data = (void*) walkNextWeight(((intvec*) h->Data()), |
---|
| 1280 | ((intvec*) h->next->Data()), |
---|
| 1281 | (ideal) h->next->next->Data()); |
---|
| 1282 | if (res->data == (void*) 0 || res->data == (void*) 1) |
---|
| 1283 | { |
---|
| 1284 | res->rtyp = INT_CMD; |
---|
| 1285 | } |
---|
| 1286 | else |
---|
| 1287 | { |
---|
| 1288 | res->rtyp = INTVEC_CMD; |
---|
| 1289 | } |
---|
| 1290 | return FALSE; |
---|
| 1291 | } |
---|
| 1292 | else if (strcmp(sys_cmd, "walkInitials") == 0) |
---|
| 1293 | { |
---|
| 1294 | if (h == NULL || h->Typ() != IDEAL_CMD) |
---|
| 1295 | { |
---|
| 1296 | WerrorS("system(\"walkInitials\", ideal) expected"); |
---|
| 1297 | return TRUE; |
---|
| 1298 | } |
---|
| 1299 | |
---|
| 1300 | res->data = (void*) walkInitials((ideal) h->Data()); |
---|
| 1301 | res->rtyp = IDEAL_CMD; |
---|
| 1302 | return FALSE; |
---|
| 1303 | } |
---|
| 1304 | else |
---|
[dc65509] | 1305 | #endif |
---|
[cb66fa] | 1306 | |
---|
[7d423e] | 1307 | /*==================== Error =================*/ |
---|
[483400] | 1308 | Werror( "system(\"%s\",...) %s", sys_cmd, feNotImplemented ); |
---|
[1a2bd8] | 1309 | } |
---|
[0e1846] | 1310 | return TRUE; |
---|
| 1311 | } |
---|
[53bb688] | 1312 | #endif // HAVE_EXTENDED_SYSTEM |
---|