SOPT
Sparse OPTimisation
l2_differentiable_func.h
Go to the documentation of this file.
1 #ifndef L2_DIFFERENTIABLE_FUNC
2 #define L2_DIFFERENTIABLE_FUNC
3 
5 
6 namespace sopt
7 {
8 
9 
10 template<typename SCALAR>
12 {
14  using Real = typename DifferentiableFunc<SCALAR>::Real;
15  using Vector = typename DifferentiableFunc<SCALAR>::t_Vector;
16  using LinearTransform = typename DifferentiableFunc<SCALAR>::t_LinearTransform;
17 
18  public:
19  L2DifferentiableFunc (const Real sigma,
20  const LinearTransform& Phi): LT(Phi), sigma(sigma)
21  {
22  this->step_size = 0.98*sigma*sigma;
23  }
24 
25  void log_message() const override
26  {
27  SOPT_HIGH_LOG("Using L2 differentiable function f(x)");
28  }
29 
30  void gradient(Vector &output, const Vector &image, const Vector &residual,
31  const LinearTransform &Phi) override
32  {
33  output = Phi.adjoint() * (residual / (sigma * sigma)); // L2 norm
34  }
35 
36  Real function(Vector const &image, Vector const &y, LinearTransform const &Phi) override
37  {
38  // Does this need to be modified to take into account MPI?
39  Real Likelihood = 0.5 * ((Phi*image) - y).squaredNorm() / (sigma * sigma);
40  return Likelihood;
41  }
42 
43  private:
44  Real sigma;
45  const LinearTransform &LT;
46 };
47 
48 } // namespace sopt
49 #endif
typename FB::t_LinearTransform t_LinearTransform
typename FB::t_Gradient t_Gradient
typename FB::Real Real
typename FB::t_Vector t_Vector
void log_message() const override
L2DifferentiableFunc(const Real sigma, const LinearTransform &Phi)
void gradient(Vector &output, const Vector &image, const Vector &residual, const LinearTransform &Phi) override
Joins together direct and indirect operators.
#define SOPT_HIGH_LOG(...)
High priority message.
Definition: logging.h:223
real_type< T >::type sigma(sopt::LinearTransform< Vector< T >> const &sampling, sopt::Image< T > const &image)
Definition: inpainting.h:17