Collection of Concrete Vector Reduction/Transformation Operator Implementations  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
RTOpPack_ROpGetElement.hpp
1 // @HEADER
2 // *****************************************************************************
3 // RTOp: Interfaces and Support Software for Vector Reduction Transformation
4 // Operations
5 //
6 // Copyright 2006 NTESS and the RTOp contributors.
7 // SPDX-License-Identifier: BSD-3-Clause
8 // *****************************************************************************
9 // @HEADER
10 
11 #ifndef RTOPPACK_ROP_GET_ELEMENT_HPP
12 #define RTOPPACK_ROP_GET_ELEMENT_HPP
13 
14 #include "RTOpPack_RTOpTHelpers.hpp"
15 
16 
17 namespace RTOpPack {
18 
19 
21 template<class Scalar>
23 public:
25  ROpGetElementEleWiseReductionOp(const Ordinal &global_i_in = -1)
26  :global_i_(global_i_in)
27  {}
29  Ordinal global_i() const
30  {
31  return global_i_;
32  }
34  void operator()(const index_type i, const Scalar &v0, Scalar &reduct) const
35  {
36  if (i == global_i_) {
37  reduct = v0;
38  }
39  }
40 private:
41  Ordinal global_i_;
42 };
43 
44 
49 template<class Scalar>
52  Scalar,
53  Scalar,
54  ROpGetElementEleWiseReductionOp<Scalar>
55  >
56 {
57 public:
59  ROpGetElement(const Ordinal &global_i)
60  {
61  this->setOpNameBase("ROpGetElement");
62  this->initialize(global_i);
63  this->initReductObjValue(ScalarTraits<Scalar>::zero());
64  }
66  void initialize(const Ordinal &global_i)
67  {
69  }
71  Scalar operator()(const ReductTarget& reduct_obj ) const
72  {
73  return this->getRawVal(reduct_obj);
74  }
75 protected:
77  virtual Range1D range_impl() const
78  {
79  const Ordinal i = this->getEleWiseReduction().global_i();
80  return Range1D(i, i);
81  }
82 
83 };
84 
85 
86 } // namespace RTOpPack
87 
88 
89 #endif // RTOPPACK_ROP_GET_ELEMENT_HPP
void initialize(const Ordinal &global_i)
ROpGetElementEleWiseReductionOp(const Ordinal &global_i_in=-1)
ROpGetElement(const Ordinal &global_i)
Returns the value of the element at index global_i.
Scalar operator()(const ReductTarget &reduct_obj) const
void setOpNameBase(const std::string &op_name_base)
void operator()(const index_type i, const Scalar &v0, Scalar &reduct) const
virtual Range1D range_impl() const