Commit 78e693ee authored by Matteo Signer's avatar Matteo Signer

Port Task Radioactive

parent 522d080f
include_directories(../../../Utils)
add_executable_numcse(solution radioactive.cpp)
get_target_name_numcse(solution SOLUTION)
target_compile_definitions(${SOLUTION} PRIVATE SOLUTION=1 INTERNAL=1)
add_executable_numcse(template radioactive.cpp)
get_target_name_numcse(template TEMPLATE)
target_compile_definitions(${TEMPLATE} PRIVATE SOLUTION=0 INTERNAL=0)
0 0.5062106145957367
0.1 0.5547024373436563
0.2 0.599531235710525
0.3 0.6096223730010905
0.4 0.666898422292914
0.5 0.6932402506617286
0.6 0.7401830209319131
0.7 0.7630035917202518
0.8 0.7987828785112423
0.9 0.799174873290365
1 0.8216656220025627
1.1 0.8725063678597177
1.2 0.8126384876898325
1.3 0.870827276056431
1.4 0.8669607053065849
1.5 0.9053299433128569
1.6 0.9478577747477862
1.7 0.9657748713735291
1.8 0.9249155512988739
1.9 0.9502281517693321
2 0.9769372144290606
2.1 0.972547326079045
2.2 0.9973084687933707
2.3 1.006643312534194
2.4 0.9725898077925734
2.5 0.9994542731061394
2.6 0.9461778549004105
2.7 1.047236529002004
2.8 0.99541083675946
2.9 0.9802009195890283
3 1.009796831493382
3.1 0.975503789249564
3.2 1.017753130928896
3.3 1.001073733161526
3.4 1.085922695762248
3.5 1.051286074360676
3.6 0.9411073587681303
3.7 1.025729577429674
3.8 0.9683176248895937
3.9 0.9993310747867051
4 1.00885451982704
4.1 1.023165465275373
4.2 0.98862986938877
4.3 1.040861331948029
4.4 0.9743991364744898
4.5 0.9938170346614454
4.6 0.9991505496887231
4.7 0.9770362991616155
4.8 0.9954368818763182
4.9 0.9736242284304403
5 0.9365299346838808
5.1 0.9030084607539873
5.2 1.001904062843765
5.3 0.9248192337896532
5.4 0.9387087829649814
5.5 0.9455939608435621
5.6 0.9267562096218116
5.7 0.8928000796240328
5.8 0.89834913754712
5.9 0.9012650138755268
6 0.9389352458468258
6.1 0.8689333635692
6.2 0.9061735241981111
6.3 0.8866417520582973
6.4 0.8657139542788183
6.5 0.8381107066934431
6.6 0.8510998964370133
6.7 0.8494225928601851
6.8 0.8084289597148268
6.9 0.842921931528653
7 0.8110218037923785
7.1 0.8221438774546086
7.2 0.8259507917820997
7.3 0.7891415468094021
7.4 0.7971217897723653
7.5 0.8056609691206177
7.6 0.7480951302307595
7.7 0.8084116306579486
7.8 0.8355213836390848
7.9 0.7926488564623356
8 0.7562331809145821
8.1 0.766516944621792
8.199999999999999 0.7270871864099077
8.300000000000001 0.7864619170315802
8.4 0.7578369990745952
8.5 0.7475974512909028
8.6 0.7048077960485514
8.699999999999999 0.7239472418180055
8.800000000000001 0.6987220907180915
8.9 0.6975021407014163
9 0.6857827278631242
9.1 0.6702624434355771
9.199999999999999 0.6664252745586483
9.300000000000001 0.6742578473291455
9.4 0.6388272345582205
9.5 0.6782330217240129
9.6 0.6574478694106025
9.699999999999999 0.6674639729973566
9.800000000000001 0.6527452501151793
9.9 0.6509869614177952
10 0.6077165095561358
10.1 0.6103996131436449
10.2 0.6151160436323596
10.3 0.6195477381981478
10.4 0.6327164005061379
10.5 0.6005844547445001
10.6 0.6232035129842584
10.7 0.6028672289921923
10.8 0.6097501240869437
10.9 0.5852330530012471
11 0.566149615684483
11.1 0.5470103522715225
11.2 0.5690153989058594
11.3 0.5748558584985364
11.4 0.5506461802281432
11.5 0.5412826995400095
11.6 0.5397950623527216
11.7 0.5220813083955548
11.8 0.5264689869583544
11.9 0.5262686376608834
12 0.5247125367533352
12.1 0.5179059530169119
12.2 0.5233601799102535
12.3 0.5105166714968551
12.4 0.5320671525589933
12.5 0.503662974787521
12.6 0.5215843727144714
12.7 0.478772114620197
12.8 0.4922022719419105
12.9 0.4760171552207772
13 0.4836817529320874
13.1 0.4788540761941379
13.2 0.4362198399577001
13.3 0.4432167052966324
13.4 0.4373689940931597
13.5 0.4576913540141967
13.6 0.4679552448252879
13.7 0.4390371809214815
13.8 0.4498325199934605
13.9 0.441856141878826
14 0.4170379696356838
14.1 0.4312785150716533
14.2 0.4125564279044864
14.3 0.4372537433021811
14.4 0.4132863692936191
14.5 0.4302154698546438
14.6 0.4004301746880835
14.7 0.4087304112474892
14.8 0.3968536164173345
14.9 0.3705053204107587
15 0.3784693206935157
{
"author" : "",
"email" : "",
"contributors" : "",
"name": "RadioactiveDecay",
"all" : ["radioactive.cpp"]
}
#include <iostream>
#include <fstream>
#include <vector>
#include <cmath>
#include <Eigen/Dense>
#include <figure/figure.hpp>
// Function F from subtask b
Eigen::VectorXd F(const Eigen::Array4d &x, const Eigen::ArrayXd &t, const Eigen::ArrayXd &m) {
double a0 = x[0], b0 = x[1], l1 = x[2], l2 = x[3];
#if SOLUTION
return (-l2*t).exp()*b0 + (l1/(l2-l1))*((-l1*t).exp() - (-l2*t).exp())*a0 - m;
#endif
}
// Jacobian of F, computed in subtask c
Eigen::MatrixX4d DF(const Eigen::Array4d &x, const Eigen::ArrayXd &t, const Eigen::ArrayXd &m) {
double a0 = x[0], b0 = x[1], l1 = x[2], l2 = x[3];
#if SOLUTION
Eigen::ArrayX4d res(t.size(), 4);
double inv_d = 1.0 / (l2-l1);
Eigen::ArrayXd expl1 = (-l1*t).exp();
Eigen::ArrayXd expl2 = (-l2*t).exp();
Eigen::ArrayXd expd = expl1-expl2;
Eigen::VectorXd col1 = l1*inv_d*expd;
Eigen::VectorXd col2 = expl2;
Eigen::VectorXd col3 = l2*inv_d*inv_d*expd*a0 - l1*t*inv_d*expl1*a0;
Eigen::VectorXd col4 = -t*expl2*b0 - l2*inv_d*inv_d*expd*a0 + l1*t*inv_d*expl2*a0;
res << col1, col2, col3, col4;
return res;
#endif
}
int main() {
std::ifstream data_file("decay.txt");
if (!data_file.is_open()) {
std::cerr << "Cannot open decay.txt\n";
return 1;
}
std::vector<double> t_data, m_data;
for (double t_i, m_i; data_file >> t_i >> m_i;) {
t_data.push_back(t_i); m_data.push_back(m_i);
}
Eigen::Map<Eigen::VectorXd> t(t_data.data(), t_data.size()), m(m_data.data(), m_data.size());
// Use Gauss-Newton iteration to find minimizer of F(x)
#if SOLUTION
/* SAM_LISTING_BEGIN_1 */
std::vector<double> gn_update;
Eigen::Vector4d x(1., 1., 1., 0.1), s;
do {
Eigen::Vector4d s = DF(x, t, m).colPivHouseholderQr().solve(F(x, t, m));
x -= s;
gn_update.push_back(s.lpNorm<Eigen::Infinity>());
} while (gn_update.back() > 1e-14);
/* SAM_LISTING_END_1 */
mgl::Figure fig1, fig2;
fig1.plot(t, m, "b").label("measured PhiB");
fig1.plot(t, F(x, t, Eigen::VectorXd::Zero(t.size())), "r").label("fitted PhiB");
Eigen::VectorXd phiA = x[0]*(-x[2]*Eigen::ArrayXd(t)).exp();
fig1.plot(t, phiA, "b").label("fitted PhiA");
fig1.xlabel("t");
fig1.legend(1, 1);
fig1.save("solution.eps");
fig2.setlog(false, true);
fig2.plot(Eigen::VectorXd::LinSpaced(gn_update.size(), 1, gn_update.size()), Eigen::Map<Eigen::VectorXd>(gn_update.data(), gn_update.size()), "r");
fig2.xlabel("iteration");
fig2.ylabel("change");
fig2.save("convergence.eps");
#endif
return 0;
}
project(RadioactiveDecay)
cmake_minimum_required(VERSION 2.8)
#
# setup compiler
#
# use c++11
if(CMAKE_VERSION VERSION_GREATER 3.1.0 OR CMAKE_VERSION VERSION_EQUAL 3.1.0)
# only valid for new platforms
set(CMAKE_CXX_STANDARD 11)
else()
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
# for older cmake versions
# (note, this CXX flag is only valid for clang and gcc, for MSVC it is not needed)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()
endif()
# enable some warnings
add_definitions(-pedantic -Wall)
# disable some warnings
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
# (this is only applicable on clang)
# ignore some mathgl warnings
add_definitions(-Wno-return-type-c-linkage -Wno-keyword-macro -Wno-missing-braces)
#set(EXTERNAL_PROJECT_CXX_FLAGS ${EXTERNAL_PROJECT_CXX_FLAGS} -Wno-return-type-c-linkage)
endif()
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
# disable some warnings on gcc
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 6)
add_definitions(-Wno-ignored-attributes -Wno-misleading-indentation)
#set(EXTERNAL_PROJECT_CXX_FLAGS ${EXTERNAL_PROJECT_CXX_FLAGS} -Wno-ignored-attributes -Wno-misleading-indentation)
endif()
endif()
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
add_definitions(-Wno-deprecated-declarations -Wno-unknown-pragmas)
#set(EXTERNAL_PROJECT_CXX_FLAGS ${EXTERNAL_PROJECT_CXX_FLAGS} -Wno-deprecated-declarations)
endif()
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake-modules/")
include(ExternalProject)
find_package(Eigen3)
if (${EIGEN3_FOUND})
include_directories(${EIGEN3_INCLUDE_DIR})
add_custom_target(Eigen) # dependency dummy
else()
SET(DOWNLOADING_EIGEN ON)
# if not found system wide download
message("-- Downloading Eigen3")
ExternalProject_Add(
Eigen
URL http://bitbucket.org/eigen/eigen/get/3.2.7.zip
SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/Eigen
INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/Eigen_install
DOWNLOAD_NO_PROGRESS 1
CMAKE_ARGS ${EXTERNAL_PROJECT_CMAKE_ARGS_PREFIX} -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/Eigen_install)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/Eigen_install/include/eigen3)
endif()
find_package(MathGL2)
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
# If mathgl is installed, we do not trust that it is build using clang (in 99% of the cases,
# it is not). Therefore, we *always* build mathgl when we use clang
set(MATHGL2_FOUND OFF)
endif()
if (${MATHGL2_FOUND})
add_custom_target(MathGL) # dependency dummy
# patch mgl2/config.h
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/mathgl_patched_headers/mgl2)
file(READ ${MATHGL2_INCLUDE_DIRS}/mgl2/config.h MATHGL_PATCHED_CONFIG_H)
STRING(REGEX REPLACE "#define MGL_HAVE_TYPEOF[ \t]+1" "#define MGL_HAVE_TYPEOF 0 // patched"
MATHGL_PATCHED_CONFIG_H ${MATHGL_PATCHED_CONFIG_H})
STRING(REGEX REPLACE "#define MGL_HAVE_C99_COMPLEX[ \t]+1" "#define MGL_HAVE_C99_COMPLEX 0 // patched"
MATHGL_PATCHED_CONFIG_H ${MATHGL_PATCHED_CONFIG_H})
file(WRITE ${PROJECT_BINARY_DIR}/mathgl_patched_headers/mgl2/config.h ${MATHGL_PATCHED_CONFIG_H} )
include_directories(${PROJECT_BINARY_DIR}/mathgl_patched_headers/) # use patched config.h for mathgl
else()
set(DOWNLOADING_MGL ON)
message("-- Downloading MathGl")
if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/mathgl_install)
ExternalProject_Add(
MathGL
URL http://downloads.sourceforge.net/mathgl/mathgl-2.3.3.tar.gz
SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/mathgl_source
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/mathgl_binary
DOWNLOAD_NO_PROGRESS 1
CMAKE_ARGS ${EXTERNAL_PROJECT_CMAKE_ARGS_PREFIX} -DCMAKE_CXX_STANDARD=11 -Denable-openmp=OFF -DMGL_HAVE_TYPEOF=0 -DMGL_HAVE_C99_COMPLEX=0 -DMGL_LIB_INSTALL_DIR=${CMAKE_CURRENT_BINARY_DIR}/mathgl_install/lib/ -DMGL_CGI_PATH=${CMAKE_CURRENT_BINARY_DIR}/mathgl_install/share/mathgl -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/mathgl_install -DCMAKE_INSTALL_NAME_DIR=@rpath
INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/mathgl_install
)
else()
add_custom_target(MathGL)
message("Skipped download of mathgl because its already present. Delete `${CMAKE_CURRENT_BINARY_DIR}/mathgl_install` to redownload it.")
endif()
set(MATHGL2_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/mathgl_install/include)
set(MATHGL2_LIBRARY_NAME ${CMAKE_SHARED_LIBRARY_PREFIX}mgl${CMAKE_SHARED_LIBRARY_SUFFIX})
set(MATHGL2_LIBRARIES "${CMAKE_CURRENT_BINARY_DIR}/mathgl_install/lib/${MATHGL2_LIBRARY_NAME}")
endif()
include_directories(${MATHGL2_INCLUDE_DIRS})
find_package(Figure QUIET)
if(FIGURE_FOUND)
set(DIRS ${DIRS} ${FIGURE_INCLUDE_DIR})
message(STATUS "Function GET_MODULES: Included Figure directory in variable DIRS")
set(LIBS ${LIBS} ${FIGURE_LIBRARY})
message(STATUS "Function GET_MODULES: Included Figure library in variable LIBS")
# case if Figure is not found by FindFigure.cmake - try to get it from MathGL/FigureClass
else()
set(FIGURE_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/figure) # directory which should contains the source files
message(STATUS "Trying to get it from ${FIGURE_INCLUDE_DIR} ...")
# check if necessary files exist in MathGL/FigureClass
foreach(FIGURE_FILE ${FIGURE_FILE_LIST})
if (NOT EXISTS ${FIGURE_INCLUDE_DIR}/${FIGURE_FILE})
message(FATAL_ERROR "Could not find necessary files to build Figure library! Try cloning the git repo again or contact someone.")
endif()
endforeach()
message(STATUS "Found necessary Figure files: ${FIGURE_INCLUDE_DIR}")
add_library(Figure STATIC ${FIGURE_INCLUDE_DIR}/figure.cpp)
#add_library(Figure SHARED ${FIGURE_INCLUDE_DIR}/figure.cpp)
#target_link_libraries(Figure ${MATHGL2_LIBRARIES})
add_dependencies(Figure Eigen)
add_dependencies(Figure MathGL)
# as libFigure.a was not built yet (this happens when '$ make' is executed) we need to call
# target_link_libraries(main Figure) and *not* target_link_libraries(main libFigure.a)
set(DIRS ${DIRS} ${FIGURE_INCLUDE_DIR})
set(LIBS ${LIBS} Figure)
endif()
include_directories(${FIGURE_INCLUDE_DIR})
include_directories(${FIGURE_INCLUDE_DIR}/..)
### RadioactiveDecay
# make radioactive
set(SRCS radioactive.cpp)
add_executable(radioactive ${SRCS})
target_link_libraries(radioactive Figure ${MATHGL2_LIBRARIES})
# - Try to find Eigen3 lib
#
# This module supports requiring a minimum version, e.g. you can do
# find_package(Eigen3 3.1.2)
# to require version 3.1.2 or newer of Eigen3.
#
# Once done this will define
#
# EIGEN3_FOUND - system has eigen lib with correct version
# EIGEN3_INCLUDE_DIR - the eigen include directory
# EIGEN3_VERSION - eigen version
#
# This module reads hints about search locations from
# the following enviroment variables:
#
# EIGEN3_ROOT
# EIGEN3_ROOT_DIR
# Copyright (c) 2006, 2007 Montel Laurent, <montel@kde.org>
# Copyright (c) 2008, 2009 Gael Guennebaud, <g.gael@free.fr>
# Copyright (c) 2009 Benoit Jacob <jacob.benoit.1@gmail.com>
# Redistribution and use is allowed according to the terms of the 2-clause BSD license.
if(NOT Eigen3_FIND_VERSION)
if(NOT Eigen3_FIND_VERSION_MAJOR)
set(Eigen3_FIND_VERSION_MAJOR 2)
endif(NOT Eigen3_FIND_VERSION_MAJOR)
if(NOT Eigen3_FIND_VERSION_MINOR)
set(Eigen3_FIND_VERSION_MINOR 91)
endif(NOT Eigen3_FIND_VERSION_MINOR)
if(NOT Eigen3_FIND_VERSION_PATCH)
set(Eigen3_FIND_VERSION_PATCH 0)
endif(NOT Eigen3_FIND_VERSION_PATCH)
set(Eigen3_FIND_VERSION "${Eigen3_FIND_VERSION_MAJOR}.${Eigen3_FIND_VERSION_MINOR}.${Eigen3_FIND_VERSION_PATCH}")
endif(NOT Eigen3_FIND_VERSION)
macro(_eigen3_check_version)
file(READ "${EIGEN3_INCLUDE_DIR}/Eigen/src/Core/util/Macros.h" _eigen3_version_header)
string(REGEX MATCH "define[ \t]+EIGEN_WORLD_VERSION[ \t]+([0-9]+)" _eigen3_world_version_match "${_eigen3_version_header}")
set(EIGEN3_WORLD_VERSION "${CMAKE_MATCH_1}")
string(REGEX MATCH "define[ \t]+EIGEN_MAJOR_VERSION[ \t]+([0-9]+)" _eigen3_major_version_match "${_eigen3_version_header}")
set(EIGEN3_MAJOR_VERSION "${CMAKE_MATCH_1}")
string(REGEX MATCH "define[ \t]+EIGEN_MINOR_VERSION[ \t]+([0-9]+)" _eigen3_minor_version_match "${_eigen3_version_header}")
set(EIGEN3_MINOR_VERSION "${CMAKE_MATCH_1}")
set(EIGEN3_VERSION ${EIGEN3_WORLD_VERSION}.${EIGEN3_MAJOR_VERSION}.${EIGEN3_MINOR_VERSION})
if(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION})
set(EIGEN3_VERSION_OK FALSE)
else(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION})
set(EIGEN3_VERSION_OK TRUE)
endif(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION})
if(NOT EIGEN3_VERSION_OK)
message(STATUS "Eigen3 version ${EIGEN3_VERSION} found in ${EIGEN3_INCLUDE_DIR}, "
"but at least version ${Eigen3_FIND_VERSION} is required")
endif(NOT EIGEN3_VERSION_OK)
endmacro(_eigen3_check_version)
if (EIGEN3_INCLUDE_DIR)
# in cache already
_eigen3_check_version()
set(EIGEN3_FOUND ${EIGEN3_VERSION_OK})
else (EIGEN3_INCLUDE_DIR)
# search for signature, 1st try
find_path(EIGEN3_INCLUDE_DIR NAMES signature_of_eigen3_matrix_library
HINTS
ENV EIGEN3_ROOT
ENV EIGEN3_ROOT_DIR
PATHS
${CMAKE_INSTALL_PREFIX}/include
${KDE4_INCLUDE_DIR}
PATH_SUFFIXES eigen3 eigen
)
if (NOT DEFINED EIGEN3_INCLUDE_DIR)
# search for directory name, 2nd try
find_path(EIGEN3_INCLUDE_DIR NAMES Eigen/Core
HINTS
/usr/include
/usr/local/include
)
endif()
endif(EIGEN3_INCLUDE_DIR)
if(EIGEN3_INCLUDE_DIR)
_eigen3_check_version()
message(STATUS "Eigen3 found at ${EIGEN3_INCLUDE_DIR}")
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Eigen3 DEFAULT_MSG EIGEN3_INCLUDE_DIR EIGEN3_VERSION_OK)
mark_as_advanced(EIGEN3_INCLUDE_DIR)
endif()
# - Find FFTW
# Find the native FFTW includes and library
#
# FFTW_INCLUDES - where to find fftw3.h
# FFTW_LIBRARIES - List of libraries when using FFTW.
# FFTW_FOUND - True if FFTW found.
if (FFTW_INCLUDES)
# Already in cache, be silent
set (FFTW_FIND_QUIETLY TRUE)
endif (FFTW_INCLUDES)
find_path (FFTW_INCLUDES fftw3.h)
find_library (FFTW_LIBRARIES NAMES fftw3)
# handle the QUIETLY and REQUIRED arguments and set FFTW_FOUND to TRUE if
# all listed variables are TRUE
include (FindPackageHandleStandardArgs)
find_package_handle_standard_args (FFTW DEFAULT_MSG FFTW_LIBRARIES FFTW_INCLUDES)
mark_as_advanced (FFTW_LIBRARIES FFTW_INCLUDES)
# ================================= FindFigure.cmake =======================================
# once finshed the following variables will be initialized:
# FIGURE_INCLUDE_DIR : directory which contains all Figure files
# FIGURE_LIBRARY : libFigure.a
# FIGURE_FOUND : true, if all parts of the library have been found. Otherwise false.
# FIGURE_FILE_LIST : list of all needed files
# ==========================================================================================
# Typical usage: find_package( Figure REQUIRED)
# include_directories( ${FIGURE_INCLUDE_DIR} )
# add_executable( main my_main_file.cpp )
# target_link_libraries( main Figure )
# ==========================================================================================
if ( DEBUG )
message( STATUS "Running FindFigure.cmake with DEBUG option .." )
endif()
# setting variable FIGURE_FILE_LIST
set( FIGURE_FILE_LIST figure.hpp
figure.cpp
FigureConfig.hpp
MglLabel.hpp
MglPlot.hpp
MglStyle.hpp
)
## ------------ find header files ------------- ##
# get paths to figure files
set( FIGURE_PATH_SUFFIX figure )
find_path( FIGURE_HPP NAMES figure.hpp PATH_SUFFIXES ${FIGURE_PATH_SUFFIX} DOC "Figure header" )
find_path( FIGURE_CPP NAMES figure.hpp PATH_SUFFIXES ${FIGURE_PATH_SUFFIX} DOC "Figure source" )
find_path( FIGURE NAMES Figure PATH_SUFFIXES ${FIGURE_PATH_SUFFIX} DOC "Figure include" )
find_path( FIGURECONFIG_HPP NAMES FigureConfig.hpp PATH_SUFFIXES ${FIGURE_PATH_SUFFIX} DOC "Figure config" )
find_path( MGL_LABEL_HPP NAMES MglLabel.hpp PATH_SUFFIXES ${FIGURE_PATH_SUFFIX} DOC "MglLabel" )
find_path( MGL_PLOT_HPP NAMES MglPlot.hpp PATH_SUFFIXES ${FIGURE_PATH_SUFFIX} DOC "MglPlot" )
find_path( MGL_STYLE_HPP NAMES MglStyle.hpp PATH_SUFFIXES ${FIGURE_PATH_SUFFIX} DOC "MglStyle" )
set( FIGURE_PATHS ${FIGURE_HPP}
${FIGURECONFIG_HPP}
${MGL_LABEL_HPP}
${MGL_PLOT_HPP}
${MGL_STYLE_HPP}
)
if ( DEBUG )
message( STATUS "Needed files are: figure.hpp FigureConfig.hpp MglLabel.hpp MglPlot.hpp MglStyle.hpp" )
endif()
# check if the files are all in the correct place
set( PATHS_ARE_VALID true )
foreach( FILE_PATH ${FIGURE_PATHS} )
if( NOT ${FILE_PATH} STREQUAL ${FIGURE_HPP} )
set( PATHS_ARE_VALID false )
if ( DEBUG ) # this will print which file exactly wasnt found
message( STATUS "${FILE_PATH}" )
endif()
endif()
endforeach()
# if all filepaths are valid set FIGURE_INCLUDE_DIR, otherwise throw error/warning
if( PATHS_ARE_VALID )
message( STATUS "Found Figure in ${FIGURE_HPP}" )
set( FIGURE_HEADERS_FOUND true )
set( FIGURE_INCLUDE_DIR ${FIGURE_HPP} )
else()
set( FIGURE_HEADERS_FOUND false )
if( Figure_REQUIRED )
message( FATAL_ERROR "Couldn't find all necessary header files for Figure, maybe try (re-)installing with administrator rights?" )
message( " Run cmake with the '-DDEBUG=1' option for more information on which files are missing." )
else()
message( STATUS "FindFigure.cmake couldn't find all necessary header files for Figure. Not stopping as Figure is not marked REQUIRED" )
endif()
endif()
## ------------ find libFigure.a -------------- ##
find_library( FIGURE_LIBRARY NAMES libFigure.a DOC "Figure library" )
if ( FIGURE_LIBRARY )
get_filename_component( FIGURE_LIBRARY_DIR ${FIGURE_LIBRARY} PATH )
message( STATUS "Found Figure library: ${FIGURE_LIBRARY_DIR}" )
else()
if ( Figure_REQUIRED )
message( FATAL_ERROR "Couldn't find libFigure.a, maybe try (re-)installing with administrator rights?" )
else()
message( STATUS "Couldn't find libFigure.a, maybe try (re-)installing with administrator rights?" )
endif()
endif()
# if the library and the header files were found set FIGURE_FOUND to true
if ( FIGURE_LIBRARY AND FIGURE_HEADERS_FOUND )
set( FIGURE_FOUND true )
else()
set( FIGURE_FOUND false )
endif()
# Try to find the GNU Multiple Precision Arithmetic Library (GMP)
# See http://gmplib.org/
if (GMP_INCLUDES AND GMP_LIBRARIES)
set(GMP_FIND_QUIETLY TRUE)
endif (GMP_INCLUDES AND GMP_LIBRARIES)
find_path(GMP_INCLUDES
NAMES
gmp.h
PATHS
$ENV{GMPDIR}
${INCLUDE_INSTALL_DIR}
)
find_library(GMP_LIBRARIES gmp PATHS $ENV{GMPDIR} ${LIB_INSTALL_DIR})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GMP DEFAULT_MSG
GMP_INCLUDES GMP_LIBRARIES)
mark_as_advanced(GMP_INCLUDES GMP_LIBRARIES)
\ No newline at end of file
# - Try to find the Intel Math Kernel Library
# Once done this will define
#
# MKL_FOUND - system has MKL