Changeset 517:2b6d5d22bb23 in lemon-main
- Timestamp:
- 02/20/09 22:37:19 (16 years ago)
- Branch:
- default
- Parents:
- 495:dab9e610e37d (diff), 499:b1ef32ab39f3 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Phase:
- public
- Files:
-
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
.hgignore
r472 r517 23 23 lemon/stamp-h2 24 24 doc/Doxyfile 25 cmake/cmake.version 25 26 .dirstamp 26 27 .libs/* -
.hgignore
r494 r517 28 28 .deps/* 29 29 demo/*.eps 30 m4/libtool.m4 31 m4/ltoptions.m4 32 m4/ltsugar.m4 33 m4/ltversion.m4 34 m4/lt~obsolete.m4 30 35 31 36 syntax: regexp … … 36 41 ^autom4te.cache/.* 37 42 ^build-aux/.* 38 ^ objs.*/.*43 ^.*objs.*/.* 39 44 ^test/[a-z_]*$ 45 ^tools/[a-z-_]*$ 40 46 ^demo/.*_demo$ 41 ^ build/.*47 ^.*build.*/.* 42 48 ^doc/gen-images/.* 43 49 CMakeFiles -
CMakeLists.txt
r481 r517 32 32 SET(HAVE_GLPK TRUE) 33 33 ENDIF(GLPK_FOUND) 34 35 INCLUDE(CheckTypeSize) 36 CHECK_TYPE_SIZE("long long" LONG_LONG) 34 37 35 38 ENABLE_TESTING() -
CMakeLists.txt
r496 r517 14 14 INCLUDE(FindDoxygen) 15 15 INCLUDE(FindGhostscript) 16 FIND_PACKAGE(GLPK 4.33) 17 18 ADD_DEFINITIONS(-DHAVE_CONFIG_H) 19 20 IF(MSVC) 21 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4250 /wd4355 /wd4800 /wd4996") 22 # Suppressed warnings: 23 # C4250: 'class1' : inherits 'class2::member' via dominance 24 # C4355: 'this' : used in base member initializer list 25 # C4800: 'type' : forcing value to bool 'true' or 'false' (performance warning) 26 # C4996: 'function': was declared deprecated 27 ENDIF(MSVC) 28 29 IF(GLPK_FOUND) 30 SET(HAVE_LP TRUE) 31 SET(HAVE_MIP TRUE) 32 SET(HAVE_GLPK TRUE) 33 ENDIF(GLPK_FOUND) 16 34 17 35 INCLUDE(CheckTypeSize) -
configure.ac
r481 r517 22 22 dnl Do compilation tests using the C++ compiler. 23 23 AC_LANG([C++]) 24 25 dnl Check the existence of long long type. 26 AC_CHECK_TYPE(long long, [long_long_found=yes], [long_long_found=no]) 27 if test x"$long_long_found" = x"yes"; then 28 AC_DEFINE([HAVE_LONG_LONG], [1], [Define to 1 if you have long long.]) 29 fi 24 30 25 31 dnl Checks for programs. … … 120 126 echo C++ compiles flags............ : $WARNINGCXXFLAGS $CXXFLAGS 121 127 echo 128 echo Compiler supports long long... : $long_long_found 129 echo 122 130 echo GLPK support.................. : $lx_glpk_found 123 131 echo CPLEX support................. : $lx_cplex_found -
configure.ac
r496 r517 19 19 AC_CONFIG_SRCDIR([lemon/list_graph.h]) 20 20 AC_CONFIG_HEADERS([config.h lemon/config.h]) 21 22 lx_cmdline_cxxflags_set=${CXXFLAGS+set}23 21 24 22 dnl Do compilation tests using the C++ compiler. … … 53 51 54 52 dnl Set custom compiler flags when using g++. 55 if test x"$lx_cmdline_cxxflags_set" != x"set" -a"$GXX" = yes -a "$ICC" = no; then56 CXXFLAGS="$CXXFLAGS -Wall -W -Wall -W -Wunused -Wformat=2 -Wctor-dtor-privacy -Wnon-virtual-dtor -Wno-char-subscripts -Wwrite-strings -Wno-char-subscripts -Wreturn-type -Wcast-qual -Wcast-align -Wsign-promo -Woverloaded-virtual-Woverloaded-virtual -ansi -fno-strict-aliasing -Wold-style-cast -Wno-unknown-pragmas"53 if test "$GXX" = yes -a "$ICC" = no; then 54 WARNINGCXXFLAGS="-Wall -W -Wall -W -Wunused -Wformat=2 -Wctor-dtor-privacy -Wnon-virtual-dtor -Wno-char-subscripts -Wwrite-strings -Wno-char-subscripts -Wreturn-type -Wcast-qual -Wcast-align -Wsign-promo -Woverloaded-virtual -ansi -fno-strict-aliasing -Wold-style-cast -Wno-unknown-pragmas" 57 55 fi 56 AC_SUBST([WARNINGCXXFLAGS]) 58 57 59 58 dnl Checks for libraries. 60 #LX_CHECK_GLPK 61 #LX_CHECK_CPLEX 62 #LX_CHECK_SOPLEX 59 LX_CHECK_GLPK 60 LX_CHECK_CPLEX 61 LX_CHECK_SOPLEX 62 LX_CHECK_CLP 63 64 AM_CONDITIONAL([HAVE_LP], [test x"$lx_lp_found" = x"yes"]) 65 AM_CONDITIONAL([HAVE_MIP], [test x"$lx_mip_found" = x"yes"]) 63 66 64 67 dnl Disable/enable building the demo programs. … … 121 124 echo 122 125 echo C++ compiler.................. : $CXX 123 echo C++ compiles flags............ : $ CXXFLAGS126 echo C++ compiles flags............ : $WARNINGCXXFLAGS $CXXFLAGS 124 127 echo 125 128 echo Compiler supports long long... : $long_long_found 126 129 echo 127 #echo GLPK support.................. : $lx_glpk_found 128 #echo CPLEX support................. : $lx_cplex_found 129 #echo SOPLEX support................ : $lx_soplex_found 130 #echo 130 echo GLPK support.................. : $lx_glpk_found 131 echo CPLEX support................. : $lx_cplex_found 132 echo SOPLEX support................ : $lx_soplex_found 133 echo CLP support................... : $lx_clp_found 134 echo 131 135 echo Build demo programs........... : $enable_demo 132 136 echo Build additional tools........ : $enable_tools -
lemon/bits/default_map.h
r440 r517 97 97 98 98 99 #if defined __GNUC__ && !defined __STRICT_ANSI__99 #if defined HAVE_LONG_LONG 100 100 101 101 // long long -
lemon/bits/default_map.h
r496 r517 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). -
lemon/config.h.cmake
r473 r517 1 #cmakedefine HAVE_LONG_LONG 1 1 2 #cmakedefine HAVE_LP 1 2 3 #cmakedefine HAVE_MIP 1 -
lemon/config.h.cmake
r496 r517 1 1 #cmakedefine HAVE_LONG_LONG 1 2 #cmakedefine HAVE_LP 1 3 #cmakedefine HAVE_MIP 1 4 #cmakedefine HAVE_GLPK 1 -
lemon/config.h.in
r459 r517 1 /* Define to 1 if you have long long */ 2 #undef HAVE_LONG_LONG 3 1 4 /* Define to 1 if you have any LP solver. */ 2 5 #undef HAVE_LP -
lemon/config.h.in
r496 r517 1 /* Define to 1 if you have long long */ 2 #undef HAVE_LONG_LONG 3 4 /* Define to 1 if you have any LP solver. */ 5 #undef HAVE_LP 6 7 /* Define to 1 if you have any MIP solver. */ 8 #undef HAVE_MIP 9 1 10 /* Define to 1 if you have CPLEX. */ 2 11 #undef HAVE_CPLEX … … 5 14 #undef HAVE_GLPK 6 15 7 /* Define to 1 if you have long long */ 8 #undef HAVE_LONG_LONG 16 /* Define to 1 if you have SOPLEX */ 17 #undef HAVE_SOPLEX 18 19 /* Define to 1 if you have CLP */ 20 #undef HAVE_CLP -
lemon/lgf_reader.h
r440 r517 391 391 class DigraphReader; 392 392 393 /// \brief Return a \ref DigraphReader class394 ///395 /// This function just returns a \ref DigraphReader class.396 /// \relates DigraphReader397 393 template <typename Digraph> 398 DigraphReader<Digraph> digraphReader(Digraph& digraph, 399 std::istream& is = std::cin) { 400 DigraphReader<Digraph> tmp(digraph, is); 401 return tmp; 402 } 403 404 /// \brief Return a \ref DigraphReader class 405 /// 406 /// This function just returns a \ref DigraphReader class. 407 /// \relates DigraphReader 394 DigraphReader<Digraph> digraphReader(Digraph& digraph, 395 std::istream& is = std::cin); 408 396 template <typename Digraph> 409 DigraphReader<Digraph> digraphReader(Digraph& digraph, 410 const std::string& fn) { 411 DigraphReader<Digraph> tmp(digraph, fn); 412 return tmp; 413 } 414 415 /// \brief Return a \ref DigraphReader class 416 /// 417 /// This function just returns a \ref DigraphReader class. 418 /// \relates DigraphReader 397 DigraphReader<Digraph> digraphReader(Digraph& digraph, const std::string& fn); 419 398 template <typename Digraph> 420 DigraphReader<Digraph> digraphReader(Digraph& digraph, const char* fn) { 421 DigraphReader<Digraph> tmp(digraph, fn); 422 return tmp; 423 } 399 DigraphReader<Digraph> digraphReader(Digraph& digraph, const char *fn); 424 400 425 401 /// \ingroup lemon_io … … 585 561 private: 586 562 587 friend DigraphReader<Digraph> digraphReader<>(Digraph& digraph, 588 std::istream& is); 589 friend DigraphReader<Digraph> digraphReader<>(Digraph& digraph, 590 const std::string& fn); 591 friend DigraphReader<Digraph> digraphReader<>(Digraph& digraph, 592 const char *fn); 563 template <typename DGR> 564 friend DigraphReader<DGR> digraphReader(DGR& digraph, std::istream& is); 565 template <typename DGR> 566 friend DigraphReader<DGR> digraphReader(DGR& digraph, 567 const std::string& fn); 568 template <typename DGR> 569 friend DigraphReader<DGR> digraphReader(DGR& digraph, const char *fn); 593 570 594 571 DigraphReader(DigraphReader& other) … … 1213 1190 }; 1214 1191 1192 /// \brief Return a \ref DigraphReader class 1193 /// 1194 /// This function just returns a \ref DigraphReader class. 1195 /// \relates DigraphReader 1196 template <typename Digraph> 1197 DigraphReader<Digraph> digraphReader(Digraph& digraph, std::istream& is) { 1198 DigraphReader<Digraph> tmp(digraph, is); 1199 return tmp; 1200 } 1201 1202 /// \brief Return a \ref DigraphReader class 1203 /// 1204 /// This function just returns a \ref DigraphReader class. 1205 /// \relates DigraphReader 1206 template <typename Digraph> 1207 DigraphReader<Digraph> digraphReader(Digraph& digraph, 1208 const std::string& fn) { 1209 DigraphReader<Digraph> tmp(digraph, fn); 1210 return tmp; 1211 } 1212 1213 /// \brief Return a \ref DigraphReader class 1214 /// 1215 /// This function just returns a \ref DigraphReader class. 1216 /// \relates DigraphReader 1217 template <typename Digraph> 1218 DigraphReader<Digraph> digraphReader(Digraph& digraph, const char* fn) { 1219 DigraphReader<Digraph> tmp(digraph, fn); 1220 return tmp; 1221 } 1222 1215 1223 template <typename Graph> 1216 1224 class GraphReader; 1217 1218 /// \brief Return a \ref GraphReader class 1219 /// 1220 /// This function just returns a \ref GraphReader class. 1221 /// \relates GraphReader 1225 1222 1226 template <typename Graph> 1223 GraphReader<Graph> graphReader(Graph& graph, std::istream& is = std::cin) { 1224 GraphReader<Graph> tmp(graph, is); 1225 return tmp; 1226 } 1227 1228 /// \brief Return a \ref GraphReader class 1229 /// 1230 /// This function just returns a \ref GraphReader class. 1231 /// \relates GraphReader 1227 GraphReader<Graph> graphReader(Graph& graph, 1228 std::istream& is = std::cin); 1232 1229 template <typename Graph> 1233 GraphReader<Graph> graphReader(Graph& graph, const std::string& fn) { 1234 GraphReader<Graph> tmp(graph, fn); 1235 return tmp; 1236 } 1237 1238 /// \brief Return a \ref GraphReader class 1239 /// 1240 /// This function just returns a \ref GraphReader class. 1241 /// \relates GraphReader 1230 GraphReader<Graph> graphReader(Graph& graph, const std::string& fn); 1242 1231 template <typename Graph> 1243 GraphReader<Graph> graphReader(Graph& graph, const char* fn) { 1244 GraphReader<Graph> tmp(graph, fn); 1245 return tmp; 1246 } 1232 GraphReader<Graph> graphReader(Graph& graph, const char *fn); 1247 1233 1248 1234 /// \ingroup lemon_io … … 1371 1357 1372 1358 private: 1373 friend GraphReader<Graph> graphReader<>(Graph& graph, std::istream& is); 1374 friend GraphReader<Graph> graphReader<>(Graph& graph, 1375 const std::string& fn); 1376 friend GraphReader<Graph> graphReader<>(Graph& graph, const char *fn); 1359 template <typename GR> 1360 friend GraphReader<GR> graphReader(GR& graph, std::istream& is); 1361 template <typename GR> 1362 friend GraphReader<GR> graphReader(GR& graph, const std::string& fn); 1363 template <typename GR> 1364 friend GraphReader<GR> graphReader(GR& graph, const char *fn); 1377 1365 1378 1366 GraphReader(GraphReader& other) … … 2044 2032 2045 2033 }; 2034 2035 /// \brief Return a \ref GraphReader class 2036 /// 2037 /// This function just returns a \ref GraphReader class. 2038 /// \relates GraphReader 2039 template <typename Graph> 2040 GraphReader<Graph> graphReader(Graph& graph, std::istream& is) { 2041 GraphReader<Graph> tmp(graph, is); 2042 return tmp; 2043 } 2044 2045 /// \brief Return a \ref GraphReader class 2046 /// 2047 /// This function just returns a \ref GraphReader class. 2048 /// \relates GraphReader 2049 template <typename Graph> 2050 GraphReader<Graph> graphReader(Graph& graph, const std::string& fn) { 2051 GraphReader<Graph> tmp(graph, fn); 2052 return tmp; 2053 } 2054 2055 /// \brief Return a \ref GraphReader class 2056 /// 2057 /// This function just returns a \ref GraphReader class. 2058 /// \relates GraphReader 2059 template <typename Graph> 2060 GraphReader<Graph> graphReader(Graph& graph, const char* fn) { 2061 GraphReader<Graph> tmp(graph, fn); 2062 return tmp; 2063 } 2046 2064 2047 2065 class SectionReader; -
lemon/lgf_reader.h
r498 r517 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 848 848 readLine(); 849 849 } 850 line.putback(c); 850 if (readSuccess()) { 851 line.putback(c); 852 } 851 853 } 852 854 … … 1688 1690 readLine(); 1689 1691 } 1690 line.putback(c); 1692 if (readSuccess()) { 1693 line.putback(c); 1694 } 1691 1695 } 1692 1696 … … 2245 2249 readLine(); 2246 2250 } 2247 line.putback(c); 2251 if (readSuccess()) { 2252 line.putback(c); 2253 } 2248 2254 } 2249 2255 … … 2586 2592 readLine(); 2587 2593 } 2588 line.putback(c); 2594 if (readSuccess()) { 2595 line.putback(c); 2596 } 2589 2597 } 2590 2598 -
lemon/lgf_writer.h
r440 r517 351 351 class DigraphWriter; 352 352 353 /// \brief Return a \ref DigraphWriter class354 ///355 /// This function just returns a \ref DigraphWriter class.356 /// \relates DigraphWriter357 353 template <typename Digraph> 358 354 DigraphWriter<Digraph> digraphWriter(const Digraph& digraph, 359 std::ostream& os = std::cout) { 360 DigraphWriter<Digraph> tmp(digraph, os); 361 return tmp; 362 } 363 364 /// \brief Return a \ref DigraphWriter class 365 /// 366 /// This function just returns a \ref DigraphWriter class. 367 /// \relates DigraphWriter 355 std::ostream& os = std::cout); 368 356 template <typename Digraph> 369 357 DigraphWriter<Digraph> digraphWriter(const Digraph& digraph, 370 const std::string& fn) { 371 DigraphWriter<Digraph> tmp(digraph, fn); 372 return tmp; 373 } 374 375 /// \brief Return a \ref DigraphWriter class 376 /// 377 /// This function just returns a \ref DigraphWriter class. 378 /// \relates DigraphWriter 358 const std::string& fn); 359 379 360 template <typename Digraph> 380 361 DigraphWriter<Digraph> digraphWriter(const Digraph& digraph, 381 const char* fn) { 382 DigraphWriter<Digraph> tmp(digraph, fn); 383 return tmp; 384 } 362 const char* fn); 363 385 364 386 365 /// \ingroup lemon_io … … 527 506 private: 528 507 529 friend DigraphWriter<Digraph> digraphWriter<>(const Digraph& digraph, 530 std::ostream& os); 531 friend DigraphWriter<Digraph> digraphWriter<>(const Digraph& digraph, 532 const std::string& fn); 533 friend DigraphWriter<Digraph> digraphWriter<>(const Digraph& digraph, 534 const char *fn); 508 template <typename DGR> 509 friend DigraphWriter<DGR> digraphWriter(const DGR& digraph, 510 std::ostream& os); 511 template <typename DGR> 512 friend DigraphWriter<DGR> digraphWriter(const DGR& digraph, 513 const std::string& fn); 514 template <typename DGR> 515 friend DigraphWriter<DGR> digraphWriter(const DGR& digraph, 516 const char *fn); 535 517 536 518 DigraphWriter(DigraphWriter& other) … … 934 916 }; 935 917 918 /// \brief Return a \ref DigraphWriter class 919 /// 920 /// This function just returns a \ref DigraphWriter class. 921 /// \relates DigraphWriter 922 template <typename Digraph> 923 DigraphWriter<Digraph> digraphWriter(const Digraph& digraph, 924 std::ostream& os) { 925 DigraphWriter<Digraph> tmp(digraph, os); 926 return tmp; 927 } 928 929 /// \brief Return a \ref DigraphWriter class 930 /// 931 /// This function just returns a \ref DigraphWriter class. 932 /// \relates DigraphWriter 933 template <typename Digraph> 934 DigraphWriter<Digraph> digraphWriter(const Digraph& digraph, 935 const std::string& fn) { 936 DigraphWriter<Digraph> tmp(digraph, fn); 937 return tmp; 938 } 939 940 /// \brief Return a \ref DigraphWriter class 941 /// 942 /// This function just returns a \ref DigraphWriter class. 943 /// \relates DigraphWriter 944 template <typename Digraph> 945 DigraphWriter<Digraph> digraphWriter(const Digraph& digraph, 946 const char* fn) { 947 DigraphWriter<Digraph> tmp(digraph, fn); 948 return tmp; 949 } 950 936 951 template <typename Graph> 937 952 class GraphWriter; 938 953 939 /// \brief Return a \ref GraphWriter class940 ///941 /// This function just returns a \ref GraphWriter class.942 /// \relates GraphWriter943 954 template <typename Graph> 944 955 GraphWriter<Graph> graphWriter(const Graph& graph, 945 std::ostream& os = std::cout) { 946 GraphWriter<Graph> tmp(graph, os); 947 return tmp; 948 } 949 950 /// \brief Return a \ref GraphWriter class 951 /// 952 /// This function just returns a \ref GraphWriter class. 953 /// \relates GraphWriter 956 std::ostream& os = std::cout); 954 957 template <typename Graph> 955 GraphWriter<Graph> graphWriter(const Graph& graph, const std::string& fn) { 956 GraphWriter<Graph> tmp(graph, fn); 957 return tmp; 958 } 959 960 /// \brief Return a \ref GraphWriter class 961 /// 962 /// This function just returns a \ref GraphWriter class. 963 /// \relates GraphWriter 958 GraphWriter<Graph> graphWriter(const Graph& graph, const std::string& fn); 964 959 template <typename Graph> 965 GraphWriter<Graph> graphWriter(const Graph& graph, const char* fn) { 966 GraphWriter<Graph> tmp(graph, fn); 967 return tmp; 968 } 960 GraphWriter<Graph> graphWriter(const Graph& graph, const char* fn); 969 961 970 962 /// \ingroup lemon_io … … 1082 1074 private: 1083 1075 1084 friend GraphWriter<Graph> graphWriter<>(const Graph& graph, 1085 std::ostream& os); 1086 friend GraphWriter<Graph> graphWriter<>(const Graph& graph, 1087 const std::string& fn); 1088 friend GraphWriter<Graph> graphWriter<>(const Graph& graph, 1089 const char *fn); 1090 1076 template <typename GR> 1077 friend GraphWriter<GR> graphWriter(const GR& graph, 1078 std::ostream& os); 1079 template <typename GR> 1080 friend GraphWriter<GR> graphWriter(const GR& graph, 1081 const std::string& fn); 1082 template <typename GR> 1083 friend GraphWriter<GR> graphWriter(const GR& graph, 1084 const char *fn); 1085 1091 1086 GraphWriter(GraphWriter& other) 1092 1087 : _os(other._os), local_os(other.local_os), _graph(other._graph), … … 1534 1529 /// @} 1535 1530 }; 1531 1532 /// \brief Return a \ref GraphWriter class 1533 /// 1534 /// This function just returns a \ref GraphWriter class. 1535 /// \relates GraphWriter 1536 template <typename Graph> 1537 GraphWriter<Graph> graphWriter(const Graph& graph, 1538 std::ostream& os) { 1539 GraphWriter<Graph> tmp(graph, os); 1540 return tmp; 1541 } 1542 1543 /// \brief Return a \ref GraphWriter class 1544 /// 1545 /// This function just returns a \ref GraphWriter class. 1546 /// \relates GraphWriter 1547 template <typename Graph> 1548 GraphWriter<Graph> graphWriter(const Graph& graph, const std::string& fn) { 1549 GraphWriter<Graph> tmp(graph, fn); 1550 return tmp; 1551 } 1552 1553 /// \brief Return a \ref GraphWriter class 1554 /// 1555 /// This function just returns a \ref GraphWriter class. 1556 /// \relates GraphWriter 1557 template <typename Graph> 1558 GraphWriter<Graph> graphWriter(const Graph& graph, const char* fn) { 1559 GraphWriter<Graph> tmp(graph, fn); 1560 return tmp; 1561 } 1536 1562 1537 1563 class SectionWriter; -
lemon/lgf_writer.h
r498 r517 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). -
lemon/path.h
r440 r517 930 930 931 931 template <typename Target, typename Source, 932 bool buildEnable = BuildTagIndicator<Target>::value, 933 bool revEnable = RevPathTagIndicator<Source>::value> 934 struct PathCopySelector { 932 bool buildEnable = BuildTagIndicator<Target>::value> 933 struct PathCopySelectorForward { 935 934 static void copy(Target& target, const Source& source) { 936 935 target.clear(); … … 942 941 943 942 template <typename Target, typename Source> 944 struct PathCopySelector<Target, Source, false, true> { 943 struct PathCopySelectorForward<Target, Source, true> { 944 static void copy(Target& target, const Source& source) { 945 target.clear(); 946 target.build(source); 947 } 948 }; 949 950 template <typename Target, typename Source, 951 bool buildEnable = BuildTagIndicator<Target>::value> 952 struct PathCopySelectorBackward { 945 953 static void copy(Target& target, const Source& source) { 946 954 target.clear(); … … 952 960 953 961 template <typename Target, typename Source> 954 struct PathCopySelector<Target, Source, true, false> { 955 static void copy(Target& target, const Source& source) { 956 target.clear(); 957 target.build(source); 958 } 959 }; 960 961 template <typename Target, typename Source> 962 struct PathCopySelector<Target, Source, true, true> { 962 struct PathCopySelectorBackward<Target, Source, true> { 963 963 static void copy(Target& target, const Source& source) { 964 964 target.clear(); 965 965 target.buildRev(source); 966 966 } 967 }; 968 969 970 template <typename Target, typename Source, 971 bool revEnable = RevPathTagIndicator<Source>::value> 972 struct PathCopySelector { 973 static void copy(Target& target, const Source& source) { 974 PathCopySelectorForward<Target, Source>::copy(target, source); 975 } 976 }; 977 978 template <typename Target, typename Source> 979 struct PathCopySelector<Target, Source, true> { 980 static void copy(Target& target, const Source& source) { 981 PathCopySelectorBackward<Target, Source>::copy(target, source); 982 } 967 983 }; 968 984 -
lemon/path.h
r498 r517 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). -
lemon/random.h
r492 r517 345 345 }; 346 346 347 template <typename Result, int exp , bool pos = (exp >= 0)>347 template <typename Result, int exp> 348 348 struct ShiftMultiplier { 349 static const Result multiplier() {350 Result res = ShiftMultiplier<Result, exp / 2>::multiplier();351 res *= res;352 if ((exp & 1) == 1) res *= static_cast<Result>(2.0);353 return res;354 }355 };356 357 template <typename Result, int exp>358 struct ShiftMultiplier<Result, exp, false> {359 349 static const Result multiplier() { 360 350 Result res = ShiftMultiplier<Result, exp / 2>::multiplier(); … … 366 356 367 357 template <typename Result> 368 struct ShiftMultiplier<Result, 0 , true> {358 struct ShiftMultiplier<Result, 0> { 369 359 static const Result multiplier() { 370 360 return static_cast<Result>(1.0); … … 373 363 374 364 template <typename Result> 375 struct ShiftMultiplier<Result, -20, true> {365 struct ShiftMultiplier<Result, 20> { 376 366 static const Result multiplier() { 377 367 return static_cast<Result>(1.0/1048576.0); … … 380 370 381 371 template <typename Result> 382 struct ShiftMultiplier<Result, -32, true> {372 struct ShiftMultiplier<Result, 32> { 383 373 static const Result multiplier() { 384 return static_cast<Result>(1.0/42 4967296.0);374 return static_cast<Result>(1.0/4294967296.0); 385 375 } 386 376 }; 387 377 388 378 template <typename Result> 389 struct ShiftMultiplier<Result, -53, true> {379 struct ShiftMultiplier<Result, 53> { 390 380 static const Result multiplier() { 391 381 return static_cast<Result>(1.0/9007199254740992.0); … … 394 384 395 385 template <typename Result> 396 struct ShiftMultiplier<Result, -64, true> {386 struct ShiftMultiplier<Result, 64> { 397 387 static const Result multiplier() { 398 388 return static_cast<Result>(1.0/18446744073709551616.0); … … 414 404 415 405 static Result convert(RandomCore<Word>& rnd) { 416 return Shifting<Result, - shift -rest>::406 return Shifting<Result, shift + rest>:: 417 407 shift(static_cast<Result>(rnd() >> (bits - rest))); 418 408 } … … 424 414 425 415 static Result convert(RandomCore<Word>& rnd) { 426 return Shifting<Result, - shift -bits>::416 return Shifting<Result, shift + bits>:: 427 417 shift(static_cast<Result>(rnd())) + 428 418 RealConversion<Result, Word, rest-bits, shift + bits>:: -
lemon/random.h
r498 r517 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 531 531 /// @{ 532 532 533 ///\name Initialization534 ///535 /// @{536 537 533 /// \brief Default constructor 538 534 /// … … 681 677 } 682 678 683 /// @}684 685 ///\name Uniform distributions686 ///687 /// @{688 689 679 /// \brief Returns a random real number from the range [0, 1) 690 680 /// … … 741 731 return _random_bits::IntConversion<Number, Word>::convert(core); 742 732 } 743 744 /// @}745 733 746 734 unsigned int uinteger() { … … 777 765 ///\name Non-uniform distributions 778 766 /// 779 780 767 ///@{ 781 768 782 /// \brief Returns a random bool 769 /// \brief Returns a random bool with given probability of true result. 783 770 /// 784 771 /// It returns a random bool with given probability of true result. … … 787 774 } 788 775 789 /// Standard Gaussdistribution790 791 /// Standard Gaussdistribution.776 /// Standard normal (Gauss) distribution 777 778 /// Standard normal (Gauss) distribution. 792 779 /// \note The Cartesian form of the Box-Muller 793 780 /// transformation is used to generate a random normal distribution. … … 802 789 return std::sqrt(-2*std::log(S)/S)*V1; 803 790 } 804 /// Gaussdistribution with given mean and standard deviation805 806 /// Gaussdistribution with given mean and standard deviation.791 /// Normal (Gauss) distribution with given mean and standard deviation 792 793 /// Normal (Gauss) distribution with given mean and standard deviation. 807 794 /// \sa gauss() 808 795 double gauss(double mean,double std_dev) 809 796 { 810 797 return gauss()*std_dev+mean; 798 } 799 800 /// Lognormal distribution 801 802 /// Lognormal distribution. The parameters are the mean and the standard 803 /// deviation of <tt>exp(X)</tt>. 804 /// 805 double lognormal(double n_mean,double n_std_dev) 806 { 807 return std::exp(gauss(n_mean,n_std_dev)); 808 } 809 /// Lognormal distribution 810 811 /// Lognormal distribution. The parameter is an <tt>std::pair</tt> of 812 /// the mean and the standard deviation of <tt>exp(X)</tt>. 813 /// 814 double lognormal(const std::pair<double,double> ¶ms) 815 { 816 return std::exp(gauss(params.first,params.second)); 817 } 818 /// Compute the lognormal parameters from mean and standard deviation 819 820 /// This function computes the lognormal parameters from mean and 821 /// standard deviation. The return value can direcly be passed to 822 /// lognormal(). 823 std::pair<double,double> lognormalParamsFromMD(double mean, 824 double std_dev) 825 { 826 double fr=std_dev/mean; 827 fr*=fr; 828 double lg=std::log(1+fr); 829 return std::pair<double,double>(std::log(mean)-lg/2.0,std::sqrt(lg)); 830 } 831 /// Lognormal distribution with given mean and standard deviation 832 833 /// Lognormal distribution with given mean and standard deviation. 834 /// 835 double lognormalMD(double mean,double std_dev) 836 { 837 return lognormal(lognormalParamsFromMD(mean,std_dev)); 811 838 } 812 839 … … 914 941 ///\name Two dimensional distributions 915 942 /// 916 917 943 ///@{ 918 944 … … 931 957 return dim2::Point<double>(V1,V2); 932 958 } 933 /// A kind of two dimensional Gaussdistribution959 /// A kind of two dimensional normal (Gauss) distribution 934 960 935 961 /// This function provides a turning symmetric two-dimensional distribution. -
lemon/tolerance.h
r440 r517 39 39 ///as a result of a probably inexact computation. 40 40 /// 41 ///This is an abstract class, it should be specialized for all 42 ///numerical data types. These specialized classes like 41 ///The general implementation is suitable only if the data type is exact, 42 ///like the integer types, otherwise a specialized version must be 43 ///implemented. These specialized classes like 43 44 ///Tolerance<double> may offer additional tuning parameters. 44 45 /// … … 46 47 ///\sa Tolerance<double> 47 48 ///\sa Tolerance<long double> 48 ///\sa Tolerance<int>49 ///\sa Tolerance<long long int>50 ///\sa Tolerance<unsigned int>51 ///\sa Tolerance<unsigned long long int>52 49 53 50 template<class T> … … 65 62 66 63 ///Returns \c true if \c a is \e surely strictly less than \c b 67 static bool less(Value a,Value b) {return false;}68 ///Returns \c true if \c a is \e surely different from \c b 69 static bool different(Value a,Value b) {return false;}70 ///Returns \c true if \c a is \e surely positive 71 static bool positive(Value a) {return false;}72 ///Returns \c true if \c a is \e surely negative 73 static bool negative(Value a) {return false;}74 ///Returns \c true if \c a is \e surely non-zero 75 static bool nonZero(Value a) {return false;}64 static bool less(Value a,Value b) {return a<b;} 65 ///Returns \c true if \c a is \e surely different from \c b 66 static bool different(Value a,Value b) {return a!=b;} 67 ///Returns \c true if \c a is \e surely positive 68 static bool positive(Value a) {return static_cast<Value>(0) < a;} 69 ///Returns \c true if \c a is \e surely negative 70 static bool negative(Value a) {return a < static_cast<Value>(0);} 71 ///Returns \c true if \c a is \e surely non-zero 72 static bool nonZero(Value a) {return a != static_cast<Value>(0);} 76 73 77 74 ///@} 78 75 79 76 ///Returns the zero value. 80 static Value zero() {return T();}77 static Value zero() {return static_cast<Value>(0);} 81 78 82 79 // static bool finite(Value a) {} … … 239 236 }; 240 237 241 ///Integer specialization of Tolerance.242 243 ///Integer specialization of Tolerance.244 ///\sa Tolerance245 template<>246 class Tolerance<int>247 {248 public:249 ///\e250 typedef int Value;251 252 ///\name Comparisons253 ///See \ref lemon::Tolerance "Tolerance" for more details.254 255 ///@{256 257 ///Returns \c true if \c a is \e surely strictly less than \c b258 static bool less(Value a,Value b) { return a<b;}259 ///Returns \c true if \c a is \e surely different from \c b260 static bool different(Value a,Value b) { return a!=b; }261 ///Returns \c true if \c a is \e surely positive262 static bool positive(Value a) { return 0<a; }263 ///Returns \c true if \c a is \e surely negative264 static bool negative(Value a) { return 0>a; }265 ///Returns \c true if \c a is \e surely non-zero266 static bool nonZero(Value a) { return a!=0; }267 268 ///@}269 270 ///Returns zero271 static Value zero() {return 0;}272 };273 274 ///Unsigned integer specialization of Tolerance.275 276 ///Unsigned integer specialization of Tolerance.277 ///\sa Tolerance278 template<>279 class Tolerance<unsigned int>280 {281 public:282 ///\e283 typedef unsigned int Value;284 285 ///\name Comparisons286 ///See \ref lemon::Tolerance "Tolerance" for more details.287 288 ///@{289 290 ///Returns \c true if \c a is \e surely strictly less than \c b291 static bool less(Value a,Value b) { return a<b;}292 ///Returns \c true if \c a is \e surely different from \c b293 static bool different(Value a,Value b) { return a!=b; }294 ///Returns \c true if \c a is \e surely positive295 static bool positive(Value a) { return 0<a; }296 ///Returns \c true if \c a is \e surely negative297 static bool negative(Value) { return false; }298 ///Returns \c true if \c a is \e surely non-zero299 static bool nonZero(Value a) { return a!=0; }300 301 ///@}302 303 ///Returns zero304 static Value zero() {return 0;}305 };306 307 308 ///Long integer specialization of Tolerance.309 310 ///Long integer specialization of Tolerance.311 ///\sa Tolerance312 template<>313 class Tolerance<long int>314 {315 public:316 ///\e317 typedef long int Value;318 319 ///\name Comparisons320 ///See \ref lemon::Tolerance "Tolerance" for more details.321 322 ///@{323 324 ///Returns \c true if \c a is \e surely strictly less than \c b325 static bool less(Value a,Value b) { return a<b;}326 ///Returns \c true if \c a is \e surely different from \c b327 static bool different(Value a,Value b) { return a!=b; }328 ///Returns \c true if \c a is \e surely positive329 static bool positive(Value a) { return 0<a; }330 ///Returns \c true if \c a is \e surely negative331 static bool negative(Value a) { return 0>a; }332 ///Returns \c true if \c a is \e surely non-zero333 static bool nonZero(Value a) { return a!=0;}334 335 ///@}336 337 ///Returns zero338 static Value zero() {return 0;}339 };340 341 ///Unsigned long integer specialization of Tolerance.342 343 ///Unsigned long integer specialization of Tolerance.344 ///\sa Tolerance345 template<>346 class Tolerance<unsigned long int>347 {348 public:349 ///\e350 typedef unsigned long int Value;351 352 ///\name Comparisons353 ///See \ref lemon::Tolerance "Tolerance" for more details.354 355 ///@{356 357 ///Returns \c true if \c a is \e surely strictly less than \c b358 static bool less(Value a,Value b) { return a<b;}359 ///Returns \c true if \c a is \e surely different from \c b360 static bool different(Value a,Value b) { return a!=b; }361 ///Returns \c true if \c a is \e surely positive362 static bool positive(Value a) { return 0<a; }363 ///Returns \c true if \c a is \e surely negative364 static bool negative(Value) { return false; }365 ///Returns \c true if \c a is \e surely non-zero366 static bool nonZero(Value a) { return a!=0;}367 368 ///@}369 370 ///Returns zero371 static Value zero() {return 0;}372 };373 374 #if defined __GNUC__ && !defined __STRICT_ANSI__375 376 ///Long long integer specialization of Tolerance.377 378 ///Long long integer specialization of Tolerance.379 ///\warning This class (more exactly, type <tt>long long</tt>)380 ///is not ansi compatible.381 ///\sa Tolerance382 template<>383 class Tolerance<long long int>384 {385 public:386 ///\e387 typedef long long int Value;388 389 ///\name Comparisons390 ///See \ref lemon::Tolerance "Tolerance" for more details.391 392 ///@{393 394 ///Returns \c true if \c a is \e surely strictly less than \c b395 static bool less(Value a,Value b) { return a<b;}396 ///Returns \c true if \c a is \e surely different from \c b397 static bool different(Value a,Value b) { return a!=b; }398 ///Returns \c true if \c a is \e surely positive399 static bool positive(Value a) { return 0<a; }400 ///Returns \c true if \c a is \e surely negative401 static bool negative(Value a) { return 0>a; }402 ///Returns \c true if \c a is \e surely non-zero403 static bool nonZero(Value a) { return a!=0;}404 405 ///@}406 407 ///Returns zero408 static Value zero() {return 0;}409 };410 411 ///Unsigned long long integer specialization of Tolerance.412 413 ///Unsigned long long integer specialization of Tolerance.414 ///\warning This class (more exactly, type <tt>unsigned long long</tt>)415 ///is not ansi compatible.416 ///\sa Tolerance417 template<>418 class Tolerance<unsigned long long int>419 {420 public:421 ///\e422 typedef unsigned long long int Value;423 424 ///\name Comparisons425 ///See \ref lemon::Tolerance "Tolerance" for more details.426 427 ///@{428 429 ///Returns \c true if \c a is \e surely strictly less than \c b430 static bool less(Value a,Value b) { return a<b;}431 ///Returns \c true if \c a is \e surely different from \c b432 static bool different(Value a,Value b) { return a!=b; }433 ///Returns \c true if \c a is \e surely positive434 static bool positive(Value a) { return 0<a; }435 ///Returns \c true if \c a is \e surely negative436 static bool negative(Value) { return false; }437 ///Returns \c true if \c a is \e surely non-zero438 static bool nonZero(Value a) { return a!=0;}439 440 ///@}441 442 ///Returns zero443 static Value zero() {return 0;}444 };445 446 #endif447 448 238 /// @} 449 239 -
lemon/tolerance.h
r497 r517 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-200 85 * Copyright (C) 2003-2009 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES).
Note: See TracChangeset
for help on using the changeset viewer.