Mantid
Loading...
Searching...
No Matches
Fit1D.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//----------------------------------------------------------------------
12#include "MantidAPI/Algorithm.h"
13#include "MantidAPI/IFunction.h"
14#include "MantidCurveFitting/DllConfig.h"
15
16namespace Mantid {
17
18namespace CurveFitting {
19namespace Algorithms {
46class MANTID_CURVEFITTING_DLL Fit1D : public API::Algorithm {
47public:
49 const std::string name() const override { return "Fit1D"; }
51 int version() const override { return (1); }
53 const std::string category() const override { return "Optimization"; }
54
56 virtual void function(const double *in, double *out, const double *xValues, const size_t nData) = 0;
58 virtual void functionDeriv(const double *in, API::Jacobian *out, const double *xValues, const size_t nData);
59
60protected:
61 ~Fit1D() = default;
62 // Overridden Algorithm methods
63 void init() override;
64 void exec() override;
65
68 virtual void modifyStartOfRange(double &startX) {
69 (void)startX; // Avoid compiler warning
70 }
73 virtual void modifyEndOfRange(double &endX) {
74 (void)endX; // Avoid compiler warning
75 }
76
80 virtual void prepare(){};
81
91 virtual void afterDataRangedDetermined(const int &m_minX, const int &m_maxX) {
92 (void)m_minX;
93 (void)m_maxX; // Avoid compiler warning
94 };
95
97 virtual void declareParameters() = 0;
98
101 virtual void modifyInitialFittedParameters(std::vector<double> &fittedParameter);
102
107 virtual void modifyFinalFittedParameters(std::vector<double> &fittedParameter);
108
111 std::vector<double> m_fittedParameter;
112
114 std::vector<std::string> m_parameterNames;
115
117 size_t nParams() const { return m_parameterNames.size(); }
118
119 friend struct FitData;
120};
121
122} // namespace Algorithms
123} // namespace CurveFitting
124} // namespace Mantid
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:85
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
const std::string category() const override
Algorithm's category for identification overriding a virtual method.
Definition: Fit1D.h:53
virtual void declareAdditionalProperties()
Declare additional properties other than fitting parameters.
Definition: Fit1D.h:78
std::vector< std::string > m_parameterNames
Holds a copy of the names of the fitting parameters.
Definition: Fit1D.h:114
std::vector< double > m_fittedParameter
Holds a copy of the value of the parameters that are actually least-squared fitted.
Definition: Fit1D.h:111
virtual void afterDataRangedDetermined(const int &m_minX, const int &m_maxX)
Called after the data ranged has been determined but before the fitting starts.
Definition: Fit1D.h:91
virtual void function(const double *in, double *out, const double *xValues, const size_t nData)=0
Function you want to fit to.
size_t nParams() const
Number of parameters (incuding fixed).
Definition: Fit1D.h:117
virtual void prepare()
Called in the beginning of exec(). Custom initialization.
Definition: Fit1D.h:80
int version() const override
Algorithm's version for identification overriding a virtual method.
Definition: Fit1D.h:51
virtual void modifyStartOfRange(double &startX)
Option for providing intelligent range starting value based e.g.
Definition: Fit1D.h:68
const std::string name() const override
Algorithm's name for identification overriding a virtual method.
Definition: Fit1D.h:49
virtual void modifyEndOfRange(double &endX)
Option for providing intelligent range finishing value based e.g.
Definition: Fit1D.h:73
virtual void declareParameters()=0
Declare parameters specific to fitting function.
Helper class which provides the Collimation Length for SANS instruments.
Structure to contain least squares data and used by GSL.
Definition: Fit1D.cpp:82