ROL
Toggle main menu visibility
Loading...
Searching...
No Matches
src
function
operator
ROL_LinearOperatorSum.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_LINEAROPERATORSUM_H
11
#define ROL_LINEAROPERATORSUM_H
12
13
#include "
ROL_LinearOperator.hpp
"
14
20
21
22
namespace
ROL
{
23
24
template
<
class
Real>
25
class
LinearOperatorSum
:
public
LinearOperator
<Real> {
26
27
typedef
Vector<Real>
V
;
28
typedef
LinearOperator<Real>
OP
;
29
30
typedef
typename
std::vector<ROL::Ptr<OP> >
::size_type
size_type
;
31
32
private
:
33
34
ROL::Ptr<std::vector<ROL::Ptr<OP> > >
ops_
;
35
ROL::Ptr<V>
scratch_
;
36
37
public
:
38
39
LinearOperatorSum
( ROL::Ptr<OP> &A,
40
ROL::Ptr<OP> &B,
41
ROL::Ptr<V> & scratch ) :
42
scratch_
(scratch) {
43
ops_
= ROL::makePtr<std::vector<OP> >>();
44
ops_
->push_back(A);
45
ops_
->push_back(B);
46
}
47
48
LinearOperatorSum
( ROL::Ptr<OP> &A,
49
ROL::Ptr<OP> &B,
50
ROL::Ptr<OP> &C,
51
ROL::Ptr<V> & scratch ) :
52
scratch_
(scratch) {
53
ops_
= ROL::makePtr<std::vector<OP> >>();
54
ops_
->push_back(A);
55
ops_
->push_back(B);
56
ops_
->push_back(C);
57
}
58
59
// TODO: implementation for arbitrary sum
60
61
virtual
void
update
(
const
Vector<Real>
&x,
bool
flag =
true
,
int
iter = -1 ) {
62
for
(
size_type
i=0; i<
ops_
->size(); ++i ) {
63
(*ops_)[i]->update(x,flag,
true
);
64
}
65
}
66
67
virtual
void
apply
(
Vector<Real>
&Hv,
const
Vector<Real>
&v, Real &tol )
const
{
68
(*ops_)[0]->apply(Hv,v,tol);
69
for
(
size_type
i=1; i<
ops_
->size(); ++i ) {
70
(*ops_)[i]->apply(*
scratch_
,v,tol);
71
Hv.
plus
(*
scratch_
);
72
}
73
}
74
75
virtual
void
applyInverse
(
Vector<Real>
&Hv,
const
Vector<Real>
&v, Real &tol )
const
{
76
ROL_TEST_FOR_EXCEPTION(
true
, std::invalid_argument,
77
">>> ERROR (ROL_LinearOperatorSum, applyInverse): "
78
"Inverse is not defined for general sum of operators."
);
79
}
80
81
};
// class LinearOperatorSum
82
83
}
// namespace ROL
84
85
#endif
// ROL_LINEAROPERATOR_PRODUCT_H
ROL_LinearOperator.hpp
ROL::LinearOperatorSum::update
virtual void update(const Vector< Real > &x, bool flag=true, int iter=-1)
Definition
ROL_LinearOperatorSum.hpp:61
ROL::LinearOperatorSum::LinearOperatorSum
LinearOperatorSum(ROL::Ptr< OP > &A, ROL::Ptr< OP > &B, ROL::Ptr< V > &scratch)
Definition
ROL_LinearOperatorSum.hpp:39
ROL::LinearOperatorSum::applyInverse
virtual void applyInverse(Vector< Real > &Hv, const Vector< Real > &v, Real &tol) const
Definition
ROL_LinearOperatorSum.hpp:75
ROL::LinearOperatorSum::OP
LinearOperator< Real > OP
Definition
ROL_LinearOperatorSum.hpp:28
ROL::LinearOperatorSum::V
Vector< Real > V
Definition
ROL_LinearOperatorSum.hpp:27
ROL::LinearOperatorSum::LinearOperatorSum
LinearOperatorSum(ROL::Ptr< OP > &A, ROL::Ptr< OP > &B, ROL::Ptr< OP > &C, ROL::Ptr< V > &scratch)
Definition
ROL_LinearOperatorSum.hpp:48
ROL::LinearOperatorSum::scratch_
ROL::Ptr< V > scratch_
Definition
ROL_LinearOperatorSum.hpp:35
ROL::LinearOperatorSum::ops_
ROL::Ptr< std::vector< ROL::Ptr< OP > > > ops_
Definition
ROL_LinearOperatorSum.hpp:34
ROL::LinearOperatorSum::size_type
std::vector< ROL::Ptr< OP > >::size_type size_type
Definition
ROL_LinearOperatorSum.hpp:30
ROL::LinearOperatorSum::apply
virtual void apply(Vector< Real > &Hv, const Vector< Real > &v, Real &tol) const
Definition
ROL_LinearOperatorSum.hpp:67
ROL::LinearOperator
Provides the interface to apply a linear operator.
Definition
ROL_LinearOperator.hpp:37
ROL::Vector
Defines the linear algebra or vector space interface.
Definition
ROL_Vector.hpp:51
ROL::Vector::plus
virtual void plus(const Vector &x)=0
Compute , where .
ROL
Definition
ROL_ElementwiseVector.hpp:27
Generated by
1.17.0