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_ROpMaxIndexLessThanBound.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_MAX_INDEX_LESS_THAN_BOUND_HPP
12 #define RTOPPACK_ROP_MAX_INDEX_LESS_THAN_BOUND_HPP
13 
14 #include "RTOpPack_ROpMaxIndex.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  ROpMaxIndexLessThanBoundEleWiseReductionOp<Scalar>,
68  ROpMaxIndexReductObjReductionOp<Scalar> >
69 {
70 public:
73  const Scalar &bound_in = Teuchos::ScalarTraits<Scalar>::zero()
74  )
75  {
76  this->setOpNameBase("ROpMaxIndexLessThanBound");
77  bound(bound_in);
78  this->initReductObjValue(
79  ScalarIndex<Scalar>(-ScalarTraits<Scalar>::rmax(), -1));
80  }
82  void bound(const Scalar& bound_in)
83  {
84  this->setEleWiseReduction(
86  );
87  }
89  ScalarIndex<Scalar> operator()(const ReductTarget& reduct_obj ) const
90  { return this->getRawVal(reduct_obj); }
91 };
92 
93 
94 } // namespace RTOpPack
95 
96 
97 #endif // RTOPPACK_ROP_MAX_INDEX_LESS_THAN_BOUND_HPP
ROpMaxIndexLessThanBound(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
Returns the maximum element less than some bound along with its index: result.scalar = x(k) and resul...
void setOpNameBase(const std::string &op_name_base)
ROpMaxIndexLessThanBoundEleWiseReductionOp(const Scalar &bound=ScalarTraits< Scalar >::zero())