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