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_ROpMinIndex.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_MIN_INDEX_HPP
12 #define RTOPPACK_ROP_MIN_INDEX_HPP
13 
14 
15 #include "RTOpPack_RTOpTHelpers.hpp"
16 
17 
18 namespace RTOpPack {
19 
20 
22 template<class Scalar>
24 public:
26  void operator()(const index_type i, const Scalar &v0,
27  ScalarIndex<Scalar> &reduct) const
28  {
29  if(
30  v0 < reduct.scalar
31  ||
32  ( v0 == reduct.scalar && i < reduct.index )
33  )
34  {
35  reduct = ScalarIndex<Scalar>(v0, i);
36  }
37  }
38 };
39 
40 
42 template<class Scalar>
44 public:
46  void operator()(
47  const ScalarIndex<Scalar>& in_reduct, ScalarIndex<Scalar>& inout_reduct
48  ) const
49  {
50  if(
51  in_reduct.scalar < inout_reduct.scalar
52  ||
53  (
54  in_reduct.scalar == inout_reduct.scalar
55  &&
56  in_reduct.index < inout_reduct.index
57  )
58  )
59  {
60  inout_reduct = in_reduct;
61  }
62  }
63 };
64 
65 
71 template<class Scalar>
74  Scalar,
75  ScalarIndex<Scalar>,
76  ROpMinIndexEleWiseReductionOp<Scalar>,
77  ROpMinIndexReductObjReductionOp<Scalar> >
78 {
79 public:
82  {
83  this->setOpNameBase("ROpMinIndex");
84  this->initReductObjValue(
85  ScalarIndex<Scalar>(+ScalarTraits<Scalar>::rmax(), -1));
86  }
88  ScalarIndex<Scalar> operator()(const ReductTarget& reduct_obj) const
89  { return this->getRawVal(reduct_obj); }
90 };
91 
92 
93 } // namespace RTOpPack
94 
95 
96 #endif // RTOPPACK_ROP_MIN_INDEX_HPP
Returns the minimum element and its index: result.scalar = x(k) and result.index = k such that x(k) &lt;...
ScalarIndex< Scalar > operator()(const ReductTarget &reduct_obj) const
void operator()(const index_type i, const Scalar &v0, ScalarIndex< Scalar > &reduct) const
void setOpNameBase(const std::string &op_name_base)
void operator()(const ScalarIndex< Scalar > &in_reduct, ScalarIndex< Scalar > &inout_reduct) const