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
13namespace ROL {
14
15template<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
23template<typename Real>
24Real 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
32template<typename Real>
34 H_->apply(g,x,tol);
35 g.plus(*g_);
36}
37
38template<typename Real>
39void QuadraticObjective<Real>::hessVec( Vector<Real> &hv, const Vector<Real> &v, const Vector<Real> &x, Real &tol ) {
40 H_->apply(hv,v,tol);
41}
42
43template<typename Real>
45 H_->applyInverse(hv,v,tol);
46}
47
48} // namespace ROL
49
50#endif
Provides the interface to apply a linear operator.
void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol) override
Compute gradient.
const Ptr< const Vector< Real > > g_
void invHessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &x, Real &tol) override
Apply inverse Hessian approximation to vector.
void hessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &x, Real &tol) override
Apply Hessian approximation to vector.
QuadraticObjective(const Ptr< const LinearOperator< Real > > &H, const Ptr< const Vector< Real > > &g, Real c=Real(0))
Real value(const Vector< Real > &x, Real &tol) override
Compute value.
Defines the linear algebra or vector space interface.
virtual Real apply(const Vector< Real > &x) const
Apply to a dual vector. This is equivalent to the call .
virtual void plus(const Vector &x)=0
Compute , where .