Mantid
Loading...
Searching...
No Matches
Power.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 +
7//----------------------------------------------------------------------
8// Includes
9//----------------------------------------------------------------------
12#include <cmath>
13
14using namespace Mantid::API;
15using namespace Mantid::Kernel;
16
17namespace Mantid::Algorithms {
18
19// Register the class into the algorithm factory
21
22Power::Power() : UnaryOperation(), m_exponent(0.) { this->useHistogram = true; }
23
25
27 declareProperty("Exponent", 1.0, "The exponent with which to raise base values in the base workspace to.");
28}
29
31
32void Power::performUnaryOperation(const double XIn, const double YIn, const double EIn, double &YOut, double &EOut) {
33 (void)XIn; // Avoid compiler warning
34 YOut = calculatePower(YIn, m_exponent);
35 EOut = std::fabs(m_exponent * YOut * (EIn / YIn));
36}
37
38inline double Power::calculatePower(const double base, const double exponent) { return std::pow(base, exponent); }
39} // namespace Mantid::Algorithms
#define DECLARE_ALGORITHM(classname)
Definition: Algorithm.h:576
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
Definition: Algorithm.cpp:1913
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
Definition: Algorithm.cpp:2076
Provides the ability to raise the values in the workspace to a specified power.
Definition: Power.h:32
void retrieveProperties() override
A virtual function in which additional properties should be retrieved into member variables.
Definition: Power.cpp:30
double calculatePower(const double base, const double exponent)
calculate the power
Definition: Power.cpp:38
double m_exponent
Exponent to raise the base workspace to.
Definition: Power.h:58
void performUnaryOperation(const double XIn, const double YIn, const double EIn, double &YOut, double &EOut) override
Carries out the Unary operation on the current 'cell'.
Definition: Power.cpp:32
void defineProperties() override
A virtual function in which additional properties of an algorithm should be declared.
Definition: Power.cpp:26
UnaryOperation supports the implementation of a Unary operation on an input workspace.