added exponential into predefined functions
This commit is contained in:
@@ -12,6 +12,8 @@ std::function<double(double)> Constant(double constant);
|
|||||||
|
|
||||||
std::function<double(double)> Product(
|
std::function<double(double)> Product(
|
||||||
std::vector<std::function<double(double)>> functions);
|
std::vector<std::function<double(double)>> functions);
|
||||||
|
|
||||||
|
std::function<double(double)> Exponential(double prefactor, double scale);
|
||||||
}; // namespace D1ToD1
|
}; // namespace D1ToD1
|
||||||
|
|
||||||
namespace D3ToD1 {
|
namespace D3ToD1 {
|
||||||
|
|||||||
@@ -55,6 +55,10 @@ std::function<double(double)> Product(
|
|||||||
return product;
|
return product;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::function<double(double)> Exponential(double prefactor, double scale) {
|
||||||
|
return [=](double x) { return prefactor * std::exp(scale * x); };
|
||||||
|
}
|
||||||
}; // namespace D1ToD1
|
}; // namespace D1ToD1
|
||||||
|
|
||||||
namespace D3ToD1 {
|
namespace D3ToD1 {
|
||||||
|
|||||||
@@ -71,6 +71,13 @@ std::function<double(double)> function1D(json_t* object) {
|
|||||||
}
|
}
|
||||||
return D1ToD1::Product(functions);
|
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 {
|
} else {
|
||||||
ERROR("This 1d to 1d function is not implemented.");
|
ERROR("This 1d to 1d function is not implemented.");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|||||||
Reference in New Issue
Block a user