Skip to content

Commit

Permalink
Refs #4036 3 unary operations on MDHisto
Browse files Browse the repository at this point in the history
  • Loading branch information
Janik Zikovsky committed Nov 8, 2011
1 parent 213658e commit 9ee9c6b
Show file tree
Hide file tree
Showing 17 changed files with 663 additions and 13 deletions.
9 changes: 9 additions & 0 deletions Code/Mantid/Framework/MDAlgorithms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ set ( SRC_FILES
src/ConvertToQ3DdE.cpp
src/ConvertToQNDany.cpp
src/DivideMD.cpp
src/ExponentialMD.cpp
src/IDynamicRebinning.cpp
src/InvalidParameter.cpp
src/InvalidParameterParser.cpp
src/LogarithmMD.cpp
src/MinusMD.cpp
src/MultiplyMD.cpp
src/NullImplicitFunction.cpp
src/PlusMD.cpp
src/PowerMD.cpp
src/QuadEnBackground.cpp
src/RunParam.cpp
src/SimulateMDD.cpp
Expand All @@ -38,13 +41,16 @@ set ( INC_FILES
inc/MantidMDAlgorithms/ConvertToQ3DdE.h
inc/MantidMDAlgorithms/ConvertToQNDany.h
inc/MantidMDAlgorithms/DivideMD.h
inc/MantidMDAlgorithms/ExponentialMD.h
inc/MantidMDAlgorithms/IDynamicRebinning.h
inc/MantidMDAlgorithms/InvalidParameter.h
inc/MantidMDAlgorithms/InvalidParameterParser.h
inc/MantidMDAlgorithms/LogarithmMD.h
inc/MantidMDAlgorithms/MinusMD.h
inc/MantidMDAlgorithms/MultiplyMD.h
inc/MantidMDAlgorithms/NullImplicitFunction.h
inc/MantidMDAlgorithms/PlusMD.h
inc/MantidMDAlgorithms/PowerMD.h
inc/MantidMDAlgorithms/QuadEnBackground.h
inc/MantidMDAlgorithms/RunParam.h
inc/MantidMDAlgorithms/SimulateMDD.h
Expand All @@ -64,11 +70,14 @@ set ( TEST_FILES
test/ConvertToQ3DdETest.h
test/ConvertToQNDanyTest.h
test/DivideMDTest.h
test/ExponentialMDTest.h
test/InvalidParameterParserTest.h
test/InvalidParameterTest.h
test/LogarithmMDTest.h
test/MinusMDTest.h
test/MultiplyMDTest.h
test/PlusMDTest.h
test/PowerMDTest.h
test/RunParamTest.h
test/SimulateMDDTest.h
test/TobyFitSimulateTest.h
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#ifndef MANTID_MDALGORITHMS_EXPONENTIALMD_H_
#define MANTID_MDALGORITHMS_EXPONENTIALMD_H_

#include "MantidKernel/System.h"
#include "MantidAPI/Algorithm.h"
#include "MantidMDAlgorithms/UnaryOperationMD.h"

namespace Mantid
{
namespace MDAlgorithms
{

/** ExponentialMD : exponential function on MDHistoWorkspace
@date 2011-11-08
Copyright © 2011 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
This file is part of Mantid.
Mantid is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Mantid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
File change history is stored at: <https://svn.mantidproject.org/mantid/trunk/Code/Mantid>
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class DLLExport ExponentialMD : public UnaryOperationMD
{
public:
ExponentialMD();
virtual ~ExponentialMD();

virtual const std::string name() const;
virtual int version() const;

private:
virtual void initDocs();

/// Check the inputs and throw if the algorithm cannot be run
void checkInputs();

/// Run the algorithm on a MDEventWorkspace
void execEvent(Mantid::API::IMDEventWorkspace_sptr out);

/// Run the algorithm with a MDHistoWorkspace
void execHisto(Mantid::MDEvents::MDHistoWorkspace_sptr out);


};


} // namespace MDAlgorithms
} // namespace Mantid

#endif /* MANTID_MDALGORITHMS_EXPONENTIALMD_H_ */
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#ifndef MANTID_MDALGORITHMS_LOGARITHMMD_H_
#define MANTID_MDALGORITHMS_LOGARITHMMD_H_

#include "MantidKernel/System.h"
#include "MantidAPI/Algorithm.h"
#include "MantidMDAlgorithms/UnaryOperationMD.h"

namespace Mantid
{
namespace MDAlgorithms
{

/** LogarithmMD : natural logarithm of a MDHistoWorkspace
@date 2011-11-08
Copyright &copy; 2011 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
This file is part of Mantid.
Mantid is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Mantid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
File change history is stored at: <https://svn.mantidproject.org/mantid/trunk/Code/Mantid>
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class DLLExport LogarithmMD : public UnaryOperationMD
{
public:
LogarithmMD();
virtual ~LogarithmMD();

virtual const std::string name() const;
virtual int version() const;

private:
virtual void initDocs();
virtual void initExtraProperties();

/// Check the inputs and throw if the algorithm cannot be run
void checkInputs();

/// Run the algorithm on a MDEventWorkspace
void execEvent(Mantid::API::IMDEventWorkspace_sptr out);

/// Run the algorithm with a MDHistoWorkspace
void execHisto(Mantid::MDEvents::MDHistoWorkspace_sptr out);


};


} // namespace MDAlgorithms
} // namespace Mantid

#endif /* MANTID_MDALGORITHMS_LOGARITHMMD_H_ */
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#ifndef MANTID_MDALGORITHMS_POWERMD_H_
#define MANTID_MDALGORITHMS_POWERMD_H_

#include "MantidKernel/System.h"
#include "MantidAPI/Algorithm.h"
#include "MantidMDAlgorithms/UnaryOperationMD.h"

namespace Mantid
{
namespace MDAlgorithms
{

/** PowerMD : raise a MDHistoWorkspace to a power.
@date 2011-11-08
Copyright &copy; 2011 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
This file is part of Mantid.
Mantid is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Mantid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
File change history is stored at: <https://svn.mantidproject.org/mantid/trunk/Code/Mantid>
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class DLLExport PowerMD : public UnaryOperationMD
{
public:
PowerMD();
virtual ~PowerMD();

virtual const std::string name() const;
virtual int version() const;

private:
virtual void initDocs();
virtual void initExtraProperties();

/// Check the inputs and throw if the algorithm cannot be run
void checkInputs();

/// Run the algorithm on a MDEventWorkspace
void execEvent(Mantid::API::IMDEventWorkspace_sptr out);

/// Run the algorithm with a MDHistoWorkspace
void execHisto(Mantid::MDEvents::MDHistoWorkspace_sptr out);

};


} // namespace MDAlgorithms
} // namespace Mantid

#endif /* MANTID_MDALGORITHMS_POWERMD_H_ */
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ namespace MDAlgorithms
virtual const std::string outputPropName() const { return "OutputWorkspace";}

void init();
virtual void initExtraProperties();
void exec();

/// Check the inputs and throw if the algorithm cannot be run
Expand Down
79 changes: 79 additions & 0 deletions Code/Mantid/Framework/MDAlgorithms/src/ExponentialMD.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*WIKI*
This executes the exponential function on a MDHistoWorkspace.
The signal <math>a</math> becomes <math> f = exp(a) </math>
The error <math>da</math> becomes <math> df^2 = f^2 * da^2 </math>
This algorithm cannot be run on a [[MDEventWorkspace]]. Its equivalent on a [[MatrixWorkspace]] is called [[Exponential]].
*WIKI*/

#include "MantidMDAlgorithms/ExponentialMD.h"
#include "MantidKernel/System.h"

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

namespace Mantid
{
namespace MDAlgorithms
{

// Register the algorithm into the AlgorithmFactory
DECLARE_ALGORITHM(ExponentialMD)

//----------------------------------------------------------------------------------------------
/** Constructor
*/
ExponentialMD::ExponentialMD()
{ }

//----------------------------------------------------------------------------------------------
/** Destructor
*/
ExponentialMD::~ExponentialMD()
{ }

//----------------------------------------------------------------------------------------------
/// Algorithm's name for identification. @see Algorithm::name
const std::string ExponentialMD::name() const { return "ExponentialMD";};

/// Algorithm's version for identification. @see Algorithm::version
int ExponentialMD::version() const { return 1;};

//----------------------------------------------------------------------------------------------
/// Sets documentation strings for this algorithm
void ExponentialMD::initDocs()
{
this->setWikiSummary("Applies the exponential function on a [[MDHistoWorkspace]].");
this->setOptionalMessage("Applies the exponential function on a MDHistoWorkspace.");
}

//----------------------------------------------------------------------------------------------
/// Check the inputs and throw if the algorithm cannot be run
void ExponentialMD::checkInputs()
{
if (!m_in_histo)
throw std::runtime_error(this->name() + " can only be run on a MDHistoWorkspace.");
}

//----------------------------------------------------------------------------------------------
/// Run the algorithm on a MDEventWorkspace
void ExponentialMD::execEvent(Mantid::API::IMDEventWorkspace_sptr /*out*/)
{
throw std::runtime_error(this->name() + " can only be run on a MDHistoWorkspace.");
}

//----------------------------------------------------------------------------------------------
/// ExponentialMD::Run the algorithm with a MDHistoWorkspace
void ExponentialMD::execHisto(Mantid::MDEvents::MDHistoWorkspace_sptr out)
{
out->exp();
}



} // namespace Mantid
} // namespace MDAlgorithms

0 comments on commit 9ee9c6b

Please sign in to comment.