0
4
0
| 1 | 1 |
CMAKE_MINIMUM_REQUIRED(VERSION 2.6) |
| 2 | 2 |
|
| 3 | 3 |
SET(PROJECT_NAME "LEMON") |
| 4 | 4 |
SET(PROJECT_VERSION "hg-tip" CACHE STRING "The version string.") |
| 5 | 5 |
|
| 6 | 6 |
PROJECT(${PROJECT_NAME})
|
| 7 | 7 |
|
| 8 | 8 |
SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
|
| 9 | 9 |
|
| 10 | 10 |
INCLUDE(FindDoxygen) |
| 11 | 11 |
INCLUDE(FindGhostscript) |
| 12 | 12 |
FIND_PACKAGE(GLPK 4.33) |
| 13 | 13 |
|
| 14 | 14 |
ADD_DEFINITIONS(-DHAVE_CONFIG_H) |
| 15 | 15 |
|
| 16 |
IF(MSVC) |
|
| 17 |
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4250 /wd4355 /wd4800 /wd4996")
|
|
| 18 |
# Suppressed warnings: |
|
| 19 |
# C4250: 'class1' : inherits 'class2::member' via dominance |
|
| 20 |
# C4355: 'this' : used in base member initializer list |
|
| 21 |
# C4800: 'type' : forcing value to bool 'true' or 'false' (performance warning) |
|
| 22 |
# C4996: 'function': was declared deprecated |
|
| 23 |
ENDIF(MSVC) |
|
| 24 |
|
|
| 16 | 25 |
IF(GLPK_FOUND) |
| 17 | 26 |
SET(HAVE_LP TRUE) |
| 18 | 27 |
SET(HAVE_MIP TRUE) |
| 19 | 28 |
SET(HAVE_GLPK TRUE) |
| 20 | 29 |
ENDIF(GLPK_FOUND) |
| 21 | 30 |
|
| 22 | 31 |
ENABLE_TESTING() |
| 23 | 32 |
|
| 24 | 33 |
ADD_SUBDIRECTORY(lemon) |
| 25 | 34 |
ADD_SUBDIRECTORY(demo) |
| 26 | 35 |
ADD_SUBDIRECTORY(doc) |
| 27 | 36 |
ADD_SUBDIRECTORY(test) |
| 28 | 37 |
|
| 29 | 38 |
IF(WIN32) |
| 30 | 39 |
INSTALL(FILES ${CMAKE_SOURCE_DIR}/cmake/nsis/lemon.ico
|
| 31 | 40 |
DESTINATION bin) |
| 32 | 41 |
ENDIF(WIN32) |
| 33 | 42 |
|
| 34 | 43 |
IF(WIN32) |
| 35 | 44 |
SET(CPACK_PACKAGE_NAME ${PROJECT_NAME})
|
| 36 | 45 |
SET(CPACK_PACKAGE_VENDOR |
| 37 | 46 |
"EGRES - Egervary Research Group on Combinatorial Optimization") |
| 38 | 47 |
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY |
| 39 | 48 |
"LEMON - Library of Efficient Models and Optimization in Networks") |
| 40 | 49 |
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE")
|
| 41 | 50 |
|
| 42 | 51 |
SET(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
|
| 43 | 52 |
|
| 44 | 53 |
SET(CPACK_PACKAGE_INSTALL_DIRECTORY |
| 45 | 54 |
"${PROJECT_NAME} ${PROJECT_VERSION}")
|
| 46 | 55 |
SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY |
| 47 | 56 |
"${PROJECT_NAME} ${PROJECT_VERSION}")
|
| 48 | 57 |
|
| 49 | 58 |
# Variables to generate a component-based installer. |
| 50 | 59 |
#SET(CPACK_COMPONENTS_ALL headers library html_documentation) |
| 51 | 60 |
|
| 52 | 61 |
#SET(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C++ headers") |
| 53 | 62 |
#SET(CPACK_COMPONENT_LIBRARY_DISPLAY_NAME "Static library") |
| 54 | 63 |
#SET(CPACK_COMPONENT_HTML_DOCUMENTATION_DISPLAY_NAME "HTML documentation") |
| 55 | 64 |
|
| 56 | 65 |
#SET(CPACK_COMPONENT_HEADERS_DESCRIPTION |
| 57 | 66 |
# "C++ header files for use with the LEMON library") |
| 58 | 67 |
#SET(CPACK_COMPONENT_LIBRARY_DESCRIPTION |
| 59 | 68 |
# "Static library used to build programs with LEMON") |
| 60 | 69 |
#SET(CPACK_COMPONENT_HTML_DOCUMENTATION_DESCRIPTION |
| 61 | 70 |
# "Doxygen generated documentation") |
| 62 | 71 |
|
| 63 | 72 |
#SET(CPACK_COMPONENT_HEADERS_DEPENDS library) |
| 64 | 73 |
|
| 65 | 74 |
#SET(CPACK_COMPONENT_HEADERS_GROUP "Development") |
| 66 | 75 |
#SET(CPACK_COMPONENT_LIBRARY_GROUP "Development") |
| 67 | 76 |
#SET(CPACK_COMPONENT_HTML_DOCUMENTATION_GROUP "Documentation") |
| 68 | 77 |
|
| 69 | 78 |
#SET(CPACK_COMPONENT_GROUP_DEVELOPMENT_DESCRIPTION |
| 70 | 79 |
# "Components needed to develop software using LEMON") |
| 71 | 80 |
#SET(CPACK_COMPONENT_GROUP_DOCUMENTATION_DESCRIPTION |
| 72 | 81 |
# "Documentation of LEMON") |
| 73 | 82 |
|
| 74 | 83 |
#SET(CPACK_ALL_INSTALL_TYPES Full Developer) |
| 75 | 84 |
|
| 76 | 85 |
#SET(CPACK_COMPONENT_HEADERS_INSTALL_TYPES Developer Full) |
| 77 | 86 |
#SET(CPACK_COMPONENT_LIBRARY_INSTALL_TYPES Developer Full) |
| 78 | 87 |
#SET(CPACK_COMPONENT_HTML_DOCUMENTATION_INSTALL_TYPES Full) |
| 79 | 88 |
|
| 80 | 89 |
SET(CPACK_GENERATOR "NSIS") |
| 81 | 90 |
SET(CPACK_NSIS_MUI_ICON "${CMAKE_SOURCE_DIR}/cmake/nsis/lemon.ico")
|
| 82 | 91 |
SET(CPACK_NSIS_MUI_UNIICON "${CMAKE_SOURCE_DIR}/cmake/nsis/uninstall.ico")
|
| 83 | 92 |
#SET(CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/cmake/nsis\\\\installer.bmp")
|
| 84 | 93 |
SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\lemon.ico") |
| 85 | 94 |
SET(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} ${PROJECT_NAME}")
|
| 86 | 95 |
SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\lemon.cs.elte.hu") |
| 87 | 96 |
SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\lemon.cs.elte.hu") |
| 88 | 97 |
SET(CPACK_NSIS_CONTACT "lemon-user@lemon.cs.elte.hu") |
| 89 | 98 |
SET(CPACK_NSIS_CREATE_ICONS_EXTRA " |
| 90 | 99 |
CreateShortCut \\\"$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Documentation.lnk\\\" \\\"$INSTDIR\\\\doc\\\\index.html\\\" |
| 91 | 100 |
") |
| 92 | 101 |
SET(CPACK_NSIS_DELETE_ICONS_EXTRA " |
| 93 | 102 |
!insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP |
| 94 | 103 |
Delete \\\"$SMPROGRAMS\\\\$MUI_TEMP\\\\Documentation.lnk\\\" |
| 95 | 104 |
") |
| 96 | 105 |
|
| 97 | 106 |
INCLUDE(CPack) |
| 98 | 107 |
ENDIF(WIN32) |
| 1 | 1 |
/* -*- mode: C++; indent-tabs-mode: nil; -*- |
| 2 | 2 |
* |
| 3 | 3 |
* This file is a part of LEMON, a generic C++ optimization library. |
| 4 | 4 |
* |
| 5 | 5 |
* Copyright (C) 2003-2009 |
| 6 | 6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
| 7 | 7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES). |
| 8 | 8 |
* |
| 9 | 9 |
* Permission to use, modify and distribute this software is granted |
| 10 | 10 |
* provided that this copyright notice appears in all copies. For |
| 11 | 11 |
* precise terms see the accompanying LICENSE file. |
| 12 | 12 |
* |
| 13 | 13 |
* This software is provided "AS IS" with no warranty of any kind, |
| 14 | 14 |
* express or implied, and with no claim as to its suitability for any |
| 15 | 15 |
* purpose. |
| 16 | 16 |
* |
| 17 | 17 |
*/ |
| 18 | 18 |
|
| 19 | 19 |
///\file |
| 20 | 20 |
///\brief Some basic non-inline functions and static global data. |
| 21 | 21 |
|
| 22 | 22 |
#include<lemon/tolerance.h> |
| 23 | 23 |
#include<lemon/core.h> |
| 24 | 24 |
namespace lemon {
|
| 25 | 25 |
|
| 26 |
float Tolerance<float>::def_epsilon = 1e-4; |
|
| 26 |
float Tolerance<float>::def_epsilon = static_cast<float>(1e-4); |
|
| 27 | 27 |
double Tolerance<double>::def_epsilon = 1e-10; |
| 28 | 28 |
long double Tolerance<long double>::def_epsilon = 1e-14; |
| 29 | 29 |
|
| 30 | 30 |
#ifndef LEMON_ONLY_TEMPLATES |
| 31 | 31 |
const Invalid INVALID = Invalid(); |
| 32 | 32 |
#endif |
| 33 | 33 |
|
| 34 | 34 |
} //namespace lemon |
| 1 | 1 |
INCLUDE_DIRECTORIES( |
| 2 | 2 |
${CMAKE_SOURCE_DIR}
|
| 3 | 3 |
${CMAKE_BINARY_DIR}
|
| 4 | 4 |
) |
| 5 | 5 |
|
| 6 | 6 |
IF(HAVE_GLPK) |
| 7 | 7 |
INCLUDE_DIRECTORIES(${GLPK_INCLUDE_DIR})
|
| 8 | 8 |
ENDIF(HAVE_GLPK) |
| 9 | 9 |
|
| 10 | 10 |
LINK_DIRECTORIES(${CMAKE_BINARY_DIR}/lemon)
|
| 11 | 11 |
|
| 12 | 12 |
SET(TESTS |
| 13 |
adaptors_test |
|
| 13 |
# adaptors_test |
|
| 14 | 14 |
bfs_test |
| 15 | 15 |
circulation_test |
| 16 | 16 |
counter_test |
| 17 | 17 |
dfs_test |
| 18 | 18 |
digraph_test |
| 19 | 19 |
dijkstra_test |
| 20 | 20 |
dim_test |
| 21 |
edge_set_test |
|
| 21 |
# edge_set_test |
|
| 22 | 22 |
error_test |
| 23 | 23 |
graph_copy_test |
| 24 | 24 |
graph_test |
| 25 | 25 |
graph_utils_test |
| 26 | 26 |
hao_orlin_test |
| 27 | 27 |
heap_test |
| 28 | 28 |
kruskal_test |
| 29 | 29 |
maps_test |
| 30 | 30 |
max_matching_test |
| 31 | 31 |
path_test |
| 32 | 32 |
preflow_test |
| 33 | 33 |
radix_sort_test |
| 34 | 34 |
random_test |
| 35 | 35 |
suurballe_test |
| 36 | 36 |
time_measure_test |
| 37 | 37 |
unionfind_test) |
| 38 | 38 |
|
| 39 | 39 |
IF(HAVE_LP) |
| 40 | 40 |
ADD_EXECUTABLE(lp_test lp_test.cc) |
| 41 | 41 |
IF(HAVE_GLPK) |
| 42 | 42 |
TARGET_LINK_LIBRARIES(lp_test lemon ${GLPK_LIBRARIES})
|
| 43 | 43 |
ENDIF(HAVE_GLPK) |
| 44 | 44 |
ADD_TEST(lp_test lp_test) |
| 45 | 45 |
|
| 46 | 46 |
IF(WIN32 AND HAVE_GLPK) |
| 47 | 47 |
GET_TARGET_PROPERTY(TARGET_LOC lp_test LOCATION) |
| 48 | 48 |
GET_FILENAME_COMPONENT(TARGET_PATH ${TARGET_LOC} PATH)
|
| 49 | 49 |
ADD_CUSTOM_COMMAND(TARGET lp_test POST_BUILD |
| 50 | 50 |
COMMAND cmake -E copy ${GLPK_BIN_DIR}/glpk.dll ${TARGET_PATH}
|
| 51 | 51 |
COMMAND cmake -E copy ${GLPK_BIN_DIR}/libltdl3.dll ${TARGET_PATH}
|
| 52 | 52 |
COMMAND cmake -E copy ${GLPK_BIN_DIR}/zlib1.dll ${TARGET_PATH}
|
| 53 | 53 |
) |
| 54 | 54 |
ENDIF(WIN32 AND HAVE_GLPK) |
| 55 | 55 |
ENDIF(HAVE_LP) |
| 56 | 56 |
|
| 57 | 57 |
IF(HAVE_MIP) |
| 58 | 58 |
ADD_EXECUTABLE(mip_test mip_test.cc) |
| 59 | 59 |
IF(HAVE_GLPK) |
| 60 | 60 |
TARGET_LINK_LIBRARIES(mip_test lemon ${GLPK_LIBRARIES})
|
| 61 | 61 |
ENDIF(HAVE_GLPK) |
| 62 | 62 |
ADD_TEST(mip_test mip_test) |
| 63 | 63 |
|
| 64 | 64 |
IF(WIN32 AND HAVE_GLPK) |
| 65 | 65 |
GET_TARGET_PROPERTY(TARGET_LOC mip_test LOCATION) |
| 66 | 66 |
GET_FILENAME_COMPONENT(TARGET_PATH ${TARGET_LOC} PATH)
|
| 67 | 67 |
ADD_CUSTOM_COMMAND(TARGET mip_test POST_BUILD |
| 68 | 68 |
COMMAND cmake -E copy ${GLPK_BIN_DIR}/glpk.dll ${TARGET_PATH}
|
| 69 | 69 |
COMMAND cmake -E copy ${GLPK_BIN_DIR}/libltdl3.dll ${TARGET_PATH}
|
| 70 | 70 |
COMMAND cmake -E copy ${GLPK_BIN_DIR}/zlib1.dll ${TARGET_PATH}
|
| 71 | 71 |
) |
| 72 | 72 |
ENDIF(WIN32 AND HAVE_GLPK) |
| 73 | 73 |
ENDIF(HAVE_MIP) |
| 74 | 74 |
|
| 75 | 75 |
FOREACH(TEST_NAME ${TESTS})
|
| 76 | 76 |
ADD_EXECUTABLE(${TEST_NAME} ${TEST_NAME}.cc)
|
| 77 | 77 |
TARGET_LINK_LIBRARIES(${TEST_NAME} lemon)
|
| 78 | 78 |
ADD_TEST(${TEST_NAME} ${TEST_NAME})
|
| 79 | 79 |
ENDFOREACH(TEST_NAME) |
| ... | ... |
@@ -77,222 +77,222 @@ |
| 77 | 77 |
checkConcept<ReadWriteMap<A,B>, NullMap<A,B> >(); |
| 78 | 78 |
NullMap<A,B> map1; |
| 79 | 79 |
NullMap<A,B> map2 = map1; |
| 80 | 80 |
map1 = nullMap<A,B>(); |
| 81 | 81 |
} |
| 82 | 82 |
|
| 83 | 83 |
// ConstMap |
| 84 | 84 |
{
|
| 85 | 85 |
checkConcept<ReadWriteMap<A,B>, ConstMap<A,B> >(); |
| 86 | 86 |
checkConcept<ReadWriteMap<A,C>, ConstMap<A,C> >(); |
| 87 | 87 |
ConstMap<A,B> map1; |
| 88 | 88 |
ConstMap<A,B> map2 = B(); |
| 89 | 89 |
ConstMap<A,B> map3 = map1; |
| 90 | 90 |
map1 = constMap<A>(B()); |
| 91 | 91 |
map1 = constMap<A,B>(); |
| 92 | 92 |
map1.setAll(B()); |
| 93 | 93 |
ConstMap<A,C> map4(C(1)); |
| 94 | 94 |
ConstMap<A,C> map5 = map4; |
| 95 | 95 |
map4 = constMap<A>(C(2)); |
| 96 | 96 |
map4.setAll(C(3)); |
| 97 | 97 |
|
| 98 | 98 |
checkConcept<ReadWriteMap<A,int>, ConstMap<A,int> >(); |
| 99 | 99 |
check(constMap<A>(10)[A()] == 10, "Something is wrong with ConstMap"); |
| 100 | 100 |
|
| 101 | 101 |
checkConcept<ReadWriteMap<A,int>, ConstMap<A,Const<int,10> > >(); |
| 102 | 102 |
ConstMap<A,Const<int,10> > map6; |
| 103 | 103 |
ConstMap<A,Const<int,10> > map7 = map6; |
| 104 | 104 |
map6 = constMap<A,int,10>(); |
| 105 | 105 |
map7 = constMap<A,Const<int,10> >(); |
| 106 | 106 |
check(map6[A()] == 10 && map7[A()] == 10, |
| 107 | 107 |
"Something is wrong with ConstMap"); |
| 108 | 108 |
} |
| 109 | 109 |
|
| 110 | 110 |
// IdentityMap |
| 111 | 111 |
{
|
| 112 | 112 |
checkConcept<ReadMap<A,A>, IdentityMap<A> >(); |
| 113 | 113 |
IdentityMap<A> map1; |
| 114 | 114 |
IdentityMap<A> map2 = map1; |
| 115 | 115 |
map1 = identityMap<A>(); |
| 116 | 116 |
|
| 117 | 117 |
checkConcept<ReadMap<double,double>, IdentityMap<double> >(); |
| 118 | 118 |
check(identityMap<double>()[1.0] == 1.0 && |
| 119 | 119 |
identityMap<double>()[3.14] == 3.14, |
| 120 | 120 |
"Something is wrong with IdentityMap"); |
| 121 | 121 |
} |
| 122 | 122 |
|
| 123 | 123 |
// RangeMap |
| 124 | 124 |
{
|
| 125 | 125 |
checkConcept<ReferenceMap<int,B,B&,const B&>, RangeMap<B> >(); |
| 126 | 126 |
RangeMap<B> map1; |
| 127 | 127 |
RangeMap<B> map2(10); |
| 128 | 128 |
RangeMap<B> map3(10,B()); |
| 129 | 129 |
RangeMap<B> map4 = map1; |
| 130 | 130 |
RangeMap<B> map5 = rangeMap<B>(); |
| 131 | 131 |
RangeMap<B> map6 = rangeMap<B>(10); |
| 132 | 132 |
RangeMap<B> map7 = rangeMap(10,B()); |
| 133 | 133 |
|
| 134 | 134 |
checkConcept< ReferenceMap<int, double, double&, const double&>, |
| 135 | 135 |
RangeMap<double> >(); |
| 136 | 136 |
std::vector<double> v(10, 0); |
| 137 | 137 |
v[5] = 100; |
| 138 | 138 |
RangeMap<double> map8(v); |
| 139 | 139 |
RangeMap<double> map9 = rangeMap(v); |
| 140 | 140 |
check(map9.size() == 10 && map9[2] == 0 && map9[5] == 100, |
| 141 | 141 |
"Something is wrong with RangeMap"); |
| 142 | 142 |
} |
| 143 | 143 |
|
| 144 | 144 |
// SparseMap |
| 145 | 145 |
{
|
| 146 | 146 |
checkConcept<ReferenceMap<A,B,B&,const B&>, SparseMap<A,B> >(); |
| 147 | 147 |
SparseMap<A,B> map1; |
| 148 | 148 |
SparseMap<A,B> map2 = B(); |
| 149 | 149 |
SparseMap<A,B> map3 = sparseMap<A,B>(); |
| 150 | 150 |
SparseMap<A,B> map4 = sparseMap<A>(B()); |
| 151 | 151 |
|
| 152 | 152 |
checkConcept< ReferenceMap<double, int, int&, const int&>, |
| 153 | 153 |
SparseMap<double, int> >(); |
| 154 | 154 |
std::map<double, int> m; |
| 155 | 155 |
SparseMap<double, int> map5(m); |
| 156 | 156 |
SparseMap<double, int> map6(m,10); |
| 157 | 157 |
SparseMap<double, int> map7 = sparseMap(m); |
| 158 | 158 |
SparseMap<double, int> map8 = sparseMap(m,10); |
| 159 | 159 |
|
| 160 | 160 |
check(map5[1.0] == 0 && map5[3.14] == 0 && |
| 161 | 161 |
map6[1.0] == 10 && map6[3.14] == 10, |
| 162 | 162 |
"Something is wrong with SparseMap"); |
| 163 | 163 |
map5[1.0] = map6[3.14] = 100; |
| 164 | 164 |
check(map5[1.0] == 100 && map5[3.14] == 0 && |
| 165 | 165 |
map6[1.0] == 10 && map6[3.14] == 100, |
| 166 | 166 |
"Something is wrong with SparseMap"); |
| 167 | 167 |
} |
| 168 | 168 |
|
| 169 | 169 |
// ComposeMap |
| 170 | 170 |
{
|
| 171 | 171 |
typedef ComposeMap<DoubleMap, ReadMap<B,A> > CompMap; |
| 172 | 172 |
checkConcept<ReadMap<B,double>, CompMap>(); |
| 173 |
CompMap map1(DoubleMap(),ReadMap<B,A>()); |
|
| 173 |
CompMap map1 = CompMap(DoubleMap(),ReadMap<B,A>()); |
|
| 174 | 174 |
CompMap map2 = composeMap(DoubleMap(), ReadMap<B,A>()); |
| 175 | 175 |
|
| 176 | 176 |
SparseMap<double, bool> m1(false); m1[3.14] = true; |
| 177 | 177 |
RangeMap<double> m2(2); m2[0] = 3.0; m2[1] = 3.14; |
| 178 | 178 |
check(!composeMap(m1,m2)[0] && composeMap(m1,m2)[1], |
| 179 | 179 |
"Something is wrong with ComposeMap") |
| 180 | 180 |
} |
| 181 | 181 |
|
| 182 | 182 |
// CombineMap |
| 183 | 183 |
{
|
| 184 | 184 |
typedef CombineMap<DoubleMap, DoubleMap, std::plus<double> > CombMap; |
| 185 | 185 |
checkConcept<ReadMap<A,double>, CombMap>(); |
| 186 |
CombMap map1(DoubleMap(), DoubleMap()); |
|
| 186 |
CombMap map1 = CombMap(DoubleMap(), DoubleMap()); |
|
| 187 | 187 |
CombMap map2 = combineMap(DoubleMap(), DoubleMap(), std::plus<double>()); |
| 188 | 188 |
|
| 189 | 189 |
check(combineMap(constMap<B,int,2>(), identityMap<B>(), &binc)[B()] == 3, |
| 190 | 190 |
"Something is wrong with CombineMap"); |
| 191 | 191 |
} |
| 192 | 192 |
|
| 193 | 193 |
// FunctorToMap, MapToFunctor |
| 194 | 194 |
{
|
| 195 | 195 |
checkConcept<ReadMap<A,B>, FunctorToMap<F,A,B> >(); |
| 196 | 196 |
checkConcept<ReadMap<A,B>, FunctorToMap<F> >(); |
| 197 | 197 |
FunctorToMap<F> map1; |
| 198 |
FunctorToMap<F> map2(F()); |
|
| 198 |
FunctorToMap<F> map2 = FunctorToMap<F>(F()); |
|
| 199 | 199 |
B b = functorToMap(F())[A()]; |
| 200 | 200 |
|
| 201 | 201 |
checkConcept<ReadMap<A,B>, MapToFunctor<ReadMap<A,B> > >(); |
| 202 |
MapToFunctor<ReadMap<A,B> > map(ReadMap<A,B>()); |
|
| 202 |
MapToFunctor<ReadMap<A,B> > map = MapToFunctor<ReadMap<A,B> >(ReadMap<A,B>()); |
|
| 203 | 203 |
|
| 204 | 204 |
check(functorToMap(&func)[A()] == 3, |
| 205 | 205 |
"Something is wrong with FunctorToMap"); |
| 206 | 206 |
check(mapToFunctor(constMap<A,int>(2))(A()) == 2, |
| 207 | 207 |
"Something is wrong with MapToFunctor"); |
| 208 | 208 |
check(mapToFunctor(functorToMap(&func))(A()) == 3 && |
| 209 | 209 |
mapToFunctor(functorToMap(&func))[A()] == 3, |
| 210 | 210 |
"Something is wrong with FunctorToMap or MapToFunctor"); |
| 211 | 211 |
check(functorToMap(mapToFunctor(constMap<A,int>(2)))[A()] == 2, |
| 212 | 212 |
"Something is wrong with FunctorToMap or MapToFunctor"); |
| 213 | 213 |
} |
| 214 | 214 |
|
| 215 | 215 |
// ConvertMap |
| 216 | 216 |
{
|
| 217 | 217 |
checkConcept<ReadMap<double,double>, |
| 218 | 218 |
ConvertMap<ReadMap<double, int>, double> >(); |
| 219 | 219 |
ConvertMap<RangeMap<bool>, int> map1(rangeMap(1, true)); |
| 220 | 220 |
ConvertMap<RangeMap<bool>, int> map2 = convertMap<int>(rangeMap(2, false)); |
| 221 | 221 |
} |
| 222 | 222 |
|
| 223 | 223 |
// ForkMap |
| 224 | 224 |
{
|
| 225 | 225 |
checkConcept<DoubleWriteMap, ForkMap<DoubleWriteMap, DoubleWriteMap> >(); |
| 226 | 226 |
|
| 227 | 227 |
typedef RangeMap<double> RM; |
| 228 | 228 |
typedef SparseMap<int, double> SM; |
| 229 | 229 |
RM m1(10, -1); |
| 230 | 230 |
SM m2(-1); |
| 231 | 231 |
checkConcept<ReadWriteMap<int, double>, ForkMap<RM, SM> >(); |
| 232 | 232 |
checkConcept<ReadWriteMap<int, double>, ForkMap<SM, RM> >(); |
| 233 | 233 |
ForkMap<RM, SM> map1(m1,m2); |
| 234 | 234 |
ForkMap<SM, RM> map2 = forkMap(m2,m1); |
| 235 | 235 |
map2.set(5, 10); |
| 236 | 236 |
check(m1[1] == -1 && m1[5] == 10 && m2[1] == -1 && |
| 237 | 237 |
m2[5] == 10 && map2[1] == -1 && map2[5] == 10, |
| 238 | 238 |
"Something is wrong with ForkMap"); |
| 239 | 239 |
} |
| 240 | 240 |
|
| 241 | 241 |
// Arithmetic maps: |
| 242 | 242 |
// - AddMap, SubMap, MulMap, DivMap |
| 243 | 243 |
// - ShiftMap, ShiftWriteMap, ScaleMap, ScaleWriteMap |
| 244 | 244 |
// - NegMap, NegWriteMap, AbsMap |
| 245 | 245 |
{
|
| 246 | 246 |
checkConcept<DoubleMap, AddMap<DoubleMap,DoubleMap> >(); |
| 247 | 247 |
checkConcept<DoubleMap, SubMap<DoubleMap,DoubleMap> >(); |
| 248 | 248 |
checkConcept<DoubleMap, MulMap<DoubleMap,DoubleMap> >(); |
| 249 | 249 |
checkConcept<DoubleMap, DivMap<DoubleMap,DoubleMap> >(); |
| 250 | 250 |
|
| 251 | 251 |
ConstMap<int, double> c1(1.0), c2(3.14); |
| 252 | 252 |
IdentityMap<int> im; |
| 253 | 253 |
ConvertMap<IdentityMap<int>, double> id(im); |
| 254 | 254 |
check(addMap(c1,id)[0] == 1.0 && addMap(c1,id)[10] == 11.0, |
| 255 | 255 |
"Something is wrong with AddMap"); |
| 256 | 256 |
check(subMap(id,c1)[0] == -1.0 && subMap(id,c1)[10] == 9.0, |
| 257 | 257 |
"Something is wrong with SubMap"); |
| 258 | 258 |
check(mulMap(id,c2)[0] == 0 && mulMap(id,c2)[2] == 6.28, |
| 259 | 259 |
"Something is wrong with MulMap"); |
| 260 | 260 |
check(divMap(c2,id)[1] == 3.14 && divMap(c2,id)[2] == 1.57, |
| 261 | 261 |
"Something is wrong with DivMap"); |
| 262 | 262 |
|
| 263 | 263 |
checkConcept<DoubleMap, ShiftMap<DoubleMap> >(); |
| 264 | 264 |
checkConcept<DoubleWriteMap, ShiftWriteMap<DoubleWriteMap> >(); |
| 265 | 265 |
checkConcept<DoubleMap, ScaleMap<DoubleMap> >(); |
| 266 | 266 |
checkConcept<DoubleWriteMap, ScaleWriteMap<DoubleWriteMap> >(); |
| 267 | 267 |
checkConcept<DoubleMap, NegMap<DoubleMap> >(); |
| 268 | 268 |
checkConcept<DoubleWriteMap, NegWriteMap<DoubleWriteMap> >(); |
| 269 | 269 |
checkConcept<DoubleMap, AbsMap<DoubleMap> >(); |
| 270 | 270 |
|
| 271 | 271 |
check(shiftMap(id, 2.0)[1] == 3.0 && shiftMap(id, 2.0)[10] == 12.0, |
| 272 | 272 |
"Something is wrong with ShiftMap"); |
| 273 | 273 |
check(shiftWriteMap(id, 2.0)[1] == 3.0 && |
| 274 | 274 |
shiftWriteMap(id, 2.0)[10] == 12.0, |
| 275 | 275 |
"Something is wrong with ShiftWriteMap"); |
| 276 | 276 |
check(scaleMap(id, 2.0)[1] == 2.0 && scaleMap(id, 2.0)[10] == 20.0, |
| 277 | 277 |
"Something is wrong with ScaleMap"); |
| 278 | 278 |
check(scaleWriteMap(id, 2.0)[1] == 2.0 && |
| 279 | 279 |
scaleWriteMap(id, 2.0)[10] == 20.0, |
| 280 | 280 |
"Something is wrong with ScaleWriteMap"); |
| 281 | 281 |
check(negMap(id)[1] == -1.0 && negMap(id)[-10] == 10.0, |
| 282 | 282 |
"Something is wrong with NegMap"); |
| 283 | 283 |
check(negWriteMap(id)[1] == -1.0 && negWriteMap(id)[-10] == 10.0, |
| 284 | 284 |
"Something is wrong with NegWriteMap"); |
| 285 | 285 |
check(absMap(id)[1] == 1.0 && absMap(id)[-10] == 10.0, |
| 286 | 286 |
"Something is wrong with AbsMap"); |
| 287 | 287 |
} |
| 288 | 288 |
|
| 289 | 289 |
// Logical maps: |
| 290 | 290 |
// - TrueMap, FalseMap |
| 291 | 291 |
// - AndMap, OrMap |
| 292 | 292 |
// - NotMap, NotWriteMap |
| 293 | 293 |
// - EqualMap, LessMap |
| 294 | 294 |
{
|
| 295 | 295 |
checkConcept<BoolMap, TrueMap<A> >(); |
| 296 | 296 |
checkConcept<BoolMap, FalseMap<A> >(); |
| 297 | 297 |
checkConcept<BoolMap, AndMap<BoolMap,BoolMap> >(); |
| 298 | 298 |
checkConcept<BoolMap, OrMap<BoolMap,BoolMap> >(); |
0 comments (0 inline)