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