Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
Interpolator.h
Go to the documentation of this file.
1// @(#)root/mathmore:$Id$
2// Authors: L. Moneta, A. Zsenei 08/2005
3
4 /**********************************************************************
5 * *
6 * Copyright (c) 2004 ROOT Foundation, CERN/PH-SFT *
7 * *
8 * This library is free software; you can redistribute it and/or *
9 * modify it under the terms of the GNU General Public License *
10 * as published by the Free Software Foundation; either version 2 *
11 * of the License, or (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16 * General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU General Public License *
19 * along with this library (see file COPYING); if not, write *
20 * to the Free Software Foundation, Inc., 59 Temple Place, Suite *
21 * 330, Boston, MA 02111-1307 USA, or contact the author. *
22 * *
23 **********************************************************************/
24
25// Header file for class Interpolator
26//
27// Created by: moneta at Fri Nov 26 15:00:25 2004
28//
29// Last update: Fri Nov 26 15:00:25 2004
30//
31#ifndef ROOT_Math_Interpolator
32#define ROOT_Math_Interpolator
33
35
36#include <vector>
37#include <string>
38
39/**
40@defgroup Interpolation Interpolation Classes
41
42Classes for interpolation of points
43
44@ingroup NumAlgo
45*/
46
47
48namespace ROOT {
49namespace Math {
50
51
52 class GSLInterpolator;
53
54//_____________________________________________________________________________________
55 /**
56 Class for performing function interpolation of points.
57 The class is instantiated with an interpolation methods, passed as an enumeration in the constructor.
58 See Interpolation::Type for the available interpolation algorithms, which are implemented using GSL.
59 See also the <A HREF=http://www.gnu.org/software/gsl/manual/html_node/Interpolation.html">GSL manual</A> for more information.
60 The class provides additional methods for computing derivatives and integrals of interpolating functions.
61
62 This class does not support copying.
63 @ingroup Interpolation
64 */
65
67
68public:
69
70 /**
71 Constructs an interpolator class from number of data points and with Interpolation::Type type.
72 The data can be set later on with the SetData method.
73 In case the data size is not known, better using the default of zero or the next constructor later on.
74 The default interpolation type is Cubic spline
75 */
77
78 /**
79 Constructs an interpolator class from vector of data points \f$ (x_i, y_i )\f$ and with Interpolation::Type type.
80 The method will compute a continuous interpolating function \f$ y(x) \f$ such that \f$ y_i = y ( x_i )\f$.
81 The default interpolation type is Cubic spline
82 */
83 Interpolator(const std::vector<double> & x, const std::vector<double> & y, Interpolation::Type type = Interpolation::kCSPLINE);
84
85 virtual ~Interpolator();
86
87 // usually copying is non trivial, so we delete this
88 Interpolator(const Interpolator &) = delete;
92
93 /**
94 Set the data vector ( x[] and y[] )
95 To be efficient, the size of the data must be the same of the value used in the constructor (ndata)
96 If this is not the case a new re-initialization is performed with the new data size
97 */
98 bool SetData(const std::vector<double> & x, const std::vector<double> & y);
99
100 /**
101 Set the data vector ( x[] and y[] )
102 To be efficient, the size of the data must be the same of the value used when constructing the class (ndata)
103 If this is not the case a new re-initialization is performed with the new data size.
104 */
105 bool SetData(unsigned int ndata, const double * x, const double * y);
106
107 /**
108 Return the interpolated value at point x
109 */
110 double Eval( double x ) const;
111
112 /**
113 Return the derivative of the interpolated function at point x
114 */
115 double Deriv( double x ) const;
116
117 /**
118 Return the second derivative of the interpolated function at point x
119 */
120 double Deriv2( double x ) const;
121
122 /**
123 Return the Integral of the interpolated function over the range [a,b]
124 */
125 double Integ( double a, double b) const;
126
127 /**
128 Return the type of interpolation method
129 */
130 std::string Type() const;
131 std::string TypeGet() const;
132
133protected:
134
135
136private:
137
138 GSLInterpolator * fInterp; // pointer to GSL interpolator class
139
140};
141
142} // namespace Math
143} // namespace ROOT
144
145
146#endif /* ROOT_Math_Interpolator */
#define b(i)
Definition RSha256.hxx:100
#define a(i)
Definition RSha256.hxx:99
Interpolation class based on GSL interpolation functions.
double Deriv2(double x) const
Return the second derivative of the interpolated function at point x.
std::string Type() const
Return the type of interpolation method.
bool SetData(const std::vector< double > &x, const std::vector< double > &y)
Set the data vector ( x[] and y[] ) To be efficient, the size of the data must be the same of the val...
double Integ(double a, double b) const
Return the Integral of the interpolated function over the range [a,b].
std::string TypeGet() const
double Deriv(double x) const
Return the derivative of the interpolated function at point x.
double Eval(double x) const
Return the interpolated value at point x.
Interpolator(const Interpolator &)=delete
GSLInterpolator * fInterp
Interpolator & operator=(const Interpolator &)=delete
Interpolator(Interpolator &&)=delete
Interpolator(unsigned int ndata=0, Interpolation::Type type=Interpolation::kCSPLINE)
Constructs an interpolator class from number of data points and with Interpolation::Type type.
Type
Enumeration defining the types of interpolation methods availables.
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17