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
14
26namespace ROL {
27
28template<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
35private:
36
37 ROL::Ptr<OP> C_;
38
39
40public:
41
42 BlockOperator2UnitLower( ROL::Ptr<OP> &C ) : C_(C) {}
43 }
44
45 void apply( V &Hv, const V &v, Real &tol ) const {
46
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
Vector< Real > V
PartitionedVector< Real > PV
ROL::Ptr< OP > C_
Provides the interface to apply a 2x2 block unit lower operator to a partitioned vector.
void apply(V &Hv, const V &v, Real &tol) const
Apply linear operator.
Provides the interface to apply a linear operator.
Defines the linear algebra of vector space on a generic partitioned vector.
Defines the linear algebra or vector space interface.
ROL::BlockOperator2Diagonal BlockOperator2 apply(V &Hv, const V &v, Real &tol) const
ROL::Ptr< LinearOperator< Real > > getOperator(int row, int col) const
void applyInverse(V &Hv, const V &v Real &tol) const