-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refs #4036 3 unary operations on MDHisto
- Loading branch information
Janik Zikovsky
committed
Nov 8, 2011
1 parent
213658e
commit 9ee9c6b
Showing
17 changed files
with
663 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ExponentialMD.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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_ */ |
66 changes: 66 additions & 0 deletions
66
Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/LogarithmMD.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 © 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_ */ |
65 changes: 65 additions & 0 deletions
65
Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/PowerMD.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 © 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_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.