#pragma once #include "./numerics/interpolation1d/interpolation1d_base.h" namespace numerics{ template struct interp_linear : Base_interp { using Base = Base_interp; // bring base data members into scope (or use this->xx / this->yy below) using Base::xx; using Base::yy; interp_linear(const utils::Vector &xv, const utils::Vector &yv): Base_interp(xv, &yv[0], 2){} T rawinterp(int64_t j, T x) override{ if (xx[j]==xx[j+1]){ return yy[j]; // Table is defective, but we can recover. }else { return (yy[j] + ((x-xx[j])/(xx[j+1]-xx[j]))*(yy[j+1]-yy[j])); } } }; } // namespace numerics