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
15namespace ROL {
16
17template<typename Real>
18class ShiftedProxObjective : public ProxObjective<Real> {
19private:
20 const Ptr<ProxObjective<Real>> prox_;
21 const Ptr<Vector<Real>> x_, xtmp_;
22
23public:
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
const Ptr< Vector< Real > > x_
const Ptr< Vector< Real > > xtmp_
void prox(Vector< Real > &x, Real gamma) override
const Ptr< ProxObjective< Real > > prox_
Real value(const Vector< Real > x, Real &tol) override
void setX(const Vector< Real > &x)
ShiftedProxObjective(const Ptr< ProxObjective< Real > > &prox, const Ptr< Vector< Real > > &x)
void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol) override
Compute gradient.
Defines the linear algebra or vector space interface.
virtual void plus(const Vector &x)=0
Compute , where .
virtual void axpy(const Real alpha, const Vector &x)
Compute where .