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