Mantid
|
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... | |
SimpleChebfun & | operator+= (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... | |
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.
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.
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.
Mantid::CurveFitting::Functions::SimpleChebfun::SimpleChebfun | ( | size_t | n, |
const API::IFunction & | fun, | ||
double | start, | ||
double | end | ||
) |
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.
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.
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.
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.
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.
|
private |
Constructor.
Construct an empty SimpleChebfun with shared base.
Definition at line 76 of file SimpleChebfun.cpp.
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().
const std::vector< double > & Mantid::CurveFitting::Functions::SimpleChebfun::coeffs | ( | ) | const |
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().
|
inline |
End of the interval.
Definition at line 42 of file SimpleChebfun.h.
Referenced by Mantid::CurveFitting::ParameterEstimator::getPeakHWHM().
SimpleChebfun Mantid::CurveFitting::Functions::SimpleChebfun::integral | ( | ) | const |
Create an integral of this function.
Definition at line 117 of file SimpleChebfun.cpp.
double Mantid::CurveFitting::Functions::SimpleChebfun::integrate | ( | ) | const |
Integrate the function on its interval.
Definition at line 150 of file SimpleChebfun.cpp.
|
inline |
Check if approximation is good.
Definition at line 38 of file SimpleChebfun.h.
std::vector< double > Mantid::CurveFitting::Functions::SimpleChebfun::linspace | ( | size_t | n | ) | const |
Create a vector of x values linearly spaced on the approximation interval.
n | :: Number of points in the vector. |
Definition at line 100 of file SimpleChebfun.cpp.
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.
x | :: Points where the function is evaluated. |
Definition at line 96 of file SimpleChebfun.cpp.
References m_base, m_P, and Mantid::Geometry::x.
double Mantid::CurveFitting::Functions::SimpleChebfun::operator() | ( | double | x | ) | const |
Evaluate the function.
x | :: Point where the function is evaluated. |
Definition at line 92 of file SimpleChebfun.cpp.
References m_base, m_P, and Mantid::Geometry::x.
SimpleChebfun & Mantid::CurveFitting::Functions::SimpleChebfun::operator+= | ( | const ChebfunFunctionType & | fun | ) |
Add a C++ function to the function.
fun | :: A function to add. |
Definition at line 154 of file SimpleChebfun.cpp.
References m_A, m_P, Mantid::Geometry::x, and xPoints().
|
inline |
Order of the approximating polynomial.
Definition at line 36 of file SimpleChebfun.h.
Referenced by Mantid::CurveFitting::ParameterEstimator::setBackToBackExponential().
std::vector< double > Mantid::CurveFitting::Functions::SimpleChebfun::roughRoots | ( | double | level = 0.0 | ) | const |
Get rough estimates of the roots.
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().
|
inline |
Number of points in the approximation.
Definition at line 34 of file SimpleChebfun.h.
|
inline |
Start of the interval.
Definition at line 40 of file SimpleChebfun.h.
Referenced by Mantid::CurveFitting::ParameterEstimator::getPeakHWHM().
|
inline |
Get the width of the interval.
Definition at line 44 of file SimpleChebfun.h.
Referenced by Mantid::CurveFitting::ParameterEstimator::getPeakCentre().
|
inline |
Get a reference to the x-points.
Definition at line 46 of file SimpleChebfun.h.
Referenced by Mantid::CurveFitting::ParameterEstimator::getPeakLeftRightWidth(), and operator+=().
|
inline |
Get a reference to the y-points.
Definition at line 48 of file SimpleChebfun.h.
|
mutableprivate |
Chebyshev expansion coefficients.
Definition at line 78 of file SimpleChebfun.h.
Referenced by coeffs(), derivative(), integral(), operator+=(), and SimpleChebfun().
|
private |
Set in a case of a bad fit.
Definition at line 81 of file SimpleChebfun.h.
Referenced by SimpleChebfun().
|
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().
|
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().