Mantid
Loading...
Searching...
No Matches
MaxentEntropyNegativeValues.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 +
8#include <cmath>
9
10namespace Mantid::Algorithms {
11
18std::vector<double> MaxentEntropyNegativeValues::derivative(const std::vector<double> &values, double background) {
19
20 std::vector<double> result(values.size());
21
22 // First derivative
23 for (size_t i = 0; i < values.size(); i++) {
24 double normVal = values[i] / background;
25 result[i] = -std::log(normVal + std::sqrt(normVal * normVal + 1));
26 }
27 return result;
28}
29
36std::vector<double> MaxentEntropyNegativeValues::secondDerivative(const std::vector<double> &values,
37 double background) {
38
39 std::vector<double> result(values.size());
40
41 double bkg2 = background * background;
42
43 // Second derivative
44 for (size_t i = 0; i < values.size(); i++) {
45 result[i] = std::sqrt(values[i] * values[i] + bkg2);
46 }
47 return result;
48}
49
57std::vector<double> MaxentEntropyNegativeValues::correctValues(const std::vector<double> &values, double newValue) {
58
59 UNUSED_ARG(newValue)
60
61 // Nothing to correct
62 return values;
63}
64
65} // namespace Mantid::Algorithms
#define UNUSED_ARG(x)
Function arguments are sometimes unused in certain implmentations but are required for documentation ...
Definition: System.h:64
std::vector< double > secondDerivative(const std::vector< double > &values, double background) override
Returns the second derivative at a given point.
std::vector< double > correctValues(const std::vector< double > &values, double newValue) override
Corrects the image.
std::vector< double > derivative(const std::vector< double > &values, double background) override
Returns the first derivative at a given point.