Changeset 2a95b2 in git for factory/algext.cc


Ignore:
Timestamp:
Oct 12, 2012, 5:30:21 PM (12 years ago)
Author:
Martin Lee <martinlee84@…>
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
Message:
chg: added more timing infos to gcd functions
File:
1 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
Note: See TracChangeset for help on using the changeset viewer.