Browse Source
Added temporary Find* files for CMake
Added temporary Find* files for CMake
Added custom exceptions Added Sparse Matrix Added Guidelines for Doxygen Added BUILD hintstempestpy_adaptions
PBerger
13 years ago
12 changed files with 1049 additions and 13 deletions
-
64CMakeLists.txt
-
445FindPantheios.cmake
-
56FindSTLSoft.cmake
-
16resources/BUILD.txt
-
56resources/GUIDELINES-Doxygen.example.h
-
23src/exceptions/invalid_argument.h
-
25src/exceptions/invalid_state.h
-
23src/exceptions/out_of_range.h
-
39src/mrmc-cpp.cpp
-
195src/sparse/static_sparse_matrix.h
-
13test/mrmc-tests.cpp
-
103test/sparse/static_sparse_matrix.cpp
@ -0,0 +1,445 @@ |
|||||
|
# Locate the Pantheois Logging Framework. |
||||
|
# |
||||
|
# Defines the following variables: |
||||
|
# |
||||
|
# PANTHEIOS_FOUND - Found the Pantheios Logging Framework |
||||
|
# PANTHEIOS_INCLUDE_DIRS - Include directories |
||||
|
# |
||||
|
# Accepts the following variables as input: |
||||
|
# |
||||
|
# PANTHEIOS_ROOT - (as a CMake or environment variable) |
||||
|
# The root directory of the pantheios install prefix |
||||
|
# |
||||
|
# PANTHEIOS_USE_DYNAMIC_RUNTIME |
||||
|
# |
||||
|
# If you want to use splitting, specify LRSplit and than preface the components with L and R, so e.g. LRSplit LFile RSyslog |
||||
|
# To use more than one BackEnd, specify NBackEnd followed by a list of components. NBackEnd requires the NFrontEnd. |
||||
|
# |
||||
|
# Possible Components for BackEnd: |
||||
|
# ACELogger |
||||
|
# COMErrorObject |
||||
|
# File |
||||
|
# FileCallback |
||||
|
# FPrintf |
||||
|
# FPrintfCallback |
||||
|
# Null |
||||
|
# Speech |
||||
|
# Syslog |
||||
|
# WindowsConsole |
||||
|
# WindowsConsoleCallback |
||||
|
# WindowsDebugger |
||||
|
# WindowsDebuggerCallback |
||||
|
# WindowsEventLog |
||||
|
# WindowsMessageBox |
||||
|
# WindowsSyslog |
||||
|
# WindowsSyslogCallback |
||||
|
# |
||||
|
# Possible components for FrontEnd: |
||||
|
# NoFrontEnd |
||||
|
# SimpleFrontEnd |
||||
|
# NFrontEnd |
||||
|
# |
||||
|
# |
||||
|
|
||||
|
#============================================================================= |
||||
|
# Copyright 2012 Philipp Berger <admin@philippberger.de> |
||||
|
# |
||||
|
# Distributed under the OSI-approved BSD License (the "License"); |
||||
|
# see accompanying file Copyright.txt for details. |
||||
|
# |
||||
|
# This software is distributed WITHOUT ANY WARRANTY; without even the |
||||
|
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||||
|
# See the License for more information. |
||||
|
#============================================================================= |
||||
|
# (To distribute this file outside of CMake, substitute the full |
||||
|
# License text for the above reference.) |
||||
|
# |
||||
|
# Credits: |
||||
|
# |
||||
|
# HUGE thanks to Michael Wild |
||||
|
# Additional thanks to: |
||||
|
# Mateusz Loskot |
||||
|
# Rolf Eike Beer |
||||
|
|
||||
|
|
||||
|
|
||||
|
# default for WideString option |
||||
|
set(PANTHEIOS_WIDESTRING 0) |
||||
|
# default for Front- and BackEnd |
||||
|
set(PANTHEIOS_FRONTEND "simple") |
||||
|
set(PANTHEIOS_BACKEND "file") |
||||
|
set(PANTHEIOS_BACKEND_L OFF) |
||||
|
set(PANTHEIOS_BACKEND_R OFF) |
||||
|
set(PANTHEIOS_BACKEND_LIST) |
||||
|
|
||||
|
# Use FIND_PACKAGE( Pantheios COMPONENTS ... ) to enable modules |
||||
|
if( Pantheios_FIND_COMPONENTS ) |
||||
|
list(FIND Pantheios_FIND_COMPONENTS "LRSplit" PANTHEIOS_use_lrsplit) |
||||
|
list(FIND Pantheios_FIND_COMPONENTS "NFrontEnd" PANTHEIOS_use_nfe) |
||||
|
list(FIND Pantheios_FIND_COMPONENTS "NBackEnd" PANTHEIOS_use_nbe) |
||||
|
list(FIND Pantheios_FIND_COMPONENTS "WideString" PANTHEIOS_use_ws) |
||||
|
|
||||
|
list(REMOVE_ITEM Pantheios_FIND_COMPONENTS "LRSplit" "NFrontEnd" "NBackEnd" "WideString") |
||||
|
|
||||
|
if (NOT PANTHEIOS_use_ws EQUAL -1) |
||||
|
# Use WideString |
||||
|
set(PANTHEIOS_WIDESTRING 1) |
||||
|
endif() |
||||
|
|
||||
|
if (NOT PANTHEIOS_use_lrsplit EQUAL -1) |
||||
|
# Found LRSplit |
||||
|
set(PANTHEIOS_BACKEND "lrsplit") |
||||
|
if (NOT PANTHEIOS_use_nbe EQUAL -1) |
||||
|
# Also found NBe |
||||
|
message(FATAL_ERROR "Pantheios: Use either LRSplit or NBackEnd, not both.") |
||||
|
endif() |
||||
|
if (NOT PANTHEIOS_use_nfe EQUAL -1) |
||||
|
# Also found NFe |
||||
|
message(FATAL_ERROR "Pantheios: Use either LRSplit or NFrontEnd, not both.") |
||||
|
endif() |
||||
|
|
||||
|
foreach( component ${Pantheios_FIND_COMPONENTS} ) |
||||
|
# LRSplit L BackEnds |
||||
|
string(SUBSTRING ${component} 0 1 _sub_comp_head) |
||||
|
string(LENGTH ${component} _length_comp) |
||||
|
math(EXPR _length_comp_tail "${_length_comp} - 1") |
||||
|
string(SUBSTRING ${component} 1 ${_length_comp_tail} _sub_comp_tail) |
||||
|
|
||||
|
if ((_sub_comp_tail STREQUAL "ACELogger") OR (_sub_comp_tail STREQUAL "COMErrorObject") OR (_sub_comp_tail STREQUAL "File") OR (_sub_comp_tail STREQUAL "FileCallback") OR (_sub_comp_tail STREQUAL "FPrintf") OR (_sub_comp_tail STREQUAL "FPrintfCallback") OR (_sub_comp_tail STREQUAL "Null") OR (_sub_comp_tail STREQUAL "Speech") OR (_sub_comp_tail STREQUAL "Syslog") OR (_sub_comp_tail STREQUAL "WindowsConsole") OR (_sub_comp_tail STREQUAL "WindowsConsoleCallback") OR (_sub_comp_tail STREQUAL "WindowsDebugger") OR (_sub_comp_tail STREQUAL "WindowsDebuggerCallback") OR (_sub_comp_tail STREQUAL "WindowsEventLog") OR (_sub_comp_tail STREQUAL "WindowsMessageBox") OR (_sub_comp_tail STREQUAL "WindowsSyslog") OR (_sub_comp_tail STREQUAL "WindowsSyslogCallback")) |
||||
|
if ((_sub_comp_head STREQUAL L) OR (_sub_comp_head STREQUAL R)) |
||||
|
message(STATUS "Pantheios: Setting LRSplit BackEnd ${_sub_comp_head} to ${_sub_comp_tail}") |
||||
|
string(TOLOWER ${_sub_comp_tail} _sub_comp_tail_low) |
||||
|
set(PANTHEIOS_BACKEND_${_sub_comp_head} "${_sub_comp_tail_low}") |
||||
|
else () |
||||
|
message(FATAL_ERROR "Pantheios: Internal Parsing Error") |
||||
|
endif() |
||||
|
|
||||
|
# FrontEnds |
||||
|
elseif (component STREQUAL "NoFrontEnd") |
||||
|
message(STATUS "Pantheios: Setting FrontEnd to NoFrontEnd") |
||||
|
set(PANTHEIOS_FRONTEND "null") |
||||
|
elseif (component STREQUAL "SimpleFrontEnd") |
||||
|
message(STATUS "Pantheios: Setting FrontEnd to SimpleFrontEnd") |
||||
|
set(PANTHEIOS_FRONTEND "simple") |
||||
|
|
||||
|
else () |
||||
|
message(FATAL_ERROR "Unknown Component: ${component}") |
||||
|
endif () |
||||
|
endforeach(component) |
||||
|
elseif (NOT PANTHEIOS_use_nbe EQUAL -1) |
||||
|
# Found NBackEnd |
||||
|
if (PANTHEIOS_use_nfe EQUAL -1) |
||||
|
message(FATAL_ERROR "Pantheios: Usage of NBackEnd requires the NFrontEnd.") |
||||
|
endif() |
||||
|
set(PANTHEIOS_BACKEND "N") |
||||
|
set(PANTHEIOS_FRONTEND "N") |
||||
|
|
||||
|
foreach( component ${Pantheios_FIND_COMPONENTS} ) |
||||
|
# Std BackEnds |
||||
|
if ((component STREQUAL "ACELogger") OR (component STREQUAL "COMErrorObject") OR (component STREQUAL "File") OR (component STREQUAL "FileCallback") OR (component STREQUAL "FPrintf") OR (component STREQUAL "FPrintfCallback") OR (component STREQUAL "Null") OR (component STREQUAL "Speech") OR (component STREQUAL "Syslog") OR (component STREQUAL "WindowsConsole") OR (component STREQUAL "WindowsConsoleCallback") OR (component STREQUAL "WindowsDebugger") OR (component STREQUAL "WindowsDebuggerCallback") OR (component STREQUAL "WindowsEventLog") OR (component STREQUAL "WindowsMessageBox") OR (component STREQUAL "WindowsSyslog") OR (component STREQUAL "WindowsSyslogCallback")) |
||||
|
message(STATUS "Pantheios: Adding BackEnd ${component}") |
||||
|
string(TOLOWER ${component} _low_comp) |
||||
|
list(APPEND PANTHEIOS_BACKEND_LIST ${_low_comp}) |
||||
|
else () |
||||
|
message(FATAL_ERROR "Unknown Component: ${component}") |
||||
|
endif () |
||||
|
endforeach(component) |
||||
|
else () |
||||
|
# Simple, one FE, one BE |
||||
|
foreach( component ${Pantheios_FIND_COMPONENTS} ) |
||||
|
if ((component STREQUAL "ACELogger") OR (component STREQUAL "COMErrorObject") OR (component STREQUAL "File") OR (component STREQUAL "FileCallback") OR (component STREQUAL "FPrintf") OR (component STREQUAL "FPrintfCallback") OR (component STREQUAL "Null") OR (component STREQUAL "Speech") OR (component STREQUAL "Syslog") OR (component STREQUAL "WindowsConsole") OR (component STREQUAL "WindowsConsoleCallback") OR (component STREQUAL "WindowsDebugger") OR (component STREQUAL "WindowsDebuggerCallback") OR (component STREQUAL "WindowsEventLog") OR (component STREQUAL "WindowsMessageBox") OR (component STREQUAL "WindowsSyslog") OR (component STREQUAL "WindowsSyslogCallback")) |
||||
|
message(STATUS "Pantheios: Setting BackEnd to ${component}") |
||||
|
string(TOLOWER ${component} _low_comp) |
||||
|
set(PANTHEIOS_BACKEND ${_low_comp}) |
||||
|
|
||||
|
# FrontEnds |
||||
|
elseif (component STREQUAL "NoFrontEnd") |
||||
|
message(STATUS "Pantheios: Setting FrontEnd to NoFrontEnd") |
||||
|
set(PANTHEIOS_FRONTEND "null") |
||||
|
elseif (component STREQUAL "SimpleFrontEnd") |
||||
|
message(STATUS "Pantheios: Setting FrontEnd to SimpleFrontEnd") |
||||
|
set(PANTHEIOS_FRONTEND "simple") |
||||
|
else () |
||||
|
message(FATAL_ERROR "Unknown Component: ${component}") |
||||
|
endif () |
||||
|
endforeach(component) |
||||
|
endif () |
||||
|
endif(Pantheios_FIND_COMPONENTS) |
||||
|
|
||||
|
if (PANTHEIOS_USE_DYNAMIC_RUNTIME) |
||||
|
set(PANTHEIOS_LIB_LINKTYPE "dll") |
||||
|
else () |
||||
|
set(PANTHEIOS_LIB_LINKTYPE "mt") |
||||
|
endif () |
||||
|
|
||||
|
if(PANTHEIOS_INCLUDE_DIR) |
||||
|
if (NOT PANTHEIOS_ROOT) |
||||
|
get_filename_component(PANTHEIOS_ROOT "${PANTHEIOS_INCLUDE_DIR}" PATH) |
||||
|
endif() |
||||
|
|
||||
|
get_filename_component(PANTHEIOS_ROOT_HINT "${PANTHEIOS_INCLUDE_DIR}" PATH) |
||||
|
endif() |
||||
|
|
||||
|
find_path(PANTHEIOS_INCLUDE_DIR pantheios/pantheios.h |
||||
|
PATH_SUFFIXES include |
||||
|
HINTS ${PANTHEIOS_ROOT} ${PANTHEIOS_ROOT_HINT} |
||||
|
ENV PANTHEIOS_ROOT |
||||
|
) |
||||
|
|
||||
|
# No idea what the stuff for ICC et. al. is, so I don't handle it here... |
||||
|
set(_P_COMP_TAG) |
||||
|
set(_P_OS_TAG) |
||||
|
set(_P_ARCH_TAG) |
||||
|
if(MSVC) |
||||
|
if(MSVC60) |
||||
|
set(_P_COMP_TAG vc6) |
||||
|
elseif(MSVC70) |
||||
|
set(_P_COMP_TAG vc7) |
||||
|
elseif(MSVC71) |
||||
|
set(_P_COMP_TAG vc71) |
||||
|
elseif(MSVC80) |
||||
|
set(_P_COMP_TAG vc8) |
||||
|
if(CMAKE_SIZEOF_VOID_P EQUAL 8) |
||||
|
set(_P_ARCH_TAG .x64) |
||||
|
endif() |
||||
|
elseif(MSVC90) |
||||
|
set(_P_COMP_TAG vc9) |
||||
|
if(CMAKE_SIZEOF_VOID_P EQUAL 8) |
||||
|
set(_P_ARCH_TAG .x64) |
||||
|
endif() |
||||
|
elseif(MSVC10) |
||||
|
set(_P_COMP_TAG vc10) |
||||
|
if(CMAKE_SIZEOF_VOID_P EQUAL 8) |
||||
|
set(_P_ARCH_TAG .x64) |
||||
|
endif() |
||||
|
endif() |
||||
|
elseif(CMAKE_COMPILER_IS_GNUCC) |
||||
|
execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION) |
||||
|
string(REGEX MATCHALL "[0-9]+" GCC_VERSION_COMPONENTS ${GCC_VERSION}) |
||||
|
list(GET GCC_VERSION_COMPONENTS 0 GCC_MAJOR) |
||||
|
list(GET GCC_VERSION_COMPONENTS 1 GCC_MINOR) |
||||
|
set(_P_COMP_TAG gcc${GCC_MAJOR}${GCC_MINOR}) |
||||
|
if(CMAKE_SIZEOF_VOID_P EQUAL 8) |
||||
|
set(_P_ARCH_TAG .file64bit) |
||||
|
endif() |
||||
|
else() |
||||
|
message(FATAL_ERROR "Pantheios: Your compiler/environment is currently unsupported.") |
||||
|
endif() |
||||
|
|
||||
|
set(_P_LIB_TAG ${_P_COMP_TAG}${_P_OS_TAG}${_P_ARCH_TAG}) |
||||
|
|
||||
|
# Is this the right way? |
||||
|
set(PANTHEIOS_INCLUDE_DIRS ${PANTHEIOS_INCLUDE_DIR}) |
||||
|
|
||||
|
set(_P_REQUIRED_LIBVARS) |
||||
|
set(PANTHEIOS_LIBRARIES) |
||||
|
set(PANTHEIOS_LIBRARIES_DEBUG) |
||||
|
set(PANTHEIOS_LIBRARIES_RELEASE) |
||||
|
|
||||
|
# core and util libraries |
||||
|
foreach(l core util) |
||||
|
find_library(PANTHEIOS_${l}_${PANTHEIOS_LIB_LINKTYPE}_DEBUG_LIBRARY |
||||
|
pantheios.1.${l}.${_P_LIB_TAG}.${PANTHEIOS_LIB_LINKTYPE}.debug |
||||
|
PATH_SUFFIXES lib |
||||
|
HINTS ${PANTHEIOS_ROOT_HINT} ${PANTHEIOS_ROOT} |
||||
|
ENV PANTHEIOS_ROOT |
||||
|
) |
||||
|
|
||||
|
find_library(PANTHEIOS_${l}_${PANTHEIOS_LIB_LINKTYPE}_LIBRARY |
||||
|
pantheios.1.${l}.${_P_LIB_TAG}.${PANTHEIOS_LIB_LINKTYPE} |
||||
|
PATH_SUFFIXES lib |
||||
|
HINTS ${PANTHEIOS_ROOT_HINT} ${PANTHEIOS_ROOT} |
||||
|
ENV PANTHEIOS_ROOT |
||||
|
) |
||||
|
|
||||
|
list(APPEND _P_REQUIRED_LIBVARS |
||||
|
PANTHEIOS_${l}_${PANTHEIOS_LIB_LINKTYPE}_DEBUG_LIBRARY |
||||
|
PANTHEIOS_${l}_${PANTHEIOS_LIB_LINKTYPE}_LIBRARY |
||||
|
) |
||||
|
list(APPEND PANTHEIOS_LIBRARIES |
||||
|
debug ${PANTHEIOS_${l}_${PANTHEIOS_LIB_LINKTYPE}_DEBUG_LIBRARY} |
||||
|
optimized ${PANTHEIOS_${l}_${PANTHEIOS_LIB_LINKTYPE}_LIBRARY} |
||||
|
) |
||||
|
endforeach() |
||||
|
|
||||
|
# set PANTHEIOS_LIBRARY_DIRS |
||||
|
get_filename_component(PANTHEIOS_LIBRARY_DIRS ${PANTHEIOS_core_${PANTHEIOS_LIB_LINKTYPE}_LIBRARY} PATH) |
||||
|
|
||||
|
|
||||
|
|
||||
|
# backend libraries (split, sole, local, remote and common) |
||||
|
set(_P_LT ${PANTHEIOS_LIB_LINKTYPE}) |
||||
|
set(_P_BE ${PANTHEIOS_BACKEND}) |
||||
|
|
||||
|
find_library(PANTHEIOS_be_${_P_BE}_${_P_LT}_DEBUG_LIBRARY |
||||
|
pantheios.1.be.${_P_BE}.${_P_LIB_TAG}.${_P_LT}.debug |
||||
|
PATH_SUFFIXES lib |
||||
|
HINTS ${PANTHEIOS_ROOT_HINT} ${PANTHEIOS_ROOT} |
||||
|
ENV PANTHEIOS_ROOT |
||||
|
) |
||||
|
|
||||
|
find_library(PANTHEIOS_be_${_P_BE}_${_P_LT}_LIBRARY |
||||
|
pantheios.1.be.${_P_BE}.${_P_LIB_TAG}.${_P_LT} |
||||
|
PATH_SUFFIXES lib |
||||
|
HINTS ${PANTHEIOS_ROOT_HINT} ${PANTHEIOS_ROOT} |
||||
|
ENV PANTHEIOS_ROOT |
||||
|
) |
||||
|
|
||||
|
list(APPEND _P_REQUIRED_LIBVARS |
||||
|
PANTHEIOS_be_${_P_BE}_${_P_LT}_DEBUG_LIBRARY |
||||
|
PANTHEIOS_be_${_P_BE}_${_P_LT}_LIBRARY |
||||
|
) |
||||
|
list(APPEND PANTHEIOS_LIBRARIES |
||||
|
debug ${PANTHEIOS_be_${_P_BE}_${_P_LT}_DEBUG_LIBRARY} |
||||
|
optimized ${PANTHEIOS_be_${_P_BE}_${_P_LT}_LIBRARY} |
||||
|
) |
||||
|
|
||||
|
if (_P_BE STREQUAL N) |
||||
|
# N Backend, go through list |
||||
|
message(STATUS "Pantheios: Dbg: Lib-n") |
||||
|
|
||||
|
foreach (blib PANTHEIOS_BACKEND_LIST) |
||||
|
find_library(PANTHEIOS_bec_${blib}_${_P_LT}_DEBUG_LIBRARY |
||||
|
pantheios.1.bec.${blib}.${_P_LIB_TAG}.${_P_LT}.debug |
||||
|
PATH_SUFFIXES lib |
||||
|
HINTS ${PANTHEIOS_ROOT_HINT} ${PANTHEIOS_ROOT} |
||||
|
ENV PANTHEIOS_ROOT |
||||
|
) |
||||
|
|
||||
|
find_library(PANTHEIOS_bec_${blib}_${_P_LT}_LIBRARY |
||||
|
pantheios.1.bec.${blib}.${_P_LIB_TAG}.${_P_LT} |
||||
|
PATH_SUFFIXES lib |
||||
|
HINTS ${PANTHEIOS_ROOT_HINT} ${PANTHEIOS_ROOT} |
||||
|
ENV PANTHEIOS_ROOT |
||||
|
) |
||||
|
|
||||
|
list(APPEND _P_REQUIRED_LIBVARS |
||||
|
PANTHEIOS_bec_${blib}_${_P_LT}_DEBUG_LIBRARY |
||||
|
PANTHEIOS_bec_${blib}_${_P_LT}_LIBRARY |
||||
|
) |
||||
|
list(APPEND PANTHEIOS_LIBRARIES |
||||
|
debug ${PANTHEIOS_bec_${blib}_${_P_LT}_DEBUG_LIBRARY} |
||||
|
optimized ${PANTHEIOS_bec_${blib}_${_P_LT}_LIBRARY} |
||||
|
) |
||||
|
endforeach() |
||||
|
elseif (_P_BE STREQUAL lrsplit) |
||||
|
# LRSplit |
||||
|
message(STATUS "Pantheios: Dbg: Lib-lrsplit") |
||||
|
|
||||
|
# Left side |
||||
|
foreach (t bec bel) |
||||
|
find_library(PANTHEIOS_${t}_${PANTHEIOS_BACKEND_L}_${_P_LT}_DEBUG_LIBRARY |
||||
|
pantheios.1.${t}.${PANTHEIOS_BACKEND_L}.${_P_LIB_TAG}.${_P_LT}.debug |
||||
|
PATH_SUFFIXES lib |
||||
|
HINTS ${PANTHEIOS_ROOT_HINT} ${PANTHEIOS_ROOT} |
||||
|
ENV PANTHEIOS_ROOT |
||||
|
) |
||||
|
|
||||
|
find_library(PANTHEIOS_${t}_${PANTHEIOS_BACKEND_L}_${_P_LT}_LIBRARY |
||||
|
pantheios.1.${t}.${PANTHEIOS_BACKEND_L}.${_P_LIB_TAG}.${_P_LT} |
||||
|
PATH_SUFFIXES lib |
||||
|
HINTS ${PANTHEIOS_ROOT_HINT} ${PANTHEIOS_ROOT} |
||||
|
ENV PANTHEIOS_ROOT |
||||
|
) |
||||
|
list(APPEND _P_REQUIRED_LIBVARS |
||||
|
PANTHEIOS_${t}_${PANTHEIOS_BACKEND_L}_${_P_LT}_DEBUG_LIBRARY |
||||
|
PANTHEIOS_${t}_${PANTHEIOS_BACKEND_L}_${_P_LT}_LIBRARY |
||||
|
) |
||||
|
list(APPEND PANTHEIOS_LIBRARIES |
||||
|
debug ${PANTHEIOS_${t}_${PANTHEIOS_BACKEND_L}_${_P_LT}_DEBUG_LIBRARY} |
||||
|
optimized ${PANTHEIOS_${t}_${PANTHEIOS_BACKEND_L}_${_P_LT}_LIBRARY} |
||||
|
) |
||||
|
endforeach() |
||||
|
# Right side |
||||
|
foreach (t bec ber) |
||||
|
find_library(PANTHEIOS_${t}_${PANTHEIOS_BACKEND_R}_${_P_LT}_DEBUG_LIBRARY |
||||
|
pantheios.1.${t}.${PANTHEIOS_BACKEND_R}.${_P_LIB_TAG}.${_P_LT}.debug |
||||
|
PATH_SUFFIXES lib |
||||
|
HINTS ${PANTHEIOS_ROOT_HINT} ${PANTHEIOS_ROOT} |
||||
|
ENV PANTHEIOS_ROOT |
||||
|
) |
||||
|
|
||||
|
find_library(PANTHEIOS_${t}_${PANTHEIOS_BACKEND_R}_${_P_LT}_LIBRARY |
||||
|
pantheios.1.${t}.${PANTHEIOS_BACKEND_R}.${_P_LIB_TAG}.${_P_LT} |
||||
|
PATH_SUFFIXES lib |
||||
|
HINTS ${PANTHEIOS_ROOT_HINT} ${PANTHEIOS_ROOT} |
||||
|
ENV PANTHEIOS_ROOT |
||||
|
) |
||||
|
list(APPEND _P_REQUIRED_LIBVARS |
||||
|
PANTHEIOS_${t}_${PANTHEIOS_BACKEND_R}_${_P_LT}_DEBUG_LIBRARY |
||||
|
PANTHEIOS_${t}_${PANTHEIOS_BACKEND_R}_${_P_LT}_LIBRARY |
||||
|
) |
||||
|
list(APPEND PANTHEIOS_LIBRARIES |
||||
|
debug ${PANTHEIOS_${t}_${PANTHEIOS_BACKEND_R}_${_P_LT}_DEBUG_LIBRARY} |
||||
|
optimized ${PANTHEIOS_${t}_${PANTHEIOS_BACKEND_R}_${_P_LT}_LIBRARY} |
||||
|
) |
||||
|
endforeach() |
||||
|
else () |
||||
|
# normal |
||||
|
message(STATUS "Pantheios: Dbg: Lib-normal") |
||||
|
foreach (t bec) |
||||
|
find_library(PANTHEIOS_${t}_${PANTHEIOS_BACKEND}_${_P_LT}_DEBUG_LIBRARY |
||||
|
pantheios.1.${t}.${PANTHEIOS_BACKEND}.${_P_LIB_TAG}.${_P_LT}.debug |
||||
|
PATH_SUFFIXES lib |
||||
|
HINTS ${PANTHEIOS_ROOT_HINT} ${PANTHEIOS_ROOT} |
||||
|
ENV PANTHEIOS_ROOT |
||||
|
) |
||||
|
|
||||
|
find_library(PANTHEIOS_${t}_${PANTHEIOS_BACKEND}_${_P_LT}_LIBRARY |
||||
|
pantheios.1.${t}.${PANTHEIOS_BACKEND}.${_P_LIB_TAG}.${_P_LT} |
||||
|
PATH_SUFFIXES lib |
||||
|
HINTS ${PANTHEIOS_ROOT_HINT} ${PANTHEIOS_ROOT} |
||||
|
ENV PANTHEIOS_ROOT |
||||
|
) |
||||
|
list(APPEND _P_REQUIRED_LIBVARS |
||||
|
PANTHEIOS_${t}_${PANTHEIOS_BACKEND}_${_P_LT}_DEBUG_LIBRARY |
||||
|
PANTHEIOS_${t}_${PANTHEIOS_BACKEND}_${_P_LT}_LIBRARY |
||||
|
) |
||||
|
list(APPEND PANTHEIOS_LIBRARIES |
||||
|
debug ${PANTHEIOS_${t}_${PANTHEIOS_BACKEND}_${_P_LT}_DEBUG_LIBRARY} |
||||
|
optimized ${PANTHEIOS_${t}_${PANTHEIOS_BACKEND}_${_P_LT}_LIBRARY} |
||||
|
) |
||||
|
endforeach() |
||||
|
endif() |
||||
|
|
||||
|
# frontent libraries |
||||
|
set(PANTHEIOS_fe_DEBUG_LIBRARY) |
||||
|
set(PANTHEIOS_fe_LIBRARY) |
||||
|
if(NOT PANTHEIOS_FRONTENT STREQUAL null) |
||||
|
set(_P_FE ${PANTHEIOS_FRONTEND}) |
||||
|
find_library(PANTHEIOS_${_P_FE}_${_P_LT}_DEBUG_LIBRARY |
||||
|
pantheios.1.fe.${_P_FE}.${_P_LIB_TAG}.${_P_LT}.debug |
||||
|
PATH_SUFFIXES lib |
||||
|
HINTS ${PANTHEIOS_ROOT_HINT} ${PANTHEIOS_ROOT} |
||||
|
ENV PANTHEIOS_ROOT |
||||
|
) |
||||
|
find_library(PANTHEIOS_${_P_FE}_${_P_LT}_LIBRARY |
||||
|
pantheios.1.fe.${_P_FE}.${_P_LIB_TAG}.${_P_LT} |
||||
|
PATH_SUFFIXES lib |
||||
|
HINTS ${PANTHEIOS_ROOT_HINT} ${PANTHEIOS_ROOT} |
||||
|
ENV PANTHEIOS_ROOT |
||||
|
) |
||||
|
|
||||
|
list(APPEND _P_REQUIRED_LIBVARS |
||||
|
PANTHEIOS_${_P_FE}_${_P_LT}_DEBUG_LIBRARY |
||||
|
PANTHEIOS_${_P_FE}_${_P_LT}_LIBRARY |
||||
|
) |
||||
|
list(APPEND PANTHEIOS_LIBRARIES |
||||
|
debug ${PANTHEIOS_${_P_FE}_${_P_LT}_DEBUG_LIBRARY} |
||||
|
optimized ${PANTHEIOS_${_P_FE}_${_P_LT}_LIBRARY} |
||||
|
) |
||||
|
endif() |
||||
|
|
||||
|
# copy to NAME_LIBS |
||||
|
set(PANTHEIOS_LIBS ${PANTHEIOS_LIBRARIES}) |
||||
|
|
||||
|
# handle the QUIETLY and REQUIRED arguments and set Pantheios_FOUND to TRUE if |
||||
|
# all listed variables are TRUE |
||||
|
include(FindPackageHandleStandardArgs) |
||||
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Pantheios |
||||
|
REQUIRED_VARS PANTHEIOS_INCLUDE_DIR ${_P_REQUIRED_LIBVARS} |
||||
|
) |
||||
|
|
||||
|
|
||||
|
mark_as_advanced(PANTHEIOS_INCLUDE_DIR PANTHEIOS_LIBRARIES) |
||||
|
|
@ -0,0 +1,56 @@ |
|||||
|
# Locate the STLSoft Headers. |
||||
|
# |
||||
|
# Defines the following variables: |
||||
|
# |
||||
|
# STLSOFT_FOUND - Found the Pantheios Logging Framework |
||||
|
# STLSOFT_INCLUDE_DIRS - Include directories |
||||
|
# |
||||
|
# Accepts the following variables as input: |
||||
|
# |
||||
|
# STLSOFT_ROOT - (as a CMake or environment variable) |
||||
|
# The root directory of the STLSoft install prefix |
||||
|
# |
||||
|
# |
||||
|
|
||||
|
#============================================================================= |
||||
|
# Copyright 2012 Philipp Berger <admin@philippberger.de> |
||||
|
# |
||||
|
# Distributed under the OSI-approved BSD License (the "License"); |
||||
|
# see accompanying file Copyright.txt for details. |
||||
|
# |
||||
|
# This software is distributed WITHOUT ANY WARRANTY; without even the |
||||
|
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||||
|
# See the License for more information. |
||||
|
#============================================================================= |
||||
|
# (To distribute this file outside of CMake, substitute the full |
||||
|
# License text for the above reference.) |
||||
|
# |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
if(STLSOFT_INCLUDE_DIR) |
||||
|
if (NOT STLSOFT_ROOT) |
||||
|
get_filename_component(STLSOFT_ROOT "${STLSOFT_INCLUDE_DIR}" PATH) |
||||
|
endif() |
||||
|
|
||||
|
get_filename_component(STLSOFT_ROOT_HINT "${STLSOFT_INCLUDE_DIR}" PATH) |
||||
|
endif() |
||||
|
|
||||
|
find_path(STLSOFT_INCLUDE_DIR stlsoft/stlsoft.h |
||||
|
PATH_SUFFIXES include |
||||
|
HINTS ${STLSOFT_ROOT} ${STLSOFT_ROOT_HINT} |
||||
|
ENV STLSOFT_ROOT |
||||
|
) |
||||
|
set(STLSOFT_INCLUDE_DIRS ${STLSOFT_INCLUDE_DIR}) |
||||
|
|
||||
|
# handle the QUIETLY and REQUIRED arguments and set STLSOFT_FOUND to TRUE if |
||||
|
# all listed variables are TRUE |
||||
|
include(FindPackageHandleStandardArgs) |
||||
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(STLSoft |
||||
|
REQUIRED_VARS STLSOFT_INCLUDE_DIR |
||||
|
) |
||||
|
|
||||
|
|
||||
|
mark_as_advanced(STLSOFT_INCLUDE_DIR) |
||||
|
|
@ -0,0 +1,16 @@ |
|||||
|
CMake |
||||
|
|
||||
|
Prerequisites: |
||||
|
Boost >= 1.49 |
||||
|
Build using the Boost Build system, for x64 use "bjam address-model=64" or "bjam.exe address-model=64 --build-type=complete" |
||||
|
You may use --toolset to specify the compiler, for ex. msvc-10.0, intel11.1, etc |
||||
|
Doxygen |
||||
|
Set DOXYGEN_EXECUTABLE to your doxygen executable, e.g. "C:/Program Files/doxygen/bin/doxygen.exe" |
||||
|
GTest >= 1.6.0 |
||||
|
Download, build using CMake |
||||
|
If you installed gtest to e.g. "C:/C++ Projects/gtest-1.6.0" |
||||
|
Set GTEST_INCLUDE_DIR to "C:/C++ Projects/gtest-1.6.0/include" |
||||
|
Set GTEST_LIBRARY to |
||||
|
Set GTEST_LIBRARY_DEBUG to |
||||
|
Set GTEST_MAIN_LIBRARY to |
||||
|
Set GTEST_MAIN_LIBRARY_DEBUG to |
@ -0,0 +1,56 @@ |
|||||
|
//! A test class. |
||||
|
/*! |
||||
|
A more elaborate class description. |
||||
|
*/ |
||||
|
class Test |
||||
|
{ |
||||
|
public: |
||||
|
//! An enum. |
||||
|
/*! More detailed enum description. */ |
||||
|
enum TEnum { |
||||
|
TVal1, /*!< Enum value TVal1. */ |
||||
|
TVal2, /*!< Enum value TVal2. */ |
||||
|
TVal3 /*!< Enum value TVal3. */ |
||||
|
} |
||||
|
//! Enum pointer. |
||||
|
/*! Details. */ |
||||
|
*enumPtr, |
||||
|
//! Enum variable. |
||||
|
/*! Details. */ |
||||
|
enumVar; |
||||
|
//! A constructor. |
||||
|
/*! |
||||
|
A more elaborate description of the constructor. |
||||
|
*/ |
||||
|
Test(); |
||||
|
//! A destructor. |
||||
|
/*! |
||||
|
A more elaborate description of the destructor. |
||||
|
*/ |
||||
|
~Test(); |
||||
|
//! A normal member taking two arguments and returning an integer value. |
||||
|
/*! |
||||
|
\param a an integer argument. |
||||
|
\param s a constant character pointer. |
||||
|
\return The test results |
||||
|
\sa Test(), ~Test(), testMeToo() and publicVar() |
||||
|
*/ |
||||
|
int testMe(int a,const char *s); |
||||
|
//! A pure virtual member. |
||||
|
/*! |
||||
|
\sa testMe() |
||||
|
\param c1 the first argument. |
||||
|
\param c2 the second argument. |
||||
|
*/ |
||||
|
virtual void testMeToo(char c1,char c2) = 0; |
||||
|
//! A public variable. |
||||
|
/*! |
||||
|
Details. |
||||
|
*/ |
||||
|
int publicVar; |
||||
|
//! A function variable. |
||||
|
/*! |
||||
|
Details. |
||||
|
*/ |
||||
|
int (*handler)(int a,int b); |
||||
|
}; |
@ -0,0 +1,23 @@ |
|||||
|
#ifndef MRMC_EXCEPTIONS_INVALID_ARGUMENT_H_ |
||||
|
#define MRMC_EXCEPTIONS_INVALID_ARGUMENT_H_ |
||||
|
|
||||
|
#include <exception> |
||||
|
|
||||
|
namespace mrmc { |
||||
|
|
||||
|
namespace exceptions { |
||||
|
|
||||
|
//!This exception is thrown when a parameter is invalid in this context |
||||
|
class invalid_argument : public std::exception |
||||
|
{ |
||||
|
public: |
||||
|
invalid_argument() : exception("::mrmc::invalid_argument"){} |
||||
|
invalid_argument(const char * const s): exception(s) {} |
||||
|
virtual const char* what() const throw() |
||||
|
{ return "mrmc::invalid_argument"; } |
||||
|
}; |
||||
|
|
||||
|
} // namespace exceptions |
||||
|
|
||||
|
} // namespace mrmc |
||||
|
#endif // MRMC_EXCEPTIONS_INVALID_ARGUMENT_H_ |
@ -0,0 +1,25 @@ |
|||||
|
#ifndef MRMC_EXCEPTIONS_INVALID_STATE_H_ |
||||
|
#define MRMC_EXCEPTIONS_INVALID_STATE_H_ |
||||
|
|
||||
|
#include <exception> |
||||
|
|
||||
|
namespace mrmc { |
||||
|
|
||||
|
namespace exceptions { |
||||
|
|
||||
|
//!This exception is thrown when a memory request can't be |
||||
|
//!fulfilled. |
||||
|
class invalid_state : public std::exception |
||||
|
{ |
||||
|
public: |
||||
|
invalid_state() : exception("::mrmc::invalid_state"){} |
||||
|
invalid_state(const char * const s): exception(s) {} |
||||
|
virtual const char* what() const throw() |
||||
|
{ return "mrmc::invalid_state"; } |
||||
|
}; |
||||
|
|
||||
|
} // namespace exceptions |
||||
|
|
||||
|
} // namespace mrmc |
||||
|
|
||||
|
#endif // MRMC_EXCEPTIONS_INVALID_STATE_H_ |
@ -0,0 +1,23 @@ |
|||||
|
#ifndef MRMC_EXCEPTIONS_OUT_OF_RANGE_H_ |
||||
|
#define MRMC_EXCEPTIONS_OUT_OF_RANGE_H_ |
||||
|
|
||||
|
#include <exception> |
||||
|
|
||||
|
namespace mrmc { |
||||
|
|
||||
|
namespace exceptions { |
||||
|
|
||||
|
//!This exception is thrown when a parameter is not in the range of valid values |
||||
|
class out_of_range : public std::exception |
||||
|
{ |
||||
|
public: |
||||
|
out_of_range() : exception("::mrmc::out_of_range"){} |
||||
|
out_of_range(const char * const s): exception(s) {} |
||||
|
virtual const char* what() const throw() |
||||
|
{ return "mrmc::out_of_range"; } |
||||
|
}; |
||||
|
|
||||
|
} // namespace exceptions |
||||
|
|
||||
|
} // namespace mrmc |
||||
|
#endif // MRMC_EXCEPTIONS_OUT_OF_RANGE_H_ |
@ -0,0 +1,195 @@ |
|||||
|
#ifndef MRMC_SPARSE_STATIC_SPARSE_MATRIX_H_ |
||||
|
#define MRMC_SPARSE_STATIC_SPARSE_MATRIX_H_ |
||||
|
|
||||
|
#include <exception> |
||||
|
#include "boost/integer/integer_mask.hpp" |
||||
|
|
||||
|
#include <pantheios/pantheios.hpp> |
||||
|
#include <pantheios/inserters/integer.hpp> |
||||
|
|
||||
|
#include "src/exceptions/invalid_state.h" |
||||
|
#include "src/exceptions/invalid_argument.h" |
||||
|
#include "src/exceptions/out_of_range.h" |
||||
|
|
||||
|
namespace mrmc { |
||||
|
|
||||
|
namespace sparse { |
||||
|
|
||||
|
//! A sparse Matrix for DTMCs with a constant number of non-zero entries on the non-diagonal fields. |
||||
|
/*! |
||||
|
The sparse matrix used for calculation on the DTMCs. |
||||
|
Adressing is NOT zero-based! The valid range for getValue and addNextValue is 1 to rows (first argument to constructor). |
||||
|
*/ |
||||
|
template <class T> |
||||
|
class StaticSparseMatrix { |
||||
|
public: |
||||
|
|
||||
|
//! Constructor |
||||
|
/*! |
||||
|
\param rows Row-Count and therefor column-count of the symetric matrix |
||||
|
\param non_zero_entries The exact count of entries that will be submitted through addNextValue *excluding* those on the diagonal (A_{i,j} with i = j) |
||||
|
*/ |
||||
|
StaticSparseMatrix(uint_fast32_t rows, uint_fast32_t non_zero_entries) { |
||||
|
current_size = 0; |
||||
|
storage_size = 0; |
||||
|
|
||||
|
row_count = rows; |
||||
|
non_zero_entry_count = non_zero_entries; |
||||
|
|
||||
|
//initialize(rows, non_zero_entries); |
||||
|
} |
||||
|
|
||||
|
~StaticSparseMatrix() { |
||||
|
if (value_storage != NULL) { |
||||
|
free(value_storage); |
||||
|
} |
||||
|
if (column_indications != NULL) { |
||||
|
free(column_indications); |
||||
|
} |
||||
|
if (row_indications != NULL) { |
||||
|
free(row_indications); |
||||
|
} |
||||
|
if (diagonal_storage != NULL) { |
||||
|
free(diagonal_storage); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
//! Getter for saving matrix entry A_{row,col} to target |
||||
|
/*! |
||||
|
Getter function for the matrix. |
||||
|
\param row 1-based index of the requested row |
||||
|
\param col 1-based index of the requested column |
||||
|
\param target pointer to where the result will be stored |
||||
|
\return True iff the value was set, false otherwise. On false, 0 will be written to *target. |
||||
|
*/ |
||||
|
inline bool getValue(uint_fast32_t row, uint_fast32_t col, T* const target) { |
||||
|
|
||||
|
if (row == col) { |
||||
|
// storage is row_count + 1 large for direct access without the -1 |
||||
|
*target = diagonal_storage[row]; |
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
if ((row > row_count) || (col > row_count) || (row == 0) || (col == 0)) { |
||||
|
throw new mrmc::exceptions::out_of_range("mrmc::StaticSparseMatrix::getValue: row or col not in 1 .. rows"); |
||||
|
} |
||||
|
|
||||
|
uint_fast32_t row_start = row_indications[row - 1]; |
||||
|
uint_fast32_t row_end = row_indications[row]; |
||||
|
|
||||
|
while (row_start < row_end) { |
||||
|
if (column_indications[row_start] == col) { |
||||
|
*target = value_storage[row_start]; |
||||
|
return true; |
||||
|
} |
||||
|
if (column_indications[row_start] > col) { |
||||
|
break; |
||||
|
} |
||||
|
row_start++; |
||||
|
} |
||||
|
|
||||
|
*target = 0; |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
//! Mandatory initialization of the matrix |
||||
|
/*! |
||||
|
Mandatory initialization of the matrix, must be called before using any other member function. |
||||
|
*/ |
||||
|
void initialize() { |
||||
|
|
||||
|
if (row_count == 0) { |
||||
|
pantheios::log_ERROR("StaticSparseMatrix::initialize: Throwing invalid_argument for row_count = 0"); |
||||
|
throw new mrmc::exceptions::invalid_argument("mrmc::StaticSparseMatrix::initialize: Matrix with 0 rows is not reasonable"); |
||||
|
} |
||||
|
|
||||
|
if (((row_count * row_count) - row_count) < non_zero_entry_count) { |
||||
|
pantheios::log_ERROR("StaticSparseMatrix::initialize: Throwing invalid_argument: More non-zero entries than entries in target matrix"); |
||||
|
throw new mrmc::exceptions::invalid_argument("mrmc::StaticSparseMatrix::initialize: More non-zero entries than entries in target matrix"); |
||||
|
} |
||||
|
|
||||
|
storage_size = non_zero_entry_count; |
||||
|
last_row = 0; |
||||
|
|
||||
|
value_storage = static_cast<T*>(calloc(storage_size, sizeof(*value_storage))); |
||||
|
|
||||
|
column_indications = static_cast<uint_fast32_t*>(calloc(storage_size, sizeof(*column_indications))); |
||||
|
|
||||
|
row_indications = static_cast<uint_fast32_t*>(calloc(row_count + 1, sizeof(*row_indications))); |
||||
|
|
||||
|
// row_count + 1 so that access with 1-based indices can be direct without the overhead of a -1 each time |
||||
|
diagonal_storage = static_cast<T*>(calloc(row_count + 1, sizeof(*diagonal_storage))); |
||||
|
|
||||
|
if ((value_storage == NULL) || (column_indications == NULL) || (row_indications == NULL) || (diagonal_storage == NULL)) { |
||||
|
pantheios::log_ERROR("StaticSparseMatrix::initialize: Throwing bad_alloc: memory allocation failed"); |
||||
|
throw new std::bad_alloc("mrmc::StaticSparseMatrix::initialize: memory allocation failed"); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
//! Linear Setter for matrix entry A_{row, col} to value |
||||
|
/*! |
||||
|
Linear Setter function for matrix entry A_{row, col} to value. Must be called consecutively for each element in a row in ascending order of columns AND in ascending order of rows. |
||||
|
Diagonal entries may be set at any time. |
||||
|
*/ |
||||
|
void addNextValue(const uint_fast32_t row, const uint_fast32_t col, const T value) { |
||||
|
if ((row > row_count) || (col > row_count) || (row == 0) || (col == 0)) { |
||||
|
pantheios::log_ERROR("StaticSparseMatrix::addNextValue: Throwing out_of_range: row or col not in 1 .. rows"); |
||||
|
throw new mrmc::exceptions::out_of_range("mrmc::StaticSparseMatrix::addNextValue: row or col not in 1 .. rows"); |
||||
|
} |
||||
|
|
||||
|
if (row == col) { |
||||
|
diagonal_storage[row] = value; |
||||
|
} else { |
||||
|
if (row != last_row) { |
||||
|
for (uint_fast32_t i = last_row; i < row; ++i) { |
||||
|
row_indications[i] = current_size; |
||||
|
} |
||||
|
last_row = row; |
||||
|
} |
||||
|
|
||||
|
value_storage[current_size] = value; |
||||
|
column_indications[current_size] = col; |
||||
|
|
||||
|
// Increment counter for stored elements |
||||
|
current_size++; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
void finalize() { |
||||
|
if (storage_size != current_size) { |
||||
|
pantheios::log_ERROR("StaticSparseMatrix::finalize: Throwing invalid_state: Wrong call count for addNextValue"); |
||||
|
throw new mrmc::exceptions::invalid_state("mrmc::StaticSparseMatrix::finalize: Wrong call count for addNextValue"); |
||||
|
} |
||||
|
|
||||
|
if (last_row != row_count) { |
||||
|
for (uint_fast32_t i = last_row; i < row_count; ++i) { |
||||
|
row_indications[i] = current_size; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
row_indications[row_count] = storage_size; |
||||
|
} |
||||
|
private: |
||||
|
uint_fast32_t storage_size; |
||||
|
uint_fast32_t current_size; |
||||
|
|
||||
|
uint_fast32_t row_count; |
||||
|
uint_fast32_t non_zero_entry_count; |
||||
|
uint_fast32_t last_row; |
||||
|
|
||||
|
/*! Array containing all non-zero values, apart from the diagonal entries */ |
||||
|
T* value_storage; |
||||
|
/*! Array containing all diagonal values */ |
||||
|
T* diagonal_storage; |
||||
|
|
||||
|
/*! Array containing the column number of the corresponding value_storage entry */ |
||||
|
uint_fast32_t* column_indications; |
||||
|
/*! Array containing the row boundarys of valueStorage */ |
||||
|
uint_fast32_t* row_indications; |
||||
|
}; |
||||
|
|
||||
|
} // namespace sparse |
||||
|
|
||||
|
} // namespace mrmc |
||||
|
|
||||
|
#endif // MRMC_SPARSE_STATIC_SPARSE_MATRIX_H_ |
@ -0,0 +1,103 @@ |
|||||
|
#include "gtest/gtest.h"
|
||||
|
#include "src/sparse/static_sparse_matrix.h"
|
||||
|
#include "src/exceptions/invalid_argument.h"
|
||||
|
|
||||
|
TEST(StaticSparseMatrixTest, ZeroRowsTest) { |
||||
|
mrmc::sparse::StaticSparseMatrix<int> *ssm = new mrmc::sparse::StaticSparseMatrix<int>(0, 50); |
||||
|
|
||||
|
ASSERT_THROW(ssm->initialize(), mrmc::exceptions::invalid_argument); |
||||
|
|
||||
|
delete ssm; |
||||
|
} |
||||
|
|
||||
|
TEST(StaticSparseMatrixTest, TooManyEntriesTest) { |
||||
|
mrmc::sparse::StaticSparseMatrix<int> *ssm = new mrmc::sparse::StaticSparseMatrix<int>(2, 10); |
||||
|
|
||||
|
ASSERT_THROW(ssm->initialize(), mrmc::exceptions::invalid_argument); |
||||
|
|
||||
|
delete ssm; |
||||
|
} |
||||
|
|
||||
|
TEST(StaticSparseMatrixTest, addNextValueTest) { |
||||
|
mrmc::sparse::StaticSparseMatrix<int> *ssm = new mrmc::sparse::StaticSparseMatrix<int>(5, 1); |
||||
|
|
||||
|
ASSERT_NO_THROW(ssm->initialize()); |
||||
|
|
||||
|
ASSERT_THROW(ssm->addNextValue(0, 1, 1), mrmc::exceptions::out_of_range); |
||||
|
ASSERT_THROW(ssm->addNextValue(1, 0, 1), mrmc::exceptions::out_of_range); |
||||
|
ASSERT_THROW(ssm->addNextValue(6, 1, 1), mrmc::exceptions::out_of_range); |
||||
|
ASSERT_THROW(ssm->addNextValue(1, 6, 1), mrmc::exceptions::out_of_range); |
||||
|
|
||||
|
delete ssm; |
||||
|
} |
||||
|
|
||||
|
TEST(StaticSparseMatrixTest, finalizeTest) { |
||||
|
mrmc::sparse::StaticSparseMatrix<int> *ssm = new mrmc::sparse::StaticSparseMatrix<int>(5, 5); |
||||
|
|
||||
|
ASSERT_NO_THROW(ssm->initialize()); |
||||
|
|
||||
|
ASSERT_NO_THROW(ssm->addNextValue(1, 2, 1)); |
||||
|
ASSERT_NO_THROW(ssm->addNextValue(1, 3, 1)); |
||||
|
ASSERT_NO_THROW(ssm->addNextValue(1, 4, 1)); |
||||
|
ASSERT_NO_THROW(ssm->addNextValue(1, 5, 1)); |
||||
|
|
||||
|
ASSERT_THROW(ssm->finalize(), mrmc::exceptions::invalid_state); |
||||
|
|
||||
|
delete ssm; |
||||
|
} |
||||
|
|
||||
|
TEST(StaticSparseMatrixTest, Test) { |
||||
|
// 25 rows, 50 non zero entries
|
||||
|
mrmc::sparse::StaticSparseMatrix<int> *ssm = new mrmc::sparse::StaticSparseMatrix<int>(25, 50); |
||||
|
|
||||
|
int values[50] = { |
||||
|
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, |
||||
|
10, 11, 12, 13, 14, 15, 16, 17, 18, 19, |
||||
|
20, 21, 22, 23, 24, 25, 26, 27, 28, 29, |
||||
|
30, 31, 32, 33, 34, 35, 36, 37, 38, 39, |
||||
|
40, 41, 42, 43, 44, 45, 46, 47, 48, 49 |
||||
|
}; |
||||
|
int position_row[50] = { |
||||
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
||||
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
||||
|
2, 2, 2, 2, /* first row empty, one full row à 25 minus the diagonal entry */ |
||||
|
4, 4, /* one empty row, then first and last column */ |
||||
|
13, 13, 13, 13, /* a few empty rows, middle columns */ |
||||
|
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, |
||||
|
24, 24, 24, 24, 24, 24, 24, 24, 24, 24 /* second to last row */ |
||||
|
}; |
||||
|
int position_col[50] = { |
||||
|
1, 3, 4, 5, 6, 7, 8, 9, 10, |
||||
|
11, 12, 13, 14, 15, 16, 17, 18, 19, 20, |
||||
|
21, 22, 23, 24, 25, /* first row empty, one full row a 25 */ |
||||
|
1, 25, /* one empty row, then first and last column */ |
||||
|
16, 17, 18, 19, /* a few empty rows, middle columns */ |
||||
|
2, 3, 4, 5, 6, 7, 8, 9, 10, 11, |
||||
|
14, 15, 16, 17, 18, 19, 20, 21, 22, 23 /* second to last row */ |
||||
|
}; |
||||
|
|
||||
|
ASSERT_NO_THROW(ssm->initialize()); |
||||
|
|
||||
|
for (int i = 0; i < 50; ++i) { |
||||
|
ASSERT_NO_THROW(ssm->addNextValue(position_row[i], position_col[i], values[i])); |
||||
|
} |
||||
|
|
||||
|
ASSERT_NO_THROW(ssm->finalize()); |
||||
|
|
||||
|
int target; |
||||
|
for (int i = 0; i < 50; ++i) { |
||||
|
ASSERT_TRUE(ssm->getValue(position_row[i], position_col[i], &target)); |
||||
|
ASSERT_EQ(values[i], target); |
||||
|
} |
||||
|
|
||||
|
// test for a few of the empty rows
|
||||
|
for (int row = 14; row < 24; ++row) { |
||||
|
for (int col = 1; col <= 25; ++col) { |
||||
|
target = 1; |
||||
|
ASSERT_FALSE(ssm->getValue(row, col, &target)); |
||||
|
ASSERT_EQ(0, target); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
delete ssm; |
||||
|
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue