Skip to content
Snippets Groups Projects
Power.cpp 1.03 KiB
Newer Older
Owen Arnold's avatar
Owen Arnold committed
//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include "MantidAlgorithms/Power.h"
#include "MantidKernel/Exception.h"

using namespace Mantid::API;
using namespace Mantid::Kernel;

namespace Mantid {
namespace Algorithms {
Owen Arnold's avatar
Owen Arnold committed

// Register the class into the algorithm factory
DECLARE_ALGORITHM( Power)

///////////////////////////////////


void Power::defineProperties() {
	BoundedValidator<double> *mustBePositive = new BoundedValidator<double> ();
	mustBePositive->setLower(0.0);
	declareProperty("Exponent", 1.0, mustBePositive);
void Power::retrieveProperties() {
	m_exponent = getProperty("Exponent");
void Power::performUnaryOperation(const double& XIn, const double& YIn,
		const double& EIn, double& YOut, double& EOut) {
		YOut = CalculatePower(YIn, m_exponent);
		EOut = m_exponent * YOut * (EIn / YIn);
inline double Power::CalculatePower(const double base, const double exponent)
Owen Arnold's avatar
Owen Arnold committed
{
return std::pow(base, exponent);