Mantid
|
Classes | |
struct | AddVariance |
Functor to deal with the increase in the error when adding (or subtracting) a number of counts. More... | |
struct | DividesNonNull |
Divide functor with result reset to 0 if the denominator is null. More... | |
struct | Log |
Log functor. More... | |
struct | LogNoThrow |
struct | SimpleAverage |
A binary functor to compute the simple average of 2 numbers. More... | |
struct | Squares |
Square functor. More... | |
struct | SumGaussError |
Functor used for computing the sum of the square values of a vector, using the accumulate algorithm. More... | |
struct | SumSquares |
Functor to accumulate a sum of squares. More... | |
struct | TimesSquares |
Functor giving the product of the squares of the arguments. More... | |
Functions | |
void MANTID_KERNEL_DLL | convertToBinBoundary (const std::vector< double > &bin_centers, std::vector< double > &bin_edges) |
Convert an array of bin centers to bin boundary values. More... | |
void MANTID_KERNEL_DLL | convertToBinCentre (const std::vector< double > &bin_edges, std::vector< double > &bin_centres) |
Convert an array of bin boundaries to bin center values. More... | |
int MANTID_KERNEL_DLL | createAxisFromRebinParams (const std::vector< double > ¶ms, std::vector< double > &xnew, const bool resize_xnew, const bool full_bins_only, const double xMinHint, const double xMaxHint, const bool useReverseLogarithmic, const double power) |
Creates a new output X array given a 'standard' set of rebinning parameters. More... | |
template<typename T > | |
std::vector< T > | flattenVector (const std::vector< std::vector< T > > &v) |
A convenience function to "flatten" the given vector of vectors into a single vector. More... | |
MANTID_KERNEL_DLL int | getBinIndex (const std::vector< double > &bins, const double value) |
Return the index into a vector of bin boundaries for a particular X value. More... | |
size_t MANTID_KERNEL_DLL | indexOfValueFromCenters (const std::vector< double > &bin_centers, const double value) |
Gets the bin of a value from a vector of bin centers and throws exception if out of range. More... | |
int MANTID_KERNEL_DLL | indexOfValueFromCentersNoThrow (const std::vector< double > &bin_centers, const double value) |
Gets the bin of a value from a vector of bin centers and returns -1 if out of range. More... | |
size_t MANTID_KERNEL_DLL | indexOfValueFromEdges (const std::vector< double > &bin_edges, const double value) |
Gets the bin of a value from a vector of bin edges. More... | |
bool MANTID_KERNEL_DLL | isConstantValue (const std::vector< double > &arra) |
Assess if all the values in the vector are equal or if there are some different values. More... | |
template<typename T > | |
T | lengthVector (const std::vector< T > &x) |
Return the length of the vector (in the physical sense), the sqrt of the sum of the squares of the components. More... | |
template<typename T > | |
std::vector< T > | normalizeVector (const std::vector< T > &x) |
Normalize a vector of any size to unity, using the sum of the squares of the components. More... | |
void MANTID_KERNEL_DLL | rebin (const std::vector< double > &xold, const std::vector< double > &yold, const std::vector< double > &eold, const std::vector< double > &xnew, std::vector< double > &ynew, std::vector< double > &enew, bool distribution, bool addition) |
Rebins data according to a new output X array. More... | |
void MANTID_KERNEL_DLL | rebinHistogram (const std::vector< double > &xold, const std::vector< double > &yold, const std::vector< double > &eold, const std::vector< double > &xnew, std::vector< double > &ynew, std::vector< double > &enew, bool addition) |
Rebins histogram data according to a new output X array. More... | |
template<typename T > | |
T | scalar_prod (const std::vector< T > &v1, const std::vector< T > &v2) |
template<typename T , typename U > | |
double | scalar_prod (const std::vector< T > &v1, const std::vector< U > &v2) |
MANTID_KERNEL_DLL void | smoothInRange (const std::vector< double > &input, std::vector< double > &output, const double avrgInterval, std::vector< double > const *const binBndrs, size_t startIndex, size_t endIndex, std::vector< double > *const outBins) |
Basic running average of input vector within specified range, considering variable bin-boundaries if such boundaries are provided. More... | |
template<typename NumT > | |
MANTID_KERNEL_DLL std::vector< NumT > | splitStringIntoVector (std::string listString) |
Take a string of comma or space-separated values, and splits it into a vector of doubles. More... | |
template<typename NumT > | |
std::vector< NumT > | splitStringIntoVector (std::string listString) |
Take a string of comma or space-separated values, and splits it into a vector of doubles. More... | |
template DLLExport std::vector< double > | splitStringIntoVector< double > (std::string listString) |
template DLLExport std::vector< float > | splitStringIntoVector< float > (std::string listString) |
template DLLExport std::vector< int32_t > | splitStringIntoVector< int32_t > (std::string listString) |
Declare all version of this. More... | |
template DLLExport std::vector< int64_t > | splitStringIntoVector< int64_t > (std::string listString) |
template DLLExport std::vector< size_t > | splitStringIntoVector< size_t > (std::string listString) |
template DLLExport std::vector< std::string > | splitStringIntoVector< std::string > (std::string listString) |
void Mantid::Kernel::VectorHelper::convertToBinBoundary | ( | const std::vector< double > & | bin_centers, |
std::vector< double > & | bin_edges | ||
) |
Convert an array of bin centers to bin boundary values.
Convert the given set of bin centers into bin boundary values.
NOTE: the first and last bin boundaries are calculated so that the first and last bin centers are in the center of the first and last bins, respectively. For a particular set of bin centers, this may not be correct, but it is the best that can be done, lacking any other information. For an empty input vector, an empty output is returned. For an input vector of size 1, i.e., a single bin, there is no information about a proper bin size, so it is set to 1.0.
bin_centers | :: A vector of values specifying bin centers. |
bin_edges | :: An output vector of values specifying bin boundaries |
Definition at line 404 of file VectorHelper.cpp.
References n.
Referenced by Mantid::API::NumericAxis::createBinBoundaries(), Mantid::DataObjects::Workspace2D::generateHistogram(), Mantid::DataHandling::LoadILLSANS::getVariableTimeBinning(), Mantid::Algorithms::DiscusMultipleScatteringCorrection::integrateQSQ(), and Mantid::Algorithms::DiscusMultipleScatteringCorrection::sampleQWUniform().
void Mantid::Kernel::VectorHelper::convertToBinCentre | ( | const std::vector< double > & | bin_edges, |
std::vector< double > & | bin_centres | ||
) |
Convert an array of bin boundaries to bin center values.
Convert the given set of bin boundaries into bin centre values.
bin_edges | :: A vector of values specifying bin boundaries |
bin_centres | :: An output vector of bin centre values. |
Definition at line 372 of file VectorHelper.cpp.
Referenced by Mantid::DataHandling::LoadRKH::binCenter(), Mantid::Algorithms::DiscusMultipleScatteringCorrection::convertWsBothAxesToPoints(), and Mantid::Algorithms::InterpolatingRebin::cubicInterpolation().
int DLLExport Mantid::Kernel::VectorHelper::createAxisFromRebinParams | ( | const std::vector< double > & | params, |
std::vector< double > & | xnew, | ||
const bool | resize_xnew, | ||
const bool | full_bins_only, | ||
const double | xMinHint, | ||
const double | xMaxHint, | ||
const bool | useReverseLogarithmic, | ||
const double | power | ||
) |
Creates a new output X array given a 'standard' set of rebinning parameters.
[in] | params | Rebin parameters input [x_1, delta_1,x_2, ... ,x_n-1,delta_n-1,x_n] |
[out] | xnew | The newly created axis resulting from the input params |
[in] | resize_xnew | If false then the xnew vector is NOT resized. Useful if the number of bins needs determining. (Default=True) |
[in] | full_bins_only | If true, bins of the size less than the current step are not included. (Default=True) |
[in] | xMinHint | x_1 if params contains only delta_1. |
[in] | xMaxHint | x_2 if params contains only delta_1. |
[in] | useReverseLogarithmic | wheter or not to use reverse logarithmic for bins |
[in] | power | the power in case of inverse power sum. Must be between 0 and 1 or is ignored. |
Definition at line 34 of file VectorHelper.cpp.
Referenced by Mantid::Algorithms::Q1DWeighted::bootstrap(), Mantid::Algorithms::MergeRuns::checkRebinning(), Mantid::DataHandling::CreateSimulationWorkspace::createBinBoundaries(), Mantid::Algorithms::SumEventsByLogValue::createBinnedOutput(), Mantid::Algorithms::Bin2DPowderDiffraction::createOutputWorkspace(), Mantid::Algorithms::Rebin2D::createOutputWorkspace(), WorkspaceCreationHelper::createRebinnedOutputWorkspace(), Mantid::Algorithms::ResampleX::determineBinning(), Mantid::Algorithms::InterpolatingRebin::exec(), Mantid::Algorithms::Rebin::exec(), Mantid::Algorithms::RebinByTimeBase::exec(), Mantid::DataObjects::ReflectometryTransform::executeNormPoly(), Mantid::Algorithms::SofQW::setUpOutputWorkspace(), and Mantid::Algorithms::Q1D2::setUpOutputWorkspace().
std::vector< T > Mantid::Kernel::VectorHelper::flattenVector | ( | const std::vector< std::vector< T > > & | v | ) |
A convenience function to "flatten" the given vector of vectors into a single vector.
For example:
((1), (2, 3), (4), (5, 6)) becomes (1, 2, 3, 4, 5, 6)
v | :: the vector of vectors to be flattened. |
Definition at line 69 of file VectorHelper.h.
Referenced by Mantid::MDAlgorithms::LoadDNSSCD::exec(), Mantid::MDAlgorithms::MergeMDFiles::exec(), MantidQt::API::FindFilesWorker::getFilesFromAlgorithm(), and Mantid::API::MultipleFileProperty::setValueAsMultipleFiles().
int Mantid::Kernel::VectorHelper::getBinIndex | ( | const std::vector< double > & | bins, |
const double | value | ||
) |
Return the index into a vector of bin boundaries for a particular X value.
The index returned is the one for the left edge of the bin. If beyond the range of the vector, it will return either 0 or bins.size()-2.
bins | A reference to the set of bin boundaries to search. It is assumed that they are monotonically increasing values and this is NOT checked |
value | The value whose boundaries should be found |
Definition at line 583 of file VectorHelper.cpp.
References value.
Referenced by Mantid::Algorithms::SumEventsByLogValue::createBinnedOutput(), Mantid::Algorithms::StripVanadiumPeaks::exec(), Mantid::Crystal::PeakIntegration::exec(), Mantid::API::Run::histogramBinBoundaries(), Mantid::Crystal::CentroidPeaks::integrate(), and Mantid::Algorithms::GetAllEi::peakGuess().
size_t Mantid::Kernel::VectorHelper::indexOfValueFromCenters | ( | const std::vector< double > & | bin_centers, |
const double | value | ||
) |
Gets the bin of a value from a vector of bin centers and throws exception if out of range.
Finds the bin index of a value from the vector of bin centers without converting the whole array to bin edges.
Assumes the vector is already sorted ascending.
bin_centers | : vector of bin centers |
value | : input value |
std::out_of_range | : if vector is empty or value is out of it's range (in bin edge representation) |
Definition at line 442 of file VectorHelper.cpp.
References index, indexOfValueFromCentersNoThrow(), and value.
Referenced by Mantid::API::MatrixWorkspace::getSignalAtCoord(), Mantid::API::NumericAxis::indexOfValue(), Mantid::API::TextAxis::indexOfValue(), and Mantid::Algorithms::SumOverlappingTubes::performBinning().
int Mantid::Kernel::VectorHelper::indexOfValueFromCentersNoThrow | ( | const std::vector< double > & | bin_centers, |
const double | value | ||
) |
Gets the bin of a value from a vector of bin centers and returns -1 if out of range.
Definition at line 450 of file VectorHelper.cpp.
Referenced by indexOfValueFromCenters(), Mantid::Algorithms::DiscusMultipleScatteringCorrection::Interpolate2D(), and Mantid::Algorithms::DiscusMultipleScatteringCorrection::sampleQWUniform().
size_t Mantid::Kernel::VectorHelper::indexOfValueFromEdges | ( | const std::vector< double > & | bin_edges, |
const double | value | ||
) |
Gets the bin of a value from a vector of bin edges.
Finds the bin index of a value from the vector of bin edges.
Assumes the vector is already sorted ascending.
bin_edges | : vector of bin centers |
value | : input value |
std::out_of_range | : if vector is empty, contains one element, or value is out of it's range |
Definition at line 490 of file VectorHelper.cpp.
References value.
Referenced by Mantid::Algorithms::Q1DWeighted::calculate(), Mantid::API::MatrixWorkspace::getSignalAtCoord(), Mantid::API::BinEdgeAxis::indexOfValue(), and Mantid::API::SpectraAxis::indexOfValue().
bool Mantid::Kernel::VectorHelper::isConstantValue | ( | const std::vector< double > & | arra | ) |
Assess if all the values in the vector are equal or if there are some different values.
[in] | arra | the vector to examine |
Definition at line 518 of file VectorHelper.cpp.
Referenced by Mantid::Algorithms::InterpolatingRebin::cubicInterpolation().
T Mantid::Kernel::VectorHelper::lengthVector | ( | const std::vector< T > & | x | ) |
Return the length of the vector (in the physical sense), the sqrt of the sum of the squares of the components.
x | :: input vector, x should be float or double. |
Definition at line 97 of file VectorHelper.h.
References Mantid::Geometry::x.
Referenced by normalizeVector().
std::vector< T > Mantid::Kernel::VectorHelper::normalizeVector | ( | const std::vector< T > & | x | ) |
Normalize a vector of any size to unity, using the sum of the squares of the components.
x | :: input vector, x should be float or double. Length 1+ |
Definition at line 136 of file VectorHelper.h.
References lengthVector(), and Mantid::Geometry::x.
void Mantid::Kernel::VectorHelper::rebin | ( | const std::vector< double > & | xold, |
const std::vector< double > & | yold, | ||
const std::vector< double > & | eold, | ||
const std::vector< double > & | xnew, | ||
std::vector< double > & | ynew, | ||
std::vector< double > & | enew, | ||
bool | distribution, | ||
bool | addition | ||
) |
Rebins data according to a new output X array.
[in] | xold | Old X array of data. |
[in] | yold | Old Y array of data. Must be 1 element shorter than xold. |
[in] | eold | Old error array of data. Must be same length as yold. |
[in] | xnew | X array of data to rebin to. |
[out] | ynew | Rebinned data. Must be 1 element shorter than xnew. |
[out] | enew | Rebinned errors. Must be same length as ynew. |
[in] | distribution | Flag defining if distribution data (true) or not (false). |
[in] | addition | If true, rebinned values are added to the existing ynew/enew vectors. NOTE THAT, IN THIS CASE THE RESULTING enew WILL BE THE SQUARED ERRORS AND THE ynew WILL NOT HAVE THE BIN WIDTH DIVISION PUT IN! |
runtime_error | Thrown if algorithm cannot execute. |
invalid_argument | Thrown if input to function is incorrect. |
Definition at line 163 of file VectorHelper.cpp.
References Mantid::Kernel::delta.
Referenced by Mantid::Algorithms::ApplyFloodWorkspace::exec(), Mantid::Algorithms::CrossCorrelate::exec(), Mantid::Algorithms::DiffractionFocussing2::exec(), Mantid::Algorithms::ResampleX::exec(), Mantid::DataObjects::Workspace2D::generateHistogram(), Mantid::Algorithms::VesuvioL1ThetaResolution::processDistribution(), and Mantid::Algorithms::MergeRuns::rebinInput().
void Mantid::Kernel::VectorHelper::rebinHistogram | ( | const std::vector< double > & | xold, |
const std::vector< double > & | yold, | ||
const std::vector< double > & | eold, | ||
const std::vector< double > & | xnew, | ||
std::vector< double > & | ynew, | ||
std::vector< double > & | enew, | ||
bool | addition | ||
) |
Rebins histogram data according to a new output X array.
Should be faster than previous one.
[in] | xold | Old X array of data. |
[in] | yold | Old Y array of data. Must be 1 element shorter than xold. |
[in] | eold | Old error array of data. Must be same length as yold. |
[in] | xnew | X array of data to rebin to. |
[out] | ynew | Rebinned data. Must be 1 element shorter than xnew. |
[out] | enew | Rebinned errors. Must be same length as ynew. |
[in] | addition | If true, rebinned values are added to the existing ynew/enew vectors. NOTE THAT, IN THIS CASE THE RESULTING enew WILL BE THE SQUARED ERRORS! |
runtime_error | Thrown if vector sizes are inconsistent |
Definition at line 280 of file VectorHelper.cpp.
Referenced by Mantid::Algorithms::DiffractionFocussing2::exec(), and Mantid::Algorithms::NormaliseToMonitor::normaliseBinByBin().
T Mantid::Kernel::VectorHelper::scalar_prod | ( | const std::vector< T > & | v1, |
const std::vector< T > & | v2 | ||
) |
Definition at line 106 of file VectorHelper.h.
double Mantid::Kernel::VectorHelper::scalar_prod | ( | const std::vector< T > & | v1, |
const std::vector< U > & | v2 | ||
) |
Definition at line 118 of file VectorHelper.h.
void Mantid::Kernel::VectorHelper::smoothInRange | ( | const std::vector< double > & | input, |
std::vector< double > & | output, | ||
const double | avrgInterval, | ||
std::vector< double > const *const | binBndrs, | ||
size_t | startIndex, | ||
size_t | endIndex, | ||
std::vector< double > *const | outBins | ||
) |
Basic running average of input vector within specified range, considering variable bin-boundaries if such boundaries are provided.
The algorithm performs trapezium integration, so some peak shift related to the first derivative of the integrated function can be observed.
input,: | input vector to smooth |
output,: | resulting vector (can not coincide with input) |
avrgInterval,: | the interval to average function in. the function is averaged within +-0.5*avrgInterval |
binBndrs | :: pointer to the vector, containing bin boundaries. If provided, its length has to be input.size()+1, if not, equal size bins of size 1 are assumed, so avrgInterval becomes the number of points to average over. Bin boundaries array have to increase and can not contain equal boundaries. |
startIndex,: | if provided, its start index to run averaging from. if not, averaging starts from the index 0 |
endIndex | :: final index to run average to, if provided. If not, or higher then number of elements in input array, averaging is performed to the end point of the input array |
outBins | :: if present, pointer to a vector to return bin boundaries for output array. |
Definition at line 716 of file VectorHelper.cpp.
Referenced by Mantid::Algorithms::GetAllEi::peakGuess().
MANTID_KERNEL_DLL std::vector< NumT > Mantid::Kernel::VectorHelper::splitStringIntoVector | ( | std::string | listString | ) |
Take a string of comma or space-separated values, and splits it into a vector of doubles.
listString | :: a string like "0.0 1.2" or "2.4, 5.67, 88" |
an | error if there was a string that could not convert to a double. |
Definition at line 554 of file VectorHelper.cpp.
References splitStringIntoVector().
Referenced by splitStringIntoVector().
std::vector< NumT > Mantid::Kernel::VectorHelper::splitStringIntoVector | ( | std::string | listString | ) |
Take a string of comma or space-separated values, and splits it into a vector of doubles.
listString | :: a string like "0.0 1.2" or "2.4, 5.67, 88" |
an | error if there was a string that could not convert to a double. |
Definition at line 554 of file VectorHelper.cpp.
References splitStringIntoVector().
Referenced by splitStringIntoVector().
template DLLExport std::vector< double > Mantid::Kernel::VectorHelper::splitStringIntoVector< double > | ( | std::string | listString | ) |
template DLLExport std::vector< float > Mantid::Kernel::VectorHelper::splitStringIntoVector< float > | ( | std::string | listString | ) |
template DLLExport std::vector< int32_t > Mantid::Kernel::VectorHelper::splitStringIntoVector< int32_t > | ( | std::string | listString | ) |
Declare all version of this.
template DLLExport std::vector< int64_t > Mantid::Kernel::VectorHelper::splitStringIntoVector< int64_t > | ( | std::string | listString | ) |
template DLLExport std::vector< size_t > Mantid::Kernel::VectorHelper::splitStringIntoVector< size_t > | ( | std::string | listString | ) |
template DLLExport std::vector< std::string > Mantid::Kernel::VectorHelper::splitStringIntoVector< std::string > | ( | std::string | listString | ) |
Referenced by Mantid::DataHandling::SaveAscii2::stringListToVector().