Changeset 74fe358 in git
- Timestamp:
- Aug 17, 2015, 5:19:52 PM (9 years ago)
- Branches:
- (u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', '98550b669234b32be762076c32b3be2c35188ac4')
- Children:
- 36b81ac0b97d2f019093a024dc770731cfabfe17
- Parents:
- 654a230847a8318a2a297f1520550f19f34a4401e3e12979d70ffe1c897b47e9826594e9099b886a
- Files:
-
- 6 added
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/dmodloc.lib
r654a23 r74fe358 64 64 65 65 dmodGeneralAssumptionCheck(); check general assumptions 66 safeVarName(s); finds a free name to use for a new variable67 66 extendWeyl(S); extends basering (Weyl algebra) by given vars 68 67 polyVars(f,v); checks whether f contains only variables indexed by v … … 188 187 189 188 190 proc safeVarName (string s)189 static proc safeVarName (string s) 191 190 " 192 191 USAGE: safeVarName(s); s string -
Singular/LIB/grwalk.lib
re3e129 r74fe358 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/modwalk.lib
-
Property
mode
changed from
100644
to100755
re3e129 r74fe358 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/rwalk.lib
-
Property
mode
changed from
100644
to100755
re3e129 r74fe358 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/dyn_modules/singmathic/singmathic.cc
r654a23 r74fe358 525 525 extern "C" int SI_MOD_INIT(singmathic)(SModulFunctions* psModulFunctions) 526 526 { 527 PrintS("Initializing Singular-Mathic interface Singmathic.\n");528 527 psModulFunctions->iiAddCproc( 529 528 (currPack->libname ? currPack->libname : ""), -
Singular/extra.cc
re3e129 r74fe358 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/feOptTab.h
r654a23 r74fe358 108 108 109 109 {"allow-net", no_argument, LONG_OPTION_RETURN, 110 0, "Allow to fetch (html) help pages from the net",feOptBool, 0, 0},110 0, "Allow one to fetch (html) help pages from the net", feOptBool, 0, 0}, 111 111 112 112 {"browser", required_argument, LONG_OPTION_RETURN, -
Singular/iparith.cc
r654a23 r74fe358 1828 1828 else 1829 1829 { 1830 xx=(number *)omAlloc(rl*sizeof(number));1831 1830 if (nMap==NULL) 1832 1831 { … … 1834 1833 return TRUE; 1835 1834 } 1835 xx=(number *)omAlloc(rl*sizeof(number)); 1836 1836 for(i=rl-1;i>=0;i--) 1837 1837 { … … 1898 1898 // deletes also x 1899 1899 c->Clean(); 1900 if ( return_type==POLY_CMD)1900 if ((return_type==POLY_CMD) &&(result!=NULL)) 1901 1901 { 1902 1902 res->data=(char *)result->m[0]; … … 1913 1913 omFree(q); 1914 1914 res->rtyp=return_type; 1915 return FALSE;1915 return result==NULL; 1916 1916 } 1917 1917 static BOOLEAN jjCOEF(leftv res, leftv u, leftv v) -
Singular/ipid.cc
r654a23 r74fe358 739 739 return NULL; 740 740 } 741 742 BOOLEAN iiAlias(leftv p) 743 { 744 if (iiCurrArgs==NULL) 745 { 746 Werror("not enough arguments for proc %s",VoiceName()); 747 p->CleanUp(); 748 return TRUE; 749 } 750 leftv h=iiCurrArgs; 751 iiCurrArgs=h->next; 752 h->next=NULL; 753 if (h->rtyp!=IDHDL) 754 { 755 BOOLEAN res=iiAssign(p,h); 756 h->CleanUp(); 757 omFreeBin((ADDRESS)h, sleftv_bin); 758 return res; 759 } 760 if ((h->Typ()!=p->Typ()) &&(p->Typ()!=DEF_CMD)) 761 { 762 WerrorS("type mismatch"); 763 return TRUE; 764 } 765 idhdl pp=(idhdl)p->data; 766 switch(pp->typ) 767 { 768 #ifdef SINGULAR_4_1 769 case CRING_CMD: 770 nKillChar((coeffs)pp); 771 break; 772 #endif 773 case DEF_CMD: 774 case INT_CMD: 775 break; 776 case INTVEC_CMD: 777 case INTMAT_CMD: 778 delete IDINTVEC(pp); 779 break; 780 case NUMBER_CMD: 781 nDelete(&IDNUMBER(pp)); 782 break; 783 case BIGINT_CMD: 784 n_Delete(&IDNUMBER(pp),coeffs_BIGINT); 785 break; 786 case MAP_CMD: 787 { 788 map im = IDMAP(pp); 789 omFree((ADDRESS)im->preimage); 790 } 791 // continue as ideal: 792 case IDEAL_CMD: 793 case MODUL_CMD: 794 case MATRIX_CMD: 795 idDelete(&IDIDEAL(pp)); 796 break; 797 case PROC_CMD: 798 case RESOLUTION_CMD: 799 case STRING_CMD: 800 omFree((ADDRESS)IDSTRING(pp)); 801 break; 802 case LIST_CMD: 803 IDLIST(pp)->Clean(); 804 break; 805 case LINK_CMD: 806 omFreeBin(IDLINK(pp),sip_link_bin); 807 break; 808 // case ring: cannot happen 809 default: 810 Werror("unknown type %d",p->Typ()); 811 return TRUE; 812 } 813 pp->typ=ALIAS_CMD; 814 IDDATA(pp)=(char*)h->data; 815 int eff_typ=h->Typ(); 816 if ((RingDependend(eff_typ)) 817 || ((eff_typ==LIST_CMD) && (lRingDependend((lists)h->Data())))) 818 { 819 ipSwapId(pp,IDROOT,currRing->idroot); 820 } 821 h->CleanUp(); 822 omFreeBin((ADDRESS)h, sleftv_bin); 823 return FALSE; 824 } 825 -
Singular/ipshell.cc
r654a23 r74fe358 166 166 switch(IDTYP(h)) 167 167 { 168 case ALIAS_CMD: Print(" for %s",IDID((idhdl)IDDATA(h))); break; 168 169 case INT_CMD: Print(" %d",IDINT(h)); break; 169 170 case INTVEC_CMD:Print(" (%d)",IDINTVEC(h)->length()); break; … … 783 784 v->rtyp=IDEAL_CMD; 784 785 char *tmp = theMap->preimage; 785 786 theMap->preimage=(char*)1L; 786 787 // map gets 1 as its rank (as an ideal) 787 788 v->data=fast_map(IDIDEAL(w), src_ring, (ideal)theMap, currRing); … … 1326 1327 return res; 1327 1328 } 1328 BOOLEAN iiAlias(leftv p)1329 {1330 if (iiCurrArgs==NULL)1331 {1332 Werror("not enough arguments for proc %s",VoiceName());1333 p->CleanUp();1334 return TRUE;1335 }1336 leftv h=iiCurrArgs;1337 iiCurrArgs=h->next;1338 h->next=NULL;1339 if (h->rtyp!=IDHDL)1340 {1341 BOOLEAN res=iiAssign(p,h);1342 h->CleanUp();1343 omFreeBin((ADDRESS)h, sleftv_bin);1344 return res;1345 }1346 if (h->Typ()!=p->Typ())1347 {1348 WerrorS("type mismatch");1349 return TRUE;1350 }1351 idhdl pp=(idhdl)p->data;1352 switch(pp->typ)1353 {1354 #ifdef SINGULAR_4_11355 case CRING_CMD:1356 nKillChar((coeffs)pp);1357 break;1358 #endif1359 case INT_CMD:1360 break;1361 case INTVEC_CMD:1362 case INTMAT_CMD:1363 delete IDINTVEC(pp);1364 break;1365 case NUMBER_CMD:1366 nDelete(&IDNUMBER(pp));1367 break;1368 case BIGINT_CMD:1369 n_Delete(&IDNUMBER(pp),coeffs_BIGINT);1370 break;1371 case MAP_CMD:1372 {1373 map im = IDMAP(pp);1374 omFree((ADDRESS)im->preimage);1375 }1376 // continue as ideal:1377 case IDEAL_CMD:1378 case MODUL_CMD:1379 case MATRIX_CMD:1380 idDelete(&IDIDEAL(pp));1381 break;1382 case PROC_CMD:1383 case RESOLUTION_CMD:1384 case STRING_CMD:1385 omFree((ADDRESS)IDSTRING(pp));1386 break;1387 case LIST_CMD:1388 IDLIST(pp)->Clean();1389 break;1390 case LINK_CMD:1391 omFreeBin(IDLINK(pp),sip_link_bin);1392 break;1393 // case ring: cannot happen1394 default:1395 Werror("unknown type %d",p->Typ());1396 return TRUE;1397 }1398 pp->typ=ALIAS_CMD;1399 IDDATA(pp)=(char*)h->data;1400 h->CleanUp();1401 omFreeBin((ADDRESS)h, sleftv_bin);1402 return FALSE;1403 }1404 1405 1329 static BOOLEAN iiInternalExport (leftv v, int toLev) 1406 1330 { -
Singular/walk.cc
-
Property
mode
changed from
100644
to100755
re3e129 r74fe358 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 6255 7308 xtextra=xtextra+clock()-to; 7309 #endif 6256 7310 Gt = NULL; 6257 7311 6258 7312 delete omega2; 6259 delete altomega; 6260 6261 //Print("\n// Leaving the %d-th recursion with %d steps", nlev, nwalks); 6262 //Print(" ** Overflow_Error? (%d)", Overflow_Error); 7313 //delete altomega; 7314 if(printout > 0) 7315 { 7316 Print("\n//** rec_fractal_call: Overflow. Leaving the %d-th recursion with %d steps.\n", 7317 nlev, nwalks); 7318 //Print(" ** Overflow_Error? (%d)", Overflow_Error); 7319 } 7320 6263 7321 nnflow ++; 6264 6265 7322 Overflow_Error = FALSE; 6266 7323 return (G1); 6267 7324 } 6268 6269 7325 6270 7326 /* If the perturbed target vector stays in the correct cone, … … 6277 7333 if (MivComp(next_vect, XivNull) == 1) 6278 7334 { 6279 if (rParameter(currRing) != NULL) 6280 DefRingPar(omtmp); 7335 if(ivtarget->length() == nV) 7336 { 7337 if (rParameter(currRing) != NULL) 7338 DefRingPar(omtmp); 7339 else 7340 rChangeCurrRing(VMrDefault(omtmp)); 7341 } 6281 7342 else 6282 rChangeCurrRing(VMrDefault1(omtmp)); //Aenderung5 7343 { 7344 rChangeCurrRing(VMatrDefault(ivtarget)); 7345 } 6283 7346 6284 7347 testring = currRing; 6285 7348 Gt = idrMoveR(G, oRing,currRing); 6286 7349 6287 if(test_w_in_ConeCC(Gt, omega2) == 1) { 7350 if(test_w_in_ConeCC(Gt, omega2) == 1) 7351 { 7352 delete omega2; 7353 delete next_vect; 7354 //delete altomega; 7355 if(printout > 0) 7356 { 7357 Print("\n//** rec_fractal_call: Correct cone. Leaving the %d-th recursion with %d steps.\n", 7358 nlev, nwalks); 7359 } 7360 return (Gt); 7361 } 7362 else 7363 { 7364 if(printout > 0) 7365 { 7366 Print("\n//** rec_fractal_call: Wrong cone. Tau doesn't stay in the correct cone.\n"); 7367 } 7368 7369 #ifndef MSTDCC_FRACTAL 7370 intvec* Xtautmp; 7371 if(ivtarget->length() == nV) 7372 { 7373 Xtautmp = Mfpertvector(Gt, MivMatrixOrder(omtmp)); 7374 } 7375 else 7376 { 7377 Xtautmp = Mfpertvector(Gt, ivtarget); 7378 } 7379 #ifdef TEST_OVERFLOW 7380 if(Overflow_Error == TRUE) 7381 Gt = NULL; return(Gt); 7382 #endif 7383 7384 if(MivSame(Xtau, Xtautmp) == 1) 7385 { 7386 if(printout > 0) 7387 { 7388 Print("\n//** rec_fractal_call: Updated vectors are equal to the old vectors.\n"); 7389 } 7390 delete Xtautmp; 7391 goto FRACTAL_MSTDCC; 7392 } 7393 7394 Xtau = Xtautmp; 7395 Xtautmp = NULL; 7396 7397 for(i=nV-1; i>=0; i--) 7398 (*omega2)[i] = (*Xtau)[(nlev-1)*nV+i]; 7399 7400 rChangeCurrRing(oRing); 7401 G = idrMoveR(Gt, testring,currRing); 7402 7403 goto NEXT_VECTOR_FRACTAL; 7404 #endif 7405 7406 FRACTAL_MSTDCC: 7407 if(printout > 0) 7408 { 7409 Print("\n//** rec_fractal_call: Wrong cone. Applying Buchberger's algorithm in ring = %s.\n", 7410 rString(currRing)); 7411 } 7412 #ifdef TIME_TEST 7413 to=clock(); 7414 #endif 7415 G = MstdCC(Gt); 7416 #ifdef TIME_TEST 7417 xtextra=xtextra+clock()-to; 7418 #endif 7419 oRing = currRing; 7420 7421 // update the original target vector w.r.t. the current GB 7422 if(ivtarget->length() == nV) 7423 { 7424 if(MivSame(Xivinput, Xivlp) == 1) 7425 if (rParameter(currRing) != NULL) 7426 DefRingParlp(); 7427 else 7428 VMrDefaultlp(); 7429 else 7430 if (rParameter(currRing) != NULL) 7431 DefRingPar(Xivinput); 7432 else 7433 rChangeCurrRing(VMrDefault(Xivinput)); 7434 } 7435 else 7436 { 7437 rChangeCurrRing(VMatrRefine(ivtarget,Xivinput)); 7438 } 7439 testring = currRing; 7440 Gt = idrMoveR(G, oRing,currRing); 7441 7442 // perturb the original target vector w.r.t. the current GB 7443 if(ivtarget->length() == nV) 7444 { 7445 delete Xtau; 7446 Xtau = NewVectorlp(Gt); 7447 } 7448 else 7449 { 7450 delete Xtau; 7451 Xtau = Mfpertvector(Gt,ivtarget); 7452 } 7453 7454 rChangeCurrRing(oRing); 7455 G = idrMoveR(Gt, testring,currRing); 7456 7457 delete omega2; 7458 delete next_vect; 7459 //delete altomega; 7460 if(printout > 0) 7461 { 7462 Print("\n//** rec_fractal_call: Vectors updated. Leaving the %d-th recursion with %d steps.\n", 7463 nlev, nwalks); 7464 //Print(" ** Overflow_Error? (%d)", Overflow_Error); 7465 } 7466 if(Overflow_Error == TRUE) 7467 nnflow ++; 7468 7469 Overflow_Error = FALSE; 7470 return(G); 7471 } 7472 }// end of (if next_vect==nullvector) 7473 7474 for(i=nV-1; i>=0; i--) { 7475 //(*altomega)[i] = (*omega)[i]; 7476 (*omega)[i] = (*next_vect)[i]; 7477 } 7478 delete next_vect; 7479 #ifdef TIME_TEST 7480 to=clock(); 7481 #endif 7482 // Take the initial form of <G> w.r.t. omega 7483 Gomega = MwalkInitialForm(G, omega); 7484 #ifdef TIME_TEST 7485 xtif=xtif+clock()-to; 7486 #endif 7487 #ifdef CHECK_IDEAL_MWALK 7488 if(printout > 1) 7489 { 7490 idString(Gomega,"//** rec_fractal_call: Gomega"); 7491 } 7492 #endif 7493 if(reduction == 0) 7494 { 7495 // Check whether the intermediate weight vector lies in the interior of the cone. 7496 // If so, only perform reductions. Otherwise apply Buchberger's algorithm. 7497 FF = middleOfCone(G,Gomega); 7498 if( FF != NULL) 7499 { 7500 idDelete(&G); 7501 G = idCopy(FF); 7502 idDelete(&FF); 7503 // Compue next vector. 7504 goto NEXT_VECTOR_FRACTAL; 7505 } 7506 } 7507 7508 #ifndef BUCHBERGER_ALG 7509 if(isNolVector(omega) == 0) 7510 hilb_func = hFirstSeries(Gomega,NULL,NULL,omega,currRing); 7511 else 7512 hilb_func = hFirstSeries(Gomega,NULL,NULL,last_omega,currRing); 7513 #endif 7514 7515 if(ivtarget->length() == nV) 7516 { 7517 if (rParameter(currRing) != NULL) 7518 DefRingPar(omega); 7519 else 7520 rChangeCurrRing(VMrDefault(omega)); 7521 } 7522 else 7523 { 7524 rChangeCurrRing(VMatrRefine(ivtarget,omega)); 7525 } 7526 Gomega1 = idrMoveR(Gomega, oRing,currRing); 7527 7528 // Maximal recursion depth, to compute a red. GB 7529 // Fractal walk with the alternative recursion 7530 // alternative recursion 7531 if(nlev == Xnlev || lengthpoly(Gomega1) == 0) 7532 { 7533 if(printout > 1) 7534 { 7535 Print("\n//** rec_fractal_call: Maximal recursion depth.\n"); 7536 } 7537 #ifdef TIME_TEST 7538 to=clock(); 7539 #endif 7540 #ifdef BUCHBERGER_ALG 7541 Gresult = MstdhomCC(Gomega1); 7542 #else 7543 Gresult =kStd(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,omega); 7544 delete hilb_func; 7545 #endif 7546 #ifdef TIME_TEST 7547 xtstd=xtstd+clock()-to; 7548 #endif 7549 } 7550 else 7551 { 7552 rChangeCurrRing(oRing); 7553 Gomega1 = idrMoveR(Gomega1, oRing,currRing); 7554 Gresult = rec_fractal_call(idCopy(Gomega1),nlev+1,omega,reduction,printout); 7555 } 7556 #ifdef CHECK_IDEAL_MWALK 7557 if(printout > 2) 7558 { 7559 idString(Gresult,"//** rec_fractal_call: M"); 7560 } 7561 #endif 7562 //convert a Groebner basis from a ring to another ring 7563 new_ring = currRing; 7564 7565 rChangeCurrRing(oRing); 7566 Gresult1 = idrMoveR(Gresult, new_ring,currRing); 7567 Gomega2 = idrMoveR(Gomega1, new_ring,currRing); 7568 #ifdef TIME_TEST 7569 to=clock(); 7570 #endif 7571 // Lifting process 7572 F = MLifttwoIdeal(Gomega2, Gresult1, G); 7573 #ifdef TIME_TEST 7574 xtlift=xtlift+clock()-to; 7575 #endif 7576 #ifdef CHECK_IDEAL_MWALK 7577 if(printout > 2) 7578 { 7579 idString(F,"//** rec_fractal_call: F"); 7580 } 7581 #endif 7582 idDelete(&Gresult1); 7583 idDelete(&Gomega2); 7584 idDelete(&G); 7585 7586 rChangeCurrRing(new_ring); 7587 G = idrMoveR(F,oRing,currRing); 7588 /* 7589 F1 = idrMoveR(F, oRing,currRing); 7590 #ifdef TIME_TEST 7591 to=clock(); 7592 #endif 7593 // Interreduce G 7594 G = kInterRedCC(F1, NULL); 7595 #ifdef TIME_TEST 7596 xtred=xtred+clock()-to; 7597 #endif 7598 idDelete(&F1); 7599 */ 7600 } 7601 } 7602 7603 /************************************************************************ 7604 * Perturb the start weight vector at the top level with random element * 7605 ************************************************************************/ 7606 static ideal rec_r_fractal_call(ideal G, int nlev, intvec* ivtarget, 7607 int weight_rad, int reduction, int printout) 7608 { 7609 Overflow_Error = FALSE; 7610 //Print("\n\n// Entering the %d-th recursion:", nlev); 7611 7612 int nwalks = 0,i,nV=currRing->N;//polylength 7613 ring new_ring, testring; 7614 //ring extoRing; 7615 ideal Gomega, Gomega1, Gomega2, F, FF, F1, Gresult, Gresult1, G1, Gt; 7616 intvec* Mwlp; 7617 #ifndef BUCHBERGER_ALG 7618 intvec* hilb_func; 7619 #endif 7620 // intvec* extXtau; 7621 intvec* next_vect; 7622 intvec* iv_M; 7623 intvec* omega2 = new intvec(nV); 7624 intvec* omtmp = new intvec(nV); 7625 intvec* altomega = new intvec(nV); 7626 7627 //BOOLEAN isnewtarget = FALSE; 7628 7629 for(i = nV -1; i>0; i--) 7630 { 7631 (*omtmp)[i] = (*ivtarget)[i]; 7632 } 7633 // to avoid (1,0,...,0) as the target vector (Hans) 7634 intvec* last_omega = new intvec(nV); 7635 for(i=nV-1; i>0; i--) 7636 (*last_omega)[i] = 1; 7637 (*last_omega)[0] = 10000; 7638 7639 intvec* omega = new intvec(nV); 7640 for(i=0; i<nV; i++) { 7641 if(Xsigma->length() == nV) 7642 (*omega)[i] = (*Xsigma)[i]; 7643 else 7644 (*omega)[i] = (*Xsigma)[(nV*(nlev-1))+i]; 7645 7646 (*omega2)[i] = (*Xtau)[(nlev-1)*nV+i]; 7647 } 7648 7649 if(nlev == 1) Xcall = 1; 7650 else Xcall = 0; 7651 7652 ring oRing = currRing; 7653 7654 while(1) 7655 { 7656 #ifdef FIRST_STEP_FRACTAL 7657 /* 7658 perturb the current weight vector only on the top level or 7659 after perturbation of the both vectors, nlev = 2 as the top level 7660 */ 7661 if((nlev == 1 && Xcall == 0) || (nlev == 2 && Xngleich == 1)) 7662 if(islengthpoly2(G) == 1) 7663 { 7664 Mwlp = MivWeightOrderlp(omega); 7665 Xsigma = Mfpertvector(G, Mwlp); 7666 delete Mwlp; 7667 Overflow_Error = FALSE; 7668 } 7669 #endif 7670 nwalks ++; 7671 NEXT_VECTOR_FRACTAL: 7672 #ifdef TIME_TEST 7673 to=clock(); 7674 #endif 7675 /* determine the next border */ 7676 next_vect = MkInterRedNextWeight(omega,omega2,G); 7677 #ifdef TIME_TEST 7678 xtnw=xtnw+clock()-to; 7679 #endif 7680 if(lengthpoly(MwalkInitialForm(G, next_vect)) > 0 && G->m[0] != NULL) 7681 { 7682 if(printout > 0) 7683 { 7684 PrintS("\n**// rec_r_fractal_call: there is a polynomial in Gomega with at least 3 monomials.\n"); 7685 } 7686 delete next_vect; 7687 iv_M = MivMatrixOrder(omega); 7688 #ifdef TIME_TEST 7689 to=clock(); 7690 #endif 7691 next_vect = MWalkRandomNextWeight(G,iv_M,omega2,weight_rad,nlev); 7692 #ifdef TIME_TEST 7693 xtnw=xtnw+clock()-to; 7694 #endif 7695 if(isNegNolVector(next_vect) == 1) 7696 { 7697 delete next_vect; 7698 #ifdef TIME_TEST 7699 to=clock(); 7700 #endif 7701 next_vect = MkInterRedNextWeight(omega,omega2,G); 7702 #ifdef TIME_TEST 7703 xtnw=xtnw+clock()-to; 7704 #endif 7705 } 7706 } 7707 oRing = currRing; 7708 7709 // We only perturb the current target vector at the recursion level 1 7710 if(Xngleich == 0 && nlev == 1) //(ngleich == 0) important, e.g. ex2, ex3 7711 if (MivComp(next_vect, omega2) == 1) 7712 { 7713 // to dispense with taking initials and lifting/interreducing 7714 // after the call of recursion. 7715 if(printout > 0) 7716 { 7717 Print("\n//** rec_r_fractal_call: Perturb both vectors with degree %d.",nlev); 7718 //idElements(G, "G"); 7719 } 7720 Xngleich = 1; 7721 nlev +=1; 7722 if(ivtarget->length() == nV) 7723 { 7724 if (rParameter(currRing) != NULL) 7725 DefRingPar(omtmp); 7726 else 7727 rChangeCurrRing(VMrDefault(omtmp)); 7728 } 7729 else 7730 { 7731 rChangeCurrRing(VMatrDefault(ivtarget)); 7732 } 7733 testring = currRing; 7734 Gt = idrMoveR(G, oRing,currRing); 7735 7736 // perturb the original target vector w.r.t. the current GB 7737 if(ivtarget->length() == nV) 7738 { 7739 delete Xtau; 7740 Xtau = NewVectorlp(Gt); 7741 } 7742 else 7743 { 7744 delete Xtau; 7745 Xtau = Mfpertvector(Gt,ivtarget); 7746 } 7747 7748 rChangeCurrRing(oRing); 7749 G = idrMoveR(Gt,testring,currRing); 7750 7751 // perturb the current vector w.r.t. the current GB 7752 Mwlp = MivWeightOrderlp(omega); 7753 if(ivtarget->length() > nV) 7754 { 7755 delete Mwlp; 7756 Mwlp = MivMatrixOrderRefine(omega,ivtarget); 7757 } 7758 Xsigma = Mfpertvector(G, Mwlp); 7759 delete Mwlp; 7760 7761 for(i=nV-1; i>=0; i--) 7762 { 7763 (*omega2)[i] = (*Xtau)[nV+i]; 7764 (*omega)[i] = (*Xsigma)[nV+i]; 7765 } 7766 7767 delete next_vect; 7768 7769 //to avoid the value of Overflow_Error that occur in Mfpertvector 7770 Overflow_Error = FALSE; 7771 #ifdef TIME_TEST 7772 to=clock(); 7773 #endif 7774 next_vect = MkInterRedNextWeight(omega,omega2,G); 7775 #ifdef TIME_TEST 7776 xtnw=xtnw+clock()-to; 7777 #endif 7778 if(lengthpoly(MwalkInitialForm(G, next_vect)) > 0 && G->m[0] != NULL) 7779 { 7780 // there is a polynomial in Gomega with at least 3 monomials 7781 iv_M = MivMatrixOrder(omega); 7782 delete next_vect; 7783 #ifdef TIME_TEST 7784 to=clock(); 7785 #endif 7786 next_vect = MWalkRandomNextWeight(G,iv_M,omega2,weight_rad,nlev); 7787 #ifdef TIME_TEST 7788 xtnw=xtnw+clock()-to; 7789 #endif 7790 delete iv_M; 7791 if(isNegNolVector(next_vect) == 1) 7792 { 7793 delete next_vect; 7794 #ifdef TIME_TEST 7795 to=clock(); 7796 #endif 7797 next_vect = MkInterRedNextWeight(omega,omega2,G); 7798 #ifdef TIME_TEST 7799 xtnw=xtnw+clock()-to; 7800 #endif 7801 } 7802 } 7803 } 7804 #ifdef PRINT_VECTORS 7805 if(printout > 0) 7806 { 7807 MivString(omega, omega2, next_vect); 7808 } 7809 #endif 7810 7811 /* check whether the the computed vector is in the correct cone 7812 If no, the reduced GB of an omega-homogeneous ideal will be 7813 computed by Buchberger algorithm and stop this recursion step 7814 */ 7815 if(Overflow_Error == TRUE || test_w_in_ConeCC(G,next_vect) != 1)//e.g. Example s7, cyc6 7816 { 7817 delete next_vect; 7818 if(ivtarget->length() == nV) 7819 { 7820 if (rParameter(currRing) != NULL) 7821 { 7822 DefRingPar(omtmp); 7823 } 7824 else 7825 { 7826 rChangeCurrRing(VMrDefault(omtmp)); 7827 } 7828 } 7829 else 7830 { 7831 rChangeCurrRing(VMatrDefault(ivtarget)); 7832 } 7833 #ifdef TEST_OVERFLOW 7834 Gt = idrMoveR(G, oRing,currRing); 7835 Gt = NULL; 7836 return(Gt); 7837 #endif 7838 if(printout > 0) 7839 { 7840 Print("\n//** rec_r_fractal_call: applying Buchberger's algorithm in ring r = %s;", 7841 rString(currRing)); 7842 } 7843 Gt = idrMoveR(G, oRing,currRing); 7844 #ifdef TIME_TEST 7845 to=clock(); 7846 #endif 7847 G1 = MstdCC(Gt); 7848 #ifdef TIME_TEST 7849 xtextra=xtextra+clock()-to; 7850 #endif 7851 Gt = NULL; 7852 7853 delete omega2; 7854 delete altomega; 7855 if(printout > 0) 7856 { 7857 Print("\n//** rec_r_fractal_call: Leaving the %d-th recursion with %d steps.\n", 7858 nlev, nwalks); 7859 //Print(" ** Overflow_Error? (%d)", Overflow_Error); 7860 } 7861 nnflow ++; 7862 Overflow_Error = FALSE; 7863 return (G1); 7864 } 7865 /* 7866 If the perturbed target vector stays in the correct cone, 7867 return the current Groebner basis. 7868 Otherwise, return the Groebner basis computed with Buchberger's 7869 algorithm. 7870 Then we update the perturbed target vectors w.r.t. this GB. 7871 */ 7872 if (MivComp(next_vect, XivNull) == 1) 7873 { 7874 // The computed vector is equal to the origin vector, 7875 // because t is not defined 7876 if(ivtarget->length() == nV) 7877 { 7878 if (rParameter(currRing) != NULL) 7879 DefRingPar(omtmp); 7880 else 7881 rChangeCurrRing(VMrDefault(omtmp)); 7882 } 7883 else 7884 { 7885 rChangeCurrRing(VMatrDefault(ivtarget)); 7886 } 7887 testring = currRing; 7888 Gt = idrMoveR(G, oRing,currRing); 7889 7890 if(test_w_in_ConeCC(Gt, omega2) == 1) 7891 { 6288 7892 delete omega2; 6289 7893 delete next_vect; 6290 7894 delete altomega; 6291 //Print("\n// Leaving the %d-th recursion with %d steps ",nlev, nwalks); 6292 //Print(" ** Overflow_Error? (%d)", Overflow_Error); 6293 7895 if(printout > 0) 7896 { 7897 Print("\n//** rec_r_fractal_call: Leaving the %d-th recursion with %d steps.\n", 7898 nlev, nwalks); 7899 //Print(" ** Overflow_Error? (%d)", Overflow_Error); 7900 } 6294 7901 return (Gt); 6295 7902 } 6296 7903 else 6297 { 6298 //ivString(omega2, "tau'"); 6299 //Print("\n// tau' doesn't stay in the correct cone!!"); 7904 { 7905 if(printout > 0) 7906 { 7907 Print("\n//** rec_r_fractal_call: target weight doesn't stay in the correct cone.\n"); 7908 } 6300 7909 6301 7910 #ifndef MSTDCC_FRACTAL 6302 //07.08.03 6303 //ivString(Xtau, "old Xtau"); 6304 intvec* Xtautmp = Mfpertvector(Gt, MivMatrixOrder(omtmp)); 7911 #ifdef PRINT_VECTORS 7912 if(printout > 0) 7913 { 7914 ivString(Xtau, "old Xtau"); 7915 } 7916 #endif 7917 intvec* Xtautmp; 7918 if(ivtarget->length() == nV) 7919 { 7920 Xtautmp = Mfpertvector(Gt, MivMatrixOrder(omtmp)); 7921 } 7922 else 7923 { 7924 Xtautmp = Mfpertvector(Gt, ivtarget); 7925 } 6305 7926 #ifdef TEST_OVERFLOW 6306 7927 if(Overflow_Error == TRUE) … … 6317 7938 Xtau = Xtautmp; 6318 7939 Xtautmp = NULL; 6319 //ivString(Xtau, "new Xtau"); 7940 #ifdef PRINT_VECTORS 7941 if(printout > 0) 7942 { 7943 ivString(Xtau, "new Xtau"); 7944 } 7945 #endif 6320 7946 6321 7947 for(i=nV-1; i>=0; i--) … … 6330 7956 6331 7957 FRACTAL_MSTDCC: 6332 //Print("\n// apply BB-Alg in ring = %s;", rString(currRing)); 7958 if(printout > 0) 7959 { 7960 Print("\n//** rec_r_fractal_call: apply Buchberger's algorithm in ring = %s.\n", 7961 rString(currRing)); 7962 } 7963 #ifdef TIME_TEST 6333 7964 to=clock(); 7965 #endif 6334 7966 G = MstdCC(Gt); 7967 #ifdef TIME_TEST 6335 7968 xtextra=xtextra+clock()-to; 6336 7969 #endif 6337 7970 oRing = currRing; 6338 7971 6339 7972 // update the original target vector w.r.t. the current GB 6340 if(MivSame(Xivinput, Xivlp) == 1) 6341 if (rParameter(currRing) != NULL) 6342 DefRingParlp(); 7973 if(ivtarget->length() == nV) 7974 { 7975 if(MivSame(Xivinput, Xivlp) == 1) 7976 if (rParameter(currRing) != NULL) 7977 DefRingParlp(); 7978 else 7979 VMrDefaultlp(); 6343 7980 else 6344 VMrDefaultlp(); 7981 if (rParameter(currRing) != NULL) 7982 DefRingPar(Xivinput); 7983 else 7984 rChangeCurrRing(VMrDefault(Xivinput)); 7985 } 6345 7986 else 6346 if (rParameter(currRing) != NULL) 6347 DefRingPar(Xivinput); 6348 else 6349 rChangeCurrRing(VMrDefault1(Xivinput)); //Aenderung6 6350 7987 { 7988 rChangeCurrRing(VMatrRefine(ivtarget,Xivinput)); 7989 } 6351 7990 testring = currRing; 6352 7991 Gt = idrMoveR(G, oRing,currRing); 6353 7992 6354 delete Xtau; 6355 Xtau = NewVectorlp(Gt); 7993 // perturb the original target vector w.r.t. the current GB 7994 if(ivtarget->length() == nV) 7995 { 7996 delete Xtau; 7997 Xtau = NewVectorlp(Gt); 7998 } 7999 else 8000 { 8001 delete Xtau; 8002 Xtau = Mfpertvector(Gt,ivtarget); 8003 } 6356 8004 6357 8005 rChangeCurrRing(oRing); … … 6361 8009 delete next_vect; 6362 8010 delete altomega; 6363 /* 6364 Print("\n// Leaving the %d-th recursion with %d steps,", nlev,nwalks); 6365 Print(" ** Overflow_Error? (%d)", Overflow_Error); 6366 */ 8011 if(printout > 0) 8012 { 8013 Print("\n//** rec_r_fractal_call: Leaving the %d-th recursion with %d steps.\n", 8014 nlev,nwalks); 8015 //Print(" ** Overflow_Error? (%d)", Overflow_Error); 8016 } 6367 8017 if(Overflow_Error == TRUE) 6368 8018 nnflow ++; … … 6371 8021 return(G); 6372 8022 } 6373 } 6374 6375 for(i=nV-1; i>=0; i--) { 8023 } //end of if(MivComp(next_vect, XivNull) == 1) 8024 8025 for(i=nV-1; i>=0; i--) 8026 { 6376 8027 (*altomega)[i] = (*omega)[i]; 6377 8028 (*omega)[i] = (*next_vect)[i]; 6378 8029 } 6379 8030 delete next_vect; 6380 8031 #ifdef TIME_TEST 6381 8032 to=clock(); 6382 /* Take the initial form of <G> w.r.t. omega */ 8033 #endif 8034 // Take the initial form of <G> w.r.t. omega 6383 8035 Gomega = MwalkInitialForm(G, omega); 8036 #ifdef TIME_TEST 6384 8037 xtif=xtif+clock()-to; 8038 #endif 8039 //polylength = 1 if there is a polynomial in Gomega with at least 3 monomials and 0 otherwise 8040 //polylength = lengthpoly(Gomega); 8041 #ifdef CHECK_IDEAL_MWALK 8042 if(printout > 1) 8043 { 8044 idString(Gomega,"//** rec_r_fractal_call: Gomega"); 8045 } 8046 #endif 8047 if(reduction == 0) 8048 { 8049 /* Check whether the intermediate weight vector lies in the interior of the cone. 8050 * If so, only perform reductions. Otherwise apply Buchberger's algorithm. */ 8051 FF = middleOfCone(G,Gomega); 8052 if( FF != NULL) 8053 { 8054 idDelete(&G); 8055 G = idCopy(FF); 8056 idDelete(&FF); 8057 /* Compue next vector. */ 8058 goto NEXT_VECTOR_FRACTAL; 8059 } 8060 } 6385 8061 6386 8062 #ifndef BUCHBERGER_ALG … … 6389 8065 else 6390 8066 hilb_func = hFirstSeries(Gomega,NULL,NULL,last_omega,currRing); 6391 #endif // BUCHBERGER_ALG 6392 6393 if (rParameter(currRing) != NULL) 6394 DefRingPar(omega); 8067 #endif 8068 if(ivtarget->length() == nV) 8069 { 8070 if (rParameter(currRing) != NULL) 8071 DefRingPar(omega); 8072 else 8073 rChangeCurrRing(VMrDefault(omega)); 8074 } 6395 8075 else 6396 rChangeCurrRing(VMrDefault1(omega)); //Aenderung7 6397 8076 { 8077 rChangeCurrRing(VMatrRefine(ivtarget,omega)); 8078 } 6398 8079 Gomega1 = idrMoveR(Gomega, oRing,currRing); 6399 8080 6400 /* Maximal recursion depth, to compute a red. GB */ 6401 /* Fractal walk with the alternative recursion */ 6402 /* alternative recursion */ 6403 // if(nlev == nV || lengthpoly(Gomega1) == 0) 8081 // Maximal recursion depth, to compute a red. GB 8082 // Fractal walk with the alternative recursion 8083 // alternative recursion 6404 8084 if(nlev == Xnlev || lengthpoly(Gomega1) == 0) 6405 //if(nlev == nV) // blind recursion 6406 { 6407 /* 6408 if(Xnlev != nV) 6409 { 6410 Print("\n// ** Xnlev = %d", Xnlev); 6411 ivString(Xtau, "Xtau"); 6412 } 6413 */ 8085 { 8086 #ifdef TIME_TEST 6414 8087 to=clock(); 8088 #endif 6415 8089 #ifdef BUCHBERGER_ALG 6416 8090 Gresult = MstdhomCC(Gomega1); … … 6418 8092 Gresult =kStd(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,omega); 6419 8093 delete hilb_func; 6420 #endif // BUCHBERGER_ALG 8094 #endif 8095 #ifdef TIME_TEST 6421 8096 xtstd=xtstd+clock()-to; 6422 } 6423 else { 8097 #endif 8098 } 8099 else 8100 { 6424 8101 rChangeCurrRing(oRing); 6425 8102 Gomega1 = idrMoveR(Gomega1, oRing,currRing); 6426 Gresult = rec_fractal_call(idCopy(Gomega1),nlev+1,omega); 6427 } 6428 6429 //convert a Groebner basis from a ring to another ring, 8103 Gresult = rec_r_fractal_call(idCopy(Gomega1),nlev+1,omega,weight_rad,reduction,printout); 8104 } 8105 #ifdef CHECK_IDEAL_MWALK 8106 if(printout > 2) 8107 { 8108 idString(Gresult,"//** rec_r_fractal_call: M"); 8109 } 8110 #endif 8111 //convert a Groebner basis from a ring to another ring 6430 8112 new_ring = currRing; 6431 8113 … … 6433 8115 Gresult1 = idrMoveR(Gresult, new_ring,currRing); 6434 8116 Gomega2 = idrMoveR(Gomega1, new_ring,currRing); 6435 8117 #ifdef TIME_TEST 6436 8118 to=clock(); 6437 /* Lifting process */ 8119 #endif 8120 // Lifting process 6438 8121 F = MLifttwoIdeal(Gomega2, Gresult1, G); 8122 #ifdef TIME_TEST 6439 8123 xtlift=xtlift+clock()-to; 8124 #endif 8125 #ifdef CHECK_IDEAL_MWALK 8126 if(printout > 2) 8127 { 8128 idString(F,"//** rec_r_fractal_call: F"); 8129 } 8130 #endif 6440 8131 idDelete(&Gresult1); 6441 8132 idDelete(&Gomega2); … … 6443 8134 6444 8135 rChangeCurrRing(new_ring); 6445 F1 = idrMoveR(F, oRing,currRing); 6446 8136 //F1 = idrMoveR(F, oRing,currRing); 8137 G = idrMoveR(F,oRing,currRing); 8138 /* 8139 #ifdef TIME_TEST 6447 8140 to=clock(); 6448 /* Interreduce G */ 8141 #endif 8142 // Interreduce G 6449 8143 G = kInterRedCC(F1, NULL); 8144 #ifdef TIME_TEST 6450 8145 xtred=xtred+clock()-to; 8146 #endif 6451 8147 idDelete(&F1); 8148 */ 6452 8149 } 6453 8150 } 6454 6455 /************************************************************************6456 * Perturb the start weight vector at the top level with random element *6457 ************************************************************************/6458 static ideal rec_r_fractal_call(ideal G, int nlev, intvec* omtmp, int weight_rad)6459 {6460 Overflow_Error = FALSE;6461 //Print("\n\n// Entering the %d-th recursion:", nlev);6462 6463 int i, nV = currRing->N;6464 ring new_ring, testring;6465 //ring extoRing;6466 ideal Gomega, Gomega1, Gomega2, F, F1, Gresult, Gresult1, G1, Gt;6467 int nwalks = 0;6468 intvec* Mwlp;6469 #ifndef BUCHBERGER_ALG6470 intvec* hilb_func;6471 #endif6472 // intvec* extXtau;6473 intvec* next_vect;6474 intvec* omega2 = new intvec(nV);6475 intvec* altomega = new intvec(nV);6476 6477 //BOOLEAN isnewtarget = FALSE;6478 6479 // to avoid (1,0,...,0) as the target vector (Hans)6480 intvec* last_omega = new intvec(nV);6481 for(i=nV-1; i>0; i--)6482 (*last_omega)[i] = 1;6483 (*last_omega)[0] = 10000;6484 6485 intvec* omega = new intvec(nV);6486 for(i=0; i<nV; i++) {6487 if(Xsigma->length() == nV)6488 (*omega)[i] = (*Xsigma)[i];6489 else6490 (*omega)[i] = (*Xsigma)[(nV*(nlev-1))+i];6491 6492 (*omega2)[i] = (*Xtau)[(nlev-1)*nV+i];6493 }6494 6495 if(nlev == 1) Xcall = 1;6496 else Xcall = 0;6497 6498 ring oRing = currRing;6499 6500 while(1)6501 {6502 #ifdef FIRST_STEP_FRACTAL6503 // perturb the current weight vector only on the top level or6504 // after perturbation of the both vectors, nlev = 2 as the top level6505 if((nlev == 1 && Xcall == 0) || (nlev == 2 && Xngleich == 1))6506 if(islengthpoly2(G) == 1)6507 {6508 Mwlp = MivWeightOrderlp(omega);6509 Xsigma = Mfpertvector(G, Mwlp);6510 delete Mwlp;6511 Overflow_Error = FALSE;6512 }6513 #endif6514 nwalks ++;6515 NEXT_VECTOR_FRACTAL:6516 to=clock();6517 /* determine the next border */6518 next_vect = MWalkRandomNextWeight(G, omega,omega2, weight_rad, 1+nlev);6519 //next_vect = MkInterRedNextWeight(omega,omega2,G);6520 xtnw=xtnw+clock()-to;6521 #ifdef PRINT_VECTORS6522 MivString(omega, omega2, next_vect);6523 #endif6524 oRing = currRing;6525 6526 /* We only perturb the current target vector at the recursion level 1 */6527 if(Xngleich == 0 && nlev == 1) //(ngleich == 0) important, e.g. ex2, ex36528 if (MivComp(next_vect, omega2) == 1)6529 {6530 /* to dispense with taking initial (and lifting/interreducing6531 after the call of recursion */6532 //Print("\n\n// ** Perturb the both vectors with degree %d with",nlev);6533 //idElements(G, "G");6534 6535 Xngleich = 1;6536 nlev +=1;6537 6538 if (rParameter(currRing) != NULL)6539 DefRingPar(omtmp);6540 else6541 rChangeCurrRing(VMrDefault1(omtmp)); //Aenderung36542 6543 testring = currRing;6544 Gt = idrMoveR(G, oRing,currRing);6545 6546 /* perturb the original target vector w.r.t. the current GB */6547 delete Xtau;6548 Xtau = NewVectorlp(Gt);6549 6550 rChangeCurrRing(oRing);6551 G = idrMoveR(Gt, testring,currRing);6552 6553 /* perturb the current vector w.r.t. the current GB */6554 Mwlp = MivWeightOrderlp(omega);6555 Xsigma = Mfpertvector(G, Mwlp);6556 delete Mwlp;6557 6558 for(i=nV-1; i>=0; i--) {6559 (*omega2)[i] = (*Xtau)[nV+i];6560 (*omega)[i] = (*Xsigma)[nV+i];6561 }6562 6563 delete next_vect;6564 to=clock();6565 6566 /* to avoid the value of Overflow_Error that occur in Mfpertvector*/6567 Overflow_Error = FALSE;6568 6569 next_vect = MkInterRedNextWeight(omega,omega2,G);6570 xtnw=xtnw+clock()-to;6571 6572 #ifdef PRINT_VECTORS6573 MivString(omega, omega2, next_vect);6574 #endif6575 }6576 6577 6578 /* check whether the the computed vector is in the correct cone */6579 /* If no, the reduced GB of an omega-homogeneous ideal will be6580 computed by Buchberger algorithm and stop this recursion step*/6581 //if(test_w_in_ConeCC(G, next_vect) != 1) //e.g. Example s7, cyc66582 if(Overflow_Error == TRUE)6583 {6584 delete next_vect;6585 if (rParameter(currRing) != NULL)6586 {6587 DefRingPar(omtmp);6588 }6589 else6590 {6591 rChangeCurrRing(VMrDefault1(omtmp)); // Aenderung46592 }6593 #ifdef TEST_OVERFLOW6594 Gt = idrMoveR(G, oRing,currRing);6595 Gt = NULL; return(Gt);6596 #endif6597 6598 //Print("\n\n// apply BB's alg. in ring r = %s;", rString(currRing));6599 to=clock();6600 Gt = idrMoveR(G, oRing,currRing);6601 G1 = MstdCC(Gt);6602 xtextra=xtextra+clock()-to;6603 Gt = NULL;6604 6605 delete omega2;6606 delete altomega;6607 6608 //Print("\n// Leaving the %d-th recursion with %d steps", nlev, nwalks);6609 //Print(" ** Overflow_Error? (%d)", Overflow_Error);6610 nnflow ++;6611 6612 Overflow_Error = FALSE;6613 return (G1);6614 }6615 6616 6617 /* If the perturbed target vector stays in the correct cone,6618 return the current GB,6619 otherwise, return the computed GB by the Buchberger-algorithm.6620 Then we update the perturbed target vectors w.r.t. this GB. */6621 6622 /* the computed vector is equal to the origin vector, since6623 t is not defined */6624 if (MivComp(next_vect, XivNull) == 1)6625 {6626 if (rParameter(currRing) != NULL)6627 DefRingPar(omtmp);6628 else6629 rChangeCurrRing(VMrDefault1(omtmp)); //Aenderung56630 6631 testring = currRing;6632 Gt = idrMoveR(G, oRing,currRing);6633 6634 if(test_w_in_ConeCC(Gt, omega2) == 1) {6635 delete omega2;6636 delete next_vect;6637 delete altomega;6638 //Print("\n// Leaving the %d-th recursion with %d steps ",nlev, nwalks);6639 //Print(" ** Overflow_Error? (%d)", Overflow_Error);6640 6641 return (Gt);6642 }6643 else6644 {6645 //ivString(omega2, "tau'");6646 //Print("\n// tau' doesn't stay in the correct cone!!");6647 6648 #ifndef MSTDCC_FRACTAL6649 //07.08.036650 //ivString(Xtau, "old Xtau");6651 intvec* Xtautmp = Mfpertvector(Gt, MivMatrixOrder(omtmp));6652 #ifdef TEST_OVERFLOW6653 if(Overflow_Error == TRUE)6654 Gt = NULL; return(Gt);6655 #endif6656 6657 if(MivSame(Xtau, Xtautmp) == 1)6658 {6659 //PrintS("\n// Update vectors are equal to the old vectors!!");6660 delete Xtautmp;6661 goto FRACTAL_MSTDCC;6662 }6663 6664 Xtau = Xtautmp;6665 Xtautmp = NULL;6666 //ivString(Xtau, "new Xtau");6667 6668 for(i=nV-1; i>=0; i--)6669 (*omega2)[i] = (*Xtau)[(nlev-1)*nV+i];6670 6671 //Print("\n// ring tau = %s;", rString(currRing));6672 rChangeCurrRing(oRing);6673 G = idrMoveR(Gt, testring,currRing);6674 6675 goto NEXT_VECTOR_FRACTAL;6676 #endif6677 6678 FRACTAL_MSTDCC:6679 //Print("\n// apply BB-Alg in ring = %s;", rString(currRing));6680 to=clock();6681 G = MstdCC(Gt);6682 xtextra=xtextra+clock()-to;6683 6684 oRing = currRing;6685 6686 // update the original target vector w.r.t. the current GB6687 if(MivSame(Xivinput, Xivlp) == 1)6688 if (rParameter(currRing) != NULL)6689 DefRingParlp();6690 else6691 VMrDefaultlp();6692 else6693 if (rParameter(currRing) != NULL)6694 DefRingPar(Xivinput);6695 else6696 rChangeCurrRing(VMrDefault1(Xivinput)); //Aenderung66697 6698 testring = currRing;6699 Gt = idrMoveR(G, oRing,currRing);6700 6701 delete Xtau;6702 Xtau = NewVectorlp(Gt);6703 6704 rChangeCurrRing(oRing);6705 G = idrMoveR(Gt, testring,currRing);6706 6707 delete omega2;6708 delete next_vect;6709 delete altomega;6710 /*6711 Print("\n// Leaving the %d-th recursion with %d steps,", nlev,nwalks);6712 Print(" ** Overflow_Error? (%d)", Overflow_Error);6713 */6714 if(Overflow_Error == TRUE)6715 nnflow ++;6716 6717 Overflow_Error = FALSE;6718 return(G);6719 }6720 }6721 6722 for(i=nV-1; i>=0; i--) {6723 (*altomega)[i] = (*omega)[i];6724 (*omega)[i] = (*next_vect)[i];6725 }6726 delete next_vect;6727 6728 to=clock();6729 /* Take the initial form of <G> w.r.t. omega */6730 Gomega = MwalkInitialForm(G, omega);6731 xtif=xtif+clock()-to;6732 6733 #ifndef BUCHBERGER_ALG6734 if(isNolVector(omega) == 0)6735 hilb_func = hFirstSeries(Gomega,NULL,NULL,omega,currRing);6736 else6737 hilb_func = hFirstSeries(Gomega,NULL,NULL,last_omega,currRing);6738 #endif // BUCHBERGER_ALG6739 6740 if (rParameter(currRing) != NULL)6741 DefRingPar(omega);6742 else6743 rChangeCurrRing(VMrDefault1(omega)); //Aenderung76744 6745 Gomega1 = idrMoveR(Gomega, oRing,currRing);6746 6747 /* Maximal recursion depth, to compute a red. GB */6748 /* Fractal walk with the alternative recursion */6749 /* alternative recursion */6750 // if(nlev == nV || lengthpoly(Gomega1) == 0)6751 if(nlev == Xnlev || lengthpoly(Gomega1) == 0)6752 //if(nlev == nV) // blind recursion6753 {6754 /*6755 if(Xnlev != nV)6756 {6757 Print("\n// ** Xnlev = %d", Xnlev);6758 ivString(Xtau, "Xtau");6759 }6760 */6761 to=clock();6762 #ifdef BUCHBERGER_ALG6763 Gresult = MstdhomCC(Gomega1);6764 #else6765 Gresult =kStd(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,omega);6766 delete hilb_func;6767 #endif // BUCHBERGER_ALG6768 xtstd=xtstd+clock()-to;6769 }6770 else {6771 rChangeCurrRing(oRing);6772 Gomega1 = idrMoveR(Gomega1, oRing,currRing);6773 Gresult = rec_fractal_call(idCopy(Gomega1),nlev+1,omega);6774 }6775 6776 //convert a Groebner basis from a ring to another ring,6777 new_ring = currRing;6778 6779 rChangeCurrRing(oRing);6780 Gresult1 = idrMoveR(Gresult, new_ring,currRing);6781 Gomega2 = idrMoveR(Gomega1, new_ring,currRing);6782 6783 to=clock();6784 /* Lifting process */6785 F = MLifttwoIdeal(Gomega2, Gresult1, G);6786 xtlift=xtlift+clock()-to;6787 idDelete(&Gresult1);6788 idDelete(&Gomega2);6789 idDelete(&G);6790 6791 rChangeCurrRing(new_ring);6792 F1 = idrMoveR(F, oRing,currRing);6793 6794 to=clock();6795 /* Interreduce G */6796 G = kInterRedCC(F1, NULL);6797 xtred=xtred+clock()-to;6798 idDelete(&F1);6799 }6800 }6801 6802 6803 8151 6804 8152 … … 6807 8155 * * 6808 8156 * The main procedur Mfwalk calls the recursive Subroutine * 6809 * rec_fractal_call to compute the wanted Gr ï¿œbner basis.*6810 * At the main procedur we compute the reduced Gr ï¿œbner basis w.r.t. a "fast"*8157 * rec_fractal_call to compute the wanted Groebner basis. * 8158 * At the main procedur we compute the reduced Groebner basis w.r.t. a "fast" * 6811 8159 * order, e.g. "dp" and a sequence of weight vectors which are row vectors * 6812 8160 * of a matrix. This matrix defines the given monomial order, e.g. "lp" * 6813 8161 *******************************************************************************/ 6814 ideal Mfwalk(ideal G, intvec* ivstart, intvec* ivtarget) 8162 ideal Mfwalk(ideal G, intvec* ivstart, intvec* ivtarget, 8163 int reduction, int printout) 6815 8164 { 8165 BITSET save1 = si_opt_1; // save current options 8166 if(reduction == 0) 8167 { 8168 si_opt_1 &= (~Sy_bit(OPT_REDSB)); // no reduced Groebner basis 8169 //si_opt_1 &= (~Sy_bit(OPT_REDTAIL)); // not tail reductions 8170 } 6816 8171 Set_Error(FALSE); 6817 8172 Overflow_Error = FALSE; … … 6822 8177 Xngleich = 0; 6823 8178 Xcall = 0; 8179 #ifdef TIME_TEST 6824 8180 xtif=0; xtstd=0; xtlift=0; xtred=0; xtnw=0; xtextra=0; 6825 8181 xftinput = clock(); 6826 8182 #endif 6827 8183 ring oldRing = currRing; 6828 8184 int i, nV = currRing->N; … … 6830 8186 Xivinput = ivtarget; 6831 8187 ngleich = 0; 8188 #ifdef TIME_TEST 6832 8189 to=clock(); 8190 #endif 6833 8191 ideal I = MstdCC(G); 6834 8192 G = NULL; 8193 #ifdef TIME_TEST 6835 8194 xftostd=clock()-to; 8195 #endif 6836 8196 Xsigma = ivstart; 6837 8197 … … 6848 8208 intvec* iv_dp = MivUnit(nV); // define (1,1,...,1) 6849 8209 intvec* Mdp; 6850 6851 if(MivSame(ivstart, iv_dp) != 1) 6852 Mdp = MivWeightOrderdp(ivstart); 8210 if(ivstart->length() == nV) 8211 { 8212 if(MivSame(ivstart, iv_dp) != 1) 8213 Mdp = MivWeightOrderdp(ivstart); 8214 else 8215 Mdp = MivMatrixOrderdp(nV); 8216 } 6853 8217 else 6854 Mdp = MivMatrixOrderdp(nV); 8218 { 8219 Mdp = ivstart; 8220 } 6855 8221 6856 8222 Xsigma = Mfpertvector(I, Mdp); … … 6869 8235 Xivlp = Mivlp(nV); 6870 8236 6871 if(MivComp(ivtarget, Xivlp) != 1) 6872 { 6873 if (rParameter(currRing) != NULL) 6874 DefRingPar(ivtarget); 8237 if(ivtarget->length() == nV) 8238 { 8239 if(MivComp(ivtarget, Xivlp) != 1) 8240 { 8241 if (rParameter(currRing) != NULL) 8242 DefRingPar(ivtarget); 8243 else 8244 rChangeCurrRing(VMrDefault(ivtarget)); 8245 8246 I1 = idrMoveR(I, oldRing,currRing); 8247 Mlp = MivWeightOrderlp(ivtarget); 8248 Xtau = Mfpertvector(I1, Mlp); 8249 } 6875 8250 else 6876 rChangeCurrRing(VMrDefault1(ivtarget)); //Aenderung1 6877 6878 I1 = idrMoveR(I, oldRing,currRing); 6879 Mlp = MivWeightOrderlp(ivtarget); 6880 Xtau = Mfpertvector(I1, Mlp); 8251 { 8252 if (rParameter(currRing) != NULL) 8253 DefRingParlp(); 8254 else 8255 VMrDefaultlp(); 8256 8257 I1 = idrMoveR(I, oldRing,currRing); 8258 Mlp = MivMatrixOrderlp(nV); 8259 Xtau = Mfpertvector(I1, Mlp); 8260 } 6881 8261 } 6882 8262 else 6883 8263 { 6884 if (rParameter(currRing) != NULL) 6885 DefRingParlp(); 6886 else 6887 VMrDefaultlp(); 6888 6889 I1 = idrMoveR(I, oldRing,currRing); 6890 Mlp = MivMatrixOrderlp(nV); 8264 rChangeCurrRing(VMatrDefault(ivtarget)); 8265 I1 = idrMoveR(I,oldRing,currRing); 8266 Mlp = ivtarget; 6891 8267 Xtau = Mfpertvector(I1, Mlp); 6892 8268 } … … 6899 8275 id_Delete(&I, oldRing); 6900 8276 ring tRing = currRing; 6901 6902 if (rParameter(currRing) != NULL) 6903 DefRingPar(ivstart); 8277 if(ivtarget->length() == nV) 8278 { 8279 if (rParameter(currRing) != NULL) 8280 DefRingPar(ivstart); 8281 else 8282 rChangeCurrRing(VMrDefault(ivstart)); 8283 } 6904 8284 else 6905 rChangeCurrRing(VMrDefault1(ivstart)); //Aenderung2 8285 { 8286 rChangeCurrRing(VMatrDefault(ivstart)); 8287 } 6906 8288 6907 8289 I = idrMoveR(I1,tRing,currRing); 8290 #ifdef TIME_TEST 6908 8291 to=clock(); 8292 #endif 6909 8293 ideal J = MstdCC(I); 6910 8294 idDelete(&I); 8295 #ifdef TIME_TEST 6911 8296 xftostd=xftostd+clock()-to; 6912 8297 #endif 6913 8298 ideal resF; 6914 8299 ring helpRing = currRing; 6915 8300 6916 J = rec_fractal_call(J, 1, ivtarget);8301 J = rec_fractal_call(J,1,ivtarget,reduction,printout); 6917 8302 6918 8303 rChangeCurrRing(oldRing); … … 6920 8305 idSkipZeroes(resF); 6921 8306 8307 si_opt_1 = save1; //set original options, e. g. option(RedSB) 6922 8308 delete Xivlp; 6923 8309 delete Xsigma; … … 6938 8324 } 6939 8325 6940 ideal Mfrwalk(ideal G, intvec* ivstart, intvec* ivtarget,int weight_rad) 8326 /******************************************************************************* 8327 * The implementation of the fractal walk algorithm with random element * 8328 * * 8329 * The main procedur Mfwalk calls the recursive Subroutine * 8330 * rec_r_fractal_call to compute the wanted Groebner basis. * 8331 * At the main procedure we compute the reduced Groebner basis w.r.t. a "fast" * 8332 * order, e.g. "dp" and a sequence of weight vectors which are row vectors * 8333 * of a matrix. This matrix defines the given monomial order, e.g. "lp" * 8334 *******************************************************************************/ 8335 ideal Mfrwalk(ideal G, intvec* ivstart, intvec* ivtarget, 8336 int weight_rad, int reduction, int printout) 6941 8337 { 8338 BITSET save1 = si_opt_1; // save current options 8339 //check that weight radius is valid 8340 if(weight_rad < 0) 8341 { 8342 Werror("Invalid radius.\n"); 8343 return NULL; 8344 } 8345 if(reduction == 0) 8346 { 8347 si_opt_1 &= (~Sy_bit(OPT_REDSB)); // no reduced Groebner basis 8348 si_opt_1 &= (~Sy_bit(OPT_REDTAIL)); // not tail reductions 8349 } 6942 8350 Set_Error(FALSE); 6943 8351 Overflow_Error = FALSE; … … 6948 8356 Xngleich = 0; 6949 8357 Xcall = 0; 8358 #ifdef TIME_TEST 6950 8359 xtif=0; xtstd=0; xtlift=0; xtred=0; xtnw=0; xtextra=0; 6951 8360 xftinput = clock(); 6952 8361 #endif 6953 8362 ring oldRing = currRing; 6954 8363 int i, nV = currRing->N; … … 6956 8365 Xivinput = ivtarget; 6957 8366 ngleich = 0; 8367 #ifdef TIME_TEST 6958 8368 to=clock(); 8369 #endif 6959 8370 ideal I = MstdCC(G); 6960 8371 G = NULL; 8372 #ifdef TIME_TEST 6961 8373 xftostd=clock()-to; 8374 #endif 6962 8375 Xsigma = ivstart; 6963 8376 … … 6974 8387 intvec* iv_dp = MivUnit(nV); // define (1,1,...,1) 6975 8388 intvec* Mdp; 6976 6977 if(MivSame(ivstart, iv_dp) != 1) 6978 Mdp = MivWeightOrderdp(ivstart); 8389 if(ivstart->length() == nV) 8390 { 8391 if(MivSame(ivstart, iv_dp) != 1) 8392 Mdp = MivWeightOrderdp(ivstart); 8393 else 8394 Mdp = MivMatrixOrderdp(nV); 8395 } 6979 8396 else 6980 Mdp = MivMatrixOrderdp(nV); 8397 { 8398 Mdp = ivstart; 8399 } 6981 8400 6982 8401 Xsigma = Mfpertvector(I, Mdp); … … 6995 8414 Xivlp = Mivlp(nV); 6996 8415 6997 if(MivComp(ivtarget, Xivlp) != 1) 6998 { 6999 if (rParameter(currRing) != NULL) 7000 DefRingPar(ivtarget); 8416 if(ivtarget->length() == nV) 8417 { 8418 if(MivComp(ivtarget, Xivlp) != 1) 8419 { 8420 if (rParameter(currRing) != NULL) 8421 DefRingPar(ivtarget); 8422 else 8423 rChangeCurrRing(VMrDefault(ivtarget)); 8424 8425 I1 = idrMoveR(I, oldRing,currRing); 8426 Mlp = MivWeightOrderlp(ivtarget); 8427 Xtau = Mfpertvector(I1, Mlp); 8428 } 7001 8429 else 7002 rChangeCurrRing(VMrDefault1(ivtarget)); //Aenderung1 7003 7004 I1 = idrMoveR(I, oldRing,currRing); 7005 Mlp = MivWeightOrderlp(ivtarget); 7006 Xtau = Mfpertvector(I1, Mlp); 8430 { 8431 if (rParameter(currRing) != NULL) 8432 DefRingParlp(); 8433 else 8434 VMrDefaultlp(); 8435 8436 I1 = idrMoveR(I, oldRing,currRing); 8437 Mlp = MivMatrixOrderlp(nV); 8438 Xtau = Mfpertvector(I1, Mlp); 8439 } 7007 8440 } 7008 8441 else 7009 8442 { 7010 if (rParameter(currRing) != NULL) 7011 DefRingParlp(); 7012 else 7013 VMrDefaultlp(); 7014 7015 I1 = idrMoveR(I, oldRing,currRing); 7016 Mlp = MivMatrixOrderlp(nV); 8443 rChangeCurrRing(VMatrDefault(ivtarget)); 8444 I1 = idrMoveR(I,oldRing,currRing); 8445 Mlp = ivtarget; 7017 8446 Xtau = Mfpertvector(I1, Mlp); 7018 8447 } … … 7025 8454 id_Delete(&I, oldRing); 7026 8455 ring tRing = currRing; 7027 7028 if (rParameter(currRing) != NULL) 7029 DefRingPar(ivstart); 8456 if(ivtarget->length() == nV) 8457 { 8458 if (rParameter(currRing) != NULL) 8459 DefRingPar(ivstart); 8460 else 8461 rChangeCurrRing(VMrDefault(ivstart)); 8462 } 7030 8463 else 7031 rChangeCurrRing(VMrDefault1(ivstart)); //Aenderung2 8464 { 8465 rChangeCurrRing(VMatrDefault(ivstart)); 8466 } 7032 8467 7033 8468 I = idrMoveR(I1,tRing,currRing); 8469 #ifdef TIME_TEST 7034 8470 to=clock(); 8471 #endif 7035 8472 ideal J = MstdCC(I); 7036 8473 idDelete(&I); 8474 #ifdef TIME_TEST 7037 8475 xftostd=xftostd+clock()-to; 7038 8476 #endif 7039 8477 ideal resF; 7040 8478 ring helpRing = currRing; 7041 //ideal G, int nlev, intvec* omtmp, int weight_rad) 7042 J = rec_r_fractal_call(J, 1, ivtarget,weight_rad);8479 8480 J = rec_r_fractal_call(J,1,ivtarget,weight_rad,reduction,printout); 7043 8481 7044 8482 rChangeCurrRing(oldRing); … … 7046 8484 idSkipZeroes(resF); 7047 8485 8486 si_opt_1 = save1; //set original options, e. g. option(RedSB) 7048 8487 delete Xivlp; 7049 8488 delete Xsigma; … … 7101 8540 intvec* hilb_func; 7102 8541 #endif 7103 / * to avoid (1,0,...,0) as the target vector */8542 // to avoid (1,0,...,0) as the target vector 7104 8543 intvec* last_omega = new intvec(nV); 7105 8544 for(i=nV-1; i>0; i--) … … 7116 8555 7117 8556 to=clock(); 7118 / * compute a red. GB w.r.t. the help ring */8557 // compute a red. GB w.r.t. the help ring 7119 8558 if(MivComp(curr_weight, iv_dp) == 1) //rOrdStr(currRing) = "dp" 7120 8559 G = MstdCC(G); … … 7125 8564 DefRingPar(curr_weight); 7126 8565 else 7127 rChangeCurrRing(VMrDefault(curr_weight)); // Aenderung 48566 rChangeCurrRing(VMrDefault(curr_weight)); 7128 8567 G = idrMoveR(G, XXRing,currRing); 7129 8568 G = MstdCC(G); … … 7151 8590 DefRingPar(curr_weight); 7152 8591 else 7153 rChangeCurrRing(VMrDefault(curr_weight)); //Aenderung 58592 rChangeCurrRing(VMrDefault(curr_weight)); 7154 8593 to=clock(); 7155 8594 Gw = idrMoveR(G, exring,currRing); … … 7186 8625 DefRingPar(curr_weight); 7187 8626 else 7188 rChangeCurrRing(VMrDefault(curr_weight)); //Aenderung 68627 rChangeCurrRing(VMrDefault(curr_weight)); 7189 8628 7190 8629 newRing = currRing; … … 7256 8695 goto BE_FINISH; 7257 8696 #endif 7258 8697 /* 7259 8698 #ifdef CHECK_IDEAL_MWALK 7260 8699 idElements(G, "G"); 7261 8700 //headidString(G, "G"); 7262 8701 #endif 7263 8702 */ 7264 8703 if(MivSame(target_tmp, iv_lp) == 1) 7265 8704 if (rParameter(currRing) != NULL) … … 7271 8710 DefRingPar(target_tmp); 7272 8711 else 7273 rChangeCurrRing(VMrDefault(target_tmp)); // Aenderung 88712 rChangeCurrRing(VMrDefault(target_tmp)); 7274 8713 7275 8714 lpRing = currRing; … … 7331 8770 DefRingPar(target_tmp); 7332 8771 else 7333 rChangeCurrRing(VMrDefault(target_tmp)); //Aenderung 98772 rChangeCurrRing(VMrDefault(target_tmp)); 7334 8773 7335 8774 lpRing = currRing; … … 7534 8973 else 7535 8974 { 7536 rChangeCurrRing(VMrDefault(curr_weight)); // Aenderung 108975 rChangeCurrRing(VMrDefault(curr_weight)); 7537 8976 } 7538 8977 G = idrMoveR(G, XXRing,currRing); … … 7567 9006 else 7568 9007 { 7569 rChangeCurrRing(VMrDefault(curr_weight)); //Aenderung 119008 rChangeCurrRing(VMrDefault(curr_weight)); 7570 9009 } 7571 9010 to=clock(); … … 7610 9049 else 7611 9050 { 7612 rChangeCurrRing(VMrDefault(curr_weight)); // Aenderung 129051 rChangeCurrRing(VMrDefault(curr_weight)); 7613 9052 } 7614 9053 newRing = currRing; … … 7779 9218 else 7780 9219 { 7781 rChangeCurrRing(VMrDefault(target_tmp)); // Aenderung 139220 rChangeCurrRing(VMrDefault(target_tmp)); 7782 9221 } 7783 9222 } … … 7852 9291 else 7853 9292 { 7854 rChangeCurrRing(VMrDefault(target_tmp)); // Aenderung 149293 rChangeCurrRing(VMrDefault(target_tmp)); 7855 9294 } 7856 9295 } … … 7995 9434 clock_t tinput=clock(); 7996 9435 int i, nV = currRing->N; 9436 9437 //check that perturbation degree is valid 9438 if(tp_deg < 1 || tp_deg > nV) 9439 { 9440 Werror("Invalid perturbation degree.\n"); 9441 return NULL; 9442 } 9443 7997 9444 int nwalk=0, endwalks=0, ntestwinC=1; 7998 9445 int tp_deg_tmp = tp_deg; … … 8095 9542 else 8096 9543 { 8097 rChangeCurrRing(VMrDefault(curr_weight)); // Aenderung 159544 rChangeCurrRing(VMrDefault(curr_weight)); 8098 9545 } 8099 9546 newRing = currRing; … … 8104 9551 { 8105 9552 Print("\n// it is %d-th step!!", nwalk); 8106 id Elements(Gomega1, "Gw");9553 idString(Gomega1, "Gw"); 8107 9554 PrintS("\n// compute a rGB of Gw:"); 8108 9555 } … … 8237 9684 8238 9685 //Print("\n// \"Mpwalk\" (1,%d) took %d steps and %.2f sec. Overflow_Error (%d)", tp_deg, nwalk, ((double) clock()-tinput)/1000000, nOverflow_Error); 8239 9686 Print("\n// Mprwalk took %d steps. Ring= %s;\n", nwalk, rString(currRing)); 8240 9687 return(result); 8241 }8242 8243 /*******************************************************8244 * THE PERTURBATION WALK ALGORITHM WITH RANDOM ELEMENT *8245 *******************************************************/8246 ideal Mprwalk(ideal Go, intvec* curr_weight, intvec* target_weight, int weight_rad, int op_deg, int tp_deg, ring baseRing)8247 {8248 BITSET save1 = si_opt_1; // save current options8249 si_opt_1 &= (~Sy_bit(OPT_REDSB)); // no reduced Groebner basis8250 Set_Error(FALSE);8251 Overflow_Error = FALSE;8252 #ifdef TIME_TEST8253 clock_t tinput=0, tostd=0, tif=0, tstd=0, tlift=0, tred=0, tnw=0;8254 xtif=0; xtstd=0; xtlift=0; xtred=0; xtnw=0;8255 tinput = clock();8256 clock_t tim;8257 #endif8258 int i,nwalk,nV = baseRing->N;8259 8260 ideal G, Gomega, M, F, Gomega1, Gomega2, M1;8261 ring newRing;8262 ring XXRing = baseRing;8263 intvec* exivlp = Mivlp(nV);8264 intvec* orig_target = target_weight;8265 intvec* pert_target_vector = target_weight;8266 intvec* ivNull = new intvec(nV);8267 intvec* tmp_weight = new intvec(nV);8268 #ifdef CHECK_IDEAL_MWALK8269 poly p;8270 #endif8271 for(i=0; i<nV; i++)8272 {8273 (*tmp_weight)[i] = (*curr_weight)[i];8274 }8275 #ifndef BUCHBERGER_ALG8276 intvec* hilb_func;8277 // to avoid (1,0,...,0) as the target vector8278 intvec* last_omega = new intvec(nV);8279 for(i=0 i<nV; i++)8280 {8281 (*last_omega)[i] = 1;8282 }8283 (*last_omega)[0] = 10000;8284 #endif8285 baseRing = currRing;8286 newRing = VMrDefault(curr_weight);8287 rChangeCurrRing(newRing);8288 G = idrMoveR(Go,baseRing,currRing);8289 #ifdef TIME_TEST8290 to = clock();8291 #endif8292 G = kStd(G,NULL,testHomog,NULL,NULL,0,0,NULL);8293 idSkipZeroes(G);8294 #ifdef TIME_TEST8295 tostd = tostd + to - clock();8296 #endif8297 #ifdef CHECK_IDEAL_MWALK8298 idString(G,"G");8299 #endif8300 if(op_deg >1)8301 {8302 if(MivComp(curr_weight,MivUnit(nV)) == 1) //ring order is "dp"8303 {8304 curr_weight = MPertVectors(G, MivMatrixOrderdp(nV), op_deg);8305 }8306 else //ring order is not "dp"8307 {8308 curr_weight = MPertVectors(G, MivMatrixOrder(curr_weight), op_deg);8309 }8310 }8311 baseRing = currRing;8312 if(tp_deg > 1 && tp_deg <= nV)8313 {8314 pert_target_vector = target_weight;8315 }8316 #ifdef CHECK_IDEAL_MWALK8317 ivString(curr_weight, "new curr_weight");8318 ivString(target_weight, "new target_weight");8319 #endif8320 nwalk = 0;8321 while(1)8322 {8323 nwalk ++;8324 #ifdef TIME_TEST8325 to = clock();8326 #endif8327 Gomega = MwalkInitialForm(G, curr_weight); // compute an initial form ideal of <G> w.r.t. "curr_vector"8328 #ifdef TIME_TEST8329 tif = tif + clock()-to; //time for computing initial form ideal8330 #endif8331 #ifdef CHECK_IDEAL_MWALK8332 idString(Gomega,"Gomega");8333 #endif8334 #ifndef BUCHBERGER_ALG8335 if(isNolVector(curr_weight) == 0)8336 {8337 hilb_func = hFirstSeries(Gomega,NULL,NULL,curr_weight,currRing);8338 }8339 else8340 {8341 hilb_func = hFirstSeries(Gomega,NULL,NULL,last_omega,currRing);8342 }8343 #endif8344 if(nwalk == 1)8345 {8346 newRing = VMrDefault(curr_weight); // define a new ring with ordering "(a(curr_weight),lp)8347 }8348 else8349 {8350 newRing = VMrRefine(curr_weight,target_weight); //define a new ring with ordering "(a(curr_weight),Wp(target_weight))"8351 }8352 rChangeCurrRing(newRing);8353 Gomega1 = idrMoveR(Gomega, baseRing,currRing);8354 idDelete(&Gomega);8355 // compute a Groebner basis of <Gomega> w.r.t. "newRing"8356 #ifdef TIME_TEST8357 to = clock();8358 #endif8359 #ifndef BUCHBERGER_ALG8360 M=kStd(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,curr_weight);8361 delete hilb_func;8362 #else8363 M = kStd(Gomega1,NULL,testHomog,NULL,NULL,0,0,NULL);8364 #endif8365 idSkipZeroes(M);8366 #ifdef TIME_TEST8367 tstd = tstd + clock() - to;8368 #endif8369 #ifdef CHECK_IDEAL_MWALK8370 idString(M, "M");8371 #endif8372 //change the ring to baseRing8373 rChangeCurrRing(baseRing);8374 M1 = idrMoveR(M, newRing,currRing);8375 idDelete(&M);8376 Gomega2 = idrMoveR(Gomega1, newRing,currRing);8377 idDelete(&Gomega1);8378 to = clock();8379 // 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 ring8380 F = MLifttwoIdeal(Gomega2, M1, G);8381 idSkipZeroes(F);8382 #ifdef TIME_TEST8383 tlift = tlift + clock() - to;8384 #endif8385 #ifdef CHECK_IDEAL_MWALK8386 idString(F,"F");8387 #endif8388 rChangeCurrRing(newRing); // change the ring to newRing8389 G = idrMoveR(F,baseRing,currRing);8390 idDelete(&F);8391 baseRing = currRing; // set baseRing equal to newRing8392 #ifdef CHECK_IDEAL_MWALK8393 idString(G,"G");8394 #endif8395 #ifdef TIME_TEST8396 to = clock();8397 #endif8398 intvec* next_weight = MWalkRandomNextWeight(G, curr_weight, target_weight, weight_rad, op_deg);8399 #ifdef TIME_TEST8400 tnw = tnw + clock() - to;8401 #endif8402 #ifdef PRINT_VECTORS8403 MivString(curr_weight, target_weight, next_weight);8404 #endif8405 if(Overflow_Error == TRUE)8406 {8407 PrintS("\n//**Mprwalk: OVERFLOW: The computed vector does not stay in cone, the result may be wrong.\n");8408 delete next_weight;8409 break;8410 }8411 8412 if(test_w_in_ConeCC(G,target_weight) == 1 || MivComp(next_weight, ivNull) == 1)8413 {8414 delete next_weight;8415 break;8416 }8417 //update tmp_weight and curr_weight8418 for(i=nV-1; i>=0; i--)8419 {8420 (*tmp_weight)[i] = (*curr_weight)[i];8421 (*curr_weight)[i] = (*next_weight)[i];8422 }8423 delete next_weight;8424 } //end of while-loop8425 Print("\n// Mprwalk took %d steps. Ring= %s;\n", nwalk, rString(currRing));8426 idSkipZeroes(G);8427 si_opt_1 = save1; //set original options, e. g. option(RedSB)8428 baseRing = currRing;8429 rChangeCurrRing(XXRing);8430 ideal Res = idrMoveR(G,baseRing,currRing);8431 delete tmp_weight;8432 delete ivNull;8433 delete exivlp;8434 #ifndef BUCHBERGER_ALG8435 delete last_omega;8436 #endif8437 #ifdef TIME_TEST8438 TimeString(tinput, tostd, tif, tstd, tlift, tred, tnw, nstep);8439 #endif8440 return(Res);8441 9688 } 8442 9689 … … 8517 9764 else 8518 9765 { 8519 rChangeCurrRing(VMrDefault(cw_tmp)); // Aenderung 169766 rChangeCurrRing(VMrDefault(cw_tmp)); 8520 9767 } 8521 9768 G = idrMoveR(Go, XXRing,currRing); … … 8591 9838 else 8592 9839 { 8593 rChangeCurrRing(VMrDefault(curr_weight)); // Aenderung 179840 rChangeCurrRing(VMrDefault(curr_weight)); 8594 9841 } 8595 9842 newRing = currRing; … … 8653 9900 else 8654 9901 { 8655 rChangeCurrRing(VMrDefault(target_weight)); // Aenderung 189902 rChangeCurrRing(VMrDefault(target_weight)); 8656 9903 } 8657 9904 F1 = idrMoveR(G, newRing,currRing); -
Property
mode
changed from
-
Singular/walk.h
-
Property
mode
changed from
100644
to100755
re3e129 r74fe358 52 52 53 53 /* Okt -- Nov'01 */ 54 // compute a Groebner basis of an ideal G w.r.t. lexicographic order 54 // compute a Groebner basis of an ideal G w.r.t. lexicographic order 55 55 //ideal Mwalk(ideal Go, intvec* orig_M, intvec* target_M); 56 ideal Mwalk(ideal Go, intvec* orig_M, intvec* target_M, ring baseRing );56 ideal Mwalk(ideal Go, intvec* orig_M, intvec* target_M, ring baseRing, int reduction, int printout); 57 57 58 58 // random walk algorithm to compute a Groebner basis 59 ideal Mrwalk(ideal Go, intvec* curr_weight, intvec* target_weight, int weight_rad, int pert_deg, ring baseRing); 59 60 ideal Mrwalk(ideal Go, intvec* orig_M, intvec* target_M, int weight_rad, int pert_deg, int reduction, int printout); 60 61 61 62 /* the perturbation walk algorithm */ 62 63 63 ideal Mpwalk(ideal Go, int op_deg, int tp_deg,intvec* curr_weight,intvec* target_weight, int nP );64 ideal Mpwalk(ideal Go, int op_deg, int tp_deg,intvec* curr_weight,intvec* target_weight, int nP, int reduction, int printout); 64 65 65 66 /* the perturbation walk algorithm with random element */ 66 67 ideal Mprwalk(ideal Go, intvec* curr_weight, intvec* target_weight, int weight_rad, int op_deg, int tp_deg, ring baseRing); 67 ideal Mprwalk(ideal Go, intvec* orig_M, intvec* target_M, int weight_rad, int op_deg, int tp_deg, int nP, int reduction, int printout); 68 68 69 69 /* The fractal walk algorithm */ 70 ideal Mfwalk(ideal G, intvec* ivstart, intvec* ivtarget );70 ideal Mfwalk(ideal G, intvec* ivstart, intvec* ivtarget, int reduction, int printout); 71 71 72 72 /* The fractal walk algorithm with random element */ 73 ideal Mfrwalk(ideal G, intvec* ivstart, intvec* ivtarget, int weight_rad);73 ideal Mfrwalk(ideal G, intvec* ivstart, intvec* ivtarget, int weight_rad, int reduction, int printout); 74 74 75 75 /* Implement Tran's idea */ -
Property
mode
changed from
-
Tst/Plural/derham.res.gz.uu
r654a23 r74fe358 1 1 begin 640 derham.res.gz 2 M'XL(" (/O0%4``V1E<FAA;2YR97,`I=?=;MHP%`#@^SR%A781(-#XWRD":>MZ3 M 48E5TSI5D]#4IDIHHU%2)51+>/HE#;%-FJ:IQPWFV([QIW.PN?KY]>(2```74 M 8'GQ!0QVZ6ZZB>X&,U"T;J)MM+.'A_;]-DY">W!R`D8CL(G](`S`H+7S!D0I5 M V,8@W?G;P$\"<.>G45J,M<H'@L4"!&'RX#].M^'?:3%H9Q7SU&-.P=$:[9WM6 M :UA7A_V@PWZ"\$>YT,N6K&IF$@;ANO@BVWMPF_KK\-I/+OW'\+;HD]/Q`L@V7 M F19+3GJ^Y"Q:SCK_]?G;]^4Y@#+,C![&IR`IOV\R=QT[<_*A$SS-9*]8@*=X8 M DX/U/$>3#$]0-L:JUUN`393NP')>69S%#_%CO(GO<WL]E,.@6X#-K!7\?6J59 M Z6"MD&SAJH7DV")9_D2;#4B<<DX=1<H,8I-M0J*;J>6HT<-8EQGD#;-,=8E^10 M 8%Y_,.2V@2&HP!`RV2/".AB68:.,1;0+#+&#RMF\?+,S-('%J#$<CG(G']DY11 M &J/RDP)"_&W',VV8>,/1E8Y%BU0M8JUH':OG>VVVV%6V&)IP8*3;$ADVRFQ,12 M &K;._D@7TX;NR,XF<%B.&]G[LK6O(LH-LUZ\F'^`U]5X5ZQJ86O%&^18M))[13 M BIRX)DH$ZN14AHUJ@^!N<D*:Y&4>[Y4<H1W`SN`Z2,*7(ZT>SM[]/5#04$++14 M DX'P-E0B-%3/Q(&Z.BJ38:.BH.@5JO-\Q$IQ@_4P1@T@O?*6TO_,6U?+VY5H15 M 8%/6ADVYPJ;"R,?3L7D=9D;EP&!W!C,DS[`,CW,\WJM3G^%>AQ@C/0ZQ6ED>16 M 9XRVZ3&F]!@WVK#0]80,&^4]=[OU.%1Z:%P<7WND^E"'WNO2Y_@#I2]_13EI17 M 4^14*7*CRR+GNJ(GPT8)S;WW"EZXS8M!A:G7O("]:EZ@#]0\;*WY^DFXS58018 M 92N*VXYL&SF+(V>HUC:"%J^ACYB]!G-Y1<A?K@CHZ%K@]:/VWJ+N/JWD)KU619 <8$\#]@K@\E];^??N.;7A</;)^@?Q'F.9;0X`````2 M'XL("`)WP%4``V1E<FAA;2YR97,`I==;;]HP%`#@]_P*"^TA0*#QW6X%TM;U 3 MH1*;IG6:)J&IH@IMHZ6D2JB6\.L7%V*;-$U3CY<>CB^I/XZQN?KQ^?(K``#. 4 MP>+R$QAL\^TTB6\&9Z"*KN--O/6'A_ANDV9K?W!R`D8CD*2K:!V!06OC-8AS 5 ML$E!OEUMHE46@9M5'N=57T]-".9S$*VS^]7#=+/^.ZTZ;;UJG)GF%!P]H[VQ 6 M_1G>U6$]Z+">:/U=/>AY2;H1SX&.R;2:<-+SI4=1->KBU\<OWQ87`.HT<YJ, 7 M3T$6;^Y`-@L#OPC*81`]FG]6S,%CFI3@=E:B28$GJ!ACTRKG((GS+5C,]BL] 8 M3^_3AS1)[TK_=JB[P;#B./.6\/>IISYL;XETA/<1TGVK4O@3)PG(`C6FSB)C 9 M!K'+,B&QS<SCJ--DK,L,\H9989I$/S#9'PR%;6`(&C"$7-:(L`V&==JI8A'M 10 M`D/LH'(^4W_\`DU@U6L,AZ,R*$=^B<9(O3-`B+_N>&YU$Z\XAMJQBL@^(MZ2 11 MUKEZO&RSQ:&QQ="%`R/;ENBT4V5CTK`-=D>ZF#9T1WXQ@4/5;^3O5+3;9XP; 12 M9KUX,7\';VCQ+MD^PMZ2-\BQ:"67AIR$+DH$VN14IYWV!L'=Y(0TR54=[XP< 13 MH1W`P>!GE*V?#ZRZ.WOS^\!`0PVM3P;"VU")L%"EBP,-;52FTTZ;@J(7J,'3 14 M$2O%#=9#'].!]*I;2O^S;D.K;I>B@4U9&S;E!IL*)Q]I8_,ZS9RV`X/=%<R0 15 M/L,*/"[Q>&=.?89['6*,]#C$:F5]G#':IL>8T6/<:<'"UA,Z[53W/.S6X]#H 16 MH7%U?.V0:4,=>B^W/L?OV/KZ6Y23-D5.C2)WNBQR;BM*G78J:"[?VO`B;%X, 17 M]ICVGA>PUYX7Z!U['K;N^7HFW&8KB+$5U6U'QT[.XL@9FF<[08N7T$?,LL&L 18 MK@CE\Q4!'5T+9#]J^1IU]VFE%RE;@:4%+"M@]9M,_7A[RGTX//O@_0-O58,G 19 $2PX````` 20 20 ` 21 21 end -
Tst/Short/alias.res.gz.uu
r654a23 r74fe358 1 1 begin 640 alias.res.gz 2 M'XL(" "2@A4\``V%L:6%S+G)E<P#M4\MNPC`0O.<K5E4/21N9V.%5(G)`O2!53 M O=`;JE`H`1E9`=EN2XOX]ZX=<'P(53^@.22V=W9V=C.>O3Q.GP&`YO`TG<"-4 M 5IH(OKS)@MDYPG+`PP6ON`ZC+#!?R',H!"\4J<I/HG2A'3K-P:V[!/9R]V9>5 M RS*T"2"XTE#(C8H<K$?@Z#9]8J--^2$!_;4O=^O09KD`30CP2@.',2C^7=KP6 M G+YZ"$;@Y#:>,(K")*\V(#$WB>$0PVK?I/5RX*NR$);ZT)SW\UJ]P&.S"'D,7 M S"LW\"H,R;EK@0!4-0JPE04NQH=@SNHM"PR+2WEHTEGB3X[YH^,1'(%G<')U8 M &?42L64+JU`C;2#8_)FJ\O10%^]Z%#V_=GJN;2==ES;\'X5$+_@B^A[#H/XS9 MV S%KXL/\0KA%!2SH='"\+0]J@]I;!K)MA20(,04L2W458H3&UALC;!6A\BKT10 M SMC!0.PC_D3)'+Z]$:O2^BB<3:(8*&S*JI2%WLD0W8_)YEJ9R_.N%FLN2B]/11 M :>O/]CO&/*>D";G,E=X;,Z:_3]:,+?V?[)7)IMY52O$J-30AC;+;X`<31!RO12 $+04`````2 M'XL("`?2S54``V%L:6%S+G)E<P#M4SUOPC`0W?,K3JA#TD8F=O@J$1E0%Z2J 3 M"]U0A4()R%&4(,=M:1'_O6<G.!Y0H4.W9@#;=^_=NZ_Y\\/L"0!H#(^S*71D 4 M)4G.5YW(F3<6%@,^+GG!I>M%COJ'.(8DYTE%BO2#5#*1QCN,P9Q[!':B?%4_ 5 MJ]35`,AY)2$1V\HS;GT"!W,9$&UMPX\(R,]=6FY<C3(&&A#@A00.$ZCX5ZK- 6 M"_IB>3`"1W.QA%$4)GBQ!8'8P(>]#^M="^O'P-=IDFOJ??L^B&OU.3ZK@\M] 7 M8%:XH15A1)JL<W1`56,'4UGB8;)W%JR^,D>Q&,A]"V>!73EFEXY[<``>P='$ 8 M9=0"8LK:K4"-M'7!Y!NJPM)#C;UG4?3MV&$36U>Z#JWXWQ.!LV"+&%@,P[HS 9 MV82U]E%\(LQ0`7.Z72SOCQ^JA'K*8%,*R!0DNP`)$*)":_[B"F>5C*_G9XSE 10 M0)"X`G2KAD<YZR__91AFD)<*H+/1D^C.IYX/%+9ID8I$EL+%_4$:M9AJ_=ZJ 11 MY8;GZ5F&2NI9/[^OS)JZ,""G'M$[-=CAM5U2)0__^_,'_0FMY0YQN5M"EWK1 12 +C?,-2!0&\[\%```` 13 13 ` 14 14 end -
Tst/Short/ok_s.lst
r654a23 r74fe358 46 46 bug_tr723 47 47 bug_tr724 48 bug_732 49 bug_tr735 48 50 bug_genus_etc 49 51 conv_bi -
doc/Singular.man
r654a23 r74fe358 48 48 .TP 49 49 \fB\-\-allow\-net\fR 50 Allow to fetch (html) help pages from the net50 Allow one to fetch (html) help pages from the net 51 51 .TP 52 52 \fB\-\-browser\fR=\fIBROWSER\fR -
kernel/ideals.cc
r654a23 r74fe358 928 928 } 929 929 } 930 s_temp->rank += k; 930 931 } 931 932 … … 1024 1025 } 1025 1026 } 1027 s_temp->rank += k; 1026 1028 } 1027 1029 ideal s_result = kNF(s_h3,currRing->qideal,s_temp,k); -
libpolys/polys/monomials/p_polys.cc
r654a23 r74fe358 116 116 { 117 117 hh=xx[j]; 118 if ((hh!=NULL) && (p_LmCmp( r,hh,R)==0))118 if ((hh!=NULL) && (p_LmCmp(h,hh,R)==0)) 119 119 { 120 120 x[j]=pGetCoeff(hh); -
libpolys/polys/simpleideals.cc
r654a23 r74fe358 1721 1721 ideal id_ChineseRemainder(ideal *xx, number *q, int rl, const ring r) 1722 1722 { 1723 int cnt=IDELEMS(xx[0])*xx[0]->nrows; 1723 int cnt=0;int rw=0; int cl=0; 1724 int i,j; 1725 // find max. size of xx[.]: 1726 for(j=rl-1;j>=0;j--) 1727 { 1728 i=IDELEMS(xx[j])*xx[j]->nrows; 1729 if (i>cnt) cnt=i; 1730 if (xx[j]->nrows >rw) rw=xx[j]->nrows; // for lifting matrices 1731 if (xx[j]->ncols >cl) cl=xx[j]->ncols; // for lifting matrices 1732 } 1733 if (rw*cl !=cnt) 1734 { 1735 WerrorS("format mismatch in CRT"); 1736 return NULL; 1737 } 1724 1738 ideal result=idInit(cnt,xx[0]->rank); 1725 result->nrows=xx[0]->nrows; // for lifting matrices 1726 result->ncols=xx[0]->ncols; // for lifting matrices 1727 int i,j; 1739 result->nrows=rw; // for lifting matrices 1740 result->ncols=cl; // for lifting matrices 1728 1741 number *x=(number *)omAlloc(rl*sizeof(number)); 1729 1742 poly *p=(poly *)omAlloc(rl*sizeof(poly)); 1730 CFArray inv_cache(rl); ;1743 CFArray inv_cache(rl); 1731 1744 for(i=cnt-1;i>=0;i--) 1732 1745 { 1733 1746 for(j=rl-1;j>=0;j--) 1734 1747 { 1735 p[j]=xx[j]->m[i]; 1748 if(i>=IDELEMS(xx[j])*xx[j]->nrows) // out of range of this ideal 1749 p[j]=NULL; 1750 else 1751 p[j]=xx[j]->m[i]; 1736 1752 } 1737 1753 result->m[i]=p_ChineseRemainder(p,x,q,rl,inv_cache,r); 1738 1754 for(j=rl-1;j>=0;j--) 1739 1755 { 1740 xx[j]->m[i]=p[j];1756 if(i<IDELEMS(xx[j])*xx[j]->nrows) xx[j]->m[i]=p[j]; 1741 1757 } 1742 1758 } -
omalloc/omAllocFunc.h
r654a23 r74fe358 12 12 void omFreeFunc(void* addr); 13 13 void* omVallocFunc(size_t size); 14 #if defined(sgi)15 14 void* omMemalignFunc(size_t size_1, size_t size_2); 16 #else17 #if (defined(__sun) && (defined(__sparc) || defined(__i386) || defined(__x86_64)) || defined(__CYGWIN__))18 extern void* omMemalignFunc(size_t, size_t);19 #else20 void* omMemalignFunc(void* alignment, size_t size);21 #endif22 #endif23 15 void* omReallocFunc(void* old_addr, size_t new_size); 24 16 char* omStrdupFunc(const char* addr); -
omalloc/omalloc.c
r654a23 r74fe358 47 47 } 48 48 49 #if defined(sgi)50 49 void* memalign(size_t size_1, size_t size_2) 51 #elif (defined(__sun) && (defined(__sparc) || defined(__i386) || defined(__x86_64)) || defined(__CYGWIN__))52 void* memalign(size_t size_1, size_t size_2)53 #else54 void* memalign(void* alignment, size_t size)55 #endif56 50 { 57 51 fprintf(stderr, "omalloc Warning: memalign not yet implemented\n");
Note: See TracChangeset
for help on using the changeset viewer.