Mantid
Loading...
Searching...
No Matches
WorkspaceOpOverloads.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2008 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#pragma once
8
9#include "MantidAPI/DllConfig.h"
11#include <string>
12
13namespace Mantid {
14namespace API {
15
16namespace OperatorOverloads {
17// Helper function for operator overloads
18template <typename LHSType, typename RHSType, typename ResultType>
19DLLExport ResultType executeBinaryOperation(const std::string &algorithmName, const LHSType lhs, const RHSType rhs,
20 bool lhsAsOutput = false, bool child = true, const std::string &name = "",
21 bool rethrow = false);
22} // namespace OperatorOverloads
23
24bool MANTID_API_DLL equals(const MatrixWorkspace_sptr &lhs, const MatrixWorkspace_sptr &rhs, double tolerance = 0.0);
25
26// Workspace operator overloads
31
32MatrixWorkspace_sptr MANTID_API_DLL operator+(const MatrixWorkspace_sptr &lhs, const double &rhsValue);
33MatrixWorkspace_sptr MANTID_API_DLL operator-(const MatrixWorkspace_sptr &lhs, const double &rhsValue);
34MatrixWorkspace_sptr MANTID_API_DLL operator-(const double &lhsValue, const MatrixWorkspace_sptr &rhs);
35MatrixWorkspace_sptr MANTID_API_DLL operator*(const MatrixWorkspace_sptr &lhs, const double &rhsValue);
36MatrixWorkspace_sptr MANTID_API_DLL operator*(const double &lhsValue, const MatrixWorkspace_sptr &rhs);
37MatrixWorkspace_sptr MANTID_API_DLL operator/(const MatrixWorkspace_sptr &lhs, const double &rhsValue);
38MatrixWorkspace_sptr MANTID_API_DLL operator/(const double &lhsValue, const MatrixWorkspace_sptr &rhs);
39
44
45MatrixWorkspace_sptr MANTID_API_DLL operator+=(const MatrixWorkspace_sptr &lhs, const double &rhsValue);
46MatrixWorkspace_sptr MANTID_API_DLL operator-=(const MatrixWorkspace_sptr &lhs, const double &rhsValue);
47MatrixWorkspace_sptr MANTID_API_DLL operator*=(const MatrixWorkspace_sptr &lhs, const double &rhsValue);
48MatrixWorkspace_sptr MANTID_API_DLL operator/=(const MatrixWorkspace_sptr &lhs, const double &rhsValue);
49
55struct MANTID_API_DLL WorkspaceHelpers {
56 // Checks whether the binning is the same in two workspaces
57 static bool matchingBins(const MatrixWorkspace &ws1, const MatrixWorkspace &ws2, const bool firstOnly = false);
58 // Checks whether a the X vectors in a workspace are actually the same vector
59 static bool sharedXData(const MatrixWorkspace &WS);
60 // Divides the data in a workspace by the bin width to make it a distribution
61 // (or the reverse)
62 static void makeDistribution(const MatrixWorkspace_sptr &workspace, const bool forwards = true);
63};
64
65} // namespace API
66} // namespace Mantid
const std::vector< double > & rhs
IPeaksWorkspace_sptr workspace
Definition: IndexPeaks.cpp:114
double tolerance
#define DLLExport
Definitions of the DLLImport compiler directives for MSVC.
Definition: System.h:53
Base MatrixWorkspace Abstract Class.
DLLExport ResultType executeBinaryOperation(const std::string &algorithmName, const LHSType lhs, const RHSType rhs, bool lhsAsOutput=false, bool child=true, const std::string &name="", bool rethrow=false)
Performs a binary operation on two workspaces.
MatrixWorkspace_sptr MANTID_API_DLL operator*(const MatrixWorkspace_sptr &lhs, const MatrixWorkspace_sptr &rhs)
Multiply two workspaces.
bool MANTID_API_DLL equals(const MatrixWorkspace_sptr &lhs, const MatrixWorkspace_sptr &rhs, double tolerance=0.0)
Performs a comparison operation on two workspaces, using the CompareWorkspaces algorithm.
MatrixWorkspace_sptr MANTID_API_DLL operator/=(const MatrixWorkspace_sptr &lhs, const MatrixWorkspace_sptr &rhs)
Divide two workspaces.
MatrixWorkspace_sptr MANTID_API_DLL operator+=(const MatrixWorkspace_sptr &lhs, const MatrixWorkspace_sptr &rhs)
Adds two workspaces.
MatrixWorkspace_sptr MANTID_API_DLL operator-=(const MatrixWorkspace_sptr &lhs, const MatrixWorkspace_sptr &rhs)
Subtracts two workspaces.
MatrixWorkspace_sptr MANTID_API_DLL operator-(const MatrixWorkspace_sptr &lhs, const MatrixWorkspace_sptr &rhs)
Subtracts two workspaces.
MatrixWorkspace_sptr MANTID_API_DLL operator*=(const MatrixWorkspace_sptr &lhs, const MatrixWorkspace_sptr &rhs)
Multiply two workspaces.
MatrixWorkspace_sptr MANTID_API_DLL operator/(const MatrixWorkspace_sptr &lhs, const MatrixWorkspace_sptr &rhs)
Divide two workspaces.
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
MatrixWorkspace_sptr MANTID_API_DLL operator+(const MatrixWorkspace_sptr &lhs, const MatrixWorkspace_sptr &rhs)
Adds two workspaces.
Helper class which provides the Collimation Length for SANS instruments.
A collection of static functions for use with workspaces.