18using namespace CurveFitting;
20using namespace Kernel;
27 declareParameter(
"A0");
29 declareAttribute(
"StartX",
Attribute(m_StartX));
30 declareAttribute(
"EndX",
Attribute(m_EndX));
35 throw std::runtime_error(
"Chebyshev: invalid x-range");
38 double a = 1. - b *
m_EndX;
39 if (
static_cast<int>(
m_b.size()) !=
m_n + 3) {
42 for (
size_t i = 0; i < nData; ++i) {
44 double x = a + b * xValues[i];
47 for (
int j =
m_n; j > 0; --j) {
60 double a = 1. - b *
m_EndX;
62 for (
size_t i = 0; i < nData; i++) {
64 double x = a + b * xValues[i];
70 for (
int j = 2; j <=
m_n; ++j) {
71 double t = 2 *
x * t1 - t0;
90 auto newN = att.
asInt();
92 throw std::invalid_argument(
"Chebyshev: polynomial order cannot be negative.");
96 std::vector<double> oldValues(std::min(
m_n, newN) + 1);
97 for (
size_t i = 0; i < oldValues.size(); ++i) {
105 for (
int i = 0; i <=
m_n; ++i) {
111 for (
size_t i = 0; i < oldValues.size(); ++i) {
115 }
else if (attName ==
"StartX") {
117 }
else if (attName ==
"EndX") {
#define DECLARE_FUNCTION(classname)
Macro for declaring a new type of function to be used with the FunctionFactory.
Mantid::API::IFunction::Attribute Attribute
Attribute is a non-fitting parameter.
int asInt() const
Returns int value if attribute is a int, throws exception otherwise.
double asDouble() const
Returns double value if attribute is a double, throws exception otherwise.
void storeAttributeValue(const std::string &name, const API::IFunction::Attribute &value)
Store an attribute's value.
Represents the Jacobian in IFitFunction::functionDeriv.
virtual void set(size_t iY, size_t iP, double value)=0
Set a value to a Jacobian matrix element.
void clearAllParameters()
Nonvirtual member which removes all declared parameters.
void setParameter(size_t, const double &value, bool explicitlySet=true) override
Set i-th parameter.
void declareParameter(const std::string &name, double initValue=0, const std::string &description="") override
Declare a new parameter.
double getParameter(size_t i) const override
Get i-th parameter.
Implements Chebyshev polynomial expansion.
double m_EndX
Upper x boundary. The default is 1.
void functionDeriv1D(API::Jacobian *out, const double *xValues, const size_t nData) override
Derivatives of function with respect to active parameters.
void setAttribute(const std::string &attName, const Attribute &) override
Set a value to attribute attName.
double m_StartX
Lower x boundary. The default is -1.
std::valarray< double > m_b
Keep intermediate calculatons.
void function1D(double *out, const double *xValues, const size_t nData) const override
Function you want to fit to.
std::string to_string(const wide_integer< Bits, Signed > &n)