Mantid
Loading...
Searching...
No Matches
FunctionDomain1D.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2009 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//----------------------------------------------------------------------
10// Includes
11//----------------------------------------------------------------------
13
14#include <vector>
15
16namespace Mantid {
17namespace API {
30class MANTID_API_DLL FunctionDomain1D : public FunctionDomain {
31public:
37 size_t size() const override { return m_n; }
40 double operator[](size_t i) const { return m_data[i]; }
42 const double *getPointerAt(size_t i) const { return m_data + i; }
44 std::vector<double> toVector() const;
46 void setPeakRadius(int radius);
48 int getPeakRadius() const;
49
50protected:
53 FunctionDomain1D(const double *x, size_t n);
55 void resetData(const double *x, size_t n) {
56 m_data = x;
57 m_n = n;
58 }
59
60private:
62 const double *m_data;
64 size_t m_n;
67};
68
72class MANTID_API_DLL FunctionDomain1DVector : public FunctionDomain1D {
73public:
75 FunctionDomain1DVector(const double x);
77 FunctionDomain1DVector(const double startX, const double endX, const size_t n);
79 FunctionDomain1DVector(const std::vector<double> &xvalues);
81 FunctionDomain1DVector(std::vector<double> &&xvalues);
83 FunctionDomain1DVector(std::vector<double>::const_iterator from, std::vector<double>::const_iterator to);
89 std::vector<double> getVector() { return m_X; }
90
91protected:
92 std::vector<double> m_X;
93};
94
98class MANTID_API_DLL FunctionDomain1DView : public FunctionDomain1D {
99public:
105 FunctionDomain1DView(const double *x, size_t n) : FunctionDomain1D(x, n) {}
106
107private:
112};
113
121public:
123 FunctionDomain1DSpectrum(size_t wi, const std::vector<double> &xvalues);
125 FunctionDomain1DSpectrum(size_t wi, std::vector<double>::const_iterator from, std::vector<double>::const_iterator to);
127 size_t getWorkspaceIndex() const { return m_workspaceIndex; }
128
129private:
132};
133
138class MANTID_API_DLL FunctionDomain1DHistogram : public FunctionDomain1D {
139public:
141 FunctionDomain1DHistogram(const std::vector<double> &bins);
143 FunctionDomain1DHistogram(std::vector<double>::const_iterator from, std::vector<double>::const_iterator to);
144
147
150
152 double leftBoundary() const;
153
154protected:
155 std::vector<double> m_bins;
156};
157
159using FunctionDomain1D_sptr = std::shared_ptr<FunctionDomain1D>;
161using FunctionDomain1D_const_sptr = std::shared_ptr<const FunctionDomain1D>;
162
163} // namespace API
164} // namespace Mantid
double right
Definition: LineProfile.cpp:81
double radius
Definition: Rasterize.cpp:31
const std::vector< Type > & m_data
Definition: TableColumn.h:417
Implements FunctionDomain1D as a set of bins for a histogram.
FunctionDomain1DHistogram & operator=(const FunctionDomain1DHistogram &)=delete
Disable assignment operator.
FunctionDomain1DHistogram(const FunctionDomain1DHistogram &)=delete
Disable copy operator.
std::vector< double > m_bins
vector of bin boundaries
Specialization of FunctionDomain1DVector for spectra of MatrixWorkspaces.
size_t m_workspaceIndex
The workspace index.
size_t getWorkspaceIndex() const
Get the workspace index.
Implements FunctionDomain1D with its own storage in form of a std::vector.
std::vector< double > getVector()
Get the underlying vector.
std::vector< double > m_X
vector of function arguments
1D domain - a wrapper around an array of doubles.
FunctionDomain1DView & operator=(const FunctionDomain1DView &)
Private copy assignment operator - copying is not allowed.
FunctionDomain1DView(const double *x, size_t n)
Creates a FunctionDomain1DView pointing to an array of doubles of size n.
FunctionDomain1DView(const FunctionDomain1DView &)
Private copy constructor - copying is not allowed.
Represent a domain for functions of one real argument.
size_t size() const override
Return the number of arguments in the domain.
FunctionDomain1D & operator=(const FunctionDomain1D &)=delete
copying is not allowed.
size_t m_n
size of the data
const double * getPointerAt(size_t i) const
Get a pointer to i-th value.
int m_peakRadius
A peak radius that IPeakFunctions should use.
const double * m_data
pointer to the start of the domain data
double operator[](size_t i) const
Get an x value.
FunctionDomain1D(const FunctionDomain1D &right)=delete
copying is not allowed.
void resetData(const double *x, size_t n)
Reset the pointer and size of the domain.
Base class that represents the domain of a function.
std::shared_ptr< const FunctionDomain1D > FunctionDomain1D_const_sptr
typedef for a shared pointer to a const FunctionDomain1D
std::shared_ptr< FunctionDomain1D > FunctionDomain1D_sptr
typedef for a shared pointer to a FunctionDomain1D
Helper class which provides the Collimation Length for SANS instruments.