Mantid
Loading...
Searching...
No Matches
UserFunction1D.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2007 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#pragma once
8
9//----------------------------------------------------------------------
10// Includes
11//----------------------------------------------------------------------
14
15namespace Mantid {
16namespace CurveFitting {
17namespace Functions {
58public:
60 UserFunction1D() : m_x(0.0), m_x_set(false), m_parameters(100), m_nPars(0){};
62 const std::string name() const override { return "UserFunction1D"; }
64 int version() const override { return (1); }
66 const std::string category() const override { return "Optimization\\FitAlgorithms"; }
68 const std::string summary() const override { return "Fits a histogram from a workspace to a user defined function."; }
69 const std::vector<std::string> seeAlso() const override { return {"Fit"}; }
70
71protected:
73 // double function(const double* in, const double& x);
74 void function(const double *in, double *out, const double *xValues, const size_t nData) override;
75 void declareAdditionalProperties() override;
76 void declareParameters() override{};
77 void prepare() override;
79 void functionDeriv(const double *in, API::Jacobian *out, const double *xValues, const size_t nData) override;
80
81 static double *AddVariable(const char *varName, void *palg);
82
83private:
85 mu::Parser m_parser;
87 double m_x;
89 bool m_x_set;
91 std::vector<double> m_parameters;
95 std::vector<double> m_tmp;
97 std::vector<double> m_tmp1;
98};
99
100} // namespace Functions
101} // namespace CurveFitting
102} // namespace Mantid
Represents the Jacobian in IFitFunction::functionDeriv.
Definition: Jacobian.h:22
Deprecation notice: instead of using this algorithm please use the Fit algorithm instead.
Definition: Fit1D.h:46
Deprecation notice: instead of using this algorithm please use the Fit algorithm where the Function p...
int m_nPars
Number of actual parameters.
void declareAdditionalProperties() override
Declare properties that are not fit parameters.
std::vector< double > m_tmp
Temporary data storage.
std::vector< double > m_parameters
Pointer to muParser variables' buffer.
void functionDeriv(const double *in, API::Jacobian *out, const double *xValues, const size_t nData) override
Derivatives of function with respect to parameters you are trying to fit.
const std::vector< std::string > seeAlso() const override
Function to return all of the seeAlso (these are not validated) algorithms related to this algorithm....
const std::string category() const override
Algorithm's category for identification overriding a virtual method.
const std::string summary() const override
Summary of algorithms purpose.
static double * AddVariable(const char *varName, void *palg)
Static callback function used by MuParser to initialize variables implicitly.
bool m_x_set
True indicates that input formula contains 'x' variable.
const std::string name() const override
Algorithm's name for identification overriding a virtual method.
void function(const double *in, double *out, const double *xValues, const size_t nData) override
overwrite base class methods
void prepare() override
Declare fit parameters using muParser's implicit variable initialization.
void declareParameters() override
Declare parameters specific to fitting function.
double m_x
Used as 'x' variable in m_parser.
std::vector< double > m_tmp1
Temporary data storage.
int version() const override
Algorithm's version for identification overriding a virtual method.
Helper class which provides the Collimation Length for SANS instruments.