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