ROL
ROL_LinearObjective_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_LINEAR_OBJECTIVE_DEF_H
11 #define ROL_LINEAR_OBJECTIVE_DEF_H
12 
13 namespace ROL {
14 
15 template<typename Real>
16 LinearObjective<Real>::LinearObjective(const Ptr<const Vector<Real>> &cost) : cost_(cost) {
17  dual_cost_ = cost_->dual().clone();
18  dual_cost_->set(cost_->dual());
19 }
20 
21 template<typename Real>
22 Real LinearObjective<Real>::value( const Vector<Real> &x, Real &tol ) {
23  return x.dot(*dual_cost_);
24 }
25 
26 template<typename Real>
28  g.set(*cost_);
29 }
30 
31 template<typename Real>
32 void LinearObjective<Real>::hessVec( Vector<Real> &hv, const Vector<Real> &v, const Vector<Real> &x, Real &tol ) {
33  hv.zero();
34 }
35 
36 } // namespace ROL
37 
38 #endif
void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol) override
Compute gradient.
const Ptr< const Vector< Real > > dual_cost_
virtual void zero()
Set to zero vector.
Definition: ROL_Vector.hpp:133
Defines the linear algebra or vector space interface.
Definition: ROL_Vector.hpp:46
virtual Real dot(const Vector &x) const =0
Compute where .
void hessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &x, Real &tol) override
Apply Hessian approximation to vector.
const Ptr< const Vector< Real > > cost_
Real value(const Vector< Real > &x, Real &tol) override
Compute value.
virtual void set(const Vector &x)
Set where .
Definition: ROL_Vector.hpp:175
LinearObjective(const Ptr< const Vector< Real >> &cost)