ROL
ROL_ShiftedProxObjective.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_SHIFTEDPROXOBJECTIVE_HPP
11 #define ROL_SHIFTEDPROXOBJECTIVE_HPP
12 
13 #include "ROL_ProxObjective.hpp"
14 
15 namespace ROL {
16 
17 template<typename Real>
18 class ShiftedProxObjective : public ProxObjective<Real> {
19 private:
20  const Ptr<ProxObjective<Real>> prox_;
21  const Ptr<Vector<Real>> x_, xtmp_;
22 
23 public:
25  : prox_(prox), x_(x->clone()), xtmp_(x->clone()) {}
26 
27  void setX(const Vector<Real> &x) {
28  x_->set(x);
29  }
30 
31  Real value(const Vector<Real> x, Real &tol) override {
32  xtmp_->set(*x_); xtmp_->plus(x);
33  return prox_->(*xtmp_,tol);
34  }
35 
36  void gradient(Vector<Real> &g, const Vector<Real> &x, Real &tol) override {
37  xtmp_->set(*x_); xtmp_->plus(x);
38  prox_->gradient(g,*xtmp_,tol);
39  }
40 
41  void prox(Vector<Real> &x, Real gamma) override {
42  x.plus(*x_);
43  prox_->prox(x,gamma);
44  x.axpy(static_cast<Real>(-1),*x_);
45  }
46 
47 };
48 
49 }
50 
51 #endif
virtual void plus(const Vector &x)=0
Compute , where .
virtual void axpy(const Real alpha, const Vector &x)
Compute where .
Definition: ROL_Vector.hpp:119
ShiftedProxObjective(const Ptr< ProxObjective< Real >> &prox, const Ptr< Vector< Real >> &x)
Defines the linear algebra or vector space interface.
Definition: ROL_Vector.hpp:46
const Ptr< Vector< Real > > xtmp_
Real value(const Vector< Real > x, Real &tol) override
void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol) override
Compute gradient.
const Ptr< Vector< Real > > x_
const Ptr< ProxObjective< Real > > prox_
void prox(Vector< Real > &x, Real gamma) override
void setX(const Vector< Real > &x)