Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-18 09:31:38

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    // usually copying is non trivial, so we delete this
0088    Interpolator(const Interpolator &) = delete;
0089    Interpolator & operator = (const Interpolator &) = delete;
0090    Interpolator(Interpolator &&) = delete;
0091    Interpolator & operator = (Interpolator &&) = delete;
0092 
0093    /**
0094       Set the data vector ( x[] and y[] )
0095       To be efficient, the size of the data must be the same of the value used in the constructor (ndata)
0096       If this is not  the case a new re-initialization is performed with the new data size
0097     */
0098    bool SetData(const std::vector<double> & x, const std::vector<double> & y);
0099 
0100    /**
0101       Set the data vector ( x[] and y[] )
0102       To be efficient, the size of the data must be the same of the value used when  constructing the class (ndata)
0103       If this is not  the case a new re-initialization is performed with the new data size.
0104     */
0105    bool SetData(unsigned int ndata, const double * x, const double *  y);
0106 
0107    /**
0108       Return the interpolated value at point x
0109    */
0110    double Eval( double x ) const;
0111 
0112    /**
0113       Return the derivative of the interpolated function at point x
0114    */
0115    double Deriv( double x ) const;
0116 
0117    /**
0118       Return the second derivative of the interpolated function at point x
0119    */
0120    double Deriv2( double x ) const;
0121 
0122    /**
0123       Return the Integral of the interpolated function over the range [a,b]
0124    */
0125    double Integ( double a, double b) const;
0126 
0127    /**
0128       Return the type of interpolation method
0129    */
0130    std::string Type() const;
0131    std::string TypeGet() const;
0132 
0133 protected:
0134 
0135 
0136 private:
0137 
0138    GSLInterpolator * fInterp;   // pointer to GSL interpolator class
0139 
0140 };
0141 
0142 } // namespace Math
0143 } // namespace ROOT
0144 
0145 
0146 #endif /* ROOT_Math_Interpolator */