SOPT
Sparse OPTimisation
Functions
soft_threshhold.cc File Reference
#include "sopt/maths.h"
#include "sopt/types.h"
+ Include dependency graph for soft_threshhold.cc:

Go to the source code of this file.

Functions

int main (int, char const **)
 

Function Documentation

◆ main()

int main ( int  ,
char const **   
)

Definition at line 4 of file soft_threshhold.cc.

4  {
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

References sopt::soft_threshhold().