33 if (domain.
size() == 0) {
34 throw std::invalid_argument(
"FunctionValues cannot have zero size.");
45 throw std::invalid_argument(
"Cannot make FunctionValues smaller");
69 throw std::out_of_range(
"FunctionValue index out of range.");
104 throw std::runtime_error(
"Cannot add values: sizes do not match");
118 throw std::runtime_error(
"Cannot multiply values: sizes do not match");
133 if (start +
size() < values.
size()) {
134 throw std::runtime_error(
"Cannot add values: sizes do not match");
157 if (values.size() != this->size()) {
158 throw std::invalid_argument(
"Setting data of a wrong size");
160 m_data.assign(values.begin(), values.end());
169 throw std::runtime_error(
"Fitting data was not set");
192 if (values.size() != this->size()) {
193 throw std::invalid_argument(
"Setting data of a wrong size");
195 m_weights.assign(values.begin(), values.end());
210 throw std::runtime_error(
"Fitting weights was not set");
double value
The value of the point.
Base class that represents the domain of a function.
virtual size_t size() const =0
Return the number of points in the domain.
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 zeroCalculated()
Set all calculated values to zero.
FunctionValues & operator*=(const FunctionValues &values)
Multiply by other calculated values.
double * getPointerToCalculated(size_t i)
Get a pointer to calculated data at index i.
double getFitWeight(size_t i) const
Get a fitting weight.
void setFitWeight(size_t i, double value)
Set a fitting weight.
double getFitData(size_t i) const
Get a fitting data value.
std::vector< double > m_weights
buffer for fitting weights (reciprocal errors)
size_t size() const
Return the number of values.
void expand(size_t n)
Expand values to a new size, preserve stored values.
std::vector< double > m_data
buffer for fit data
FunctionValues(size_t n=0)
Constructor.
void copyTo(double *to) const
Copy calculated values to a buffer.
void setFitData(size_t i, double value)
Set a fitting data value.
void setCalculated(double value)
set all calculated values to same number
void add(double *to) const
Add calculated values to values in a buffer and save result to the buffer.
void setFitWeights(const std::vector< double > &values)
Set all fitting weights.
void reset(const FunctionDomain &domain)
Reset the values to match a new domain.
void multiply(double *to) const
Multiply calculated values by values in a buffer and save result to the buffer.
FunctionValues & operator+=(const FunctionValues &values)
Add other calculated values.
void setFitDataFromCalculated(const FunctionValues &values)
Set all calculated values by copying them from another FunctionValues instance.