SOPT
Sparse OPTimisation
Classes | Functions
sopt::algorithm Namespace Reference

Classes

class  ImagingForwardBackward
 
class  ImagingProximalADMM
 
class  ImagingPrimalDual
 
class  JointMAP
 
class  L1GProximal
 
class  L2ForwardBackward
 
class  ProximalADMM
 Proximal Alternate Direction method of mutltipliers. More...
 
class  PositiveQuadrant
 Computes according to given algorithm and then projects it to the positive quadrant. More...
 
class  PowerMethod
 Eigenvalue and eigenvector for eigenvalue with largest magnitude. More...
 
class  PrimalDual
 Primal Dual Algorithm. More...
 
class  RealIndicator
 
class  Reweighted
 L0-approximation algorithm, through reweighting. More...
 
class  SDMM
 Simultaneous-direction method of the multipliers. More...
 
class  TFGProximal
 
class  TVPrimalDual
 

Functions

template<typename ALGORITHM >
PositiveQuadrant< ALGORITHM > positive_quadrant (ALGORITHM const &algo)
 Extended algorithm where the solution is projected on the positive quadrant. More...
 
template<typename T >
std::tuple< t_real, T > power_method (const sopt::LinearTransform< T > &op, const t_uint niters, const t_real relative_difference, const T &initial_vector)
 Returns the eigenvalue and eigenvector for eigenvalue of the Linear Transform with largest magnitude. More...
 
template<typename T >
std::tuple< t_real, T, std::shared_ptr< sopt::LinearTransform< T > > > normalise_operator (const std::shared_ptr< sopt::LinearTransform< T > const > &op, const t_uint &niters, const t_real &relative_difference, const T &initial_vector)
 
template<typename T >
std::tuple< t_real, T, sopt::LinearTransform< T > > normalise_operator (const sopt::LinearTransform< T > &op, const t_uint &niters, const t_real &relative_difference, const T &initial_vector)
 
template<typename ALGORITHM >
Reweighted< ALGORITHM > reweighted (ALGORITHM const &algo, typename Reweighted< ALGORITHM >::t_SetWeights const &set_weights, typename Reweighted< ALGORITHM >::t_Reweightee const &reweightee)
 Factory function to create an l0-approximation by reweighting an l1 norm. More...
 
template<typename T >
Eigen::CwiseUnaryOp< const details::ProjectPositiveQuadrant< typename T::Scalar >, const T > positive_quadrant (Eigen::DenseBase< T > const &input)
 
template<typename SCALAR >
Reweighted< PositiveQuadrant< ImagingProximalADMM< SCALAR > > > reweighted (ImagingProximalADMM< SCALAR > const &algo)
 
template<typename SCALAR >
Reweighted< PositiveQuadrant< PrimalDual< SCALAR > > > reweighted (PrimalDual< SCALAR > const &algo)
 

Function Documentation

◆ normalise_operator() [1/2]

template<typename T >
std::tuple<t_real, T, sopt::LinearTransform<T> > sopt::algorithm::normalise_operator ( const sopt::LinearTransform< T > &  op,
const t_uint niters,
const t_real relative_difference,
const T &  initial_vector 
)

Definition at line 75 of file power_method.h.

77  {
78  const std::shared_ptr<sopt::LinearTransform<T>> shared_op =
79  std::make_shared<sopt::LinearTransform<T>>(std::move(op));
80  const auto result = normalise_operator<T>(shared_op, niters, relative_difference, initial_vector);
81  const auto normed_shared_op = std::get<2>(result);
82  return std::make_tuple(std::get<0>(result), std::get<1>(result), *normed_shared_op);
83 }

◆ normalise_operator() [2/2]

template<typename T >
std::tuple<t_real, T, std::shared_ptr<sopt::LinearTransform<T> > > sopt::algorithm::normalise_operator ( const std::shared_ptr< sopt::LinearTransform< T > const > &  op,
const t_uint niters,
const t_real relative_difference,
const T &  initial_vector 
)

Definition at line 59 of file power_method.h.

61  {
62  const auto result = power_method(*op, niters, relative_difference, initial_vector.derived());
63  const t_real norm = std::get<0>(result);
64  return std::make_tuple(
65  std::get<0>(result), std::get<1>(result),
66  std::make_shared<sopt::LinearTransform<T>>(
67  [op, norm](T &output, const T &input) { output = static_cast<T>(*op * input) / norm; },
68  op->sizes(),
69  [op, norm](T &output, const T &input) {
70  output = static_cast<T>(op->adjoint() * input) / norm;
71  },
72  op->adjoint().sizes()));
73 }
Joins together direct and indirect operators.
sopt::t_real t_real
std::tuple< t_real, T > power_method(const sopt::LinearTransform< T > &op, const t_uint niters, const t_real relative_difference, const T &initial_vector)
Returns the eigenvalue and eigenvector for eigenvalue of the Linear Transform with largest magnitude.
Definition: power_method.h:23

References power_method().

◆ positive_quadrant() [1/2]

template<typename ALGORITHM >
PositiveQuadrant<ALGORITHM> sopt::algorithm::positive_quadrant ( ALGORITHM const &  algo)

Extended algorithm where the solution is projected on the positive quadrant.

Definition at line 59 of file positive_quadrant.h.

59  {
60  return {algo};
61 }

Referenced by sopt::algorithm::PositiveQuadrant< ALGORITHM >::operator()(), and reweighted().

◆ positive_quadrant() [2/2]

template<typename T >
Eigen::CwiseUnaryOp< const details::ProjectPositiveQuadrant< typename T::Scalar >, const T > sopt::algorithm::positive_quadrant ( Eigen::DenseBase< T > const &  input)

◆ power_method()

template<typename T >
std::tuple<t_real, T> sopt::algorithm::power_method ( const sopt::LinearTransform< T > &  op,
const t_uint  niters,
const t_real  relative_difference,
const T &  initial_vector 
)

Returns the eigenvalue and eigenvector for eigenvalue of the Linear Transform with largest magnitude.

Definition at line 23 of file power_method.h.

24  {
25  /*
26  Attempt at coding the power method, returns the sqrt of the largest eigen value of a linear
27  operator composed with its adjoint niters:: max number of iterations relative_difference::
28  percentage difference at which eigen value has converged
29  */
30  if (niters <= 0) return std::make_tuple(1., initial_vector);
31  t_real estimate_eigen_value = 1;
32  t_real old_value = 0;
33  T estimate_eigen_vector = initial_vector;
34  estimate_eigen_vector = estimate_eigen_vector / estimate_eigen_vector.matrix().stableNorm();
35  SOPT_DEBUG("Starting power method");
36  SOPT_DEBUG(" -[PM] Iteration: 0, norm = {}", estimate_eigen_value);
37  bool converged = false;
38  ScalarRelativeVariation<t_real> scalvar(relative_difference, 0., "Eigenvalue");
39  for (t_int i = 0; i < niters; ++i) {
40  estimate_eigen_vector = op.adjoint() * static_cast<T>(op * estimate_eigen_vector);
41  estimate_eigen_value = estimate_eigen_vector.matrix().stableNorm();
42  if (estimate_eigen_value <= 0) throw std::runtime_error("Error in operator.");
43  if (estimate_eigen_value != estimate_eigen_value)
44  throw std::runtime_error("Error in operator or data corrupted.");
45  estimate_eigen_vector = estimate_eigen_vector / estimate_eigen_value;
46  SOPT_DEBUG(" -[PM] Iteration: {}, norm = {}", i + 1, estimate_eigen_value);
47  converged = scalvar(std::sqrt(estimate_eigen_value));
48  old_value = estimate_eigen_value;
49  if (converged) {
50  SOPT_DEBUG("Converged to norm = {}, relative difference < {}", std::sqrt(old_value),
51  relative_difference);
52  break;
53  }
54  }
55  return std::make_tuple(std::sqrt(old_value), estimate_eigen_vector);
56 }
LinearTransform< VECTOR > adjoint() const
Indirect transform.
#define SOPT_DEBUG(...)
\macro Output some debugging
Definition: logging.h:217
int t_int
Root of the type hierarchy for signed integers.
Definition: types.h:13

References sopt::LinearTransform< VECTOR >::adjoint(), and SOPT_DEBUG.

Referenced by normalise_operator().

◆ reweighted() [1/3]

template<typename ALGORITHM >
Reweighted< ALGORITHM > sopt::algorithm::reweighted ( ALGORITHM const &  algo,
typename Reweighted< ALGORITHM >::t_SetWeights const &  set_weights,
typename Reweighted< ALGORITHM >::t_Reweightee const &  reweightee 
)

Factory function to create an l0-approximation by reweighting an l1 norm.

Definition at line 238 of file reweighted.h.

240  {
241  return {algo, set_weights, reweightee};
242 }

Referenced by main(), and TEST_CASE().

◆ reweighted() [2/3]

template<typename SCALAR >
Reweighted<PositiveQuadrant<ImagingProximalADMM<SCALAR> > > sopt::algorithm::reweighted ( ImagingProximalADMM< SCALAR > const &  algo)

Definition at line 253 of file reweighted.h.

254  {
255  auto const posq = positive_quadrant(algo);
256  using Algorithm = typename std::remove_const<decltype(posq)>::type;
257  using RW = Reweighted<Algorithm>;
258  auto const reweightee =
259  [](Algorithm const &posq, typename RW::XVector const &x) -> typename RW::XVector {
260  return posq.algorithm().Psi().adjoint() * x;
261  };
262  auto const set_weights = [](Algorithm &posq, typename RW::WeightVector const &weights) -> void {
263  posq.algorithm().l1_proximal_weights(weights);
264  };
265  return {posq, set_weights, reweightee};
266 }
Eigen::CwiseUnaryOp< const details::ProjectPositiveQuadrant< typename T::Scalar >, const T > positive_quadrant(Eigen::DenseBase< T > const &input)

References sopt::algorithm::Reweighted< ALGORITHM >::algorithm(), and positive_quadrant().

◆ reweighted() [3/3]

template<typename SCALAR >
Reweighted<PositiveQuadrant<PrimalDual<SCALAR> > > sopt::algorithm::reweighted ( PrimalDual< SCALAR > const &  algo)

Definition at line 277 of file reweighted.h.

277  {
278  auto const posq = positive_quadrant(algo);
279  using Algorithm = typename std::remove_const<decltype(posq)>::type;
280  using RW = Reweighted<Algorithm>;
281  auto const reweightee =
282  [](Algorithm const &posq, typename RW::XVector const &x) -> typename RW::XVector {
283  return posq.algorithm().Psi().adjoint() * x;
284  };
285  auto const set_weights = [](Algorithm &posq, typename RW::WeightVector const &weights) -> void {
286  posq.algorithm().l1_proximal_weights(weights);
287  };
288  return {posq, set_weights, reweightee};
289 }

References sopt::algorithm::Reweighted< ALGORITHM >::algorithm(), and positive_quadrant().