Commit 0deaa546 authored by niklas.baumgarten's avatar niklas.baumgarten
Browse files

new project structure

parent 399a3039
Pipeline #118455 passed with stages
in 10 minutes and 44 seconds
......@@ -51,14 +51,14 @@ include_directories(${PROJECT_SOURCE_DIR}/mlmc/src)
add_subdirectory(mlmc/src)
# Libraries
set(MLMC_LIBRARIES MLMC sprng fftw3 m ${MPP_LIBRARIES})
set(MLMC_TEST_LIBRARIES MLMC sprng fftw3 m ${MPP_TEST_LIBRARIES})
set(MLMC_LIBRARIES PDESOLVER MONTECARLO PROBLEMS MLMC sprng fftw3 m ${MPP_LIBRARIES})
set(MLMC_TEST_LIBRARIES PDESOLVER MONTECARLO PROBLEMS MLMC sprng fftw3 m ${MPP_TEST_LIBRARIES})
# Executables
add_executable(MLMC-M++ mlmc/src/Main.cpp)
# Linking
target_link_libraries(MLMC-M++ ${MLMC_LIBRARIES} PDESOLVER)
target_link_libraries(MLMC-M++ ${MLMC_LIBRARIES})
# Tests
if (BUILD_MLMC_TESTS)
......
include_directories(problems)
add_subdirectory(problems)
include_directories(pdesolver)
add_subdirectory(pdesolver)
include_directories(problems)
add_subdirectory(problems)
include_directories(montecarlo)
add_subdirectory(montecarlo)
include(main/CMakeLists.txt)
include(montecarlo/CMakeLists.txt)
add_library(MLMC STATIC ${assemble} ${main}
${montecarlo} ${problem} ${generators})
add_library(MLMC STATIC ${main})
target_link_libraries(MLMC PDESOLVER)
#ifndef PLOTMAP_HPP
#define PLOTMAP_HPP
#include "Sample.hpp"
#include "SampleID.hpp"
#include "Plot.hpp"
#include "dof/LagrangeDoF.hpp"
......
#ifndef SAMPLEID_HPP
#define SAMPLEID_HPP
#include "basics/Level.hpp"
#include <string>
struct SampleID {
Level level;
int number;
bool coarse;
SampleID() {}
SampleID(Level level, int number, bool coarse) :
level(level), number(number), coarse(coarse) {}
int MGLevel() const {
return level.MGLevel(coarse);
}
std::string Str() const {
return "l:" + std::to_string(level.fine) +
"-m:" + std::to_string(number) +
"-c:" + std::to_string((int) coarse);
}
};
#endif //SAMPLEID_HPP
#include "Utils.hpp"
#define REAL 0
#define IMAG 1
using namespace std;
double calc_mean(const vector<double> &vec) {
double mean_ = 0.0;
for (auto const &value: vec)
mean_ += value;
return mean_ / vec.size();
}
double calc_mean(const vector<vector<double>> &vec) {
double mean_ = 0.0;
for (auto const &v: vec)
for (auto const &value : v)
mean_ += value;
return mean_ / vec.size() / vec[0].size();
}
double calc_mean(const vector<int> &vec) {
double mean_ = 0.0;
for (auto const &value: vec)
mean_ += value;
return mean_ / vec.size();
}
double calc_mean(const vector<vector<int>> &vec) {
double mean_ = 0.0;
for (auto const &v: vec)
for (auto const &value : v)
mean_ += value;
return mean_ / vec.size() / vec[0].size();
}
double calc_var(const vector<double> &vec) {
double sqrs_ = 0.0;
for (auto const &value: vec)
sqrs_ += pow(value, 2);
return sqrs_ / vec.size() - pow(calc_mean(vec), 2);
}
double calc_var(const vector<vector<double>> &vec) {
double sqrs_ = 0.0;
for (auto const &v: vec)
for (auto const &value :v)
sqrs_ += pow(value, 2);
return sqrs_ / vec.size() / vec[0].size() - pow(calc_mean(vec), 2);
}
double calc_var(const vector<int> &vec) {
double sqrs_ = 0.0;
for (auto const &value: vec)
sqrs_ += pow(value, 2);
return sqrs_ / vec.size() - pow(calc_mean(vec), 2);
}
double calc_var(const vector<vector<int>> &vec) {
double sqrs_ = 0.0;
for (auto const &v: vec)
for (auto const &value :v)
sqrs_ += pow(value, 2);
return sqrs_ / vec.size() / vec[0].size() - pow(calc_mean(vec), 2);
}
template<>
std::string vec2str<int>(vector<int> vec) {
std::string str = "[";
......
set(montecarlo
montecarlo/MonteCarlo.cpp
montecarlo/MultilevelMonteCarlo.cpp
montecarlo/EmpiricMeasures.cpp
montecarlo/EmpiricMeasureLevelMaps.cpp
montecarlo/Exponents.cpp
montecarlo/Errors.cpp
montecarlo/PlotMap.cpp
)
\ No newline at end of file
add_library(MONTECARLO STATIC
MonteCarlo.cpp
MultilevelMonteCarlo.cpp
datastructure/Errors.cpp
datastructure/Exponents.cpp
datastructure/EmpiricMeasures.cpp
datastructure/EmpiricMeasureLevelMaps.cpp
)
target_link_libraries(MONTECARLO ${MLMC_LIBRARIES})
#ifndef MLMC_MC_HPP
#define MLMC_MC_HPP
#include "EmpiricMeasures.hpp"
#include "montecarlo/datastructure/EmpiricMeasures.hpp"
#include "pdesolver/PDESolver.hpp"
......
......@@ -2,9 +2,9 @@
#define MULTILEVELMONTECARLO_HPP
#include "montecarlo/MonteCarlo.hpp"
#include "EmpiricMeasureLevelMaps.hpp"
#include "Exponents.hpp"
#include "Errors.hpp"
#include "montecarlo/datastructure/EmpiricMeasureLevelMaps.hpp"
#include "montecarlo/datastructure/Exponents.hpp"
#include "montecarlo/datastructure/Errors.hpp"
#include "main/Utils.hpp"
......
......@@ -2,8 +2,8 @@
#define EMPIRICMEASURELEVELMAPS_HPP
#include "EmpiricMeasures.hpp"
#include "LevelMap.hpp"
#include "MonteCarlo.hpp"
#include "basics/LevelMap.hpp"
#include "montecarlo/MonteCarlo.hpp"
#include <math.h>
......
#ifndef EMPIRICMEASURES_HPP
#define EMPIRICMEASURES_HPP
#include "Sample.hpp"
#include "pdesolver/SampleSolution.hpp"
struct SampleCounter {
......
#ifndef PDESOLVER_HPP
#define PDESOLVER_HPP
#include "montecarlo/Sample.hpp"
#include "SampleSolution.hpp"
// General solving approaches
#include "dof/BasicDoFs.hpp"
......@@ -23,7 +23,7 @@
#include "assembling/DGReactionAssemble.hpp"
#include "assembling/PGReactionAssemble.hpp"
#include "montecarlo/PlotMap.hpp"
#include "basics/PlotMap.hpp"
#include <typeinfo>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment