00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #include "Math/Interpolator.h"
00033 #include "GSLInterpolator.h"
00034
00035
00036 namespace ROOT {
00037 namespace Math {
00038
00039 Interpolator::Interpolator(unsigned int ndata, Interpolation::Type type ) {
00040
00041 fInterp = new GSLInterpolator(ndata, type);
00042 }
00043
00044 Interpolator::Interpolator(const std::vector<double> & x, const std::vector<double> & y, Interpolation::Type type)
00045 {
00046
00047
00048 size_t size = std::min( x.size(), y.size() );
00049
00050 fInterp = new GSLInterpolator(size, type);
00051
00052 fInterp->Init(size, &x.front(), &y.front() );
00053
00054 }
00055
00056
00057 Interpolator::~Interpolator()
00058 {
00059
00060 if (fInterp) delete fInterp;
00061 }
00062
00063 Interpolator::Interpolator(const Interpolator &)
00064 {
00065 }
00066
00067 Interpolator & Interpolator::operator = (const Interpolator &rhs)
00068 {
00069
00070 if (this == &rhs) return *this;
00071
00072 return *this;
00073 }
00074
00075 bool Interpolator::SetData(unsigned int ndata, const double * x, const double *y) {
00076
00077 return fInterp->Init(ndata, x, y);
00078 }
00079 bool Interpolator::SetData(const std::vector<double> & x, const std::vector<double> &y) {
00080
00081 size_t size = std::min( x.size(), y.size() );
00082 return fInterp->Init(size, &x.front(), &y.front());
00083 }
00084
00085
00086 double Interpolator::Eval( double x ) const
00087 {
00088
00089 return fInterp->Eval(x);
00090 }
00091
00092 double Interpolator::Deriv( double x ) const
00093 {
00094
00095 return fInterp->Deriv(x);
00096 }
00097
00098 double Interpolator::Deriv2( double x ) const {
00099
00100 return fInterp->Deriv2(x);
00101 }
00102
00103 double Interpolator::Integ( double a, double b) const {
00104
00105 return fInterp->Integ(a,b);
00106 }
00107
00108 std::string Interpolator::TypeGet() const {
00109
00110 return fInterp->Name();
00111 }
00112 std::string Interpolator::Type() const {
00113
00114 return fInterp->Name();
00115 }
00116
00117
00118
00119 }
00120 }