ROL
ROL_BlockOperator2UnitUpper.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_BLOCKOPERATOR2UNITUPPER_H
11#define ROL_BLOCKOPERATOR2UNITUPPER_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> B_;
38
39
40public:
41
42 BlockOperator2UnitUpper( ROL::Ptr<OP> &B ) : B_(B) {}
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 B_->apply(*Hv1,*v2,tol);
57 Hv1->plus(*v1);
58 Hv2->set(*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 B_->apply(*Hv1,*v2,tol);
74 Hv1->scale(-1.0);
75 Hv1->plus(*v1);
76 Hv2->set(*v2);
77
78 }
79
80 ROL::Ptr<LinearOperator<Real> > getOperator( int row, int col ) const {
81 if( row == 0 && col == 1 ) {
82 return B_;
83 }
84 else {
85 ROL_TEST_FOR_EXCEPTION( true, std::invalid_argument,
86 ">>> ERROR (ROL_BlockOperator2UnitUpper, getOperator): "
87 "invalid block indices.");
88 }
89
90 }
91
92
93}; // class BlockOperator2UnitUpper
94
95} // namespace ROL
96
97#endif // ROL_BLOCKOPERATOR2UNITUPPER_H
Vector< Real > V
PartitionedVector< Real > PV
ROL::Ptr< OP > B_
Provides the interface to apply a 2x2 block unit upper 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