Changeset b2e4bd in git
- Timestamp:
- Jun 16, 2011, 12:01:59 PM (12 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
- Children:
- ccd1b0f4ccf9a7be41b783b8f77aef7cc476ffe8
- Parents:
- 9189e93eec836e1bd1e7b9961d718cb4ecce03c9
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/assprimeszerodim.lib
r9189e93 rb2e4bd 31 31 parallel computing) 32 32 ASSUME: I is zero-dimensional in Q[variables] 33 NOTE: Parallelization is just applicable using 32-bit Singular version since34 MP-links are not compatible with 64-bit Singular version.35 33 RETURN: the radical of I 36 34 EXAMPLE: example zeroRadical; shows an example … … 66 64 if(size(#) > 0) 67 65 { 68 int n = #[1]; 69 if((n > 1) && (1 - system("with","MP"))) 70 { 71 "========================================================================"; 72 "There is no MP available on your system. Since this is necessary to "; 73 "parallelize the algorithm, the computation will be done without forking."; 74 "========================================================================"; 75 n = 1; 66 int n1 = #[1]; 67 if(n1 >= 10) 68 { 69 int n2 = n1 + 1; 70 int n3 = n1; 71 } 72 else 73 { 74 int n2 = 10; 75 int n3 = 10; 76 76 } 77 77 } 78 78 else 79 79 { 80 int n = 1; 80 int n1 = 1; 81 int n2 = 10; 82 int n3 = 10; 81 83 } 82 84 83 85 //-------------------- Initialize the list of primes ------------------------- 84 intvec L = primeList(I, 10);86 intvec L = primeList(I,n2); 85 87 L[5] = prime(random(100000000,536870912)); 86 88 87 if(n > 1) 88 { 89 90 //----- Create n links l(1),...,l(n), open all of them and compute ----------- 91 //----- polynomial F for the primes L[2],...,L[n + 1]. ----------- 92 93 for(i = 1; i <= n; i++) 94 { 95 link l(i) = "MPtcp:fork"; 89 if(n1 > 1) 90 { 91 92 //----- Create n links l(1),...,l(n1), open all of them and compute ---------- 93 //----- polynomial F for the primes L[2],...,L[n1 + 1]. ---------- 94 95 for(i = 1; i <= n1; i++) 96 { 97 //link l(i) = "MPtcp:fork"; 98 link l(i) = "ssi:fork"; 96 99 open(l(i)); 97 100 write(l(i), quote(zeroRadP(eval(I), eval(L[i + 1])))); … … 107 110 index++; 108 111 109 j = j + n + 1;112 j = j + n1 + 1; 110 113 } 111 114 … … 114 117 while(!crit) 115 118 { 116 if(n > 1)119 if(n1 > 1) 117 120 { 118 121 while(j <= size(L) + 1) 119 122 { 120 for(i = 1; i <= n ; i++)123 for(i = 1; i <= n1; i++) 121 124 { 122 125 if(status(l(i), "read", "ready")) … … 141 144 } 142 145 //--- k describes the number of closed links --- 143 if(k == n )146 if(k == n1) 144 147 { 145 148 j++; … … 151 154 else 152 155 { 153 while(j <=size(L))156 while(j <= size(L)) 154 157 { 155 158 P = zeroRadP(I, L[j]); … … 164 167 G = chinrem(CO1,CO2); 165 168 N = CO2[1]; 166 for(i = 2; i <= size(CO2); i++){ N = N*CO2[i];}169 for(i = 2; i <= size(CO2); i++){ N = N*CO2[i]; } 167 170 F = farey(G,N); 168 171 … … 180 183 181 184 j = size(L) + 1; 182 L = primeList(I, 10,L);183 184 if(n > 1)185 L = primeList(I,n3,L); 186 187 if(n1 > 1) 185 188 { 186 for(i = 1; i <= n ; i++)189 for(i = 1; i <= n1; i++) 187 190 { 188 191 open(l(i)); 189 192 write(l(i), quote(zeroRadP(eval(I), eval(L[j+i-1])))); 190 193 } 191 j = j + n ;194 j = j + n1; 192 195 k = 0; 193 196 } … … 204 207 205 208 if(k == 0) { return(I); } 206 else { return(modStd(I + F )); }209 else { return(modStd(I + F, n1)); } 207 210 } 208 211 … … 210 213 211 214 proc assPrimes(list #) 212 "USAGE: assPrimes(I,[ a],[n]); I ideal or module,215 "USAGE: assPrimes(I,[n],[a]); I ideal or module, 213 216 optional: int n: number of processors (for parallel computing), int a: 214 217 - a = 1: method of Eisenbud/Hunecke/Vasconcelos … … 217 220 assPrimes(I) chooses n = a = 1 218 221 ASSUME: I is zero-dimensional over Q[variables] 219 NOTE: Parallelization is just applicable using 32-bit Singular version since220 MP-links are not compatible with 64-bit Singular version.221 222 RETURN: a list Re of associated primes of I: 222 223 EXAMPLE: example assPrimes; shows an example … … 239 240 if(size(#) == 2) 240 241 { 241 int alg = #[2]; 242 int n = 1; 242 int n1 = #[2]; 243 int alg = 1; 244 if(n1 >= 10) 245 { 246 int n2 = n1 + 1; 247 int n3 = n1; 248 } 249 else 250 { 251 int n2 = 10; 252 int n3 = 10; 253 } 243 254 } 244 255 if(size(#) == 3) 245 256 { 246 int alg = #[2]; 247 int n = #[3]; 248 if((n > 1) && (1 - system("with","MP"))) 257 int n1 = #[2]; 258 int alg = #[3]; 259 if(n1 >= 10) 260 { 261 int n2 = n1 + 1; 262 int n3 = n1; 263 } 264 else 249 265 { 250 "========================================================================"; 251 "There is no MP available on your system. Since this is necessary to "; 252 "parallelize the algorithm, the computation will be done without forking."; 253 "========================================================================"; 254 n = 1; 266 int n2 = 10; 267 int n3 = 10; 255 268 } 256 269 } … … 258 271 else 259 272 { 273 int n1 = 1; 260 274 int alg = 1; 261 int n = 1; 275 int n2 = 10; 276 int n3 = 10; 277 } 278 279 if(printlevel >= 10) 280 { 281 "n1 = "+string(n1)+", n2 = "+string(n2)+", n3 = "+string(n3); 262 282 } 263 283 … … 265 285 int RT = rtimer; 266 286 int TT; 287 int t_sleep; 267 288 268 289 def SPR = basering; 290 map phi; 291 list H = ideal(0); 292 ideal F; 293 poly F1; 294 269 295 if(printlevel >= 10) { "========== Start modStd =========="; } 270 I = modStd(I,n );296 I = modStd(I,n1); 271 297 if(printlevel >= 10) { "=========== End modStd ==========="; } 272 298 if(printlevel >= 9) { "modStd takes "+string(rtimer-RT)+" seconds."; } 273 299 int d = vdim(I); 274 300 if(d == -1) { ERROR("Ideal is not zero-dimensional."); } 275 if(homog(I) == 1) { return(list(maxideal(1))); }301 if(homog(I) == 1) { return(list(maxideal(1))); } 276 302 poly f = findGen(I); 277 303 if(printlevel >= 9) { "Coordinate change: "+string(f); } … … 293 319 { 294 320 TT = timer; 295 I = zeroR(I,n );321 I = zeroR(I,n1); 296 322 if(printlevel >= 9) 297 323 { 298 "zeroR(I,n ) takes "+string(timer-TT)+" seconds.";324 "zeroR(I,n1) takes "+string(timer-TT)+" seconds."; 299 325 } 300 326 TT = timer; … … 311 337 { 312 338 TT = timer; 313 I = zeroR(I,n );339 I = zeroR(I,n1); 314 340 if(printlevel >= 9) 315 341 { 316 "zeroR(I,n ) takes "+string(timer-TT)+" seconds.";342 "zeroR(I,n1) takes "+string(timer-TT)+" seconds."; 317 343 } 318 344 TT = timer; … … 340 366 341 367 //-------------------- Initialize the list of primes ------------------------- 342 intvec L = primeList(I, 10);368 intvec L = primeList(I,n2); 343 369 L[5] = prime(random(1000000000,2134567879)); 344 370 … … 358 384 //----- main standard basis computations in positive characteristic ---- 359 385 360 if(n > 1)386 if(n1 > 1) 361 387 { 362 388 363 389 //----- Create n1 links l(1),...,l(n1), open all of them and compute --------- 364 //----- standard basis for the primes L[2],...,L[n + 1]. --------- 365 366 for(i = 1; i <= n; i++) 367 { 368 link l(i) = "MPtcp:fork"; 390 //----- standard basis for the primes L[2],...,L[n1 + 1]. --------- 391 392 for(i = 1; i <= n1; i++) 393 { 394 //link l(i) = "MPtcp:fork"; 395 link l(i) = "ssi:fork"; 369 396 open(l(i)); 370 397 write(l(i), quote(modpSpecialAlgDep(eval(ringL), eval(L[i + 1]), … … 381 408 index++; 382 409 383 j = j + n + 1;410 j = j + n1 + 1; 384 411 } 385 412 … … 388 415 int tt = timer; 389 416 int rt = rtimer; 390 417 391 418 while(1) 392 419 { 393 420 tt = timer; 394 421 rt = rtimer; 395 396 if(n > 1) 422 423 if(printlevel >= 9) { "size(L) = "+string(size(L)); } 424 425 if(n1 > 1) 397 426 { 398 427 while(j <= size(L) + 1) 399 428 { 400 for(i = 1; i <= n ; i++)429 for(i = 1; i <= n1; i++) 401 430 { 402 431 //--- ask if link l(i) is ready otherwise sleep for t seconds --- … … 424 453 } 425 454 //--- k describes the number of closed links --- 426 if(k == n )455 if(k == n1) 427 456 { 428 457 j++; … … 433 462 else 434 463 { 435 while(j <=size(L))464 while(j <= size(L)) 436 465 { 437 466 P = modpSpecialAlgDep(ringL, L[j], alg); … … 442 471 } 443 472 } 473 444 474 if(printlevel >= 9) 445 475 { … … 450 480 } 451 481 452 // insert deleteUnluckyPrimes 482 //------------------- Lift results to basering via farey ---------------------- 483 484 tt = timer; 453 485 G = chinrem(CO1,CO2); 454 486 N = CO2[1]; 455 for(j = 2; j <= size(CO2); j++){ N = N*CO2[j];}487 for(j = 2; j <= size(CO2); j++){ N = N*CO2[j]; } 456 488 F = farey(G,N); 457 if(F[1]-testF[1]==0) 458 { 459 if(printlevel >= 9) { "size(L) = "+string(size(L)); } 460 489 if(printlevel >= 10) { "Lifting-process takes "+string(timer - tt) 490 +" seconds"; } 491 492 if(pTestPoly(F[1], ringL, alg, L)) 493 { 461 494 F = cleardenom(F[1]); 462 495 … … 478 511 { 479 512 setring SPR; 480 map phi = rHelp,var(nvars(SPR)); 481 list H = phi(H); 513 phi = rHelp,var(nvars(SPR)); 514 H = phi(H); 515 482 516 if(printlevel >= 9) 483 517 { … … 485 519 "CPU-time without test is "+string(timer - T)+" seconds."; 486 520 } 521 487 522 T = timer; 488 523 RT = rtimer; 489 524 490 ideal F = phi(F); 491 poly F1; 492 493 if(n > 1) 525 F = phi(F); 526 527 if(n1 > 1) 494 528 { 495 529 open(l(1)); 496 530 write(l(1), quote(quickSubst(eval(F[1]), eval(f), eval(I)))); 497 intt_sleep = timer;531 t_sleep = timer; 498 532 } 499 533 else … … 511 545 } 512 546 513 if(n > 1)547 if(n1 > 1) 514 548 { 515 549 t_sleep = timer - t_sleep; … … 546 580 547 581 int_break = 0; 582 setring rHelp; 548 583 testF = F; 549 584 CO1 = G; … … 553 588 j = size(L) + 1; 554 589 555 setring (SPR);556 L = primeList(I, 10,L);590 setring SPR; 591 L = primeList(I,n3,L); 557 592 setring rHelp; 558 593 559 if(n > 1)560 { 561 for(i = 1; i <= n ; i++)594 if(n1 > 1) 595 { 596 for(i = 1; i <= n1; i++) 562 597 { 563 598 open(l(i)); … … 565 600 eval(alg)))); 566 601 } 567 j = j + n ;602 j = j + n1; 568 603 k = 0; 569 604 } … … 572 607 example 573 608 { "EXAMPLE:"; echo = 2; 574 ring R =0,(a,b,c,d,e,f),dp;575 ideal I =609 ring R = 0,(a,b,c,d,e,f),dp; 610 ideal I = 576 611 2fb+2ec+d2+a2+a, 577 612 2fc+2ed+2ba+b, … … 880 915 //////////////////////////////////////////////////////////////////////////////// 881 916 917 static proc pTestPoly(poly testF, list ringL, int alg, list L) 918 { 919 int i,j,p; 920 def R0 = basering; 921 922 while(!i) 923 { 924 i = 1; 925 p = prime(random(1000000000,2134567879)); 926 for(j = 1; j <= size(L); j++) 927 { 928 if(p == L[j]) { i = 0; break; } 929 } 930 } 931 932 ringL[1] = p; 933 def @R = ring(ringL); 934 setring @R; 935 poly f = fetch(SPR,f_for_fork); 936 ideal I = fetch(SPR,I_for_fork); 937 if(alg == 1) { list M = specialAlgDepEHV(f,I); } 938 if(alg == 2) { list M = specialAlgDepGTZ(f,I); } 939 if(alg == 3) { list M = specialAlgDepMonico(f,I); } 940 def @S = M[1]; 941 setring @S; 942 poly testF = fetch(R0,testF); 943 int k = (testF == F); 944 945 setring R0; 946 return(k); 947 } 948 949 //////////////////////////////////////////////////////////////////////////////// 950 882 951 /* 883 952 Examples:
Note: See TracChangeset
for help on using the changeset viewer.