18using namespace CurveFitting;
26 declareParameter(
"A0");
35 vector<double> coeff(
m_n + 1, 0.0);
36 for (
int i = 0; i <
m_n + 1; ++i)
40 for (
size_t i = 0; i < nData; ++i) {
41 double x = xValues[i];
42 double temp = coeff[0];
44 for (
int j = 1; j <=
m_n; ++j) {
45 temp += coeff[j] * nx;
56 for (
size_t i = 0; i < nData; i++) {
57 double x = xValues[i];
59 for (
int j = 0; j <=
m_n; ++j) {
83 throw std::invalid_argument(
"Polynomial: Unknown attribute " + attName);
97 auto newN = att.
asInt();
99 throw std::invalid_argument(
"Polynomial: polynomial order cannot be negative.");
103 std::vector<double> oldValues(std::min(
m_n, newN) + 1);
104 for (
size_t i = 0; i < oldValues.size(); ++i) {
112 for (
int i = 0; i <=
m_n; ++i) {
118 for (
size_t i = 0; i < oldValues.size(); ++i) {
#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.
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.
Polynomial : N-th polynomial background function.
bool hasAttribute(const std::string &attName) const override
Check if attribute attName exists.
void setAttribute(const std::string &attName, const Attribute &) override
Set a value to attribute attName.
void function1D(double *out, const double *xValues, const size_t nData) const override
Function to calcualte polynomial.
Attribute getAttribute(const std::string &attName) const override
Return a value of attribute attName.
void functionDeriv1D(API::Jacobian *out, const double *xValues, const size_t nData) override
Function to calculate derivative analytically.
std::vector< std::string > getAttributeNames() const override
Returns a list of attribute names.
std::string to_string(const wide_integer< Bits, Signed > &n)