COIN-OR::LEMON - Graph Library

Ticket #268: 0c8e5c688440.patch

File 0c8e5c688440.patch, 3.6 KB (added by Alpar Juttner, 15 years ago)
  • demo/graph_to_eps_demo.cc

    # HG changeset patch
    # User Alpar Juttner <alpar@cs.elte.hu>
    # Date 1240479875 -3600
    # Node ID 0c8e5c688440b6b90b285cd9af3c22c699b34748
    # Parent  85cb3aa71cced72f8915b8abf50f705037a76bb1
    Fix usage of sqrt() (#268)
    
    diff --git a/demo/graph_to_eps_demo.cc b/demo/graph_to_eps_demo.cc
    a b  
    182182  ListDigraph::NodeMap<int> hcolors(h);
    183183  ListDigraph::NodeMap<Point> hcoords(h);
    184184
    185   int cols=int(sqrt(double(palette.size())));
     185  int cols=int(std::sqrt(double(palette.size())));
    186186  for(int i=0;i<int(paletteW.size());i++) {
    187187    Node n=h.addNode();
    188188    hcoords[n]=Point(1+i%cols,1+i/cols);
  • lemon/network_simplex.h

    diff --git a/lemon/network_simplex.h b/lemon/network_simplex.h
    a b  
    381381        const double BLOCK_SIZE_FACTOR = 2.0;
    382382        const int MIN_BLOCK_SIZE = 10;
    383383
    384         _block_size = std::max( int(BLOCK_SIZE_FACTOR * sqrt(_arc_num)),
     384        _block_size = std::max( int(BLOCK_SIZE_FACTOR *
     385                                    std::sqrt(double(_arc_num))),
    385386                                MIN_BLOCK_SIZE );
    386387      }
    387388
     
    457458        const double MINOR_LIMIT_FACTOR = 0.1;
    458459        const int MIN_MINOR_LIMIT = 3;
    459460
    460         _list_length = std::max( int(LIST_LENGTH_FACTOR * sqrt(_arc_num)),
     461        _list_length = std::max( int(LIST_LENGTH_FACTOR *
     462                                     std::sqrt(double(_arc_num))),
    461463                                 MIN_LIST_LENGTH );
    462464        _minor_limit = std::max( int(MINOR_LIMIT_FACTOR * _list_length),
    463465                                 MIN_MINOR_LIMIT );
     
    577579        const double HEAD_LENGTH_FACTOR = 0.1;
    578580        const int MIN_HEAD_LENGTH = 3;
    579581
    580         _block_size = std::max( int(BLOCK_SIZE_FACTOR * sqrt(_arc_num)),
     582        _block_size = std::max( int(BLOCK_SIZE_FACTOR *
     583                                    std::sqrt(double(_arc_num))),
    581584                                MIN_BLOCK_SIZE );
    582585        _head_length = std::max( int(HEAD_LENGTH_FACTOR * _block_size),
    583586                                 MIN_HEAD_LENGTH );
     
    12251228      }
    12261229
    12271230      // Store the arcs in a mixed order
    1228       int k = std::max(int(sqrt(_arc_num)), 10);
     1231      int k = std::max(int(std::sqrt(double(_arc_num))), 10);
    12291232      int i = 0;
    12301233      for (ArcIt e(_graph); e != INVALID; ++e) {
    12311234        _arc_ref[i] = e;
  • tools/lgf-gen.cc

    diff --git a/tools/lgf-gen.cc b/tools/lgf-gen.cc
    a b  
    6565double totalLen(){
    6666  double tlen=0;
    6767  for(EdgeIt e(g);e!=INVALID;++e)
    68     tlen+=sqrt((coords[g.v(e)]-coords[g.u(e)]).normSquare());
     68    tlen+=std::sqrt((coords[g.v(e)]-coords[g.u(e)]).normSquare());
    6969  return tlen;
    7070}
    7171
     
    188188      (q.x * q.x + q.y * q.y) * (r.x * p.y - p.x * r.y) +
    189189      (r.x * r.x + r.y * r.y) * (p.x * q.y - q.x * p.y);
    190190
    191     return d / (2 * a) + sqrt((d * d + e * e) / (4 * a * a) + f / a);
     191    return d / (2 * a) + std::sqrt((d * d + e * e) / (4 * a * a) + f / a);
    192192  }
    193193
    194194  inline bool circle_form(const Point& p, const Point& q, const Point& r) {
     
    206206    double a = q.x - p.x;
    207207    double b = (q.x - sx) * p.y - (p.x - sx) * q.y;
    208208    double d = (q.x - sx) * (p.x - sx) * (p - q).normSquare();
    209     return (b - sqrt(d)) / a;
     209    return (b - std::sqrt(d)) / a;
    210210  }
    211211
    212212  struct YLess {
     
    813813  std::cout << "Number of arcs    : " << countEdges(g) << std::endl;
    814814  double tlen=0;
    815815  for(EdgeIt e(g);e!=INVALID;++e)
    816     tlen+=sqrt((coords[g.v(e)]-coords[g.u(e)]).normSquare());
     816    tlen+=std::sqrt((coords[g.v(e)]-coords[g.u(e)]).normSquare());
    817817  std::cout << "Total arc length  : " << tlen << std::endl;
    818818
    819819  if(ap["eps"])