/
Poldi2DFunction.cpp
69 lines (59 loc) · 1.83 KB
/
Poldi2DFunction.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include "MantidSINQ/PoldiUtilities/Poldi2DFunction.h"
#include <math.h>
namespace Mantid
{
namespace Poldi
{
using namespace API;
Poldi2DFunction::Poldi2DFunction() :
IFunction1DSpectrum(),
CompositeFunction(),
m_iteration(0)
{
}
/**
* Calculates function values for domain. In contrast to CompositeFunction, the summation
* of values is performed in a different way: The values are set to zero once at the beginning,
* then it is expected of the member functions to use FunctionValues::addToCalculated or add
* their values otherwise, without erasing the values.
*
* @param domain :: Function domain which is passed on to the member functions.
* @param values :: Function values.
*/
void Poldi2DFunction::function(const FunctionDomain &domain, FunctionValues &values) const
{
CompositeFunction::function(domain, values);
if(m_iteration > 0) {
for(size_t i = 0; i < values.size(); ++i) {
values.setFitWeight(i, 1.0/sqrt(values.getCalculated(i) + 0.1));
}
}
}
/**
* Calculates function derivatives. Simply calls CompositeFunction::functionDeriv
*
* @param domain :: Function domain which is passed on to the member functions.
* @param jacobian :: Jacobian.
*/
void Poldi2DFunction::functionDeriv(const FunctionDomain &domain, Jacobian &jacobian)
{
CompositeFunction::functionDeriv(domain, jacobian);
}
/**
* Empty implementation of IFunction1DSpectrum::function1DSpectrum which must be present to
* completely implement the interface.
*
* @param domain :: Unused domain.
* @param values :: Unused function values.
*/
void Poldi2DFunction::function1DSpectrum(const FunctionDomain1DSpectrum &domain, FunctionValues &values) const
{
UNUSED_ARG(domain);
UNUSED_ARG(values);
}
void Poldi2DFunction::iterationFinished()
{
++m_iteration;
}
} // namespace Poldi
} // namespace Mantid