Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:10:18

0001 // @(#)root/mathmore:$Id$
0002 // Authors: L. Moneta, A. Zsenei   08/2005
0003 
0004  /**********************************************************************
0005   *                                                                    *
0006   * Copyright (c) 2004 ROOT Foundation,  CERN/PH-SFT                   *
0007   *                                                                    *
0008   * This library is free software; you can redistribute it and/or      *
0009   * modify it under the terms of the GNU General Public License        *
0010   * as published by the Free Software Foundation; either version 2     *
0011   * of the License, or (at your option) any later version.             *
0012   *                                                                    *
0013   * This library is distributed in the hope that it will be useful,    *
0014   * but WITHOUT ANY WARRANTY; without even the implied warranty of     *
0015   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU   *
0016   * General Public License for more details.                           *
0017   *                                                                    *
0018   * You should have received a copy of the GNU General Public License  *
0019   * along with this library (see file COPYING); if not, write          *
0020   * to the Free Software Foundation, Inc., 59 Temple Place, Suite      *
0021   * 330, Boston, MA 02111-1307 USA, or contact the author.             *
0022   *                                                                    *
0023   **********************************************************************/
0024 
0025 // Header file for class Interpolator
0026 //
0027 // Created by: moneta  at Fri Nov 26 15:00:25 2004
0028 //
0029 // Last update: Fri Nov 26 15:00:25 2004
0030 //
0031 #ifndef ROOT_Math_Interpolator
0032 #define ROOT_Math_Interpolator
0033 
0034 #include "Math/InterpolationTypes.h"
0035 
0036 #include <vector>
0037 #include <string>
0038 
0039 /**
0040 @defgroup Interpolation Interpolation Classes
0041 
0042 Classes for interpolation of points
0043 
0044 @ingroup NumAlgo
0045 */
0046 
0047 
0048 namespace ROOT {
0049 namespace Math {
0050 
0051 
0052    class GSLInterpolator;
0053 
0054 //_____________________________________________________________________________________
0055    /**
0056       Class for performing function interpolation of points.
0057       The class is instantiated with an interpolation methods, passed as an enumeration in the constructor.
0058       See Interpolation::Type for the available interpolation algorithms, which are implemented using GSL.
0059       See also the <A HREF=http://www.gnu.org/software/gsl/manual/html_node/Interpolation.html">GSL manual</A> for more information.
0060       The class provides additional methods for computing derivatives and integrals of interpolating functions.
0061 
0062       This class does not support copying.
0063       @ingroup Interpolation
0064    */
0065 
0066 class Interpolator {
0067 
0068 public:
0069 
0070    /**
0071       Constructs an interpolator class from  number of data points and with Interpolation::Type type.
0072       The data can be set later on with the SetData method.
0073       In case the data size is not known, better using the default of zero or the next constructor later on.
0074       The default interpolation type is Cubic spline
0075    */
0076    Interpolator(unsigned int ndata = 0, Interpolation::Type type = Interpolation::kCSPLINE);
0077 
0078    /**
0079       Constructs an interpolator class from vector of data points \f$ (x_i, y_i )\f$ and with Interpolation::Type type.
0080       The method will compute a continuous interpolating function \f$ y(x) \f$ such that \f$ y_i = y ( x_i )\f$.
0081       The default interpolation type is Cubic spline
0082    */
0083    Interpolator(const std::vector<double> & x, const std::vector<double> & y, Interpolation::Type type = Interpolation::kCSPLINE);
0084 
0085    virtual ~Interpolator();
0086 
0087 private:
0088    // usually copying is non trivial, so we make this unaccessible
0089    Interpolator(const Interpolator &);
0090    Interpolator & operator = (const Interpolator &);
0091 
0092 public:
0093 
0094    /**
0095       Set the data vector ( x[] and y[] )
0096       To be efficient, the size of the data must be the same of the value used in the constructor (ndata)
0097       If this is not  the case a new re-initialization is performed with the new data size
0098     */
0099    bool SetData(const std::vector<double> & x, const std::vector<double> & y);
0100 
0101    /**
0102       Set the data vector ( x[] and y[] )
0103       To be efficient, the size of the data must be the same of the value used when  constructing the class (ndata)
0104       If this is not  the case a new re-initialization is performed with the new data size.
0105     */
0106    bool SetData(unsigned int ndata, const double * x, const double *  y);
0107 
0108    /**
0109       Return the interpolated value at point x
0110    */
0111    double Eval( double x ) const;
0112 
0113    /**
0114       Return the derivative of the interpolated function at point x
0115    */
0116    double Deriv( double x ) const;
0117 
0118    /**
0119       Return the second derivative of the interpolated function at point x
0120    */
0121    double Deriv2( double x ) const;
0122 
0123    /**
0124       Return the Integral of the interpolated function over the range [a,b]
0125    */
0126    double Integ( double a, double b) const;
0127 
0128    /**
0129       Return the type of interpolation method
0130    */
0131    std::string Type() const;
0132    std::string TypeGet() const;
0133 
0134 protected:
0135 
0136 
0137 private:
0138 
0139    GSLInterpolator * fInterp;   // pointer to GSL interpolator class
0140 
0141 };
0142 
0143 } // namespace Math
0144 } // namespace ROOT
0145 
0146 
0147 #endif /* ROOT_Math_Interpolator */