Changeset 2a95b2 in git


Ignore:
Timestamp:
Oct 12, 2012, 5:30:21 PM (10 years ago)
Author:
Martin Lee <martinlee84@…>
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
Message:
chg: added more timing infos to gcd functions
Location:
factory
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • factory/algext.cc

    r2df361 r2a95b2  
    1515
    1616#include "cf_assert.h"
     17#include "timing.h"
    1718
    1819#include "templates/ftmpl_functions.h"
     
    2930#include "NTLconvert.h"
    3031#endif
     32
     33TIMING_DEFINE_PRINT(alg_content_p)
     34TIMING_DEFINE_PRINT(alg_content)
     35TIMING_DEFINE_PRINT(alg_compress)
     36TIMING_DEFINE_PRINT(alg_termination)
     37TIMING_DEFINE_PRINT(alg_termination_p)
     38TIMING_DEFINE_PRINT(alg_reconstruction)
     39TIMING_DEFINE_PRINT(alg_newton_p)
     40TIMING_DEFINE_PRINT(alg_recursion_p)
     41TIMING_DEFINE_PRINT(alg_gcd_p)
     42TIMING_DEFINE_PRINT(alg_euclid_p)
    3143
    3244/// compressing two polynomials F and G, M is used for compressing,
     
    430442    return;
    431443  }
     444  TIMING_START (alg_compress)
    432445  CFMap MM,NN;
    433446  int lev= myCompress (F, G, MM, NN, topLevel);
     
    439452  CanonicalForm f=MM(F);
    440453  CanonicalForm g=MM(G);
     454  TIMING_END_AND_PRINT (alg_compress, "time to compress in alg gcd: ")
    441455  // here: f,g are compressed
    442456  // compute largest variable in f or g (least one is Variable(1))
     
    447461  if(mv == 1) // f,g univariate
    448462  {
     463    TIMING_START (alg_euclid_p)
    449464    tryEuclid(f,g,M,result,fail);
     465    TIMING_END_AND_PRINT (alg_euclid_p, "time for euclidean alg mod p: ")
    450466    if(fail)
    451467      return;
     
    453469    return;
    454470  }
     471  TIMING_START (alg_content_p)
    455472  // here: mv > 1
    456473  CanonicalForm cf = tryvcontent(f, Variable(2), M, fail); // cf is univariate poly in var(1)
     
    472489  if(fail)
    473490    return;
     491  TIMING_END_AND_PRINT (alg_content_p, "time for content in alg gcd mod p: ")
    474492  if(f.inCoeffDomain())
    475493  {
     
    495513  N = leadDeg(g, N);
    496514  CanonicalForm gamma;
     515  TIMING_START (alg_euclid_p)
    497516  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: ")
    498518  if(fail)
    499519    return;
     
    517537    if(gamma_image.isZero()) // skip lc-bad points var(1)-alpha
    518538      continue;
     539    TIMING_START (alg_recursion_p)
    519540    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: ")
    520543    if(fail)
    521544      return;
     
    541564      g_image *= gamma_image; // multiply by multiple of image lc(gcd)
    542565      g_image= reduce (g_image, M);
     566      TIMING_START (alg_newton_p)
    543567      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: ")
    544570      // gnew = gm mod m
    545571      // gnew = g_image mod var(1)-alpha
     
    550576      if((firstLC(gnew) == gamma) || (gnew == gm)) // gnew did not change
    551577      {
     578        TIMING_START (alg_termination_p)
    552579        cf = tryvcontent(gnew, Variable(2), M, fail);
    553580        if(fail)
     
    569596          {
    570597            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: ")
    571600            return;
    572601          }
    573602        }
     603        TIMING_END_AND_PRINT (alg_termination_p,
     604                    "time for unsuccessful termination test in alg gcd mod p: ")
    574605      }
    575606      gm = gnew;
     
    665696  f = F * bCommonDen(F);
    666697  g = G * bCommonDen(G);
     698  TIMING_START (alg_content)
    667699  CanonicalForm contf= myicontent (f);
    668700  CanonicalForm contg= myicontent (g);
     
    670702  g /= contg;
    671703  CanonicalForm gcdcfcg= myicontent (contf, contg);
     704  TIMING_END_AND_PRINT (alg_content, "time for content in alg gcd: ")
    672705  Variable a, b;
    673706  if(hasFirstAlgVar(f,a))
     
    727760    mipo /= mipo.lc();
    728761    // here: mipo is monic
     762    TIMING_START (alg_gcd_p)
    729763    tryBrownGCD( mapinto(f), mapinto(g), mipo, Dp, fail );
     764    TIMING_END_AND_PRINT (alg_gcd_p, "time for alg gcd mod p: ")
    730765    if( fail ) // mipo splits in char p
    731766      continue;
     
    756791        D = tmp;
    757792      On( SW_RATIONAL );
     793      TIMING_START (alg_reconstruction)
    758794      tmp = Farey( D, q ); // Farey
    759795      tmp *= bCommonDen (tmp);
     796      TIMING_END_AND_PRINT (alg_reconstruction,
     797                            "time for rational reconstruction in alg gcd: ")
    760798      setReduce(a,true); // reduce expressions modulo mipo
    761799      On( SW_RATIONAL ); // needed by fdivides
     
    764802      else
    765803        equal= true; // modular image did not add any new information
     804      TIMING_START (alg_termination)
    766805      if(equal && fdivides( tmp, f ) && fdivides( tmp, g )) // trial division
    767806      {
     
    769808        setReduce(a,true);
    770809        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: ")
    771812        return tmp*gcdcfcg;
    772813      }
     814      TIMING_END_AND_PRINT (alg_termination,
     815                          "time for unsuccessful termination test in alg gcd: ")
    773816      Off( SW_RATIONAL );
    774817      setReduce(a,false); // do not reduce expressions modulo mipo
  • factory/cf_gcd.cc

    r2df361 r2a95b2  
    33#include "config.h"
    44
     5#include "timing.h"
    56#include "cf_assert.h"
    67#include "debug.h"
     
    11561157}
    11571158
     1159TIMING_DEFINE_PRINT(chinrem_termination)
     1160TIMING_DEFINE_PRINT(chinrem_recursion)
     1161TIMING_DEFINE_PRINT(chinrem_reconstruction)
     1162
    11581163CanonicalForm chinrem_gcd ( const CanonicalForm & FF, const CanonicalForm & GG )
    11591164{
     
    12231228    fp= mapinto (f);
    12241229    gp= mapinto (g);
     1230    TIMING_START (chinrem_recursion)
    12251231#ifdef HAVE_NTL
    12261232    if (size (fp)/maxNumVars > 500 && size (gp)/maxNumVars > 500)
     
    12371243    cogp= gp/Dp;
    12381244#endif
     1245    TIMING_END_AND_PRINT (chinrem_recursion,
     1246                          "time for gcd mod p in modular gcd: ");
    12391247    Dp /=Dp.lc();
    12401248    cofp /= lc (cofp);
     
    12871295    if ( i >= 0 )
    12881296    {
     1297      TIMING_START (chinrem_reconstruction);
    12891298      Dn= Farey(D,q);
    12901299      cofn= Farey(cof,q);
    12911300      cogn= Farey(cog,q);
     1301      TIMING_END_AND_PRINT (chinrem_reconstruction,
     1302                           "time for rational reconstruction in modular gcd: ");
    12921303      int is_rat= isOn (SW_RATIONAL);
    12931304      On (SW_RATIONAL);
     
    13031314        equal= true;
    13041315      //Dn /=vcontent(Dn,Variable(1));
     1316      TIMING_START (chinrem_termination);
    13051317      if ((terminationTest (f,g, cofn, cogn, Dn)) ||
    13061318          ((equal || q > b) && fdivides (Dn, f) && fdivides (Dn, g)))
    13071319      {
     1320        TIMING_END_AND_PRINT (chinrem_termination,
     1321                            "time for successful termination in modular gcd: ");
    13081322        //printf(" -> success\n");
    13091323        return Dn*gcdcfcg;
    13101324      }
     1325      TIMING_END_AND_PRINT (chinrem_termination,
     1326                          "time for unsuccessful termination in modular gcd: ");
    13111327      equal= false;
    13121328      //else: try more primes
  • factory/cf_gcd_smallp.cc

    r2df361 r2a95b2  
    4545TIMING_DEFINE_PRINT(gcd_recursion)
    4646TIMING_DEFINE_PRINT(newton_interpolation)
     47TIMING_DEFINE_PRINT(termination_test)
     48TIMING_DEFINE_PRINT(ez_p_compress)
     49TIMING_DEFINE_PRINT(ez_p_hensel_lift)
     50TIMING_DEFINE_PRINT(ez_p_eval)
     51TIMING_DEFINE_PRINT(ez_p_content)
    4752
    4853bool
     
    797802    if ((uni_lcoeff (H) == gcdlcAlcB) || (G_m == H))
    798803    {
     804      TIMING_START (termination_test);
    799805      if (gcdlcAlcB.isOne())
    800806        cH= 1;
     
    831837          coF= N ((cA/gcdcAcB)*ppCoF);
    832838          coG= N ((cB/gcdcAcB)*ppCoG);
     839          TIMING_END_AND_PRINT (termination_test,
     840                                "time for successful termination test Fq: ");
    833841          return N(gcdcAcB*ppH);
    834842        }
     
    846854        }
    847855        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: ");
    849859        return N(gcdcAcB*ppH);
    850860      }
     861      TIMING_END_AND_PRINT (termination_test,
     862                            "time for unsuccessful termination test Fq: ");
    851863    }
    852864
     
    12371249    if ((uni_lcoeff (H) == gcdlcAlcB) || (G_m == H))
    12381250    {
     1251      TIMING_START (termination_test);
    12391252      if (gcdlcAlcB.isOne())
    12401253        cH= 1;
     
    12701283          coG= N ((cB/gcdcAcB)*ppCoG);
    12711284          setCharacteristic (p, k, gf_name_buf);
     1285          TIMING_END_AND_PRINT (termination_test,
     1286                                "time for successful termination GF: ");
    12721287          return N(gcdcAcB*ppH);
    12731288        }
     
    12881303          coF= N ((cA/gcdcAcB)*ppCoF);
    12891304          coG= N ((cB/gcdcAcB)*ppCoG);
     1305          TIMING_END_AND_PRINT (termination_test,
     1306                                "time for successful termination GF: ");
    12901307          return N(gcdcAcB*ppH);
    12911308        }
    12921309      }
     1310      TIMING_END_AND_PRINT (termination_test,
     1311                            "time for unsuccessful termination GF: ");
    12931312    }
    12941313
     
    17441763    if ((uni_lcoeff (H) == gcdlcAlcB) || (G_m == H))
    17451764    {
     1765      TIMING_START (termination_test);
    17461766      if (gcdlcAlcB.isOne())
    17471767        cH= 1;
     
    17691789        coF= N ((cA/gcdcAcB)*ppCoF);
    17701790        coG= N ((cB/gcdcAcB)*ppCoG);
     1791        TIMING_END_AND_PRINT (termination_test,
     1792                              "time for successful termination Fp: ");
    17711793        return N(gcdcAcB*ppH);
    17721794      }
     1795      TIMING_END_AND_PRINT (termination_test,
     1796                            "time for unsuccessful termination Fp: ");
    17731797    }
    17741798
     
    44504474  CFMap M,N;
    44514475  int smallestDegLev;
     4476  TIMING_START (ez_p_compress)
    44524477  int best_level= compress4EZGCD (F, G, M, N, smallestDegLev);
    44534478
     
    44564481  F= M (F);
    44574482  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)
    44594486  f = content( F, x ); g = content( G, x );
    44604487  d = gcd( f, g );
    44614488  F /= f; G /= g;
     4489  TIMING_END_AND_PRINT (ez_p_content, "time to extract content in EZ_P: ")
    44624490
    44634491  if( F.isUnivariate() && G.isUnivariate() )
     
    45984626  while( !gcdfound )
    45994627  {
     4628    TIMING_START (ez_p_eval);
    46004629    if( !findeval_P( F, G, Fb, Gb, Db, b, delta, degF, degG, maxeval, count, o,
    46014630         maxeval/maxNumVars, t ))
     
    46204649      return N (d*result);
    46214650    }
     4651    TIMING_END_AND_PRINT (ez_p_eval, "time for eval point search in EZ_P1: ");
    46224652    delta = degree( Db );
    46234653    if( delta == 0 )
     
    46324662    {
    46334663      bt = b;
     4664      TIMING_START (ez_p_eval);
    46344665      if( !findeval_P(F,G,Fbt,Gbt,Dbt, bt, delta, degF, degG, maxeval, count, o,
    46354666           maxeval/maxNumVars, t ))
     
    46544685        return N (d*result);
    46554686      }
     4687      TIMING_END_AND_PRINT (ez_p_eval, "time for eval point search in EZ_P2: ");
    46564688      int dd = degree( Dbt );
    46574689      if( dd == 0 )
     
    48074839      }
    48084840
     4841      TIMING_START (ez_p_hensel_lift);
    48094842      gcdfound= Hensel_P (B*lcD, DD, b, lcDD);
     4843      TIMING_END_AND_PRINT (ez_p_hensel_lift, "time for Hensel lift in EZ_P: ");
    48104844
    48114845      if (gcdfound == -1)
     
    48334867      if (gcdfound == 1)
    48344868      {
     4869        TIMING_START (termination_test);
    48354870        contcand= content (DD[2], Variable (1));
    48364871        cand = DD[2] / contcand;
     
    48394874        else
    48404875          gcdfound = fdivides( cand, F ) && cand*(DD[1]/(lcD/contcand)) == G;
     4876        TIMING_END_AND_PRINT (termination_test,
     4877                              "time for termination test EZ_P: ");
    48414878
    48424879        if (passToGF && gcdfound)
  • factory/fac_ezgcd.cc

    r2df361 r2a95b2  
    1515#include "config.h"
    1616
     17#include "timing.h"
    1718#include "cf_assert.h"
    1819#include "debug.h"
     
    3031
    3132#ifdef HAVE_NTL
     33
     34TIMING_DEFINE_PRINT(ez_eval)
     35TIMING_DEFINE_PRINT(ez_compress)
     36TIMING_DEFINE_PRINT(ez_hensel_lift)
     37TIMING_DEFINE_PRINT(ez_content)
     38TIMING_DEFINE_PRINT(ez_termination)
     39
    3240static
    3341int compress4EZGCD (const CanonicalForm& F, const CanonicalForm& G, CFMap & M,
     
    432440    Off (SW_RATIONAL);
    433441
     442  TIMING_START (ez_compress)
    434443  CFMap M,N;
    435444  int smallestDegLev;
     
    444453  F= M (F);
    445454  G= M (G);
     455  TIMING_END_AND_PRINT (ez_compress, "time for compression in EZ: ")
    446456
    447457  DEBINCLEVEL( cerr, "ezgcd" );
    448458  DEBOUTLN( cerr, "FF = " << FF );
    449459  DEBOUTLN( cerr, "GG = " << GG );
     460  TIMING_START (ez_content)
    450461  f = content( F, x ); g = content( G, x ); d = gcd( f, g );
    451462  d /= icontent (d);
     
    453464  DEBOUTLN( cerr, "g = " << g );
    454465  F /= f; G /= g;
     466  TIMING_END_AND_PRINT (ez_content, "time to extract content in EZ: ")
    455467  if ( F.isUnivariate() && G.isUnivariate() )
    456468  {
     
    500512    DEBOUTLN( cerr, "F = " << F );
    501513    DEBOUTLN( cerr, "G = " << G );
     514    TIMING_START (ez_eval)
    502515    if (!findeval( F, G, Fb, Gb, Db, b, delta, degF, degG, maxeval, count,
    503516                   o, 25, l))
     
    512525      return N (d*result);
    513526    }
     527    TIMING_END_AND_PRINT (ez_eval, "time to find eval point in EZ1: ")
    514528    DEBOUTLN( cerr, "found evaluation b = " << b );
    515529    DEBOUTLN( cerr, "F(b) = " << Fb );
     
    530544    {
    531545      bt = b;
     546      TIMING_START (ez_eval)
    532547      if (!findeval( F, G, Fbt, Gbt, Dbt, bt, delta, degF, degG, maxeval, count,
    533548                     o, 25,l ))
     
    542557        return N (d*result);
    543558      }
     559      TIMING_END_AND_PRINT (ez_eval, "time to find eval point in EZ2: ")
    544560      int dd=degree( Dbt );
    545561      if ( dd /*degree( Dbt )*/ == 0 )
     
    636652      DEBOUTLN( cerr, "(hensel) DD   = " << DD );
    637653      DEBOUTLN( cerr, "(hensel) lcDD = " << lcDD );
     654      TIMING_START (ez_hensel_lift)
    638655      gcdfound= Hensel (B*lcD, DD, b, lcDD);
     656      TIMING_END_AND_PRINT (ez_hensel_lift, "time to hensel lift in EZ: ")
    639657      DEBOUTLN( cerr, "(hensel finished) DD   = " << DD );
    640658
     
    653671      if (gcdfound)
    654672      {
     673        TIMING_START (ez_termination)
    655674        contcand= content (DD[2], Variable (1));
    656675        cand = DD[2] / contcand;
     
    659678        else
    660679          gcdfound = fdivides( cand, F ) && cand*(DD[1]/(lcD/contcand)) == G;
     680        TIMING_END_AND_PRINT (ez_termination,
     681                              "time for termination test in EZ: ")
    661682      }
    662683      /// ---> A8 (gcdfound)
Note: See TracChangeset for help on using the changeset viewer.