Mantid
|
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... | |
FunctionValues & | operator*= (const FunctionValues &values) |
Multiply by other calculated values. More... | |
FunctionValues & | operator+= (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... | |
A class to store values calculated by a function.
It also can contain data a function can fit to.
Definition at line 25 of file FunctionValues.h.
|
explicit |
Constructor.
n | :: A number of values to store. |
Definition at line 18 of file FunctionValues.cpp.
References m_calculated, and n.
|
explicit |
Constructor.
Constructs a set of output values based on the given domain.
domain | :: A reference to the domain over which the function is calculated |
Definition at line 29 of file FunctionValues.cpp.
References reset().
|
protected |
Add calculated values to values in a buffer and save result to the buffer.
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+=().
|
inline |
Add a number to a calculated value.
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().
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.
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. |
Definition at line 132 of file FunctionValues.cpp.
References add(), getPointerToCalculated(), and size().
|
protected |
Copy calculated values to a buffer.
to | :: Pointer to the buffer |
Definition at line 79 of file FunctionValues.cpp.
References m_calculated.
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.
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().
|
inline |
Get i-th calculated value.
i | :: An index of a value 0 <= i < size() |
Definition at line 51 of file FunctionValues.h.
Referenced by Mantid::CurveFitting::Functions::CrystalFieldUtils::buildSpectrumFunction(), Mantid::CurveFitting::Algorithms::CalculateChiSquared::calcChiSquared(), Mantid::CurveFitting::CostFunctions::CostFuncPoisson::calculateDerivative(), Mantid::Algorithms::FitPeaks::calculateFittedPeaks(), Mantid::CurveFitting::CostFunctions::CostFuncPoisson::calculateHessian(), Mantid::API::IFunction::calNumericalDeriv(), Mantid::MDAlgorithms::FitMD::createEventOutputWorkspace(), Mantid::CurveFitting::Algorithms::ConvolveWorkspaces::exec(), Mantid::Algorithms::PeakParameterHelper::observePeakCenter(), Mantid::Algorithms::PeakParameterHelper::observePeakFwhm(), and Mantid::CurveFitting::Functions::CrystalFieldUtils::updateSpectrumFunction().
double Mantid::API::FunctionValues::getFitData | ( | size_t | i | ) | const |
Get a fitting data value.
i | :: A value index |
Definition at line 167 of file FunctionValues.cpp.
References m_calculated, and m_data.
Referenced by Mantid::CurveFitting::Algorithms::CalculateChiSquared::calcChiSquared(), Mantid::CurveFitting::CostFunctions::CostFuncPoisson::calculateDerivative(), Mantid::CurveFitting::CostFunctions::CostFuncPoisson::calculateHessian(), and Mantid::CurveFitting::ParameterEstimator::extractValues().
double Mantid::API::FunctionValues::getFitWeight | ( | size_t | i | ) | const |
Get a fitting weight.
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().
double * Mantid::API::FunctionValues::getPointerToCalculated | ( | size_t | i | ) |
Get a pointer to calculated data at index i.
i | :: Index. |
Definition at line 65 of file FunctionValues.cpp.
References m_calculated, and size().
Referenced by addToCalculated(), Mantid::CurveFitting::Functions::PawleyFunction::calculateFunctionValues(), Mantid::API::IFunction1D::derivative(), Mantid::MDAlgorithms::EvaluateMDFunction::exec(), Mantid::API::IFunction1D::function(), Mantid::CurveFitting::Functions::Convolution::functionDirectMode(), Mantid::CurveFitting::Functions::Convolution::functionFFTMode(), operator*=(), and operator+=().
|
protected |
Multiply calculated values by values in a buffer and save result to the buffer.
to | :: Pointer to the buffer, it must be large enough |
Definition at line 92 of file FunctionValues.cpp.
References m_calculated.
Referenced by operator*=().
FunctionValues & Mantid::API::FunctionValues::operator*= | ( | const FunctionValues & | values | ) |
Multiply by other calculated values.
values | :: An instance of FunctionValues to multiply to this. Must have the same size to this. |
Definition at line 116 of file FunctionValues.cpp.
References getPointerToCalculated(), multiply(), and size().
FunctionValues & Mantid::API::FunctionValues::operator+= | ( | const FunctionValues & | values | ) |
Add other calculated values.
Add other calculated values to this.
values | :: An instance of FunctionValues to be added to this. Must have the same size to this. |
Definition at line 102 of file FunctionValues.cpp.
References add(), getPointerToCalculated(), and size().
|
inline |
Get i-th calculated value.
i | :: An index of a value 0 <= i < size() |
Definition at line 54 of file FunctionValues.h.
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().
void Mantid::API::FunctionValues::setCalculated | ( | double | value | ) |
set all calculated values to same number
Set all calculated values to same number.
value | :: A new value. |
Definition at line 59 of file FunctionValues.cpp.
References m_calculated, and value.
Referenced by Mantid::CurveFitting::Functions::CrystalFieldFunction::calcExcitations(), Mantid::CurveFitting::Functions::CrystalFieldMultiSpectrum::calcExcitations(), Mantid::API::IFunctionMD::evaluateFunction(), Mantid::CurveFitting::Functions::CrystalFieldPeaks::functionGeneral(), Mantid::CurveFitting::LatticeFunction::functionLattice(), and zeroCalculated().
|
inline |
Store i-th calculated value.
i | :: Index of the stored value 0 <= i < size() |
value | :: A value to store. |
Definition at line 48 of file FunctionValues.h.
References value.
void Mantid::API::FunctionValues::setFitData | ( | const std::vector< double > & | values | ) |
Set all fitting data values.
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.
void Mantid::API::FunctionValues::setFitData | ( | size_t | i, |
double | value | ||
) |
Set a fitting data value.
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.
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.
values | :: An instance of FunctionValues to copy the data from. |
Definition at line 219 of file FunctionValues.cpp.
References m_calculated, and m_data.
void Mantid::API::FunctionValues::setFitWeight | ( | size_t | i, |
double | value | ||
) |
Set a fitting weight.
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.
void Mantid::API::FunctionValues::setFitWeights | ( | const double & | value | ) |
Set all fitting weights to a number.
Set all weights to the same value.
value | :: The value to set. |
Definition at line 202 of file FunctionValues.cpp.
References m_calculated, m_weights, and value.
void Mantid::API::FunctionValues::setFitWeights | ( | const std::vector< double > & | values | ) |
Set all fitting weights.
values | :: A vector of fitting weights. Must have the same size as this. |
Definition at line 191 of file FunctionValues.cpp.
References m_weights.
|
inline |
Return the number of values.
Definition at line 32 of file FunctionValues.h.
Referenced by addToCalculated(), Mantid::CurveFitting::Functions::CrystalFieldFunction::buildMultiSiteSingleSpectrum(), Mantid::CurveFitting::Functions::CrystalFieldFunction::buildSingleSiteSingleSpectrum(), Mantid::CurveFitting::Functions::CrystalFieldSpectrum::buildTargetFunction(), Mantid::CurveFitting::Algorithms::CalculateChiSquared::calcChiSquared(), Mantid::CurveFitting::Algorithms::RefinePowderInstrumentParameters::calculateD2TOFFunction(), Mantid::CurveFitting::Functions::CrystalFieldUtils::calculateNPeaks(), Mantid::API::IFunction::calNumericalDeriv(), Mantid::MDAlgorithms::EvaluateMDFunction::exec(), expand(), Mantid::CurveFitting::Functions::ProcessBackground::filterForBackground(), Mantid::API::IFunctionGeneral::function(), Mantid::API::MultiDomainFunction::function(), Mantid::CurveFitting::Functions::CrystalFieldPeaks::functionGeneral(), Mantid::CurveFitting::LatticeFunction::functionLattice(), Mantid::Algorithms::GeneratePeaks::generatePeaks(), getPointerToCalculated(), Mantid::Algorithms::PeakParameterHelper::observePeakFwhm(), operator*=(), and operator+=().
|
inline |
Return the calculated values as a vector.
Definition at line 86 of file FunctionValues.h.
Referenced by Mantid::CurveFitting::Algorithms::estimateBackgroundCoarse(), Mantid::Algorithms::CreateSampleWorkspace::evalFunction(), Mantid::CurveFitting::Functions::evaluateFunctionOnRange(), Mantid::CurveFitting::Algorithms::LeBailFit::execRefineBackground(), Mantid::CurveFitting::Algorithms::RefinePowderInstrumentParameters3::genOutputWorkspace(), Mantid::MDAlgorithms::IntegratePeaksMD::integrate(), Mantid::MDAlgorithms::IntegratePeaksMD2::integrate(), and Mantid::Algorithms::FitPeak::setupOutput().
void Mantid::API::FunctionValues::zeroCalculated | ( | ) |
Set all calculated values to zero.
Definition at line 73 of file FunctionValues.cpp.
References setCalculated().
Referenced by Mantid::CurveFitting::Functions::Convolution::function(), Mantid::CurveFitting::Functions::PawleyFunction::function(), Mantid::API::CompositeFunction::function(), Mantid::API::MultiDomainFunction::function(), Mantid::CurveFitting::Functions::Convolution::functionDirectMode(), and Mantid::CurveFitting::Functions::Convolution::functionFFTMode().
|
protected |
buffer for calculated values
Definition at line 100 of file FunctionValues.h.
Referenced by add(), copyTo(), expand(), FunctionValues(), getFitData(), getFitWeight(), getPointerToCalculated(), multiply(), reset(), setCalculated(), setFitData(), setFitDataFromCalculated(), setFitWeight(), and setFitWeights().
|
protected |
buffer for fit data
Definition at line 102 of file FunctionValues.h.
Referenced by expand(), getFitData(), setFitData(), and setFitDataFromCalculated().
|
protected |
buffer for fitting weights (reciprocal errors)
Definition at line 104 of file FunctionValues.h.
Referenced by expand(), getFitWeight(), setFitWeight(), and setFitWeights().