Changeset 2a95b2 in git for factory/algext.cc
- Timestamp:
- Oct 12, 2012, 5:30:21 PM (12 years ago)
- Branches:
- (u'spielwiese', '17f1d200f27c5bd38f5dfc6e8a0879242279d1d8')
- 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
- File:
-
- 1 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
Note: See TracChangeset
for help on using the changeset viewer.