ROL
ROL_BlockOperator2.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_BLOCKOPERATOR2_H
11#define ROL_BLOCKOPERATOR2_H
12
13#include "ROL_BlockOperator.hpp"
14
23namespace ROL {
24
25template<class Real>
26class BlockOperator2 : public LinearOperator<Real> {
27
28 typedef Vector<Real> V; // ROL Vector
29 typedef PartitionedVector<Real> PV; // ROL PartitionedVector
30 typedef LinearOperator<Real> OP; // Linear Operator
31
32private:
33
34 ROL::Ptr<OP> bkop_;
35 ROL::Ptr<std::vector<ROL::Ptr<OP> > > ops_;
36
37public:
38
39 BlockOperator2( ROL::Ptr<OP> &a11, ROL::Ptr<OP> &a12,
40 ROL::Ptr<OP> &a21, ROL::Ptr<OP> &a22 ) {
41
42 using std::vector;
43
44
45
46 ops_ = ROL::makePtr<vector<ROL::Ptr<OP> >>();
47 ops_->push_back(a11);
48 ops_->push_back(a12);
49 ops_->push_back(a21);
50 ops_->push_back(a22);
51
52 bkop_ = ROL::makePtr<BlockOperator<Real>>(ops_);
53
54 }
55
56
57 void apply( V &Hv, const V &v, Real &tol ) const {
58 bkop_->apply(Hv,v,tol);
59 }
60
61
62 void applyInverse( V &Hv, const V &v, Real &tol ) const {
63
64 ROL_TEST_FOR_EXCEPTION( true , std::logic_error,
65 ">>> ERROR (ROL_BlockOperator2, applyInverse): "
66 "Not implemented.");
67
68 }
69
70 ROL::Ptr<LinearOperator<Real> > getOperator( int row, int col ) const {
71 int dex = 2*row+col;
72 if( 0<=dex && dex<=3 ) {
73 return (*ops_)[dex];
74 }
75 else {
76 ROL_TEST_FOR_EXCEPTION( true, std::invalid_argument,
77 ">>> ERROR (ROL_BlockOperator2, getOperator): "
78 "invalid block indices.");
79 }
80
81 }
82
83
84}; // class BlockOperator2
85
86} // namespace ROL
87
88#endif // ROL_BLOCKOPERATOR2_H
Provides the interface to apply a 2x2 block operator to a partitioned vector.
PartitionedVector< Real > PV
LinearOperator< Real > OP
void applyInverse(V &Hv, const V &v, Real &tol) const
Apply inverse of linear operator.
ROL::Ptr< LinearOperator< Real > > getOperator(int row, int col) const
BlockOperator2(ROL::Ptr< OP > &a11, ROL::Ptr< OP > &a12, ROL::Ptr< OP > &a21, ROL::Ptr< OP > &a22)
void apply(V &Hv, const V &v, Real &tol) const
Apply linear operator.
ROL::Ptr< std::vector< ROL::Ptr< OP > > > ops_
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.