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 const std::string category() const override { return "Optimization\\FitAlgorithms"; }
66 const std::string summary() const override { return "Fits a histogram from a workspace to a user defined function."; }
67 const std::vector<std::string> seeAlso() const override { return {"Fit"}; }
68
69protected:
71 // double function(const double* in, const double& x);
72 void function(const double *in, double *out, const double *xValues, const size_t nData) override;
73 void declareAdditionalProperties() override;
74 void declareParameters() override {};
75 void prepare() override;
77 void functionDeriv(const double *in, API::Jacobian *out, const double *xValues, const size_t nData) override;
78
79 static double *AddVariable(const char *varName, void *palg);
80
81private:
83 mu::Parser m_parser;
85 double m_x;
87 bool m_x_set;
89 std::vector<double> m_parameters;
93 std::vector<double> m_tmp;
95 std::vector<double> m_tmp1;
96};
97
98} // namespace Functions
99} // namespace CurveFitting
100} // 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.
Helper class which provides the Collimation Length for SANS instruments.