#include "Math/IFunction.h"
#include "Math/Chebyshev.h"
#include "GSLFunctionWrapper.h"
#include "GSLChebSeries.h"
#include "gsl/gsl_chebyshev.h"
#include <cassert>
namespace ROOT {
namespace Math {
Chebyshev::Chebyshev(const ROOT::Math::IGenFunction & f, double a, double b, size_t n) :
fOrder(n) , fSeries(0), fFunction(0)
{
fSeries = new GSLChebSeries(n);
GSLFunctionAdapter<ROOT::Math::IGenFunction> adapter;
const void * p = &f;
Initialize( &adapter.F, const_cast<void *>(p), a, b );
}
Chebyshev::Chebyshev(GSLFuncPointer f, void * params, double a, double b, size_t n) :
fOrder(n) , fSeries(0), fFunction(0)
{
fSeries = new GSLChebSeries(n);
Initialize( f, params, a, b );
}
Chebyshev::~Chebyshev()
{
if (fFunction) delete fFunction;
if (fSeries) delete fSeries;
}
Chebyshev::Chebyshev(size_t n) :
fOrder(n) , fSeries(0), fFunction(0)
{
fSeries = new GSLChebSeries(n);
}
Chebyshev::Chebyshev(const Chebyshev & )
{
}
Chebyshev & Chebyshev::operator = (const Chebyshev &rhs)
{
if (this == &rhs) return *this;
return *this;
}
void Chebyshev::Initialize( GSLFuncPointer f, void * params, double a, double b) {
assert(fSeries != 0);
if (fFunction) delete fFunction;
fFunction = new GSLFunctionWrapper();
fFunction->SetFuncPointer( f );
fFunction->SetParams( params );
gsl_cheb_init( fSeries->get(), fFunction->GetFunc(), a, b);
}
double Chebyshev::operator() ( double x ) const {
return gsl_cheb_eval(fSeries->get(), x);
}
std::pair<double, double> Chebyshev::EvalErr( double x) const {
double result, error;
gsl_cheb_eval_err(fSeries->get(), x, &result, &error);
return std::make_pair( result, error);
}
double Chebyshev::operator() ( double x, size_t n) const {
return gsl_cheb_eval_n(fSeries->get(), n, x);
}
std::pair<double, double> Chebyshev::EvalErr( double x, size_t n) const {
double result, error;
gsl_cheb_eval_n_err(fSeries->get(), n, x, &result, &error);
return std::make_pair( result, error);
}
Chebyshev * Chebyshev::Deriv() {
Chebyshev * deriv = new Chebyshev(fOrder);
gsl_cheb_calc_deriv( (deriv->fSeries)->get(), fSeries->get() );
return deriv;
}
Chebyshev * Chebyshev::Integral() {
Chebyshev * integ = new Chebyshev(fOrder);
gsl_cheb_calc_integ( (integ->fSeries)->get(), fSeries->get() );
return integ;
}
}
}
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.