-
Notifications
You must be signed in to change notification settings - Fork 122
/
Logarithm.cpp
53 lines (46 loc) · 1.7 KB
/
Logarithm.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
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source,
// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
// SPDX - License - Identifier: GPL - 3.0 +
#include "MantidAlgorithms/Logarithm.h"
#include "MantidAPI/WorkspaceProperty.h"
using namespace Mantid::API;
using namespace Mantid::Kernel;
#include <cmath>
namespace Mantid::Algorithms {
// Register the class into the algorithm factory
DECLARE_ALGORITHM(Logarithm)
Logarithm::Logarithm() : UnaryOperation(), log_Min(0), is_natural(true) { this->useHistogram = true; }
void Logarithm::defineProperties() {
declareProperty("Filler", 0.0,
"The value that will be placed into the "
"output workspace if an input value is equal "
"or less than 0. Default value is 0");
declareProperty("Natural", true,
"Logical value which specifies if user "
"wants to calculate natural or base 10 "
"logarithm.");
}
void Logarithm::retrieveProperties() {
this->log_Min = getProperty("Filler");
this->is_natural = getProperty("Natural");
}
void Logarithm::performUnaryOperation(const double XIn, const double YIn, const double EIn, double &YOut,
double &EOut) {
(void)XIn; // Avoid compiler warning
if (YIn <= 0) {
YOut = this->log_Min;
EOut = 0;
} else {
if (this->is_natural) {
YOut = std::log(YIn);
EOut = EIn / YIn;
} else {
YOut = std::log10(YIn);
EOut = 0.434 * EIn / YIn;
}
}
}
} // namespace Mantid::Algorithms