Go to the documentation of this file.
10 #ifndef vtk_m_worklet_AverageByKey_h
11 #define vtk_m_worklet_AverageByKey_h
33 template <
typename ValuesVecType,
typename OutType>
37 for (
vtkm::IdComponent index = 1; index < valuesIn.GetNumberOfComponents(); ++index)
39 sum += valuesIn[index];
48 using ComponentType =
typename VTraits::ComponentType;
49 ComponentType divisor =
static_cast<ComponentType
>(valuesIn.GetNumberOfComponents());
50 for (
vtkm::IdComponent cIndex = 0; cIndex < VTraits::GetNumberOfComponents(sum); ++cIndex)
52 VTraits::SetComponent(sum, cIndex, VTraits::GetComponent(sum, cIndex) / divisor);
62 template <
typename InArrayType,
typename OutArrayType>
63 VTKM_CONT static void Run(
const vtkm::worklet::internal::KeysBase& keys,
64 const InArrayType& inValues,
65 const OutArrayType& outAverages)
70 dispatcher.Invoke(keys, inValues, outAverages);
78 template <
typename ValueType,
typename InValuesStorage>
80 const vtkm::worklet::internal::KeysBase& keys,
85 Run(keys, inValues, outAverages);
91 template <
typename ValueType>
110 template <
class KeyType,
114 class ValueInStorage,
115 class ValueOutStorage>
125 outputKeyArray = results.GetFirstArray();
138 #endif //vtk_m_worklet_AverageByKey_h
VTKM_CONT void ArrayCopyDevice(const vtkm::cont::ArrayHandle< InValueType, InStorage > &source, vtkm::cont::ArrayHandle< OutValueType, OutStorage > &destination)
Does a deep copy from one array to another array.
Definition: ArrayCopyDevice.h:75
#define VTKM_LOG_SCOPE(level,...)
Definition: Logging.h:265
Manages an array-worth of data.
Definition: ArrayHandle.h:283
#define VTKM_EXEC
Definition: ExportMacros.h:51
Groups connected points that have the same field value.
Definition: Atomic.h:19
vtkm::Int32 IdComponent
Represents a component ID (index of component in a vector).
Definition: Types.h:168
A control signature tag for input values.
Definition: WorkletReduceByKey.h:70
static VTKM_CONT void Run(const vtkm::cont::ArrayHandle< KeyType, KeyInStorage > &keyArray, const vtkm::cont::ArrayHandle< ValueType, ValueInStorage > &valueArray, vtkm::cont::ArrayHandle< KeyType, KeyOutStorage > &outputKeyArray, vtkm::cont::ArrayHandle< ValueType, ValueOutStorage > &outputValueArray)
Compute average values based on an array of keys.
Definition: AverageByKey.h:116
static VTKM_CONT StatState< FieldType > Run(const vtkm::cont::ArrayHandle< FieldType, Storage > &field)
Calculate various summary statistics for the input ArrayHandle.
Definition: DescriptiveStatistics.h:186
Definition: AverageByKey.h:27
static VTKM_CONT void Run(const vtkm::worklet::internal::KeysBase &keys, const InArrayType &inValues, const OutArrayType &outAverages)
Compute average values based on a set of Keys.
Definition: AverageByKey.h:63
A control signature tag for reduced output values.
Definition: WorkletReduceByKey.h:150
VTKM_EXEC void operator()(const ValuesVecType &valuesIn, OutType &sum) const
Definition: AverageByKey.h:34
_1 InputDomain
Definition: AverageByKey.h:31
VTKM_CONT vtkm::cont::ArrayHandleTransform< HandleType, FunctorType > make_ArrayHandleTransform(HandleType handle, FunctorType functor)
make_ArrayHandleTransform is convenience function to generate an ArrayHandleTransform.
Definition: ArrayHandleTransform.h:474
Definition: WorkletReduceByKey.h:42
Definition: DescriptiveStatistics.h:26
void(_2, _3) ExecutionSignature
Definition: AverageByKey.h:30
static VTKM_CONT vtkm::cont::ArrayHandle< ValueType > Run(const vtkm::worklet::internal::KeysBase &keys, const vtkm::cont::ArrayHandle< ValueType, InValuesStorage > &inValues)
Compute average values based on a set of Keys.
Definition: AverageByKey.h:79
#define VTKM_CONT
Definition: ExportMacros.h:57
A control signature tag for input keys.
Definition: WorkletReduceByKey.h:56
VTKM_EXEC_CONT T Mean() const
Definition: DescriptiveStatistics.h:113
Dispatcher for worklets that inherit from WorkletReduceByKey.
Definition: DispatcherReduceByKey.h:27
The VecTraits class gives several static members that define how to use a given type as a vector.
Definition: VecTraits.h:66
@ Perf
General timing data and algorithm flow information, such as filter execution, worklet dispatches,...
Definition: AverageByKey.h:25
void(KeysIn keys, ValuesIn valuesIn, ReducedValuesOut averages) ControlSignature
Definition: AverageByKey.h:29