Interpolator.cxx

Go to the documentation of this file.
00001 // @(#)root/mathmore:$Id: Interpolator.cxx 21637 2008-01-11 09:56:31Z moneta $
00002 // Authors: L. Moneta, A. Zsenei   08/2005
00003 
00004  /**********************************************************************
00005   *                                                                    *
00006   * Copyright (c) 2004 ROOT Foundation,  CERN/PH-SFT                   *
00007   *                                                                    *
00008   * This library is free software; you can redistribute it and/or      *
00009   * modify it under the terms of the GNU General Public License        *
00010   * as published by the Free Software Foundation; either version 2     *
00011   * of the License, or (at your option) any later version.             *
00012   *                                                                    *
00013   * This library is distributed in the hope that it will be useful,    *
00014   * but WITHOUT ANY WARRANTY; without even the implied warranty of     *
00015   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU   *
00016   * General Public License for more details.                           *
00017   *                                                                    *
00018   * You should have received a copy of the GNU General Public License  *
00019   * along with this library (see file COPYING); if not, write          *
00020   * to the Free Software Foundation, Inc., 59 Temple Place, Suite      *
00021   * 330, Boston, MA 02111-1307 USA, or contact the author.             *
00022   *                                                                    *
00023   **********************************************************************/
00024 
00025 // Implementation file for class Interpolator using GSL
00026 //
00027 // Created by: moneta  at Fri Nov 26 15:00:25 2004
00028 //
00029 // Last update: Fri Nov 26 15:00:25 2004
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    // allocate GSL interpolaiton object 
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    // allocate and initialize GSL interpolation object with data
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    // destructor (delete underlined obj)
00060    if (fInterp) delete fInterp;
00061 }
00062 
00063 Interpolator::Interpolator(const Interpolator &)
00064 {
00065 }
00066 
00067 Interpolator & Interpolator::operator = (const Interpolator &rhs)
00068 {
00069    // dummy (private) assignment 
00070    if (this == &rhs) return *this;  // time saving self-test
00071    
00072    return *this;
00073 }
00074 
00075 bool Interpolator::SetData(unsigned int ndata, const double * x, const double *y) { 
00076    // set the interpolation data
00077    return fInterp->Init(ndata, x, y); 
00078 }
00079 bool Interpolator::SetData(const std::vector<double> & x, const std::vector<double> &y) { 
00080    // set the interpolation data
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    // forward evaluation
00089    return fInterp->Eval(x);
00090 }
00091 
00092 double Interpolator::Deriv( double x ) const
00093 {
00094    // forward deriv evaluation   
00095    return fInterp->Deriv(x);
00096 }
00097 
00098 double Interpolator::Deriv2( double x ) const {
00099    // forward deriv evaluation   
00100    return fInterp->Deriv2(x);
00101 }
00102 
00103 double Interpolator::Integ( double a, double b) const {
00104    // forward integ evaluation
00105    return fInterp->Integ(a,b);
00106 }
00107 
00108 std::string  Interpolator::TypeGet() const {
00109    // forward name request
00110    return fInterp->Name();
00111 }
00112 std::string  Interpolator::Type() const {
00113    // forward name request
00114    return fInterp->Name();
00115 }
00116 
00117 
00118 
00119 } // namespace Math
00120 } // namespace ROOT

Generated on Tue Jul 5 14:34:57 2011 for ROOT_528-00b_version by  doxygen 1.5.1