/*************************************************************************** aon_interpolation.h - wrapper around the GSL interpolation functions ------------------- begin : 2004-02-17 copyright : (C) 2004 by Andrew O'Neill, HiRes Grad Student email : oneill@phys.columbia.edu ***************************************************************************/ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef AON_INTERPOLATION_H #define AON_INTERPOLATION_H using namespace std; #include "aon_debug.h" #include "gsl/gsl_integration.h" #include "gsl/gsl_errno.h" #include "gsl/gsl_spline.h" #include /////////////////////////////////////////////////////////////////////////////// // // NOTE: // There's a design decision here that each different function to be // interploatedshould just be a derived class from Interpolation // The alternative would be to have a pointer to a function rather than a // virtual function. The "C++ way" is to use virtual functions, but perhaps // pointers to functions would make more sense here // /////////////////////////////////////////////////////////////////////////////// /// Class: Interpolation /// Wrapper for gsl interpolation functions /// Usage: define a derived class and over-ride the abstract BuildSpline() /// function to produce the function you wish to interpolate class Interpolation { public: Interpolation(const int NumPoints, const gsl_interp_type *InterpType); Interpolation(const int NumPoints); virtual ~Interpolation(); // Build the spline according with the values we wish to interpolate // This function must be over-ridden by derived classes // The ArgList is a list of arguments that may be required to make the // spline... i.e. a function f(x,y,z) will be interpolated in x for fixed // values of y & z, we need to know those values here. // the example of this is my BremSpectrumIterpolation_c::BuildSpline() virtual int BuildSpline (const double& LowerBound, const double& UpperBound, list& ArgList) = 0; // Give us the interpolated value of the function at point x double Evaluate (const double& Arg); double EvaluateIntegral(const double& a, const double& b); int getNumPoints(void) { return itsNumPoints; } int checkInitialized(void) {return itsInitializedFlag;} double EvaluateMaximum() { return itsMaximum; } // having problems with inheritance here protected: gsl_spline *itsSpline; // required by internals of gsl interpolation gsl_interp_accel* itsAccel;// required by internals of gsl interpolation int itsNumPoints; // the number of points to use in iterpolation int itsInitializedFlag; // flag that tells us if we're ready to // use the interpolation // ( set by BuildSpline() ) double itsMaximum; // maximum value of interpolated function // to be filled during BuildSpline() }; #endif