VTK-m  2.0
MarginalizeNDHistogram.h
Go to the documentation of this file.
1 //============================================================================
2 // Copyright (c) Kitware, Inc.
3 // All rights reserved.
4 // See LICENSE.txt for details.
5 //
6 // This software is distributed WITHOUT ANY WARRANTY; without even
7 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8 // PURPOSE. See the above copyright notice for more information.
9 //============================================================================
10 
11 #ifndef vtk_m_worklet_MarginalizeNDHistogram_h
12 #define vtk_m_worklet_MarginalizeNDHistogram_h
13 
15 
16 namespace vtkm
17 {
18 namespace worklet
19 {
20 namespace histogram
21 {
22 // Set freq of the entity, which does not meet the condition, to 0
23 template <class BinaryCompare>
25 {
26 public:
27  VTKM_CONT
28  explicit ConditionalFreq(BinaryCompare _bop)
29  : bop(_bop)
30  {
31  }
32 
33  VTKM_CONT
34  void setVar(vtkm::Id _var) { var = _var; }
35 
36  BinaryCompare bop;
38 
40  using ExecutionSignature = void(_1, _2, _3);
41 
42  VTKM_EXEC
43  void operator()(const vtkm::Id& binIdIn, const vtkm::Id& freqIn, vtkm::Id& freqOut) const
44  {
45  if (bop(var, binIdIn))
46  freqOut = freqIn;
47  else
48  freqOut = 0;
49  }
50 };
51 
52 // Convert multiple indices to 1D index
54 {
55 public:
56  using ControlSignature = void(FieldIn bin, FieldIn binIndexIn, FieldOut binIndexOut);
57  using ExecutionSignature = void(_1, _2, _3);
58  using InputDomain = _1;
59 
61 
62  VTKM_CONT
63  explicit To1DIndex(vtkm::Id numberOfBins0)
64  : numberOfBins(numberOfBins0)
65  {
66  }
67 
68  VTKM_EXEC
69  void operator()(const vtkm::Id& bin, const vtkm::Id& binIndexIn, vtkm::Id& binIndexOut) const
70  {
71  binIndexOut = binIndexIn * numberOfBins + bin;
72  }
73 };
74 }
75 }
76 } // namespace vtkm::worklet
77 
78 #endif // vtk_m_worklet_MarginalizeNDHistogram_h
vtkm::worklet::histogram::To1DIndex::ControlSignature
void(FieldIn bin, FieldIn binIndexIn, FieldOut binIndexOut) ControlSignature
Definition: MarginalizeNDHistogram.h:56
VTKM_EXEC
#define VTKM_EXEC
Definition: ExportMacros.h:51
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
vtkm::worklet::histogram::To1DIndex::numberOfBins
vtkm::Id numberOfBins
Definition: MarginalizeNDHistogram.h:60
vtkm::worklet::histogram::ConditionalFreq::var
vtkm::Id var
Definition: MarginalizeNDHistogram.h:37
vtkm::worklet::WorkletMapField::FieldOut
A control signature tag for output fields.
Definition: WorkletMapField.h:60
vtkm::worklet::histogram::To1DIndex::To1DIndex
VTKM_CONT To1DIndex(vtkm::Id numberOfBins0)
Definition: MarginalizeNDHistogram.h:63
vtkm::worklet::histogram::To1DIndex::InputDomain
_1 InputDomain
Definition: MarginalizeNDHistogram.h:58
vtkm::worklet::histogram::ConditionalFreq::setVar
VTKM_CONT void setVar(vtkm::Id _var)
Definition: MarginalizeNDHistogram.h:34
vtkm::worklet::histogram::To1DIndex::operator()
VTKM_EXEC void operator()(const vtkm::Id &bin, const vtkm::Id &binIndexIn, vtkm::Id &binIndexOut) const
Definition: MarginalizeNDHistogram.h:69
vtkm::Id
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
DispatcherMapField.h
vtkm::worklet::histogram::ConditionalFreq::ExecutionSignature
void(_1, _2, _3) ExecutionSignature
Definition: MarginalizeNDHistogram.h:40
vtkm::worklet::histogram::ConditionalFreq::bop
BinaryCompare bop
Definition: MarginalizeNDHistogram.h:36
vtkm::worklet::WorkletMapField::FieldIn
A control signature tag for input fields.
Definition: WorkletMapField.h:49
VTKM_CONT
#define VTKM_CONT
Definition: ExportMacros.h:57
vtkm::worklet::histogram::ConditionalFreq::operator()
VTKM_EXEC void operator()(const vtkm::Id &binIdIn, const vtkm::Id &freqIn, vtkm::Id &freqOut) const
Definition: MarginalizeNDHistogram.h:43
vtkm::worklet::histogram::To1DIndex::ExecutionSignature
void(_1, _2, _3) ExecutionSignature
Definition: MarginalizeNDHistogram.h:57
vtkm::worklet::histogram::To1DIndex
Definition: MarginalizeNDHistogram.h:53
vtkm::worklet::histogram::ConditionalFreq::ConditionalFreq
VTKM_CONT ConditionalFreq(BinaryCompare _bop)
Definition: MarginalizeNDHistogram.h:28
vtkm::worklet::histogram::ConditionalFreq::ControlSignature
void(FieldIn, FieldIn, FieldOut) ControlSignature
Definition: MarginalizeNDHistogram.h:39
vtkm::worklet::WorkletMapField
Base class for worklets that do a simple mapping of field arrays.
Definition: WorkletMapField.h:38
vtkm::worklet::histogram::ConditionalFreq
Definition: MarginalizeNDHistogram.h:24