Fix usage of sqrt() (#268)
authorAlpar Juttner <alpar@cs.elte.hu>
Thu, 23 Apr 2009 10:44:35 +0100
changeset 6590c8e5c688440
parent 658 85cb3aa71cce
child 663 f2d6d3446adf
Fix usage of sqrt() (#268)
demo/graph_to_eps_demo.cc
lemon/network_simplex.h
tools/lgf-gen.cc
     1.1 --- a/demo/graph_to_eps_demo.cc	Tue Apr 21 15:18:54 2009 +0100
     1.2 +++ b/demo/graph_to_eps_demo.cc	Thu Apr 23 10:44:35 2009 +0100
     1.3 @@ -182,7 +182,7 @@
     1.4    ListDigraph::NodeMap<int> hcolors(h);
     1.5    ListDigraph::NodeMap<Point> hcoords(h);
     1.6  
     1.7 -  int cols=int(sqrt(double(palette.size())));
     1.8 +  int cols=int(std::sqrt(double(palette.size())));
     1.9    for(int i=0;i<int(paletteW.size());i++) {
    1.10      Node n=h.addNode();
    1.11      hcoords[n]=Point(1+i%cols,1+i/cols);
     2.1 --- a/lemon/network_simplex.h	Tue Apr 21 15:18:54 2009 +0100
     2.2 +++ b/lemon/network_simplex.h	Thu Apr 23 10:44:35 2009 +0100
     2.3 @@ -381,7 +381,8 @@
     2.4          const double BLOCK_SIZE_FACTOR = 2.0;
     2.5          const int MIN_BLOCK_SIZE = 10;
     2.6  
     2.7 -        _block_size = std::max( int(BLOCK_SIZE_FACTOR * sqrt(_arc_num)),
     2.8 +        _block_size = std::max( int(BLOCK_SIZE_FACTOR *
     2.9 +                                    std::sqrt(double(_arc_num))),
    2.10                                  MIN_BLOCK_SIZE );
    2.11        }
    2.12  
    2.13 @@ -457,7 +458,8 @@
    2.14          const double MINOR_LIMIT_FACTOR = 0.1;
    2.15          const int MIN_MINOR_LIMIT = 3;
    2.16  
    2.17 -        _list_length = std::max( int(LIST_LENGTH_FACTOR * sqrt(_arc_num)),
    2.18 +        _list_length = std::max( int(LIST_LENGTH_FACTOR *
    2.19 +                                     std::sqrt(double(_arc_num))),
    2.20                                   MIN_LIST_LENGTH );
    2.21          _minor_limit = std::max( int(MINOR_LIMIT_FACTOR * _list_length),
    2.22                                   MIN_MINOR_LIMIT );
    2.23 @@ -577,7 +579,8 @@
    2.24          const double HEAD_LENGTH_FACTOR = 0.1;
    2.25          const int MIN_HEAD_LENGTH = 3;
    2.26  
    2.27 -        _block_size = std::max( int(BLOCK_SIZE_FACTOR * sqrt(_arc_num)),
    2.28 +        _block_size = std::max( int(BLOCK_SIZE_FACTOR *
    2.29 +                                    std::sqrt(double(_arc_num))),
    2.30                                  MIN_BLOCK_SIZE );
    2.31          _head_length = std::max( int(HEAD_LENGTH_FACTOR * _block_size),
    2.32                                   MIN_HEAD_LENGTH );
    2.33 @@ -1225,7 +1228,7 @@
    2.34        }
    2.35  
    2.36        // Store the arcs in a mixed order
    2.37 -      int k = std::max(int(sqrt(_arc_num)), 10);
    2.38 +      int k = std::max(int(std::sqrt(double(_arc_num))), 10);
    2.39        int i = 0;
    2.40        for (ArcIt e(_graph); e != INVALID; ++e) {
    2.41          _arc_ref[i] = e;
     3.1 --- a/tools/lgf-gen.cc	Tue Apr 21 15:18:54 2009 +0100
     3.2 +++ b/tools/lgf-gen.cc	Thu Apr 23 10:44:35 2009 +0100
     3.3 @@ -65,7 +65,7 @@
     3.4  double totalLen(){
     3.5    double tlen=0;
     3.6    for(EdgeIt e(g);e!=INVALID;++e)
     3.7 -    tlen+=sqrt((coords[g.v(e)]-coords[g.u(e)]).normSquare());
     3.8 +    tlen+=std::sqrt((coords[g.v(e)]-coords[g.u(e)]).normSquare());
     3.9    return tlen;
    3.10  }
    3.11  
    3.12 @@ -188,7 +188,7 @@
    3.13        (q.x * q.x + q.y * q.y) * (r.x * p.y - p.x * r.y) +
    3.14        (r.x * r.x + r.y * r.y) * (p.x * q.y - q.x * p.y);
    3.15  
    3.16 -    return d / (2 * a) + sqrt((d * d + e * e) / (4 * a * a) + f / a);
    3.17 +    return d / (2 * a) + std::sqrt((d * d + e * e) / (4 * a * a) + f / a);
    3.18    }
    3.19  
    3.20    inline bool circle_form(const Point& p, const Point& q, const Point& r) {
    3.21 @@ -206,7 +206,7 @@
    3.22      double a = q.x - p.x;
    3.23      double b = (q.x - sx) * p.y - (p.x - sx) * q.y;
    3.24      double d = (q.x - sx) * (p.x - sx) * (p - q).normSquare();
    3.25 -    return (b - sqrt(d)) / a;
    3.26 +    return (b - std::sqrt(d)) / a;
    3.27    }
    3.28  
    3.29    struct YLess {
    3.30 @@ -813,7 +813,7 @@
    3.31    std::cout << "Number of arcs    : " << countEdges(g) << std::endl;
    3.32    double tlen=0;
    3.33    for(EdgeIt e(g);e!=INVALID;++e)
    3.34 -    tlen+=sqrt((coords[g.v(e)]-coords[g.u(e)]).normSquare());
    3.35 +    tlen+=std::sqrt((coords[g.v(e)]-coords[g.u(e)]).normSquare());
    3.36    std::cout << "Total arc length  : " << tlen << std::endl;
    3.37  
    3.38    if(ap["eps"])