18void
Multiply::performBinaryOperation(const HistogramData::Histogram &lhs, const HistogramData::Histogram &
rhs,
19 HistogramData::HistogramY &YOut, HistogramData::HistogramE &EOut) {
20 const size_t bins = lhs.e().size();
21 for (
size_t j = 0; j < bins; ++j) {
23 const double leftY = lhs.y()[j];
24 const double rightY =
rhs.y()[j];
31 EOut[j] = sqrt(pow(lhs.e()[j] * rightY, 2) + pow(
rhs.e()[j] * leftY, 2));
35 YOut[j] = leftY * rightY;
40 HistogramData::HistogramY &YOut, HistogramData::HistogramE &EOut) {
41 const size_t bins = lhs.e().size();
42 for (
size_t j = 0; j < bins; ++j) {
44 const double leftY = lhs.y()[j];
47 EOut[j] = sqrt(pow(lhs.e()[j] * rhsY, 2) + pow(rhsE * leftY, 2));
51 YOut[j] = leftY * rhsY;
57 if (!lhs->isDistribution() || !
rhs->isDistribution())
58 out->setDistribution(
false);
72 rhs.generateHistogram(
rhs.x().rawData(), rhsY, rhsE);
156 if (
rhs->size() == 1)
161 if (lhs->size() == 1)
162 return "The left side cannot contain a single value if the right side "
163 "isn't also a single value.";
168 if (
m_rhsBlocksize == 1 && lhs->getNumberHistograms() ==
rhs->getNumberHistograms())
175 return "X arrays must match when multiplying 2D workspaces.";
180 const size_t rhsSpec =
rhs->getNumberHistograms();
196 if (lhs->getNumberHistograms() ==
rhs->getNumberHistograms()) {
199 return "Number of histograms not identical.";
#define DECLARE_ALGORITHM(classname)
const std::vector< double > & rhs
size_t m_rhsBlocksize
Cache for RHS workspace's blocksize.
bool m_keepEventWorkspace
Variable set to true if the operation allows the output to stay as an EventWorkspace.
bool m_AllowDifferentNumberSpectra
The property value.
bool m_useHistogramForRhsEventWorkspace
Are we going to use the histogram representation of the RHS event list when performing the operation?...
bool m_matchXSize
matchXSize set to true if the X sizes of histograms must match.
bool m_flipSides
flipSides set to true if the rhs and lhs operands should be flipped - for commutative binary operatio...
DataObjects::EventWorkspace_const_sptr m_erhs
Right-hand side EventWorkspace.
size_t m_lhsBlocksize
Cache for LHS workspace's blocksize.
DataObjects::EventWorkspace_const_sptr m_elhs
Left-hand side EventWorkspace.
API::MatrixWorkspace_const_sptr m_rhs
Right-hand side workspace.
API::MatrixWorkspace_const_sptr m_lhs
Left-hand side workspace.
std::string checkSizeCompatibility(const API::MatrixWorkspace_const_sptr lhs, const API::MatrixWorkspace_const_sptr rhs) const override
Checks the overall size compatability of two workspaces.
Multiply performs the product of two input workspaces.
void performBinaryOperation(const HistogramData::Histogram &lhs, const HistogramData::Histogram &rhs, HistogramData::HistogramY &YOut, HistogramData::HistogramE &EOut) override
Carries out the binary operation on a single spectrum, with another spectrum as the right-hand operan...
void checkRequirements() override
Check what operation will be needed in order to apply the operation to these two types of workspaces.
std::string checkSizeCompatibility(const API::MatrixWorkspace_const_sptr lhs, const API::MatrixWorkspace_const_sptr rhs) const override
Performs a simple check to see if the sizes of two workspaces are compatible for a binary operation I...
void setOutputUnits(const API::MatrixWorkspace_const_sptr lhs, const API::MatrixWorkspace_const_sptr rhs, API::MatrixWorkspace_sptr out) override
Should be overridden by operations that need to manipulate the units of the output workspace.
void performEventBinaryOperation(DataObjects::EventList &lhs, const DataObjects::EventList &rhs) override
Carries out the binary operation IN-PLACE on a single EventList, with another EventList as the right-...
void multiply(const double value, const double error=0.0) override
Multiply the weights in this event list by a scalar variable with an error; though the error can be 0...
std::shared_ptr< const MatrixWorkspace > MatrixWorkspace_const_sptr
shared pointer to the matrix workspace base class (const version)
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
std::vector< double > MantidVec
typedef for the data storage used in Mantid matrix workspaces
static bool matchingBins(const MatrixWorkspace &ws1, const MatrixWorkspace &ws2, const bool firstOnly=false)
Checks whether the bins (X values) of two workspace are the same.