Workspace 6.21.5
Functions
CSIRO::DataAnalysis::ArrayNdUtil Namespace Reference

Functions

template<class T , class UnaryFunction >
bool map (const ArrayNd &array, const NamedDimensionRangeList &arrayRange, ArrayNd &result, const NamedDimensionRangeList &resultRange, UnaryFunction op)
 
template<class T , class ReduceFunction >
bool reduce (const ArrayNd &source, const NamedDimensionRangeList &reduceRange, ArrayNdData< T > &result, ReduceFunction reduce)
 

Function Documentation

◆ map()

bool map ( const ArrayNd array,
const NamedDimensionRangeList arrayRange,
ArrayNd result,
const NamedDimensionRangeList resultRange,
UnaryFunction  op 
)
inline
Parameters
arrayThe input dataset.
arrayRangeThe range over which we are going to operate.
resultThe array into which we are going to write the results.
resultRangeThe target range in the result dataset.
opThe operation we are going to perform on each value of the input dataset, array.
Template Parameters
TThe datatype that the operation is going to operate on.
UnaryFunctionThe type of the operation functor. It must be able to operate on items of type T, and whatever the internally stored data type is in array.

Transform each of the values in the input dataset, outputting the results to a target dataset.

◆ reduce()

bool reduce ( const ArrayNd source,
const NamedDimensionRangeList reduceRange,
ArrayNdData< T > &  result,
ReduceFunction  reduce 
)
inline
Parameters
sourceThe input dataset. The index of the dimensions in result must match the index of the dimensions in array.
reduceRangeThe range of the input dataset that we are interested in reducing.
resultThe result dataset. The dimensions of this dataset must have the same names as those in range, but it should be missing the dimensions that are being reduced - these will not be required in the output dataset (they are being reduced to a single value).
reduceThe function for reducing the array into the result set.
Template Parameters
TThe datatype that the operation is going to function on (usually double)
ReduceFunctionThe type of functor to use.

This function will iterate over all of the cells in the result set, reducing the corresponding ranges in the input array into it, using the input function. One example of a use for this function is to compress a dimension down to one by averaging all the values.

This function will only reduce those dimensions that are listed in the reduceRange.

Precondition
result has already been resized and given the appropriate output dimensions.