ROL
ROL_LinearOperatorProduct.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_LINEAROPERATORPRODUCT_H
11#define ROL_LINEAROPERATORPRODUCT_H
12
14
22namespace ROL {
23
24template <class Real>
26
27 typedef Vector<Real> V;
29
30 typedef typename std::vector<ROL::Ptr<OP> >::size_type size_type;
31
32private:
33
34 ROL::Ptr<std::vector<ROL::Ptr<OP> > > ops_;
35
36public:
37
38 LinearOperatorSum( ROL::Ptr<OP> &A,
39 ROL::Ptr<OP> &B) {
40 ops_ = ROL::makePtr<std::vector<OP> >>();
41 ops_->push_back(A);
42 ops_->push_back(B);
43 }
44
45 LinearOperatorSum( ROL::Ptr<OP> &A,
46 ROL::Ptr<OP> &B,
47 ROL::Ptr<OP> &C) {
48 ops_ = ROL::makePtr<std::vector<OP> >>();
49 ops_->push_back(A);
50 ops_->push_back(B);
51 ops_->push_back(C);
52 }
53
54 virtual void update( const Vector<Real> &x, bool flag = true, int iter = -1 ) {
55 for( size_type i=0; i<ops_->size(); ++i ) {
56 (*ops_)[i]->update(x,flag,true);
57 }
58 }
59
60 virtual void apply( Vector<Real> &Hv, const Vector<Real> &v, Real &tol ) const {
61 Hv.set(v);
62 for( size_type i=0; i<ops_->size(); ++i ) {
63 (*ops_)[i]->apply(Hv,Hv,tol);
64 }
65 }
66
67 virtual void applyInverse( Vector<Real> &Hv, const Vector<Real> &v, Real &tol ) const {
68 Hv.set(v);
69 for( size_type i=ops_->size()-1; i>=0; --i ) {
70 (*ops_)[i]->applyInverse(Hv,Hv,tol);
71 }
72 }
73
74}; // class LinearOperatorProduct
75
76} // namespace ROL
77
78#endif // ROL_LINEAROPERATORPRODUCT_H
typename PV< Real >::size_type size_type
LinearOperatorSum(ROL::Ptr< OP > &A, ROL::Ptr< OP > &B)
ROL::Ptr< std::vector< ROL::Ptr< OP > > > ops_
std::vector< ROL::Ptr< OP > >::size_type size_type
virtual void update(const Vector< Real > &x, bool flag=true, int iter=-1)
Update linear operator.
virtual void applyInverse(Vector< Real > &Hv, const Vector< Real > &v, Real &tol) const
Apply inverse of linear operator.
LinearOperatorSum(ROL::Ptr< OP > &A, ROL::Ptr< OP > &B, ROL::Ptr< OP > &C)
virtual void apply(Vector< Real > &Hv, const Vector< Real > &v, Real &tol) const
Apply linear operator.
Provides the interface to apply a linear operator.
Defines the linear algebra or vector space interface.
virtual void set(const Vector &x)
Set where .