Debian Codegraph @

packages/rol/adapters/teuchos/src/pebbl/ROL_PEBBL_TeuchosIntegerTransformation.hpp

raw
1 // @HEADER
2 // *****************************************************************************
3 // Rapid Optimization Library (ROL) Package
4 //
5 // Copyright 2014 NTESS and the ROL contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9
10 #ifndef ROL_PEBBL_TEUCHOSINTEGERTRANSFORMATION_H
11 #define ROL_PEBBL_TEUCHOSINTEGERTRANSFORMATION_H
12
13 #include "ROL_PEBBL_IntegerTransformation.hpp"
14 #include "ROL_TeuchosVector.hpp"
15
16 /** @ingroup func_group
17 \class ROL::PEBBL::TeuchosIntegerTransformation
18 \brief Defines the pebbl transform operator interface for TeuchosVectors.
19
20 ROL's pebbl constraint interface is designed to set individual components
21 of a vector to a fixed value. The range space is the same as the domain.
22
23 ---
24 */
25
26
27 namespace ROL {
28 namespace PEBBL {
29
30 template <class Ordinal, class Real>
31 class TeuchosIntegerTransformation : public IntegerTransformation<Real> {
32 private:
33 Ptr<Teuchos::SerialDenseVector<Ordinal,Real>> getData(Vector<Real> &x) const {
34 return dynamic_cast<TeuchosVector<Ordinal,Real>&>(x).getVector();
35 }
36
37 Ptr<const Teuchos::SerialDenseVector<Ordinal,Real>> getConstData(const Vector<Real> &x) const {
38 return dynamic_cast<const TeuchosVector<Ordinal,Real>&>(x).getVector();
39 }
40
41 using IntegerTransformation<Real>::map_;
42
43 public:
44 TeuchosIntegerTransformation(void)
45 : IntegerTransformation<Real>() {}
46
47 TeuchosIntegerTransformation(const TeuchosIntegerTransformation &T)
48 : IntegerTransformation<Real>(T) {}
49
50 void fixValues(Vector<Real> &c, bool zero = false) const {
51 for (auto it=map_.begin(); it!=map_.end(); ++it) {
52 (*getData(c))(it->first) = (zero ? static_cast<Real>(0) : it->second);
53 }
54 }
55
56 }; // class TeuchosIntegerTransformation
57
58 } // namespace PEBBL
59 } // namespace ROL
60
61 #endif