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