-
Notifications
You must be signed in to change notification settings - Fork 122
/
ExpDecay.cpp
50 lines (39 loc) · 1.29 KB
/
ExpDecay.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
47
48
49
50
//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include "MantidCurveFitting/Functions/ExpDecay.h"
#include "MantidAPI/FunctionFactory.h"
#include <cmath>
namespace Mantid {
namespace CurveFitting {
namespace Functions {
using namespace CurveFitting;
using namespace Kernel;
using namespace API;
DECLARE_FUNCTION(ExpDecay)
ExpDecay::ExpDecay() {
declareParameter("Height", 1.0, "Height at time 0");
declareParameter("Lifetime", 1.0, "Lifetime of the process");
}
void ExpDecay::function1D(double *out, const double *xValues,
const size_t nData) const {
const double h = getParameter("Height");
const double t = getParameter("Lifetime");
for (size_t i = 0; i < nData; i++) {
out[i] = h * exp(-(xValues[i]) / t);
}
}
void ExpDecay::functionDeriv1D(Jacobian *out, const double *xValues,
const size_t nData) {
const double h = getParameter("Height");
const double t = getParameter("Lifetime");
for (size_t i = 0; i < nData; i++) {
double x = xValues[i];
double e = exp(-x / t);
out->set(i, 0, e);
out->set(i, 1, h * e * x / t / t);
}
}
} // namespace Functions
} // namespace CurveFitting
} // namespace Mantid