Mantid
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Mantid::CurveFitting::Functions::SimpleChebfun Class Reference

SimpleChebfun : approximates smooth 1d functions and provides methods to manipulate them. More...

#include <SimpleChebfun.h>

Public Member Functions

double accuracy () const
 Get the accuracy of the approximation. More...
 
const std::vector< double > & coeffs () const
 Get a reference to the Chebyshev expansion coefficients. More...
 
SimpleChebfun derivative () const
 Create a derivative of this function. More...
 
double endX () const
 End of the interval. More...
 
SimpleChebfun integral () const
 Create an integral of this function. More...
 
double integrate () const
 Integrate the function on its interval. More...
 
bool isGood () const
 Check if approximation is good. More...
 
std::vector< double > linspace (size_t n) const
 Create a vector of x values linearly spaced on the approximation interval. More...
 
std::vector< double > operator() (const std::vector< double > &x) const
 Evaluate the function. More...
 
double operator() (double x) const
 Evaluate the function. More...
 
SimpleChebfunoperator+= (const ChebfunFunctionType &fun)
 Add a C++ function to the function. More...
 
size_t order () const
 Order of the approximating polynomial. More...
 
std::vector< double > roughRoots (double level=0.0) const
 Get rough estimates of the roots. More...
 
 SimpleChebfun (const API::IFunction &fun, double start, double end, double accuracy=0.0, size_t badSize=10)
 Constructor. More...
 
 SimpleChebfun (const ChebfunFunctionType &fun, double start, double end, double accuracy=0.0, size_t badSize=10)
 Constructor. More...
 
 SimpleChebfun (const std::vector< double > &x, const std::vector< double > &y)
 Constructor. More...
 
 SimpleChebfun (size_t n, ChebfunFunctionType fun, double start, double end)
 Constructor. More...
 
 SimpleChebfun (size_t n, const API::IFunction &fun, double start, double end)
 Constructor. More...
 
size_t size () const
 Number of points in the approximation. More...
 
double startX () const
 Start of the interval. More...
 
double width () const
 Get the width of the interval. More...
 
const std::vector< double > & xPoints () const
 Get a reference to the x-points. More...
 
const std::vector< double > & yPoints () const
 Get a reference to the y-points. More...
 

Private Member Functions

 SimpleChebfun (const ChebfunBase_sptr &base)
 Constructor. More...
 

Private Attributes

std::vector< double > m_A
 Chebyshev expansion coefficients. More...
 
bool m_badFit
 Set in a case of a bad fit. More...
 
ChebfunBase_sptr m_base
 Underlying base that does actual job. More...
 
std::vector< double > m_P
 Function values at the chebfun x-points. More...
 

Detailed Description

SimpleChebfun : approximates smooth 1d functions and provides methods to manipulate them.

Main functionality is implemented in ChebfunBase class.

Definition at line 21 of file SimpleChebfun.h.

Constructor & Destructor Documentation

◆ SimpleChebfun() [1/6]

Mantid::CurveFitting::Functions::SimpleChebfun::SimpleChebfun ( size_t  n,
ChebfunFunctionType  fun,
double  start,
double  end 
)

Constructor.

Constructs a SimpleChebfun that approximates a function with a polynomial of a given order in an interval of x-values.

Parameters
n:: Polynomial order == number of points - 1.
fun:: A function to approximate.
start:: The start (lower bound) of an interval on the x-axis.
end:: The end (upper bound) of an interval on the x-axis.

Definition at line 25 of file SimpleChebfun.cpp.

References m_base, and m_P.

◆ SimpleChebfun() [2/6]

Mantid::CurveFitting::Functions::SimpleChebfun::SimpleChebfun ( size_t  n,
const API::IFunction fun,
double  start,
double  end 
)

Constructor.

Definition at line 30 of file SimpleChebfun.cpp.

References m_base, and m_P.

◆ SimpleChebfun() [3/6]

Mantid::CurveFitting::Functions::SimpleChebfun::SimpleChebfun ( const ChebfunFunctionType fun,
double  start,
double  end,
double  accuracy = 0.0,
size_t  badSize = 10 
)

Constructor.

Constructs a SimpleChebfun that approximates a function to a given accuracy in an interval of x-values.

The approximation may fail (too large interval, function discontinuous, etc). In this case a default sized polynomial is created and isGood() will be returning false.

Parameters
fun:: A function to approximate.
start:: The start (lower bound) of an interval on the x-axis.
end:: The end (upper bound) of an interval on the x-axis.
accuracy:: The accuracy of the approximation.
badSize:: If automatic approxiamtion fails the base will have this size.

Definition at line 47 of file SimpleChebfun.cpp.

References accuracy(), m_A, m_badFit, m_base, and m_P.

◆ SimpleChebfun() [4/6]

Mantid::CurveFitting::Functions::SimpleChebfun::SimpleChebfun ( const API::IFunction fun,
double  start,
double  end,
double  accuracy = 0.0,
size_t  badSize = 10 
)

Constructor.

Definition at line 57 of file SimpleChebfun.cpp.

References accuracy(), m_A, m_badFit, m_base, and m_P.

◆ SimpleChebfun() [5/6]

Mantid::CurveFitting::Functions::SimpleChebfun::SimpleChebfun ( const std::vector< double > &  x,
const std::vector< double > &  y 
)

Constructor.

Construct a SimpleChebfun by smoothing data in vectors with x and y data.

Parameters
x:: A vector of x values.
y:: A vector of y values. Must have same size as x.

Definition at line 70 of file SimpleChebfun.cpp.

References m_base, m_P, Mantid::Geometry::x, and Mantid::Geometry::y.

◆ SimpleChebfun() [6/6]

Mantid::CurveFitting::Functions::SimpleChebfun::SimpleChebfun ( const ChebfunBase_sptr base)
private

Constructor.

Construct an empty SimpleChebfun with shared base.

Definition at line 76 of file SimpleChebfun.cpp.

References m_base, and m_P.

Member Function Documentation

◆ accuracy()

double Mantid::CurveFitting::Functions::SimpleChebfun::accuracy ( ) const

Get the accuracy of the approximation.

Definition at line 103 of file SimpleChebfun.cpp.

References m_base.

Referenced by SimpleChebfun().

◆ coeffs()

const std::vector< double > & Mantid::CurveFitting::Functions::SimpleChebfun::coeffs ( ) const

Get a reference to the Chebyshev expansion coefficients.

Definition at line 83 of file SimpleChebfun.cpp.

References m_A, m_base, and m_P.

◆ derivative()

SimpleChebfun Mantid::CurveFitting::Functions::SimpleChebfun::derivative ( ) const

Create a derivative of this function.

Definition at line 106 of file SimpleChebfun.cpp.

References m_A, m_base, and m_P.

Referenced by Mantid::CurveFitting::ParameterEstimator::estimate(), and Mantid::CurveFitting::ParameterEstimator::setBackToBackExponential().

◆ endX()

double Mantid::CurveFitting::Functions::SimpleChebfun::endX ( ) const
inline

End of the interval.

Definition at line 42 of file SimpleChebfun.h.

Referenced by Mantid::CurveFitting::ParameterEstimator::getPeakHWHM().

◆ integral()

SimpleChebfun Mantid::CurveFitting::Functions::SimpleChebfun::integral ( ) const

Create an integral of this function.

Definition at line 117 of file SimpleChebfun.cpp.

References m_A, m_base, and m_P.

◆ integrate()

double Mantid::CurveFitting::Functions::SimpleChebfun::integrate ( ) const

Integrate the function on its interval.

Definition at line 150 of file SimpleChebfun.cpp.

References m_base, and m_P.

◆ isGood()

bool Mantid::CurveFitting::Functions::SimpleChebfun::isGood ( ) const
inline

Check if approximation is good.

Definition at line 38 of file SimpleChebfun.h.

◆ linspace()

std::vector< double > Mantid::CurveFitting::Functions::SimpleChebfun::linspace ( size_t  n) const

Create a vector of x values linearly spaced on the approximation interval.

Parameters
n:: Number of points in the vector.

Definition at line 100 of file SimpleChebfun.cpp.

References m_base, and n.

◆ operator()() [1/2]

std::vector< double > Mantid::CurveFitting::Functions::SimpleChebfun::operator() ( const std::vector< double > &  x) const

Evaluate the function.

Evaluate the function for each value in a vector.

Parameters
x:: Points where the function is evaluated.

Definition at line 96 of file SimpleChebfun.cpp.

References m_base, m_P, and Mantid::Geometry::x.

◆ operator()() [2/2]

double Mantid::CurveFitting::Functions::SimpleChebfun::operator() ( double  x) const

Evaluate the function.

Parameters
x:: Point where the function is evaluated.

Definition at line 92 of file SimpleChebfun.cpp.

References m_base, m_P, and Mantid::Geometry::x.

◆ operator+=()

SimpleChebfun & Mantid::CurveFitting::Functions::SimpleChebfun::operator+= ( const ChebfunFunctionType fun)

Add a C++ function to the function.

Parameters
fun:: A function to add.

Definition at line 154 of file SimpleChebfun.cpp.

References m_A, m_P, Mantid::Geometry::x, and xPoints().

◆ order()

size_t Mantid::CurveFitting::Functions::SimpleChebfun::order ( ) const
inline

Order of the approximating polynomial.

Definition at line 36 of file SimpleChebfun.h.

Referenced by Mantid::CurveFitting::ParameterEstimator::setBackToBackExponential().

◆ roughRoots()

std::vector< double > Mantid::CurveFitting::Functions::SimpleChebfun::roughRoots ( double  level = 0.0) const

Get rough estimates of the roots.

Parameters
level:: An optional right-hand-side of equation (*this)(x) == level.

Definition at line 131 of file SimpleChebfun.cpp.

References m_base, m_P, Mantid::Geometry::x, and Mantid::Geometry::y.

Referenced by Mantid::CurveFitting::ParameterEstimator::getPeakCentre(), Mantid::CurveFitting::ParameterEstimator::getPeakHWHM(), and Mantid::CurveFitting::ParameterEstimator::getPeakLeftRightWidth().

◆ size()

size_t Mantid::CurveFitting::Functions::SimpleChebfun::size ( ) const
inline

Number of points in the approximation.

Definition at line 34 of file SimpleChebfun.h.

◆ startX()

double Mantid::CurveFitting::Functions::SimpleChebfun::startX ( ) const
inline

Start of the interval.

Definition at line 40 of file SimpleChebfun.h.

Referenced by Mantid::CurveFitting::ParameterEstimator::getPeakHWHM().

◆ width()

double Mantid::CurveFitting::Functions::SimpleChebfun::width ( ) const
inline

Get the width of the interval.

Definition at line 44 of file SimpleChebfun.h.

Referenced by Mantid::CurveFitting::ParameterEstimator::getPeakCentre().

◆ xPoints()

const std::vector< double > & Mantid::CurveFitting::Functions::SimpleChebfun::xPoints ( ) const
inline

Get a reference to the x-points.

Definition at line 46 of file SimpleChebfun.h.

Referenced by Mantid::CurveFitting::ParameterEstimator::getPeakLeftRightWidth(), and operator+=().

◆ yPoints()

const std::vector< double > & Mantid::CurveFitting::Functions::SimpleChebfun::yPoints ( ) const
inline

Get a reference to the y-points.

Definition at line 48 of file SimpleChebfun.h.

Member Data Documentation

◆ m_A

std::vector<double> Mantid::CurveFitting::Functions::SimpleChebfun::m_A
mutableprivate

Chebyshev expansion coefficients.

Definition at line 78 of file SimpleChebfun.h.

Referenced by coeffs(), derivative(), integral(), operator+=(), and SimpleChebfun().

◆ m_badFit

bool Mantid::CurveFitting::Functions::SimpleChebfun::m_badFit
private

Set in a case of a bad fit.

Definition at line 81 of file SimpleChebfun.h.

Referenced by SimpleChebfun().

◆ m_base

ChebfunBase_sptr Mantid::CurveFitting::Functions::SimpleChebfun::m_base
private

Underlying base that does actual job.

Definition at line 74 of file SimpleChebfun.h.

Referenced by accuracy(), coeffs(), derivative(), integral(), integrate(), linspace(), operator()(), roughRoots(), and SimpleChebfun().

◆ m_P

std::vector<double> Mantid::CurveFitting::Functions::SimpleChebfun::m_P
private

Function values at the chebfun x-points.

Definition at line 76 of file SimpleChebfun.h.

Referenced by coeffs(), derivative(), integral(), integrate(), operator()(), operator+=(), roughRoots(), and SimpleChebfun().


The documentation for this class was generated from the following files: