14#include <boost/scoped_array.hpp>
15#include <gsl/gsl_errno.h>
16#include <gsl/gsl_spline.h>
20namespace CurveFitting {
38 std::string
name()
const override {
return "CubicSpline"; }
39 const std::string
category()
const override {
return "Background"; }
40 void function1D(
double *out,
const double *xValues,
const size_t nData)
const override;
41 void derivative1D(
double *out,
const double *xValues,
size_t nData,
const size_t order)
const override;
42 void setParameter(
size_t i,
const double &
value,
bool explicitlySet =
true)
override;
43 using ParamFunction::setParameter;
46 void setAttribute(
const std::string &attName,
const Attribute &)
override;
49 void setXAttribute(
const size_t index,
double x);
57 void operator()(gsl_spline *spline) { gsl_spline_free(spline); }
58 void operator()(gsl_interp_accel *acc) { gsl_interp_accel_free(acc); }
62 std::shared_ptr<gsl_interp_accel>
m_acc;
71 void reallocGSLObjects(
const int n);
74 void setupInput(boost::scoped_array<double> &x, boost::scoped_array<double> &y,
int n)
const;
77 void calculateSpline(
double *out,
const double *xValues,
const size_t nData)
const;
80 void calculateDerivative(
double *out,
const double *xValues,
const size_t nData,
const size_t order)
const;
83 void initGSLObjects(boost::scoped_array<double> &x, boost::scoped_array<double> &y,
int n)
const;
86 void checkGSLError(
const int status,
const int errorType)
const;
89 bool checkXInRange(
double x)
const;
92 double splineEval(
const double x)
const;
double value
The value of the point.
std::map< DeltaEMode::Type, std::string > index
Attribute is a non-fitting parameter.
A wrapper around GSL functions implementing cubic spline interpolation.
bool m_recalculateSpline
Flag for checking if the spline needs recalculating.
std::string name() const override
overwrite IFunction base class methods
const std::string category() const override
overwrite IFunction base class methods
std::shared_ptr< gsl_spline > m_spline
GSL data structure used to calculate spline.
const int m_min_points
Minimum number of data points in spline.
std::shared_ptr< gsl_interp_accel > m_acc
GSL interpolation accelerator object.
const std::shared_ptr< CubicSpline > CubicSpline_const_sptr
std::shared_ptr< CubicSpline > CubicSpline_sptr
Helper class which provides the Collimation Length for SANS instruments.
Functor to free a GSL objects in a shared pointer.
void operator()(gsl_interp_accel *acc)
void operator()(gsl_spline *spline)