-
Notifications
You must be signed in to change notification settings - Fork 122
/
GaussianAutoDiff.cpp
39 lines (31 loc) · 1.02 KB
/
GaussianAutoDiff.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "MantidCurveFitting/GaussianAutoDiff.h"
#include "MantidAPI/FunctionFactory.h"
namespace Mantid
{
namespace CurveFitting
{
DECLARE_FUNCTION(GaussianAutoDiff)
using namespace API;
//----------------------------------------------------------------------------------------------
/** Destructor
*/
GaussianAutoDiff::~GaussianAutoDiff()
{
}
void GaussianAutoDiff::function1DAutoDiff(const FunctionDomain1D &domain, std::vector<adept::adouble> &y, const AutoDiffParameterAdapter ¶meters) const
{
adept::adouble height = parameters.getParameter("Height");
adept::adouble centre = parameters.getParameter("PeakCentre");
adept::adouble sigma = parameters.getParameter("Sigma");
for(size_t i = 0; i < y.size(); ++i) {
adept::adouble term = (domain[i] - centre)/sigma;
y[i] = height * exp(-0.5 * term * term);
}
}
void GaussianAutoDiff::init() {
declareParameter("Height");
declareParameter("PeakCentre");
declareParameter("Sigma");
}
} // namespace CurveFitting
} // namespace Mantid