SOPT
Sparse OPTimisation
Namespaces | Classes | Typedefs | Functions
sopt::proximal Namespace Reference

Holds some standard proximals. More...

Namespaces

 details
 

Classes

class  L1TightFrame
 L1 proximal, including linear transform. More...
 
class  L1
 L1 proximal, including linear transform. More...
 
class  EuclidianNorm
 Proximal of euclidian norm. More...
 
class  L2Norm
 Proximal for the L2 norm. More...
 
class  L2Ball
 Proximal for indicator function of L2 ball. More...
 
class  WeightedL2Ball
 
class  Translation
 Translation over proximal function. More...
 

Typedefs

template<typename FUNC , typename T0 >
using ProximalExpression = details::DelayedProximalFunction< FUNC, Eigen::MatrixBase< T0 > >
 Eigen expression from proximal functions. More...
 
template<typename FUNC , typename T0 >
using EnveloppeExpression = details::DelayedProximalEnveloppeFunction< FUNC, Eigen::MatrixBase< T0 > >
 Eigen expression from proximal enveloppe functions. More...
 

Functions

template<typename T0 >
auto euclidian_norm (typename real_type< typename T0::Scalar >::type const &t, Eigen::MatrixBase< T0 > const &x) -> decltype(EuclidianNorm(), t, x)
 Proximal of the euclidian norm. More...
 
template<typename T0 , typename T1 >
void l1_norm (Eigen::DenseBase< T0 > &out, typename real_type< typename T0::Scalar >::type gamma, Eigen::DenseBase< T1 > const &x)
 Proximal of the l1 norm. More...
 
template<typename T0 , typename T1 , typename T2 >
void l1_norm (Eigen::DenseBase< T0 > &out, Eigen::DenseBase< T2 > const &gamma, Eigen::DenseBase< T1 > const &x)
 Proxmal of the weighted l1 norm. More...
 
template<typename S >
void l1_norm (Vector< S > &out, typename real_type< S >::type gamma, Vector< S > const &x)
 Proximal of the l1 norm \detail This specialization makes it easier to use in algorithms, e.g. within SDMM::append. More...
 
template<typename T0 , typename T1 >
void l2_norm (Eigen::DenseBase< T0 > &out, typename real_type< typename T0::Scalar >::type gamma, Eigen::DenseBase< T1 > const &x)
 Proximal of the l2 norm (note this is different from the l2 ball indicator function) More...
 
template<typename T0 , typename T1 , typename T2 >
void l2_norm (Eigen::DenseBase< T0 > &out, Eigen::DenseBase< T2 > const &gamma, Eigen::DenseBase< T1 > const &x)
 
template<typename T0 , typename T1 >
void tv_norm (Eigen::DenseBase< T0 > &out, typename real_type< typename T0::Scalar >::type gamma, Eigen::DenseBase< T1 > const &x)
 Proximal of the l1,2 norm that is used in the TV norm. More...
 
template<typename T0 , typename T1 , typename T2 >
void tv_norm (Eigen::DenseBase< T0 > &out, Eigen::DenseBase< T2 > const &gamma, Eigen::DenseBase< T1 > const &x)
 
template<typename T0 , typename T1 >
void id (Eigen::DenseBase< T0 > &out, typename real_type< typename T0::Scalar >::type gamma, Eigen::DenseBase< T1 > const &x)
 Proximal of a function that is always zero, the identity. More...
 
template<typename T >
auto l1_norm (typename real_type< typename T::Scalar >::type gamma, Eigen::DenseBase< T > const &x) -> decltype(sopt::soft_threshhold(x, gamma))
 Proximal of l1 norm. More...
 
template<typename T >
void positive_quadrant (Vector< T > &out, typename real_type< T >::type, Vector< T > const &x)
 Proximal for projection on the positive quadrant. More...
 
template<typename FUNCTION , typename VECTOR >
Translation< FUNCTION, VECTOR > translate (FUNCTION const &func, VECTOR const &translation)
 Translates given proximal by given vector. More...
 

Detailed Description

Holds some standard proximals.

Typedef Documentation

◆ EnveloppeExpression

template<typename FUNC , typename T0 >
using sopt::proximal::EnveloppeExpression = typedef details::DelayedProximalEnveloppeFunction<FUNC, Eigen::MatrixBase<T0> >

Eigen expression from proximal enveloppe functions.

Definition at line 87 of file proximal_expression.h.

◆ ProximalExpression

template<typename FUNC , typename T0 >
using sopt::proximal::ProximalExpression = typedef details::DelayedProximalFunction<FUNC, Eigen::MatrixBase<T0> >

Eigen expression from proximal functions.

Definition at line 84 of file proximal_expression.h.

Function Documentation

◆ euclidian_norm()

template<typename T0 >
auto sopt::proximal::euclidian_norm ( typename real_type< typename T0::Scalar >::type const &  t,
Eigen::MatrixBase< T0 > const &  x 
) -> decltype(EuclidianNorm(), t, x)

Proximal of the euclidian norm.

Definition at line 57 of file proximal.h.

58  {
59  return EuclidianNorm()(t, x);
60 }

◆ id()

template<typename T0 , typename T1 >
void sopt::proximal::id ( Eigen::DenseBase< T0 > &  out,
typename real_type< typename T0::Scalar >::type  gamma,
Eigen::DenseBase< T1 > const &  x 
)

Proximal of a function that is always zero, the identity.

Definition at line 135 of file proximal.h.

136  {
137  out = x;
138 }

Referenced by TEST_CASE().

◆ l1_norm() [1/4]

template<typename T0 , typename T1 , typename T2 >
void sopt::proximal::l1_norm ( Eigen::DenseBase< T0 > &  out,
Eigen::DenseBase< T2 > const &  gamma,
Eigen::DenseBase< T1 > const &  x 
)

Proxmal of the weighted l1 norm.

Definition at line 70 of file proximal.h.

71  {
72  out = sopt::soft_threshhold<T0, T2>(x, gamma);
73 }

◆ l1_norm() [2/4]

template<typename T0 , typename T1 >
void sopt::proximal::l1_norm ( Eigen::DenseBase< T0 > &  out,
typename real_type< typename T0::Scalar >::type  gamma,
Eigen::DenseBase< T1 > const &  x 
)

Proximal of the l1 norm.

Definition at line 64 of file proximal.h.

65  {
66  out = sopt::soft_threshhold<T0>(x, gamma);
67 }

Referenced by TEST_CASE().

◆ l1_norm() [3/4]

template<typename T >
auto sopt::proximal::l1_norm ( typename real_type< typename T::Scalar >::type  gamma,
Eigen::DenseBase< T > const &  x 
) -> decltype(sopt::soft_threshhold(x, gamma))

Proximal of l1 norm.

For more complex version involving linear transforms and weights, see L1TightFrame and L1 classes. In practice, this is an alias for soft_threshhold.

Definition at line 144 of file proximal.h.

145  {
146  return sopt::soft_threshhold(x, gamma);
147 }
std::enable_if< std::is_arithmetic< SCALAR >::value or is_complex< SCALAR >::value, SCALAR >::type soft_threshhold(SCALAR const &x, typename real_type< SCALAR >::type const &threshhold)
abs(x) < threshhold ? 0: x - sgn(x) * threshhold
Definition: maths.h:29

References sopt::soft_threshhold().

◆ l1_norm() [4/4]

template<typename S >
void sopt::proximal::l1_norm ( Vector< S > &  out,
typename real_type< S >::type  gamma,
Vector< S > const &  x 
)

Proximal of the l1 norm \detail This specialization makes it easier to use in algorithms, e.g. within SDMM::append.

Definition at line 78 of file proximal.h.

78  {
79  l1_norm<Vector<S>, Vector<S>>(out, gamma, x);
80 }
sopt::Vector< Scalar > Vector
Definition: inpainting.cc:28

◆ l2_norm() [1/2]

template<typename T0 , typename T1 , typename T2 >
void sopt::proximal::l2_norm ( Eigen::DenseBase< T0 > &  out,
Eigen::DenseBase< T2 > const &  gamma,
Eigen::DenseBase< T1 > const &  x 
)

Definition at line 90 of file proximal.h.

91  {
92  out = x.derived().array() * 1. / (1. + gamma.derived().array()).array();
93 }

Referenced by sopt::proximal::L2Ball< T >::operator()(), sopt::proximal::WeightedL2Ball< T >::operator()(), and sopt::proximal::EuclidianNorm::operator()().

◆ l2_norm() [2/2]

template<typename T0 , typename T1 >
void sopt::proximal::l2_norm ( Eigen::DenseBase< T0 > &  out,
typename real_type< typename T0::Scalar >::type  gamma,
Eigen::DenseBase< T1 > const &  x 
)

Proximal of the l2 norm (note this is different from the l2 ball indicator function)

Definition at line 84 of file proximal.h.

85  {
86  out = x.derived() * 1. / (1. + gamma);
87 }

Referenced by sopt::algorithm::ImagingPrimalDual< SCALAR >::ImagingPrimalDual(), and sopt::proximal::L2Norm< T >::operator()().

◆ positive_quadrant()

template<typename T >
void sopt::proximal::positive_quadrant ( Vector< T > &  out,
typename real_type< T >::type  ,
Vector< T > const &  x 
)

Proximal for projection on the positive quadrant.

Definition at line 151 of file proximal.h.

151  {
152  out = sopt::positive_quadrant(x);
153 };
Eigen::CwiseUnaryOp< const details::ProjectPositiveQuadrant< typename T::Scalar >, const T > positive_quadrant(Eigen::DenseBase< T > const &input)
Expression to create projection onto positive quadrant.
Definition: maths.h:60

References sopt::positive_quadrant().

◆ translate()

template<typename FUNCTION , typename VECTOR >
Translation<FUNCTION, VECTOR> sopt::proximal::translate ( FUNCTION const &  func,
VECTOR const &  translation 
)

Translates given proximal by given vector.

Definition at line 362 of file proximal.h.

362  {
363  return Translation<FUNCTION, VECTOR>(func, translation);
364 }

Referenced by main(), SCENARIO(), and TEST_CASE().

◆ tv_norm() [1/2]

template<typename T0 , typename T1 , typename T2 >
void sopt::proximal::tv_norm ( Eigen::DenseBase< T0 > &  out,
Eigen::DenseBase< T2 > const &  gamma,
Eigen::DenseBase< T1 > const &  x 
)

Definition at line 115 of file proximal.h.

116  {
117  typename Eigen::Index const size = x.size() / 2;
118  typename T1::PlainObject const &u = x.segment(0, size);
119  typename T1::PlainObject const &v = x.segment(size, size);
120  out = T0::Zero(size * 2);
121  for (typename Eigen::Index i(0); i < size; i++) {
122  const t_real norm = std::sqrt(std::abs(u(i) * u(i) + v(i) * v(i)));
123  if (norm > gamma(i)) {
124  out(i) = (1 - gamma(i) / norm) * u(i);
125  out(size + i) = (1 - gamma(i) / norm) * v(i);
126  } else {
127  out(i) = 0;
128  out(size + i) = 0;
129  }
130  }
131 }
sopt::t_real t_real

◆ tv_norm() [2/2]

template<typename T0 , typename T1 >
void sopt::proximal::tv_norm ( Eigen::DenseBase< T0 > &  out,
typename real_type< typename T0::Scalar >::type  gamma,
Eigen::DenseBase< T1 > const &  x 
)

Proximal of the l1,2 norm that is used in the TV norm.

Definition at line 97 of file proximal.h.

98  {
99  typename Eigen::Index const size = x.size() / 2;
100  typename T1::PlainObject const &u = x.segment(0, size);
101  typename T1::PlainObject const &v = x.segment(size, size);
102  out = T0::Zero(size * 2);
103  for (typename Eigen::Index i(0); i < size; i++) {
104  const t_real norm = std::sqrt(std::abs(u(i) * u(i) + v(i) * v(i)));
105  if (norm > gamma) {
106  out(i) = (1 - gamma / norm) * u(i);
107  out(size + i) = (1 - gamma / norm) * v(i);
108  } else {
109  out(i) = 0;
110  out(size + i) = 0;
111  }
112  }
113 }