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