ROL
ROL_ScaledObjective_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_SCALED_OBJECTIVE_DEF_HPP
11 #define ROL_SCALED_OBJECTIVE_DEF_HPP
12 
13 namespace ROL {
14 
15 template<typename Real>
16 void ScaledObjective<Real>::update(const Vector<Real> &x, UpdateType type, int iter) {
17  obj_->update(x,type,iter);
18 }
19 
20 template<typename Real>
21 void ScaledObjective<Real>::setParameter(const std::vector<Real> &param) {
23  obj_->setParameter(param);
24 }
25 
26 template<typename Real>
27 Real ScaledObjective<Real>::value( const Vector<Real> &x, Real &tol ) {
28  return scale_ * obj_->value(x,tol);
29 }
30 
31 template<typename Real>
33  obj_->gradient(g,x,tol);
34  g.scale(scale_);
35 }
36 
37 template<typename Real>
38 void ScaledObjective<Real>::hessVec( Vector<Real> &hv, const Vector<Real> &v, const Vector<Real> &x, Real &tol ) {
39  obj_->hessVec(hv,v,x,tol);
40  hv.scale(scale_);
41 }
42 
43 template<typename Real>
44 void ScaledObjective<Real>::invHessVec( Vector<Real> &hv, const Vector<Real> &v, const Vector<Real> &x, Real &tol ) {
45  obj_->invHessVec(hv,v,x,tol);
46  hv.scale(static_cast<Real>(1)/scale_);
47 }
48 
49 template<typename Real>
50 void ScaledObjective<Real>::precond( Vector<Real> &Pv, const Vector<Real> &v, const Vector<Real> &x, Real &tol ) {
51  obj_->precond(Pv,v,x,tol);
52  Pv.scale(static_cast<Real>(1)/scale_);
53 }
54 
55 } // End ROL Namespace
56 
57 #endif
virtual void scale(const Real alpha)=0
Compute where .
Real value(const Vector< Real > &x, Real &tol) override
Compute value.
void precond(Vector< Real > &Pv, const Vector< Real > &v, const Vector< Real > &x, Real &tol) override
Apply preconditioner to vector.
void update(const Vector< Real > &x, UpdateType type, int iter=-1) override
Update objective function.
void setParameter(const std::vector< Real > &param) override
Defines the linear algebra or vector space interface.
Definition: ROL_Vector.hpp:46
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.
virtual void setParameter(const std::vector< Real > &param)
const Ptr< Obj > obj_
void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol) override
Compute gradient.