ROL
ROL_BlockOperator2UnitLower.hpp
Go to the documentation of this file.
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_BLOCKOPERATOR2UNITLOWER_H
11 #define ROL_BLOCKOPERATOR2UNITLOWER_H
12 
13 #include "ROL_BlockOperator2.hpp"
14 
26 namespace ROL {
27 
28 template<class Real>
30 
31  typedef Vector<Real> V; // ROL Vector
32  typedef PartitionedVector<Real> PV; // ROL PartitionedVector
33  typedef LinearOperator<Real> OP; // Linear Operator
34 
35 private:
36 
37  ROL::Ptr<OP> C_;
38 
39 
40 public:
41 
42  BlockOperator2UnitLower( ROL::Ptr<OP> &C ) : C_(C) {}
43  }
44 
45  void apply( V &Hv, const V &v, Real &tol ) const {
46 
47 
48  PV &Hv_pv = dynamic_cast<PV&>(Hv);
49  const PV &v_pv = dynamic_cast<const PV&>(v);
50 
51  ROL::Ptr<V> Hv1 = Hv_pv.get(0);
52  ROL::Ptr<V> Hv2 = Hv_pv.get(1);
53  ROL::Ptr<const V> v1 = v_pv.get(0);
54  ROL::Ptr<const V> v2 = v_pv.get(1);
55 
56  Hv1->set(*v1);
57  C_->apply(*Hv2,*v1,tol);
58  Hv2->plus(*v2);
59  }
60 
61 
62  void applyInverse( V &Hv, const V &v Real &tol ) const {
63 
64 
65  PV &Hv_pv = dynamic_cast<PV&>(Hv);
66  const PV &v_pv = dynamic_cast<const PV&>(v);
67 
68  ROL::Ptr<V> Hv1 = Hv_pv.get(0);
69  ROL::Ptr<V> Hv2 = Hv_pv.get(1);
70  ROL::Ptr<const V> v1 = v_pv.get(0);
71  ROL::Ptr<const V> v2 = v_pv.get(1);
72 
73  Hv1->set(*v1);
74  C_->apply(*Hv2,*v1,tol);
75  Hv2->scale(-1.0);
76  Hv2->plus(*v2);
77 
78  }
79 
80  ROL::Ptr<LinearOperator<Real> > getOperator( int row, int col ) const {
81  if( row == 1 && col == 0 ) {
82  return C_;
83  }
84  else {
85  ROL_TEST_FOR_EXCEPTION( true, std::invalid_argument,
86  ">>> ERROR (ROL_BlockOperator2UnitLower, getOperator): "
87  "invalid block indices.");
88  }
89 
90  }
91 
92 
93 }; // class BlockOperator2UnitLower
94 
95 } // namespace ROL
96 
97 #endif // ROL_BLOCKOPERATOR2UNITLOWER_H
PartitionedVector< Real > PV
ROL::Ptr< LinearOperator< Real > > getOperator(int row, int col) const
void applyInverse(V &Hv, const V &v Real &tol) const
Defines the linear algebra of vector space on a generic partitioned vector.
Defines the linear algebra or vector space interface.
Definition: ROL_Vector.hpp:46
Vector< Real > V
Provides the interface to apply a linear operator.
Provides the interface to apply a 2x2 block unit lower operator to a partitioned vector.
ROL::Ptr< OP > C_
ROL::DiagonalOperator apply