/
StaticKuboToyabeTimesGausDecay.cpp
46 lines (36 loc) · 1.27 KB
/
StaticKuboToyabeTimesGausDecay.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
40
41
42
43
44
45
46
#include "MantidCurveFitting/Functions/StaticKuboToyabeTimesGausDecay.h"
#include "MantidAPI/FunctionFactory.h"
#include <cmath>
namespace Mantid {
namespace CurveFitting {
namespace Functions {
using namespace CurveFitting;
using namespace Kernel;
using namespace API;
DECLARE_FUNCTION(StaticKuboToyabeTimesGausDecay)
void StaticKuboToyabeTimesGausDecay::init() {
declareParameter("A", 1.0, "Amplitude at time 0");
declareParameter("Delta", 0.2, "StaticKuboToyabe decay rate");
declareParameter("Sigma", 0.2, "Gaus decay rate");
}
void StaticKuboToyabeTimesGausDecay::function1D(double *out,
const double *xValues,
const size_t nData) const {
const double A = getParameter("A");
const double D = getParameter("Delta");
const double S = getParameter("Sigma");
// Precalculate squares
const double D2 = pow(D, 2);
const double S2 = pow(S, 2);
// Precalculate constants
const double C1 = 2.0 / 3;
const double C2 = 1.0 / 3;
for (size_t i = 0; i < nData; i++) {
double x2 = pow(xValues[i], 2);
out[i] =
A * (exp(-(x2 * D2) / 2) * (1 - x2 * D2) * C1 + C2) * exp(-S2 * x2);
}
}
} // namespace Functions
} // namespace CurveFitting
} // namespace Mantid