SOPT
Sparse OPTimisation
sara.cc
Go to the documentation of this file.
1 #include "sopt/wavelets/sara.h"
2 
3 int main(int, char const **) {
4  // Creates SARA with two wavelets
5  using t_i = std::tuple<std::string, sopt::t_uint>;
6  sopt::wavelets::SARA sara{t_i{"DB4", 5}, t_i{"DB8", 2}};
7 
8  // Then another one for good measure
9  sara.emplace_back("DB3", 7);
10 
11  // Creates a random signal
13  // Now gets its coefficients
14  auto coefficients = sara.direct(input);
15  // And transform back. We pass a pre-defined matrix explicitly to illustrate that API.
16  // But we could just store the return value as above.
17  sopt::Image<sopt::t_complex> recover; // This matrix will be resized if necessary
18  sara.indirect(coefficients, recover);
19 
20  // Check the reconstruction is corrrect
21  if (not input.isApprox(recover)) throw std::exception();
22 
23  // The coefficient for each wavelet basis is stored alongs columns:
24  sopt::Image<sopt::t_complex> const DB3_coeffs = sara[2].direct(input) / std::sqrt(sara.size());
25  if (not coefficients.rightCols(input.cols()).isApprox(DB3_coeffs)) throw std::exception();
26 
27  return 0;
28 }
Sparsity Averaging Reweighted Analysis.
Definition: sara.h:20
void emplace_back(std::string const &name, t_uint nlevels)
Adds a wavelet of specific type.
Definition: sara.h:114
int main(int, char const **)
Definition: sara.cc:3
Eigen::Array< T, Eigen::Dynamic, Eigen::Dynamic > Image
A 2-dimensional list of elements of given type.
Definition: types.h:39