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
#define VTKM_LOG_SCOPE(level,...)
Definition: Logging.h:211
Manages an array-worth of data.
Definition: ArrayHandle.h:300
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_EXEC
Definition: ExportMacros.h:51
Groups connected points that have the same field value.
Definition: Atomic.h:19
vtkm::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:194
A control signature tag for input values associated with the keys.
Definition: WorkletReduceByKey.h:88
static 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
Definition: AverageByKey.h:27
A control signature tag for reduced output values.
Definition: WorkletReduceByKey.h:139
T Mean() const
Definition: DescriptiveStatistics.h:133
_1 InputDomain
Definition: AverageByKey.h:31
Base class for worklets that group elements by keys.
Definition: WorkletReduceByKey.h:54
Definition: DescriptiveStatistics.h:26
void(_2, _3) ExecutionSignature
Definition: AverageByKey.h:30
#define VTKM_CONT
Definition: ExportMacros.h:57
A control signature tag for input keys.
Definition: WorkletReduceByKey.h:73
void operator()(const ValuesVecType &valuesIn, OutType &sum) const
Definition: AverageByKey.h:34
static 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
Dispatcher for worklets that inherit from WorkletReduceByKey.
Definition: DispatcherReduceByKey.h:27
static 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
Traits that can be queried to treat any type as a Vec.
Definition: VecTraits.h:61
static StatState< FieldType > Run(const vtkm::cont::ArrayHandle< FieldType, Storage > &field)
Calculate various summary statistics for the input ArrayHandle.
Definition: DescriptiveStatistics.h:225
vtkm::cont::ArrayHandleTransform< HandleType, FunctorType > make_ArrayHandleTransform(HandleType handle, FunctorType functor)
make_ArrayHandleTransform is convenience function to generate an ArrayHandleTransform.
Definition: ArrayHandleTransform.h:480
@ 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