ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Interpolator.cxx
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 // Implementation file for class Interpolator using GSL
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 
32 #include "Math/Interpolator.h"
33 #include "GSLInterpolator.h"
34 
35 
36 namespace ROOT {
37 namespace Math {
38 
40  // allocate GSL interpolaiton object
41  fInterp = new GSLInterpolator(ndata, type);
42 }
43 
44 Interpolator::Interpolator(const std::vector<double> & x, const std::vector<double> & y, Interpolation::Type type)
45 {
46  // allocate and initialize GSL interpolation object with data
47 
48  size_t size = std::min( x.size(), y.size() );
49 
50  fInterp = new GSLInterpolator(size, type);
51 
52  fInterp->Init(size, &x.front(), &y.front() );
53 
54 }
55 
56 
58 {
59  // destructor (delete underlined obj)
60  if (fInterp) delete fInterp;
61 }
62 
64 {
65 }
66 
68 {
69  // dummy (private) assignment
70  if (this == &rhs) return *this; // time saving self-test
71 
72  return *this;
73 }
74 
75 bool Interpolator::SetData(unsigned int ndata, const double * x, const double *y) {
76  // set the interpolation data
77  return fInterp->Init(ndata, x, y);
78 }
79 bool Interpolator::SetData(const std::vector<double> & x, const std::vector<double> &y) {
80  // set the interpolation data
81  size_t size = std::min( x.size(), y.size() );
82  return fInterp->Init(size, &x.front(), &y.front());
83 }
84 
85 
86 double Interpolator::Eval( double x ) const
87 {
88  // forward evaluation
89  return fInterp->Eval(x);
90 }
91 
92 double Interpolator::Deriv( double x ) const
93 {
94  // forward deriv evaluation
95  return fInterp->Deriv(x);
96 }
97 
98 double Interpolator::Deriv2( double x ) const {
99  // forward deriv evaluation
100  return fInterp->Deriv2(x);
101 }
102 
103 double Interpolator::Integ( double a, double b) const {
104  // forward integ evaluation
105  return fInterp->Integ(a,b);
106 }
107 
108 std::string Interpolator::TypeGet() const {
109  // forward name request
110  return fInterp->Name();
111 }
112 std::string Interpolator::Type() const {
113  // forward name request
114  return fInterp->Name();
115 }
116 
117 
118 
119 } // namespace Math
120 } // namespace ROOT
const int ndata
double Eval(double x) const
Return the interpolated value at point x.
static Vc_ALWAYS_INLINE int_v min(const int_v &x, const int_v &y)
Definition: vector.h:433
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...
GSLInterpolator * fInterp
Definition: Interpolator.h:139
double Deriv2(double x) const
double Eval(double x) const
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.
Interpolator & operator=(const Interpolator &)
Class for performing function interpolation of points.
Definition: Interpolator.h:66
double Integ(double a, double b) const
Return the Integral of the interpolated function over the range [a,b].
double Deriv(double x) const
TArc * a
Definition: textangle.C:12
Double_t x[n]
Definition: legend1.C:17
std::string TypeGet() const
bool Init(unsigned int ndata, const double *x, const double *y)
Interpolation class based on GSL interpolation functions.
int type
Definition: TGX11.cxx:120
Type
Enumeration defining the types of interpolation methods availables.
Double_t y[n]
Definition: legend1.C:17
double Deriv(double x) const
Return the derivative of the interpolated function at point x.
double Integ(double a, double b) const
Interpolator(unsigned int ndata=0, Interpolation::Type type=Interpolation::kCSPLINE)
Constructs an interpolator class from number of data points and with Interpolation::Type type...