SOPT
Sparse OPTimisation
soft_threshhold.cc
Go to the documentation of this file.
1 #include "sopt/maths.h"
2 #include "sopt/types.h"
3 
4 int main(int, char const **) {
5  sopt::Array<> input(6);
6  input << 1e1, 2e1, 3e1, 4e1, 1e4, 2e4;
7 
8  if (not(sopt::soft_threshhold(input, 2.5e1).head(2).array() < 1e-8).all()) throw std::exception();
9  if (not(sopt::soft_threshhold(input, 2.5e1).tail(4).array() > 1e-8).all()) throw std::exception();
10 
11  return 0;
12 }
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
Eigen::Array< T, Eigen::Dynamic, 1 > Array
A 1-dimensional list of elements of given type.
Definition: types.h:34
int main(int, char const **)