6 #ifndef MATHS_INTERPOLATION_LINEAR_H
7 #define MATHS_INTERPOLATION_LINEAR_H
11 namespace Interpolation
25 Linear(
int n,
double *x,
double *y) {
30 for (
int i = 0; i < n; ++i) {
49 while (x > m_x[++i] && i < size-1);
51 double a = (x - m_x[i - 1]) / (m_x[i] - m_x[i - 1]);
52 return m_y[i - 1] + a * (m_y[i] - m_y[i - 1]);
Linear(int n, double *x, double *y)
Linear interpolation of two arrays.
double getValue(double x)