Mantid
Loading...
Searching...
No Matches
Framework
CurveFitting
src
Functions
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 +
7
#include "
MantidCurveFitting/Functions/PeakParameterFunction.h
"
8
#include "
MantidAPI/FunctionFactory.h
"
9
#include "
MantidAPI/IPeakFunction.h
"
10
11
namespace
Mantid::CurveFitting::Functions
{
12
13
using namespace
CurveFitting;
14
15
using namespace
API
;
16
17
DECLARE_FUNCTION
(PeakParameterFunction)
18
19
32
void
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
49
void
PeakParameterFunction::functionDeriv
(
const
FunctionDomain
&domain,
Jacobian
&jacobian) {
50
calNumericalDeriv
(domain, jacobian);
51
}
52
54
void
PeakParameterFunction::beforeDecoratedFunctionSet
(
const
IFunction_sptr
&fn) {
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
FunctionFactory.h
DECLARE_FUNCTION
#define DECLARE_FUNCTION(classname)
Macro for declaring a new type of function to be used with the FunctionFactory.
Definition
FunctionFactory.h:151
IPeakFunction.h
PeakParameterFunction.h
UNUSED_ARG
#define UNUSED_ARG(x)
Function arguments are sometimes unused in certain implmentations but are required for documentation ...
Definition
System.h:48
Mantid::API::FunctionDomain
Base class that represents the domain of a function.
Definition
FunctionDomain.h:31
Mantid::API::IFunction::calNumericalDeriv
void calNumericalDeriv(const FunctionDomain &domain, Jacobian &jacobian)
Calculate numerical derivatives.
Definition
IFunction.cpp:1106
Mantid::API::Jacobian
Represents the Jacobian in IFitFunction::functionDeriv.
Definition
Jacobian.h:22
Mantid::CurveFitting::Functions::PeakParameterFunction
PeakParameterFunction :
Definition
PeakParameterFunction.h:32
Mantid::CurveFitting::Functions::PeakParameterFunction::beforeDecoratedFunctionSet
void beforeDecoratedFunctionSet(const API::IFunction_sptr &fn) override
Make sure the decorated function is IPeakFunction and store it.
Definition
PeakParameterFunction.cpp:54
Mantid::CurveFitting::Functions::PeakParameterFunction::functionDeriv
void functionDeriv(const API::FunctionDomain &domain, API::Jacobian &jacobian) override
Uses numerical derivatives to calculate Jacobian of the function.
Definition
PeakParameterFunction.cpp:49
Mantid::CurveFitting::Functions::PeakParameterFunction::m_peakFunction
API::IPeakFunction_sptr m_peakFunction
Definition
PeakParameterFunction.h:45
API
Definition
ChudleyElliotSQE.h:11
Mantid::API::IFunction_sptr
std::shared_ptr< IFunction > IFunction_sptr
shared pointer to the function base class
Definition
IFunction.h:743
Mantid::CurveFitting::Functions
Definition
VesuvioCalculateGammaBackground.h:23
Generated by
1.9.8