[762407] | 1 | #include "config.h" |
---|
[19ef53c] | 2 | #include "mod2.h" |
---|
| 3 | |
---|
[210e07] | 4 | #include <omalloc/omalloc.h> |
---|
| 5 | #include <misc/auxiliary.h> |
---|
[0726609] | 6 | #ifdef HAVE_FACTORY |
---|
| 7 | #include <factory/factory.h> // :( |
---|
| 8 | #endif |
---|
[b54a36e] | 9 | |
---|
[210e07] | 10 | #include <misc/intvec.h> |
---|
[b54a36e] | 11 | #include <misc/int64vec.h> |
---|
[210e07] | 12 | #include <misc/mylimits.h> |
---|
| 13 | #include <misc/options.h> |
---|
| 14 | |
---|
| 15 | #include <reporter/reporter.h> |
---|
| 16 | |
---|
[0c6947] | 17 | #include <findexec/feFopen.h> |
---|
[f323dd1] | 18 | #include <findexec/feResource.h> |
---|
[210e07] | 19 | |
---|
| 20 | #include <coeffs/coeffs.h> |
---|
| 21 | |
---|
[cab375] | 22 | #include <coeffs/si_gmp.h> |
---|
[210e07] | 23 | |
---|
| 24 | #include <polys/kbuckets.h> |
---|
| 25 | #include <polys/matpol.h> |
---|
| 26 | #include <polys/mod_raw.h> |
---|
| 27 | #include <polys/prCopy.h> |
---|
| 28 | #include <polys/sbuckets.h> |
---|
| 29 | #include <polys/simpleideals.h> |
---|
| 30 | #include <polys/weight.h> |
---|
| 31 | |
---|
| 32 | #include <polys/monomials/maps.h> |
---|
| 33 | #include <polys/monomials/monomials.h> |
---|
| 34 | #include <polys/monomials/p_polys.h> |
---|
| 35 | #include <polys/monomials/ring.h> |
---|
| 36 | |
---|
| 37 | #include <polys/nc/nc.h> |
---|
| 38 | #include <polys/nc/ncSACache.h> |
---|
| 39 | #include <polys/nc/ncSAFormula.h> |
---|
| 40 | #include <polys/nc/ncSAMult.h> |
---|
| 41 | #include <polys/nc/sca.h> |
---|
| 42 | #include <polys/nc/summator.h> |
---|
| 43 | |
---|
| 44 | |
---|
| 45 | #include <polys/templates/p_MemAdd.h> |
---|
| 46 | #include <polys/templates/p_Procs.h> |
---|
| 47 | |
---|
[aec311] | 48 | #include <polys/operations/pShallowCopyDelete.h> |
---|
| 49 | |
---|
| 50 | #include <polys/clapsing.h> |
---|
[210e07] | 51 | |
---|
| 52 | |
---|
[b54a36e] | 53 | #ifdef HAVE_FACTORY |
---|
[6bcd036] | 54 | // The following are needed due to FACTORY (e.g. initCanonicalForm) |
---|
[f323dd1] | 55 | int initializeGMP(){ return 1; } |
---|
[6bcd036] | 56 | int mmInit(void) {return 1; } |
---|
[b54a36e] | 57 | #endif |
---|
| 58 | |
---|
[eb0708] | 59 | // // TODO: DUE to the use of HALT in npolygon.cc :((( |
---|
| 60 | extern "C" {void m2_end(int i){exit(i);}} |
---|
| 61 | |
---|
| 62 | // // TODO: DUE to its use in kutil.cc :((( |
---|
| 63 | char * showOption(){return NULL;} |
---|
| 64 | |
---|
| 65 | // // TODO: DUE to its use in feread.cc :((( |
---|
| 66 | char *iiArithGetCmd(int nPos){return NULL; } |
---|
| 67 | |
---|
[210e07] | 68 | |
---|
| 69 | #include <coeffs/numbers.h> |
---|
| 70 | |
---|
[aec311] | 71 | #include "structs.h" |
---|
[210e07] | 72 | |
---|
| 73 | |
---|
[aec311] | 74 | // HEADERS: |
---|
[210e07] | 75 | #include "hutil.h" |
---|
[b54a36e] | 76 | //#include "idrec.h" // moved to Singular |
---|
[210e07] | 77 | #include "stairc.h" |
---|
| 78 | #include "ideals.h" |
---|
| 79 | #include "syz.h" |
---|
| 80 | #include "fast_maps.h" |
---|
| 81 | #include "febase.h" |
---|
| 82 | #include "walkProc.h" |
---|
| 83 | #include "walkMain.h" |
---|
| 84 | #include "walkSupport.h" |
---|
| 85 | #include "khstd.h" |
---|
| 86 | /// #include "sparsmat.h" // TODO: install polys/this! |
---|
[aec311] | 87 | //+ |
---|
| 88 | |
---|
[210e07] | 89 | #include "fglm.h" |
---|
| 90 | #include "kstd1.h" |
---|
| 91 | #include "fglmgauss.h" |
---|
| 92 | #include "fglmvec.h" |
---|
| 93 | #include "kstdfac.h" |
---|
| 94 | #include "kmatrix.h" |
---|
| 95 | #include "GMPrat.h" |
---|
| 96 | #include "multicnt.h" |
---|
| 97 | #include "npolygon.h" |
---|
| 98 | #include "semic.h" |
---|
| 99 | #include "spectrum.h" |
---|
| 100 | #include "splist.h" |
---|
| 101 | #include "multicnt.h" |
---|
| 102 | #include "eigenval.h" |
---|
| 103 | #include "units.h" |
---|
| 104 | #include "ratgring.h" |
---|
| 105 | #include "shiftgb.h" |
---|
[715936] | 106 | // #include "mmalloc.h" // move to Singular!? |
---|
[210e07] | 107 | #include "gfan.h" |
---|
| 108 | |
---|
[b54a36e] | 109 | #include "kutil.h" |
---|
[210e07] | 110 | |
---|
[e585b6] | 111 | // #include "dbm_sl.h" // TODO: needs si_link// already moved to Singular/! |
---|
[210e07] | 112 | |
---|
| 113 | // #include "CCRing.h" // Too old! |
---|
| 114 | #include "digitech.h" |
---|
| 115 | #include "eigenval.h" |
---|
| 116 | #include "fast_maps.h" |
---|
| 117 | #include "fast_mult.h" |
---|
| 118 | #include "febase.h" |
---|
[aec311] | 119 | |
---|
[210e07] | 120 | #include "fglmgauss.h" |
---|
| 121 | #include "fglm.h" |
---|
| 122 | #include "fglmvec.h" |
---|
[aec311] | 123 | |
---|
| 124 | ////////#include "F5cData.h" |
---|
| 125 | #include "f5c.h" |
---|
| 126 | #include "f5data.h" |
---|
| 127 | #include "f5gb.h" |
---|
| 128 | #include "f5lists.h" |
---|
| 129 | ////////#include "F5cLists.h" |
---|
| 130 | |
---|
[210e07] | 131 | #include "gfan.h" |
---|
[aec311] | 132 | |
---|
| 133 | |
---|
[210e07] | 134 | #include "GMPrat.h" |
---|
[aec311] | 135 | |
---|
[f323dd1] | 136 | // #include "htmlhelp.h" // For Windows // |
---|
[210e07] | 137 | #include "hutil.h" |
---|
| 138 | // #include "Ideal.h" // Too old? |
---|
[aec311] | 139 | |
---|
| 140 | |
---|
[210e07] | 141 | #include "ideals.h" |
---|
[aec311] | 142 | |
---|
[210e07] | 143 | #include "kmatrix.h" |
---|
| 144 | #include "kstd1.h" |
---|
| 145 | #include "kstdfac.h" |
---|
[aec311] | 146 | #include "khstd.h" |
---|
[210e07] | 147 | |
---|
| 148 | #include "linearAlgebra.h" |
---|
[aec311] | 149 | |
---|
| 150 | |
---|
| 151 | |
---|
[210e07] | 152 | // #include "lplist.h" // Too old! |
---|
| 153 | #include "multicnt.h" |
---|
| 154 | #include "npolygon.h" |
---|
| 155 | // #include "Number.h" // Too old? |
---|
| 156 | // #include "Poly.h" // Too old? |
---|
| 157 | // #include "PowerSeries.h" // Too old? |
---|
[aec311] | 158 | |
---|
[d914cf0] | 159 | #include "preimage.h" |
---|
[aec311] | 160 | |
---|
[e63576] | 161 | #include "nc.h" |
---|
| 162 | |
---|
[210e07] | 163 | #include "ratgring.h" |
---|
| 164 | #include "ringgb.h" |
---|
[bcfb6e] | 165 | // #include "run.h" // moved to Singular |
---|
[210e07] | 166 | #include "semic.h" |
---|
| 167 | #include "shiftgb.h" |
---|
[cab375] | 168 | // #include "si_gmp.h" // remove it... |
---|
[210e07] | 169 | #include "spectrum.h" |
---|
| 170 | #include "splist.h" |
---|
| 171 | #include "stairc.h" |
---|
| 172 | #include "structs.h" |
---|
| 173 | #include "syz.h" |
---|
| 174 | // #include "testpoly.h" // Too old? |
---|
| 175 | |
---|
| 176 | #include "tgbgauss.h" |
---|
| 177 | #include "tgb.h" |
---|
[aec311] | 178 | |
---|
[210e07] | 179 | #include "timer.h" |
---|
[aec311] | 180 | |
---|
[210e07] | 181 | #include "units.h" |
---|
| 182 | #include "walkMain.h" |
---|
| 183 | #include "walkProc.h" |
---|
| 184 | #include "walkSupport.h" |
---|
| 185 | |
---|
[aec311] | 186 | |
---|
| 187 | // #include <polys/clapconv.h> // due to factory? :( |
---|
| 188 | // #include "tgb_internal.h" // :( |
---|
| 189 | // #include "F4.h" // uses tgb_internal // :( |
---|
| 190 | // #include "IIntvec.h" // :( |
---|
| 191 | |
---|
| 192 | |
---|
[76cfef] | 193 | |
---|
| 194 | |
---|
[6bcd036] | 195 | // #include "fglmzero.cc" // looks like <factory/templates/ftmpl_list.h> must be installed! |
---|
[76cfef] | 196 | // TODO: looks like <coeffs/mpr_complex.h> must be installed! |
---|
| 197 | |
---|
[b54a36e] | 198 | |
---|
| 199 | |
---|
[8aa03b] | 200 | #include "polys.h" |
---|
[b54a36e] | 201 | |
---|
[c36096] | 202 | void TestGBEngine() |
---|
[b54a36e] | 203 | { |
---|
[f323dd1] | 204 | |
---|
[c36096] | 205 | // R = MPolynomialRing_polydict(QQ,5,'w,x,y,z,C', order='degrevlex') |
---|
| 206 | // J = (w*w - x*z, w*x - y*z, x*x - w*y, x*y - z*z, y*y - w*z) |
---|
[f323dd1] | 207 | |
---|
[c36096] | 208 | const short w = 1; |
---|
| 209 | const short x = 2; |
---|
| 210 | const short y = 3; |
---|
| 211 | const short z = 4; |
---|
[b54a36e] | 212 | |
---|
[c36096] | 213 | const short N = (z - w + 1); |
---|
| 214 | |
---|
| 215 | char **n=(char**)omalloc(N*sizeof(char*)); |
---|
| 216 | |
---|
[f323dd1] | 217 | |
---|
[c36096] | 218 | n[w-1]=omStrDup("w"); |
---|
| 219 | n[x-1]=omStrDup("x"); |
---|
| 220 | n[y-1]=omStrDup("y"); |
---|
| 221 | n[z-1]=omStrDup("z"); |
---|
| 222 | |
---|
| 223 | |
---|
| 224 | const int D = 3; |
---|
| 225 | int *order = (int *) omAlloc0(D* sizeof(int)); |
---|
| 226 | int *block0 = (int *)omAlloc0(D * sizeof(int)); |
---|
| 227 | int *block1 = (int *)omAlloc0(D * sizeof(int)); |
---|
| 228 | |
---|
| 229 | order[0] = ringorder_dp; |
---|
| 230 | block0[0] = 1; |
---|
| 231 | block1[0] = N; |
---|
| 232 | |
---|
| 233 | order[1] = ringorder_C; |
---|
| 234 | block0[1] = 1; |
---|
| 235 | block1[1] = N; |
---|
| 236 | |
---|
[f323dd1] | 237 | ring R = rDefault(0, N, n, D, order, block0, block1); |
---|
| 238 | |
---|
| 239 | // ring R = rDefault(0, N, n); |
---|
[c36096] | 240 | |
---|
| 241 | rWrite(R); PrintLn(); |
---|
| 242 | |
---|
| 243 | #ifdef RDEBUG |
---|
| 244 | rDebugPrint(R); |
---|
| 245 | #endif |
---|
| 246 | |
---|
| 247 | ideal I = idInit(5, 1); |
---|
| 248 | |
---|
| 249 | int gen = 0; |
---|
| 250 | |
---|
| 251 | { |
---|
| 252 | // -xz |
---|
| 253 | poly p = p_ISet(-1,R); |
---|
[f323dd1] | 254 | |
---|
[c36096] | 255 | p_SetExp(p, x, 1, R); |
---|
| 256 | p_SetExp(p, z, 1, R); |
---|
| 257 | p_Setm(p, R); |
---|
| 258 | |
---|
| 259 | assume( p_GetExp(p, x, R) == 1 ); |
---|
| 260 | assume( p_GetExp(p, z, R) == 1 ); |
---|
| 261 | assume( p_GetExp(p, w, R) == 0 ); |
---|
| 262 | assume( p_GetExp(p, y, R) == 0 ); |
---|
| 263 | |
---|
| 264 | // +w2 |
---|
| 265 | poly lp = p_ISet(1,R); |
---|
| 266 | p_SetExp(lp, w, 2, R); |
---|
| 267 | p_Setm(lp, R); |
---|
| 268 | |
---|
| 269 | assume( p_GetExp(lp, w, R) == 2 ); |
---|
| 270 | assume( p_GetExp(lp, x, R) == 0 ); |
---|
| 271 | assume( p_GetExp(lp, y, R) == 0 ); |
---|
| 272 | assume( p_GetExp(lp, z, R) == 0 ); |
---|
| 273 | |
---|
| 274 | MATELEM(I, 1, ++gen) = p_Add_q(lp, p, R); // w2 - xz |
---|
| 275 | } |
---|
| 276 | |
---|
| 277 | { |
---|
| 278 | // -yz |
---|
| 279 | poly p = p_ISet(-1,R); |
---|
| 280 | |
---|
| 281 | p_SetExp(p, y, 1, R); |
---|
| 282 | p_SetExp(p, z, 1, R); |
---|
| 283 | p_Setm(p, R); |
---|
| 284 | |
---|
| 285 | assume( p_GetExp(p, y, R) == 1 ); |
---|
| 286 | assume( p_GetExp(p, z, R) == 1 ); |
---|
| 287 | assume( p_GetExp(p, w, R) == 0 ); |
---|
| 288 | assume( p_GetExp(p, x, R) == 0 ); |
---|
| 289 | |
---|
| 290 | // +wx |
---|
| 291 | poly lp = p_ISet(1,R); |
---|
| 292 | p_SetExp(lp, w, 1, R); |
---|
| 293 | p_SetExp(lp, x, 1, R); |
---|
| 294 | p_Setm(lp, R); |
---|
| 295 | |
---|
| 296 | assume( p_GetExp(lp, w, R) == 1 ); |
---|
| 297 | assume( p_GetExp(lp, x, R) == 1 ); |
---|
| 298 | assume( p_GetExp(lp, y, R) == 0 ); |
---|
| 299 | assume( p_GetExp(lp, z, R) == 0 ); |
---|
| 300 | |
---|
| 301 | MATELEM(I, 1, ++gen) = p_Add_q(lp, p, R); // wx - yz |
---|
| 302 | } |
---|
[f323dd1] | 303 | |
---|
[c36096] | 304 | |
---|
| 305 | { |
---|
| 306 | // -wy |
---|
| 307 | poly p = p_ISet(-1,R); |
---|
| 308 | |
---|
| 309 | p_SetExp(p, y, 1, R); |
---|
| 310 | p_SetExp(p, w, 1, R); |
---|
| 311 | p_Setm(p, R); |
---|
| 312 | |
---|
| 313 | assume( p_GetExp(p, y, R) == 1 ); |
---|
| 314 | assume( p_GetExp(p, w, R) == 1 ); |
---|
| 315 | assume( p_GetExp(p, z, R) == 0 ); |
---|
| 316 | assume( p_GetExp(p, x, R) == 0 ); |
---|
| 317 | |
---|
| 318 | // +x2 |
---|
| 319 | poly lp = p_ISet(1,R); |
---|
| 320 | p_SetExp(lp, x, 2, R); |
---|
| 321 | p_Setm(lp, R); |
---|
| 322 | |
---|
| 323 | assume( p_GetExp(lp, w, R) == 0 ); |
---|
| 324 | assume( p_GetExp(lp, x, R) == 2 ); |
---|
| 325 | assume( p_GetExp(lp, y, R) == 0 ); |
---|
| 326 | assume( p_GetExp(lp, z, R) == 0 ); |
---|
| 327 | |
---|
| 328 | MATELEM(I, 1, ++gen) = p_Add_q(lp, p, R); // x2 - wy |
---|
| 329 | } |
---|
[f323dd1] | 330 | |
---|
[c36096] | 331 | |
---|
| 332 | { |
---|
| 333 | // -z2 |
---|
| 334 | poly p = p_ISet(-1,R); |
---|
| 335 | |
---|
| 336 | p_SetExp(p, z, 2, R); |
---|
| 337 | p_Setm(p, R); |
---|
| 338 | |
---|
| 339 | assume( p_GetExp(p, y, R) == 0 ); |
---|
| 340 | assume( p_GetExp(p, w, R) == 0 ); |
---|
| 341 | assume( p_GetExp(p, z, R) == 2 ); |
---|
| 342 | assume( p_GetExp(p, x, R) == 0 ); |
---|
| 343 | |
---|
| 344 | // +xy |
---|
| 345 | poly lp = p_ISet(1,R); |
---|
| 346 | p_SetExp(lp, x, 1, R); |
---|
| 347 | p_SetExp(lp, y, 1, R); |
---|
| 348 | p_Setm(lp, R); |
---|
| 349 | |
---|
| 350 | assume( p_GetExp(lp, w, R) == 0 ); |
---|
| 351 | assume( p_GetExp(lp, x, R) == 1 ); |
---|
| 352 | assume( p_GetExp(lp, y, R) == 1 ); |
---|
| 353 | assume( p_GetExp(lp, z, R) == 0 ); |
---|
| 354 | |
---|
| 355 | MATELEM(I, 1, ++gen) = p_Add_q(lp, p, R); // xy - z2 |
---|
| 356 | } |
---|
[f323dd1] | 357 | |
---|
[c36096] | 358 | |
---|
| 359 | { |
---|
| 360 | // -wz |
---|
| 361 | poly p = p_ISet(-1,R); |
---|
| 362 | |
---|
| 363 | p_SetExp(p, w, 1, R); |
---|
| 364 | p_SetExp(p, z, 1, R); |
---|
| 365 | p_Setm(p, R); |
---|
| 366 | |
---|
| 367 | assume( p_GetExp(p, y, R) == 0 ); |
---|
| 368 | assume( p_GetExp(p, w, R) == 1 ); |
---|
| 369 | assume( p_GetExp(p, z, R) == 1 ); |
---|
| 370 | assume( p_GetExp(p, x, R) == 0 ); |
---|
| 371 | |
---|
| 372 | // +y2 |
---|
| 373 | poly lp = p_ISet(1,R); |
---|
| 374 | p_SetExp(lp, y, 2, R); |
---|
| 375 | p_Setm(lp, R); |
---|
| 376 | |
---|
| 377 | assume( p_GetExp(lp, w, R) == 0 ); |
---|
| 378 | assume( p_GetExp(lp, x, R) == 0 ); |
---|
| 379 | assume( p_GetExp(lp, y, R) == 2 ); |
---|
| 380 | assume( p_GetExp(lp, z, R) == 0 ); |
---|
| 381 | |
---|
| 382 | MATELEM(I, 1, ++gen) = p_Add_q(lp, p, R); // y2 - wz |
---|
| 383 | } |
---|
| 384 | #ifdef PDEBUG |
---|
| 385 | PrintS("I: "); |
---|
| 386 | idShow(I, R, R, 0); |
---|
| 387 | #endif |
---|
| 388 | |
---|
| 389 | |
---|
| 390 | // ideal kStd(ideal F, ideal Q, tHomog h, intvec ** mw,intvec *hilb=NULL, |
---|
| 391 | // int syzComp=0,int newIdeal=0, intvec *vw=NULL); |
---|
| 392 | // make R the default ring: |
---|
| 393 | rChangeCurrRing(R); |
---|
| 394 | |
---|
[5116a21] | 395 | { |
---|
| 396 | ideal G = kStd(I, currQuotient, testHomog, NULL); |
---|
| 397 | |
---|
| 398 | #ifdef PDEBUG |
---|
| 399 | PrintS("GB: "); |
---|
| 400 | idShow(G, R, R, 0); |
---|
| 401 | #endif |
---|
[c36096] | 402 | |
---|
[5116a21] | 403 | idDelete( &G, R); |
---|
| 404 | } |
---|
| 405 | |
---|
| 406 | { |
---|
| 407 | intvec *weights = NULL; |
---|
| 408 | ideal SYZ = idSyzygies(I, testHomog, &weights); |
---|
[f323dd1] | 409 | |
---|
[c36096] | 410 | #ifdef PDEBUG |
---|
[5116a21] | 411 | PrintS("SYZ: "); |
---|
| 412 | idShow(SYZ, R, R, 0); |
---|
[c36096] | 413 | #endif |
---|
[8aa03b] | 414 | |
---|
[5116a21] | 415 | idDelete(&SYZ, R); |
---|
| 416 | if (weights!=NULL) { PrintS("weights: "); weights->show(); delete weights; } |
---|
| 417 | } |
---|
[c36096] | 418 | |
---|
| 419 | |
---|
| 420 | { |
---|
[5116a21] | 421 | PrintS("\n**********************************\n"); |
---|
| 422 | PrintS("lres: \n"); |
---|
| 423 | int dummy; |
---|
| 424 | syStrategy r = syLaScala3(I,&dummy); |
---|
| 425 | |
---|
| 426 | intvec *b = syBettiOfComputation(r, FALSE); |
---|
| 427 | PrintS("non-min. betti: \n"); b->show(); PrintLn(); |
---|
| 428 | delete b; |
---|
| 429 | |
---|
| 430 | Print("length: %d\n", sySize(r)); |
---|
| 431 | |
---|
| 432 | syPrint(r, "R"); |
---|
| 433 | |
---|
| 434 | r = syMinimize(r); // syzstr->references ++ ==> memory leak :((( |
---|
| 435 | |
---|
| 436 | b = syBettiOfComputation(r, TRUE); |
---|
| 437 | PrintS("min. betti: \n"); b->show(); PrintLn(); |
---|
[f323dd1] | 438 | delete b; |
---|
[5116a21] | 439 | |
---|
| 440 | Print("length: %d\n", sySize(r)); |
---|
| 441 | |
---|
| 442 | syPrint(r, "R"); |
---|
[f323dd1] | 443 | |
---|
[5116a21] | 444 | syKillComputation(r, R); |
---|
[c36096] | 445 | } |
---|
| 446 | |
---|
[5116a21] | 447 | { |
---|
| 448 | PrintS("\n**********************************\n"); |
---|
| 449 | PrintS("sres: \n"); |
---|
| 450 | const int maxl = rVar(R)-1; // +2*(1); |
---|
[c36096] | 451 | |
---|
[5116a21] | 452 | syStrategy r = sySchreyer(I, rVar(R)); |
---|
| 453 | |
---|
| 454 | intvec *b = syBettiOfComputation(r, FALSE); |
---|
| 455 | PrintS("non-min. betti: \n"); b->show(); PrintLn(); |
---|
| 456 | delete b; |
---|
| 457 | |
---|
| 458 | Print("length: %d\n", sySize(r)); |
---|
| 459 | |
---|
| 460 | syPrint(r, "R"); |
---|
| 461 | |
---|
| 462 | r = syMinimize(r); // syzstr->references ++ ==> memory leak :((( |
---|
| 463 | |
---|
| 464 | b = syBettiOfComputation(r, TRUE); |
---|
| 465 | PrintS("min. betti: \n"); b->show(); PrintLn(); |
---|
[f323dd1] | 466 | delete b; |
---|
[5116a21] | 467 | |
---|
| 468 | Print("length: %d\n", sySize(r)); |
---|
| 469 | |
---|
| 470 | syPrint(r, "R"); |
---|
| 471 | |
---|
| 472 | syKillComputation(r, R); |
---|
| 473 | } |
---|
| 474 | |
---|
[f323dd1] | 475 | |
---|
[5116a21] | 476 | |
---|
| 477 | { |
---|
| 478 | PrintS("\n**********************************\n"); |
---|
| 479 | PrintS("nres: \n"); |
---|
| 480 | intvec *weights=NULL; |
---|
| 481 | // const int maxl = rVar(R)-1 + 2*(1); |
---|
| 482 | syStrategy r = syResolution(I, rVar(R)-1, weights, FALSE/*iiOp==MRES_CMD*/); |
---|
| 483 | |
---|
| 484 | intvec *b = syBettiOfComputation(r, FALSE); |
---|
| 485 | PrintS("non-min. betti: \n"); b->show(); PrintLn(); |
---|
| 486 | delete b; |
---|
| 487 | |
---|
| 488 | Print("length: %d\n", sySize(r)); |
---|
| 489 | |
---|
| 490 | syPrint(r, "R"); |
---|
| 491 | |
---|
| 492 | r = syMinimize(r); // syzstr->references ++ ==> memory leak :((( |
---|
| 493 | |
---|
| 494 | b = syBettiOfComputation(r, TRUE); |
---|
| 495 | PrintS("min. betti: \n"); b->show(); PrintLn(); |
---|
[f323dd1] | 496 | delete b; |
---|
[5116a21] | 497 | |
---|
| 498 | Print("length: %d\n", sySize(r)); |
---|
| 499 | |
---|
| 500 | syPrint(r, "R"); |
---|
| 501 | |
---|
| 502 | syKillComputation(r, R); |
---|
| 503 | } |
---|
[f323dd1] | 504 | |
---|
[c36096] | 505 | |
---|
[5116a21] | 506 | { |
---|
| 507 | PrintS("\n**********************************\n"); |
---|
| 508 | PrintS("mres: \n"); |
---|
| 509 | intvec *weights=NULL; |
---|
| 510 | // const int maxl = rVar(R)-1 + 2*(1); |
---|
| 511 | syStrategy r = syResolution(I, rVar(R)+1, weights, TRUE/*iiOp==MRES_CMD*/); |
---|
| 512 | |
---|
| 513 | intvec *b = syBettiOfComputation(r, FALSE); |
---|
| 514 | PrintS("non-min. betti: \n"); b->show(); PrintLn(); |
---|
| 515 | delete b; |
---|
| 516 | |
---|
| 517 | Print("length: %d\n", sySize(r)); |
---|
| 518 | |
---|
| 519 | syPrint(r, "R"); |
---|
| 520 | |
---|
| 521 | r = syMinimize(r); // syzstr->references ++ ==> memory leak :((( |
---|
| 522 | |
---|
| 523 | b = syBettiOfComputation(r, TRUE); |
---|
| 524 | PrintS("min. betti: \n"); b->show(); PrintLn(); |
---|
[f323dd1] | 525 | delete b; |
---|
[5116a21] | 526 | |
---|
| 527 | Print("length: %d\n", sySize(r)); |
---|
| 528 | |
---|
| 529 | syPrint(r, "R"); |
---|
| 530 | |
---|
| 531 | syKillComputation(r, R); |
---|
| 532 | } |
---|
| 533 | |
---|
| 534 | |
---|
[f323dd1] | 535 | |
---|
| 536 | |
---|
| 537 | idDelete( &I, R); |
---|
[c36096] | 538 | rDelete(R); // should cleanup every belonging polynomial, right!? |
---|
[f323dd1] | 539 | |
---|
[c36096] | 540 | } |
---|
| 541 | |
---|
| 542 | |
---|
| 543 | |
---|
| 544 | void TestSimpleRingArithmetcs() |
---|
| 545 | { |
---|
[8aa03b] | 546 | // Libpolys tests: |
---|
[c36096] | 547 | |
---|
[8aa03b] | 548 | // construct the ring Z/32003[x,y,z] |
---|
| 549 | // the variable names |
---|
| 550 | char **n=(char**)omalloc(3*sizeof(char*)); |
---|
| 551 | n[0]=omStrDup("x"); |
---|
| 552 | n[1]=omStrDup("y"); |
---|
| 553 | n[2]=omStrDup("z2"); |
---|
| 554 | |
---|
[0e4a9f] | 555 | ring R = rDefault(32003,3,n); // ring R = rDefault(0,3,n); |
---|
| 556 | |
---|
| 557 | rWrite(R); PrintLn(); |
---|
| 558 | |
---|
| 559 | #ifdef RDEBUG |
---|
| 560 | rDebugPrint(R); |
---|
| 561 | #endif |
---|
| 562 | |
---|
[c36096] | 563 | |
---|
[0e4a9f] | 564 | poly p = p_ISet(1,R); p_SetExp(p,1,1, R); p_Setm(p, R); |
---|
| 565 | |
---|
| 566 | assume( p_GetExp(p,1, R) == 1 ); |
---|
[c36096] | 567 | |
---|
[0e4a9f] | 568 | poly pp = pp_Mult_qq( p, p, R); |
---|
| 569 | |
---|
[d894371] | 570 | Print("p: "); p_Write0(p, R); Print(", deg(p): %d", p_Totaldegree(p, R)); assume( 1 == p_Totaldegree(p, R) ); |
---|
| 571 | |
---|
| 572 | Print("; p*p : "); p_Write0(pp, R); Print("deg(pp): %d\n", p_Totaldegree(pp, R)); assume( 2 == p_Totaldegree(pp, R) ); |
---|
| 573 | |
---|
[0e4a9f] | 574 | |
---|
| 575 | p_Delete(&p, R); |
---|
[c36096] | 576 | |
---|
[0e4a9f] | 577 | assume( p_GetExp(pp,1, R) == 2 ); |
---|
[c36096] | 578 | |
---|
[0e4a9f] | 579 | p_Delete(&pp, R); |
---|
[c36096] | 580 | |
---|
| 581 | |
---|
[0e4a9f] | 582 | // rDelete(R); |
---|
[c36096] | 583 | |
---|
[8aa03b] | 584 | // make R the default ring: |
---|
| 585 | rChangeCurrRing(R); |
---|
[c36096] | 586 | |
---|
[8aa03b] | 587 | // create the polynomial 1 |
---|
| 588 | poly p1=pISet(1); |
---|
| 589 | |
---|
| 590 | // create tthe polynomial 2*x^3*z^2 |
---|
| 591 | poly p2=p_ISet(2,R); |
---|
| 592 | pSetExp(p2,1,3); |
---|
| 593 | pSetExp(p2,3,2); |
---|
| 594 | pSetm(p2); |
---|
| 595 | |
---|
| 596 | // print p1 + p2 |
---|
[f323dd1] | 597 | Print("p1: "); pWrite0(p1); |
---|
| 598 | Print(" + p2: "); pWrite0(p2); |
---|
[0e4a9f] | 599 | Print(" ---- >>>> "); |
---|
[8aa03b] | 600 | |
---|
| 601 | // compute p1+p2 |
---|
| 602 | p1=p_Add_q(p1,p2,R); p2=NULL; |
---|
[f323dd1] | 603 | pWrite(p1); |
---|
[8aa03b] | 604 | |
---|
| 605 | // clean up: |
---|
[0e4a9f] | 606 | // pDelete(&p1); |
---|
[c36096] | 607 | |
---|
[0e4a9f] | 608 | rDelete(R); // should cleanup every belonging polynomial, right!? |
---|
[c36096] | 609 | } |
---|
| 610 | |
---|
| 611 | |
---|
[f323dd1] | 612 | int main( int, char *argv[] ) |
---|
[c36096] | 613 | { |
---|
| 614 | feInitResources(argv[0]); |
---|
| 615 | |
---|
| 616 | StringSetS("ressources in use (as reported by feStringAppendResources(0):\n"); |
---|
| 617 | feStringAppendResources(0); |
---|
| 618 | |
---|
[80c703] | 619 | PrintLn(); |
---|
| 620 | { char* s = StringEndS(); PrintS(s); omFree(s); } |
---|
| 621 | |
---|
[c36096] | 622 | TestGBEngine(); |
---|
| 623 | TestSimpleRingArithmetcs(); |
---|
[f323dd1] | 624 | |
---|
[b54a36e] | 625 | return 0; |
---|
| 626 | } |
---|