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_ROpMinIndexGreaterThanBound.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_GREATER_THAN_BOUND_HPP
12 #define RTOPPACK_ROP_MIN_INDEX_GREATER_THAN_BOUND_HPP
13 
14 #include "RTOpPack_ROpMinIndex.hpp"
16 
17 
18 namespace RTOpPack {
19 
20 
22 template<class Scalar>
24 public:
27  const Scalar &bound = ScalarTraits<Scalar>::zero()
28  )
29  :bound_(bound)
30  {}
32  void operator()(const index_type i, const Scalar &v0,
33  ScalarIndex<Scalar> &reduct) const
34  {
35  if(
36  v0 > bound_
37  &&
38  (
39  v0 < reduct.scalar
40  ||
41  ( v0 == reduct.scalar && i < reduct.index )
42  )
43  )
44  {
45  reduct = ScalarIndex<Scalar>(v0, i);
46  }
47  }
48 private:
49  Scalar bound_;
50 };
51 
52 
62 template<class Scalar>
65  Scalar,
66  ScalarIndex<Scalar>,
67  ROpMinIndexGreaterThanBoundEleWiseReductionOp<Scalar>,
68  ROpMinIndexReductObjReductionOp<Scalar> >
69 {
70 public:
71 
74  const Scalar &bound_in = Teuchos::ScalarTraits<Scalar>::zero()
75  )
76  {
77  this->setOpNameBase("ROpMinIndexGreaterThanBound");
78  bound(bound_in);
79  this->initReductObjValue(
80  ScalarIndex<Scalar>(+ScalarTraits<Scalar>::rmax(), -1));
81  }
83  void bound(const Scalar& bound_in)
84  {
85  this->setEleWiseReduction(
87  );
88  }
90  ScalarIndex<Scalar> operator()(const ReductTarget& reduct_obj ) const
91  { return this->getRawVal(reduct_obj); }
92 
93 };
94 
95 
96 } // namespace RTOpPack
97 
98 
99 #endif // RTOPPACK_ROP_MIN_INDEX_GREATER_THAN_BOUND_HPP
Returns the minimum element greater than some bound along with its index: result.scalar = x(k) and re...
ROpMinIndexGreaterThanBoundEleWiseReductionOp(const Scalar &bound=ScalarTraits< Scalar >::zero())
void setOpNameBase(const std::string &op_name_base)
ROpMinIndexGreaterThanBound(const Scalar &bound_in=Teuchos::ScalarTraits< Scalar >::zero())
void operator()(const index_type i, const Scalar &v0, ScalarIndex< Scalar > &reduct) const
ScalarIndex< Scalar > operator()(const ReductTarget &reduct_obj) const