Mantid
Loading...
Searching...
No Matches
MaxentEntropyPositiveValues.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> MaxentEntropyPositiveValues::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 result[i] = -std::log(values[i] / background);
25 }
26 return result;
27}
28
35std::vector<double> MaxentEntropyPositiveValues::secondDerivative(const std::vector<double> &values,
36 double background) {
37
38 UNUSED_ARG(background);
39 // This is referred to as 'second derivative' in the paper, but in the codes
40 // I've seen is just the input vector
41 return values;
42}
43
50std::vector<double> MaxentEntropyPositiveValues::correctValues(const std::vector<double> &values, double newValue) {
51
52 std::vector<double> result(values.size());
53
54 for (size_t i = 0; i < values.size(); i++) {
55 if (values[i] < 0)
56 result[i] = newValue;
57 else
58 result[i] = values[i];
59 }
60
61 return result;
62}
63
64} // 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 a negative value.
std::vector< double > derivative(const std::vector< double > &values, double background) override
Returns the first derivative at a given point.