-
Notifications
You must be signed in to change notification settings - Fork 122
/
Power.cpp
40 lines (31 loc) · 1.18 KB
/
Power.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
//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include "MantidAlgorithms/Power.h"
#include "MantidKernel/Exception.h"
using namespace Mantid::API;
using namespace Mantid::Kernel;
namespace Mantid {
namespace Algorithms {
// Register the class into the algorithm factory
DECLARE_ALGORITHM(Power)
Power::Power() : UnaryOperation(), m_exponent(0.) { this->useHistogram = true; }
///////////////////////////////////
void Power::defineProperties() {
declareProperty(
"Exponent", 1.0,
"The exponent with which to raise base values in the base workspace to.");
}
void Power::retrieveProperties() { m_exponent = getProperty("Exponent"); }
void Power::performUnaryOperation(const double XIn, const double YIn,
const double EIn, double &YOut,
double &EOut) {
(void)XIn; // Avoid compiler warning
YOut = calculatePower(YIn, m_exponent);
EOut = std::fabs(m_exponent * YOut * (EIn / YIn));
}
inline double Power::calculatePower(const double base, const double exponent) {
return std::pow(base, exponent);
}
}
}