Logo ROOT   6.18/05
Reference Guide
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
87private:
88 // usually copying is non trivial, so we make this unaccessible
91
92public:
93
94 /**
95 Set the data vector ( x[] and y[] )
96 To be efficient, the size of the data must be the same of the value used in the constructor (ndata)
97 If this is not the case a new re-initialization is performed with the new data size
98 */
99 bool SetData(const std::vector<double> & x, const std::vector<double> & y);
100
101 /**
102 Set the data vector ( x[] and y[] )
103 To be efficient, the size of the data must be the same of the value used when constructing the class (ndata)
104 If this is not the case a new re-initialization is performed with the new data size.
105 */
106 bool SetData(unsigned int ndata, const double * x, const double * y);
107
108 /**
109 Return the interpolated value at point x
110 */
111 double Eval( double x ) const;
112
113 /**
114 Return the derivative of the interpolated function at point x
115 */
116 double Deriv( double x ) const;
117
118 /**
119 Return the second derivative of the interpolated function at point x
120 */
121 double Deriv2( double x ) const;
122
123 /**
124 Return the Integral of the interpolated function over the range [a,b]
125 */
126 double Integ( double a, double b) const;
127
128 /**
129 Return the type of interpolation method
130 */
131 std::string Type() const;
132 std::string TypeGet() const;
133
134protected:
135
136
137private:
138
139 GSLInterpolator * fInterp; // pointer to GSL interpolator class
140
141};
142
143} // namespace Math
144} // namespace ROOT
145
146
147#endif /* ROOT_Math_Interpolator */
#define b(i)
Definition: RSha256.hxx:100
int type
Definition: TGX11.cxx:120
Interpolation class based on GSL interpolation functions.
Class for performing function interpolation of points.
Definition: Interpolator.h:66
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.
GSLInterpolator * fInterp
Definition: Interpolator.h:139
Interpolator & operator=(const Interpolator &)
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
Namespace for new Math classes and functions.
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21
auto * a
Definition: textangle.C:12