00001 /* 00002 00003 Class FInterpolate produces a linear interpolations of any given function f(x) on the interval [a,b] 00004 where [a,b] is divided into N equal length subintervals. 00005 00006 Author: John Spitler 3/26/2012 00007 00008 */ 00009 00010 #ifndef _FInterpolate 00011 #define _FInterpolate 00012 00013 #include <assert.h> 00014 #include "sfunctions.h" 00015 00016 00017 class FInterpolate : public Function1D 00018 { 00019 private: 00020 Function1D &_f; // 1D function to be interpolated 00021 double _a, _b; // Interval over which interpolation is to take place 00022 unsigned _N; // Number of subintervals to be used in the interpolation 00023 double _dx; // subinterval size 00024 VecDouble _fVals; // Vector containing values of f at interpolation points 00025 00026 public: 00027 FInterpolate(Function1D &f, double a, double b, unsigned N); 00028 00029 virtual double operator()(double x, unsigned cmp) const; 00030 00031 virtual bool isInDomain(double x, unsigned cmp) const; 00032 00033 virtual ~FInterpolate(); 00034 }; 00035 00036 #endif