Commit 090b6cf4 authored by niklas.baumgarten's avatar niklas.baumgarten
Browse files

removed basics lib

parent 65a65deb
Pipeline #149256 failed with stages
in 15 minutes
add_subdirectory(basics)
add_subdirectory(generators)
add_subdirectory(problems)
add_subdirectory(pdesolver)
......
add_library(BASICS STATIC
Utilities.cpp
)
target_link_libraries(BASICS MPP_LIBRARIES)
\ No newline at end of file
#include "Utilities.hpp"
#include <sstream>
template<>
std::string vec2str<int>(std::vector<int> vec) {
std::string str = "[";
for (unsigned long i = 0; i < vec.size(); i++) {
if (i != vec.size() - 1) str += std::to_string(vec[i]) + ", ";
else str += std::to_string(vec[i]);
}
return (str + "]");
}
template<>
std::string vec2str<double>(std::vector<double> vec) {
std::string str = "[";
for (unsigned long i = 0; i < vec.size(); i++) {
std::ostringstream streamObj;
if (i != vec.size() - 1) {
streamObj << vec[i];
str += streamObj.str() + ", ";
}
else {
streamObj << vec[i];
str += streamObj.str();
}
}
return (str + "]");
}
template<>
std::string vec2str<std::string>(std::vector<std::string> vec) {
std::string str = "[";
for (unsigned long i = 0; i < vec.size(); i++) {
if (i != vec.size() - 1) str += vec[i] + ", ";
else str += vec[i];
}
return (str + "]");
}
#ifndef TOOLS_HPP
#define TOOLS_HPP
#include "RVector.hpp"
#include "CVector.hpp"
#include "RMatrix.hpp"
#include "CMatrix.hpp"
#include <vector>
#include <string>
#include <math.h>
template<typename T>
std::string vec2str(std::vector<T> vec);
#endif //TOOLS_HPP
......@@ -5,7 +5,6 @@
#include "MonteCarlo.hpp"
#include "Exponents.hpp"
#include "MultilevelErrors.hpp"
#include "Utilities.hpp"
#include "Estimator.hpp"
......
......@@ -2,6 +2,43 @@
#include "MultilevelEstimator.hpp"
template<>
std::string vec2str<int>(std::vector<int> vec) {
std::string str = "[";
for (unsigned long i = 0; i < vec.size(); i++) {
if (i != vec.size() - 1) str += std::to_string(vec[i]) + ", ";
else str += std::to_string(vec[i]);
}
return (str + "]");
}
template<>
std::string vec2str<double>(std::vector<double> vec) {
std::string str = "[";
for (unsigned long i = 0; i < vec.size(); i++) {
std::ostringstream streamObj;
if (i != vec.size() - 1) {
streamObj << vec[i];
str += streamObj.str() + ", ";
}
else {
streamObj << vec[i];
str += streamObj.str();
}
}
return (str + "]");
}
template<>
std::string vec2str<std::string>(std::vector<std::string> vec) {
std::string str = "[";
for (unsigned long i = 0; i < vec.size(); i++) {
if (i != vec.size() - 1) str += vec[i] + ", ";
else str += vec[i];
}
return (str + "]");
}
void EstimatorMap::UpdateSampleCounter(double epsilon) {
int optimalM;
......@@ -68,3 +105,15 @@ void KurtosisMap::Update(const EstimatorMap &estimatorMap) {
for (auto &[level, estimator]: estimatorMap)
_levelMap[level] = estimator->aggregate.kurtosis;
}
void MultilevelData::MultilevelResults() const {
mout.PrintInfo("Multilevel Results", 1,
PrintInfoEntry("E(Qf-Qc)", vec2str(means.GetYVector())),
PrintInfoEntry("E(Qf)", vec2str(means.GetQVector())),
PrintInfoEntry("V(Qf-Qc)", vec2str(sVars.GetYVector())),
PrintInfoEntry("V(Qf)", vec2str(sVars.GetQVector())),
PrintInfoEntry("kurtosis", vec2str(kurtosis.GetYVector())),
PrintInfoEntry("E(cost)", vec2str(means.GetCostVector())),
PrintInfoEntry("Used Levels", vec2str(means.GetLevelVector())),
PrintInfoEntry("Used Samples", vec2str(ctrs.GetMVector())));
}
......@@ -121,7 +121,8 @@ public:
}
};
template<typename T>
std::string vec2str(std::vector<T> vec);
struct EstimatorMap;
......@@ -207,17 +208,7 @@ struct MultilevelData {
kurtosis.Update(estimatorMap);
}
void MultilevelResults() const {
mout.PrintInfo("Multilevel Results", 1,
PrintInfoEntry("E(Qf-Qc)", vec2str(means.GetYVector())),
PrintInfoEntry("E(Qf)", vec2str(means.GetQVector())),
PrintInfoEntry("V(Qf-Qc)", vec2str(sVars.GetYVector())),
PrintInfoEntry("V(Qf)", vec2str(sVars.GetQVector())),
PrintInfoEntry("kurtosis", vec2str(kurtosis.GetYVector())),
PrintInfoEntry("E(cost)", vec2str(means.GetCostVector())),
PrintInfoEntry("Used Levels", vec2str(means.GetLevelVector())),
PrintInfoEntry("Used Samples", vec2str(ctrs.GetMVector())));
}
void MultilevelResults() const;
friend Logging &operator<<(Logging &s, const MultilevelData &data) {
return s << "E(Qf-Qc)=" << data.means.GetYVector() << endl
......
#ifndef WELFORDAGGREGATE_HPP
#define WELFORDAGGREGATE_HPP
#include "basics/Sample.hpp"
#include "Sample.hpp"
#include "Parallel.hpp"
......
......@@ -6,4 +6,4 @@ add_library(GENERATORS STATIC
algorithms/SymmetricCovariance.cpp
algorithms/HybridFluxGenerator.cpp
)
target_link_libraries(GENERATORS BASICS PDESOLVER sprng MPP_LIBRARIES)
target_link_libraries(GENERATORS PDESOLVER sprng MPP_LIBRARIES)
......@@ -3,9 +3,8 @@
#include "SymmetricCovariance.hpp"
#include "LagrangeDiscretization.hpp"
#include "basics/Utilities.hpp"
#include "Algebra.hpp"
#include "generators/NormalDistribution.hpp"
#include "NormalDistribution.hpp"
#include "FFT.hpp"
......
#ifndef M_COVARIANCEFUNCTION_H
#define M_COVARIANCEFUNCTION_H
#include "basics/Utilities.hpp"
#include "Assertion.hpp"
#include "RVector.hpp"
#include "CVector.hpp"
......
......@@ -5,7 +5,7 @@
#include "assembling/IStochasticDummyAssemble.hpp"
// Imports from basics
#include "basics/Sample.hpp"
#include "Sample.hpp"
// Mpp imports
#include "TimeIntegrator.hpp"
......
......@@ -3,4 +3,4 @@ add_library(PROBLEMS STATIC
StochasticEllipticProblem.cpp
StochasticTransportProblem.cpp
)
target_link_libraries(PROBLEMS GENERATORS ${MPP_LIBRARIES})
target_link_libraries(PROBLEMS GENERATORS MPP_LIBRARIES)
......@@ -2,7 +2,6 @@
#define ISTOCHASTICPROBLEM_HPP
#include "Sample.hpp"
#include "Utilities.hpp"
#include "SampleGeneratorContainer.hpp"
#include "Algebra.hpp"
......@@ -14,13 +13,11 @@ protected:
const Meshes &meshes;
GeneratorNames genNames;
SampleGeneratorContainer genContainer;
public:
IStochasticProblem(Meshes &meshes, GeneratorNames genNames) :
meshes(meshes), genNames(genNames), genContainer(genNames, meshes) {
meshes(meshes), genContainer(genNames, meshes) {
config.get("ProblemVerbose", verbose);
}
......@@ -28,12 +25,6 @@ public:
genContainer.DrawSample(id);
}
virtual void PrintInfo() const {
mout.PrintInfo("Stochastic Problem", verbose,
PrintInfoEntry("Problem Name", Name()),
PrintInfoEntry("Generators", vec2str(genNames)));
};
virtual string Name() const = 0;
};
......
......@@ -9,8 +9,7 @@ file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/mlmc/tests/data/vtu)
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/mlmc/tests/log)
# ------- Unit Tests -------
add_mpp_test(basics/TestPlotting BASICS)
add_mpp_test(generators/TestPlotting GENERATORS)
add_mpp_test(generators/TestNormalDistribution GENERATORS)
add_mpp_test(generators/TestUniformDistribution GENERATORS)
add_mpp_test(generators/TestCirculantEmbedding GENERATORS)
......
// Todo
\ No newline at end of file
#include "generators/NormalDistribution.hpp"
#include "basics/Utilities.hpp"
#include "TestEnvironment.hpp"
#include "MeshesCreator.hpp"
......
#include "basics/Sample.hpp"
#include "Sample.hpp"
#include "RTLagrangeDiscretization.hpp"
#include "LagrangeDiscretization.hpp"
......
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