14#include <boost/tokenizer.hpp>
18using namespace CurveFitting;
24using namespace Kernel;
40 if (std::string(varName) !=
"x") {
61 if (attName !=
"Formula") {
69 mu::Parser tmp_parser;
70 extraOneVarFunctions(tmp_parser);
91 for (
size_t i = 0; i <
nParams(); i++) {
107 throw std::invalid_argument(
"Empty formula supplied for user function");
109 for (
size_t i = 0; i < nData; i++) {
113 }
catch (mu::Parser::exception_type &e) {
double value
The value of the point.
#define DECLARE_FUNCTION(classname)
Macro for declaring a new type of function to be used with the FunctionFactory.
Base class that represents the domain of a function.
Attribute is a non-fitting parameter.
virtual void setAttribute(const std::string &name, const Attribute &)
Set a value to attribute attName.
void calNumericalDeriv(const FunctionDomain &domain, Jacobian &jacobian)
Calculate numerical derivatives.
Represents the Jacobian in IFitFunction::functionDeriv.
void clearAllParameters()
Nonvirtual member which removes all declared parameters.
virtual double * getParameterAddress(size_t i)
Get the address of the parameter. For use in UserFunction with mu::Parser.
std::string parameterName(size_t i) const override
Returns the name of parameter i.
void declareParameter(const std::string &name, double initValue=0, const std::string &description="") override
Declare a new parameter.
size_t nParams() const override
Total number of parameters.
static double * AddVariable(const char *varName, void *pufun)
mu::Parser callback function for setting variables.
void function1D(double *out, const double *xValues, const size_t nData) const override
Function you want to fit to.
~UserFunction() override
Destructor.
void setAttribute(const std::string &attName, const Attribute &value) override
Set a value to attribute attName.
UserFunction()
Constructor.
bool m_x_set
True indicates that input formula contains 'x' variable.
double m_x
Used as 'x' variable in m_parser.
void functionDeriv(const API::FunctionDomain &domain, API::Jacobian &jacobian) override
Derivatives of function with respect to active parameters.
std::string m_formula
The formula.
mu::Parser * m_parser
extended muParser instance
void MANTID_API_DLL extraOneVarFunctions(mu::Parser &parser)
std::string to_string(const wide_integer< Bits, Signed > &n)