16 if (lhs->YUnit() !=
rhs->YUnit()) {
17 g_log.
error(
"The two workspaces are not compatible because they have "
18 "different units for the data (Y).");
21 if (lhs->isDistribution() !=
rhs->isDistribution()) {
22 g_log.
error(
"The two workspaces are not compatible because one is flagged "
23 "as a distribution.");
42 if (lhs->size() ==
rhs->size()) {
45 return "Workspaces not identically sized.";
50 HistogramData::HistogramY &YOut, HistogramData::HistogramE &EOut) {
51 const size_t bins = lhs.size();
52 for (
size_t j = 0; j < bins; ++j) {
53 if (lhs.e()[j] > 0.0 &&
rhs.e()[j] > 0.0) {
54 const double err1 = lhs.e()[j] * lhs.e()[j];
55 const double err2 =
rhs.e()[j] *
rhs.e()[j];
56 YOut[j] = (lhs.y()[j] / err1) + (
rhs.y()[j] / err2);
57 EOut[j] = (err1 * err2) / (err1 + err2);
59 EOut[j] = sqrt(EOut[j]);
60 }
else if (lhs.e()[j] > 0.0 &&
rhs.e()[j] <= 0.0) {
63 }
else if (lhs.e()[j] <= 0.0 &&
rhs.e()[j] > 0.0) {
74 HistogramData::HistogramY &YOut, HistogramData::HistogramE &EOut) {
75 assert(lhs.size() == 1);
77 if (lhs.e()[0] > 0.0 && rhsE > 0.0) {
78 const double err1 = lhs.e()[0] * lhs.e()[0];
79 const double err2 = rhsE * rhsE;
80 YOut[0] = (lhs.y()[0] / err1) + (rhsY / err2);
81 EOut[0] = (err1 * err2) / (err1 + err2);
83 EOut[0] = sqrt(EOut[0]);
84 }
else if (lhs.e()[0] > 0.0 && rhsE <= 0.0) {
87 }
else if (lhs.e()[0] <= 0.0 && rhsE > 0.0) {
#define DECLARE_ALGORITHM(classname)
const std::vector< double > & rhs
virtual bool checkCompatibility(const API::MatrixWorkspace_const_sptr lhs, const API::MatrixWorkspace_const_sptr rhs) const
Checks the compatibility of the two workspaces.
An algorithm to calculate the weighted mean of two 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...
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 identically sized.
void error(const std::string &msg)
Logs at error level.
Kernel::Logger g_log("ExperimentInfo")
static logger object
std::shared_ptr< const MatrixWorkspace > MatrixWorkspace_const_sptr
shared pointer to the matrix workspace base class (const version)