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
13namespace ROL {
14
15template<typename Real>
17 obj_->update(x,type,iter);
18}
19
20template<typename Real>
21void ScaledObjective<Real>::setParameter(const std::vector<Real> &param) {
23 obj_->setParameter(param);
24}
25
26template<typename Real>
27Real ScaledObjective<Real>::value( const Vector<Real> &x, Real &tol ) {
28 return scale_ * obj_->value(x,tol);
29}
30
31template<typename Real>
33 obj_->gradient(g,x,tol);
34 g.scale(scale_);
35}
36
37template<typename Real>
38void 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
43template<typename Real>
44void 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
49template<typename Real>
50void 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
const Ptr< Obj > obj_
virtual void setParameter(const std::vector< Real > &param)
Real value(const Vector< Real > &x, Real &tol) override
Compute value.
void invHessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &x, Real &tol) override
Apply inverse Hessian approximation 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
void hessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &x, Real &tol) override
Apply Hessian approximation to vector.
void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol) override
Compute gradient.
void precond(Vector< Real > &Pv, const Vector< Real > &v, const Vector< Real > &x, Real &tol) override
Apply preconditioner to vector.
Defines the linear algebra or vector space interface.
virtual void scale(const Real alpha)=0
Compute where .