Files
karl/include/functions/functions.h
T
2024-12-04 17:15:04 +01:00

41 lines
1.5 KiB
C++
Executable File
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#ifndef FUNCTIONS_H
#define FUNCTIONS_H
#include <functional>
#include <vector>
// R^1 -> R^1 mappings
namespace D1ToD1 {
// return a function defined at the vector positions with the vector values
// which interpolates linearly between those values
// both vectors have to be sorted according to the values in positions
std::function<double(double)> PiecewiseLinear(std::vector<double> positions,
std::vector<double> values);
// return a function, that always returns the constant value "constant"
std::function<double(double)> Constant(double constant);
// return a function returning the product of the values defined by the functions
// in the vector "functions"
std::function<double(double)> Product(
std::vector<std::function<double(double)>> functions);
}; // namespace D1ToD1
// R^3 -> R^1 mappings
namespace D3ToD1 {
// return a function, that always returns the constant value "constant"
std::function<double(double, double, double)> Constant(double value);
// return a function that returns the product of the values of the functions fi, fj and fk
// fi calculates its value from the first parameter the function "Product" returns gets,
// fj from the second parameter and
// fk from the third
std::function<double(double, double, double)> Product(
std::function<double(double)> fi,
std::function<double(double)> fj,
std::function<double(double)> fk);
}; // namespace D3ToD1
#endif /* FUNCTIONS_H */