ROL
ROL_PQNObjective_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_PQNOBJECTIVEDEF_H
11 #define ROL_PQNOBJECTIVEDEF_H
12 
13 
14 namespace ROL {
15 
16 template<typename Real>
18  const Vector<Real> &x,
19  const Vector<Real> &g)
20  : secant_(secant), x_(x.clone()), g_(g.clone()), pwa_(x.clone()), dwa_(g.clone()) {
21  setAnchor(x,g);
22 }
23 
24 template<typename Real>
25 Real PQNObjective<Real>::value( const Vector<Real> &x, Real &tol ) {
26  pwa_->set(x);
27  pwa_->axpy(static_cast<Real>(-1),*x_);
28  secant_->applyB(*dwa_, *pwa_);
29  dwa_->scale(static_cast<Real>(0.5));
30  dwa_->plus(*g_);
31  return dwa_->apply(*pwa_);
32 }
33 
34 template<typename Real>
35 void PQNObjective<Real>::gradient( Vector<Real> &g, const Vector<Real> &x, Real &tol ) {
36  pwa_->set(x);
37  pwa_->axpy(static_cast<Real>(-1),*x_);
38  secant_->applyB(g, *pwa_);
39  g.plus(*g_);
40 }
41 
42 template<typename Real>
43 void PQNObjective<Real>::hessVec( Vector<Real> &hv, const Vector<Real> &v, const Vector<Real> &x, Real &tol ) {
44  secant_->applyB(hv, v);
45 }
46 
47 template<typename Real>
49  x_->set(x); g_->set(g);
50 }
51 
52 } // namespace ROL
53 
54 #endif
void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol) override
Compute gradient.
virtual void plus(const Vector &x)=0
Compute , where .
Defines the linear algebra or vector space interface.
Definition: ROL_Vector.hpp:46
PQNObjective(const Ptr< Secant< Real >> &secant, const Vector< Real > &x, const Vector< Real > &g)
Provides interface for and implements limited-memory secant operators.
Definition: ROL_Secant.hpp:45
void setAnchor(const Vector< Real > &x, const Vector< Real > &g)
Real value(const Vector< Real > &x, Real &tol) override
Compute value.
void hessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &x, Real &tol) override
Apply Hessian approximation to vector.