Mantid
|
Utils: General-purpose utility functions that do not belong anywhere else. More...
Namespaces | |
namespace | NestedForLoop |
Functions | |
std::vector< size_t > | getIndicesFromLinearIndex (const size_t linear_index, const std::vector< size_t > &num_bins) |
Convert an linear index in nDim workspace into vector of loop indexes of nDim depth loop. More... | |
void | getIndicesFromLinearIndex (const size_t linear_index, size_t const *const numBins, const size_t numDims, size_t *const out_indices) |
Convert an linear index in nDim workspace into vector of loop indexes of nDim depth loop Unsafe (pointers) version, used by safe vectors version. More... | |
bool | isNeighbourOfSubject (const size_t ndims, const size_t neighbour_linear_index, const size_t *subject_indices, const size_t *num_bins, const size_t *index_max, const std::vector< int > &widths) |
Determine, using an any-vertex touching type approach, whether the neighbour linear index corresponds to a true neighbour of the subject, which is already decomposed into it's constituent dimension indices. More... | |
long | round (double x) |
Custom rounding method for a double->long because none is portable in C++ (!) More... | |
double | rounddbl (double r) |
Custom rounding method for a double->double because none is portable in C++ (!) More... | |
double | roundToDP (double r, int d) |
Custom rounding method for a double->double because none is portable in C++ (!) More... | |
double | roundToSF (double r, int f) |
Custom rounding method for a double->double because none is portable in C++ (!) More... | |
Utils: General-purpose utility functions that do not belong anywhere else.
NOTE! There are other places to put specific functions:
VectorHelper.h Strings.h Statistics.h Memory.h
|
inline |
Convert an linear index in nDim workspace into vector of loop indexes of nDim depth loop.
linear_index | :: linear index into the nested for loop. |
num_bins | :: a vector of [numDims] size, where numDims is the loop depth and each element equal to number of bins in the correspondent dimension |
Definition at line 255 of file Utils.h.
References getIndicesFromLinearIndex().
|
inline |
Convert an linear index in nDim workspace into vector of loop indexes of nDim depth loop Unsafe (pointers) version, used by safe vectors version.
linear_index | :: linear index into the nested for loop. | |
numBins | :: an array[numDims], with number of bins in each dimension | |
numDims | :: how many levels of nesting do the for loops have and the size of the numBins array above | |
[out] | out_indices | :: an array, sized numDims, which will be filled with the index for each dimension, given the linear index |
Definition at line 228 of file Utils.h.
References Mantid::Geometry::d.
Referenced by Mantid::DataObjects::FakeMD::addFakeRegularData(), and getIndicesFromLinearIndex().
|
inline |
Determine, using an any-vertex touching type approach, whether the neighbour linear index corresponds to a true neighbour of the subject, which is already decomposed into it's constituent dimension indices.
subject is already expressed in it's constituent indices for speed.
The approach used here is to determine if a dimension index differ by any more than 1 in any dimension. If it does, then the neighbour does not represent a valid neighbour of the subject.
ndims | |
neighbour_linear_index | |
subject_indices | |
num_bins | |
index_max | |
widths | : width in pixels per dimension |
Definition at line 283 of file Utils.h.
Referenced by Mantid::DataObjects::MDHistoWorkspaceIterator::findNeighbourIndexesByWidth(), Mantid::DataObjects::MDHistoWorkspaceIterator::findNeighbourIndexesByWidth1D(), and Mantid::DataObjects::MDHistoWorkspaceIterator::findNeighbourIndexesFaceTouching().
|
inline |
Custom rounding method for a double->long because none is portable in C++ (!)
x | :: floating point value to round |
Definition at line 37 of file Utils.h.
References Mantid::Geometry::x.
Referenced by Mantid::Crystal::SaveHKL::exec(), Mantid::Crystal::SaveIsawPeaks::exec(), Mantid::Crystal::SaveLauenorm::exec(), Mantid::MDAlgorithms::IntegratePeaksMD::integrate(), and Mantid::MDAlgorithms::IntegratePeaksMD2::integrate().
|
inline |
Custom rounding method for a double->double because none is portable in C++ (!)
r | :: floating point value to round |
Definition at line 46 of file Utils.h.
Referenced by roundToDP(), and roundToSF().
|
inline |
Custom rounding method for a double->double because none is portable in C++ (!)
r | :: floating point value to round |
d | :: number of digits after decimal point to preserve |
Definition at line 69 of file Utils.h.
References Mantid::Geometry::d, Mantid::Geometry::m, and rounddbl().
|
inline |
Custom rounding method for a double->double because none is portable in C++ (!)
r | :: floating point value to round |
f | :: number of significant figures to preserve |
Definition at line 56 of file Utils.h.
References fabs, and rounddbl().