Changeset 36b81ac in git
- Timestamp:
- Sep 1, 2015, 3:13:14 PM (8 years ago)
- Branches:
- (u'spielwiese', '0d6b7fcd9813a1ca1ed4220cfa2b104b97a0a003')
- Children:
- 510257fc6c7ff9c0c28e81f62f6fe06e63f024f8b430ca2b1337f52e1932f689e451e9abb002ec4a
- Parents:
- 74fe3587102ed73b3858258975abbe6d63139abfcd38fbd954495900afc188a0e871f8586db00535
- Files:
-
- 4 added
- 35 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/grwalk.lib
rcd38fbd r36b81ac 255 255 } 256 256 257 proc gwalk(ideal Go, list #)258 "SYNTAX: gwalk(ideal i );259 gwalk(ideal i, int vec v, intvec w);257 proc gwalk(ideal Go, int reduction,int printout, list #) 258 "SYNTAX: gwalk(ideal i, int reduction, int printout); 259 gwalk(ideal i, int reduction, int printout, intvec v, intvec w); 260 260 TYPE: ideal 261 261 PURPOSE: compute the standard basis of the ideal, calculated via … … 274 274 string ord_str = OSCTW[2]; 275 275 intvec curr_weight = OSCTW[3]; /* original weight vector */ 276 intvec target_weight = OSCTW[4]; /* t erget weight vector */276 intvec target_weight = OSCTW[4]; /* target weight vector */ 277 277 kill OSCTW; 278 278 option(redSB); … … 284 284 //print("//** help ring = " + string(basering)); 285 285 ideal G = fetch(xR, Go); 286 G = system("Mwalk", G, curr_weight, target_weight,basering );286 G = system("Mwalk", G, curr_weight, target_weight,basering,reduction,printout); 287 287 288 288 setring xR; … … 299 299 //** compute a Groebner basis of I w.r.t. lp. 300 300 ring r = 32003,(z,y,x), lp; 301 ideal I = y3+xyz+y2z+xz3, 3+xy+x2y+y2z; 302 gwalk(I); 301 ideal I = zy2+yx2+yx+3, 302 z3x+y3+zyx-yx2-yx-3, 303 z2yx3-y5+z2yx2+y3x2+y2x3+y3x+y2x2+3z2x+3y2+3yx, 304 zyx5+y6-y4x2-y3x3+2zyx4-y4x-y3x2+zyx3-3z2yx+3zx3-3y3-3y2x+3zx2, 305 yx7-y7+y5x2+y4x3+3yx6+y5x+y4x2+3yx5-6zyx3+yx4+3x5+3y4+3y3x-6zyx2+6x4+3x3-9zx; 306 gwalk(I,0,1); 303 307 } 304 308 … … 346 350 } 347 351 348 proc fwalk(ideal Go, list #)349 "SYNTAX: fwalk(ideal i );350 fwalk(ideal i, int vec v, intvec w);352 proc fwalk(ideal Go, int reduction, int printout, list #) 353 "SYNTAX: fwalk(ideal i,int reductioin); 354 fwalk(ideal i, int reduction intvec v, intvec w); 351 355 TYPE: ideal 352 356 PURPOSE: compute the standard basis of the ideal w.r.t. the … … 372 376 373 377 ideal G = fetch(xR, Go); 374 G = system("Mfwalk", G, curr_weight, target_weight );378 G = system("Mfwalk", G, curr_weight, target_weight, reduction, printout); 375 379 376 380 setring xR; … … 387 391 ring r = 32003,(z,y,x), lp; 388 392 ideal I = y3+xyz+y2z+xz3, 3+xy+x2y+y2z; 389 fwalk(I); 393 int reduction = 1; 394 int printout = 1; 395 fwalk(I,reduction,printout); 390 396 } 391 397 … … 437 443 } 438 444 439 proc pwalk(ideal Go, int n1, int n2, list #)440 "SYNTAX: pwalk(int d, ideal i, int n1, int n2 );441 pwalk(int d, ideal i, int n1, int n2, int vec v, intvec w);445 proc pwalk(ideal Go, int n1, int n2, int reduction, int printout, list #) 446 "SYNTAX: pwalk(int d, ideal i, int n1, int n2, int reduction, int printout); 447 pwalk(int d, ideal i, int n1, int n2, int reduction, int printout, intvec v, intvec w); 442 448 TYPE: ideal 443 449 PURPOSE: compute the standard basis of the ideal, calculated via … … 477 483 ideal G = fetch(xR, Go); 478 484 479 G = system("Mpwalk", G, n1, n2, curr_weight, target_weight,nP);480 485 G = system("Mpwalk",G,n1,n2,curr_weight,target_weight,nP,reduction,printout); 486 481 487 setring xR; 482 //kill Go; 488 //kill Go; //unused 483 489 484 490 keepring basering; … … 492 498 ring r = 32003,(z,y,x), lp; 493 499 ideal I = y3+xyz+y2z+xz3, 3+xy+x2y+y2z; 494 //I = std(I); 495 //ring rr = 32003,(z,y,x),lp; 496 //ideal I = fetch(r,I); 497 pwalk(I,2,2); 500 int reduction = 1; 501 int printout = 2; 502 pwalk(I,2,2,reduction,printout); 498 503 } 499 504 -
Singular/LIB/modstd.lib
r74fe358 r36b81ac 1 1 /////////////////////////////////////////////////////////////////////////////// 2 version="version modstd.lib 4.0. 0.0 May_2014"; // $Id$2 version="version modstd.lib 4.0.2.0 Aug_2015 "; // $Id$ 3 3 category="Commutative Algebra"; 4 4 info=" … … 219 219 /* test if 'command' applied to 'args' in characteristic p is the same as 220 220 'result' mapped to characteristic p */ 221 static proc pTest_std(string command, list args, ideal result, int p) 221 static proc pTest_std(string command, alias list args, alias ideal result, 222 int p) 222 223 { 223 224 /* change to characteristic p */ -
Singular/LIB/modwalk.lib
-
Property
mode
changed from
100644
to100755
rcd38fbd r36b81ac 16 16 17 17 PROCEDURES: 18 modWalk(ideal,int,int[,int,int,int,int]); standard basis conversion of I using modular methods (chinese remainder) 18 19 modWalk(I,#); standard basis conversion of I by Groebner Walk using modular methods 20 modrWalk(I,radius,pertdeg,#); standard basis conversion of I by Random Walk using modular methods 21 modfWalk(I,#); standard basis conversion of I by Fractal Walk using modular methods 22 modfrWalk(I,radius,#); standard basis conversion of I by Random Fractal Walk using modular methods 19 23 "; 20 24 21 LIB "poly.lib";22 LIB "ring.lib";23 LIB "parallel.lib";24 25 LIB "rwalk.lib"; 25 26 LIB "grwalk.lib"; 26 LIB "modstd.lib"; 27 28 29 //////////////////////////////////////////////////////////////////////////////// 30 31 static proc modpWalk(def II, int p, int variant, list #) 32 "USAGE: modpWalk(I,p,#); I ideal, p integer, variant integer 33 ASSUME: If size(#) > 0, then 34 #[1] is an intvec describing the current weight vector 35 #[2] is an intvec describing the target weight vector 36 RETURN: ideal - a standard basis of I mod p, integer - p 37 NOTE: The procedure computes a standard basis of the ideal I modulo p and 38 fetches the result to the basering. 39 EXAMPLE: example modpWalk; shows an example 40 " 41 { 42 option(redSB); 43 int k,nvar@r; 44 def R0 = basering; 45 string ordstr_R0 = ordstr(R0); 46 list rl = ringlist(R0); 47 int sizerl = size(rl); 48 int neg = 1 - attrib(R0,"global"); 49 if(typeof(II) == "ideal") 50 { 51 ideal I = II; 27 LIB "modular.lib"; 28 29 proc modWalk(ideal I, list #) 30 "USAGE: modWalk(I, [, v, w]); I ideal, v intvec, w intvec 31 RETURN: a standard basis of I 32 NOTE: The procedure computes a standard basis of I (over the rational 33 numbers) by using modular methods. 34 SEE ALSO: modular 35 EXAMPLE: example modWalk; shows an example" 36 { 37 /* read optional parameter */ 38 if (size(#) > 0) { 39 if (size(#) == 1) { 40 intvec w = #[1]; 41 } 42 if (size(#) == 2) { 43 intvec v = #[1]; 44 intvec w = #[2]; 45 } 46 if (size(#) > 2 || typeof(#[1]) != "intvec") { 47 ERROR("wrong optional parameter"); 48 } 49 } 50 51 /* save options */ 52 intvec opt = option(get); 53 option(redSB); 54 55 /* set additional parameters */ 56 int reduction = 1; 57 int printout = 0; 58 59 /* call modular() */ 60 if (size(#) > 0) { 61 I = modular("gwalk", list(I,reduction,printout,#)); 62 } 63 else { 64 I = modular("gwalk", list(I,reduction,printout)); 65 } 66 67 /* return the result */ 68 attrib(I, "isSB", 1); 69 option(set, opt); 70 return(I); 71 } 72 example 73 { 74 "EXAMPLE:"; 75 echo = 2; 76 ring R1 = 0, (x,y,z,t), dp; 77 ideal I = 3x3+x2+1, 11y5+y3+2, 5z4+z2+4; 78 I = std(I); 79 ring R2 = 0, (x,y,z,t), lp; 80 ideal I = fetch(R1, I); 81 ideal J = modWalk(I); 82 J; 83 } 84 85 proc modrWalk(ideal I, int radius, int pertdeg, list #) 86 "USAGE: modrWalk(I, radius, pertdeg[, v, w]); 87 I ideal, radius int, pertdeg int, v intvec, w intvec 88 RETURN: a standard basis of I 89 NOTE: The procedure computes a standard basis of I (over the rational 90 numbers) by using modular methods. 91 SEE ALSO: modular 92 EXAMPLE: example modrWalk; shows an example" 93 { 94 /* read optional parameter */ 95 if (size(#) > 0) { 96 if (size(#) == 1) { 97 intvec w = #[1]; 98 } 99 if (size(#) == 2) { 100 intvec v = #[1]; 101 intvec w = #[2]; 102 } 103 if (size(#) > 2 || typeof(#[1]) != "intvec") { 104 ERROR("wrong optional parameter"); 105 } 106 } 107 108 /* save options */ 109 intvec opt = option(get); 110 option(redSB); 111 112 /* set additional parameters */ 113 int reduction = 1; 114 int printout = 0; 115 116 /* call modular() */ 117 if (size(#) > 0) { 118 I = modular("rwalk", list(I,radius,pertdeg,reduction,printout,#)); 119 } 120 else { 121 I = modular("rwalk", list(I,radius,pertdeg,reduction,printout)); 122 } 123 124 /* return the result */ 125 attrib(I, "isSB", 1); 126 option(set, opt); 127 return(I); 128 } 129 example 130 { 131 "EXAMPLE:"; 132 echo = 2; 133 ring R1 = 0, (x,y,z,t), dp; 134 ideal I = 3x3+x2+1, 11y5+y3+2, 5z4+z2+4; 135 I = std(I); 136 ring R2 = 0, (x,y,z,t), lp; 137 ideal I = fetch(R1, I); 52 138 int radius = 2; 53 int pert_deg = 2; 54 } 55 if(typeof(II) == "list" && typeof(II[1]) == "ideal") 56 { 57 ideal I = II[1]; 58 if(size(II) == 2) 59 { 60 int radius = II[2]; 61 int pert_deg = 2; 62 } 63 if(size(II) == 3) 64 { 65 int radius = II[2]; 66 int pert_deg = II[3]; 67 } 68 } 69 rl[1] = p; 70 int h = homog(I); 71 def @r = ring(rl); 72 setring @r; 73 ideal i = fetch(R0,I); 74 string order; 75 if(system("nblocks") <= 2) 76 { 77 if(find(ordstr_R0, "M") + find(ordstr_R0, "lp") + find(ordstr_R0, "rp") <= 0) 78 { 79 order = "simple"; 80 } 81 } 82 83 //------------------------- make i homogeneous ----------------------------- 84 if(!mixedTest() && !h) 85 { 86 if(!((find(ordstr_R0, "M") > 0) || (find(ordstr_R0, "a") > 0) || neg)) 87 { 88 if(!((order == "simple") || (sizerl > 4))) 89 { 90 list rl@r = ringlist(@r); 91 nvar@r = nvars(@r); 92 intvec w; 93 for(k = 1; k <= nvar@r; k++) 94 { 95 w[k] = deg(var(k)); 96 } 97 w[nvar@r + 1] = 1; 98 rl@r[2][nvar@r + 1] = "homvar"; 99 rl@r[3][2][2] = w; 100 def HomR = ring(rl@r); 101 setring HomR; 102 ideal i = imap(@r, i); 103 i = homog(i, homvar); 104 } 105 } 106 } 107 108 //------------------------- compute a standard basis mod p ----------------------------- 109 110 if(variant == 1) 111 { 112 if(size(#)>0) 113 { 114 i = rwalk(i,radius,pert_deg,#); 115 // rwalk(i,radius,pert_deg,#); std(i); 116 } 117 else 118 { 119 i = rwalk(i,radius,pert_deg); 120 } 121 } 122 if(variant == 2) 123 { 124 if(size(#) == 2) 125 { 126 i = gwalk(i,#); 127 } 128 else 129 { 130 i = gwalk(i); 131 } 132 } 133 if(variant == 3) 134 { 135 if(size(#) == 2) 136 { 137 i = frandwalk(i,radius,#); 138 } 139 else 140 { 141 i = frandwalk(i,radius); 142 } 143 } 144 if(variant == 4) 145 { 146 if(size(#) == 2) 147 { 148 i=fwalk(i,#); 149 } 150 else 151 { 152 i=fwalk(i); 153 } 154 } 155 if(variant == 5) 156 { 157 if(size(#) == 2) 158 { 159 i=prwalk(i,radius,pert_deg,pert_deg,#); 160 } 161 else 162 { 163 i=prwalk(i,radius,pert_deg,pert_deg); 164 } 165 } 166 if(variant == 6) 167 { 168 if(size(#) == 2) 169 { 170 i=pwalk(i,pert_deg,pert_deg,#); 171 } 172 else 173 { 174 i=pwalk(i,pert_deg,pert_deg); 175 } 176 } 177 178 if(!mixedTest() && !h) 179 { 180 if(!((find(ordstr_R0, "M") > 0) || (find(ordstr_R0, "a") > 0) || neg)) 181 { 182 if(!((order == "simple") || (sizerl > 4))) 183 { 184 i = subst(i, homvar, 1); 185 i = simplify(i, 34); 186 setring @r; 187 i = imap(HomR, i); 188 i = interred(i); 189 kill HomR; 190 } 191 } 192 } 193 setring R0; 194 return(list(fetch(@r,i),p)); 195 } 196 example 197 { 198 "EXAMPLE:"; echo = 2; 199 option(redSB); 200 201 int p = 181; 202 intvec a = 2,1,3,4; 203 intvec b = 1,9,1,1; 204 ring ra = 0,x(1..4),(a(a),lp); 205 ideal I = std(cyclic(4)); 206 ring rb = 0,x(1..4),(a(b),lp); 207 ideal I = imap(ra,I); 208 modpWalk(I,p,1,a,b); 209 std(I); 210 } 211 212 //////////////////////////////////////////////////////////////////////////////// 213 214 proc modWalk(def II, int variant, list #) 215 "USAGE: modWalk(II); II ideal or list(ideal,int) 216 ASSUME: If variant = 217 @* - 1 the Random Walk algorithm with radius II[2] is applied 218 to II[1] if II = list(ideal, int). It is applied to II with radius 2 219 if II is an ideal. 220 @* - 2, the Groebner Walk algorithm is applied to II[1] or to II, respectively. 221 @* - 3, the Fractal Walk algorithm with random element is applied to II[1] or II, 222 respectively. 223 @* - 4, the Fractal Walk algorithm is applied to II[1] or II, respectively. 224 @* - 5, the Perturbation Walk algorithm with random element is applied to II[1] 225 or II, respectively, with radius II[3] and perturbation degree II[2]. 226 @* - 6, the Perturbation Walk algorithm is applied to II[1] or II, respectively, 227 with perturbation degree II[3]. 228 If size(#) > 0, then # contains either 1, 2 or 4 integers such that 229 @* - #[1] is the number of available processors for the computation, 230 @* - #[2] is an optional parameter for the exactness of the computation, 231 if #[2] = 1, the procedure computes a standard basis for sure, 232 @* - #[3] is the number of primes until the first lifting, 233 @* - #[4] is the constant number of primes between two liftings until 234 the computation stops. 235 RETURN: a standard basis of I if no warning appears. 236 NOTE: The procedure converts a standard basis of I (over the rational 237 numbers) from the ordering \"a(v),lp\", "dp\" or \"Dp\" to the ordering 238 \"(a(w),lp\" or \"a(1,0,...,0),lp\" by using modular methods. 239 By default the procedure computes a standard basis of I for sure, but 240 if the optional parameter #[2] = 0, it computes a standard basis of I 241 with high probability. 242 EXAMPLE: example modWalk; shows an example 243 " 244 { 245 int TT = timer; 246 int RT = rtimer; 247 int i,j,pTest,sizeTest,weighted,n1; 248 bigint N; 249 250 def R0 = basering; 251 list rl = ringlist(R0); 252 if((npars(R0) > 0) || (rl[1] > 0)) 253 { 254 ERROR("Characteristic of basering should be zero, basering should have no parameters."); 255 } 256 257 if(typeof(II) == "ideal") 258 { 259 ideal I = II; 260 kill II; 261 list II; 262 II[1] = I; 263 II[2] = 2; 264 II[3] = 2; 265 } 266 else 267 { 268 if(typeof(II) == "list" && typeof(II[1]) == "ideal") 269 { 270 ideal I = II[1]; 271 if(size(II) == 1) 272 { 273 II[2] = 2; 274 II[3] = 2; 275 } 276 if(size(II) == 2) 277 { 278 II[3] = 2; 279 } 280 281 } 282 else 283 { 284 ERROR("Unexpected type of input."); 285 } 286 } 287 288 //-------------------- Initialize optional parameters ------------------------ 289 n1 = system("--cpus"); 290 if(size(#) == 0) 291 { 292 int exactness = 1; 293 int n2 = 10; 294 int n3 = 10; 295 } 296 else 297 { 298 if(size(#) == 1) 299 { 300 if(typeof(#[1]) == "int") 301 { 302 if(#[1] < n1) 303 { 304 n1 = #[1]; 305 } 306 int exactness = 1; 307 if(n1 >= 10) 308 { 309 int n2 = n1 + 1; 310 int n3 = n1; 311 } 312 else 313 { 314 int n2 = 10; 315 int n3 = 10; 316 } 317 } 318 else 319 { 320 ERROR("Unexpected type of input."); 321 } 322 } 323 if(size(#) == 2) 324 { 325 if(typeof(#[1]) == "int" && typeof(#[2]) == "int") 326 { 327 if(#[1] < n1) 328 { 329 n1 = #[1]; 330 } 331 int exactness = #[2]; 332 if(n1 >= 10) 333 { 334 int n2 = n1 + 1; 335 int n3 = n1; 336 } 337 else 338 { 339 int n2 = 10; 340 int n3 = 10; 341 } 342 } 343 else 344 { 345 if(typeof(#[1]) == "intvec" && typeof(#[2]) == "intvec") 346 { 347 intvec curr_weight = #[1]; 348 intvec target_weight = #[2]; 349 weighted = 1; 350 int n2 = 10; 351 int n3 = 10; 352 int exactness = 1; 353 } 354 else 355 { 356 ERROR("Unexpected type of input."); 357 } 358 } 359 } 360 if(size(#) == 3) 361 { 362 if(typeof(#[1]) == "intvec" && typeof(#[2]) == "intvec" && typeof(#[3]) == "int") 363 { 364 intvec curr_weight = #[1]; 365 intvec target_weight = #[2]; 366 weighted = 1; 367 n1 = #[3]; 368 int n2 = 10; 369 int n3 = 10; 370 int exactness = 1; 371 } 372 else 373 { 374 ERROR("Unexpected type of input."); 375 } 376 } 377 if(size(#) == 4) 378 { 379 if(typeof(#[1]) == "intvec" && typeof(#[2]) == "intvec" && typeof(#[3]) == "int" 380 && typeof(#[4]) == "int") 381 { 382 intvec curr_weight = #[1]; 383 intvec target_weight = #[2]; 384 weighted = 1; 385 if(#[1] < n1) 386 { 387 n1 = #[3]; 388 } 389 int exactness = #[4]; 390 if(n1 >= 10) 391 { 392 int n2 = n1 + 1; 393 int n3 = n1; 394 } 395 else 396 { 397 int n2 = 10; 398 int n3 = 10; 399 } 400 } 401 else 402 { 403 if(typeof(#[1]) == "int" && typeof(#[2]) == "int" && typeof(#[3]) == "int" && typeof(#[4]) == "int") 404 { 405 if(#[1] < n1) 406 { 407 n1 = #[1]; 408 } 409 int exactness = #[2]; 410 if(n1 >= #[3]) 411 { 412 int n2 = n1 + 1; 413 } 414 else 415 { 416 int n2 = #[3]; 417 } 418 if(n1 >= #[4]) 419 { 420 int n3 = n1; 421 } 422 else 423 { 424 int n3 = #[4]; 425 } 426 } 427 else 428 { 429 ERROR("Unexpected type of input."); 430 } 431 } 432 } 433 if(size(#) == 6) 434 { 435 if(typeof(#[1]) == "intvec" && typeof(#[2]) == "intvec" && typeof(#[3]) == "int" && typeof(#[4]) == "int" && typeof(#[5]) == "int" && typeof(#[6]) == "int") 436 { 437 intvec curr_weight = #[1]; 438 intvec target_weight = #[2]; 439 weighted = 1; 440 if(#[3] < n1) 441 { 442 n1 = #[3]; 443 } 444 int exactness = #[4]; 445 if(n1 >= #[5]) 446 { 447 int n2 = n1 + 1; 448 } 449 else 450 { 451 int n2 = #[5]; 452 } 453 if(n1 >= #[6]) 454 { 455 int n3 = n1; 456 } 457 else 458 { 459 int n3 = #[6]; 460 } 461 } 462 else 463 { 464 ERROR("Expected list(intvec,intvec,int,int,int,int) as optional parameter list."); 465 } 466 } 467 if(size(#) == 1 || size(#) == 5 || size(#) > 6) 468 { 469 ERROR("Expected 0,2,3,4 or 5 optional arguments."); 470 } 471 } 472 if(printlevel >= 10) 473 { 474 "n1 = "+string(n1)+", n2 = "+string(n2)+", n3 = "+string(n3)+", exactness = "+string(exactness); 475 } 476 477 //------------------------- Save current options ----------------------------- 478 intvec opt = option(get); 479 //option(redSB); 480 481 //-------------------- Initialize the list of primes ------------------------- 482 int tt = timer; 483 int rt = rtimer; 484 int en = 2134567879; 485 int an = 1000000000; 486 intvec L = primeList(I,n2); 487 if(n2 > 4) 488 { 489 // L[5] = prime(random(an,en)); 490 } 491 if(printlevel >= 10) 492 { 493 "CPU-time for primeList: "+string(timer-tt)+" seconds."; 494 "Real-time for primeList: "+string(rtimer-rt)+" seconds."; 495 } 496 int h = homog(I); 497 list P,T1,T2,LL,Arguments,PP; 498 ideal J,K,H; 499 500 //------------------- parallelized Groebner Walk in positive characteristic -------------------- 501 502 if(weighted) 503 { 504 for(i=1; i<=size(L); i++) 505 { 506 Arguments[i] = list(II,L[i],variant,list(curr_weight,target_weight)); 507 } 508 } 509 else 510 { 511 for(i=1; i<=size(L); i++) 512 { 513 Arguments[i] = list(II,L[i],variant); 514 } 515 } 516 P = parallelWaitAll("modpWalk",Arguments); 517 for(i=1; i<=size(P); i++) 518 { 519 T1[i] = P[i][1]; 520 T2[i] = bigint(P[i][2]); 521 } 522 523 while(1) 524 { 525 LL = deleteUnluckyPrimes(T1,T2,h); 526 T1 = LL[1]; 527 T2 = LL[2]; 528 //------------------- Now all leading ideals are the same -------------------- 529 //------------------- Lift results to basering via farey --------------------- 530 531 tt = timer; rt = rtimer; 532 N = T2[1]; 533 for(i=2; i<=size(T2); i++) 534 { 535 N = N*T2[i]; 536 } 537 H = chinrem(T1,T2); 538 J = parallelFarey(H,N,n1); 539 //J=farey(H,N); 540 if(printlevel >= 10) 541 { 542 "CPU-time for lifting-process is "+string(timer - tt)+" seconds."; 543 "Real-time for lifting-process is "+string(rtimer - rt)+" seconds."; 544 } 545 546 //---------------- Test if we already have a standard basis of I -------------- 547 548 tt = timer; rt = rtimer; 549 pTest = pTestSB(I,J,L,variant); 550 //pTest = primeTestSB(I,J,L,variant); 551 if(printlevel >= 10) 552 { 553 "CPU-time for pTest is "+string(timer - tt)+" seconds."; 554 "Real-time for pTest is "+string(rtimer - rt)+" seconds."; 555 } 556 if(pTest) 557 { 558 if(printlevel >= 10) 559 { 560 "CPU-time for computation without final tests is "+string(timer - TT)+" seconds."; 561 "Real-time for computation without final tests is "+string(rtimer - RT)+" seconds."; 562 } 563 attrib(J,"isSB",1); 564 if(exactness == 0) 565 { 566 option(set, opt); 567 return(J); 568 } 569 else 570 { 571 tt = timer; 572 rt = rtimer; 573 sizeTest = 1 - isIdealIncluded(I,J,n1); 574 if(printlevel >= 10) 575 { 576 "CPU-time for checking if I subset <G> is "+string(timer - tt)+" seconds."; 577 "Real-time for checking if I subset <G> is "+string(rtimer - rt)+" seconds."; 578 } 579 if(sizeTest == 0) 580 { 581 tt = timer; 582 rt = rtimer; 583 K = std(J); 584 if(printlevel >= 10) 585 { 586 "CPU-time for last std-computation is "+string(timer - tt)+" seconds."; 587 "Real-time for last std-computation is "+string(rtimer - rt)+" seconds."; 588 } 589 if(size(reduce(K,J)) == 0) 590 { 591 option(set, opt); 592 return(J); 593 } 594 } 595 } 596 } 597 //-------------- We do not already have a standard basis of I, therefore do the main computation for more primes -------------- 598 599 T1 = H; 600 T2 = N; 601 j = size(L)+1; 602 tt = timer; rt = rtimer; 603 L = primeList(I,n3,L,n1); 604 if(printlevel >= 10) 605 { 606 "CPU-time for primeList: "+string(timer-tt)+" seconds."; 607 "Real-time for primeList: "+string(rtimer-rt)+" seconds."; 608 } 609 Arguments = list(); 610 PP = list(); 611 if(weighted) 612 { 613 for(i=j; i<=size(L); i++) 614 { 615 //Arguments[i-j+1] = list(II,L[i],variant,list(curr_weight,target_weight)); 616 Arguments[size(Arguments)+1] = list(II,L[i],variant,list(curr_weight,target_weight)); 617 } 618 } 619 else 620 { 621 for(i=j; i<=size(L); i++) 622 { 623 //Arguments[i-j+1] = list(II,L[i],variant); 624 Arguments[size(Arguments)+1] = list(II,L[i],variant); 625 } 626 } 627 PP = parallelWaitAll("modpWalk",Arguments); 628 if(printlevel >= 10) 629 { 630 "parallel modpWalk"; 631 } 632 for(i=1; i<=size(PP); i++) 633 { 634 //P[size(P) + 1] = PP[i]; 635 T1[size(T1) + 1] = PP[i][1]; 636 T2[size(T2) + 1] = bigint(PP[i][2]); 637 } 638 } 639 if(printlevel >= 10) 640 { 641 "CPU-time for computation with final tests is "+string(timer - TT)+" seconds."; 642 "Real-time for computation with final tests is "+string(rtimer - RT)+" seconds."; 643 } 644 } 645 646 example 647 { 648 "EXAMPLE:"; 649 echo = 2; 650 ring R=0,(x,y,z),lp; 651 ideal I=-x+y2z-z,xz+1,x2+y2-1; 652 // I is a standard basis in dp 653 ideal J = modWalk(I,1); 654 J; 655 } 656 657 //////////////////////////////////////////////////////////////////////////////// 658 static proc isIdealIncluded(ideal I, ideal J, int n1) 659 "USAGE: isIdealIncluded(I,J,int n1); I ideal, J ideal, n1 integer 660 " 661 { 662 if(n1 > 1) 663 { 664 int k; 665 list args,results; 666 for(k=1; k<=size(I); k++) 667 { 668 args[k] = list(ideal(I[k]),J,1); 669 } 670 results = parallelWaitAll("reduce",args); 671 for(k=1; k<=size(results); k++) 672 { 673 if(results[k] == 0) 674 { 675 return(1); 676 } 677 } 678 return(0); 679 } 680 else 681 { 682 if(reduce(I,J,1) == 0) 683 { 684 return(1); 685 } 686 else 687 { 688 return(0); 689 } 690 } 691 } 692 693 //////////////////////////////////////////////////////////////////////////////// 694 static proc parallelChinrem(list T1, list T2, int n1) 695 "USAGE: parallelChinrem(T1,T2); T1 list of ideals, T2 list of primes, n1 integer" 696 { 697 int i,j,k; 698 699 ideal H,J; 700 701 list arguments_chinrem,results_chinrem; 702 for(i=1; i<=size(T1); i++) 703 { 704 J = ideal(T1[i]); 705 attrib(J,"isSB",1); 706 arguments_chinrem[size(arguments_chinrem)+1] = list(list(J),T2); 707 } 708 results_chinrem = parallelWaitAll("chinrem",arguments_chinrem); 709 for(j=1; j <= size(results_chinrem); j++) 710 { 711 J = results_chinrem[j]; 712 attrib(J,"isSB",1); 713 if(isIdealIncluded(J,H,n1) == 0) 714 { 715 if(H == 0) 716 { 717 H = J; 718 } 719 else 720 { 721 H = H,J; 722 } 723 } 724 } 725 return(H); 726 } 727 728 //////////////////////////////////////////////////////////////////////////////// 729 static proc parallelFarey(ideal H, bigint N, int n1) 730 "USAGE: parallelFarey(H,N,n1); H ideal, N bigint, n1 integer 731 " 732 { 733 int i,j; 734 int ii = 1; 735 list arguments_farey,results_farey; 736 for(i=1; i<=size(H); i++) 737 { 738 for(j=1; j<=size(H[i]); j++) 739 { 740 arguments_farey[size(arguments_farey)+1] = list(H[i][j],N); 741 } 742 } 743 results_farey = parallelWaitAll("farey",arguments_farey); 744 ideal J,K; 745 poly f_farey; 746 while(ii<=size(results_farey)) 747 { 748 for(i=1; i<=size(H); i++) 749 { 750 f_farey = 0; 751 for(j=1; j<=size(H[i]); j++) 752 { 753 f_farey = f_farey + results_farey[ii][1]; 754 ii++; 755 } 756 K = ideal(f_farey); 757 attrib(K,"isSB",1); 758 attrib(J,"isSB",1); 759 if(isIdealIncluded(K,J,n1) == 0) 760 { 761 if(J == 0) 762 { 763 J = K; 764 } 765 else 766 { 767 J = J,K; 768 } 769 } 770 } 771 } 772 return(J); 773 } 774 ////////////////////////////////////////////////////////////////////////////////// 775 static proc primeTestSB(def II, ideal J, list L, int variant, list #) 776 "USAGE: primeTestSB(I,J,L,variant,#); I,J ideals, L intvec of primes, variant int 777 RETURN: 1 (resp. 0) if for a randomly chosen prime p that is not in L 778 J mod p is (resp. is not) a standard basis of I mod p 779 EXAMPLE: example primeTestSB; shows an example 780 " 781 { 782 if(typeof(II) == "ideal") 783 { 784 ideal I = II; 785 int radius = 2; 786 } 787 if(typeof(II) == "list") 788 { 789 ideal I = II[1]; 790 int radius = II[2]; 791 } 792 793 int i,j,k,p; 794 def R = basering; 795 list r = ringlist(R); 796 797 while(!j) 798 { 799 j = 1; 800 p = prime(random(1000000000,2134567879)); 801 for(i = 1; i <= size(L); i++) 802 { 803 if(p == L[i]) 804 { 805 j = 0; 806 break; 807 } 808 } 809 if(j) 810 { 811 for(i = 1; i <= ncols(I); i++) 812 { 813 for(k = 2; k <= size(I[i]); k++) 814 { 815 if((denominator(leadcoef(I[i][k])) mod p) == 0) 816 { 817 j = 0; 818 break; 819 } 820 } 821 if(!j) 822 { 823 break; 824 } 825 } 826 } 827 if(j) 828 { 829 if(!primeTest(I,p)) 830 { 831 j = 0; 832 } 833 } 834 } 835 r[1] = p; 836 def @R = ring(r); 837 setring @R; 838 ideal I = imap(R,I); 839 ideal J = imap(R,J); 840 attrib(J,"isSB",1); 841 842 int t = timer; 843 j = 1; 844 if(isIncluded(I,J) == 0) 845 { 846 j = 0; 847 } 848 if(printlevel >= 11) 849 { 850 "isIncluded(I,J) takes "+string(timer - t)+" seconds"; 851 "j = "+string(j); 852 } 853 t = timer; 854 if(j) 855 { 856 if(size(#) > 0) 857 { 858 ideal K = modpWalk(I,p,variant,#)[1]; 859 } 860 else 861 { 862 ideal K = modpWalk(I,p,variant)[1]; 863 } 864 t = timer; 865 if(isIncluded(J,K) == 0) 866 { 867 j = 0; 868 } 869 if(printlevel >= 11) 870 { 871 "isIncluded(K,J) takes "+string(timer - t)+" seconds"; 872 "j = "+string(j); 873 } 874 } 875 setring R; 876 877 return(j); 878 } 879 example 880 { "EXAMPLE:"; echo = 2; 881 intvec L = 2,3,5; 882 ring r = 0,(x,y,z),lp; 883 ideal I = x+1,x+y+1; 884 ideal J = x+1,y; 885 primeTestSB(I,I,L,1); 886 primeTestSB(I,J,L,1); 887 } 888 889 //////////////////////////////////////////////////////////////////////////////// 890 static proc pTestSB(ideal I, ideal J, list L, int variant, list #) 891 "USAGE: pTestSB(I,J,L,variant,#); I,J ideals, L intvec of primes, variant int 892 RETURN: 1 (resp. 0) if for a randomly chosen prime p that is not in L 893 J mod p is (resp. is not) a standard basis of I mod p 894 EXAMPLE: example pTestSB; shows an example 895 " 896 { 897 int i,j,k,p; 898 def R = basering; 899 list r = ringlist(R); 900 901 while(!j) 902 { 903 j = 1; 904 p = prime(random(1000000000,2134567879)); 905 for(i = 1; i <= size(L); i++) 906 { 907 if(p == L[i]) { j = 0; break; } 908 } 909 if(j) 910 { 911 for(i = 1; i <= ncols(I); i++) 912 { 913 for(k = 2; k <= size(I[i]); k++) 914 { 915 if((denominator(leadcoef(I[i][k])) mod p) == 0) { j = 0; break; } 916 } 917 if(!j){ break; } 918 } 919 } 920 if(j) 921 { 922 if(!primeTest(I,p)) { j = 0; } 923 } 924 } 925 r[1] = p; 926 def @R = ring(r); 927 setring @R; 928 ideal I = imap(R,I); 929 ideal J = imap(R,J); 930 attrib(J,"isSB",1); 931 932 int t = timer; 933 j = 1; 934 if(isIncluded(I,J) == 0) { j = 0; } 935 936 if(printlevel >= 11) 937 { 938 "isIncluded(I,J) takes "+string(timer - t)+" seconds"; 939 "j = "+string(j); 940 } 941 942 t = timer; 943 if(j) 944 { 945 if(size(#) > 0) 946 { 947 ideal K = modpStd(I,p,variant,#[1])[1]; 948 } 949 else 950 { 951 ideal K = groebner(I); 952 } 953 t = timer; 954 if(isIncluded(J,K) == 0) { j = 0; } 955 956 if(printlevel >= 11) 957 { 958 "isIncluded(J,K) takes "+string(timer - t)+" seconds"; 959 "j = "+string(j); 960 } 961 } 962 setring R; 963 return(j); 964 } 965 example 966 { "EXAMPLE:"; echo = 2; 967 intvec L = 2,3,5; 968 ring r = 0,(x,y,z),dp; 969 ideal I = x+1,x+y+1; 970 ideal J = x+1,y; 971 pTestSB(I,I,L,2); 972 pTestSB(I,J,L,2); 973 } 974 //////////////////////////////////////////////////////////////////////////////// 975 static proc mixedTest() 976 "USAGE: mixedTest(); 977 RETURN: 1 if ordering of basering is mixed, 0 else 978 EXAMPLE: example mixedTest(); shows an example 979 " 980 { 981 int i,p,m; 982 for(i = 1; i <= nvars(basering); i++) 983 { 984 if(var(i) > 1) 985 { 986 p++; 987 } 988 else 989 { 990 m++; 991 } 992 } 993 if((p > 0) && (m > 0)) { return(1); } 994 return(0); 995 } 996 example 997 { "EXAMPLE:"; echo = 2; 998 ring R1 = 0,(x,y,z),dp; 999 mixedTest(); 1000 ring R2 = 31,(x(1..4),y(1..3)),(ds(4),lp(3)); 1001 mixedTest(); 1002 ring R3 = 181,x(1..9),(dp(5),lp(4)); 1003 mixedTest(); 1004 } 139 int pertdeg = 3; 140 ideal J = modrWalk(I,radius,pertdeg); 141 J; 142 } 143 144 proc modfWalk(ideal I, list #) 145 "USAGE: modfWalk(I, [, v, w]); I ideal, v intvec, w intvec 146 RETURN: a standard basis of I 147 NOTE: The procedure computes a standard basis of I (over the rational 148 numbers) by using modular methods. 149 SEE ALSO: modular 150 EXAMPLE: example modfWalk; shows an example" 151 { 152 /* read optional parameter */ 153 if (size(#) > 0) { 154 if (size(#) == 1) { 155 intvec w = #[1]; 156 } 157 if (size(#) == 2) { 158 intvec v = #[1]; 159 intvec w = #[2]; 160 } 161 if (size(#) > 2 || typeof(#[1]) != "intvec") { 162 ERROR("wrong optional parameter"); 163 } 164 } 165 166 /* save options */ 167 intvec opt = option(get); 168 option(redSB); 169 170 /* set additional parameters */ 171 int reduction = 1; 172 int printout = 0; 173 174 /* call modular() */ 175 if (size(#) > 0) { 176 I = modular("fwalk", list(I,reduction,printout,#)); 177 } 178 else { 179 I = modular("fwalk", list(I,reduction,printout)); 180 } 181 182 /* return the result */ 183 attrib(I, "isSB", 1); 184 option(set, opt); 185 return(I); 186 } 187 example 188 { 189 "EXAMPLE:"; 190 echo = 2; 191 ring R1 = 0, (x,y,z,t), dp; 192 ideal I = 3x3+x2+1, 11y5+y3+2, 5z4+z2+4; 193 I = std(I); 194 ring R2 = 0, (x,y,z,t), lp; 195 ideal I = fetch(R1, I); 196 ideal J = modfWalk(I); 197 J; 198 } 199 200 proc modfrWalk(ideal I, int radius, list #) 201 "USAGE: modfrWalk(I, radius [, v, w]); I ideal, radius int, v intvec, w intvec 202 RETURN: a standard basis of I 203 NOTE: The procedure computes a standard basis of I (over the rational 204 numbers) by using modular methods. 205 SEE ALSO: modular 206 EXAMPLE: example modfrWalk; shows an example" 207 { 208 /* read optional parameter */ 209 if (size(#) > 0) { 210 if (size(#) == 1) { 211 intvec w = #[1]; 212 } 213 if (size(#) == 2) { 214 intvec v = #[1]; 215 intvec w = #[2]; 216 } 217 if (size(#) > 2 || typeof(#[1]) != "intvec") { 218 ERROR("wrong optional parameter"); 219 } 220 } 221 222 /* save options */ 223 intvec opt = option(get); 224 option(redSB); 225 226 /* set additional parameters */ 227 int reduction = 1; 228 int printout = 0; 229 230 /* call modular() */ 231 if (size(#) > 0) { 232 I = modular("frandwalk", list(I,radius,reduction,printout,#)); 233 } 234 else { 235 I = modular("frandwalk", list(I,radius,reduction,printout)); 236 } 237 238 /* return the result */ 239 attrib(I, "isSB", 1); 240 option(set, opt); 241 return(I); 242 } 243 example 244 { 245 "EXAMPLE:"; 246 echo = 2; 247 ring R1 = 0, (x,y,z,t), dp; 248 ideal I = 3x3+x2+1, 11y5+y3+2, 5z4+z2+4; 249 I = std(I); 250 ring R2 = 0, (x,y,z,t), lp; 251 ideal I = fetch(R1, I); 252 int radius = 2; 253 ideal J = modfrWalk(I,radius); 254 J; 255 } -
Property
mode
changed from
-
Singular/LIB/multigrading.lib
r74fe358 r36b81ac 3276 3276 /******************************************************/ 3277 3277 proc multiDegBasis(intvec d) 3278 "USAGE: multi degreed3278 "USAGE: multiDegBasis(d), multidegree: intvec d 3279 3279 ASSUME: current ring is multigraded, monomial ordering is global 3280 3280 PURPOSE: compute all monomials of multidegree d -
Singular/LIB/primdec.lib
r74fe358 r36b81ac 7997 7997 7998 7998 ideal jkeep=@j; 7999 if( ordstr(@P)[1]=="w")7999 if((ordstr(@P)[1]=="w")&&(size(ringlist(@P)[3])==2)) // weighted ordering 8000 8000 { 8001 8001 def @Phelp=ring(ringlist(gnir)); -
Singular/LIB/rwalk.lib
-
Property
mode
changed from
100644
to100755
rcd38fbd r36b81ac 10 10 rwalk(ideal,int,int[,intvec,intvec]); standard basis of ideal via Random Walk algorithm 11 11 rwalk(ideal,int[,intvec,intvec]); standard basis of ideal via Random Perturbation Walk algorithm 12 fr walk(ideal,int[,intvec,intvec]); standard basis of ideal via Random Fractal Walk algorithm12 frandwalk(ideal,int[,intvec,intvec]); standard basis of ideal via Random Fractal Walk algorithm 13 13 "; 14 14 … … 141 141 * Random Walk * 142 142 ****************/ 143 proc rwalk(ideal Go, int radius, int pert_deg, list #)143 proc rwalk(ideal Go, int radius, int pert_deg, int reduction, int printout, list #) 144 144 "SYNTAX: rwalk(ideal i, int radius); 145 145 if size(#)>0 then rwalk(ideal i, int radius, intvec v, intvec w); 146 intermediate Groebner bases are not reduced if reduction = 0 146 147 TYPE: ideal 147 148 PURPOSE: compute the standard basis of the ideal, calculated via … … 178 179 179 180 ideal G = fetch(xR, Go); 180 G = system("Mrwalk", G, curr_weight, target_weight, radius, pert_deg, basering);181 G = system("Mrwalk", G, curr_weight, target_weight, radius, pert_deg, reduction, printout); 181 182 182 183 setring xR; … … 196 197 int radius = 1; 197 198 int perturb_deg = 2; 198 rwalk(I,radius,perturb_deg); 199 int reduction = 0; 200 int printout = 1; 201 rwalk(I,radius,perturb_deg,reduction,printout); 199 202 } 200 203 … … 202 205 * Perturbation Walk with random element * 203 206 *****************************************/ 204 proc prwalk(ideal Go, int radius, int o_pert_deg, int t_pert_deg, list #)207 proc prwalk(ideal Go, int radius, int o_pert_deg, int t_pert_deg, int reduction, int printout, list #) 205 208 "SYNTAX: rwalk(ideal i, int radius); 206 209 if size(#)>0 then rwalk(ideal i, int radius, intvec v, intvec w); … … 227 230 OSCTW= OrderStringalp_NP("al", #); 228 231 } 232 int nP = OSCTW[1]; 229 233 string ord_str = OSCTW[2]; 230 234 intvec curr_weight = OSCTW[3]; // original weight vector … … 238 242 239 243 ideal G = fetch(xR, Go); 240 G = system("Mprwalk", G, curr_weight, target_weight, radius, o_pert_deg, t_pert_deg, basering); 244 G = system("Mprwalk", G, curr_weight, target_weight, radius, o_pert_deg, t_pert_deg, 245 nP, reduction, printout); 241 246 242 247 setring xR; … … 257 262 int o_perturb_deg = 2; 258 263 int t_perturb_deg = 2; 259 prwalk(I,radius,o_perturb_deg,t_perturb_deg); 264 int reduction = 0; 265 int printout = 2; 266 prwalk(I,radius,o_perturb_deg,t_perturb_deg,reduction,printout); 260 267 } 261 268 … … 263 270 * Fractal Walk with random element * 264 271 ************************************/ 265 proc frandwalk(ideal Go, int radius, list #)266 "SYNTAX: frwalk(ideal i, int radius );267 frwalk(ideal i, int radius, int vec v, intvec w);272 proc frandwalk(ideal Go, int radius, int reduction, int printout, list #) 273 "SYNTAX: frwalk(ideal i, int radius, int reduction, int printout); 274 frwalk(ideal i, int radius, int reduction, int printout, intvec v, intvec w); 268 275 TYPE: ideal 269 276 PURPOSE: compute the standard basis of the ideal, calculated via … … 299 306 ideal G = fetch(xR, Go); 300 307 int pert_deg = 2; 301 G = system("Mfrwalk", G, curr_weight, target_weight, radius); 308 309 G = system("Mfrwalk", G, curr_weight, target_weight, radius, reduction, printout); 302 310 303 311 setring xR; … … 314 322 ring r = 0,(z,y,x), lp; 315 323 ideal I = y3+xyz+y2z+xz3, 3+xy+x2y+y2z; 316 frandwalk(I,2); 317 } 324 int reduction = 0; 325 frandwalk(I,2,0,1); 326 } -
Property
mode
changed from
-
Singular/LIB/swalk.lib
-
Property
mode
changed from
100644
to100755
-
Property
mode
changed from
-
Singular/extra.cc
rcd38fbd r36b81ac 1864 1864 if (strcmp(sys_cmd, "Mwalk") == 0) 1865 1865 { 1866 const short t[]={ 4,IDEAL_CMD,INTVEC_CMD,INTVEC_CMD,RING_CMD};1866 const short t[]={6,IDEAL_CMD,INTVEC_CMD,INTVEC_CMD,RING_CMD,INT_CMD,INT_CMD}; 1867 1867 if (!iiCheckTypes(h,t,1)) return TRUE; 1868 1868 if (((intvec*) h->next->Data())->length() != currRing->N && … … 1875 1875 ideal arg1 = (ideal) h->Data(); 1876 1876 intvec* arg2 = (intvec*) h->next->Data(); 1877 intvec* arg3 = (intvec*) h->next->next->Data(); 1878 ring arg4 = (ring) h->next->next->next->Data(); 1879 ideal result = (ideal) Mwalk(arg1, arg2, arg3,arg4); 1877 intvec* arg3 = (intvec*) h->next->next->Data(); 1878 ring arg4 = (ring) h->next->next->next->Data(); 1879 int arg5 = (int) (long) h->next->next->next->next->Data(); 1880 int arg6 = (int) (long) h->next->next->next->next->next->Data(); 1881 ideal result = (ideal) Mwalk(arg1, arg2, arg3, arg4, arg5, arg6); 1880 1882 res->rtyp = IDEAL_CMD; 1881 1883 res->data = result; … … 1913 1915 if (strcmp(sys_cmd, "Mpwalk") == 0) 1914 1916 { 1915 const short t[]={ 6,IDEAL_CMD,INT_CMD,INT_CMD,INTVEC_CMD,INTVEC_CMD,INT_CMD};1917 const short t[]={8,IDEAL_CMD,INT_CMD,INT_CMD,INTVEC_CMD,INTVEC_CMD,INT_CMD,INT_CMD,INT_CMD}; 1916 1918 if (!iiCheckTypes(h,t,1)) return TRUE; 1917 1919 if(((intvec*) h->next->next->next->Data())->length() != currRing->N && … … 1927 1929 intvec* arg5 = (intvec*) h->next->next->next->next->Data(); 1928 1930 int arg6 = (int) (long) h->next->next->next->next->next->Data(); 1929 ideal result = (ideal) Mpwalk(arg1, arg2, arg3, arg4, arg5,arg6); 1931 int arg7 = (int) (long) h->next->next->next->next->next->next->Data(); 1932 int arg8 = (int) (long) h->next->next->next->next->next->next->next->Data(); 1933 ideal result = (ideal) Mpwalk(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); 1930 1934 res->rtyp = IDEAL_CMD; 1931 1935 res->data = result; … … 1939 1943 if (strcmp(sys_cmd, "Mrwalk") == 0) 1940 1944 { 1941 const short t[]={ 6,IDEAL_CMD,INTVEC_CMD,INTVEC_CMD,INT_CMD,INT_CMD,RING_CMD};1945 const short t[]={7,IDEAL_CMD,INTVEC_CMD,INTVEC_CMD,INT_CMD,INT_CMD,INT_CMD,INT_CMD}; 1942 1946 if (!iiCheckTypes(h,t,1)) return TRUE; 1943 if((( (intvec*) h->next->Data())->length() != currRing->N &&1944 ((intvec*) h->next-> next->Data())->length() != currRing->N) &&1945 (( (intvec*) h->next->Data())->length() != (currRing->N)*(currRing->N)&&1946 ((intvec*) h->next->next->Data())->length() != (currRing->N)*(currRing->N) ) )1947 if(((intvec*) h->next->Data())->length() != currRing->N && 1948 ((intvec*) h->next->Data())->length() != (currRing->N)*(currRing->N) && 1949 ((intvec*) h->next->next->Data())->length() != currRing->N && 1950 ((intvec*) h->next->next->Data())->length() != (currRing->N)*(currRing->N) ) 1947 1951 { 1948 1952 Werror("system(\"Mrwalk\" ...) intvecs not of length %d or %d\n", … … 1955 1959 int arg4 = (int)(long) h->next->next->next->Data(); 1956 1960 int arg5 = (int)(long) h->next->next->next->next->Data(); 1957 ring arg6 = (ring) h->next->next->next->next->next->Data(); 1958 ideal result = (ideal) Mrwalk(arg1, arg2, arg3, arg4, arg5, arg6); 1961 int arg6 = (int)(long) h->next->next->next->next->next->Data(); 1962 int arg7 = (int)(long) h->next->next->next->next->next->next->Data(); 1963 ideal result = (ideal) Mrwalk(arg1, arg2, arg3, arg4, arg5, arg6, arg7); 1959 1964 res->rtyp = IDEAL_CMD; 1960 1965 res->data = result; … … 2018 2023 if (strcmp(sys_cmd, "Mfwalk") == 0) 2019 2024 { 2020 const short t[]={ 3,IDEAL_CMD,INTVEC_CMD,INTVEC_CMD};2025 const short t[]={5,IDEAL_CMD,INTVEC_CMD,INTVEC_CMD,INT_CMD,INT_CMD}; 2021 2026 if (!iiCheckTypes(h,t,1)) return TRUE; 2022 2027 if (((intvec*) h->next->Data())->length() != currRing->N && … … 2025 2030 Werror("system(\"Mfwalk\" ...) intvecs not of length %d\n", 2026 2031 currRing->N); 2027 return TRUE;2028 }2029 ideal arg1 = (ideal) h->Data();2030 intvec* arg2 = (intvec*) h->next->Data();2031 intvec* arg3 = (intvec*) h->next->next->Data();2032 ideal result = (ideal) Mfwalk(arg1, arg2, arg3);2033 res->rtyp = IDEAL_CMD;2034 res->data = result;2035 return FALSE;2036 }2037 else2038 #endif2039 /*==================== Mfrwalk =================*/2040 #ifdef HAVE_WALK2041 if (strcmp(sys_cmd, "Mfrwalk") == 0)2042 {2043 const short t[]={6,IDEAL_CMD,INTVEC_CMD,INTVEC_CMD,INT_CMD,INT_CMD,RING_CMD};2044 if (!iiCheckTypes(h,t,1)) return TRUE;2045 if (((intvec*) h->next->Data())->length() != currRing->N &&2046 ((intvec*) h->next->next->Data())->length() != currRing->N)2047 {2048 Werror("system(\"Mfrwalk\" ...) intvecs not of length %d\n",currRing->N);2049 2032 return TRUE; 2050 2033 } … … 2053 2036 intvec* arg3 = (intvec*) h->next->next->Data(); 2054 2037 int arg4 = (int)(long) h->next->next->next->Data(); 2055 ideal result = (ideal) Mfrwalk(arg1, arg2, arg3, arg4); 2038 int arg5 = (int)(long) h->next->next->next->next->Data(); 2039 ideal result = (ideal) Mfwalk(arg1, arg2, arg3, arg4, arg5); 2056 2040 res->rtyp = IDEAL_CMD; 2057 2041 res->data = result; … … 2059 2043 } 2060 2044 else 2045 #endif 2046 /*==================== Mfrwalk =================*/ 2047 #ifdef HAVE_WALK 2048 if (strcmp(sys_cmd, "Mfrwalk") == 0) 2049 { 2050 const short t[]={6,IDEAL_CMD,INTVEC_CMD,INTVEC_CMD,INT_CMD,INT_CMD,INT_CMD}; 2051 if (!iiCheckTypes(h,t,1)) return TRUE; 2052 /* 2053 if (((intvec*) h->next->Data())->length() != currRing->N && 2054 ((intvec*) h->next->next->Data())->length() != currRing->N) 2055 { 2056 Werror("system(\"Mfrwalk\" ...) intvecs not of length %d\n",currRing->N); 2057 return TRUE; 2058 } 2059 */ 2060 if((((intvec*) h->next->Data())->length() != currRing->N && 2061 ((intvec*) h->next->next->Data())->length() != currRing->N ) && 2062 (((intvec*) h->next->Data())->length() != (currRing->N)*(currRing->N) && 2063 ((intvec*) h->next->next->Data())->length() != (currRing->N)*(currRing->N) )) 2064 { 2065 Werror("system(\"Mfrwalk\" ...) intvecs not of length %d or %d\n", 2066 currRing->N,(currRing->N)*(currRing->N)); 2067 return TRUE; 2068 } 2069 2070 ideal arg1 = (ideal) h->Data(); 2071 intvec* arg2 = (intvec*) h->next->Data(); 2072 intvec* arg3 = (intvec*) h->next->next->Data(); 2073 int arg4 = (int)(long) h->next->next->next->Data(); 2074 int arg5 = (int)(long) h->next->next->next->next->Data(); 2075 int arg6 = (int)(long) h->next->next->next->next->next->Data(); 2076 ideal result = (ideal) Mfrwalk(arg1, arg2, arg3, arg4, arg5, arg6); 2077 res->rtyp = IDEAL_CMD; 2078 res->data = result; 2079 return FALSE; 2080 } 2081 else 2061 2082 /*==================== Mprwalk =================*/ 2062 2083 if (strcmp(sys_cmd, "Mprwalk") == 0) 2063 2084 { 2064 const short t[]={ 7,IDEAL_CMD,INTVEC_CMD,INTVEC_CMD,INT_CMD,INT_CMD,INT_CMD,RING_CMD};2085 const short t[]={9,IDEAL_CMD,INTVEC_CMD,INTVEC_CMD,INT_CMD,INT_CMD,INT_CMD,INT_CMD,INT_CMD,INT_CMD}; 2065 2086 if (!iiCheckTypes(h,t,1)) return TRUE; 2066 if (((intvec*) h->next->Data())->length() != currRing->N && 2067 ((intvec*) h->next->next->Data())->length() != currRing->N ) 2068 { 2069 Werror("system(\"Mrwalk\" ...) intvecs not of length %d\n", 2070 currRing->N); 2087 if((((intvec*) h->next->Data())->length() != currRing->N && 2088 ((intvec*) h->next->next->Data())->length() != currRing->N ) && 2089 (((intvec*) h->next->Data())->length() != (currRing->N)*(currRing->N) && 2090 ((intvec*) h->next->next->Data())->length() != (currRing->N)*(currRing->N) )) 2091 { 2092 Werror("system(\"Mrwalk\" ...) intvecs not of length %d or %d\n", 2093 currRing->N,(currRing->N)*(currRing->N)); 2071 2094 return TRUE; 2072 2095 } … … 2077 2100 int arg5 = (int)(long) h->next->next->next->next->Data(); 2078 2101 int arg6 = (int)(long) h->next->next->next->next->next->Data(); 2079 ring arg7 = (ring) h->next->next->next->next->next->next->Data(); 2080 ideal result = (ideal) Mprwalk(arg1, arg2, arg3, arg4, arg5, arg6, arg7); 2102 int arg7 = (int)(long) h->next->next->next->next->next->next->Data(); 2103 int arg8 = (int)(long) h->next->next->next->next->next->next->next->Data(); 2104 int arg9 = (int)(long) h->next->next->next->next->next->next->next->next->Data(); 2105 ideal result = (ideal) Mprwalk(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); 2081 2106 res->rtyp = IDEAL_CMD; 2082 2107 res->data = result; -
Singular/iparith.cc
r74fe358 r36b81ac 3479 3479 return FALSE; 3480 3480 } 3481 static BOOLEAN jjSTD_1(leftv res, leftv u, leftv v);3482 static void jjSTD_1_ID(leftv res, ideal i0, int t0, ideal p0, attr a)3483 /* destroys i0, p0 */3484 /* result (with attributes) in res */3485 /* i0: SB*/3486 /* t0: type of p0*/3487 /* p0 new elements*/3488 /* a attributes of i0*/3489 {3490 int tp;3491 if (t0==IDEAL_CMD) tp=POLY_CMD;3492 else tp=VECTOR_CMD;3493 for (int i=IDELEMS(p0)-1; i>=0; i--)3494 {3495 poly p=p0->m[i];3496 p0->m[i]=NULL;3497 if (p!=NULL)3498 {3499 sleftv u0,v0;3500 memset(&u0,0,sizeof(sleftv));3501 memset(&v0,0,sizeof(sleftv));3502 v0.rtyp=tp;3503 v0.data=(void*)p;3504 u0.rtyp=t0;3505 u0.data=i0;3506 u0.attribute=a;3507 setFlag(&u0,FLAG_STD);3508 jjSTD_1(res,&u0,&v0);3509 i0=(ideal)res->data;3510 res->data=NULL;3511 a=res->attribute;3512 res->attribute=NULL;3513 u0.CleanUp();3514 v0.CleanUp();3515 res->CleanUp();3516 }3517 }3518 idDelete(&p0);3519 res->attribute=a;3520 res->data=(void *)i0;3521 res->rtyp=t0;3522 }3523 3481 static BOOLEAN jjSTD_1(leftv res, leftv u, leftv v) 3524 3482 { … … 3567 3525 else /*IDEAL/MODULE*/ 3568 3526 { 3569 attr *aa=u->Attribute(); 3570 attr a=NULL; 3571 if ((aa!=NULL)&&(*aa!=NULL)) a=(*aa)->Copy(); 3572 jjSTD_1_ID(res,(ideal)u->CopyD(),r,(ideal)v->CopyD(),a); 3527 i0=(ideal)v->CopyD(); 3528 int ii0=idElem(i0); /* size of i0 */ 3529 i1=idSimpleAdd(i1,i0); // 3530 memset(i0->m,0,sizeof(poly)*IDELEMS(i0)); 3531 idDelete(&i0); 3532 intvec *w=(intvec *)atGet(u,"isHomog",INTVEC_CMD); 3533 tHomog hom=testHomog; 3534 3535 if (w!=NULL) 3536 { 3537 if (!idTestHomModule(i1,currRing->qideal,w)) 3538 { 3539 // no warnung: this is legal, if i in std(i,p) 3540 // is homogeneous, but p not 3541 w=NULL; 3542 } 3543 else 3544 { 3545 w=ivCopy(w); 3546 hom=isHomog; 3547 } 3548 } 3549 if (ii0*4 >= 3*IDELEMS(i1)) // MAGIC: add few poly to large SB: 3/4 3550 { 3551 BITSET save1; 3552 SI_SAVE_OPT1(save1); 3553 si_opt_1|=Sy_bit(OPT_SB_1); 3554 /* ii0 appears to be the position of the first element of il that 3555 does not belong to the old SB ideal */ 3556 result=kStd(i1,currRing->qideal,hom,&w,NULL,0,ii0); 3557 SI_RESTORE_OPT1(save1); 3558 } 3559 else 3560 { 3561 result=kStd(i1,currRing->qideal,hom,&w); 3562 } 3563 idDelete(&i1); 3564 idSkipZeroes(result); 3565 if (w!=NULL) atSet(res,omStrDup("isHomog"),w,INTVEC_CMD); 3566 res->data = (char *)result; 3573 3567 } 3574 3568 if(!TEST_OPT_DEGBOUND) setFlag(res,FLAG_STD); -
Singular/walk.cc
-
Property
mode
changed from
100644
to100755
rcd38fbd r36b81ac 16 16 17 17 //#define TEST_OVERFLOW 18 //#define CHECK_IDEAL 19 //#define CHECK_IDEAL_MWALK 18 19 #define CHECK_IDEAL_MWALK //to print intermediate results 20 20 21 21 //#define NEXT_VECTORS_CC 22 //#define PRINT_VECTORS //to print vectors (sigma, tau, omega) 22 #define PRINT_VECTORS //to print weight vectors 23 23 24 24 #define INVEPS_SMALL_IN_FRACTAL //to choose the small invers of epsilon … … 27 27 28 28 #define FIRST_STEP_FRACTAL // to define the first step of the fractal 29 //#define MSTDCC_FRACTAL // apply Buchberger alg to compute a red GB, if 30 // tau doesn't stay in the correct cone 29 #define MSTDCC_FRACTAL // apply Buchberger alg to compute a red GB, if tau doesn't stay in the correct cone 31 30 32 31 //#define TIME_TEST // print the used time of each subroutine … … 42 41 #include <Singular/ipshell.h> 43 42 #include <Singular/ipconv.h> 43 #include <coeffs/ffields.h> 44 44 #include <coeffs/coeffs.h> 45 45 #include <Singular/subexpr.h> 46 #include <polys/templates/p_Procs.h> 46 47 47 48 #include <polys/monomials/maps.h> … … 120 121 ************************************/ 121 122 // unused 122 #if 0 123 /* 123 124 static void initSSpecialCC (ideal F, ideal Q, ideal P,kStrategy strat) 124 125 { … … 268 269 #endif 269 270 } 270 #endif 271 */ 271 272 272 273 /***************** … … 277 278 int j; 278 279 kStrategy strat = new skStrategy; 279 280 // if (TEST_OPT_PROT) 281 // { 282 // writeTime("start InterRed:"); 283 // mflush(); 284 // } 285 //strat->syzComp = 0; 280 /* 281 if (TEST_OPT_PROT) 282 { 283 writeTime("start InterRed:"); 284 mflush(); 285 } 286 strat->syzComp = 0; 287 */ 286 288 strat->kHEdgeFound = (currRing->ppNoether) != NULL; 287 289 strat->kNoether=pCopy((currRing->ppNoether)); … … 346 348 strat->fromQ = NULL; 347 349 } 348 // if (TEST_OPT_PROT) 349 // { 350 // writeTime("end Interred:"); 351 // mflush(); 352 // } 350 /* 351 if (TEST_OPT_PROT) 352 { 353 writeTime("end Interred:"); 354 mflush(); 355 } 356 */ 353 357 ideal shdl=strat->Shdl; 354 358 idSkipZeroes(shdl); … … 358 362 } 359 363 360 //unused 361 #if 0 364 #ifdef TIME_TEST 362 365 static void TimeString(clock_t tinput, clock_t tostd, clock_t tif,clock_t tstd, 363 366 clock_t tlf,clock_t tred, clock_t tnw, int step) … … 397 400 ((((double) xtextra)/1000000)/totm)*100); 398 401 } 399 #endif 400 401 //unused 402 #if 0 402 403 403 static void TimeStringFractal(clock_t tinput, clock_t tostd, clock_t tif,clock_t tstd, 404 404 clock_t textra, clock_t tlf,clock_t tred, clock_t tnw) … … 442 442 } 443 443 #endif 444 444 /* 445 445 #if defined(CHECK_IDEAL_MWALK) || defined(ENDWALKS) 446 446 static void headidString(ideal L, char* st) … … 496 496 } 497 497 #endif 498 498 */ 499 499 500 500 static void ivString(intvec* iv, const char* ch) … … 510 510 } 511 511 512 //unused 513 #if 0 512 #ifdef PRINT_VECTORS 514 513 static void MivString(intvec* iva, intvec* ivb, intvec* ivc) 515 514 { … … 558 557 } 559 558 return p0; 559 } 560 561 /***************************************************************************** 562 * compute the gcd of the entries of the vectors curr_weight and diff_weight * 563 *****************************************************************************/ 564 static int simplify_gcd(intvec* curr_weight, intvec* diff_weight) 565 { 566 int j; 567 int nRing = currRing->N; 568 int gcd_tmp = (*curr_weight)[0]; 569 for (j=1; j<nRing; j++) 570 { 571 gcd_tmp = gcd(gcd_tmp, (*curr_weight)[j]); 572 if(gcd_tmp == 1) 573 { 574 break; 575 } 576 } 577 if(gcd_tmp != 1) 578 { 579 for (j=0; j<nRing; j++) 580 { 581 gcd_tmp = gcd(gcd_tmp, (*diff_weight)[j]); 582 if(gcd_tmp == 1) 583 { 584 break; 585 } 586 } 587 } 588 return gcd_tmp; 560 589 } 561 590 … … 774 803 for(i=nG-1; i>=0; i--) 775 804 { 776 mi = MpolyInitialForm(G->m[i], iv); 777 gi = G->m[i]; 778 805 mi = pHead(MpolyInitialForm(G->m[i], iv)); 806 //Print("\n **// test_w_in_ConeCC: lm(initial)= %s \n",pString(mi)); 807 gi = pHead(G->m[i]); 808 //Print("\n **// test_w_in_ConeCC: lm(ideal)= %s \n",pString(gi)); 779 809 if(mi == NULL) 780 810 { … … 953 983 } 954 984 955 /***************************************************************************** 956 * create a weight matrix order as intvec of an extra weight vector (a(iv), lp)*957 ****************************************************************************** /985 /********************************************************************************* 986 * create a weight matrix order as intvec of an extra weight vector (a(iv),M(iw)) * 987 **********************************************************************************/ 958 988 intvec* MivMatrixOrderRefine(intvec* iv, intvec* iw) 959 989 { 960 assume( iv->length() == iw->length());961 int i, nR = iv->length();962 990 assume((iv->length())*(iv->length()) == iw->length()); 991 int i,j, nR = iv->length(); 992 963 993 intvec* ivm = new intvec(nR*nR); 964 994 … … 966 996 { 967 997 (*ivm)[i] = (*iv)[i]; 968 (*ivm)[i+nR] = (*iw)[i]; 969 } 970 for(i=2; i<nR; i++) 971 { 972 (*ivm)[i*nR+i-2] = 1; 998 } 999 for(i=1; i<nR; i++) 1000 { 1001 for(j=0; j<nR; j++) 1002 { 1003 (*ivm)[j+i*nR] = (*iw)[j+i*nR]; 1004 } 973 1005 } 974 1006 return ivm; … … 1005 1037 * print the max total degree and the max coefficient of G * 1006 1038 *****************************************************************************/ 1007 #if 0 1039 /* 1008 1040 static void checkComplexity(ideal G, char* cG) 1009 1041 { … … 1046 1078 PrintLn(); 1047 1079 } 1048 #endif 1080 */ 1049 1081 1050 1082 /***************************************************************************** … … 1068 1100 intvec* v_null = new intvec(nV); 1069 1101 1070 1071 1102 // Check that the perturbed degree is valid 1072 1103 if(pdeg > nV || pdeg <= 0) … … 1082 1113 } 1083 1114 mpz_t *pert_vector = (mpz_t*)omAlloc(nV*sizeof(mpz_t)); 1084 //mpz_t *pert_vector1 = (mpz_t*)omAlloc(nV*sizeof(mpz_t));1115 mpz_t *pert_vector1 = (mpz_t*)omAlloc(nV*sizeof(mpz_t)); 1085 1116 1086 1117 for(i=0; i<nV; i++) 1087 1118 { 1088 1119 mpz_init_set_si(pert_vector[i], (*ivtarget)[i]); 1089 //mpz_init_set_si(pert_vector1[i], (*ivtarget)[i]);1120 mpz_init_set_si(pert_vector1[i], (*ivtarget)[i]); 1090 1121 } 1091 1122 // Calculate max1 = Max(A2)+Max(A3)+...+Max(Apdeg), … … 1167 1198 } 1168 1199 } 1200 1201 // 2147483647 is max. integer representation in SINGULAR 1202 mpz_t sing_int; 1203 mpz_init_set_ui(sing_int, 2147483647); 1204 1205 mpz_t check_int; 1206 mpz_init_set_ui(check_int, 100000); 1207 1169 1208 mpz_t ztemp; 1170 1209 mpz_init(ztemp); … … 1186 1225 } 1187 1226 1188 intvec *pert_vector1= new intvec(nV);1189 j = 0;1190 1227 for(i=0; i<nV; i++) 1191 1228 { 1192 (* pert_vector1)[i] = mpz_get_si(pert_vector[i]); 1193 (* pert_vector1)[i] = 0.1*(* pert_vector1)[i]; 1194 (* pert_vector1)[i] = floor((* pert_vector1)[i] + 0.5); 1195 if((* pert_vector1)[i] == 0) 1196 { 1197 j++; 1198 } 1199 } 1200 if(j > nV - 1) 1201 { 1202 // Print("\n// MPertVectors: geaenderter vector gleich Null! \n"); 1203 delete pert_vector1; 1204 goto CHECK_OVERFLOW; 1205 } 1206 1207 // check that the perturbed weight vector lies in the Groebner cone 1208 if(test_w_in_ConeCC(G,pert_vector1) != 0) 1209 { 1210 // Print("\n// MPertVectors: geaenderter vector liegt in Groebnerkegel! \n"); 1229 if(mpz_cmp(pert_vector[i], check_int)>=0) 1230 { 1231 for(j=0; j<nV; j++) 1232 { 1233 mpz_fdiv_q_ui(pert_vector1[j], pert_vector[j], 100); 1234 } 1235 } 1236 } 1237 1238 intvec* result = new intvec(nV); 1239 1240 int ntrue=0; 1241 1242 for(i=0; i<nV; i++) 1243 { 1244 (*result)[i] = mpz_get_si(pert_vector1[i]); 1245 if(mpz_cmp(pert_vector1[i], sing_int)>=0) 1246 { 1247 ntrue++; 1248 } 1249 } 1250 if(ntrue > 0 || test_w_in_ConeCC(G,result)==0) 1251 { 1252 ntrue=0; 1211 1253 for(i=0; i<nV; i++) 1212 1254 { 1213 mpz_set_si(pert_vector[i], (*pert_vector1)[i]); 1214 } 1215 } 1216 else 1217 { 1218 //Print("\n// MpertVectors: geaenderter vector liegt nicht in Groebnerkegel! \n"); 1219 } 1220 delete pert_vector1; 1221 1222 CHECK_OVERFLOW: 1223 intvec* result = new intvec(nV); 1224 1225 /* 2147483647 is max. integer representation in SINGULAR */ 1226 mpz_t sing_int; 1227 mpz_init_set_ui(sing_int, 2147483647); 1228 1229 int ntrue=0; 1230 for(i=0; i<nV; i++) 1231 { 1232 (*result)[i] = mpz_get_si(pert_vector[i]); 1233 if(mpz_cmp(pert_vector[i], sing_int)>=0) 1234 { 1235 ntrue++; 1236 if(Overflow_Error == FALSE) 1237 { 1238 Overflow_Error = TRUE; 1239 PrintS("\n// ** OVERFLOW in \"MPertvectors\": "); 1240 mpz_out_str( stdout, 10, pert_vector[i]); 1241 PrintS(" is greater than 2147483647 (max. integer representation)"); 1242 Print("\n// So vector[%d] := %d is wrong!!", i+1, (*result)[i]); 1243 } 1244 } 1245 } 1246 1247 if(Overflow_Error == TRUE) 1248 { 1249 ivString(result, "pert_vector"); 1250 Print("\n// %d element(s) of it is overflow!!", ntrue); 1255 (*result)[i] = mpz_get_si(pert_vector[i]); 1256 if(mpz_cmp(pert_vector[i], sing_int)>=0) 1257 { 1258 ntrue++; 1259 if(Overflow_Error == FALSE) 1260 { 1261 Overflow_Error = TRUE; 1262 PrintS("\n// ** OVERFLOW in \"MPertvectors\": "); 1263 mpz_out_str( stdout, 10, pert_vector[i]); 1264 PrintS(" is greater than 2147483647 (max. integer representation)"); 1265 Print("\n// So vector[%d] := %d is wrong!!", i+1, (*result)[i]); 1266 } 1267 } 1268 } 1269 1270 if(Overflow_Error == TRUE) 1271 { 1272 ivString(result, "pert_vector"); 1273 Print("\n// %d element(s) of it is overflow!!", ntrue); 1274 } 1251 1275 } 1252 1276 1253 1277 mpz_clear(ztemp); 1254 1278 mpz_clear(sing_int); 1279 mpz_clear(check_int); 1255 1280 omFree(pert_vector); 1256 //omFree(pert_vector1);1281 omFree(pert_vector1); 1257 1282 mpz_clear(tot_deg); 1258 1283 mpz_clear(maxdeg); … … 1456 1481 1457 1482 //unused 1458 #if 0 1483 /* 1459 1484 static intvec* MatrixOrderdp(int nV) 1460 1485 { … … 1472 1497 return(ivM); 1473 1498 } 1474 #endif 1499 */ 1475 1500 1476 1501 intvec* MivUnit(int nV) … … 1549 1574 mpz_cdiv_q_ui(inveps, inveps, nV); 1550 1575 } 1551 // PrintS("\n// choose the \"small\" inverse epsilon!");1576 // choose the small inverse epsilon 1552 1577 #endif 1553 1578 … … 1583 1608 1584 1609 for(j=0; j<nV; j++) 1585 1610 { 1586 1611 mpz_init_set(pert_vector[i*nV+j],ivtemp[j]); 1587 1588 } 1589 1590 / * 2147483647 is max. integer representation in SINGULAR */1612 } 1613 } 1614 1615 // 2147483647 is max. integer representation in SINGULAR 1591 1616 mpz_t sing_int; 1592 1617 mpz_init_set_ui(sing_int, 2147483647); … … 1611 1636 mpz_divexact(pert_vector[i], pert_vector[i], ztmp); 1612 1637 (* result)[i] = mpz_get_si(pert_vector[i]); 1613 }1614 1615 j = 0;1616 for(i=0; i<nV; i++)1617 {1618 (* result1)[i] = mpz_get_si(pert_vector[i]);1619 (* result1)[i] = 0.1*(* result1)[i];1620 (* result1)[i] = floor((* result1)[i] + 0.5);1621 if((* result1)[i] == 0)1622 {1623 j++;1624 }1625 }1626 if(j > nV - 1)1627 {1628 // Print("\n// MfPertwalk: geaenderter vector gleich Null! \n");1629 delete result1;1630 goto CHECK_OVERFLOW;1631 }1632 1633 // check that the perturbed weight vector lies in the Groebner cone1634 if(test_w_in_ConeCC(G,result1) != 0)1635 {1636 // Print("\n// MfPertwalk: geaenderter vector liegt in Groebnerkegel! \n");1637 delete result;1638 result = result1;1639 for(i=0; i<nV; i++)1640 {1641 mpz_set_si(pert_vector[i], (*result1)[i]);1642 }1643 }1644 else1645 {1646 delete result1;1647 // Print("\n// Mfpertwalk: geaenderter vector liegt nicht in Groebnerkegel! \n");1648 1638 } 1649 1639 … … 1685 1675 while(p!=NULL) 1686 1676 { 1687 p_Setm(p,currRing); pIter(p); 1677 p_Setm(p,currRing); 1678 pIter(p); 1688 1679 } 1689 1680 } … … 1768 1759 1769 1760 //unused 1770 #if 0 1761 /* 1771 1762 static void checkidealCC(ideal G, char* Ch) 1772 1763 { … … 1794 1785 PrintLn(); 1795 1786 } 1796 #endif 1787 */ 1797 1788 1798 1789 //unused 1799 #if 0 1790 /* 1800 1791 static void HeadidString(ideal L, char* st) 1801 1792 { … … 1809 1800 Print(" %s;\n", pString(pHead(L->m[nL]))); 1810 1801 } 1811 #endif 1812 1802 1803 */ 1813 1804 static inline int MivComp(intvec* iva, intvec* ivb) 1814 1805 { … … 1859 1850 } 1860 1851 1852 1853 /************************************************************** 1854 * Look for the position of the smallest absolut value in vec * 1855 **************************************************************/ 1856 static int MivAbsMaxArg(intvec* vec) 1857 { 1858 int k = MivAbsMax(vec); 1859 int i=0; 1860 while(1) 1861 { 1862 if((*vec)[i] == k || (*vec)[i] == -k) 1863 { 1864 break; 1865 } 1866 i++; 1867 } 1868 return i; 1869 } 1870 1871 1861 1872 /********************************************************************** 1862 1873 * Compute a next weight vector between curr_weight and target_weight * 1863 1874 * with respect to an ideal <G>. * 1864 1875 **********************************************************************/ 1876 /* 1865 1877 static intvec* MwalkNextWeightCC(intvec* curr_weight, intvec* target_weight, 1866 1878 ideal G) … … 1873 1885 1874 1886 int nRing = currRing->N; 1875 int checkRed, j, kkk,nG = IDELEMS(G);1887 int checkRed, j, nG = IDELEMS(G); 1876 1888 intvec* ivtemp; 1877 1889 … … 1911 1923 mpz_init(dcw); 1912 1924 1913 //int tn0, tn1, tz1, ncmp, gcd_tmp, ntmp;1914 1925 int gcd_tmp; 1915 1926 intvec* diff_weight = MivSub(target_weight, curr_weight); … … 1917 1928 intvec* diff_weight1 = MivSub(target_weight, curr_weight); 1918 1929 poly g; 1919 //poly g, gw; 1930 1920 1931 for (j=0; j<nG; j++) 1921 1932 { … … 1934 1945 mpz_set_si(MwWd, MivDotProduct(ivtemp, curr_weight)); 1935 1946 mpz_sub(s_zaehler, deg_w0_p1, MwWd); 1936 1937 1947 if(mpz_cmp(s_zaehler, t_null) != 0) 1938 1948 { 1939 1949 mpz_set_si(MwWd, MivDotProduct(ivtemp, diff_weight)); 1940 1950 mpz_sub(s_nenner, MwWd, deg_d0_p1); 1941 1942 1951 // check for 0 < s <= 1 1943 1952 if( (mpz_cmp(s_zaehler,t_null) > 0 && … … 1979 1988 } 1980 1989 } 1981 //Print("\n// Alloc Size = %d \n", nRing*sizeof(mpz_t));1990 //Print("\n// Alloc Size = %d \n", nRing*sizeof(mpz_t)); 1982 1991 mpz_t *vec=(mpz_t*)omAlloc(nRing*sizeof(mpz_t)); 1983 1992 1984 1993 1985 // there is no 0<t<1 and define the next weight vector that is equal to the current weight vector 1994 // there is no 0<t<1 and define the next weight vector that is equal 1995 // to the current weight vector 1986 1996 if(mpz_cmp(t_nenner, t_null) == 0) 1987 1997 { 1988 1989 Print("\n//MwalkNextWeightCC: t_nenner ist Null!");1990 1998 #ifndef SING_NDEBUG 1999 Print("\n//MwalkNextWeightCC: t_nenner=0\n"); 2000 #endif 1991 2001 delete diff_weight; 1992 2002 diff_weight = ivCopy(curr_weight);//take memory … … 2054 2064 #endif 2055 2065 2056 // BOOLEAN isdwpos; 2057 2058 // construct a new weight vector 2066 // construct a new weight vector and check whether vec[j] is overflow, 2067 // i.e. vec[j] > 2^31. 2068 // If vec[j] doesn't overflow, define a weight vector. Otherwise, 2069 // report that overflow appears. In the second case, test whether the 2070 // the correctness of the new vector plays an important role 2071 2059 2072 for (j=0; j<nRing; j++) 2060 2073 { … … 2100 2113 } 2101 2114 } 2102 2115 // reduce the vector with the gcd 2116 if(mpz_cmp_si(ggt,1) != 0) 2117 { 2118 for (j=0; j<nRing; j++) 2119 { 2120 mpz_divexact(vec[j], vec[j], ggt); 2121 } 2122 } 2103 2123 #ifdef NEXT_VECTORS_CC 2104 2124 PrintS("\n// gcd of elements of the vector: "); … … 2106 2126 #endif 2107 2127 2108 /**********************************************************************2109 * construct a new weight vector and check whether vec[j] is overflow, *2110 * i.e. vec[j] > 2^31. *2111 * If vec[j] doesn't overflow, define a weight vector. Otherwise, *2112 * report that overflow appears. In the second case, test whether the *2113 * the correctness of the new vector plays an important role *2114 **********************************************************************/2115 kkk=0;2116 2128 for(j=0; j<nRing; j++) 2117 2129 { 2118 2130 if(mpz_cmp(vec[j], sing_int_half) >= 0) 2119 2131 { 2120 2132 goto REDUCTION; 2121 2122 2133 } 2134 } 2123 2135 checkRed = 1; 2124 2136 for (j=0; j<nRing; j++) … … 2129 2141 2130 2142 REDUCTION: 2143 checkRed = 1; 2131 2144 for (j=0; j<nRing; j++) 2132 2145 { 2133 (*diff_weight)[j] = mpz_get_si(vec[j]); 2134 } 2135 while(MivAbsMax(diff_weight) >= 5) 2136 { 2137 for (j=0; j<nRing; j++) 2138 { 2139 if(mpz_cmp_si(ggt,1)==0) 2140 { 2141 (*diff_weight1)[j] = floor(0.1*(*diff_weight)[j] + 0.5); 2142 // Print("\n// vector[%d] = %d \n",j+1, (*diff_weight1)[j]); 2143 } 2144 else 2145 { 2146 mpz_divexact(vec[j], vec[j], ggt); 2147 (*diff_weight1)[j] = floor(0.1*(*diff_weight)[j] + 0.5); 2148 // Print("\n// vector[%d] = %d \n",j+1, (*diff_weight1)[j]); 2149 } 2150 /* 2151 if((*diff_weight1)[j] == 0) 2152 { 2153 kkk = kkk + 1; 2154 } 2155 */ 2156 } 2157 2158 2159 /* 2160 if(kkk > nRing - 1) 2161 { 2162 // diff_weight was reduced to zero 2163 // Print("\n // MwalkNextWeightCC: geaenderter Vector gleich Null! \n"); 2164 goto TEST_OVERFLOW; 2165 } 2166 */ 2167 2168 if(test_w_in_ConeCC(G,diff_weight1) != 0) 2169 { 2170 Print("\n// MwalkNextWeightCC: geaenderter vector liegt in Groebnerkegel! \n"); 2171 for (j=0; j<nRing; j++) 2172 { 2173 (*diff_weight)[j] = (*diff_weight1)[j]; 2174 } 2175 if(MivAbsMax(diff_weight) < 5) 2176 { 2177 checkRed = 1; 2178 goto SIMPLIFY_GCD; 2179 } 2180 } 2181 else 2182 { 2183 // Print("\n// MwalkNextWeightCC: geaenderter vector liegt nicht in Groebnerkegel! \n"); 2184 break; 2185 } 2146 (*diff_weight1)[j] = mpz_get_si(vec[j]); 2147 } 2148 while(test_w_in_ConeCC(G,diff_weight1)) 2149 { 2150 for(j=0; j<nRing; j++) 2151 { 2152 (*diff_weight)[j] = (*diff_weight1)[j]; 2153 mpz_set_si(vec[j], (*diff_weight)[j]); 2154 } 2155 for(j=0; j<nRing; j++) 2156 { 2157 (*diff_weight1)[j] = floor(0.1*(*diff_weight)[j] + 0.5); 2158 } 2159 } 2160 if(MivAbsMax(diff_weight)>10000) 2161 { 2162 for(j=0; j<nRing; j++) 2163 { 2164 (*diff_weight1)[j] = (*diff_weight)[j]; 2165 } 2166 j = 0; 2167 while(test_w_in_ConeCC(G,diff_weight1)) 2168 { 2169 (*diff_weight)[j] = (*diff_weight1)[j]; 2170 mpz_set_si(vec[j], (*diff_weight)[j]); 2171 j = MivAbsMaxArg(diff_weight1); 2172 (*diff_weight1)[j] = floor(0.1*(*diff_weight1)[j] + 0.5); 2173 } 2174 goto SIMPLIFY_GCD; 2186 2175 } 2187 2176 … … 2222 2211 mpz_clear(t_null); 2223 2212 2224 2225 2226 2213 if(Overflow_Error == FALSE) 2227 2214 { 2228 2215 Overflow_Error = nError; 2229 2216 } 2230 rComplete(currRing);2231 for( kkk=0; kkk<IDELEMS(G);kkk++)2232 { 2233 poly p=G->m[ kkk];2217 rComplete(currRing); 2218 for(j=0; j<IDELEMS(G); j++) 2219 { 2220 poly p=G->m[j]; 2234 2221 while(p!=NULL) 2235 2222 { … … 2240 2227 return diff_weight; 2241 2228 } 2229 */ 2230 /********************************************************************** 2231 * Compute a next weight vector between curr_weight and target_weight * 2232 * with respect to an ideal <G>. * 2233 **********************************************************************/ 2234 static intvec* MwalkNextWeightCC(intvec* curr_weight, intvec* target_weight, 2235 ideal G) 2236 { 2237 BOOLEAN nError = Overflow_Error; 2238 Overflow_Error = FALSE; 2239 2240 assume(currRing != NULL && curr_weight != NULL && 2241 target_weight != NULL && G != NULL); 2242 2243 int nRing = currRing->N; 2244 int checkRed, j, nG = IDELEMS(G); 2245 intvec* ivtemp; 2246 2247 mpz_t t_zaehler, t_nenner; 2248 mpz_init(t_zaehler); 2249 mpz_init(t_nenner); 2250 2251 mpz_t s_zaehler, s_nenner, temp, MwWd; 2252 mpz_init(s_zaehler); 2253 mpz_init(s_nenner); 2254 mpz_init(temp); 2255 mpz_init(MwWd); 2256 2257 mpz_t sing_int; 2258 mpz_init(sing_int); 2259 mpz_set_si(sing_int, 2147483647); 2260 2261 mpz_t sing_int_half; 2262 mpz_init(sing_int_half); 2263 mpz_set_si(sing_int_half, 3*(1073741824/2)); 2264 2265 mpz_t deg_w0_p1, deg_d0_p1; 2266 mpz_init(deg_w0_p1); 2267 mpz_init(deg_d0_p1); 2268 2269 mpz_t sztn, sntz; 2270 mpz_init(sztn); 2271 mpz_init(sntz); 2272 2273 mpz_t t_null; 2274 mpz_init(t_null); 2275 2276 mpz_t ggt; 2277 mpz_init(ggt); 2278 2279 mpz_t dcw; 2280 mpz_init(dcw); 2281 2282 int gcd_tmp; 2283 //intvec* diff_weight = MivSub(target_weight, curr_weight); 2284 2285 intvec* diff_weight1 = new intvec(nRing); //MivSub(target_weight, curr_weight); 2286 poly g; 2287 2288 // reduce the size of the entries of the current weight vector 2289 if(TEST_OPT_REDSB) 2290 { 2291 for (j=0; j<nRing; j++) 2292 { 2293 (*diff_weight1)[j] = (*curr_weight)[j]; 2294 } 2295 while(MivAbsMax(diff_weight1)>10000 && test_w_in_ConeCC(G,diff_weight1)==1) 2296 { 2297 for(j=0; j<nRing; j++) 2298 { 2299 (*curr_weight)[j] = (*diff_weight1)[j]; 2300 } 2301 for(j=0; j<nRing; j++) 2302 { 2303 (*diff_weight1)[j] = floor(0.1*(*diff_weight1)[j] + 0.5); 2304 } 2305 } 2306 2307 if(MivAbsMax(curr_weight)>100000) 2308 { 2309 for(j=0; j<nRing; j++) 2310 { 2311 (*diff_weight1)[j] = (*curr_weight)[j]; 2312 } 2313 j = 0; 2314 while(test_w_in_ConeCC(G,diff_weight1)==1 && MivAbsMax(diff_weight1)>1000) 2315 { 2316 (*curr_weight)[j] = (*diff_weight1)[j]; 2317 j = MivAbsMaxArg(diff_weight1); 2318 (*diff_weight1)[j] = floor(0.1*(*diff_weight1)[j] + 0.5); 2319 } 2320 } 2321 2322 } 2323 intvec* diff_weight = MivSub(target_weight, curr_weight); 2324 2325 // compute a suitable next weight vector 2326 for (j=0; j<nG; j++) 2327 { 2328 g = G->m[j]; 2329 if (g != NULL) 2330 { 2331 ivtemp = MExpPol(g); 2332 mpz_set_si(deg_w0_p1, MivDotProduct(ivtemp, curr_weight)); 2333 mpz_set_si(deg_d0_p1, MivDotProduct(ivtemp, diff_weight)); 2334 delete ivtemp; 2335 2336 pIter(g); 2337 while (g != NULL) 2338 { 2339 ivtemp = MExpPol(g); 2340 mpz_set_si(MwWd, MivDotProduct(ivtemp, curr_weight)); 2341 mpz_sub(s_zaehler, deg_w0_p1, MwWd); 2342 if(mpz_cmp(s_zaehler, t_null) != 0) 2343 { 2344 mpz_set_si(MwWd, MivDotProduct(ivtemp, diff_weight)); 2345 mpz_sub(s_nenner, MwWd, deg_d0_p1); 2346 // check for 0 < s <= 1 2347 if( (mpz_cmp(s_zaehler,t_null) > 0 && 2348 mpz_cmp(s_nenner, s_zaehler)>=0) || 2349 (mpz_cmp(s_zaehler, t_null) < 0 && 2350 mpz_cmp(s_nenner, s_zaehler)<=0)) 2351 { 2352 // make both positive 2353 if (mpz_cmp(s_zaehler, t_null) < 0) 2354 { 2355 mpz_neg(s_zaehler, s_zaehler); 2356 mpz_neg(s_nenner, s_nenner); 2357 } 2358 2359 //compute a simple fraction of s 2360 cancel(s_zaehler, s_nenner); 2361 2362 if(mpz_cmp(t_nenner, t_null) != 0) 2363 { 2364 mpz_mul(sztn, s_zaehler, t_nenner); 2365 mpz_mul(sntz, s_nenner, t_zaehler); 2366 2367 if(mpz_cmp(sztn,sntz) < 0) 2368 { 2369 mpz_add(t_nenner, t_null, s_nenner); 2370 mpz_add(t_zaehler,t_null, s_zaehler); 2371 } 2372 } 2373 else 2374 { 2375 mpz_add(t_nenner, t_null, s_nenner); 2376 mpz_add(t_zaehler,t_null, s_zaehler); 2377 } 2378 } 2379 } 2380 pIter(g); 2381 delete ivtemp; 2382 } 2383 } 2384 } 2385 //Print("\n// Alloc Size = %d \n", nRing*sizeof(mpz_t)); 2386 mpz_t *vec=(mpz_t*)omAlloc(nRing*sizeof(mpz_t)); 2387 2388 2389 // there is no 0<t<1 and define the next weight vector that is equal 2390 // to the current weight vector 2391 if(mpz_cmp(t_nenner, t_null) == 0) 2392 { 2393 #ifndef SING_NDEBUG 2394 Print("\n//MwalkNextWeightCC: t_nenner=0\n"); 2395 #endif 2396 delete diff_weight; 2397 diff_weight = ivCopy(curr_weight);//take memory 2398 goto FINISH; 2399 } 2400 2401 // define the target vector as the next weight vector, if t = 1 2402 if(mpz_cmp_si(t_nenner, 1)==0 && mpz_cmp_si(t_zaehler,1)==0) 2403 { 2404 delete diff_weight; 2405 diff_weight = ivCopy(target_weight); //this takes memory 2406 goto FINISH; 2407 } 2408 2409 //checkRed = 0; 2410 2411 SIMPLIFY_GCD: 2412 2413 // simplify the vectors curr_weight and diff_weight (C-int) 2414 gcd_tmp = (*curr_weight)[0]; 2415 2416 for (j=1; j<nRing; j++) 2417 { 2418 gcd_tmp = gcd(gcd_tmp, (*curr_weight)[j]); 2419 if(gcd_tmp == 1) 2420 { 2421 break; 2422 } 2423 } 2424 if(gcd_tmp != 1) 2425 { 2426 for (j=0; j<nRing; j++) 2427 { 2428 gcd_tmp = gcd(gcd_tmp, (*diff_weight)[j]); 2429 if(gcd_tmp == 1) 2430 { 2431 break; 2432 } 2433 } 2434 } 2435 if(gcd_tmp != 1) 2436 { 2437 for (j=0; j<nRing; j++) 2438 { 2439 (*curr_weight)[j] = (*curr_weight)[j]/gcd_tmp; 2440 (*diff_weight)[j] = (*diff_weight)[j]/gcd_tmp; 2441 } 2442 } 2443 if(checkRed > 0) 2444 { 2445 for (j=0; j<nRing; j++) 2446 { 2447 mpz_set_si(vec[j], (*diff_weight)[j]); 2448 } 2449 goto TEST_OVERFLOW; 2450 } 2451 2452 #ifdef NEXT_VECTORS_CC 2453 Print("\n// gcd of the weight vectors (current and target) = %d", gcd_tmp); 2454 ivString(curr_weight, "new cw"); 2455 ivString(diff_weight, "new dw"); 2456 2457 PrintS("\n// t_zaehler: "); mpz_out_str( stdout, 10, t_zaehler); 2458 PrintS(", t_nenner: "); mpz_out_str( stdout, 10, t_nenner); 2459 #endif 2460 2461 // construct a new weight vector and check whether vec[j] is overflow, i.e. vec[j] > 2^31. 2462 // If vec[j] doesn't overflow, define a weight vector. Otherwise, report that overflow 2463 // appears. In the second case, test whether the the correctness of the new vector plays 2464 // an important role 2465 2466 for (j=0; j<nRing; j++) 2467 { 2468 mpz_set_si(dcw, (*curr_weight)[j]); 2469 mpz_mul(s_nenner, t_nenner, dcw); 2470 2471 if( (*diff_weight)[j]>0) 2472 { 2473 mpz_mul_ui(s_zaehler, t_zaehler, (*diff_weight)[j]); 2474 } 2475 else 2476 { 2477 mpz_mul_ui(s_zaehler, t_zaehler, -(*diff_weight)[j]); 2478 mpz_neg(s_zaehler, s_zaehler); 2479 } 2480 mpz_add(sntz, s_nenner, s_zaehler); 2481 mpz_init_set(vec[j], sntz); 2482 2483 #ifdef NEXT_VECTORS_CC 2484 Print("\n// j = %d ==> ", j); 2485 PrintS("("); 2486 mpz_out_str( stdout, 10, t_nenner); 2487 Print(" * %d)", (*curr_weight)[j]); 2488 Print(" + ("); mpz_out_str( stdout, 10, t_zaehler); 2489 Print(" * %d) = ", (*diff_weight)[j]); 2490 mpz_out_str( stdout, 10, s_nenner); 2491 PrintS(" + "); 2492 mpz_out_str( stdout, 10, s_zaehler); 2493 PrintS(" = "); mpz_out_str( stdout, 10, sntz); 2494 Print(" ==> vector[%d]: ", j); mpz_out_str(stdout, 10, vec[j]); 2495 #endif 2496 2497 if(j==0) 2498 { 2499 mpz_set(ggt, sntz); 2500 } 2501 else 2502 { 2503 if(mpz_cmp_si(ggt,1) != 0) 2504 { 2505 mpz_gcd(ggt, ggt, sntz); 2506 } 2507 } 2508 } 2509 // reduce the vector with the gcd 2510 if(mpz_cmp_si(ggt,1) != 0) 2511 { 2512 for (j=0; j<nRing; j++) 2513 { 2514 mpz_divexact(vec[j], vec[j], ggt); 2515 } 2516 } 2517 #ifdef NEXT_VECTORS_CC 2518 PrintS("\n// gcd of elements of the vector: "); 2519 mpz_out_str( stdout, 10, ggt); 2520 #endif 2521 2522 for (j=0; j<nRing; j++) 2523 { 2524 (*diff_weight)[j] = mpz_get_si(vec[j]); 2525 } 2526 2527 TEST_OVERFLOW: 2528 2529 for (j=0; j<nRing; j++) 2530 { 2531 if(mpz_cmp(vec[j], sing_int)>=0) 2532 { 2533 if(Overflow_Error == FALSE) 2534 { 2535 Overflow_Error = TRUE; 2536 PrintS("\n// ** OVERFLOW in \"MwalkNextWeightCC\": "); 2537 mpz_out_str( stdout, 10, vec[j]); 2538 PrintS(" is greater than 2147483647 (max. integer representation)\n"); 2539 Print("// So vector[%d] := %d is wrong!!\n",j+1, vec[j]);// vec[j] is mpz_t 2540 } 2541 } 2542 } 2543 2544 FINISH: 2545 delete diff_weight1; 2546 mpz_clear(t_zaehler); 2547 mpz_clear(t_nenner); 2548 mpz_clear(s_zaehler); 2549 mpz_clear(s_nenner); 2550 mpz_clear(sntz); 2551 mpz_clear(sztn); 2552 mpz_clear(temp); 2553 mpz_clear(MwWd); 2554 mpz_clear(deg_w0_p1); 2555 mpz_clear(deg_d0_p1); 2556 mpz_clear(ggt); 2557 omFree(vec); 2558 mpz_clear(sing_int_half); 2559 mpz_clear(sing_int); 2560 mpz_clear(dcw); 2561 mpz_clear(t_null); 2562 2563 if(Overflow_Error == FALSE) 2564 { 2565 Overflow_Error = nError; 2566 } 2567 rComplete(currRing); 2568 for(j=0; j<IDELEMS(G); j++) 2569 { 2570 poly p=G->m[j]; 2571 while(p!=NULL) 2572 { 2573 p_Setm(p,currRing); 2574 pIter(p); 2575 } 2576 } 2577 return diff_weight; 2578 } 2579 2242 2580 2243 2581 /********************************************************************** … … 2271 2609 } 2272 2610 2273 /************************************************************** 2611 /******************************************************************** 2274 2612 * define and execute a new ring which order is (a(vb),a(va),lp,C) * 2275 * ************************************************************/ 2276 #if 0 2277 // unused 2613 * ******************************************************************/ 2278 2614 static void VMrHomogeneous(intvec* va, intvec* vb) 2279 2615 { … … 2353 2689 rChangeCurrRing(r); 2354 2690 } 2355 #endif 2691 2356 2692 2357 2693 /************************************************************** … … 2428 2764 } 2429 2765 2430 static ring VMrDefault1(intvec* va)2431 {2432 2433 if ((currRing->ppNoether)!=NULL)2434 {2435 pDelete(&(currRing->ppNoether));2436 }2437 if (((sLastPrinted.rtyp>BEGIN_RING) && (sLastPrinted.rtyp<END_RING)) ||2438 ((sLastPrinted.rtyp==LIST_CMD)&&(lRingDependend((lists)sLastPrinted.data))))2439 {2440 sLastPrinted.CleanUp();2441 }2442 2443 ring r = (ring) omAlloc0Bin(sip_sring_bin);2444 int i, nv = currRing->N;2445 2446 r->cf = currRing->cf;2447 r->N = currRing->N;2448 2449 int nb = 4;2450 2451 //names2452 char* Q; // In order to avoid the corrupted memory, do not change.2453 r->names = (char **) omAlloc0(nv * sizeof(char_ptr));2454 for(i=0; i<nv; i++)2455 {2456 Q = currRing->names[i];2457 r->names[i] = omStrDup(Q);2458 }2459 2460 /*weights: entries for 3 blocks: NULL Made:???*/2461 r->wvhdl = (int **)omAlloc0(nb * sizeof(int_ptr));2462 r->wvhdl[0] = (int*) omAlloc(nv*sizeof(int));2463 for(i=0; i<nv; i++)2464 r->wvhdl[0][i] = (*va)[i];2465 2466 /* order: a,lp,C,0 */2467 r->order = (int *) omAlloc(nb * sizeof(int *));2468 r->block0 = (int *)omAlloc0(nb * sizeof(int *));2469 r->block1 = (int *)omAlloc0(nb * sizeof(int *));2470 2471 // ringorder a for the first block: var 1..nv2472 r->order[0] = ringorder_a;2473 r->block0[0] = 1;2474 r->block1[0] = nv;2475 2476 // ringorder lp for the second block: var 1..nv2477 r->order[1] = ringorder_lp;2478 r->block0[1] = 1;2479 r->block1[1] = nv;2480 2481 // ringorder C for the third block2482 // it is very important within "idLift",2483 // especially, by ring syz_ring=rCurrRingAssure_SyzComp();2484 // therefore, nb must be (nBlocks(currRing) + 1)2485 r->order[2] = ringorder_C;2486 2487 // the last block: everything is 02488 r->order[3] = 0;2489 2490 // polynomial ring2491 r->OrdSgn = 1;2492 2493 // complete ring intializations2494 2495 rComplete(r);2496 2497 //rChangeCurrRing(r);2498 return r;2499 }2500 2501 2766 /**************************************************************** 2502 2767 * define and execute a new ring with ordering (a(va),Wp(vb),C) * 2503 2768 * **************************************************************/ 2504 2505 2769 static ring VMrRefine(intvec* va, intvec* vb) 2506 2770 { … … 2576 2840 2577 2841 // complete ring intializations 2578 2842 2579 2843 rComplete(r); 2580 2844 … … 2806 3070 } 2807 3071 2808 2809 /* define a ring with parameters und change to it */ 2810 /* DefRingPar and DefRingParlp corrupt still memory */ 3072 /*************************************************** 3073 * define a ring with parameters und change to it * 3074 * DefRingPar and DefRingParlp corrupt still memory * 3075 ****************************************************/ 2811 3076 static void DefRingPar(intvec* va) 2812 3077 { … … 2956 3221 } 2957 3222 2958 //unused 2959 /************************************************************** 2960 * check wheather one or more components of a vector are zero * 2961 **************************************************************/ 2962 #if 0 3223 /************************************************************* 3224 * check whether one or more components of a vector are zero * 3225 *************************************************************/ 2963 3226 static int isNolVector(intvec* hilb) 2964 3227 { … … 2973 3236 return 0; 2974 3237 } 2975 #endif 3238 3239 /************************************************************* 3240 * check whether one or more components of a vector are <= 0 * 3241 *************************************************************/ 3242 static int isNegNolVector(intvec* hilb) 3243 { 3244 int i; 3245 for(i=hilb->length()-1; i>=0; i--) 3246 { 3247 if((* hilb)[i]<=0) 3248 { 3249 return 1; 3250 } 3251 } 3252 return 0; 3253 } 3254 3255 /************************************************************************** 3256 * Gomega is the initial ideal of G w. r. t. the current weight vector * 3257 * curr_weight. Check whether curr_weight lies on a border of the Groebner * 3258 * cone, i. e. check whether a monomial is divisible by a leading monomial * 3259 ***************************************************************************/ 3260 static ideal middleOfCone(ideal G, ideal Gomega) 3261 { 3262 BOOLEAN middle = FALSE; 3263 int i,j,N = IDELEMS(Gomega); 3264 poly p,lm,factor1,factor2; 3265 3266 ideal Go = idCopy(G); 3267 3268 // check whether leading monomials of G and Gomega coincide 3269 // and return NULL if not 3270 for(i=0; i<N; i++) 3271 { 3272 if(!pIsConstant(pSub(pCopy(Gomega->m[i]),pCopy(pHead(G->m[i]))))) 3273 { 3274 idDelete(&Go); 3275 return NULL; 3276 } 3277 } 3278 for(i=0; i<N; i++) 3279 { 3280 for(j=0; j<N; j++) 3281 { 3282 if(i!=j) 3283 { 3284 p = pCopy(Gomega->m[i]); 3285 lm = pCopy(Gomega->m[j]); 3286 pIter(p); 3287 while(p!=NULL) 3288 { 3289 if(pDivisibleBy(lm,p)) 3290 { 3291 if(middle == FALSE) 3292 { 3293 middle = TRUE; 3294 } 3295 factor1 = singclap_pdivide(pHead(p),lm,currRing); 3296 factor2 = pMult(pCopy(factor1),pCopy(Go->m[j])); 3297 pDelete(&factor1); 3298 Go->m[i] = pAdd((Go->m[i]),pNeg(pCopy(factor2))); 3299 pDelete(&factor2); 3300 } 3301 pIter(p); 3302 } 3303 pDelete(&lm); 3304 pDelete(&p); 3305 } 3306 } 3307 } 3308 3309 if(middle == TRUE) 3310 { 3311 return Go; 3312 } 3313 idDelete(&Go); 3314 return NULL; 3315 } 2976 3316 2977 3317 /****************************** Februar 2002 **************************** … … 3104 3444 { 3105 3445 Print("\n// ring r%d_%d = %s;\n", tp_deg, nwalk, rString(currRing)); 3446 /* 3106 3447 idElements(Gomega, "Gw"); 3107 3448 headidString(Gomega, "Gw"); 3449 */ 3108 3450 } 3109 3451 #endif … … 3128 3470 else 3129 3471 { 3130 rChangeCurrRing(VMrDefault(curr_weight)); //Aenderung3472 rChangeCurrRing(VMrDefault(curr_weight)); 3131 3473 } 3132 3474 newRing = currRing; … … 3255 3597 3256 3598 /********************************************************** 3257 * check whether a polynomial of G has least 3monomials *3599 * check whether a polynomial of G has least 4 monomials * 3258 3600 **********************************************************/ 3259 3601 static int lengthpoly(ideal G) … … 3262 3604 for(i=IDELEMS(G)-1; i>=0; i--) 3263 3605 { 3264 #if 03265 if(pLength(G->m[i])>2)3266 {3267 return 1;3268 }3269 #else3270 3606 if((G->m[i]!=NULL) /* len >=0 */ 3271 3607 && (G->m[i]->next!=NULL) /* len >=1 */ 3272 3608 && (G->m[i]->next->next!=NULL) /* len >=2 */ 3273 3609 && (G->m[i]->next->next->next!=NULL) /* len >=3 */ 3274 //&& (G->m[i]->next->next->next->next!=NULL) /* len >=4 */ 3275 ) 3276 { 3277 return 1; 3278 } 3279 #endif 3610 && (G->m[i]->next->next->next->next!=NULL) /* len >=4*/ ) 3611 { 3612 return 1; 3613 } 3280 3614 } 3281 3615 return 0; 3616 } 3617 3618 /***************************************** 3619 * return maximal polynomial length of G * 3620 *****************************************/ 3621 static int maxlengthpoly(ideal G) 3622 { 3623 int i,k,length=0; 3624 for(i=IDELEMS(G)-1; i>=0; i--) 3625 { 3626 k = pLength(G->m[i]); 3627 if(k>length) 3628 { 3629 length = k; 3630 } 3631 } 3632 return length; 3282 3633 } 3283 3634 … … 3350 3701 for(i=nG-1; i>=0; i--) 3351 3702 { 3352 #if 0 3703 /* 3353 3704 poly t; 3354 3705 if((t=pSub(pCopy(H0->m[i]), pCopy(H1->m[i]))) != NULL) … … 3358 3709 } 3359 3710 pDelete(&t); 3360 #else 3711 */ 3361 3712 if(!pEqualPolys(H0->m[i],H1->m[i])) 3362 3713 { 3363 3714 return 0; 3364 3715 } 3365 #endif3366 3716 } 3367 3717 return 1; … … 3372 3722 * find the maximal total degree of polynomials in G * 3373 3723 *****************************************************/ 3374 #if 0 3724 /* 3375 3725 static int Trandegreebound(ideal G) 3376 3726 { … … 3393 3743 return result; 3394 3744 } 3395 #endif 3745 */ 3396 3746 3397 3747 //unused … … 3740 4090 * basis or n times, where n is the numbers of variables. * 3741 4091 *****************************************************************************/ 3742 3743 //unused3744 #if 03745 static int testnegintvec(intvec* v)3746 {3747 int n = v->length();3748 int i;3749 for(i=0; i<n; i++)3750 {3751 if((*v)[i]<0)3752 {3753 return(1);3754 }3755 }3756 return(0);3757 }3758 #endif3759 4092 3760 4093 // npwinc = 0, if curr_weight doesn't stay in the correct Groebner cone … … 3884 4217 else 3885 4218 { 3886 rChangeCurrRing(VMrDefault(curr_weight)); //Aenderung4219 rChangeCurrRing(VMrDefault(curr_weight)); 3887 4220 } 3888 4221 newRing = currRing; … … 3968 4301 //nOverflow_Error = Overflow_Error; 3969 4302 tproc=tproc+clock()-tinput; 3970 /*3971 3972 3973 */4303 4304 Print("\n// takes %d steps and calls \"Rec_LastGB\" (%d):", 4305 nwalk, tp_deg+1); 4306 3974 4307 G = Rec_LastGB(G,curr_weight, orig_target_weight, tp_deg+1,nnwinC); 3975 4308 newRing = currRing; … … 4005 4338 { 4006 4339 // nOverflow_Error = Overflow_Error; 4007 //Print("\n// takes %d steps and calls \"Rec_LastGB (%d):", tp_deg+1);4340 Print("\n// takes %d steps and calls \"Rec_LastGB (%d):", tp_deg+1); 4008 4341 tproc=tproc+clock()-tinput; 4009 4342 F1 = Rec_LastGB(F1,curr_weight, orig_target_weight, tp_deg+1,nnwinC); … … 4059 4392 Overflow_Error=nError; 4060 4393 } 4061 // Print("\n// \"Rec_LastGB\" (%d) took %d steps and %.2f sec.Overflow_Error (%d)", tp_deg, nwalk, ((double) tproc)/1000000, nOverflow_Error); 4394 #ifdef TIME_TEST 4395 Print("\n// \"Rec_LastGB\" (%d) took %d steps and %.2f sec.Overflow_Error (%d)", tp_deg, nwalk, ((double) tproc)/1000000, nOverflow_Error); 4396 #endif 4062 4397 return(result); 4063 4398 } … … 4081 4416 //BOOLEAN nOverflow_Error = FALSE; 4082 4417 //Print("// pSetm_Error = (%d)", ErrorCheck()); 4083 4418 #ifdef TIME_TEST 4084 4419 xtif=0; xtstd=0; xtlift=0; xtred=0; xtnw=0; xtextra=0; 4085 4420 xftinput = clock(); 4086 4421 clock_t tostd, tproc; 4087 4422 #endif 4088 4423 nstep = 0; 4089 4424 int i, nV = currRing->N; … … 4096 4431 intvec* ivNull = new intvec(nV); 4097 4432 intvec* next_weight; 4098 #if 0 4099 intvec* extra_curr_weight = new intvec(nV); 4100 #endif 4433 //intvec* extra_curr_weight = new intvec(nV); 4101 4434 //intvec* hilb_func; 4102 4435 intvec* exivlp = Mivlp(nV); 4103 4104 4436 ring XXRing = currRing; 4105 4437 4106 4438 //Print("\n// ring r_input = %s;", rString(currRing)); 4439 #ifdef TIME_TEST 4107 4440 to = clock(); 4441 #endif 4108 4442 /* compute the reduced Groebner basis of the given ideal w.r.t. 4109 4443 a "fast" monomial order, e.g. degree reverse lex. order (dp) */ 4110 4444 G = MstdCC(Go); 4445 #ifdef TIME_TEST 4111 4446 tostd=clock()-to; 4112 4447 4113 /*4114 4448 Print("\n// Computation of the first std took = %.2f sec", 4115 4449 ((double) tostd)/1000000); 4116 */ 4450 #endif 4117 4451 if(currRing->order[0] == ringorder_a) 4118 4452 { … … 4123 4457 nwalk ++; 4124 4458 nstep ++; 4459 #ifdef TIME_TEST 4125 4460 to = clock(); 4461 #endif 4126 4462 /* compute an initial form ideal of <G> w.r.t. "curr_vector" */ 4127 4463 Gomega = MwalkInitialForm(G, curr_weight); 4464 #ifdef TIME_TEST 4128 4465 xtif=xtif+clock()-to; 4129 #if 0 4466 #endif 4467 /* 4130 4468 if(Overflow_Error == TRUE) 4131 4469 { … … 4135 4473 goto LAST_GB_ALT2; 4136 4474 } 4137 #endif 4475 */ 4138 4476 oldRing = currRing; 4139 4477 … … 4145 4483 else 4146 4484 { 4147 rChangeCurrRing(VMrDefault(curr_weight)); // Aenderung4485 rChangeCurrRing(VMrDefault(curr_weight)); 4148 4486 } 4149 4487 newRing = currRing; 4150 4488 Gomega1 = idrMoveR(Gomega, oldRing,currRing); 4489 #ifdef TIME_TEST 4151 4490 to = clock(); 4491 #endif 4152 4492 /* compute a reduced Groebner basis of <Gomega> w.r.t. "newRing" */ 4153 4493 M = MstdhomCC(Gomega1); 4494 #ifdef TIME_TEST 4154 4495 xtstd=xtstd+clock()-to; 4496 #endif 4155 4497 /* change the ring to oldRing */ 4156 4498 rChangeCurrRing(oldRing); 4157 4499 M1 = idrMoveR(M, newRing,currRing); 4158 4500 Gomega2 = idrMoveR(Gomega1, newRing,currRing); 4159 4501 #ifdef TIME_TEST 4160 4502 to = clock(); 4503 #endif 4161 4504 /* compute the reduced Groebner basis of <G> w.r.t. "newRing" 4162 4505 by the liftig process */ 4163 4506 F = MLifttwoIdeal(Gomega2, M1, G); 4507 #ifdef TIME_TEST 4164 4508 xtlift=xtlift+clock()-to; 4509 #endif 4165 4510 idDelete(&M1); 4166 4511 idDelete(&Gomega2); … … 4170 4515 rChangeCurrRing(newRing); 4171 4516 F1 = idrMoveR(F, oldRing,currRing); 4172 4517 #ifdef TIME_TEST 4173 4518 to = clock(); 4519 #endif 4174 4520 /* reduce the Groebner basis <G> w.r.t. newRing */ 4175 4521 G = kInterRedCC(F1, NULL); 4522 #ifdef TIME_TEST 4176 4523 xtred=xtred+clock()-to; 4524 #endif 4177 4525 idDelete(&F1); 4178 4526 … … 4181 4529 4182 4530 NEXT_VECTOR: 4531 #ifdef TIME_TEST 4183 4532 to = clock(); 4533 #endif 4184 4534 /* compute a next weight vector */ 4185 4535 next_weight = MkInterRedNextWeight(curr_weight,target_weight, G); 4536 #ifdef TIME_TEST 4186 4537 xtnw=xtnw+clock()-to; 4538 #endif 4187 4539 #ifdef PRINT_VECTORS 4188 4540 MivString(curr_weight, target_weight, next_weight); … … 4228 4580 // LAST_GB_ALT2: 4229 4581 //nOverflow_Error = Overflow_Error; 4582 #ifdef TIME_TEST 4230 4583 tproc = clock()-xftinput; 4584 #endif 4231 4585 //Print("\n// takes %d steps and calls the recursion of level 2:", nwalk); 4232 4586 /* call the changed perturbation walk algorithm with degree 2 */ … … 4255 4609 4256 4610 #ifdef TIME_TEST 4257 // Print("\n// \"Main procedure\" took %d steps dnd %.2f sec. Overflow_Error (%d)", nwalk, ((double) tproc)/1000000, nOverflow_Error); 4611 Print("\n// \"Main procedure\" took %d steps dnd %.2f sec. Overflow_Error (%d)", 4612 nwalk, ((double) tproc)/1000000, nOverflow_Error); 4258 4613 4259 4614 TimeStringFractal(xftinput, tostd, xtif, xtstd, xtextra,xtlift, xtred,xtnw); … … 4287 4642 intvec* Xivlp; 4288 4643 4289 #if 0 4644 4290 4645 /******************************** 4291 4646 * compute a next weight vector * 4292 4647 ********************************/ 4293 static intvec* MWalkRandomNextWeight(ideal G, intvec* curr_weight, intvec* target_weight, int weight_rad, int pert_deg) 4648 static intvec* MWalkRandomNextWeight(ideal G, intvec* orig_M, intvec* target_weight, 4649 int weight_rad, int pert_deg) 4294 4650 { 4295 int i, weight_norm; 4296 int nV = currRing->N; 4297 intvec* next_weight2; 4651 assume(currRing != NULL && orig_M != NULL && 4652 target_weight != NULL && G->m[0] != NULL); 4653 4654 //BOOLEAN nError = Overflow_Error; 4655 Overflow_Error = FALSE; 4656 4657 BOOLEAN found_random_weight = FALSE; 4658 int i,nV = currRing->N; 4659 intvec* curr_weight = new intvec(nV); 4660 4661 for(i=0; i<nV; i++) 4662 { 4663 (*curr_weight)[i] = (*orig_M)[i]; 4664 } 4665 4666 int k=0,weight_norm; 4667 intvec* next_weight; 4668 intvec* next_weight1 = MkInterRedNextWeight(curr_weight,target_weight,G); 4669 intvec* next_weight2 = new intvec(nV); 4298 4670 intvec* next_weight22 = new intvec(nV); 4299 intvec* next_weight = MwalkNextWeightCC(curr_weight,target_weight, G); 4300 if(MivComp(next_weight, target_weight) == 1) 4301 { 4302 return(next_weight); 4303 } 4304 else 4305 { 4306 //compute a perturbed next weight vector "next_weight1" 4307 intvec* next_weight1 = MkInterRedNextWeight(MPertVectors(G, MivMatrixOrder(curr_weight), pert_deg), target_weight, G); 4308 //Print("\n // size of next_weight1 = %d", sizeof((*next_weight1))); 4309 4310 //compute a random next weight vector "next_weight2" 4311 while(1) 4312 { 4313 weight_norm = 0; 4314 while(weight_norm == 0) 4671 intvec* result = new intvec(nV); 4672 intvec* curr_weight1; 4673 ideal G_test, G_test1, G_test2; 4674 4675 //try to find a random next weight vector "next_weight2" 4676 if(weight_rad > 0){ while(k<10) 4677 { 4678 weight_norm = 0; 4679 while(weight_norm == 0) 4680 { 4681 4682 for(i=0; i<nV; i++) 4683 { 4684 (*next_weight2)[i] = rand() % 60000 - 30000; 4685 weight_norm = weight_norm + (*next_weight2)[i]*(*next_weight2)[i]; 4686 } 4687 weight_norm = 1 + floor(sqrt(weight_norm)); 4688 } 4689 4690 for(i=0; i<nV; i++) 4691 { 4692 if((*next_weight2)[i] < 0) 4693 { 4694 (*next_weight2)[i] = 1 + (*curr_weight)[i] + floor(weight_rad*(*next_weight2)[i]/weight_norm); 4695 } 4696 else 4697 { 4698 (*next_weight2)[i] = (*curr_weight)[i] + floor(weight_rad*(*next_weight2)[i]/weight_norm); 4699 } 4700 } 4701 4702 if(test_w_in_ConeCC(G,next_weight2) == 1) 4703 { 4704 if(maxlengthpoly(MwalkInitialForm(G,next_weight2))<2) 4705 { 4706 next_weight2 = MkInterRedNextWeight(next_weight2,target_weight,G); 4707 } 4708 /* 4709 if(MivAbsMax(next_weight2)>1147483647) 4315 4710 { 4316 4711 for(i=0; i<nV; i++) 4317 4712 { 4318 //Print("\n// next_weight[%d] = %d", i, (*next_weight)[i]); 4319 (*next_weight22)[i] = rand() % 60000 - 30000; 4320 weight_norm = weight_norm + (*next_weight22)[i]*(*next_weight22)[i]; 4713 (*next_weight22)[i] = (*next_weight2)[i]; 4321 4714 } 4322 weight_norm = 1 + floor(sqrt(weight_norm)); 4323 } 4324 4325 for(i=nV-1; i>=0; i--) 4326 { 4327 if((*next_weight22)[i] < 0) 4715 i = 0; 4716 // reduce the size of the maximal entry of the vector 4717 while(test_w_in_ConeCC(G,next_weight22) == 1) 4328 4718 { 4329 (*next_weight22)[i] = 1 + (*curr_weight)[i] + floor(weight_rad*(*next_weight22)[i]/weight_norm); 4719 (*next_weight2)[i] = (*next_weight22)[i]; 4720 i = MivAbsMaxArg(next_weight22); 4721 (*next_weight22)[i] = floor(0.1*(*next_weight22)[i] + 0.5); 4722 } 4723 delete next_weight22; 4724 } 4725 */ 4726 G_test2 = MwalkInitialForm(G, next_weight2); 4727 found_random_weight = TRUE; 4728 break; 4729 } 4730 k++; 4731 }} 4732 Print("\n MWalkRandomNextWeight: compute perurbation...\n"); 4733 // compute "perturbed" next weight vector 4734 if(pert_deg > 1) 4735 { 4736 curr_weight1 = MPertVectors(G,orig_M,pert_deg); 4737 next_weight = MkInterRedNextWeight(curr_weight1,target_weight,G); 4738 delete curr_weight1; 4739 } 4740 else 4741 { 4742 next_weight = MkInterRedNextWeight(curr_weight,target_weight,G); 4743 } 4744 if(MivSame(curr_weight,next_weight)==1 || Overflow_Error == TRUE) 4745 { 4746 Overflow_Error = FALSE; 4747 delete next_weight; 4748 next_weight = MkInterRedNextWeight(curr_weight,target_weight,G); 4749 } 4750 G_test=MwalkInitialForm(G,next_weight); 4751 G_test1=MwalkInitialForm(G,next_weight1); 4752 Print("\n MWalkRandomNextWeight: finished...\n"); 4753 // compare next weights 4754 if(Overflow_Error == FALSE) 4755 { 4756 if(found_random_weight == TRUE) 4757 { 4758 // random next weight vector found 4759 if(G_test1->m[0] != NULL && maxlengthpoly(G_test1) < maxlengthpoly(G_test)) 4760 { 4761 if(G_test2->m[0] != NULL && maxlengthpoly(G_test2) < maxlengthpoly(G_test1)) 4762 { 4763 for(i=0; i<nV; i++) 4764 { 4765 (*result)[i] = (*next_weight2)[i]; 4766 } 4330 4767 } 4331 4768 else 4332 4769 { 4333 (*next_weight22)[i] = (*curr_weight)[i] + floor(weight_rad*(*next_weight22)[i]/weight_norm); 4770 for(i=0; i<nV; i++) 4771 { 4772 (*result)[i] = (*next_weight1)[i]; 4773 } 4774 } 4775 } 4776 else 4777 { 4778 if(G_test2->m[0] != NULL && maxlengthpoly(G_test2) < maxlengthpoly(G_test)) 4779 { 4780 for(i=0; i<nV; i++) 4781 { 4782 (*result)[i] = (*next_weight2)[i]; 4783 } 4334 4784 } 4335 //Print("\n// next_weight22[%d] = %d", i, (*next_weight22)[i]); 4336 } 4337 4338 if(test_w_in_ConeCC(G, next_weight22) == 1) 4339 { 4340 //Print("\n//MWalkRandomNextWeight: next_weight2 im Kegel\n"); 4341 next_weight2 = MkInterRedNextWeight(next_weight22, target_weight, G); 4342 delete next_weight22; 4343 break; 4344 } 4345 } 4346 intvec* result = new intvec(nV); 4347 ideal G_test = MwalkInitialForm(G, next_weight); 4348 ideal G_test1 = MwalkInitialForm(G, next_weight1); 4349 ideal G_test2 = MwalkInitialForm(G, next_weight2); 4350 4351 // compare next_weights 4352 if(IDELEMS(G_test1) < IDELEMS(G_test)) 4353 { 4354 if(IDELEMS(G_test2) <= IDELEMS(G_test1)) // |G_test2| <= |G_test1| < |G_test| 4355 { 4356 for(i=0; i<nV; i++) 4785 else 4357 4786 { 4358 (*result)[i] = (*next_weight2)[i]; 4787 for(i=0; i<nV; i++) 4788 { 4789 (*result)[i] = (*next_weight)[i]; 4790 } 4359 4791 } 4360 4792 } 4361 else // |G_test1| < |G_test|, |G_test1| < |G_test2| 4362 { 4363 for(i=0; i<nV; i++) 4793 } 4794 else 4795 { 4796 // no random next weight vector found 4797 if(G_test1->m[0] != NULL && maxlengthpoly(G_test1) < maxlengthpoly(G_test)) 4798 { 4799 for(i=0; i<nV; i++) 4364 4800 { 4365 4801 (*result)[i] = (*next_weight1)[i]; 4366 4802 } 4367 4803 } 4368 } 4369 else 4370 { 4371 if(IDELEMS(G_test2) <= IDELEMS(G_test)) // |G_test2| <= |G_test| <= |G_test1| 4372 { 4373 for(i=0; i<nV; i++) 4374 { 4375 (*result)[i] = (*next_weight2)[i]; 4376 } 4377 } 4378 else // |G_test| <= |G_test1|, |G_test| < |G_test2| 4804 else 4379 4805 { 4380 4806 for(i=0; i<nV; i++) … … 4384 4810 } 4385 4811 } 4386 delete next_weight; 4387 delete next_weight1; 4388 idDelete(&G_test); 4389 idDelete(&G_test1); 4390 idDelete(&G_test2); 4391 if(test_w_in_ConeCC(G, result) == 1) 4392 { 4393 delete next_weight2; 4394 return result; 4395 } 4396 else 4397 { 4398 delete result; 4399 return next_weight2; 4400 } 4401 } 4402 } 4403 #endif 4404 4405 /******************************** 4406 * compute a next weight vector * 4407 ********************************/ 4408 static intvec* MWalkRandomNextWeight(ideal G, intvec* curr_weight, intvec* target_weight, int weight_rad, int pert_deg) 4409 { 4410 int i, weight_norm; 4411 //int randCount=0; 4412 int nV = currRing->N; 4413 intvec* next_weight2; 4414 intvec* next_weight22 = new intvec(nV); 4415 intvec* result = new intvec(nV); 4416 4417 //compute a perturbed next weight vector "next_weight1" 4418 //intvec* next_weight1 = MkInterRedNextWeight(MPertVectors(G,MivMatrixOrderRefine(curr_weight,target_weight),pert_deg),target_weight,G); 4419 intvec* next_weight1 =MkInterRedNextWeight(curr_weight,target_weight,G); 4420 //compute a random next weight vector "next_weight2" 4421 while(1) 4422 { 4423 weight_norm = 0; 4424 while(weight_norm == 0) 4425 { 4426 for(i=0; i<nV; i++) 4427 { 4428 (*next_weight22)[i] = rand() % 60000 - 30000; 4429 weight_norm = weight_norm + (*next_weight22)[i]*(*next_weight22)[i]; 4430 } 4431 weight_norm = 1 + floor(sqrt(weight_norm)); 4432 } 4433 for(i=0; i<nV; i++) 4434 { 4435 if((*next_weight22)[i] < 0) 4436 { 4437 (*next_weight22)[i] = 1 + (*curr_weight)[i] + floor(weight_rad*(*next_weight22)[i]/weight_norm); 4438 } 4439 else 4440 { 4441 (*next_weight22)[i] = (*curr_weight)[i] + floor(weight_rad*(*next_weight22)[i]/weight_norm); 4442 } 4443 } 4444 if(test_w_in_ConeCC(G, next_weight22) == 1) 4445 { 4446 next_weight2 = MkInterRedNextWeight(next_weight22,target_weight,G); 4447 delete next_weight22; 4448 break; 4449 } 4450 } 4451 // compute "usual" next weight vector 4452 intvec* next_weight = MwalkNextWeightCC(curr_weight,target_weight, G); 4453 ideal G_test = MwalkInitialForm(G, next_weight); 4454 ideal G_test2 = MwalkInitialForm(G, next_weight2); 4455 4456 // compare next weights 4457 if(Overflow_Error == FALSE) 4458 { 4459 ideal G_test1 = MwalkInitialForm(G, next_weight1); 4460 if(IDELEMS(G_test1) < IDELEMS(G_test)) 4461 { 4462 if(IDELEMS(G_test2) < IDELEMS(G_test1)) 4463 { 4464 // |G_test2| < |G_test1| < |G_test| 4465 for(i=0; i<nV; i++) 4812 } 4813 else 4814 { 4815 Overflow_Error = FALSE; 4816 if(found_random_weight == TRUE) 4817 { 4818 if(G_test2->m[0] != NULL && maxlengthpoly(G_test2) < maxlengthpoly(G_test)) 4819 { 4820 for(i=1; i<nV; i++) 4466 4821 { 4467 4822 (*result)[i] = (*next_weight2)[i]; … … 4470 4825 else 4471 4826 { 4472 // |G_test1| < |G_test|, |G_test1| <= |G_test2|4473 for(i=0; i<nV; i++)4474 {4475 (*result)[i] = (*next_weight1)[i];4476 }4477 }4478 }4479 else4480 {4481 if(IDELEMS(G_test2) < IDELEMS(G_test)) // |G_test2| < |G_test| <= |G_test1|4482 {4483 for(i=0; i<nV; i++)4484 {4485 (*result)[i] = (*next_weight2)[i];4486 }4487 }4488 else4489 {4490 // |G_test| < |G_test1|, |G_test| <= |G_test2|4491 4827 for(i=0; i<nV; i++) 4492 4828 { … … 4495 4831 } 4496 4832 } 4497 idDelete(&G_test1);4498 }4499 else4500 {4501 Overflow_Error = FALSE;4502 if(IDELEMS(G_test2) < IDELEMS(G_test))4503 {4504 for(i=1; i<nV; i++)4505 {4506 (*result)[i] = (*next_weight2)[i];4507 }4508 }4509 4833 else 4510 4834 { … … 4515 4839 } 4516 4840 } 4841 // delete curr_weight1; 4842 delete next_weight; 4843 delete next_weight2; 4517 4844 idDelete(&G_test); 4518 idDelete(&G_test2); 4519 if(test_w_in_ConeCC(G, result) == 1) 4520 { 4521 delete next_weight2; 4522 delete next_weight; 4845 idDelete(&G_test1); 4846 if(found_random_weight == TRUE) 4847 { 4848 idDelete(&G_test2); 4849 } 4850 if(test_w_in_ConeCC(G, result) == 1 && MivSame(curr_weight,result)==0) 4851 { 4852 delete curr_weight; 4523 4853 delete next_weight1; 4524 4854 return result; … … 4526 4856 else 4527 4857 { 4858 delete curr_weight; 4528 4859 delete result; 4529 delete next_weight2; 4530 delete next_weight1; 4531 return next_weight; 4860 return next_weight1; 4532 4861 } 4533 4862 } … … 4537 4866 * The procedur REC_GB_Mwalk computes a GB for <G> w.r.t. the weight order * 4538 4867 * otw, where G is a reduced GB w.r.t. the weight order cw. * 4539 * The new procedur Mwalk calls REC_GB.*4868 * The new procedure Mwalk calls REC_GB. * 4540 4869 ***************************************************************************/ 4541 4870 static ideal REC_GB_Mwalk(ideal G, intvec* curr_weight, intvec* orig_target_weight, … … 4575 4904 else 4576 4905 { 4577 rChangeCurrRing(VMrDefault(orig_target_weight)); // Aenderung4906 rChangeCurrRing(VMrDefault(orig_target_weight)); 4578 4907 } 4579 4908 TargetRing = currRing; … … 4646 4975 else 4647 4976 { 4648 rChangeCurrRing(VMrDefault(curr_weight)); // Aenderung4977 rChangeCurrRing(VMrDefault(curr_weight)); 4649 4978 } 4650 4979 newRing = currRing; … … 4755 5084 else 4756 5085 { 4757 rChangeCurrRing(VMrDefault(orig_target_weight)); // Aenderung5086 rChangeCurrRing(VMrDefault(orig_target_weight)); 4758 5087 } 4759 5088 F1 = idrMoveR(G, newRing,currRing); … … 4786 5115 else 4787 5116 { 4788 rChangeCurrRing(VMrDefault(orig_target_weight)); // Aenderung5117 rChangeCurrRing(VMrDefault(orig_target_weight)); 4789 5118 } 4790 5119 KSTD_Finish: … … 4840 5169 4841 5170 ideal Gomega, M, F, Gomega1, Gomega2, M1, F1, G; 4842 //ideal G1; 4843 //ring endRing; 5171 4844 5172 ring newRing, oldRing; 4845 5173 intvec* ivNull = new intvec(nV); … … 4883 5211 the recursive changed perturbation walk alg. */ 4884 5212 tim = clock(); 4885 /* 4886 Print("\n// **** Gr ᅵbnerwalk took %d steps and ", nwalk);5213 #ifdef CHECK_IDEAL_MWALK 5214 Print("\n// **** Groebnerwalk took %d steps and ", nwalk); 4887 5215 PrintS("\n// **** call the rec. Pert. Walk to compute a red GB of:"); 4888 id Elements(Gomega, "G_omega");4889 */ 5216 idString(Gomega, "Gomega"); 5217 #endif 4890 5218 4891 5219 if(MivSame(exivlp, target_weight)==1) … … 4893 5221 else 4894 5222 goto NORMAL_GW; 4895 /* 5223 #ifdef TIME_TEST 4896 5224 Print("\n// time for the last std(Gw) = %.2f sec", 4897 5225 ((double) (clock()-tim)/1000000)); 4898 PrintS("\n// ***************************************************\n"); 4899 */ 5226 #endif 5227 /* 4900 5228 #ifdef CHECK_IDEAL_MWALK 4901 5229 idElements(Gomega, "G_omega"); … … 4904 5232 //headidString(M, "M"); 4905 5233 #endif 5234 */ 4906 5235 to = clock(); 4907 5236 F = MLifttwoIdeal(Gomega, M, G); … … 4914 5243 oldRing = currRing; 4915 5244 4916 / * create a new ring newRing */5245 // create a new ring newRing 4917 5246 if (rParameter(currRing) != NULL) 4918 5247 { … … 4921 5250 else 4922 5251 { 4923 rChangeCurrRing(VMrDefault(curr_weight)); // Aenderung5252 rChangeCurrRing(VMrDefault(curr_weight)); 4924 5253 } 4925 5254 newRing = currRing; … … 4947 5276 else 4948 5277 { 4949 rChangeCurrRing(VMrDefault(curr_weight)); //Aenderung5278 rChangeCurrRing(VMrDefault(curr_weight)); 4950 5279 } 4951 5280 newRing = currRing; … … 4959 5288 M=kStd(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,curr_weight); 4960 5289 delete hilb_func; 4961 #endif // BUCHBERGER_ALG5290 #endif 4962 5291 tstd = tstd + clock() - to; 4963 5292 … … 4968 5297 4969 5298 to = clock(); 4970 // compute a representation of the generators of submod (M) with respect to those of mod (Gomega). Gomega is a reduced Groebner basis w.r.t. the current ring. 5299 // compute a representation of the generators of submod (M) with respect 5300 // to those of mod (Gomega). 5301 // Gomega is a reduced Groebner basis w.r.t. the current ring. 4971 5302 F = MLifttwoIdeal(Gomega2, M1, G); 4972 5303 tlift = tlift + clock() - to; … … 5018 5349 else 5019 5350 { 5020 rChangeCurrRing(VMrDefault(target_weight)); // Aenderung5351 rChangeCurrRing(VMrDefault(target_weight)); 5021 5352 } 5022 5353 F1 = idrMoveR(G, newRing,currRing); … … 5061 5392 } 5062 5393 5063 5064 5394 /******************************* 5065 5395 * THE GROEBNER WALK ALGORITHM * 5066 5396 *******************************/ 5067 ideal Mwalk(ideal Go, intvec* orig_M, intvec* target_M, ring baseRing) 5397 ideal Mwalk(ideal Go, intvec* orig_M, intvec* target_M, 5398 ring baseRing, int reduction, int printout) 5068 5399 { 5069 BITSET save1 = si_opt_1; // save current options 5070 //si_opt_1 &= (~Sy_bit(OPT_REDSB)); // no reduced Groebner basis 5071 //si_opt_1 &= (~Sy_bit(OPT_REDTAIL)); // not tail reductions 5072 //si_opt_1|=(Sy_bit(OPT_REDTAIL)|Sy_bit(OPT_REDSB)); 5400 // save current options 5401 BITSET save1 = si_opt_1; 5402 if(reduction == 0) 5403 { 5404 si_opt_1 &= (~Sy_bit(OPT_REDSB)); // no reduced Groebner basis 5405 si_opt_1 &= (~Sy_bit(OPT_REDTAIL)); // not tail reductions 5406 } 5073 5407 Set_Error(FALSE); 5074 5408 Overflow_Error = FALSE; 5409 //BOOLEAN endwalks = FALSE; 5075 5410 #ifdef TIME_TEST 5076 5411 clock_t tinput, tostd, tif=0, tstd=0, tlift=0, tred=0, tnw=0; … … 5080 5415 #endif 5081 5416 nstep=0; 5082 int i,nwalk ,endwalks = 0;5417 int i,nwalk; 5083 5418 int nV = baseRing->N; 5084 5419 5085 ideal Gomega, M, F, Gomega1, Gomega2, M1; //, F1;5420 ideal Gomega, M, F, FF, Gomega1, Gomega2, M1; 5086 5421 ring newRing; 5087 5422 ring XXRing = baseRing; 5423 ring targetRing; 5088 5424 intvec* ivNull = new intvec(nV); 5089 5425 intvec* curr_weight = new intvec(nV); 5090 5426 intvec* target_weight = new intvec(nV); 5091 5427 intvec* exivlp = Mivlp(nV); 5428 /* 5092 5429 intvec* tmp_weight = new intvec(nV); 5093 5430 for(i=0; i<nV; i++) 5094 5431 { 5095 (*tmp_weight)[i] = (*target_M)[i]; 5096 } 5432 (*tmp_weight)[i] = (*orig_M)[i]; 5433 } 5434 */ 5097 5435 for(i=0; i<nV; i++) 5098 5436 { … … 5112 5450 rComplete(currRing); 5113 5451 #ifdef CHECK_IDEAL_MWALK 5114 idString(Go,"Go"); 5115 #endif 5452 if(printout > 2) 5453 { 5454 idString(Go,"//** Mwalk: Go"); 5455 } 5456 #endif 5457 5458 if(target_M->length() == nV) 5459 { 5460 // define the target ring 5461 targetRing = VMrDefault(target_weight); 5462 } 5463 else 5464 { 5465 targetRing = VMatrDefault(target_M); 5466 } 5467 if(orig_M->length() == nV) 5468 { 5469 // define a new ring with ordering "(a(curr_weight),lp) 5470 newRing = VMrDefault(curr_weight); 5471 } 5472 else 5473 { 5474 newRing = VMatrDefault(orig_M); 5475 } 5476 rChangeCurrRing(newRing); 5477 5116 5478 #ifdef TIME_TEST 5117 5479 to = clock(); 5118 5480 #endif 5119 if(orig_M->length() == nV)5120 {5121 newRing = VMrDefault(curr_weight); // define a new ring with ordering "(a(curr_weight),lp)5122 }5123 else5124 {5125 newRing = VMatrDefault(orig_M);5126 }5127 rChangeCurrRing(newRing);5128 5481 ideal G = MstdCC(idrMoveR(Go,baseRing,currRing)); 5482 #ifdef TIME_TEST 5483 tostd = clock()-to; 5484 #endif 5485 5129 5486 baseRing = currRing; 5130 #ifdef TIME_TEST5131 tostd = clock()-to;5132 #endif5133 5134 5487 nwalk = 0; 5488 5135 5489 while(1) 5136 5490 { 5137 5491 nwalk ++; 5138 5492 nstep ++; 5493 //compute an initial form ideal of <G> w.r.t. "curr_vector" 5139 5494 #ifdef TIME_TEST 5140 5495 to = clock(); 5141 5496 #endif 5497 Gomega = MwalkInitialForm(G, curr_weight); 5498 #ifdef TIME_TEST 5499 tif = tif + clock()-to; 5500 #endif 5501 5142 5502 #ifdef CHECK_IDEAL_MWALK 5143 idString(G,"G"); 5144 #endif 5145 Gomega = MwalkInitialForm(G, curr_weight); // compute an initial form ideal of <G> w.r.t. "curr_vector" 5146 #ifdef TIME_TEST 5147 tif = tif + clock()-to; //time for computing initial form ideal 5148 #endif 5149 #ifdef CHECK_IDEAL_MWALK 5150 idString(Gomega,"Gomega"); 5151 #endif 5503 if(printout > 1) 5504 { 5505 idString(Gomega,"//** Mwalk: Gomega"); 5506 } 5507 #endif 5508 5509 if(reduction == 0) 5510 { 5511 FF = middleOfCone(G,Gomega); 5512 if(FF != NULL) 5513 { 5514 idDelete(&G); 5515 G = idCopy(FF); 5516 idDelete(&FF); 5517 goto NEXT_VECTOR; 5518 } 5519 } 5520 5152 5521 #ifndef BUCHBERGER_ALG 5153 5522 if(isNolVector(curr_weight) == 0) 5154 5523 { 5155 5524 hilb_func = hFirstSeries(Gomega,NULL,NULL,curr_weight,currRing); 5156 } 5525 } 5157 5526 else 5158 5527 { … … 5160 5529 } 5161 5530 #endif 5531 5162 5532 if(nwalk == 1) 5163 5533 { 5164 5534 if(orig_M->length() == nV) 5165 5535 { 5166 newRing = VMrDefault(curr_weight); // define a new ring with ordering "(a(curr_weight),lp) 5536 // define a new ring with ordering "(a(curr_weight),lp) 5537 newRing = VMrDefault(curr_weight); 5167 5538 } 5168 5539 else … … 5175 5546 if(target_M->length() == nV) 5176 5547 { 5177 newRing = VMrRefine(curr_weight,target_weight); //define a new ring with ordering "(a(curr_weight),Wp(target_weight))" 5548 //define a new ring with ordering "(a(curr_weight),lp)" 5549 newRing = VMrDefault(curr_weight); 5178 5550 } 5179 5551 else 5180 5552 { 5553 //define a new ring with matrix ordering 5181 5554 newRing = VMatrRefine(target_M,curr_weight); 5182 5555 } … … 5200 5573 idSkipZeroes(M); 5201 5574 #ifdef CHECK_IDEAL_MWALK 5202 PrintS("\n//** Mwalk: computed M.\n"); 5203 idString(M, "M"); 5575 if(printout > 2) 5576 { 5577 idString(M, "//** Mwalk: M"); 5578 } 5204 5579 #endif 5205 5580 //change the ring to baseRing … … 5212 5587 to = clock(); 5213 5588 #endif 5214 // compute a representation of the generators of submod (M) with respect to those of mod (Gomega), where Gomega is a reduced Groebner basis w.r.t. the current ring 5589 // compute a representation of the generators of submod (M) with respect to those of mod (Gomega), 5590 // where Gomega is a reduced Groebner basis w.r.t. the current ring 5215 5591 F = MLifttwoIdeal(Gomega2, M1, G); 5216 5592 #ifdef TIME_TEST … … 5218 5594 #endif 5219 5595 #ifdef CHECK_IDEAL_MWALK 5220 idString(F, "F"); 5596 if(printout > 2) 5597 { 5598 idString(F, "//** Mwalk: F"); 5599 } 5600 #endif 5601 idDelete(&Gomega2); 5602 idDelete(&M1); 5603 5604 rChangeCurrRing(newRing); // change the ring to newRing 5605 G = idrMoveR(F,baseRing,currRing); 5606 idDelete(&F); 5607 idSkipZeroes(G); 5608 5609 #ifdef CHECK_IDEAL_MWALK 5610 if(printout > 2) 5611 { 5612 idString(G, "//** Mwalk: G"); 5613 } 5614 #endif 5615 5616 rChangeCurrRing(targetRing); 5617 G = idrMoveR(G,newRing,currRing); 5618 // test whether target cone is reached 5619 if(reduction !=0 && test_w_in_ConeCC(G,curr_weight) == 1) 5620 { 5621 baseRing = currRing; 5622 break; 5623 //endwalks = TRUE; 5624 } 5625 5626 rChangeCurrRing(newRing); 5627 G = idrMoveR(G,targetRing,currRing); 5628 baseRing = currRing; 5629 5630 NEXT_VECTOR: 5631 #ifdef TIME_TEST 5632 to = clock(); 5633 #endif 5634 intvec* next_weight = MwalkNextWeightCC(curr_weight,target_weight,G); 5635 #ifdef TIME_TEST 5636 tnw = tnw + clock() - to; 5637 #endif 5638 #ifdef PRINT_VECTORS 5639 if(printout > 0) 5640 { 5641 MivString(curr_weight, target_weight, next_weight); 5642 } 5643 #endif 5644 if(MivComp(target_weight,curr_weight) == 1)// || endwalks == TRUE) 5645 { 5646 /* 5647 #ifdef CHECK_IDEAL_MWALK 5648 if(printout > 0) 5649 { 5650 PrintS("\n//** Mwalk: entering last cone.\n"); 5651 } 5652 #endif 5653 5654 Gomega = MwalkInitialForm(G, curr_weight); // compute an initial form ideal of <G> w.r.t. "curr_vector" 5655 if(target_M->length() == nV) 5656 { 5657 newRing = VMrDefault(target_weight); // define a new ring with ordering "(a(curr_weight),lp) 5658 } 5659 else 5660 { 5661 newRing = VMatrDefault(target_M); 5662 } 5663 rChangeCurrRing(newRing); 5664 Gomega1 = idrMoveR(Gomega, baseRing,currRing); 5665 idDelete(&Gomega); 5666 #ifdef CHECK_IDEAL_MWALK 5667 if(printout > 1) 5668 { 5669 idString(Gomega1, "//** Mwalk: Gomega"); 5670 } 5671 PrintS("\n //** Mwalk: kStd(Gomega)"); 5672 #endif 5673 M = kStd(Gomega1,NULL,testHomog,NULL,NULL,0,0,NULL); 5674 #ifdef CHECK_IDEAL_MWALK 5675 if(printout > 1) 5676 { 5677 idString(M,"//** Mwalk: M"); 5678 } 5679 #endif 5680 rChangeCurrRing(baseRing); 5681 M1 = idrMoveR(M, newRing,currRing); 5682 idDelete(&M); 5683 Gomega2 = idrMoveR(Gomega1, newRing,currRing); 5684 idDelete(&Gomega1); 5685 //PrintS("\n //** Mwalk: MLifttwoIdeal"); 5686 F = MLifttwoIdeal(Gomega2, M1, G); 5687 #ifdef CHECK_IDEAL_MWALK 5688 if(printout > 2) 5689 { 5690 idString(F,"//** Mwalk: F"); 5691 } 5692 #endif 5693 idDelete(&Gomega2); 5694 idDelete(&M1); 5695 rChangeCurrRing(newRing); // change the ring to newRing 5696 G = idrMoveR(F,baseRing,currRing); 5697 idDelete(&F); 5698 baseRing = currRing; 5699 idSkipZeroes(G); 5700 #ifdef TIME_TEST 5701 to = clock(); 5702 #endif 5703 //PrintS("\n //**Mwalk: Interreduce"); 5704 //interreduce the Groebner basis <G> w.r.t. currRing 5705 //G = kInterRedCC(G,NULL); 5706 #ifdef TIME_TEST 5707 tred = tred + clock() - to; 5708 #endif 5709 idSkipZeroes(G); 5710 delete next_weight; 5711 */ 5712 break; 5713 } 5714 5715 for(i=nV-1; i>=0; i--) 5716 { 5717 //(*tmp_weight)[i] = (*curr_weight)[i]; 5718 (*curr_weight)[i] = (*next_weight)[i]; 5719 } 5720 delete next_weight; 5721 } 5722 rChangeCurrRing(XXRing); 5723 ideal result = idrMoveR(G,baseRing,currRing); 5724 idDelete(&Go); 5725 idDelete(&G); 5726 //delete tmp_weight; 5727 delete ivNull; 5728 delete exivlp; 5729 #ifndef BUCHBERGER_ALG 5730 delete last_omega; 5731 #endif 5732 #ifdef TIME_TEST 5733 TimeString(tinput, tostd, tif, tstd, tlift, tred, tnw, nstep); 5734 //Print("\n// pSetm_Error = (%d)", ErrorCheck()); 5735 //Print("\n// Overflow_Error? (%d)\n", Overflow_Error); 5736 #endif 5737 Print("\n//** Mwalk: Groebner Walk took %d steps.\n", nstep); 5738 si_opt_1 = save1; //set original options 5739 return(result); 5740 } 5741 5742 // THE RANDOM WALK ALGORITHM 5743 ideal Mrwalk(ideal Go, intvec* orig_M, intvec* target_M, int weight_rad, int pert_deg, 5744 int reduction, int printout) 5745 { 5746 BITSET save1 = si_opt_1; // save current options 5747 if(reduction == 0) 5748 { 5749 si_opt_1 &= (~Sy_bit(OPT_REDSB)); // no reduced Groebner basis 5750 si_opt_1 &= (~Sy_bit(OPT_REDTAIL)); // not tail reductions 5751 } 5752 5753 Set_Error(FALSE); 5754 Overflow_Error = FALSE; 5755 BOOLEAN endwalks = FALSE; 5756 #ifdef TIME_TEST 5757 clock_t tinput, tostd, tif=0, tstd=0, tlift=0, tred=0, tnw=0; 5758 xtif=0; xtstd=0; xtlift=0; xtred=0; xtnw=0; 5759 tinput = clock(); 5760 clock_t tim; 5761 #endif 5762 nstep=0; 5763 int i,nwalk;//polylength; 5764 int nV = currRing->N; 5765 5766 //check that weight radius is valid 5767 if(weight_rad < 0) 5768 { 5769 Werror("Invalid radius.\n"); 5770 return NULL; 5771 } 5772 5773 //check that perturbation degree is valid 5774 if(pert_deg > nV || pert_deg < 1) 5775 { 5776 Werror("Invalid perturbation degree.\n"); 5777 return NULL; 5778 } 5779 5780 ideal Gomega, M, F,FF, Gomega1, Gomega2, M1; 5781 ring newRing; 5782 ring targetRing; 5783 ring baseRing = currRing; 5784 ring XXRing = currRing; 5785 intvec* iv_M; 5786 intvec* ivNull = new intvec(nV); 5787 intvec* curr_weight = new intvec(nV); 5788 intvec* target_weight = new intvec(nV); 5789 intvec* next_weight= new intvec(nV); 5790 5791 for(i=0; i<nV; i++) 5792 { 5793 (*curr_weight)[i] = (*orig_M)[i]; 5794 (*target_weight)[i] = (*target_M)[i]; 5795 } 5796 5797 #ifndef BUCHBERGER_ALG 5798 intvec* hilb_func; 5799 // to avoid (1,0,...,0) as the target vector 5800 intvec* last_omega = new intvec(nV); 5801 for(i=nV-1; i>0; i--) 5802 { 5803 (*last_omega)[i] = 1; 5804 } 5805 (*last_omega)[0] = 10000; 5806 #endif 5807 rComplete(currRing); 5808 5809 if(target_M->length() == nV) 5810 { 5811 targetRing = VMrDefault(target_weight); // define the target ring 5812 } 5813 else 5814 { 5815 targetRing = VMatrDefault(target_M); 5816 } 5817 if(orig_M->length() == nV) 5818 { 5819 newRing = VMrDefault(curr_weight); // define a new ring with ordering "(a(curr_weight),lp) 5820 } 5821 else 5822 { 5823 newRing = VMatrDefault(orig_M); 5824 } 5825 rChangeCurrRing(newRing); 5826 #ifdef TIME_TEST 5827 to = clock(); 5828 #endif 5829 ideal G = MstdCC(idrMoveR(Go,baseRing,currRing)); 5830 #ifdef TIME_TEST 5831 tostd = clock()-to; 5832 #endif 5833 baseRing = currRing; 5834 nwalk = 0; 5835 5836 #ifdef TIME_TEST 5837 to = clock(); 5838 #endif 5839 Gomega = MwalkInitialForm(G, curr_weight); // compute an initial form ideal of <G> w.r.t. "curr_vector" 5840 #ifdef TIME_TEST 5841 tif = tif + clock()-to; //time for computing initial form ideal 5842 #endif 5843 5844 while(1) 5845 { 5846 nwalk ++; 5847 nstep ++; 5848 #ifdef CHECK_IDEAL_MWALK 5849 if(printout > 1) 5850 { 5851 idString(Gomega,"//** Mrwalk: Gomega"); 5852 } 5853 #endif 5854 if(reduction == 0) 5855 { 5856 FF = middleOfCone(G,Gomega); 5857 if(FF != NULL) 5858 { 5859 idDelete(&G); 5860 G = idCopy(FF); 5861 idDelete(&FF); 5862 goto NEXT_VECTOR; 5863 } 5864 } 5865 #ifndef BUCHBERGER_ALG 5866 if(isNolVector(curr_weight) == 0) 5867 { 5868 hilb_func = hFirstSeries(Gomega,NULL,NULL,curr_weight,currRing); 5869 } 5870 else 5871 { 5872 hilb_func = hFirstSeries(Gomega,NULL,NULL,last_omega,currRing); 5873 } 5874 #endif 5875 if(nwalk == 1) 5876 { 5877 if(orig_M->length() == nV) 5878 { 5879 newRing = VMrDefault(curr_weight); // define a new ring with ordering "(a(curr_weight),lp) 5880 } 5881 else 5882 { 5883 newRing = VMatrDefault(orig_M); 5884 } 5885 } 5886 else 5887 { 5888 if(target_M->length() == nV) 5889 { 5890 newRing = VMrDefault(curr_weight); // define a new ring with ordering "(a(curr_weight),lp) 5891 } 5892 else 5893 { 5894 newRing = VMatrRefine(target_M,curr_weight); 5895 } 5896 } 5897 rChangeCurrRing(newRing); 5898 Gomega1 = idrMoveR(Gomega, baseRing,currRing); 5899 idDelete(&Gomega); 5900 // compute a reduced Groebner basis of <Gomega> w.r.t. "newRing" 5901 #ifdef TIME_TEST 5902 to = clock(); 5903 #endif 5904 #ifndef BUCHBERGER_ALG 5905 M=kStd(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,curr_weight); 5906 delete hilb_func; 5907 #else 5908 M = kStd(Gomega1,NULL,testHomog,NULL,NULL,0,0,NULL); 5909 #endif 5910 #ifdef TIME_TEST 5911 tstd = tstd + clock() - to; 5912 #endif 5913 idSkipZeroes(M); 5914 #ifdef CHECK_IDEAL_MWALK 5915 if(printout > 2) 5916 { 5917 idString(M, "//** Mrwalk: M"); 5918 } 5919 #endif 5920 //change the ring to baseRing 5921 rChangeCurrRing(baseRing); 5922 M1 = idrMoveR(M, newRing,currRing); 5923 idDelete(&M); 5924 Gomega2 = idrMoveR(Gomega1, newRing,currRing); 5925 idDelete(&Gomega1); 5926 #ifdef TIME_TEST 5927 to = clock(); 5928 #endif 5929 // compute a representation of the generators of submod (M) with respect to those of mod (Gomega), 5930 // where Gomega is a reduced Groebner basis w.r.t. the current ring 5931 F = MLifttwoIdeal(Gomega2, M1, G); 5932 #ifdef TIME_TEST 5933 tlift = tlift + clock() - to; 5934 #endif 5935 #ifdef CHECK_IDEAL_MWALK 5936 if(printout > 2) 5937 { 5938 idString(F,"//** Mrwalk: F"); 5939 } 5221 5940 #endif 5222 5941 idDelete(&Gomega2); … … 5228 5947 #ifdef TIME_TEST 5229 5948 to = clock(); 5230 #endif5231 //G = kStd(F1,NULL,testHomog,NULL,NULL,0,0,NULL);5232 #ifdef TIME_TEST5233 5949 tstd = tstd + clock() - to; 5234 5950 #endif 5235 5951 idSkipZeroes(G); 5236 5952 #ifdef CHECK_IDEAL_MWALK 5237 idString(G, "G"); 5238 #endif 5953 if(printout > 2) 5954 { 5955 idString(G,"//** Mrwalk: G"); 5956 } 5957 #endif 5958 5959 rChangeCurrRing(targetRing); 5960 G = idrMoveR(G,newRing,currRing); 5961 5962 // test whether target cone is reached 5963 if(reduction !=0 && test_w_in_ConeCC(G,curr_weight) == 1) 5964 { 5965 baseRing = currRing; 5966 break; 5967 } 5968 5969 rChangeCurrRing(newRing); 5970 G = idrMoveR(G,targetRing,currRing); 5971 baseRing = currRing; 5972 5973 NEXT_VECTOR: 5239 5974 #ifdef TIME_TEST 5240 5975 to = clock(); 5241 5976 #endif 5242 intvec*next_weight = MwalkNextWeightCC(curr_weight,target_weight,G);5977 next_weight = MwalkNextWeightCC(curr_weight,target_weight,G); 5243 5978 #ifdef TIME_TEST 5244 5979 tnw = tnw + clock() - to; 5245 5980 #endif 5246 #ifdef PRINT_VECTORS 5247 MivString(curr_weight, target_weight, next_weight); 5248 #endif 5249 if(MivComp(next_weight, ivNull) == 1 || MivComp(target_weight,curr_weight) == 1)// || test_w_in_ConeCC(G, target_weight) == 1 || MivComp(next_weight,curr_weight) == 1) 5250 { 5251 #ifdef CHECK_IDEAL_MWALK 5252 PrintS("\n//** Mwalk: entering last cone.\n"); 5253 #endif 5254 Gomega = MwalkInitialForm(G, curr_weight); // compute an initial form ideal of <G> w.r.t. "curr_vector" 5981 5982 #ifdef TIME_TEST 5983 to = clock(); 5984 #endif 5985 Gomega = MwalkInitialForm(G, next_weight); // compute an initial form ideal of <G> w.r.t. "curr_vector" 5986 #ifdef TIME_TEST 5987 tif = tif + clock()-to; //time for computing initial form ideal 5988 #endif 5989 5990 //lengthpoly(Gomega) = 1 if there is a polynomial in Gomega with at least 3 monomials and 0 otherwise 5991 //polylength = lengthpoly(Gomega); 5992 if(lengthpoly(Gomega) > 0) 5993 { 5994 //there is a polynomial in Gomega with at least 3 monomials, 5995 //low-dimensional facet of the cone 5996 delete next_weight; 5255 5997 if(target_M->length() == nV) 5256 5998 { 5257 newRing = VMrDefault(target_weight); // define a new ring with ordering "(a(curr_weight),lp)5999 iv_M = MivMatrixOrder(curr_weight); 5258 6000 } 5259 6001 else 5260 6002 { 5261 newRing = VMatrDefault(target_M); 5262 } 5263 rChangeCurrRing(newRing); 5264 Gomega1 = idrMoveR(Gomega, baseRing,currRing); 6003 iv_M = MivMatrixOrderRefine(curr_weight,target_M); 6004 } 6005 #ifdef TIME_TEST 6006 to = clock(); 6007 #endif 6008 next_weight = MWalkRandomNextWeight(G, iv_M, target_weight, weight_rad, pert_deg); 6009 #ifdef TIME_TEST 6010 tnw = tnw + clock() - to; 6011 #endif 5265 6012 idDelete(&Gomega); 5266 #ifdef CHECK_IDEAL_MWALK 5267 idString(Gomega1, "Gomega"); 5268 #endif 5269 M = kStd(Gomega1,NULL,testHomog,NULL,NULL,0,0,NULL); 5270 #ifdef CHECK_IDEAL_MWALK 5271 idString(M,"M"); 5272 #endif 5273 rChangeCurrRing(baseRing); 5274 M1 = idrMoveR(M, newRing,currRing); 5275 idDelete(&M); 5276 Gomega2 = idrMoveR(Gomega1, newRing,currRing); 5277 idDelete(&Gomega1); 5278 F = MLifttwoIdeal(Gomega2, M1, G); 5279 #ifdef CHECK_IDEAL_MWALK 5280 idString(F,"F"); 5281 #endif 5282 idDelete(&Gomega2); 5283 idDelete(&M1); 5284 rChangeCurrRing(newRing); // change the ring to newRing 5285 G = idrMoveR(F,baseRing,currRing); 5286 idDelete(&F); 6013 #ifdef TIME_TEST 6014 to = clock(); 6015 #endif 6016 Gomega = MwalkInitialForm(G, next_weight); 6017 #ifdef TIME_TEST 6018 tif = tif + clock()-to; //time for computing initial form ideal 6019 #endif 6020 delete iv_M; 6021 } 6022 6023 // test whether target weight vector is reached 6024 if(MivComp(next_weight, ivNull) == 1 || MivComp(target_weight,curr_weight) == 1) 6025 { 5287 6026 baseRing = currRing; 5288 si_opt_1 = save1; //set original options, e. g. option(RedSB)5289 idSkipZeroes(G);5290 #ifdef TIME_TEST5291 to = clock();5292 #endif5293 // if(si_opt_1 == (Sy_bit(OPT_REDSB)))5294 // {5295 G = kInterRedCC(G,NULL); //reduce the Groebner basis <G> w.r.t. currRing, if option(redSB) is set5296 // }5297 #ifdef TIME_TEST5298 tred = tred + clock() - to;5299 #endif5300 idSkipZeroes(G);5301 6027 delete next_weight; 5302 6028 break; 5303 #ifdef CHECK_IDEAL_MWALK 5304 PrintS("\n//** Mwalk: last cone.\n"); 5305 #endif 5306 } 5307 #ifdef CHECK_IDEAL_MWALK 5308 PrintS("\n//** Mwalk: update weight vectors.\n"); 5309 #endif 6029 } 6030 6031 #ifdef PRINT_VECTORS 6032 if(printout > 0) 6033 { 6034 MivString(curr_weight, target_weight, next_weight); 6035 } 6036 #endif 6037 5310 6038 for(i=nV-1; i>=0; i--) 5311 6039 { 5312 (*tmp_weight)[i] = (*curr_weight)[i];5313 6040 (*curr_weight)[i] = (*next_weight)[i]; 5314 6041 } 5315 6042 delete next_weight; 5316 6043 } 6044 baseRing = currRing; 5317 6045 rChangeCurrRing(XXRing); 5318 6046 ideal result = idrMoveR(G,baseRing,currRing); 5319 6047 idDelete(&G); 5320 /*#ifdef CHECK_IDEAL_MWALK5321 pDelete(&p);5322 #endif*/5323 delete tmp_weight;5324 6048 delete ivNull; 5325 delete exivlp;5326 6049 #ifndef BUCHBERGER_ALG 5327 6050 delete last_omega; 5328 6051 #endif 5329 #ifdef TIME_TEST 5330 Print("\n//** Mwalk: Groebner Walk took %d steps.\n", nstep); 6052 Print("\n//** Mrwalk: Groebner Walk took %d steps.\n", nstep); 6053 #ifdef TIME_TEST 5331 6054 TimeString(tinput, tostd, tif, tstd, tlift, tred, tnw, nstep); 5332 Print("\n//** Mwalk: Ergebnis.\n");5333 6055 //Print("\n// pSetm_Error = (%d)", ErrorCheck()); 5334 6056 //Print("\n// Overflow_Error? (%d)\n", Overflow_Error); 5335 6057 #endif 6058 si_opt_1 = save1; //set original options 5336 6059 return(result); 5337 6060 } 5338 5339 // 07.11.20125340 // THE RANDOM WALK ALGORITHM ideal Go, intvec* orig_M, intvec* target_M, ring baseRing5341 ideal Mrwalk(ideal Go, intvec* orig_M, intvec* target_M, int weight_rad, int pert_deg, ring baseRing)5342 {5343 BITSET save1 = si_opt_1; // save current options5344 //si_opt_1 &= (~Sy_bit(OPT_REDSB)); // no reduced Groebner basis5345 //si_opt_1 &= (~Sy_bit(OPT_REDTAIL)); // not tail reductions5346 //si_opt_1|=(Sy_bit(OPT_REDTAIL)|Sy_bit(OPT_REDSB));5347 Set_Error(FALSE);5348 Overflow_Error = FALSE;5349 #ifdef TIME_TEST5350 clock_t tinput, tostd, tif=0, tstd=0, tlift=0, tred=0, tnw=0;5351 xtif=0; xtstd=0; xtlift=0; xtred=0; xtnw=0;5352 tinput = clock();5353 clock_t tim;5354 #endif5355 nstep=0;5356 int i,nwalk,endwalks = 0;5357 int nV = baseRing->N;5358 5359 ideal Gomega, M, F, Gomega1, Gomega2, M1; //, F1;5360 ring newRing;5361 ring XXRing = baseRing;5362 intvec* ivNull = new intvec(nV);5363 intvec* curr_weight = new intvec(nV);5364 intvec* target_weight = new intvec(nV);5365 intvec* exivlp = Mivlp(nV);5366 intvec* tmp_weight = new intvec(nV);5367 for(i=0; i<nV; i++)5368 {5369 (*tmp_weight)[i] = (*target_M)[i];5370 }5371 for(i=0; i<nV; i++)5372 {5373 (*curr_weight)[i] = (*orig_M)[i];5374 (*target_weight)[i] = (*target_M)[i];5375 }5376 #ifndef BUCHBERGER_ALG5377 intvec* hilb_func;5378 // to avoid (1,0,...,0) as the target vector5379 intvec* last_omega = new intvec(nV);5380 for(i=nV-1; i>0; i--)5381 {5382 (*last_omega)[i] = 1;5383 }5384 (*last_omega)[0] = 10000;5385 #endif5386 rComplete(currRing);5387 #ifdef CHECK_IDEAL_MWALK5388 idString(Go,"Go");5389 #endif5390 #ifdef TIME_TEST5391 to = clock();5392 #endif5393 if(orig_M->length() == nV)5394 {5395 newRing = VMrDefault(curr_weight); // define a new ring with ordering "(a(curr_weight),lp)5396 }5397 else5398 {5399 newRing = VMatrDefault(orig_M);5400 }5401 rChangeCurrRing(newRing);5402 ideal G = MstdCC(idrMoveR(Go,baseRing,currRing));5403 baseRing = currRing;5404 #ifdef TIME_TEST5405 tostd = clock()-to;5406 #endif5407 5408 nwalk = 0;5409 while(1)5410 {5411 nwalk ++;5412 nstep ++;5413 #ifdef TIME_TEST5414 to = clock();5415 #endif5416 #ifdef CHECK_IDEAL_MWALK5417 idString(G,"G");5418 #endif5419 Gomega = MwalkInitialForm(G, curr_weight); // compute an initial form ideal of <G> w.r.t. "curr_vector"5420 #ifdef TIME_TEST5421 tif = tif + clock()-to; //time for computing initial form ideal5422 #endif5423 #ifdef CHECK_IDEAL_MWALK5424 idString(Gomega,"Gomega");5425 #endif5426 #ifndef BUCHBERGER_ALG5427 if(isNolVector(curr_weight) == 0)5428 {5429 hilb_func = hFirstSeries(Gomega,NULL,NULL,curr_weight,currRing);5430 }5431 else5432 {5433 hilb_func = hFirstSeries(Gomega,NULL,NULL,last_omega,currRing);5434 }5435 #endif5436 if(nwalk == 1)5437 {5438 if(orig_M->length() == nV)5439 {5440 newRing = VMrDefault(curr_weight); // define a new ring with ordering "(a(curr_weight),lp)5441 }5442 else5443 {5444 newRing = VMatrDefault(orig_M);5445 }5446 }5447 else5448 {5449 if(target_M->length() == nV)5450 {5451 newRing = VMrRefine(curr_weight,target_weight); //define a new ring with ordering "(a(curr_weight),Wp(target_weight))"5452 }5453 else5454 {5455 newRing = VMatrRefine(target_M,curr_weight);5456 }5457 }5458 rChangeCurrRing(newRing);5459 Gomega1 = idrMoveR(Gomega, baseRing,currRing);5460 idDelete(&Gomega);5461 // compute a reduced Groebner basis of <Gomega> w.r.t. "newRing"5462 #ifdef TIME_TEST5463 to = clock();5464 #endif5465 #ifndef BUCHBERGER_ALG5466 M=kStd(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,curr_weight);5467 delete hilb_func;5468 #else5469 M = kStd(Gomega1,NULL,testHomog,NULL,NULL,0,0,NULL);5470 #endif5471 #ifdef TIME_TEST5472 tstd = tstd + clock() - to;5473 #endif5474 idSkipZeroes(M);5475 #ifdef CHECK_IDEAL_MWALK5476 PrintS("\n//** Mwalk: computed M.\n");5477 idString(M, "M");5478 #endif5479 //change the ring to baseRing5480 rChangeCurrRing(baseRing);5481 M1 = idrMoveR(M, newRing,currRing);5482 idDelete(&M);5483 Gomega2 = idrMoveR(Gomega1, newRing,currRing);5484 idDelete(&Gomega1);5485 #ifdef TIME_TEST5486 to = clock();5487 #endif5488 // compute a representation of the generators of submod (M) with respect to those of mod (Gomega), where Gomega is a reduced Groebner basis w.r.t. the current ring5489 F = MLifttwoIdeal(Gomega2, M1, G);5490 #ifdef TIME_TEST5491 tlift = tlift + clock() - to;5492 #endif5493 #ifdef CHECK_IDEAL_MWALK5494 idString(F, "F");5495 #endif5496 idDelete(&Gomega2);5497 idDelete(&M1);5498 rChangeCurrRing(newRing); // change the ring to newRing5499 G = idrMoveR(F,baseRing,currRing);5500 idDelete(&F);5501 baseRing = currRing;5502 #ifdef TIME_TEST5503 to = clock();5504 #endif5505 //G = kStd(F1,NULL,testHomog,NULL,NULL,0,0,NULL);5506 #ifdef TIME_TEST5507 tstd = tstd + clock() - to;5508 #endif5509 idSkipZeroes(G);5510 #ifdef CHECK_IDEAL_MWALK5511 idString(G, "G");5512 #endif5513 #ifdef TIME_TEST5514 to = clock();5515 #endif5516 intvec* next_weight = MWalkRandomNextWeight(G, curr_weight, target_weight, weight_rad, pert_deg);//next_weight = MwalkNextWeightCC(curr_weight,target_weight,G);5517 #ifdef TIME_TEST5518 tnw = tnw + clock() - to;5519 #endif5520 #ifdef PRINT_VECTORS5521 MivString(curr_weight, target_weight, next_weight);5522 #endif5523 if(MivComp(next_weight, ivNull) == 1 || MivComp(target_weight,curr_weight) == 1)// || test_w_in_ConeCC(G, target_weight) == 1 || MivComp(next_weight,curr_weight) == 1)5524 {5525 #ifdef CHECK_IDEAL_MWALK5526 PrintS("\n//** Mwalk: entering last cone.\n");5527 #endif5528 Gomega = MwalkInitialForm(G, curr_weight); // compute an initial form ideal of <G> w.r.t. "curr_vector"5529 if(target_M->length() == nV)5530 {5531 newRing = VMrDefault(target_weight); // define a new ring with ordering "(a(curr_weight),lp)5532 }5533 else5534 {5535 newRing = VMatrDefault(target_M);5536 }5537 rChangeCurrRing(newRing);5538 Gomega1 = idrMoveR(Gomega, baseRing,currRing);5539 idDelete(&Gomega);5540 #ifdef CHECK_IDEAL_MWALK5541 idString(Gomega1, "Gomega");5542 #endif5543 M = kStd(Gomega1,NULL,testHomog,NULL,NULL,0,0,NULL);5544 #ifdef CHECK_IDEAL_MWALK5545 idString(M,"M");5546 #endif5547 rChangeCurrRing(baseRing);5548 M1 = idrMoveR(M, newRing,currRing);5549 idDelete(&M);5550 Gomega2 = idrMoveR(Gomega1, newRing,currRing);5551 idDelete(&Gomega1);5552 F = MLifttwoIdeal(Gomega2, M1, G);5553 #ifdef CHECK_IDEAL_MWALK5554 idString(F,"F");5555 #endif5556 idDelete(&Gomega2);5557 idDelete(&M1);5558 rChangeCurrRing(newRing); // change the ring to newRing5559 G = idrMoveR(F,baseRing,currRing);5560 idDelete(&F);5561 baseRing = currRing;5562 si_opt_1 = save1; //set original options, e. g. option(RedSB)5563 idSkipZeroes(G);5564 #ifdef TIME_TEST5565 to = clock();5566 #endif5567 // if(si_opt_1 == (Sy_bit(OPT_REDSB)))5568 // {5569 //G = kInterRedCC(G,NULL); //reduce the Groebner basis <G> w.r.t. currRing, if option(redSB) is set5570 // }5571 #ifdef TIME_TEST5572 tred = tred + clock() - to;5573 #endif5574 idSkipZeroes(G);5575 delete next_weight;5576 break;5577 #ifdef CHECK_IDEAL_MWALK5578 PrintS("\n//** Mwalk: last cone.\n");5579 #endif5580 }5581 #ifdef CHECK_IDEAL_MWALK5582 PrintS("\n//** Mwalk: update weight vectors.\n");5583 #endif5584 for(i=nV-1; i>=0; i--)5585 {5586 (*tmp_weight)[i] = (*curr_weight)[i];5587 (*curr_weight)[i] = (*next_weight)[i];5588 }5589 delete next_weight;5590 }5591 rChangeCurrRing(XXRing);5592 ideal result = idrMoveR(G,baseRing,currRing);5593 idDelete(&G);5594 /*#ifdef CHECK_IDEAL_MWALK5595 pDelete(&p);5596 #endif*/5597 delete tmp_weight;5598 delete ivNull;5599 delete exivlp;5600 #ifndef BUCHBERGER_ALG5601 delete last_omega;5602 #endif5603 #ifdef TIME_TEST5604 Print("\n//** Mwalk: Groebner Walk took %d steps.\n", nstep);5605 TimeString(tinput, tostd, tif, tstd, tlift, tred, tnw, nstep);5606 Print("\n//** Mwalk: Ergebnis.\n");5607 //Print("\n// pSetm_Error = (%d)", ErrorCheck());5608 //Print("\n// Overflow_Error? (%d)\n", Overflow_Error);5609 #endif5610 return(result);5611 }5612 5613 //unused5614 #if 05615 ideal Mwalk_tst(ideal Go, intvec* curr_weight, intvec* target_weight)5616 {5617 //clock_t tinput=clock();5618 //idString(Go,"Ginp");5619 int i, nV = currRing->N;5620 int nwalk=0, endwalks=0;5621 5622 ideal Gomega, M, F, Gomega1, Gomega2, M1, F1, G;5623 // ideal G1; ring endRing;5624 ring newRing, oldRing;5625 intvec* ivNull = new intvec(nV);5626 ring XXRing = currRing;5627 5628 intvec* tmp_weight = new intvec(nV);5629 for(i=nV-1; i>=0; i--)5630 {5631 (*tmp_weight)[i] = (*curr_weight)[i];5632 }5633 /* the monomial ordering of this current ring would be "dp" */5634 G = MstdCC(Go);5635 #ifndef BUCHBERGER_ALG5636 intvec* hilb_func;5637 #endif5638 /* to avoid (1,0,...,0) as the target vector */5639 intvec* last_omega = new intvec(nV);5640 for(i=nV-1; i>0; i--)5641 (*last_omega)[i] = 1;5642 (*last_omega)[0] = 10000;5643 5644 while(1)5645 {5646 nwalk ++;5647 //Print("\n// Entering the %d-th step:", nwalk);5648 //Print("\n// ring r[%d] = %s;", nwalk, rString(currRing));5649 idString(G,"G");5650 /* compute an initial form ideal of <G> w.r.t. "curr_vector" */5651 Gomega = MwalkInitialForm(G, curr_weight);5652 //ivString(curr_weight, "omega");5653 idString(Gomega,"Gw");5654 5655 #ifndef BUCHBERGER_ALG5656 if(isNolVector(curr_weight) == 0)5657 hilb_func = hFirstSeries(Gomega,NULL,NULL,curr_weight,currRing);5658 else5659 hilb_func = hFirstSeries(Gomega,NULL,NULL,last_omega,currRing);5660 #endif // BUCHBERGER_ALG5661 5662 5663 oldRing = currRing;5664 5665 /* define a new ring that its ordering is "(a(curr_weight),lp) */5666 VMrDefault(curr_weight);5667 newRing = currRing;5668 5669 Gomega1 = idrMoveR(Gomega, oldRing,currRing);5670 5671 /* compute a reduced Groebner basis of <Gomega> w.r.t. "newRing" */5672 #ifdef BUCHBERGER_ALG5673 M = MstdhomCC(Gomega1);5674 #else5675 M=kStd(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,curr_weight);5676 delete hilb_func;5677 #endif // BUCHBERGER_ALG5678 5679 idString(M,"M");5680 5681 /* change the ring to oldRing */5682 rChangeCurrRing(oldRing);5683 M1 = idrMoveR(M, newRing,currRing);5684 Gomega2 = idrMoveR(Gomega1, newRing,currRing);5685 5686 /* compute a representation of the generators of submod (M)5687 with respect to those of mod (Gomega).5688 Gomega is a reduced Groebner basis w.r.t. the current ring */5689 F = MLifttwoIdeal(Gomega2, M1, G);5690 idDelete(&M1);5691 idDelete(&Gomega2);5692 idDelete(&G);5693 idString(F,"F");5694 5695 /* change the ring to newRing */5696 rChangeCurrRing(newRing);5697 F1 = idrMoveR(F, oldRing,currRing);5698 5699 /* reduce the Groebner basis <G> w.r.t. new ring */5700 G = kInterRedCC(F1, NULL);5701 //idSkipZeroes(G);//done by kInterRed5702 idDelete(&F1);5703 idString(G,"G");5704 if(endwalks == 1)5705 break;5706 5707 /* compute a next weight vector */5708 intvec* next_weight = MkInterRedNextWeight(curr_weight,target_weight,G);5709 #ifdef PRINT_VECTORS5710 MivString(curr_weight, target_weight, next_weight);5711 #endif5712 5713 if(MivComp(next_weight, ivNull) == 1)5714 {5715 delete next_weight;5716 break;5717 }5718 if(MivComp(next_weight, target_weight) == 1)5719 endwalks = 1;5720 5721 for(i=nV-1; i>=0; i--)5722 (*tmp_weight)[i] = (*curr_weight)[i];5723 5724 /* 06.11.01 to free the memory: NOT Changed!!*/5725 for(i=nV-1; i>=0; i--)5726 (*curr_weight)[i] = (*next_weight)[i];5727 delete next_weight;5728 }5729 rChangeCurrRing(XXRing);5730 G = idrMoveR(G, newRing,currRing);5731 5732 delete tmp_weight;5733 delete ivNull;5734 PrintLn();5735 return(G);5736 }5737 #endif5738 6061 5739 6062 /**************************************************************/ … … 5749 6072 2) the changed perturbation walk algorithm with a decreased degree. 5750 6073 */ 5751 // use kStd, if nP = 0, else call LastGB6074 // if nP = 0 use kStd, else call LastGB 5752 6075 ideal Mpwalk(ideal Go, int op_deg, int tp_deg,intvec* curr_weight, 5753 intvec* target_weight, int nP )6076 intvec* target_weight, int nP, int reduction, int printout) 5754 6077 { 6078 BITSET save1 = si_opt_1; // save current options 6079 if(reduction == 0) 6080 { 6081 si_opt_1 &= (~Sy_bit(OPT_REDSB)); // no reduced Groebner basis 6082 si_opt_1 &= (~Sy_bit(OPT_REDTAIL)); // not tail reductions 6083 } 5755 6084 Set_Error(FALSE ); 5756 6085 Overflow_Error = FALSE; 5757 6086 //Print("// pSetm_Error = (%d)", ErrorCheck()); 5758 6087 #ifdef TIME_TEST 5759 6088 clock_t tinput, tostd, tif=0, tstd=0, tlift=0, tred=0, tnw=0; 5760 6089 xtextra=0; … … 5763 6092 5764 6093 clock_t tim; 5765 6094 #endif 5766 6095 nstep = 0; 5767 6096 int i, ntwC=1, ntestw=1, nV = currRing->N; 5768 int endwalks=0; 5769 5770 ideal Gomega, M, F, G, Gomega1, Gomega2, M1,F1,Eresult,ssG; 6097 6098 //check that perturbation degree is valid 6099 if(op_deg < 1 || tp_deg < 1 || op_deg > nV || tp_deg > nV) 6100 { 6101 Werror("Invalid perturbation degree.\n"); 6102 return NULL; 6103 } 6104 6105 BOOLEAN endwalks = FALSE; 6106 ideal Gomega, M, F, FF, G, Gomega1, Gomega2, M1,F1,Eresult,ssG; 5771 6107 ring newRing, oldRing, TargetRing; 5772 6108 intvec* iv_M_dp; … … 5789 6125 5790 6126 ring XXRing = currRing; 5791 5792 6127 #ifdef TIME_TEST 5793 6128 to = clock(); 5794 /* perturbs the original vector */ 6129 #endif 6130 // perturbs the original vector 5795 6131 if(MivComp(curr_weight, iv_dp) == 1) //rOrdStr(currRing) := "dp" 5796 6132 { 5797 6133 G = MstdCC(Go); 6134 #ifdef TIME_TEST 5798 6135 tostd = clock()-to; 6136 #endif 5799 6137 if(op_deg != 1){ 5800 6138 iv_M_dp = MivMatrixOrderdp(nV); … … 5809 6147 DefRingPar(curr_weight); 5810 6148 else 5811 rChangeCurrRing(VMrDefault(curr_weight)); //Aenderung 16149 rChangeCurrRing(VMrDefault(curr_weight)); 5812 6150 5813 6151 G = idrMoveR(Go, XXRing,currRing); 5814 6152 G = MstdCC(G); 6153 #ifdef TIME_TEST 5815 6154 tostd = clock()-to; 6155 #endif 5816 6156 if(op_deg != 1){ 5817 6157 iv_M_dp = MivMatrixOrder(curr_weight); … … 5824 6164 ring HelpRing = currRing; 5825 6165 5826 / * perturbs the target weight vector */6166 // perturbs the target weight vector 5827 6167 if(tp_deg > 1 && tp_deg <= nV) 5828 6168 { … … 5830 6170 DefRingPar(target_weight); 5831 6171 else 5832 rChangeCurrRing(VMrDefault(target_weight)); // Aenderung 26172 rChangeCurrRing(VMrDefault(target_weight)); 5833 6173 5834 6174 TargetRing = currRing; … … 5837 6177 { 5838 6178 iv_M_lp = MivMatrixOrderlp(nV); 5839 //ivString(iv_M_lp, "iv_M_lp");5840 //target_weight = MPertVectorslp(ssG, iv_M_lp, tp_deg);5841 6179 target_weight = MPertVectors(ssG, iv_M_lp, tp_deg); 5842 6180 } … … 5844 6182 { 5845 6183 iv_M_lp = MivMatrixOrder(target_weight); 5846 //target_weight = MPertVectorslp(ssG, iv_M_lp, tp_deg);5847 6184 target_weight = MPertVectors(ssG, iv_M_lp, tp_deg); 5848 6185 } … … 5852 6189 G = idrMoveR(ssG, TargetRing,currRing); 5853 6190 } 5854 /* 5855 Print("\n// Perturbationwalkalg. vom Gradpaar (%d,%d):",op_deg,tp_deg); 5856 ivString(curr_weight, "new sigma"); 5857 ivString(target_weight, "new tau"); 5858 */ 6191 if(printout > 0) 6192 { 6193 Print("\n//** Mpwalk: Perturbation Walk of degree (%d,%d):",op_deg,tp_deg); 6194 #ifdef PRINT_VECTORS 6195 ivString(curr_weight, "//** Mpwalk: new current weight"); 6196 ivString(target_weight, "//** Mpwalk: new target weight"); 6197 #endif 6198 } 5859 6199 while(1) 5860 6200 { 5861 6201 nstep ++; 6202 #ifdef TIME_TEST 5862 6203 to = clock(); 5863 /* compute an initial form ideal of <G> w.r.t. the weight vector 5864 "curr_weight" */ 6204 #endif 6205 // compute an initial form ideal of <G> w.r.t. the weight vector 6206 // "curr_weight" 5865 6207 Gomega = MwalkInitialForm(G, curr_weight); 5866 6208 #ifdef TIME_TEST 6209 tif = tif + clock()-to; 6210 #endif 6211 #ifdef CHECK_IDEAL_MWALK 6212 if(printout > 1) 6213 { 6214 idString(Gomega,"//** Mpwalk: Gomega"); 6215 } 6216 #endif 6217 if(reduction == 0 && nstep > 1) 6218 { 6219 /* 6220 // check whether weight vector is in the interior of the cone 6221 while(1) 6222 { 6223 FF = middleOfCone(G,Gomega); 6224 if(FF != NULL) 6225 { 6226 idDelete(&G); 6227 G = idCopy(FF); 6228 idDelete(&FF); 6229 next_weight = MwalkNextWeightCC(curr_weight,target_weight,G); 6230 #ifdef PRINT_VECTORS 6231 if(printout > 0) 6232 { 6233 MivString(curr_weight, target_weight, next_weight); 6234 } 6235 #endif 6236 } 6237 else 6238 { 6239 break; 6240 } 6241 for(i=nV-1; i>=0; i--) 6242 { 6243 (*curr_weight)[i] = (*next_weight)[i]; 6244 } 6245 Gomega = MwalkInitialForm(G, curr_weight); 6246 #ifdef CHECK_IDEAL_MWALK 6247 if(printout > 1) 6248 { 6249 idString(Gomega,"//** Mpwalk: Gomega"); 6250 } 6251 #endif 6252 } 6253 */ 6254 FF = middleOfCone(G,Gomega); 6255 if(FF != NULL) 6256 { 6257 idDelete(&G); 6258 G = idCopy(FF); 6259 idDelete(&FF); 6260 goto NEXT_VECTOR; 6261 } 6262 } 5867 6263 5868 6264 #ifdef ENDWALKS 5869 if(endwalks == 1){ 6265 if(endwalks == TRUE) 6266 { 5870 6267 Print("\n// ring r%d = %s;\n", nstep, rString(currRing)); 6268 /* 5871 6269 idElements(G, "G"); 5872 // idElements(Gomega, "Gw");5873 6270 headidString(G, "G"); 5874 //headidString(Gomega, "Gw"); 5875 } 5876 #endif 5877 5878 tif = tif + clock()-to; 6271 */ 6272 } 6273 #endif 5879 6274 5880 6275 #ifndef BUCHBERGER_ALG … … 5891 6286 DefRingPar(curr_weight); 5892 6287 else 5893 rChangeCurrRing(VMrDefault(curr_weight)); //Aenderung 36288 rChangeCurrRing(VMrDefault(curr_weight)); 5894 6289 5895 6290 newRing = currRing; … … 5897 6292 5898 6293 #ifdef ENDWALKS 5899 if(endwalks== 1)6294 if(endwalks==TRUE) 5900 6295 { 5901 6296 Print("\n// ring r%d = %s;\n", nstep, rString(currRing)); 6297 /* 5902 6298 idElements(Gomega1, "Gw"); 5903 6299 headidString(Gomega1, "headGw"); 6300 */ 5904 6301 PrintS("\n// compute a rGB of Gw:\n"); 5905 5906 6302 #ifndef BUCHBERGER_ALG 5907 6303 ivString(hilb_func, "w"); … … 5909 6305 } 5910 6306 #endif 5911 6307 #ifdef TIME_TEST 5912 6308 tim = clock(); 5913 6309 to = clock(); 5914 /* compute a reduced Groebner basis of <Gomega> w.r.t. "newRing" */ 6310 #endif 6311 // compute a reduced Groebner basis of <Gomega> w.r.t. "newRing" 5915 6312 #ifdef BUCHBERGER_ALG 5916 6313 M = MstdhomCC(Gomega1); … … 5918 6315 M=kStd(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,curr_weight); 5919 6316 delete hilb_func; 5920 #endif // BUCHBERGER_ALG 5921 5922 if(endwalks == 1){ 6317 #endif 6318 6319 if(endwalks == TRUE) 6320 { 6321 #ifdef TIME_TEST 5923 6322 xtstd = xtstd+clock()-to; 6323 #endif 5924 6324 #ifdef ENDWALKS 5925 6325 Print("\n// time for the last std(Gw) = %.2f sec\n", … … 5928 6328 } 5929 6329 else 6330 { 6331 #ifdef TIME_TEST 5930 6332 tstd=tstd+clock()-to; 5931 5932 /* change the ring to oldRing */ 6333 #endif 6334 } 6335 #ifdef CHECK_IDEAL_MWALK 6336 if(printout > 2) 6337 { 6338 idString(M,"//** Mpwalk: M"); 6339 } 6340 #endif 6341 // change the ring to oldRing 5933 6342 rChangeCurrRing(oldRing); 5934 6343 M1 = idrMoveR(M, newRing,currRing); 5935 6344 Gomega2 = idrMoveR(Gomega1, newRing,currRing); 5936 5937 //if(endwalks==1) PrintS("\n// Lifting is working:.."); 5938 6345 #ifdef TIME_TEST 5939 6346 to=clock(); 6347 #endif 5940 6348 /* compute a representation of the generators of submod (M) 5941 6349 with respect to those of mod (Gomega). 5942 6350 Gomega is a reduced Groebner basis w.r.t. the current ring */ 5943 6351 F = MLifttwoIdeal(Gomega2, M1, G); 5944 if(endwalks != 1) 6352 #ifdef TIME_TEST 6353 if(endwalks == FALSE) 5945 6354 tlift = tlift+clock()-to; 5946 6355 else 5947 6356 xtlift=clock()-to; 6357 #endif 6358 #ifdef CHECK_IDEAL_MWALK 6359 if(printout > 2) 6360 { 6361 idString(F,"//** Mpwalk: F"); 6362 } 6363 #endif 5948 6364 5949 6365 idDelete(&M1); … … 5951 6367 idDelete(&G); 5952 6368 5953 / * change the ring to newRing */6369 // change the ring to newRing 5954 6370 rChangeCurrRing(newRing); 5955 F1 = idrMoveR(F, oldRing,currRing); 5956 5957 //if(endwalks==1)PrintS("\n// InterRed is working now:"); 5958 6371 if(reduction == 0) 6372 { 6373 G = idrMoveR(F,oldRing,currRing); 6374 } 6375 else 6376 { 6377 F1 = idrMoveR(F, oldRing,currRing); 6378 if(printout > 2) 6379 { 6380 PrintS("\n //** Mpwalk: reduce the Groebner basis.\n"); 6381 } 6382 #ifdef TIME_TEST 6383 to=clock(); 6384 #endif 6385 G = kInterRedCC(F1, NULL); 6386 #ifdef TIME_TEST 6387 if(endwalks == FALSE) 6388 tred = tred+clock()-to; 6389 else 6390 xtred=clock()-to; 6391 #endif 6392 idDelete(&F1); 6393 } 6394 if(endwalks == TRUE) 6395 break; 6396 6397 NEXT_VECTOR: 6398 #ifdef TIME_TEST 5959 6399 to=clock(); 5960 /* reduce the Groebner basis <G> w.r.t. new ring */ 5961 G = kInterRedCC(F1, NULL); 5962 if(endwalks != 1) 5963 tred = tred+clock()-to; 5964 else 5965 xtred=clock()-to; 5966 5967 idDelete(&F1); 5968 5969 if(endwalks == 1) 5970 break; 5971 5972 to=clock(); 5973 /* compute a next weight vector */ 6400 #endif 6401 // compute a next weight vector 5974 6402 next_weight = MkInterRedNextWeight(curr_weight,target_weight, G); 6403 #ifdef TIME_TEST 5975 6404 tnw=tnw+clock()-to; 6405 #endif 5976 6406 #ifdef PRINT_VECTORS 5977 MivString(curr_weight, target_weight, next_weight); 6407 if(printout > 0) 6408 { 6409 MivString(curr_weight, target_weight, next_weight); 6410 } 5978 6411 #endif 5979 6412 … … 5994 6427 } 5995 6428 if(MivComp(next_weight, target_weight) == 1) 5996 endwalks = 1;6429 endwalks = TRUE; 5997 6430 5998 6431 for(i=nV-1; i>=0; i--) … … 6000 6433 6001 6434 delete next_weight; 6002 }// while6435 }//end of while-loop 6003 6436 6004 6437 if(tp_deg != 1) … … 6014 6447 DefRingPar(orig_target); 6015 6448 else 6016 rChangeCurrRing(VMrDefault(orig_target)); //Aenderung6449 rChangeCurrRing(VMrDefault(orig_target)); 6017 6450 6018 6451 TargetRing=currRing; 6019 6452 F1 = idrMoveR(G, newRing,currRing); 6020 #ifdef CHECK_IDEAL 6453 /* 6454 #ifdef CHECK_IDEAL_MWALK 6021 6455 headidString(G, "G"); 6022 6456 #endif 6023 6457 */ 6024 6458 6025 6459 // check whether the pertubed target vector stays in the correct cone … … 6030 6464 if( ntestw != 1 || ntwC == 0) 6031 6465 { 6032 /*6033 if(ntestw != 1){6466 if(ntestw != 1 && printout >2) 6467 { 6034 6468 ivString(pert_target_vector, "tau"); 6035 6469 PrintS("\n// ** perturbed target vector doesn't stay in cone!!"); 6036 6470 Print("\n// ring r%d = %s;\n", nstep, rString(currRing)); 6037 idElements(F1, "G"); 6038 } 6039 */ 6471 //idElements(F1, "G"); 6472 } 6040 6473 // LastGB is "better" than the kStd subroutine 6041 6474 to=clock(); … … 6068 6501 Eresult = idrMoveR(G, newRing,currRing); 6069 6502 } 6503 si_opt_1 = save1; //set original options, e. g. option(RedSB) 6070 6504 delete ivNull; 6071 6505 if(tp_deg != 1) … … 6082 6516 tnw+xtnw); 6083 6517 6084 Print("\n// pSetm_Error = (%d)", ErrorCheck()); 6085 Print("\n// It took %d steps and Overflow_Error? (%d)\n", nstep, Overflow_Error); 6086 #endif 6518 //Print("\n// pSetm_Error = (%d)", ErrorCheck()); 6519 //Print("\n// It took %d steps and Overflow_Error? (%d)\n", nstep, Overflow_Error); 6520 #endif 6521 Print("\n//** Mpwalk: Perturbation Walk took %d steps.\n", nstep); 6522 return(Eresult); 6523 } 6524 6525 /******************************************************* 6526 * THE PERTURBATION WALK ALGORITHM WITH RANDOM ELEMENT * 6527 *******************************************************/ 6528 ideal Mprwalk(ideal Go, intvec* orig_M, intvec* target_M, int weight_rad, 6529 int op_deg, int tp_deg, int nP, int reduction, int printout) 6530 { 6531 BITSET save1 = si_opt_1; // save current options 6532 if(reduction == 0) 6533 { 6534 si_opt_1 &= (~Sy_bit(OPT_REDSB)); // no reduced Groebner basis 6535 si_opt_1 &= (~Sy_bit(OPT_REDTAIL)); // not tail reductions 6536 } 6537 Set_Error(FALSE); 6538 Overflow_Error = FALSE; 6539 //Print("// pSetm_Error = (%d)", ErrorCheck()); 6540 #ifdef TIME_TEST 6541 clock_t tinput, tostd, tif=0, tstd=0, tlift=0, tred=0, tnw=0; 6542 xtextra=0; 6543 xtif=0; xtstd=0; xtlift=0; xtred=0; xtnw=0; 6544 tinput = clock(); 6545 6546 clock_t tim; 6547 #endif 6548 nstep = 0; 6549 int i, ntwC=1, ntestw=1, nV = currRing->N; //polylength 6550 6551 //check that weight radius is valid 6552 if(weight_rad < 0) 6553 { 6554 Werror("Invalid radius.\n"); 6555 return NULL; 6556 } 6557 6558 //check that perturbation degree is valid 6559 if(op_deg < 1 || tp_deg < 1 || op_deg > nV || tp_deg > nV) 6560 { 6561 Werror("Invalid perturbation degree.\n"); 6562 return NULL; 6563 } 6564 6565 BOOLEAN endwalks = FALSE; 6566 6567 ideal Gomega, M, F, FF, G, Gomega1, Gomega2, M1,F1,Eresult,ssG; 6568 ring newRing, oldRing, TargetRing; 6569 intvec* iv_M; 6570 intvec* iv_M_dp; 6571 intvec* iv_M_lp; 6572 intvec* exivlp = Mivlp(nV); 6573 intvec* curr_weight = new intvec(nV); 6574 intvec* target_weight = new intvec(nV); 6575 for(i=0; i<nV; i++) 6576 { 6577 (*curr_weight)[i] = (*orig_M)[i]; 6578 (*target_weight)[i] = (*target_M)[i]; 6579 } 6580 intvec* orig_target = target_weight; 6581 intvec* pert_target_vector = target_weight; 6582 intvec* ivNull = new intvec(nV); 6583 intvec* iv_dp = MivUnit(nV);// define (1,1,...,1) 6584 #ifndef BUCHBERGER_ALG 6585 intvec* hilb_func; 6586 #endif 6587 intvec* next_weight; 6588 6589 // to avoid (1,0,...,0) as the target vector 6590 intvec* last_omega = new intvec(nV); 6591 for(i=nV-1; i>0; i--) 6592 (*last_omega)[i] = 1; 6593 (*last_omega)[0] = 10000; 6594 6595 ring XXRing = currRing; 6596 6597 // perturbs the original vector 6598 if(orig_M->length() == nV) 6599 { 6600 if(MivComp(curr_weight, iv_dp) == 1) //rOrdStr(currRing) := "dp" 6601 { 6602 #ifdef TIME_TEST 6603 to = clock(); 6604 #endif 6605 G = MstdCC(Go); 6606 #ifdef TIME_TEST 6607 tostd = clock()-to; 6608 #endif 6609 if(op_deg != 1) 6610 { 6611 iv_M_dp = MivMatrixOrderdp(nV); 6612 curr_weight = MPertVectors(G, iv_M_dp, op_deg); 6613 } 6614 } 6615 else 6616 { 6617 //define ring order := (a(curr_weight),lp); 6618 if (rParameter(currRing) != NULL) 6619 DefRingPar(curr_weight); 6620 else 6621 rChangeCurrRing(VMrDefault(curr_weight)); 6622 6623 G = idrMoveR(Go, XXRing,currRing); 6624 #ifdef TIME_TEST 6625 to = clock(); 6626 #endif 6627 G = MstdCC(G); 6628 #ifdef TIME_TEST 6629 tostd = clock()-to; 6630 #endif 6631 if(op_deg != 1) 6632 { 6633 iv_M_dp = MivMatrixOrder(curr_weight); 6634 curr_weight = MPertVectors(G, iv_M_dp, op_deg); 6635 } 6636 } 6637 } 6638 else 6639 { 6640 rChangeCurrRing(VMatrDefault(orig_M)); 6641 G = idrMoveR(Go, XXRing,currRing); 6642 #ifdef TIME_TEST 6643 to = clock(); 6644 #endif 6645 G = MstdCC(G); 6646 #ifdef TIME_TEST 6647 tostd = clock()-to; 6648 #endif 6649 if(op_deg != 1) 6650 { 6651 curr_weight = MPertVectors(G, orig_M, op_deg); 6652 } 6653 } 6654 6655 delete iv_dp; 6656 if(op_deg != 1) delete iv_M_dp; 6657 6658 ring HelpRing = currRing; 6659 6660 // perturbs the target weight vector 6661 if(target_M->length() == nV) 6662 { 6663 if(tp_deg > 1 && tp_deg <= nV) 6664 { 6665 if (rParameter(currRing) != NULL) 6666 DefRingPar(target_weight); 6667 else 6668 rChangeCurrRing(VMrDefault(target_weight)); 6669 6670 TargetRing = currRing; 6671 ssG = idrMoveR(G,HelpRing,currRing); 6672 if(MivSame(target_weight, exivlp) == 1) 6673 { 6674 iv_M_lp = MivMatrixOrderlp(nV); 6675 target_weight = MPertVectors(ssG, iv_M_lp, tp_deg); 6676 } 6677 else 6678 { 6679 iv_M_lp = MivMatrixOrder(target_weight); 6680 target_weight = MPertVectors(ssG, iv_M_lp, tp_deg); 6681 } 6682 delete iv_M_lp; 6683 pert_target_vector = target_weight; 6684 rChangeCurrRing(HelpRing); 6685 G = idrMoveR(ssG, TargetRing,currRing); 6686 } 6687 } 6688 else 6689 { 6690 if(tp_deg > 1 && tp_deg <= nV) 6691 { 6692 rChangeCurrRing(VMatrDefault(target_M)); 6693 TargetRing = currRing; 6694 ssG = idrMoveR(G,HelpRing,currRing); 6695 target_weight = MPertVectors(ssG, target_M, tp_deg); 6696 } 6697 } 6698 if(printout > 0) 6699 { 6700 Print("\n//** Mprwalk: Random Perturbation Walk of degree (%d,%d):",op_deg,tp_deg); 6701 ivString(curr_weight, "//** Mprwalk: new current weight"); 6702 ivString(target_weight, "//** Mprwalk: new target weight"); 6703 } 6704 6705 #ifdef TIME_TEST 6706 to = clock(); 6707 #endif 6708 Gomega = MwalkInitialForm(G, curr_weight); // compute an initial form ideal of <G> w.r.t. "curr_vector" 6709 #ifdef TIME_TEST 6710 tif = tif + clock()-to; //time for computing initial form ideal 6711 #endif 6712 6713 while(1) 6714 { 6715 nstep ++; 6716 #ifdef CHECK_IDEAL_MWALK 6717 if(printout > 1) 6718 { 6719 idString(Gomega,"//** Mprwalk: Gomega"); 6720 } 6721 #endif 6722 6723 if(reduction == 0 && nstep > 1) 6724 { 6725 /* 6726 // check whether weight vector is in the interior of the cone 6727 while(1) 6728 { 6729 FF = middleOfCone(G,Gomega); 6730 if(FF != NULL) 6731 { 6732 idDelete(&G); 6733 G = idCopy(FF); 6734 idDelete(&FF); 6735 next_weight = MwalkNextWeightCC(curr_weight,target_weight,G); 6736 #ifdef PRINT_VECTORS 6737 if(printout > 0) 6738 { 6739 MivString(curr_weight, target_weight, next_weight); 6740 } 6741 #endif 6742 } 6743 else 6744 { 6745 break; 6746 } 6747 for(i=nV-1; i>=0; i--) 6748 { 6749 (*curr_weight)[i] = (*next_weight)[i]; 6750 } 6751 Gomega = MwalkInitialForm(G, curr_weight); 6752 #ifdef CHECK_IDEAL_MWALK 6753 if(printout > 1) 6754 { 6755 idString(Gomega,"//** Mprwalk: Gomega"); 6756 } 6757 #endif 6758 } 6759 */ 6760 FF = middleOfCone(G,Gomega); 6761 if(FF != NULL) 6762 { 6763 idDelete(&G); 6764 G = idCopy(FF); 6765 idDelete(&FF); 6766 goto NEXT_VECTOR; 6767 } 6768 } 6769 6770 #ifdef ENDWALKS 6771 if(endwalks == TRUE) 6772 { 6773 Print("\n// ring r%d = %s;\n", nstep, rString(currRing)); 6774 /* 6775 idElements(G, "G"); 6776 headidString(G, "G"); 6777 */ 6778 } 6779 #endif 6780 6781 #ifndef BUCHBERGER_ALG 6782 if(isNolVector(curr_weight) == 0) 6783 hilb_func = hFirstSeries(Gomega,NULL,NULL,curr_weight,currRing); 6784 else 6785 hilb_func = hFirstSeries(Gomega,NULL,NULL,last_omega,currRing); 6786 #endif // BUCHBERGER_ALG 6787 6788 oldRing = currRing; 6789 6790 if(target_M->length() == nV) 6791 { 6792 // define a new ring with ordering "(a(curr_weight),lp) 6793 if (rParameter(currRing) != NULL) 6794 DefRingPar(curr_weight); 6795 else 6796 rChangeCurrRing(VMrDefault(curr_weight)); 6797 } 6798 else 6799 { 6800 rChangeCurrRing(VMatrRefine(target_M,curr_weight)); 6801 } 6802 newRing = currRing; 6803 Gomega1 = idrMoveR(Gomega, oldRing,currRing); 6804 #ifdef ENDWALKS 6805 if(endwalks == TRUE) 6806 { 6807 Print("\n// ring r%d = %s;\n", nstep, rString(currRing)); 6808 /* 6809 idElements(Gomega1, "Gw"); 6810 headidString(Gomega1, "headGw"); 6811 */ 6812 PrintS("\n// compute a rGB of Gw:\n"); 6813 6814 #ifndef BUCHBERGER_ALG 6815 ivString(hilb_func, "w"); 6816 #endif 6817 } 6818 #endif 6819 #ifdef TIME_TEST 6820 tim = clock(); 6821 to = clock(); 6822 #endif 6823 // compute a reduced Groebner basis of <Gomega> w.r.t. "newRing" 6824 #ifdef BUCHBERGER_ALG 6825 M = MstdhomCC(Gomega1); 6826 #else 6827 M=kStd(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,curr_weight); 6828 delete hilb_func; 6829 #endif 6830 #ifdef CHECK_IDEAL_MWALK 6831 if(printout > 2) 6832 { 6833 idString(M,"//** Mprwalk: M"); 6834 } 6835 #endif 6836 #ifdef TIME_TEST 6837 if(endwalks == TRUE) 6838 { 6839 xtstd = xtstd+clock()-to; 6840 #ifdef ENDWALKS 6841 Print("\n// time for the last std(Gw) = %.2f sec\n", 6842 ((double) clock())/1000000 -((double)tim) /1000000); 6843 #endif 6844 } 6845 else 6846 tstd=tstd+clock()-to; 6847 #endif 6848 /* change the ring to oldRing */ 6849 rChangeCurrRing(oldRing); 6850 M1 = idrMoveR(M, newRing,currRing); 6851 Gomega2 = idrMoveR(Gomega1, newRing,currRing); 6852 #ifdef TIME_TEST 6853 to=clock(); 6854 #endif 6855 /* compute a representation of the generators of submod (M) 6856 with respect to those of mod (Gomega). 6857 Gomega is a reduced Groebner basis w.r.t. the current ring */ 6858 F = MLifttwoIdeal(Gomega2, M1, G); 6859 #ifdef TIME_TEST 6860 if(endwalks == FALSE) 6861 tlift = tlift+clock()-to; 6862 else 6863 xtlift=clock()-to; 6864 #endif 6865 #ifdef CHECK_IDEAL_MWALK 6866 if(printout > 2) 6867 { 6868 idString(F,"//** Mprwalk: F"); 6869 } 6870 #endif 6871 6872 idDelete(&M1); 6873 idDelete(&Gomega2); 6874 idDelete(&G); 6875 6876 // change the ring to newRing 6877 rChangeCurrRing(newRing); 6878 if(reduction == 0) 6879 { 6880 G = idrMoveR(F,oldRing,currRing); 6881 } 6882 else 6883 { 6884 F1 = idrMoveR(F, oldRing,currRing); 6885 if(printout > 2) 6886 { 6887 PrintS("\n //** Mprwalk: reduce the Groebner basis.\n"); 6888 } 6889 #ifdef TIME_TEST 6890 to=clock(); 6891 #endif 6892 G = kInterRedCC(F1, NULL); 6893 #ifdef TIME_TEST 6894 if(endwalks == FALSE) 6895 tred = tred+clock()-to; 6896 else 6897 xtred=clock()-to; 6898 #endif 6899 idDelete(&F1); 6900 } 6901 6902 if(endwalks == TRUE) 6903 break; 6904 6905 NEXT_VECTOR: 6906 #ifdef TIME_TEST 6907 to = clock(); 6908 #endif 6909 next_weight = next_weight = MkInterRedNextWeight(curr_weight,target_weight, G); 6910 #ifdef TIME_TEST 6911 tnw = tnw + clock() - to; 6912 #endif 6913 6914 #ifdef TIME_TEST 6915 to = clock(); 6916 #endif 6917 // compute an initial form ideal of <G> w.r.t. "next_vector" 6918 Gomega = MwalkInitialForm(G, next_weight); 6919 #ifdef TIME_TEST 6920 tif = tif + clock()-to; //time for computing initial form ideal 6921 #endif 6922 6923 //lengthpoly(Gomega) = 1 if there is a polynomial in Gomega with at least 3 monomials and 0 otherwise 6924 if(lengthpoly(Gomega) > 0) 6925 { 6926 Print("\n there is a polynomial in Gomega with at least 3 monomials,\n"); 6927 // low-dimensional facet of the cone 6928 delete next_weight; 6929 if(target_M->length() == nV) 6930 { 6931 iv_M = MivMatrixOrder(curr_weight); 6932 } 6933 else 6934 { 6935 iv_M = MivMatrixOrderRefine(curr_weight,target_M); 6936 } 6937 #ifdef TIME_TEST 6938 to = clock(); 6939 #endif 6940 next_weight = MWalkRandomNextWeight(G, iv_M, target_weight, weight_rad, op_deg); 6941 #ifdef TIME_TEST 6942 tnw = tnw + clock() - to; 6943 #endif 6944 idDelete(&Gomega); 6945 #ifdef TIME_TEST 6946 to = clock(); 6947 #endif 6948 Gomega = MwalkInitialForm(G, next_weight); 6949 #ifdef TIME_TEST 6950 tif = tif + clock()-to; //time for computing initial form ideal 6951 #endif 6952 Print("delete\n"); 6953 delete iv_M; 6954 } 6955 6956 /* 6957 to=clock(); 6958 next_weight = MkInterRedNextWeight(curr_weight,target_weight, G); 6959 if(polylength > 0) 6960 { 6961 if(printout > 2) 6962 { 6963 Print("\n //**Mprwalk: there is a polynomial in Gomega with at least 3 monomials, low-dimensional facet of the cone.\n"); 6964 } 6965 delete next_weight; 6966 next_weight = MWalkRandomNextWeight(G, curr_weight, target_weight, weight_rad, op_deg); 6967 } 6968 tnw=tnw+clock()-to; 6969 */ 6970 #ifdef PRINT_VECTORS 6971 if(printout > 0) 6972 { 6973 MivString(curr_weight, target_weight, next_weight); 6974 } 6975 #endif 6976 6977 if(Overflow_Error == TRUE) 6978 { 6979 ntwC = 0; 6980 //Print("\n// ring r%d = %s;\n", nstep, rString(currRing)); 6981 //idElements(G, "G"); 6982 delete next_weight; 6983 goto FINISH_160302; 6984 } 6985 if(MivComp(next_weight, ivNull) == 1){ 6986 newRing = currRing; 6987 delete next_weight; 6988 //Print("\n// ring r%d = %s;\n", nstep, rString(currRing)); 6989 break; 6990 } 6991 if(MivComp(next_weight, target_weight) == 1) 6992 endwalks = TRUE; 6993 6994 for(i=nV-1; i>=0; i--) 6995 (*curr_weight)[i] = (*next_weight)[i]; 6996 6997 delete next_weight; 6998 }// end of while-loop 6999 7000 if(tp_deg != 1) 7001 { 7002 FINISH_160302: 7003 if(target_M->length() == nV) 7004 { 7005 if(MivSame(orig_target, exivlp) == 1) 7006 if (rParameter(currRing) != NULL) 7007 DefRingParlp(); 7008 else 7009 VMrDefaultlp(); 7010 else 7011 if (rParameter(currRing) != NULL) 7012 DefRingPar(orig_target); 7013 else 7014 rChangeCurrRing(VMrDefault(orig_target)); 7015 } 7016 else 7017 { 7018 rChangeCurrRing(VMatrDefault(target_M)); 7019 } 7020 TargetRing=currRing; 7021 F1 = idrMoveR(G, newRing,currRing); 7022 7023 // check whether the pertubed target vector stays in the correct cone 7024 if(ntwC != 0) 7025 { 7026 ntestw = test_w_in_ConeCC(F1, pert_target_vector); 7027 } 7028 if(ntestw != 1 || ntwC == 0) 7029 { 7030 if(ntestw != 1 && printout > 2) 7031 { 7032 #ifdef PRINT_VECTORS 7033 ivString(pert_target_vector, "tau"); 7034 #endif 7035 PrintS("\n// **Mprwalk: perturbed target vector doesn't stay in cone."); 7036 Print("\n// ring r%d = %s;\n", nstep, rString(currRing)); 7037 //idElements(F1, "G"); 7038 } 7039 // LastGB is "better" than the kStd subroutine 7040 #ifdef TIME_TEST 7041 to=clock(); 7042 #endif 7043 ideal eF1; 7044 if(nP == 0 || tp_deg == 1 || MivSame(orig_target, exivlp) != 1 || target_M->length() != nV) 7045 { 7046 if(printout > 2) 7047 { 7048 PrintS("\n// ** Mprwalk: Call \"std\" to compute a Groebner basis.\n"); 7049 } 7050 eF1 = MstdCC(F1); 7051 idDelete(&F1); 7052 } 7053 else 7054 { 7055 if(printout > 2) 7056 { 7057 PrintS("\n// **Mprwalk: Call \"LastGB\" to compute a Groebner basis.\n"); 7058 } 7059 rChangeCurrRing(newRing); 7060 ideal F2 = idrMoveR(F1, TargetRing,currRing); 7061 eF1 = LastGB(F2, curr_weight, tp_deg-1); 7062 F2=NULL; 7063 } 7064 #ifdef TIME_TEST 7065 xtextra=clock()-to; 7066 #endif 7067 ring exTargetRing = currRing; 7068 7069 rChangeCurrRing(XXRing); 7070 Eresult = idrMoveR(eF1, exTargetRing,currRing); 7071 } 7072 else 7073 { 7074 rChangeCurrRing(XXRing); 7075 Eresult = idrMoveR(F1, TargetRing,currRing); 7076 } 7077 } 7078 else 7079 { 7080 rChangeCurrRing(XXRing); 7081 Eresult = idrMoveR(G, newRing,currRing); 7082 } 7083 si_opt_1 = save1; //set original options, e. g. option(RedSB) 7084 delete ivNull; 7085 if(tp_deg != 1) 7086 delete target_weight; 7087 7088 if(op_deg != 1 ) 7089 delete curr_weight; 7090 7091 delete exivlp; 7092 delete last_omega; 7093 7094 #ifdef TIME_TEST 7095 TimeStringFractal(tinput, tostd, tif+xtif, tstd+xtstd,0, tlift+xtlift, tred+xtred, 7096 tnw+xtnw); 7097 7098 //Print("\n// pSetm_Error = (%d)", ErrorCheck()); 7099 //Print("\n// It took %d steps and Overflow_Error? (%d)\n", nstep, Overflow_Error); 7100 #endif 7101 Print("\n//** Mprwalk: Perturbation Walk took %d steps.\n", nstep); 6087 7102 return(Eresult); 6088 7103 } … … 6110 7125 * Perturb the start weight vector at the top level, i.e. nlev = 1 * 6111 7126 ***********************************************************************/ 6112 static ideal rec_fractal_call(ideal G, int nlev, intvec* omtmp) 7127 static ideal rec_fractal_call(ideal G, int nlev, intvec* ivtarget, 7128 int reduction, int printout) 6113 7129 { 6114 7130 Overflow_Error = FALSE; 6115 //Print("\n\n// Entering the %d-th recursion:", nlev); 6116 7131 if(printout >0) 7132 { 7133 Print("\n\n// Entering the %d-th recursion:", nlev); 7134 } 6117 7135 int i, nV = currRing->N; 6118 7136 ring new_ring, testring; 6119 7137 //ring extoRing; 6120 ideal Gomega, Gomega1, Gomega2, F , F1, Gresult, Gresult1, G1, Gt;7138 ideal Gomega, Gomega1, Gomega2, FF, F, F1, Gresult, Gresult1, G1, Gt; 6121 7139 int nwalks = 0; 6122 7140 intvec* Mwlp; … … 6124 7142 intvec* hilb_func; 6125 7143 #endif 6126 //intvec* extXtau;7144 //intvec* extXtau; 6127 7145 intvec* next_vect; 6128 7146 intvec* omega2 = new intvec(nV); 6129 intvec* altomega = new intvec(nV); 6130 7147 intvec* omtmp = new intvec(nV); 7148 //intvec* altomega = new intvec(nV); 7149 7150 for(i = nV -1; i>0; i--) 7151 { 7152 (*omtmp)[i] = (*ivtarget)[i]; 7153 } 6131 7154 //BOOLEAN isnewtarget = FALSE; 6132 7155 … … 6168 7191 nwalks ++; 6169 7192 NEXT_VECTOR_FRACTAL: 7193 #ifdef TIME_TEST 6170 7194 to=clock(); 6171 /* determine the next border */ 7195 #endif 7196 // determine the next border 6172 7197 next_vect = MkInterRedNextWeight(omega,omega2,G); 7198 #ifdef TIME_TEST 6173 7199 xtnw=xtnw+clock()-to; 6174 #ifdef PRINT_VECTORS6175 MivString(omega, omega2, next_vect);6176 7200 #endif 6177 7201 oRing = currRing; 6178 7202 6179 / * We only perturb the current target vector at the recursion level 1 */7203 // We only perturb the current target vector at the recursion level 1 6180 7204 if(Xngleich == 0 && nlev == 1) //(ngleich == 0) important, e.g. ex2, ex3 6181 if (MivComp(next_vect, omega2) != 1) 6182 { 6183 /* to dispense with taking initial (and lifting/interreducing 6184 after the call of recursion */ 6185 //Print("\n\n// ** Perturb the both vectors with degree %d with",nlev); 6186 //idElements(G, "G"); 7205 if (MivComp(next_vect, omega2) == 1) 7206 { 7207 // to dispense with taking initial (and lifting/interreducing 7208 // after the call of recursion 7209 if(printout > 0) 7210 { 7211 Print("\n//** rec_fractal_call: Perturb the both vectors with degree %d.",nlev); 7212 //idElements(G, "G"); 7213 } 6187 7214 6188 7215 Xngleich = 1; 6189 7216 nlev +=1; 6190 7217 6191 if (rParameter(currRing) != NULL) 6192 DefRingPar(omtmp); 7218 if(ivtarget->length() == nV) 7219 { 7220 if (rParameter(currRing) != NULL) 7221 DefRingPar(omtmp); 7222 else 7223 rChangeCurrRing(VMrDefault(omtmp)); 7224 } 6193 7225 else 6194 rChangeCurrRing(VMrDefault1(omtmp)); //Aenderung3 6195 7226 { 7227 rChangeCurrRing(VMatrDefault(ivtarget)); 7228 } 6196 7229 testring = currRing; 6197 7230 Gt = idrMoveR(G, oRing,currRing); 6198 7231 6199 /* perturb the original target vector w.r.t. the current GB */ 6200 delete Xtau; 6201 Xtau = NewVectorlp(Gt); 7232 // perturb the original target vector w.r.t. the current GB 7233 if(ivtarget->length() == nV) 7234 { 7235 delete Xtau; 7236 Xtau = NewVectorlp(Gt); 7237 } 7238 else 7239 { 7240 delete Xtau; 7241 Xtau = Mfpertvector(Gt,ivtarget); 7242 } 6202 7243 6203 7244 rChangeCurrRing(oRing); 6204 7245 G = idrMoveR(Gt, testring,currRing); 6205 7246 6206 / * perturb the current vector w.r.t. the current GB */7247 // perturb the current vector w.r.t. the current GB 6207 7248 Mwlp = MivWeightOrderlp(omega); 6208 7249 Xsigma = Mfpertvector(G, Mwlp); … … 6215 7256 6216 7257 delete next_vect; 7258 #ifdef TIME_TEST 6217 7259 to=clock(); 6218 6219 / * to avoid the value of Overflow_Error that occur in Mfpertvector*/7260 #endif 7261 // to avoid the value of Overflow_Error that occur in Mfpertvector 6220 7262 Overflow_Error = FALSE; 6221 6222 7263 next_vect = MkInterRedNextWeight(omega,omega2,G); 7264 #ifdef TIME_TEST 6223 7265 xtnw=xtnw+clock()-to; 7266 #endif 7267 }// end of (if MivComp(next_vect, omega2) == 1) 6224 7268 6225 7269 #ifdef PRINT_VECTORS 7270 if(printout > 0) 7271 { 6226 7272 MivString(omega, omega2, next_vect); 6227 #endif 6228 } 6229 6230 6231 /* check whether the the computed vector is in the correct cone */ 6232 /* If no, the reduced GB of an omega-homogeneous ideal will be 6233 computed by Buchberger algorithm and stop this recursion step*/ 6234 //if(test_w_in_ConeCC(G, next_vect) != 1) //e.g. Example s7, cyc6 6235 if(Overflow_Error == TRUE) 7273 } 7274 #endif 7275 7276 // check whether the the computed vector is in the correct cone. 7277 // If no, compute the reduced Groebner basis of an omega-homogeneous 7278 // ideal with Buchberger's algorithm and stop this recursion step 7279 if(Overflow_Error == TRUE || test_w_in_ConeCC(G, next_vect) != 1) //e.g. Example s7, cyc6 6236 7280 { 6237 7281 delete next_vect; 6238 if (rParameter(currRing) != NULL) 6239 { 6240 DefRingPar(omtmp); 7282 if(ivtarget->length() == nV) 7283 { 7284 if (rParameter(currRing) != NULL) 7285 DefRingPar(omtmp); 7286 else 7287 rChangeCurrRing(VMrDefault(omtmp)); 6241 7288 } 6242 7289 else 6243 7290 { 6244 rChangeCurrRing(VM rDefault1(omtmp)); // Aenderung47291 rChangeCurrRing(VMatrDefault(ivtarget)); 6245 7292 } 6246 7293 #ifdef TEST_OVERFLOW … … 6248 7295 Gt = NULL; return(Gt); 6249 7296 #endif 6250 6251 //Print("\n\n// apply BB's alg. in ring r = %s;", rString(currRing)); 7297 if(printout > 0) 7298 { 7299 Print("\n//** rec_fractal_call: Applying Buchberger's algorithm in ring r = %s;", 7300 rString(currRing)); 7301 } 7302 #ifdef TIME_TEST 6252 7303 to=clock(); 7304 #endif 6253 7305 Gt = idrMoveR(G, oRing,currRing); 6254 7306 G1 = MstdCC(Gt); 7307 #ifdef TIME_TEST -
Property
mode
changed from