Mantid
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Mantid::API::FunctionValues Class Reference

A class to store values calculated by a function. More...

#include <FunctionValues.h>

Public Member Functions

void addToCalculated (size_t i, double value)
 Add a number to a calculated value. More...
 
void addToCalculated (size_t start, const FunctionValues &values)
 Add other calculated values with offset. More...
 
void expand (size_t n)
 Expand values to a new size, preserve stored values. More...
 
 FunctionValues (const FunctionDomain &domain)
 Constructor. More...
 
 FunctionValues (size_t n=0)
 Constructor. More...
 
double getCalculated (size_t i) const
 Get i-th calculated value. More...
 
double getFitData (size_t i) const
 Get a fitting data value. More...
 
double getFitWeight (size_t i) const
 Get a fitting weight. More...
 
double * getPointerToCalculated (size_t i)
 Get a pointer to calculated data at index i. More...
 
FunctionValuesoperator*= (const FunctionValues &values)
 Multiply by other calculated values. More...
 
FunctionValuesoperator+= (const FunctionValues &values)
 Add other calculated values. More...
 
double operator[] (size_t i) const
 Get i-th calculated value. More...
 
void reset (const FunctionDomain &domain)
 Reset the values to match a new domain. More...
 
void setCalculated (double value)
 set all calculated values to same number More...
 
void setCalculated (size_t i, double value)
 Store i-th calculated value. More...
 
void setFitData (const std::vector< double > &values)
 Set all fitting data values. More...
 
void setFitData (size_t i, double value)
 Set a fitting data value. More...
 
void setFitDataFromCalculated (const FunctionValues &values)
 Set all calculated values by copying them from another FunctionValues instance. More...
 
void setFitWeight (size_t i, double value)
 Set a fitting weight. More...
 
void setFitWeights (const double &value)
 Set all fitting weights to a number. More...
 
void setFitWeights (const std::vector< double > &values)
 Set all fitting weights. More...
 
size_t size () const
 Return the number of values. More...
 
std::vector< double > toVector () const
 Return the calculated values as a vector. More...
 
void zeroCalculated ()
 Set all calculated values to zero. More...
 

Protected Member Functions

void add (double *to) const
 Add calculated values to values in a buffer and save result to the buffer. More...
 
void copyTo (double *to) const
 Copy calculated values to a buffer. More...
 
void multiply (double *to) const
 Multiply calculated values by values in a buffer and save result to the buffer. More...
 

Protected Attributes

std::vector< double > m_calculated
 buffer for calculated values More...
 
std::vector< double > m_data
 buffer for fit data More...
 
std::vector< double > m_weights
 buffer for fitting weights (reciprocal errors) More...
 

Detailed Description

A class to store values calculated by a function.

It also can contain data a function can fit to.

Author
Roman Tolchenov, Tessella plc
Date
15/11/2011

Definition at line 25 of file FunctionValues.h.

Constructor & Destructor Documentation

◆ FunctionValues() [1/2]

Mantid::API::FunctionValues::FunctionValues ( size_t  n = 0)
explicit

Constructor.

Parameters
n:: A number of values to store.

Definition at line 18 of file FunctionValues.cpp.

References m_calculated, and n.

◆ FunctionValues() [2/2]

Mantid::API::FunctionValues::FunctionValues ( const FunctionDomain domain)
explicit

Constructor.

Constructs a set of output values based on the given domain.

Parameters
domain:: A reference to the domain over which the function is calculated

Definition at line 29 of file FunctionValues.cpp.

References reset().

Member Function Documentation

◆ add()

void Mantid::API::FunctionValues::add ( double *  to) const
protected

Add calculated values to values in a buffer and save result to the buffer.

Parameters
to:: Pointer to the buffer, it must be large enough

Definition at line 84 of file FunctionValues.cpp.

References m_calculated.

Referenced by addToCalculated(), and operator+=().

◆ addToCalculated() [1/2]

void Mantid::API::FunctionValues::addToCalculated ( size_t  i,
double  value 
)
inline

Add a number to a calculated value.

Parameters
i:: An index of a value 0 <= i < size() to update.
value:: A value to add

Definition at line 58 of file FunctionValues.h.

References value.

Referenced by Mantid::CurveFitting::Functions::PawleyFunction::function(), and Mantid::API::MultiDomainFunction::function().

◆ addToCalculated() [2/2]

void Mantid::API::FunctionValues::addToCalculated ( size_t  start,
const FunctionValues values 
)

Add other calculated values with offset.

Add other calculated values to these values starting from some index.

Parameters
start:: A starting index for addition
values:: An instance of FunctionValues to be added to this. The size mustn't exceed the number of values in this from start to the end.
Returns
A reference to this values.

Definition at line 132 of file FunctionValues.cpp.

References add(), getPointerToCalculated(), and size().

◆ copyTo()

void Mantid::API::FunctionValues::copyTo ( double *  to) const
protected

Copy calculated values to a buffer.

Parameters
to:: Pointer to the buffer

Definition at line 79 of file FunctionValues.cpp.

References m_calculated.

◆ expand()

void Mantid::API::FunctionValues::expand ( size_t  n)

Expand values to a new size, preserve stored values.

Expand to a new size.

Preserve old values. Do not contract.

Parameters
n:: A new size, must be greater than the current size.

Definition at line 43 of file FunctionValues.cpp.

References m_calculated, m_data, m_weights, n, and size().

Referenced by Mantid::CurveFitting::Functions::CrystalFieldFunction::calcExcitations(), Mantid::CurveFitting::Functions::CrystalFieldMultiSpectrum::calcExcitations(), and Mantid::CurveFitting::Functions::CrystalFieldPeaks::functionGeneral().

◆ getCalculated()

double Mantid::API::FunctionValues::getCalculated ( size_t  i) const
inline

◆ getFitData()

double Mantid::API::FunctionValues::getFitData ( size_t  i) const

◆ getFitWeight()

double Mantid::API::FunctionValues::getFitWeight ( size_t  i) const

Get a fitting weight.

Parameters
i:: A value index.

Definition at line 208 of file FunctionValues.cpp.

References m_calculated, and m_weights.

Referenced by Mantid::CurveFitting::Algorithms::CalculateChiSquared::calcChiSquared().

◆ getPointerToCalculated()

double * Mantid::API::FunctionValues::getPointerToCalculated ( size_t  i)

◆ multiply()

void Mantid::API::FunctionValues::multiply ( double *  to) const
protected

Multiply calculated values by values in a buffer and save result to the buffer.

Parameters
to:: Pointer to the buffer, it must be large enough

Definition at line 92 of file FunctionValues.cpp.

References m_calculated.

Referenced by operator*=().

◆ operator*=()

FunctionValues & Mantid::API::FunctionValues::operator*= ( const FunctionValues values)

Multiply by other calculated values.

Parameters
values:: An instance of FunctionValues to multiply to this. Must have the same size to this.
Returns
A reference to this values.

Definition at line 116 of file FunctionValues.cpp.

References getPointerToCalculated(), multiply(), and size().

◆ operator+=()

FunctionValues & Mantid::API::FunctionValues::operator+= ( const FunctionValues values)

Add other calculated values.

Add other calculated values to this.

Parameters
values:: An instance of FunctionValues to be added to this. Must have the same size to this.
Returns
A reference to this values.

Definition at line 102 of file FunctionValues.cpp.

References add(), getPointerToCalculated(), and size().

◆ operator[]()

double Mantid::API::FunctionValues::operator[] ( size_t  i) const
inline

Get i-th calculated value.

Parameters
i:: An index of a value 0 <= i < size()

Definition at line 54 of file FunctionValues.h.

◆ reset()

void Mantid::API::FunctionValues::reset ( const FunctionDomain domain)

Reset the values to match a new domain.

Definition at line 32 of file FunctionValues.cpp.

References m_calculated, and Mantid::API::FunctionDomain::size().

Referenced by Mantid::CurveFitting::Functions::PawleyFunction::calculateFunctionValues(), and FunctionValues().

◆ setCalculated() [1/2]

void Mantid::API::FunctionValues::setCalculated ( double  value)

◆ setCalculated() [2/2]

void Mantid::API::FunctionValues::setCalculated ( size_t  i,
double  value 
)
inline

Store i-th calculated value.

Parameters
i:: Index of the stored value 0 <= i < size()
value:: A value to store.

Definition at line 48 of file FunctionValues.h.

References value.

◆ setFitData() [1/2]

void Mantid::API::FunctionValues::setFitData ( const std::vector< double > &  values)

Set all fitting data values.

Parameters
values:: A vector of values for fitting. Must have the same size as this.

Definition at line 156 of file FunctionValues.cpp.

References m_data.

◆ setFitData() [2/2]

void Mantid::API::FunctionValues::setFitData ( size_t  i,
double  value 
)

Set a fitting data value.

Parameters
i:: A value index
value:: A new value to set.

Definition at line 144 of file FunctionValues.cpp.

References m_calculated, m_data, and value.

◆ setFitDataFromCalculated()

void Mantid::API::FunctionValues::setFitDataFromCalculated ( const FunctionValues values)

Set all calculated values by copying them from another FunctionValues instance.

Set fitting data copied from other FunctionValues' calculated values.

Parameters
values:: An instance of FunctionValues to copy the data from.

Definition at line 219 of file FunctionValues.cpp.

References m_calculated, and m_data.

◆ setFitWeight()

void Mantid::API::FunctionValues::setFitWeight ( size_t  i,
double  value 
)

Set a fitting weight.

Parameters
i:: A value index
value:: A new value for the weight.

Definition at line 179 of file FunctionValues.cpp.

References m_calculated, m_weights, and value.

◆ setFitWeights() [1/2]

void Mantid::API::FunctionValues::setFitWeights ( const double &  value)

Set all fitting weights to a number.

Set all weights to the same value.

Parameters
value:: The value to set.

Definition at line 202 of file FunctionValues.cpp.

References m_calculated, m_weights, and value.

◆ setFitWeights() [2/2]

void Mantid::API::FunctionValues::setFitWeights ( const std::vector< double > &  values)

Set all fitting weights.

Parameters
values:: A vector of fitting weights. Must have the same size as this.

Definition at line 191 of file FunctionValues.cpp.

References m_weights.

◆ size()

size_t Mantid::API::FunctionValues::size ( ) const
inline

◆ toVector()

std::vector< double > Mantid::API::FunctionValues::toVector ( ) const
inline

◆ zeroCalculated()

void Mantid::API::FunctionValues::zeroCalculated ( )

Member Data Documentation

◆ m_calculated

std::vector<double> Mantid::API::FunctionValues::m_calculated
protected

◆ m_data

std::vector<double> Mantid::API::FunctionValues::m_data
protected

buffer for fit data

Definition at line 102 of file FunctionValues.h.

Referenced by expand(), getFitData(), setFitData(), and setFitDataFromCalculated().

◆ m_weights

std::vector<double> Mantid::API::FunctionValues::m_weights
protected

buffer for fitting weights (reciprocal errors)

Definition at line 104 of file FunctionValues.h.

Referenced by expand(), getFitWeight(), setFitWeight(), and setFitWeights().


The documentation for this class was generated from the following files: