ROL
ROL_QuadraticObjective_Def.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_QUADRATIC_OBJECTIVE_DEF_H
11 #define ROL_QUADRATIC_OBJECTIVE_DEF_H
12 
13 namespace ROL {
14 
15 template<typename Real>
17  const Ptr<const Vector<Real>> &g,
18  Real c)
19  : H_(H), g_(g), c_(c) {
20  tmp_ = g_->clone();
21 }
22 
23 template<typename Real>
24 Real QuadraticObjective<Real>::value( const Vector<Real> &x, Real &tol ) {
25  H_->apply(*tmp_,x,tol);
26  tmp_->scale(static_cast<Real>(0.5));
27  tmp_->plus(*g_);
28  //return x.dot(tmp_->dual()) + c_;
29  return x.apply(*tmp_) + c_;
30 }
31 
32 template<typename Real>
34  H_->apply(g,x,tol);
35  g.plus(*g_);
36 }
37 
38 template<typename Real>
39 void QuadraticObjective<Real>::hessVec( Vector<Real> &hv, const Vector<Real> &v, const Vector<Real> &x, Real &tol ) {
40  H_->apply(hv,v,tol);
41 }
42 
43 template<typename Real>
44 void QuadraticObjective<Real>::invHessVec( Vector<Real> &hv, const Vector<Real> &v, const Vector<Real> &x, Real &tol ) {
45  H_->applyInverse(hv,v,tol);
46 }
47 
48 } // namespace ROL
49 
50 #endif
QuadraticObjective(const Ptr< const LinearOperator< Real >> &H, const Ptr< const Vector< Real >> &g, Real c=Real(0))
void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol) override
Compute gradient.
virtual Real apply(const Vector< Real > &x) const
Apply to a dual vector. This is equivalent to the call .
Definition: ROL_Vector.hpp:204
void hessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &x, Real &tol) override
Apply Hessian approximation to vector.
virtual void plus(const Vector &x)=0
Compute , where .
Defines the linear algebra or vector space interface.
Definition: ROL_Vector.hpp:46
Real value(const Vector< Real > &x, Real &tol) override
Compute value.
Provides the interface to apply a linear operator.
void invHessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &x, Real &tol) override
Apply inverse Hessian approximation to vector.
const Ptr< const Vector< Real > > g_