Mantid
Loading...
Searching...
No Matches
FunctionValues.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//----------------------------------------------------------------------
12#include "MantidAPI/DllConfig.h"
14
15#include <vector>
16
17namespace Mantid {
18namespace API {
25class MANTID_API_DLL FunctionValues {
26public:
28 explicit FunctionValues(size_t n = 0);
30 explicit FunctionValues(const FunctionDomain &domain);
32 size_t size() const { return m_calculated.size(); }
34 void expand(size_t n);
35
37 double *getPointerToCalculated(size_t i);
39 void zeroCalculated();
41 void setCalculated(double value);
42
44 void reset(const FunctionDomain &domain);
48 void setCalculated(size_t i, double value) { m_calculated[i] = value; }
51 double getCalculated(size_t i) const { return m_calculated[i]; }
54 double operator[](size_t i) const { return m_calculated[i]; }
58 void addToCalculated(size_t i, double value) { m_calculated[i] += value; }
59
65 void addToCalculated(size_t start, const FunctionValues &values);
66
68 void setFitData(size_t i, double value);
70 void setFitData(const std::vector<double> &values);
72 double getFitData(size_t i) const;
74 void setFitWeight(size_t i, double value);
76 void setFitWeights(const std::vector<double> &values);
78 void setFitWeights(const double &value);
80 double getFitWeight(size_t i) const;
83 void setFitDataFromCalculated(const FunctionValues &values);
84
86 std::vector<double> toVector() const { return m_calculated; }
87
88protected:
91 void copyTo(double *to) const;
94 void add(double *to) const;
98 void multiply(double *to) const;
100 std::vector<double> m_calculated;
102 std::vector<double> m_data;
104 std::vector<double> m_weights;
105};
106
108using FunctionValues_sptr = std::shared_ptr<FunctionValues>;
109
110} // namespace API
111} // namespace Mantid
double value
The value of the point.
Definition: FitMW.cpp:51
Base class that represents the domain of a function.
A class to store values calculated by a function.
void addToCalculated(size_t i, double value)
Add a number to a calculated value.
std::vector< double > m_calculated
buffer for calculated values
void setCalculated(size_t i, double value)
Store i-th calculated value.
double operator[](size_t i) const
Get i-th calculated value.
std::vector< double > m_weights
buffer for fitting weights (reciprocal errors)
size_t size() const
Return the number of values.
std::vector< double > m_data
buffer for fit data
std::vector< double > toVector() const
Return the calculated values as a vector.
double getCalculated(size_t i) const
Get i-th calculated value.
std::shared_ptr< FunctionValues > FunctionValues_sptr
typedef for a shared pointer
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)
Multiply two workspaces.
Helper class which provides the Collimation Length for SANS instruments.