Changeset 2a95b2 in git
- Timestamp:
- Oct 12, 2012, 5:30:21 PM (10 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
- Children:
- 0851b018d4d94918ad78eea2f6350c7012d2a9aa
- Parents:
- 2df3610db1525b99bc5f170fb64ea83dc29d0ac6
- git-author:
- Martin Lee <martinlee84@web.de>2012-10-12 17:30:21+02:00
- git-committer:
- Martin Lee <martinlee84@web.de>2012-10-24 12:26:22+02:00
- Location:
- factory
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
factory/algext.cc
r2df361 r2a95b2 15 15 16 16 #include "cf_assert.h" 17 #include "timing.h" 17 18 18 19 #include "templates/ftmpl_functions.h" … … 29 30 #include "NTLconvert.h" 30 31 #endif 32 33 TIMING_DEFINE_PRINT(alg_content_p) 34 TIMING_DEFINE_PRINT(alg_content) 35 TIMING_DEFINE_PRINT(alg_compress) 36 TIMING_DEFINE_PRINT(alg_termination) 37 TIMING_DEFINE_PRINT(alg_termination_p) 38 TIMING_DEFINE_PRINT(alg_reconstruction) 39 TIMING_DEFINE_PRINT(alg_newton_p) 40 TIMING_DEFINE_PRINT(alg_recursion_p) 41 TIMING_DEFINE_PRINT(alg_gcd_p) 42 TIMING_DEFINE_PRINT(alg_euclid_p) 31 43 32 44 /// compressing two polynomials F and G, M is used for compressing, … … 430 442 return; 431 443 } 444 TIMING_START (alg_compress) 432 445 CFMap MM,NN; 433 446 int lev= myCompress (F, G, MM, NN, topLevel); … … 439 452 CanonicalForm f=MM(F); 440 453 CanonicalForm g=MM(G); 454 TIMING_END_AND_PRINT (alg_compress, "time to compress in alg gcd: ") 441 455 // here: f,g are compressed 442 456 // compute largest variable in f or g (least one is Variable(1)) … … 447 461 if(mv == 1) // f,g univariate 448 462 { 463 TIMING_START (alg_euclid_p) 449 464 tryEuclid(f,g,M,result,fail); 465 TIMING_END_AND_PRINT (alg_euclid_p, "time for euclidean alg mod p: ") 450 466 if(fail) 451 467 return; … … 453 469 return; 454 470 } 471 TIMING_START (alg_content_p) 455 472 // here: mv > 1 456 473 CanonicalForm cf = tryvcontent(f, Variable(2), M, fail); // cf is univariate poly in var(1) … … 472 489 if(fail) 473 490 return; 491 TIMING_END_AND_PRINT (alg_content_p, "time for content in alg gcd mod p: ") 474 492 if(f.inCoeffDomain()) 475 493 { … … 495 513 N = leadDeg(g, N); 496 514 CanonicalForm gamma; 515 TIMING_START (alg_euclid_p) 497 516 tryEuclid( firstLC(f), firstLC(g), M, gamma, fail ); 517 TIMING_END_AND_PRINT (alg_euclid_p, "time for gcd of lcs in alg mod p: ") 498 518 if(fail) 499 519 return; … … 517 537 if(gamma_image.isZero()) // skip lc-bad points var(1)-alpha 518 538 continue; 539 TIMING_START (alg_recursion_p) 519 540 tryBrownGCD( f(alpha, x), g(alpha, x), M, g_image, fail, false ); // recursive call with one var less 541 TIMING_END_AND_PRINT (alg_recursion_p, 542 "time for recursive calls in alg gcd mod p: ") 520 543 if(fail) 521 544 return; … … 541 564 g_image *= gamma_image; // multiply by multiple of image lc(gcd) 542 565 g_image= reduce (g_image, M); 566 TIMING_START (alg_newton_p) 543 567 gnew= tryNewtonInterp (alpha, g_image, m, gm, x, M, fail); 568 TIMING_END_AND_PRINT (alg_newton_p, 569 "time for Newton interpolation in alg gcd mod p: ") 544 570 // gnew = gm mod m 545 571 // gnew = g_image mod var(1)-alpha … … 550 576 if((firstLC(gnew) == gamma) || (gnew == gm)) // gnew did not change 551 577 { 578 TIMING_START (alg_termination_p) 552 579 cf = tryvcontent(gnew, Variable(2), M, fail); 553 580 if(fail) … … 569 596 { 570 597 result = NN(reduce (c*g_image, M)); 598 TIMING_END_AND_PRINT (alg_termination_p, 599 "time for successful termination test in alg gcd mod p: ") 571 600 return; 572 601 } 573 602 } 603 TIMING_END_AND_PRINT (alg_termination_p, 604 "time for unsuccessful termination test in alg gcd mod p: ") 574 605 } 575 606 gm = gnew; … … 665 696 f = F * bCommonDen(F); 666 697 g = G * bCommonDen(G); 698 TIMING_START (alg_content) 667 699 CanonicalForm contf= myicontent (f); 668 700 CanonicalForm contg= myicontent (g); … … 670 702 g /= contg; 671 703 CanonicalForm gcdcfcg= myicontent (contf, contg); 704 TIMING_END_AND_PRINT (alg_content, "time for content in alg gcd: ") 672 705 Variable a, b; 673 706 if(hasFirstAlgVar(f,a)) … … 727 760 mipo /= mipo.lc(); 728 761 // here: mipo is monic 762 TIMING_START (alg_gcd_p) 729 763 tryBrownGCD( mapinto(f), mapinto(g), mipo, Dp, fail ); 764 TIMING_END_AND_PRINT (alg_gcd_p, "time for alg gcd mod p: ") 730 765 if( fail ) // mipo splits in char p 731 766 continue; … … 756 791 D = tmp; 757 792 On( SW_RATIONAL ); 793 TIMING_START (alg_reconstruction) 758 794 tmp = Farey( D, q ); // Farey 759 795 tmp *= bCommonDen (tmp); 796 TIMING_END_AND_PRINT (alg_reconstruction, 797 "time for rational reconstruction in alg gcd: ") 760 798 setReduce(a,true); // reduce expressions modulo mipo 761 799 On( SW_RATIONAL ); // needed by fdivides … … 764 802 else 765 803 equal= true; // modular image did not add any new information 804 TIMING_START (alg_termination) 766 805 if(equal && fdivides( tmp, f ) && fdivides( tmp, g )) // trial division 767 806 { … … 769 808 setReduce(a,true); 770 809 if (off_rational) Off(SW_RATIONAL); else On(SW_RATIONAL); 810 TIMING_END_AND_PRINT (alg_termination, 811 "time for successful termination test in alg gcd: ") 771 812 return tmp*gcdcfcg; 772 813 } 814 TIMING_END_AND_PRINT (alg_termination, 815 "time for unsuccessful termination test in alg gcd: ") 773 816 Off( SW_RATIONAL ); 774 817 setReduce(a,false); // do not reduce expressions modulo mipo -
factory/cf_gcd.cc
r2df361 r2a95b2 3 3 #include "config.h" 4 4 5 #include "timing.h" 5 6 #include "cf_assert.h" 6 7 #include "debug.h" … … 1156 1157 } 1157 1158 1159 TIMING_DEFINE_PRINT(chinrem_termination) 1160 TIMING_DEFINE_PRINT(chinrem_recursion) 1161 TIMING_DEFINE_PRINT(chinrem_reconstruction) 1162 1158 1163 CanonicalForm chinrem_gcd ( const CanonicalForm & FF, const CanonicalForm & GG ) 1159 1164 { … … 1223 1228 fp= mapinto (f); 1224 1229 gp= mapinto (g); 1230 TIMING_START (chinrem_recursion) 1225 1231 #ifdef HAVE_NTL 1226 1232 if (size (fp)/maxNumVars > 500 && size (gp)/maxNumVars > 500) … … 1237 1243 cogp= gp/Dp; 1238 1244 #endif 1245 TIMING_END_AND_PRINT (chinrem_recursion, 1246 "time for gcd mod p in modular gcd: "); 1239 1247 Dp /=Dp.lc(); 1240 1248 cofp /= lc (cofp); … … 1287 1295 if ( i >= 0 ) 1288 1296 { 1297 TIMING_START (chinrem_reconstruction); 1289 1298 Dn= Farey(D,q); 1290 1299 cofn= Farey(cof,q); 1291 1300 cogn= Farey(cog,q); 1301 TIMING_END_AND_PRINT (chinrem_reconstruction, 1302 "time for rational reconstruction in modular gcd: "); 1292 1303 int is_rat= isOn (SW_RATIONAL); 1293 1304 On (SW_RATIONAL); … … 1303 1314 equal= true; 1304 1315 //Dn /=vcontent(Dn,Variable(1)); 1316 TIMING_START (chinrem_termination); 1305 1317 if ((terminationTest (f,g, cofn, cogn, Dn)) || 1306 1318 ((equal || q > b) && fdivides (Dn, f) && fdivides (Dn, g))) 1307 1319 { 1320 TIMING_END_AND_PRINT (chinrem_termination, 1321 "time for successful termination in modular gcd: "); 1308 1322 //printf(" -> success\n"); 1309 1323 return Dn*gcdcfcg; 1310 1324 } 1325 TIMING_END_AND_PRINT (chinrem_termination, 1326 "time for unsuccessful termination in modular gcd: "); 1311 1327 equal= false; 1312 1328 //else: try more primes -
factory/cf_gcd_smallp.cc
r2df361 r2a95b2 45 45 TIMING_DEFINE_PRINT(gcd_recursion) 46 46 TIMING_DEFINE_PRINT(newton_interpolation) 47 TIMING_DEFINE_PRINT(termination_test) 48 TIMING_DEFINE_PRINT(ez_p_compress) 49 TIMING_DEFINE_PRINT(ez_p_hensel_lift) 50 TIMING_DEFINE_PRINT(ez_p_eval) 51 TIMING_DEFINE_PRINT(ez_p_content) 47 52 48 53 bool … … 797 802 if ((uni_lcoeff (H) == gcdlcAlcB) || (G_m == H)) 798 803 { 804 TIMING_START (termination_test); 799 805 if (gcdlcAlcB.isOne()) 800 806 cH= 1; … … 831 837 coF= N ((cA/gcdcAcB)*ppCoF); 832 838 coG= N ((cB/gcdcAcB)*ppCoG); 839 TIMING_END_AND_PRINT (termination_test, 840 "time for successful termination test Fq: "); 833 841 return N(gcdcAcB*ppH); 834 842 } … … 846 854 } 847 855 coF= N ((cA/gcdcAcB)*ppCoF); 848 coG= N ((cB/gcdcAcB)*ppCoG);; 856 coG= N ((cB/gcdcAcB)*ppCoG); 857 TIMING_END_AND_PRINT (termination_test, 858 "time for successful termination test Fq: "); 849 859 return N(gcdcAcB*ppH); 850 860 } 861 TIMING_END_AND_PRINT (termination_test, 862 "time for unsuccessful termination test Fq: "); 851 863 } 852 864 … … 1237 1249 if ((uni_lcoeff (H) == gcdlcAlcB) || (G_m == H)) 1238 1250 { 1251 TIMING_START (termination_test); 1239 1252 if (gcdlcAlcB.isOne()) 1240 1253 cH= 1; … … 1270 1283 coG= N ((cB/gcdcAcB)*ppCoG); 1271 1284 setCharacteristic (p, k, gf_name_buf); 1285 TIMING_END_AND_PRINT (termination_test, 1286 "time for successful termination GF: "); 1272 1287 return N(gcdcAcB*ppH); 1273 1288 } … … 1288 1303 coF= N ((cA/gcdcAcB)*ppCoF); 1289 1304 coG= N ((cB/gcdcAcB)*ppCoG); 1305 TIMING_END_AND_PRINT (termination_test, 1306 "time for successful termination GF: "); 1290 1307 return N(gcdcAcB*ppH); 1291 1308 } 1292 1309 } 1310 TIMING_END_AND_PRINT (termination_test, 1311 "time for unsuccessful termination GF: "); 1293 1312 } 1294 1313 … … 1744 1763 if ((uni_lcoeff (H) == gcdlcAlcB) || (G_m == H)) 1745 1764 { 1765 TIMING_START (termination_test); 1746 1766 if (gcdlcAlcB.isOne()) 1747 1767 cH= 1; … … 1769 1789 coF= N ((cA/gcdcAcB)*ppCoF); 1770 1790 coG= N ((cB/gcdcAcB)*ppCoG); 1791 TIMING_END_AND_PRINT (termination_test, 1792 "time for successful termination Fp: "); 1771 1793 return N(gcdcAcB*ppH); 1772 1794 } 1795 TIMING_END_AND_PRINT (termination_test, 1796 "time for unsuccessful termination Fp: "); 1773 1797 } 1774 1798 … … 4450 4474 CFMap M,N; 4451 4475 int smallestDegLev; 4476 TIMING_START (ez_p_compress) 4452 4477 int best_level= compress4EZGCD (F, G, M, N, smallestDegLev); 4453 4478 … … 4456 4481 F= M (F); 4457 4482 G= M (G); 4458 4483 TIMING_END_AND_PRINT (ez_p_compress, "time for compression in EZ_P: ") 4484 4485 TIMING_START (ez_p_content) 4459 4486 f = content( F, x ); g = content( G, x ); 4460 4487 d = gcd( f, g ); 4461 4488 F /= f; G /= g; 4489 TIMING_END_AND_PRINT (ez_p_content, "time to extract content in EZ_P: ") 4462 4490 4463 4491 if( F.isUnivariate() && G.isUnivariate() ) … … 4598 4626 while( !gcdfound ) 4599 4627 { 4628 TIMING_START (ez_p_eval); 4600 4629 if( !findeval_P( F, G, Fb, Gb, Db, b, delta, degF, degG, maxeval, count, o, 4601 4630 maxeval/maxNumVars, t )) … … 4620 4649 return N (d*result); 4621 4650 } 4651 TIMING_END_AND_PRINT (ez_p_eval, "time for eval point search in EZ_P1: "); 4622 4652 delta = degree( Db ); 4623 4653 if( delta == 0 ) … … 4632 4662 { 4633 4663 bt = b; 4664 TIMING_START (ez_p_eval); 4634 4665 if( !findeval_P(F,G,Fbt,Gbt,Dbt, bt, delta, degF, degG, maxeval, count, o, 4635 4666 maxeval/maxNumVars, t )) … … 4654 4685 return N (d*result); 4655 4686 } 4687 TIMING_END_AND_PRINT (ez_p_eval, "time for eval point search in EZ_P2: "); 4656 4688 int dd = degree( Dbt ); 4657 4689 if( dd == 0 ) … … 4807 4839 } 4808 4840 4841 TIMING_START (ez_p_hensel_lift); 4809 4842 gcdfound= Hensel_P (B*lcD, DD, b, lcDD); 4843 TIMING_END_AND_PRINT (ez_p_hensel_lift, "time for Hensel lift in EZ_P: "); 4810 4844 4811 4845 if (gcdfound == -1) … … 4833 4867 if (gcdfound == 1) 4834 4868 { 4869 TIMING_START (termination_test); 4835 4870 contcand= content (DD[2], Variable (1)); 4836 4871 cand = DD[2] / contcand; … … 4839 4874 else 4840 4875 gcdfound = fdivides( cand, F ) && cand*(DD[1]/(lcD/contcand)) == G; 4876 TIMING_END_AND_PRINT (termination_test, 4877 "time for termination test EZ_P: "); 4841 4878 4842 4879 if (passToGF && gcdfound) -
factory/fac_ezgcd.cc
r2df361 r2a95b2 15 15 #include "config.h" 16 16 17 #include "timing.h" 17 18 #include "cf_assert.h" 18 19 #include "debug.h" … … 30 31 31 32 #ifdef HAVE_NTL 33 34 TIMING_DEFINE_PRINT(ez_eval) 35 TIMING_DEFINE_PRINT(ez_compress) 36 TIMING_DEFINE_PRINT(ez_hensel_lift) 37 TIMING_DEFINE_PRINT(ez_content) 38 TIMING_DEFINE_PRINT(ez_termination) 39 32 40 static 33 41 int compress4EZGCD (const CanonicalForm& F, const CanonicalForm& G, CFMap & M, … … 432 440 Off (SW_RATIONAL); 433 441 442 TIMING_START (ez_compress) 434 443 CFMap M,N; 435 444 int smallestDegLev; … … 444 453 F= M (F); 445 454 G= M (G); 455 TIMING_END_AND_PRINT (ez_compress, "time for compression in EZ: ") 446 456 447 457 DEBINCLEVEL( cerr, "ezgcd" ); 448 458 DEBOUTLN( cerr, "FF = " << FF ); 449 459 DEBOUTLN( cerr, "GG = " << GG ); 460 TIMING_START (ez_content) 450 461 f = content( F, x ); g = content( G, x ); d = gcd( f, g ); 451 462 d /= icontent (d); … … 453 464 DEBOUTLN( cerr, "g = " << g ); 454 465 F /= f; G /= g; 466 TIMING_END_AND_PRINT (ez_content, "time to extract content in EZ: ") 455 467 if ( F.isUnivariate() && G.isUnivariate() ) 456 468 { … … 500 512 DEBOUTLN( cerr, "F = " << F ); 501 513 DEBOUTLN( cerr, "G = " << G ); 514 TIMING_START (ez_eval) 502 515 if (!findeval( F, G, Fb, Gb, Db, b, delta, degF, degG, maxeval, count, 503 516 o, 25, l)) … … 512 525 return N (d*result); 513 526 } 527 TIMING_END_AND_PRINT (ez_eval, "time to find eval point in EZ1: ") 514 528 DEBOUTLN( cerr, "found evaluation b = " << b ); 515 529 DEBOUTLN( cerr, "F(b) = " << Fb ); … … 530 544 { 531 545 bt = b; 546 TIMING_START (ez_eval) 532 547 if (!findeval( F, G, Fbt, Gbt, Dbt, bt, delta, degF, degG, maxeval, count, 533 548 o, 25,l )) … … 542 557 return N (d*result); 543 558 } 559 TIMING_END_AND_PRINT (ez_eval, "time to find eval point in EZ2: ") 544 560 int dd=degree( Dbt ); 545 561 if ( dd /*degree( Dbt )*/ == 0 ) … … 636 652 DEBOUTLN( cerr, "(hensel) DD = " << DD ); 637 653 DEBOUTLN( cerr, "(hensel) lcDD = " << lcDD ); 654 TIMING_START (ez_hensel_lift) 638 655 gcdfound= Hensel (B*lcD, DD, b, lcDD); 656 TIMING_END_AND_PRINT (ez_hensel_lift, "time to hensel lift in EZ: ") 639 657 DEBOUTLN( cerr, "(hensel finished) DD = " << DD ); 640 658 … … 653 671 if (gcdfound) 654 672 { 673 TIMING_START (ez_termination) 655 674 contcand= content (DD[2], Variable (1)); 656 675 cand = DD[2] / contcand; … … 659 678 else 660 679 gcdfound = fdivides( cand, F ) && cand*(DD[1]/(lcD/contcand)) == G; 680 TIMING_END_AND_PRINT (ez_termination, 681 "time for termination test in EZ: ") 661 682 } 662 683 /// ---> A8 (gcdfound)
Note: See TracChangeset
for help on using the changeset viewer.