added exponential into predefined functions

This commit is contained in:
2024-05-10 14:36:49 +02:00
parent 93a51acbda
commit cac5e6ff5d
3 changed files with 13 additions and 0 deletions
+2
View File
@@ -12,6 +12,8 @@ std::function<double(double)> Constant(double constant);
std::function<double(double)> Product(
std::vector<std::function<double(double)>> functions);
std::function<double(double)> Exponential(double prefactor, double scale);
}; // namespace D1ToD1
namespace D3ToD1 {
+4
View File
@@ -55,6 +55,10 @@ std::function<double(double)> Product(
return product;
};
}
std::function<double(double)> Exponential(double prefactor, double scale) {
return [=](double x) { return prefactor * std::exp(scale * x); };
}
}; // namespace D1ToD1
namespace D3ToD1 {
+7
View File
@@ -71,6 +71,13 @@ std::function<double(double)> function1D(json_t* object) {
}
return D1ToD1::Product(functions);
} else if (json_object_by_path(object, {"Exponential"})) {
DEBUG_LEVEL_2("Creating function1d: Exponential.");
double prefactor = json_double(json_object_by_path(
object, {"Exponential", {"prefactor"}}));
double scale = json_double(json_object_by_path(
object, {"Exponential", {"scale"}}));
return D1ToD1::Exponential(prefactor, scale);
} else {
ERROR("This 1d to 1d function is not implemented.");
return nullptr;