1 #ifndef _utl_PolynomialInterpolation_h_
2 #define _utl_PolynomialInterpolation_h_
5 #include <utl/ErrorLogger.h>
34 const double x,
double& dy)
39 double minDist = std::fabs(x - px[0]);
46 for (
unsigned int i = 1; i < n; ++i) {
47 const double newx = px[i];
49 ERROR(
"x values should be distinct.");
53 const double dist = std::fabs(x - newx);
63 for (
unsigned int m = 1;
m < n; ++
m) {
64 const unsigned int nm = n -
m;
65 for (
unsigned int i = 0; i < nm; ++i) {
66 const double xa = px[i];
67 const double xb = px[i+
m];
68 const double dx = xb - xa;
69 const double cd = (c[i+1] - d[i]) / dx;
73 dy = (2*k < nm) ? c[k] : d[--k];
double PolynomialInterpolation(const unsigned int n, const double px[], const double py[], const double x, double &dy)
Perform polynomial interpolation or extrapolation.
#define ERROR(message)
Macro for logging error messages.