Skip to content
Snippets Groups Projects
Commit 026651bc authored by Janik Zikovsky's avatar Janik Zikovsky
Browse files

Refs #4036: added 7 algorithms

parent 1f8a1cf6
No related merge requests found
Showing
with 1137 additions and 0 deletions
# GLOBs should be replaced with explicit listings
set ( SRC_FILES
# src/CreateMDFitWorkspace.cpp
src/AndMD.cpp
src/BinaryOperationMD.cpp
src/BooleanBinaryOperationMD.cpp
src/CobaltSpinWaveDSHO.cpp
src/CompositeFunctionBuilder.cpp
src/CompositeImplicitFunction.cpp
......@@ -9,14 +11,19 @@ set ( SRC_FILES
src/ConvertToQ3DdE.cpp
src/ConvertToQNDany.cpp
src/DivideMD.cpp
src/EqualToMD.cpp
src/ExponentialMD.cpp
src/GreaterThanMD.cpp
src/IDynamicRebinning.cpp
src/InvalidParameter.cpp
src/InvalidParameterParser.cpp
src/LessThanMD.cpp
src/LogarithmMD.cpp
src/MinusMD.cpp
src/MultiplyMD.cpp
src/NotMD.cpp
src/NullImplicitFunction.cpp
src/OrMD.cpp
src/PlusMD.cpp
src/PowerMD.cpp
src/QuadEnBackground.cpp
......@@ -26,6 +33,7 @@ set ( SRC_FILES
src/TobyFitSimulate.cpp
src/UnaryOperationMD.cpp
src/Vector3DParameterParser.cpp
src/XorMD.cpp
)
#set ( SRC_UNITY_IGNORE_FILES src/IDynamicRebinning.cpp
......@@ -33,7 +41,9 @@ set ( SRC_FILES
set ( INC_FILES
# inc/MantidMDAlgorithms/CreateMDFitWorkspace.h
inc/MantidMDAlgorithms/AndMD.h
inc/MantidMDAlgorithms/BinaryOperationMD.h
inc/MantidMDAlgorithms/BooleanBinaryOperationMD.h
inc/MantidMDAlgorithms/CobaltSpinWaveDSHO.h
inc/MantidMDAlgorithms/CompositeFunctionBuilder.h
inc/MantidMDAlgorithms/CompositeImplicitFunction.h
......@@ -41,14 +51,19 @@ set ( INC_FILES
inc/MantidMDAlgorithms/ConvertToQ3DdE.h
inc/MantidMDAlgorithms/ConvertToQNDany.h
inc/MantidMDAlgorithms/DivideMD.h
inc/MantidMDAlgorithms/EqualToMD.h
inc/MantidMDAlgorithms/ExponentialMD.h
inc/MantidMDAlgorithms/GreaterThanMD.h
inc/MantidMDAlgorithms/IDynamicRebinning.h
inc/MantidMDAlgorithms/InvalidParameter.h
inc/MantidMDAlgorithms/InvalidParameterParser.h
inc/MantidMDAlgorithms/LessThanMD.h
inc/MantidMDAlgorithms/LogarithmMD.h
inc/MantidMDAlgorithms/MinusMD.h
inc/MantidMDAlgorithms/MultiplyMD.h
inc/MantidMDAlgorithms/NotMD.h
inc/MantidMDAlgorithms/NullImplicitFunction.h
inc/MantidMDAlgorithms/OrMD.h
inc/MantidMDAlgorithms/PlusMD.h
inc/MantidMDAlgorithms/PowerMD.h
inc/MantidMDAlgorithms/QuadEnBackground.h
......@@ -59,6 +74,7 @@ set ( INC_FILES
inc/MantidMDAlgorithms/UnaryOperationMD.h
inc/MantidMDAlgorithms/Vector3DParameter.h
inc/MantidMDAlgorithms/Vector3DParameterParser.h
inc/MantidMDAlgorithms/XorMD.h
)
# Test files. Other source files required.
......@@ -67,21 +83,29 @@ set ( TEST_FILES
#test/CobaltSWDTest.h
#test/CreateMDFitWorkspaceTest.h
#test/QuadEnBackgroundTest.h
test/AndMDTest.h
test/BooleanBinaryOperationMDTest.h
test/ConvertToQ3DdETest.h
test/ConvertToQNDanyTest.h
test/DivideMDTest.h
test/EqualToMDTest.h
test/ExponentialMDTest.h
test/GreaterThanMDTest.h
test/InvalidParameterParserTest.h
test/InvalidParameterTest.h
test/LessThanMDTest.h
test/LogarithmMDTest.h
test/MinusMDTest.h
test/MultiplyMDTest.h
test/NotMDTest.h
test/OrMDTest.h
test/PlusMDTest.h
test/PowerMDTest.h
test/RunParamTest.h
test/SimulateMDDTest.h
test/TobyFitSimulateTest.h
test/UnaryOperationMDTest.h
test/XorMDTest.h
)
set ( GMOCK_TEST_FILES
......
#ifndef MANTID_MDALGORITHMS_ANDMD_H_
#define MANTID_MDALGORITHMS_ANDMD_H_
#include "MantidKernel/System.h"
#include "MantidAPI/Algorithm.h"
#include "MantidMDAlgorithms/BinaryOperationMD.h"
#include "MantidMDAlgorithms/BooleanBinaryOperationMD.h"
namespace Mantid
{
namespace MDAlgorithms
{
/** AndMD : Perform the And boolean operation on two MDHistoWorkspaces
@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 AndMD : public BooleanBinaryOperationMD
{
public:
AndMD();
virtual ~AndMD();
virtual const std::string name() const;
virtual int version() const;
private:
void execHistoHisto(Mantid::MDEvents::MDHistoWorkspace_sptr out, Mantid::MDEvents::MDHistoWorkspace_const_sptr operand);
};
} // namespace MDAlgorithms
} // namespace Mantid
#endif /* MANTID_MDALGORITHMS_ANDMD_H_ */
#ifndef MANTID_MDALGORITHMS_BOOLEANBINARYOPERATIONMD_H_
#define MANTID_MDALGORITHMS_BOOLEANBINARYOPERATIONMD_H_
#include "MantidKernel/System.h"
#include "MantidAPI/Algorithm.h"
#include "MantidMDAlgorithms/BinaryOperationMD.h"
namespace Mantid
{
namespace MDAlgorithms
{
/** BooleanBinaryOperationMD : base class for boolean-type operations on MDHistoWorkspaces
@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 BooleanBinaryOperationMD : public BinaryOperationMD
{
public:
BooleanBinaryOperationMD();
virtual ~BooleanBinaryOperationMD();
virtual const std::string name() const;
virtual int version() const;
protected:
/// Return true if the algorithm can operate on a scalar.
virtual bool acceptScalar()
{ return true; }
virtual void initDocs();
bool commutative() const;
void checkInputs();
void execEvent();
virtual void execHistoScalar(Mantid::MDEvents::MDHistoWorkspace_sptr out, Mantid::DataObjects::WorkspaceSingleValue_const_sptr scalar);
/// Run the algorithm with a MDHisotWorkspace as output and operand
virtual void execHistoHisto(Mantid::MDEvents::MDHistoWorkspace_sptr out, Mantid::MDEvents::MDHistoWorkspace_const_sptr operand) = 0;
};
} // namespace MDAlgorithms
} // namespace Mantid
#endif /* MANTID_MDALGORITHMS_BOOLEANBINARYOPERATIONMD_H_ */
#ifndef MANTID_MDALGORITHMS_EQUALTOMD_H_
#define MANTID_MDALGORITHMS_EQUALTOMD_H_
#include "MantidKernel/System.h"
#include "MantidAPI/Algorithm.h"
#include "MantidMDAlgorithms/BooleanBinaryOperationMD.h"
namespace Mantid
{
namespace MDAlgorithms
{
/** EqualToMD : boolean operation on MDHistoWorkspaces
@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 EqualToMD : public BooleanBinaryOperationMD
{
public:
EqualToMD();
virtual ~EqualToMD();
virtual const std::string name() const;
virtual int version() const;
private:
bool acceptScalar() { return true; }
void execHistoHisto(Mantid::MDEvents::MDHistoWorkspace_sptr out, Mantid::MDEvents::MDHistoWorkspace_const_sptr operand);
void execHistoScalar(Mantid::MDEvents::MDHistoWorkspace_sptr out, Mantid::DataObjects::WorkspaceSingleValue_const_sptr scalar);
};
} // namespace MDAlgorithms
} // namespace Mantid
#endif /* MANTID_MDALGORITHMS_EQUALTOMD_H_ */
#ifndef MANTID_MDALGORITHMS_GREATERTHANMD_H_
#define MANTID_MDALGORITHMS_GREATERTHANMD_H_
#include "MantidKernel/System.h"
#include "MantidAPI/Algorithm.h"
#include "MantidMDAlgorithms/BooleanBinaryOperationMD.h"
namespace Mantid
{
namespace MDAlgorithms
{
/** GreaterThanMD : boolean operation on MDHistoWorkspaces
@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 GreaterThanMD : public BooleanBinaryOperationMD
{
public:
GreaterThanMD();
virtual ~GreaterThanMD();
virtual const std::string name() const;
virtual int version() const;
private:
bool acceptScalar() { return true; }
bool commutative() { return false; }
void execHistoHisto(Mantid::MDEvents::MDHistoWorkspace_sptr out, Mantid::MDEvents::MDHistoWorkspace_const_sptr operand);
void execHistoScalar(Mantid::MDEvents::MDHistoWorkspace_sptr out, Mantid::DataObjects::WorkspaceSingleValue_const_sptr scalar);
};
} // namespace MDAlgorithms
} // namespace Mantid
#endif /* MANTID_MDALGORITHMS_GREATERTHANMD_H_ */
#ifndef MANTID_MDALGORITHMS_LESSTHANMD_H_
#define MANTID_MDALGORITHMS_LESSTHANMD_H_
#include "MantidKernel/System.h"
#include "MantidAPI/Algorithm.h"
#include "MantidMDAlgorithms/BooleanBinaryOperationMD.h"
namespace Mantid
{
namespace MDAlgorithms
{
/** LessThanMD : boolean operation on MDHistoWorkspaces
@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 LessThanMD : public BooleanBinaryOperationMD
{
public:
LessThanMD();
virtual ~LessThanMD();
virtual const std::string name() const;
virtual int version() const;
private:
bool acceptScalar() { return true; }
bool commutative() { return false; }
void execHistoHisto(Mantid::MDEvents::MDHistoWorkspace_sptr out, Mantid::MDEvents::MDHistoWorkspace_const_sptr operand);
void execHistoScalar(Mantid::MDEvents::MDHistoWorkspace_sptr out, Mantid::DataObjects::WorkspaceSingleValue_const_sptr scalar);
};
} // namespace MDAlgorithms
} // namespace Mantid
#endif /* MANTID_MDALGORITHMS_LESSTHANMD_H_ */
#ifndef MANTID_MDALGORITHMS_NOTMD_H_
#define MANTID_MDALGORITHMS_NOTMD_H_
#include "MantidKernel/System.h"
#include "MantidAPI/Algorithm.h"
namespace Mantid
{
namespace MDAlgorithms
{
/** NotMD : TODO: DESCRIPTION
@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 NotMD : public API::Algorithm
{
public:
NotMD();
virtual ~NotMD();
virtual const std::string name() const;
virtual int version() const;
virtual const std::string category() const;
private:
virtual void initDocs();
void init();
void exec();
};
} // namespace MDAlgorithms
} // namespace Mantid
#endif /* MANTID_MDALGORITHMS_NOTMD_H_ */
\ No newline at end of file
#ifndef MANTID_MDALGORITHMS_ORMD_H_
#define MANTID_MDALGORITHMS_ORMD_H_
#include "MantidKernel/System.h"
#include "MantidAPI/Algorithm.h"
#include "MantidMDAlgorithms/BooleanBinaryOperationMD.h"
namespace Mantid
{
namespace MDAlgorithms
{
/** OrMD : boolean operation on MDHistoWorkspaces
@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 OrMD : public BooleanBinaryOperationMD
{
public:
OrMD();
virtual ~OrMD();
virtual const std::string name() const;
virtual int version() const;
private:
void execHistoHisto(Mantid::MDEvents::MDHistoWorkspace_sptr out, Mantid::MDEvents::MDHistoWorkspace_const_sptr operand);
};
} // namespace MDAlgorithms
} // namespace Mantid
#endif /* MANTID_MDALGORITHMS_ORMD_H_ */
#ifndef MANTID_MDALGORITHMS_XORMD_H_
#define MANTID_MDALGORITHMS_XORMD_H_
#include "MantidKernel/System.h"
#include "MantidAPI/Algorithm.h"
#include "MantidMDAlgorithms/BooleanBinaryOperationMD.h"
namespace Mantid
{
namespace MDAlgorithms
{
/** XorMD : boolean operation on MDHistoWorkspaces
@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 XorMD : public BooleanBinaryOperationMD
{
public:
XorMD();
virtual ~XorMD();
virtual const std::string name() const;
virtual int version() const;
private:
void execHistoHisto(Mantid::MDEvents::MDHistoWorkspace_sptr out, Mantid::MDEvents::MDHistoWorkspace_const_sptr operand);
};
} // namespace MDAlgorithms
} // namespace Mantid
#endif /* MANTID_MDALGORITHMS_XORMD_H_ */
/*WIKI*
Perform the And boolean operation on two MDHistoWorkspaces.
The && operation is performed element-by-element.
A signal of 0.0 means "false" and any non-zero signal is "true".
*WIKI*/
#include "MantidMDAlgorithms/AndMD.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(AndMD)
//----------------------------------------------------------------------------------------------
/** Constructor
*/
AndMD::AndMD()
{ }
//----------------------------------------------------------------------------------------------
/** Destructor
*/
AndMD::~AndMD()
{ }
//----------------------------------------------------------------------------------------------
/// Algorithm's name for identification. @see Algorithm::name
const std::string AndMD::name() const { return "AndMD";};
/// Algorithm's version for identification. @see Algorithm::version
int AndMD::version() const { return 1;};
//----------------------------------------------------------------------------------------------
/// Run the algorithm with a MDHisotWorkspace as output and operand
void AndMD::execHistoHisto(Mantid::MDEvents::MDHistoWorkspace_sptr out, Mantid::MDEvents::MDHistoWorkspace_const_sptr operand)
{
out->operator &=(*operand);
}
} // namespace Mantid
} // namespace MDAlgorithms
/*WIKI*
TODO: Enter a full wiki-markup description of your algorithm here. You can then use the Build/wiki_maker.py script to generate your full wiki page.
*WIKI*/
#include "MantidMDAlgorithms/BooleanBinaryOperationMD.h"
#include "MantidKernel/System.h"
using namespace Mantid::Kernel;
using namespace Mantid::API;
namespace Mantid
{
namespace MDAlgorithms
{
//----------------------------------------------------------------------------------------------
/** Constructor
*/
BooleanBinaryOperationMD::BooleanBinaryOperationMD()
{ }
//----------------------------------------------------------------------------------------------
/** Destructor
*/
BooleanBinaryOperationMD::~BooleanBinaryOperationMD()
{ }
//----------------------------------------------------------------------------------------------
/// Algorithm's name for identification. @see Algorithm::name
const std::string BooleanBinaryOperationMD::name() const { return "BooleanBinaryOperationMD";};
/// Algorithm's version for identification. @see Algorithm::version
int BooleanBinaryOperationMD::version() const { return 1;};
//----------------------------------------------------------------------------------------------
/// Sets documentation strings for this algorithm
void BooleanBinaryOperationMD::initDocs()
{
std::string algo = this->name();
algo = algo.substr(0, algo.size()-2);
this->setWikiSummary("Perform the " + algo + " boolean operation on two MDHistoWorkspaces");
this->setOptionalMessage("Perform the " + algo + " boolean operation on two MDHistoWorkspaces");
}
//----------------------------------------------------------------------------------------------
/// Is the operation commutative?
bool BooleanBinaryOperationMD::commutative() const
{ return true; }
//----------------------------------------------------------------------------------------------
/// Check the inputs and throw if the algorithm cannot be run
void BooleanBinaryOperationMD::checkInputs()
{
if (m_lhs_event || m_rhs_event)
throw std::runtime_error("Cannot perform the " + this->name() + " operation on a MDEventWorkspace.");
if (!acceptScalar() && (m_lhs_scalar || m_rhs_scalar))
throw std::runtime_error("Cannot perform the " + this->name() + " operation on a WorkspaceSingleValue.");
}
//----------------------------------------------------------------------------------------------
/// Run the algorithm with an MDEventWorkspace as output
void BooleanBinaryOperationMD::execEvent()
{
throw std::runtime_error("Cannot perform the " + this->name() + " operation on a MDEventWorkspace.");
}
//----------------------------------------------------------------------------------------------
/// Run the algorithm with a MDHisotWorkspace as output, scalar and operand
void BooleanBinaryOperationMD::execHistoScalar(Mantid::MDEvents::MDHistoWorkspace_sptr out, Mantid::DataObjects::WorkspaceSingleValue_const_sptr scalar)
{
throw std::runtime_error("Cannot perform the " + this->name() + " operation on a WorkspaceSingleValue.");
}
} // namespace Mantid
} // namespace MDAlgorithms
/*WIKI*
Perform the == (equals to) boolean operation on two MDHistoWorkspaces or a MDHistoWorkspace and a scalar.
The output workspace has a signal of 0.0 to mean "false" and a signal of 1.0 to mean "true". Errors are 0.
For two MDHistoWorkspaces, the operation is performed element-by-element.
For a MDHistoWorkspace and a scalar, the operation is performed on each element of the output.
*WIKI*/
#include "MantidMDAlgorithms/EqualToMD.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(EqualToMD)
//----------------------------------------------------------------------------------------------
/** Constructor
*/
EqualToMD::EqualToMD()
{ }
//----------------------------------------------------------------------------------------------
/** Destructor
*/
EqualToMD::~EqualToMD()
{ }
//----------------------------------------------------------------------------------------------
/// Algorithm's name for identification. @see Algorithm::name
const std::string EqualToMD::name() const { return "EqualToMD";};
/// Algorithm's version for identification. @see Algorithm::version
int EqualToMD::version() const { return 1;};
//----------------------------------------------------------------------------------------------
/// Run the algorithm with a MDHisotWorkspace as output and operand
void EqualToMD::execHistoHisto(Mantid::MDEvents::MDHistoWorkspace_sptr out, Mantid::MDEvents::MDHistoWorkspace_const_sptr operand)
{
out->equalTo(*operand);
}
//----------------------------------------------------------------------------------------------
/// Run the algorithm with a MDHisotWorkspace as output and a scalar on the RHS
void EqualToMD::execHistoScalar(Mantid::MDEvents::MDHistoWorkspace_sptr out, Mantid::DataObjects::WorkspaceSingleValue_const_sptr scalar)
{
out->equalTo(scalar->dataY(0)[0]);
}
} // namespace Mantid
} // namespace MDAlgorithms
/*WIKI*
Perform the > (greater-than) boolean operation on two MDHistoWorkspaces or a MDHistoWorkspace and a scalar.
The output workspace has a signal of 0.0 to mean "false" and a signal of 1.0 to mean "true". Errors are 0.
For two MDHistoWorkspaces, the operation is performed element-by-element.
For a MDHistoWorkspace and a scalar, the operation is performed on each element of the output.
*WIKI*/
#include "MantidMDAlgorithms/GreaterThanMD.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(GreaterThanMD)
//----------------------------------------------------------------------------------------------
/** Constructor
*/
GreaterThanMD::GreaterThanMD()
{ }
//----------------------------------------------------------------------------------------------
/** Destructor
*/
GreaterThanMD::~GreaterThanMD()
{ }
//----------------------------------------------------------------------------------------------
/// Algorithm's name for identification. @see Algorithm::name
const std::string GreaterThanMD::name() const { return "GreaterThanMD";};
/// Algorithm's version for identification. @see Algorithm::version
int GreaterThanMD::version() const { return 1;};
//----------------------------------------------------------------------------------------------
/// Run the algorithm with a MDHisotWorkspace as output and operand
void GreaterThanMD::execHistoHisto(Mantid::MDEvents::MDHistoWorkspace_sptr out, Mantid::MDEvents::MDHistoWorkspace_const_sptr operand)
{
out->greaterThan(*operand);
}
//----------------------------------------------------------------------------------------------
/// Run the algorithm with a MDHisotWorkspace as output and a scalar on the RHS
void GreaterThanMD::execHistoScalar(Mantid::MDEvents::MDHistoWorkspace_sptr out, Mantid::DataObjects::WorkspaceSingleValue_const_sptr scalar)
{
out->greaterThan(scalar->dataY(0)[0]);
}
} // namespace Mantid
} // namespace MDAlgorithms
/*WIKI*
Perform the < (less-than) boolean operation on two MDHistoWorkspaces or a MDHistoWorkspace and a scalar.
The output workspace has a signal of 0.0 to mean "false" and a signal of 1.0 to mean "true". Errors are 0.
For two MDHistoWorkspaces, the operation is performed element-by-element.
For a MDHistoWorkspace and a scalar, the operation is performed on each element of the output.
*WIKI*/
#include "MantidMDAlgorithms/LessThanMD.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(LessThanMD)
//----------------------------------------------------------------------------------------------
/** Constructor
*/
LessThanMD::LessThanMD()
{ }
//----------------------------------------------------------------------------------------------
/** Destructor
*/
LessThanMD::~LessThanMD()
{ }
//----------------------------------------------------------------------------------------------
/// Algorithm's name for identification. @see Algorithm::name
const std::string LessThanMD::name() const { return "LessThanMD";};
/// Algorithm's version for identification. @see Algorithm::version
int LessThanMD::version() const { return 1;};
//----------------------------------------------------------------------------------------------
/// Run the algorithm with a MDHisotWorkspace as output and operand
void LessThanMD::execHistoHisto(Mantid::MDEvents::MDHistoWorkspace_sptr out, Mantid::MDEvents::MDHistoWorkspace_const_sptr operand)
{
out->lessThan(*operand);
}
//----------------------------------------------------------------------------------------------
/// Run the algorithm with a MDHisotWorkspace as output and a scalar on the RHS
void LessThanMD::execHistoScalar(Mantid::MDEvents::MDHistoWorkspace_sptr out, Mantid::DataObjects::WorkspaceSingleValue_const_sptr scalar)
{
out->lessThan(scalar->dataY(0)[0]);
}
} // namespace Mantid
} // namespace MDAlgorithms
/*WIKI*
TODO: Enter a full wiki-markup description of your algorithm here. You can then use the Build/wiki_maker.py script to generate your full wiki page.
*WIKI*/
#include "MantidMDAlgorithms/NotMD.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(NotMD)
//----------------------------------------------------------------------------------------------
/** Constructor
*/
NotMD::NotMD()
{
}
//----------------------------------------------------------------------------------------------
/** Destructor
*/
NotMD::~NotMD()
{
}
//----------------------------------------------------------------------------------------------
/// Algorithm's name for identification. @see Algorithm::name
const std::string NotMD::name() const { return "NotMD";};
/// Algorithm's version for identification. @see Algorithm::version
int NotMD::version() const { return 1;};
/// Algorithm's category for identification. @see Algorithm::category
const std::string NotMD::category() const { return "General";}
//----------------------------------------------------------------------------------------------
/// Sets documentation strings for this algorithm
void NotMD::initDocs()
{
this->setWikiSummary("TODO: Enter a quick description of your algorithm.");
this->setOptionalMessage("TODO: Enter a quick description of your algorithm.");
}
//----------------------------------------------------------------------------------------------
/** Initialize the algorithm's properties.
*/
void NotMD::init()
{
declareProperty(new WorkspaceProperty<>("InputWorkspace","",Direction::Input), "An input workspace.");
declareProperty(new WorkspaceProperty<>("OutputWorkspace","",Direction::Output), "An output workspace.");
}
//----------------------------------------------------------------------------------------------
/** Execute the algorithm.
*/
void NotMD::exec()
{
// TODO Auto-generated execute stub
}
} // namespace Mantid
} // namespace MDAlgorithms
\ No newline at end of file
/*WIKI*
Perform the Or boolean operation on two MDHistoWorkspaces.
The || operation is performed element-by-element.
A signal of 0.0 means "false" and any non-zero signal is "true".
*WIKI*/
#include "MantidMDAlgorithms/OrMD.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(OrMD)
//----------------------------------------------------------------------------------------------
/** Constructor
*/
OrMD::OrMD()
{ }
//----------------------------------------------------------------------------------------------
/** Destructor
*/
OrMD::~OrMD()
{ }
//----------------------------------------------------------------------------------------------
/// Algorithm's name for identification. @see Algorithm::name
const std::string OrMD::name() const { return "OrMD";};
/// Algorithm's version for identification. @see Algorithm::version
int OrMD::version() const { return 1;};
//----------------------------------------------------------------------------------------------
/// Run the algorithm with a MDHisotWorkspace as output and operand
void OrMD::execHistoHisto(Mantid::MDEvents::MDHistoWorkspace_sptr out, Mantid::MDEvents::MDHistoWorkspace_const_sptr operand)
{
out->operator |=(*operand);
}
} // namespace Mantid
} // namespace MDAlgorithms
/*WIKI*
Perform the Xor (exclusive-or) boolean operation on two MDHistoWorkspaces.
The xor operation is performed element-by-element.
A signal of 0.0 means "false" and any non-zero signal is "true".
*WIKI*/
#include "MantidMDAlgorithms/XorMD.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(XorMD)
//----------------------------------------------------------------------------------------------
/** Constructor
*/
XorMD::XorMD()
{ }
//----------------------------------------------------------------------------------------------
/** Destructor
*/
XorMD::~XorMD()
{ }
//----------------------------------------------------------------------------------------------
/// Algorithm's name for identification. @see Algorithm::name
const std::string XorMD::name() const { return "XorMD";};
/// Algorithm's version for identification. @see Algorithm::version
int XorMD::version() const { return 1;};
//----------------------------------------------------------------------------------------------
/// Run the algorithm with a MDHisotWorkspace as output and operand
void XorMD::execHistoHisto(Mantid::MDEvents::MDHistoWorkspace_sptr out, Mantid::MDEvents::MDHistoWorkspace_const_sptr operand)
{
out->operator ^=(*operand);
}
} // namespace Mantid
} // namespace MDAlgorithms
#ifndef MANTID_MDALGORITHMS_ANDMDTEST_H_
#define MANTID_MDALGORITHMS_ANDMDTEST_H_
#include <cxxtest/TestSuite.h>
#include "MantidKernel/Timer.h"
#include "MantidKernel/System.h"
#include <iostream>
#include <iomanip>
#include "MantidMDAlgorithms/AndMD.h"
using namespace Mantid;
using namespace Mantid::MDAlgorithms;
using namespace Mantid::API;
class AndMDTest : public CxxTest::TestSuite
{
public:
// This pair of boilerplate methods prevent the suite being created statically
// This means the constructor isn't called when running other tests
static AndMDTest *createSuite() { return new AndMDTest(); }
static void destroySuite( AndMDTest *suite ) { delete suite; }
void test_Init()
{
AndMD alg;
TS_ASSERT_THROWS_NOTHING( alg.initialize() )
TS_ASSERT( alg.isInitialized() )
}
void test_exec()
{
// Name of the output workspace.
std::string outWSName("AndMDTest_OutputWS");
AndMD alg;
TS_ASSERT_THROWS_NOTHING( alg.initialize() )
TS_ASSERT( alg.isInitialized() )
TS_ASSERT_THROWS_NOTHING( alg.setPropertyValue("REPLACE_PROPERTY_NAME_HERE!!!!", "value") );
TS_ASSERT_THROWS_NOTHING( alg.setPropertyValue("OutputWorkspace", outWSName) );
TS_ASSERT_THROWS_NOTHING( alg.execute(); );
TS_ASSERT( alg.isExecuted() );
// Retrieve the workspace from data service. TODO: Change to your desired type
Workspace_sptr ws;
TS_ASSERT_THROWS_NOTHING( ws = boost::dynamic_pointer_cast<Workspace>(AnalysisDataService::Instance().retrieve(outWSName)) );
TS_ASSERT(ws);
if (!ws) return;
// TODO: Check the results
// Remove workspace from the data service.
AnalysisDataService::Instance().remove(outWSName);
}
void test_Something()
{
}
};
#endif /* MANTID_MDALGORITHMS_ANDMDTEST_H_ */
\ No newline at end of file
#ifndef MANTID_MDALGORITHMS_BOOLEANBINARYOPERATIONMDTEST_H_
#define MANTID_MDALGORITHMS_BOOLEANBINARYOPERATIONMDTEST_H_
#include <cxxtest/TestSuite.h>
#include "MantidKernel/Timer.h"
#include "MantidKernel/System.h"
#include <iostream>
#include <iomanip>
#include "MantidMDAlgorithms/BooleanBinaryOperationMD.h"
using namespace Mantid;
using namespace Mantid::MDAlgorithms;
using namespace Mantid::API;
class BooleanBinaryOperationMDTest : public CxxTest::TestSuite
{
public:
void test_Something()
{
//TODO?
}
};
#endif /* MANTID_MDALGORITHMS_BOOLEANBINARYOPERATIONMDTEST_H_ */
#ifndef MANTID_MDALGORITHMS_EQUALTOMDTEST_H_
#define MANTID_MDALGORITHMS_EQUALTOMDTEST_H_
#include <cxxtest/TestSuite.h>
#include "MantidKernel/Timer.h"
#include "MantidKernel/System.h"
#include <iostream>
#include <iomanip>
#include "MantidMDAlgorithms/EqualToMD.h"
using namespace Mantid;
using namespace Mantid::MDAlgorithms;
using namespace Mantid::API;
class EqualToMDTest : public CxxTest::TestSuite
{
public:
// This pair of boilerplate methods prevent the suite being created statically
// This means the constructor isn't called when running other tests
static EqualToMDTest *createSuite() { return new EqualToMDTest(); }
static void destroySuite( EqualToMDTest *suite ) { delete suite; }
void test_Init()
{
EqualToMD alg;
TS_ASSERT_THROWS_NOTHING( alg.initialize() )
TS_ASSERT( alg.isInitialized() )
}
void test_exec()
{
// Name of the output workspace.
std::string outWSName("EqualToMDTest_OutputWS");
EqualToMD alg;
TS_ASSERT_THROWS_NOTHING( alg.initialize() )
TS_ASSERT( alg.isInitialized() )
TS_ASSERT_THROWS_NOTHING( alg.setPropertyValue("REPLACE_PROPERTY_NAME_HERE!!!!", "value") );
TS_ASSERT_THROWS_NOTHING( alg.setPropertyValue("OutputWorkspace", outWSName) );
TS_ASSERT_THROWS_NOTHING( alg.execute(); );
TS_ASSERT( alg.isExecuted() );
// Retrieve the workspace from data service. TODO: Change to your desired type
Workspace_sptr ws;
TS_ASSERT_THROWS_NOTHING( ws = boost::dynamic_pointer_cast<Workspace>(AnalysisDataService::Instance().retrieve(outWSName)) );
TS_ASSERT(ws);
if (!ws) return;
// TODO: Check the results
// Remove workspace from the data service.
AnalysisDataService::Instance().remove(outWSName);
}
void test_Something()
{
}
};
#endif /* MANTID_MDALGORITHMS_EQUALTOMDTEST_H_ */
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment