Mantid
Loading...
Searching...
No Matches
PeakParameterFunction.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 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 +
10
12
13using namespace CurveFitting;
14
15using namespace API;
16
17DECLARE_FUNCTION(PeakParameterFunction)
18
19
32void PeakParameterFunction::function1D(double *out, const double *xValues, const size_t nData) const {
33 UNUSED_ARG(xValues);
34 if (nData != 4) {
35 throw std::invalid_argument("Can only work with domain of size 4.");
36 }
37
38 if (!m_peakFunction) {
39 throw std::runtime_error("IPeakFunction has not been set.");
40 }
41
42 out[0] = m_peakFunction->centre();
43 out[1] = m_peakFunction->height();
44 out[2] = m_peakFunction->fwhm();
45 out[3] = m_peakFunction->intensity();
46}
47
50 calNumericalDeriv(domain, jacobian);
51}
52
55 std::shared_ptr<IPeakFunction> peakFunction = std::dynamic_pointer_cast<IPeakFunction>(fn);
56
57 if (!peakFunction) {
58 throw std::invalid_argument("Decorated function needs to be an IPeakFunction.");
59 }
60
61 m_peakFunction = peakFunction;
62}
63
64} // namespace Mantid::CurveFitting::Functions
#define DECLARE_FUNCTION(classname)
Macro for declaring a new type of function to be used with the FunctionFactory.
#define UNUSED_ARG(x)
Function arguments are sometimes unused in certain implmentations but are required for documentation ...
Definition: System.h:64
Base class that represents the domain of a function.
void calNumericalDeriv(const FunctionDomain &domain, Jacobian &jacobian)
Calculate numerical derivatives.
Definition: IFunction.cpp:1031
Represents the Jacobian in IFitFunction::functionDeriv.
Definition: Jacobian.h:22
void beforeDecoratedFunctionSet(const API::IFunction_sptr &fn) override
Make sure the decorated function is IPeakFunction and store it.
void functionDeriv(const API::FunctionDomain &domain, API::Jacobian &jacobian) override
Uses numerical derivatives to calculate Jacobian of the function.
std::shared_ptr< IFunction > IFunction_sptr
shared pointer to the function base class
Definition: IFunction.h:732