SOPT
Sparse OPTimisation
l1_proximal.cc
Go to the documentation of this file.
1 #include <sstream>
2 #include <benchmark/benchmark.h>
3 #include "sopt/l1_proximal.h"
4 #include "sopt/real_type.h"
5 #include "sopt/types.h"
6 
7 template <typename TYPE>
8 void function_l1p(benchmark::State &state) {
9  using Real = typename sopt::real_type<TYPE>::type;
10  auto const N = state.range_x();
11  auto const input = sopt::Vector<TYPE>::Random(N).eval();
12  auto const Psi = sopt::Matrix<TYPE>::Random(input.size(), input.size() * 10).eval();
13  sopt::Vector<Real> const weights =
14  sopt::Vector<TYPE>::Random(Psi.cols()).normalized().array().abs();
15 
16  auto const l1 = sopt::proximal::L1<TYPE>()
17  .tolerance(std::pow(10, -state.range_y()))
18  .itermax(100)
19  .fista_mixing(true)
20  .positivity_constraint(true)
21  .nu(1)
22  .Psi(Psi)
23  .weights(weights);
24 
25  Real const gamma = 1e-2 / Psi.array().abs().sum();
26  auto output = sopt::Vector<TYPE>::Zero(N).eval();
27  while (state.KeepRunning()) l1(output, gamma, input);
28  state.SetBytesProcessed(int64_t(state.iterations()) * int64_t(N) * sizeof(TYPE));
29 }
30 
31 BENCHMARK_TEMPLATE(function_l1p, sopt::t_complex)->RangePair(1, 256, 4, 12)->UseRealTime();
32 BENCHMARK_TEMPLATE(function_l1p, sopt::t_real)->RangePair(1, 256, 4, 12)->UseRealTime();
33 
BENCHMARK_TEMPLATE(function_l1p, sopt::t_complex) -> RangePair(1, 256, 4, 12) ->UseRealTime()
BENCHMARK_MAIN()
void function_l1p(benchmark::State &state)
Definition: l1_proximal.cc:8
constexpr auto N
Definition: wavelets.cc:57
Computes inner-most element type.
Definition: real_type.h:42
L1 proximal, including linear transform.
Definition: l1_proximal.h:169
Real nu() const
Bounds on the squared norm of the operator Ψ
Definition: l1_proximal.h:294
double t_real
Root of the type hierarchy for real numbers.
Definition: types.h:17
Eigen::Matrix< T, Eigen::Dynamic, 1 > Vector
A vector of a given type.
Definition: types.h:24
std::complex< t_real > t_complex
Root of the type hierarchy for (real) complex numbers.
Definition: types.h:19
Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > Matrix
A matrix of a given type.
Definition: types.h:29