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_TOpSetElement.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_TOP_SET_ELEMENT_HPP
12 #define RTOPPACK_TOP_SET_ELEMENT_HPP
13 
14 #include "RTOpPack_RTOpTHelpers.hpp"
15 #include "Teuchos_as.hpp"
16 
17 
18 namespace RTOpPack {
19 
20 
22 template<class Scalar>
24 {
25 public:
27  TOpSetElementEleWiseTransformation( const Ordinal &global_i_in = -1,
28  const Scalar &val_i_in = static_cast<Scalar>(0.0) )
29  :global_i_(global_i_in), val_i_(val_i_in)
30  {}
32  Ordinal global_i() const
33  {
34  return global_i_;
35  }
37  void operator()( const Ordinal global_i_in, Scalar &z0 ) const
38  {
39  if (global_i_in == global_i_) {
40  z0 = val_i_;
41  }
42  }
43 private:
44  Ordinal global_i_;
45  Scalar val_i_;
46 };
47 
48 
51 template<class Scalar>
53  : public TOp_0_1_CoordVariantBase<Scalar, TOpSetElementEleWiseTransformation<Scalar> >
54 {
55 public:
57  TOpSetElement(const Ordinal &global_i_in = -1,
58  const Scalar &val_i_in = static_cast<Scalar>(0.0))
59  {
60  this->setOpNameBase("TOpSetElement");
62  TOpSetElementEleWiseTransformation<Scalar>(global_i_in, val_i_in));
63  }
65  void initialize(const Ordinal &global_i_in, const Scalar &val_i_in)
66  {
68  TOpSetElementEleWiseTransformation<Scalar>(global_i_in, val_i_in));
69  }
70 protected:
72  virtual Range1D range_impl() const
73  {
74  const Ordinal i = this->getEleWiseTransformation().global_i();
75  return Range1D(i, i);
76  }
77 };
78 
79 
80 } // namespace RTOpPack
81 
82 
83 #endif // RTOPPACK_TOP_SET_ELEMENT_HPP
Element-wise transformation for TOpSetElement.
void operator()(const Ordinal global_i_in, Scalar &z0) const
TOpSetElementEleWiseTransformation(const Ordinal &global_i_in=-1, const Scalar &val_i_in=static_cast< Scalar >(0.0))
virtual Range1D range_impl() const
void initialize(const Ordinal &global_i_in, const Scalar &val_i_in)
void setOpNameBase(const std::string &op_name_base)
TOpSetElement(const Ordinal &global_i_in=-1, const Scalar &val_i_in=static_cast< Scalar >(0.0))
Set the elements of a vector to: z0[i] = i+global_i+1, i=0...n-1.