SOPT
Sparse OPTimisation
objective_functions.h
Go to the documentation of this file.
1 #ifndef SOPT_OBJECTIVE_FUNCTION_H
2 #define SOPT_OBJECTIVE_FUNCTION_H
3 #include "sopt/config.h"
4 #include <functional>
5 #include <type_traits>
6 #include "sopt/exception.h"
8 #include "sopt/logging.h"
9 #include "sopt/maths.h"
10 #include "sopt/types.h"
11 
14 template <typename T>
15 std::function<t_real(T)> const unconstrained_regularisation(
16  const std::function<t_real(T)> &g, const t_real &sig, const T &y,
17  const sopt::OperatorFunction<T> &measurement_operator);
19 template <typename T>
20 std::function<t_real(T)> const unconstrained_L1_regularisation(
21  const t_real &gamma, const t_real &sig, const T &y,
22  const sopt::OperatorFunction<T> &measurement_operator,
23  const sopt::LinearTransform<T> &wavelet_operator);
24 template <typename T>
25 std::function<t_real(T)> const unconstrained_regularisation(
26  const std::function<t_real(T)> &g, const t_real &sig, const T &y,
27  const sopt::LinearTransform<T> &measurement_operator);
28 template <typename T>
29 std::function<t_real(T)> const unconstrained_l1_regularisation(
30  const t_real &gamma, const t_real &sig, const T &y,
31  const sopt::LinearTransform<T> &measurement_operator,
32  const sopt::LinearTransform<T> &wavelet_operator);
33 
34 template <typename T>
35 std::function<t_real(T)> const unconstrained_regularisation(
36  const std::function<t_real(T)> &g, const t_real &sig, const T &y,
37  const sopt::LinearTransform<T> &measurement_operator) {
38  return [=](const T &x) -> t_real {
39  return g(x) + 0.5 * std::pow(sopt::l2_norm(y - measurement_operator * x) / sig, 2);
40  };
41 }
42 template <typename T>
43 std::function<t_real(T)> const unconstrained_l1_regularisation(
44  const t_real &gamma, const t_real &sig, const T &y,
45  const sopt::LinearTransform<T> &measurement_operator,
46  const sopt::LinearTransform<T> &wavelet_operator) {
47  if (gamma <= 0) SOPT_THROW("regularsiation paramter is not greater than 0.");
48  const std::function<t_real(T)> g = [=](const T &x) -> t_real {
49  return sopt::l1_norm(wavelet_operator.adjoint() * x) * gamma;
50  };
51  return unconstrained_regularisation<T>(g, sig, y, measurement_operator);
52 }
53 template <typename T>
54 std::function<t_real(T)> const unconstrained_regularisation(
55  const std::function<t_real(T)> &g, const t_real &sig, const T &y,
56  const sopt::OperatorFunction<T> &measurement_operator) {
57  const LinearTransform<T> mop = {measurement_operator, measurement_operator};
58  return unconstrained_regularisation<T>(g, sig, mop * y, mop);
59 }
60 template <typename T>
61 std::function<t_real(T)> const unconstrained_l1_regularisation(
62  const t_real &gamma, const t_real &sig, const T &y,
63  const sopt::OperatorFunction<T> &measurement_operator,
64  const sopt::LinearTransform<T> &wavelet_operator) {
65  const LinearTransform<T> mop = {measurement_operator, measurement_operator};
66  return unconstrained_l1_regularisation<T>(gamma, sig, mop * y, mop, wavelet_operator);
67 }
68 } // namespace sopt::objective_functions
69 #endif
Joins together direct and indirect operators.
LinearTransform< VECTOR > adjoint() const
Indirect transform.
#define SOPT_THROW(MSG)
Definition: exception.h:46
std::function< t_real(T)> const unconstrained_l1_regularisation(const t_real &gamma, const t_real &sig, const T &y, const sopt::LinearTransform< T > &measurement_operator, const sopt::LinearTransform< T > &wavelet_operator)
std::function< t_real(T)> const unconstrained_regularisation(const std::function< t_real(T)> &g, const t_real &sig, const T &y, const sopt::OperatorFunction< T > &measurement_operator)
returns g(x) + ||y - Φ x||_2^2 as a function
std::function< t_real(T)> const unconstrained_L1_regularisation(const t_real &gamma, const t_real &sig, const T &y, const sopt::OperatorFunction< T > &measurement_operator, const sopt::LinearTransform< T > &wavelet_operator)
returns ||ψ^t x||_1 + ||y - Φ x||_2^2 as a function
double t_real
Root of the type hierarchy for real numbers.
Definition: types.h:17
std::function< void(VECTOR &, VECTOR const &)> OperatorFunction
Typical function out = A*x.
Definition: types.h:43
real_type< typename T0::Scalar >::type l1_norm(Eigen::ArrayBase< T0 > const &input, Eigen::ArrayBase< T1 > const &weights)
Computes weighted L1 norm.
Definition: maths.h:116
real_type< typename T0::Scalar >::type l2_norm(Eigen::ArrayBase< T0 > const &input, Eigen::ArrayBase< T1 > const &weights)
Computes weighted L2 norm.
Definition: maths.h:140